openfox 2.0.0-beta.4 → 2.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/{chat-handler-IUWEBZG7.js → chat-handler-27FY5TEH.js} +15 -29
  2. package/dist/{chunk-WBYS7AQN.js → chunk-3FFHHYWP.js} +178 -99
  3. package/dist/{chunk-HGAMIPFO.js → chunk-7FDY3EOH.js} +18 -176
  4. package/dist/{chunk-CEZNMLOO.js → chunk-7TTEGAO6.js} +12 -13
  5. package/dist/{chunk-FQLK5GL5.js → chunk-BVHFMAVN.js} +1 -1
  6. package/dist/{chunk-HW3U4XSZ.js → chunk-CDDMHSZF.js} +4 -4
  7. package/dist/{chunk-HHAJ3QF6.js → chunk-EMJGF3A7.js} +9 -24
  8. package/dist/{chunk-KEF4O3UM.js → chunk-FRCLNAE2.js} +2952 -3256
  9. package/dist/{chunk-RF2JGDSS.js → chunk-IGSZUXQP.js} +3 -3
  10. package/dist/{chunk-HLZV4S2I.js → chunk-NPHYEUYE.js} +127 -35
  11. package/dist/{chunk-NNEHZT3V.js → chunk-QUSUEN5R.js} +3 -3
  12. package/dist/{chunk-EYCCASW3.js → chunk-R3EK3ODJ.js} +6 -6
  13. package/dist/{chunk-7IKUIYFZ.js → chunk-RBJ25FIR.js} +135 -147
  14. package/dist/{chunk-PSJIT5LZ.js → chunk-RFNEDBVO.js} +4 -4
  15. package/dist/chunk-RI6GAMNP.js +13 -0
  16. package/dist/{chunk-26DZZZDC.js → chunk-XJEOP6XU.js} +5 -11
  17. package/dist/cli/dev.js +1 -1
  18. package/dist/cli/index.js +1 -1
  19. package/dist/compactor-TDNRM3A7.js +9 -0
  20. package/dist/{config-YU7NYZYG.js → config-VBBMTXJZ.js} +5 -6
  21. package/dist/{events-YO52472Q.js → events-PQ3KTI5H.js} +8 -8
  22. package/dist/{folding-K5L6M4WK.js → folding-CXORTBAU.js} +2 -3
  23. package/dist/{orchestrator-F75DNQKQ.js → orchestrator-QDCVUBCL.js} +18 -23
  24. package/dist/package.json +1 -1
  25. package/dist/{processor-FTEASNGS.js → processor-K4B7QRO2.js} +8 -10
  26. package/dist/{protocol-K62EPEGS.js → protocol-CN24IKQN.js} +3 -5
  27. package/dist/{protocol-BQ12Aw5J.d.ts → protocol-De-Pzgry.d.ts} +12 -38
  28. package/dist/{provider-HTJEB3ON.js → provider-NRWSSO55.js} +9 -10
  29. package/dist/{serve-CEQ2QMM5.js → serve-J6EM3G6N.js} +25 -27
  30. package/dist/server/index.d.ts +1 -6
  31. package/dist/server/index.js +15 -17
  32. package/dist/{settings-VRAOAPLA.js → settings-6XX56F3F.js} +2 -2
  33. package/dist/shared/index.d.ts +2 -2
  34. package/dist/shared/index.js +1 -1
  35. package/dist/{tools-OPEU2E5M.js → tools-GCANYSB7.js} +12 -15
  36. package/dist/web/assets/{index-bDyDeCAz.css → index-aa3jRAZ9.css} +2 -2
  37. package/dist/web/assets/index-ntDiC8b_.js +299 -0
  38. package/dist/web/index.html +2 -2
  39. package/dist/web/sw.js +1 -1
  40. package/dist/workflow-defaults/default.workflow.json +3 -3
  41. package/package.json +1 -1
  42. package/dist/auto-compaction-A3PIMGLF.js +0 -28
  43. package/dist/chunk-CGZHLM3K.js +0 -70
  44. package/dist/chunk-MCPID4EJ.js +0 -28
  45. package/dist/chunk-SZKEGZIB.js +0 -140
  46. package/dist/optimize-storage-2N6BY5KZ.js +0 -7
  47. package/dist/runtime-config-NPSPMRDA.js +0 -9
  48. package/dist/vision-fallback-3MIZZ6NQ.js +0 -22
  49. package/dist/web/assets/index-ZTEHxmVW.js +0 -317
  50. /package/dist/web/{workbox-7fc22fbe.js → workbox-8c29f6e4.js} +0 -0
@@ -1,317 +0,0 @@
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 yA=Object.defineProperty;var vA=Object.getPrototypeOf;var bA=Reflect.get;var G0=e=>{throw TypeError(e)};var SA=(e,t,n)=>t in e?yA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ce=(e,t,n)=>SA(e,typeof t!="symbol"?t+"":t,n),gp=(e,t,n)=>t.has(e)||G0("Cannot "+n);var Un=(e,t,n)=>(gp(e,t,"read from private field"),n?n.call(e):t.get(e)),aa=(e,t,n)=>t.has(e)?G0("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Vr=(e,t,n,r)=>(gp(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_p=(e,t,n)=>(gp(e,t,"access private method"),n);var q0=(e,t,n)=>bA(vA(e),n,t);function wA(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const a=Object.getOwnPropertyDescriptor(r,s);a&&Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>r[s]})}}}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 s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function kh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xp={exports:{}},Gl={};/**
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 K0;function CA(){if(K0)return Gl;K0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,s,a){var l=null;if(a!==void 0&&(l=""+a),s.key!==void 0&&(l=""+s.key),"key"in s){a={};for(var d in s)d!=="key"&&(a[d]=s[d])}else a=s;return s=a.ref,{$$typeof:e,type:r,key:l,ref:s!==void 0?s:null,props:a}}return Gl.Fragment=t,Gl.jsx=n,Gl.jsxs=n,Gl}var Y0;function kA(){return Y0||(Y0=1,xp.exports=CA()),xp.exports}var c=kA(),yp={exports:{}},Ve={};/**
11
- * @license React
12
- * react.production.js
13
- *
14
- * Copyright (c) Meta Platforms, Inc. and affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- */var X0;function EA(){if(X0)return Ve;X0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),_=Symbol.iterator;function x(V){return V===null||typeof V!="object"?null:(V=_&&V[_]||V["@@iterator"],typeof V=="function"?V:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,w={};function k(V,K,O){this.props=V,this.context=K,this.refs=w,this.updater=O||v}k.prototype.isReactComponent={},k.prototype.setState=function(V,K){if(typeof V!="object"&&typeof V!="function"&&V!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,V,K,"setState")},k.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function j(){}j.prototype=k.prototype;function T(V,K,O){this.props=V,this.context=K,this.refs=w,this.updater=O||v}var A=T.prototype=new j;A.constructor=T,S(A,k.prototype),A.isPureReactComponent=!0;var P=Array.isArray;function R(){}var q={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function ne(V,K,O){var Q=O.ref;return{$$typeof:e,type:V,key:K,ref:Q!==void 0?Q:null,props:O}}function I(V,K){return ne(V.type,K,V.props)}function W(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function z(V){var K={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(O){return K[O]})}var L=/\/+/g;function U(V,K){return typeof V=="object"&&V!==null&&V.key!=null?z(""+V.key):K.toString(36)}function D(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(R,R):(V.status="pending",V.then(function(K){V.status==="pending"&&(V.status="fulfilled",V.value=K)},function(K){V.status==="pending"&&(V.status="rejected",V.reason=K)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function N(V,K,O,Q,G){var Z=typeof V;(Z==="undefined"||Z==="boolean")&&(V=null);var te=!1;if(V===null)te=!0;else switch(Z){case"bigint":case"string":case"number":te=!0;break;case"object":switch(V.$$typeof){case e:case t:te=!0;break;case p:return te=V._init,N(te(V._payload),K,O,Q,G)}}if(te)return G=G(V),te=Q===""?"."+U(V,0):Q,P(G)?(O="",te!=null&&(O=te.replace(L,"$&/")+"/"),N(G,K,O,"",function(Ce){return Ce})):G!=null&&(W(G)&&(G=I(G,O+(G.key==null||V&&V.key===G.key?"":(""+G.key).replace(L,"$&/")+"/")+te)),K.push(G)),1;te=0;var Se=Q===""?".":Q+":";if(P(V))for(var le=0;le<V.length;le++)Q=V[le],Z=Se+U(Q,le),te+=N(Q,K,O,Z,G);else if(le=x(V),typeof le=="function")for(V=le.call(V),le=0;!(Q=V.next()).done;)Q=Q.value,Z=Se+U(Q,le++),te+=N(Q,K,O,Z,G);else if(Z==="object"){if(typeof V.then=="function")return N(D(V),K,O,Q,G);throw K=String(V),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.")}return te}function F(V,K,O){if(V==null)return V;var Q=[],G=0;return N(V,Q,"","",function(Z){return K.call(O,Z,G++)}),Q}function H(V){if(V._status===-1){var K=V._result;K=K(),K.then(function(O){(V._status===0||V._status===-1)&&(V._status=1,V._result=O)},function(O){(V._status===0||V._status===-1)&&(V._status=2,V._result=O)}),V._status===-1&&(V._status=0,V._result=K)}if(V._status===1)return V._result.default;throw V._result}var se=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var K=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof V=="object"&&V!==null&&typeof V.message=="string"?String(V.message):String(V),error:V});if(!window.dispatchEvent(K))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",V);return}console.error(V)},B={map:F,forEach:function(V,K,O){F(V,function(){K.apply(this,arguments)},O)},count:function(V){var K=0;return F(V,function(){K++}),K},toArray:function(V){return F(V,function(K){return K})||[]},only:function(V){if(!W(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return Ve.Activity=g,Ve.Children=B,Ve.Component=k,Ve.Fragment=n,Ve.Profiler=s,Ve.PureComponent=T,Ve.StrictMode=r,Ve.Suspense=f,Ve.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=q,Ve.__COMPILER_RUNTIME={__proto__:null,c:function(V){return q.H.useMemoCache(V)}},Ve.cache=function(V){return function(){return V.apply(null,arguments)}},Ve.cacheSignal=function(){return null},Ve.cloneElement=function(V,K,O){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var Q=S({},V.props),G=V.key;if(K!=null)for(Z in K.key!==void 0&&(G=""+K.key),K)!J.call(K,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&K.ref===void 0||(Q[Z]=K[Z]);var Z=arguments.length-2;if(Z===1)Q.children=O;else if(1<Z){for(var te=Array(Z),Se=0;Se<Z;Se++)te[Se]=arguments[Se+2];Q.children=te}return ne(V.type,G,Q)},Ve.createContext=function(V){return V={$$typeof:l,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null},V.Provider=V,V.Consumer={$$typeof:a,_context:V},V},Ve.createElement=function(V,K,O){var Q,G={},Z=null;if(K!=null)for(Q in K.key!==void 0&&(Z=""+K.key),K)J.call(K,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(G[Q]=K[Q]);var te=arguments.length-2;if(te===1)G.children=O;else if(1<te){for(var Se=Array(te),le=0;le<te;le++)Se[le]=arguments[le+2];G.children=Se}if(V&&V.defaultProps)for(Q in te=V.defaultProps,te)G[Q]===void 0&&(G[Q]=te[Q]);return ne(V,Z,G)},Ve.createRef=function(){return{current:null}},Ve.forwardRef=function(V){return{$$typeof:d,render:V}},Ve.isValidElement=W,Ve.lazy=function(V){return{$$typeof:p,_payload:{_status:-1,_result:V},_init:H}},Ve.memo=function(V,K){return{$$typeof:h,type:V,compare:K===void 0?null:K}},Ve.startTransition=function(V){var K=q.T,O={};q.T=O;try{var Q=V(),G=q.S;G!==null&&G(O,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(R,se)}catch(Z){se(Z)}finally{K!==null&&O.types!==null&&(K.types=O.types),q.T=K}},Ve.unstable_useCacheRefresh=function(){return q.H.useCacheRefresh()},Ve.use=function(V){return q.H.use(V)},Ve.useActionState=function(V,K,O){return q.H.useActionState(V,K,O)},Ve.useCallback=function(V,K){return q.H.useCallback(V,K)},Ve.useContext=function(V){return q.H.useContext(V)},Ve.useDebugValue=function(){},Ve.useDeferredValue=function(V,K){return q.H.useDeferredValue(V,K)},Ve.useEffect=function(V,K){return q.H.useEffect(V,K)},Ve.useEffectEvent=function(V){return q.H.useEffectEvent(V)},Ve.useId=function(){return q.H.useId()},Ve.useImperativeHandle=function(V,K,O){return q.H.useImperativeHandle(V,K,O)},Ve.useInsertionEffect=function(V,K){return q.H.useInsertionEffect(V,K)},Ve.useLayoutEffect=function(V,K){return q.H.useLayoutEffect(V,K)},Ve.useMemo=function(V,K){return q.H.useMemo(V,K)},Ve.useOptimistic=function(V,K){return q.H.useOptimistic(V,K)},Ve.useReducer=function(V,K,O){return q.H.useReducer(V,K,O)},Ve.useRef=function(V){return q.H.useRef(V)},Ve.useState=function(V){return q.H.useState(V)},Ve.useSyncExternalStore=function(V,K,O){return q.H.useSyncExternalStore(V,K,O)},Ve.useTransition=function(){return q.H.useTransition()},Ve.version="19.2.4",Ve}var Q0;function Eh(){return Q0||(Q0=1,yp.exports=EA()),yp.exports}var C=Eh();const Li=kh(C),NA=wA({__proto__:null,default:Li},[C]);var vp={exports:{}},ql={},bp={exports:{}},Sp={};/**
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 J0;function jA(){return J0||(J0=1,(function(e){function t(N,F){var H=N.length;N.push(F);e:for(;0<H;){var se=H-1>>>1,B=N[se];if(0<s(B,F))N[se]=F,N[H]=B,H=se;else break e}}function n(N){return N.length===0?null:N[0]}function r(N){if(N.length===0)return null;var F=N[0],H=N.pop();if(H!==F){N[0]=H;e:for(var se=0,B=N.length,V=B>>>1;se<V;){var K=2*(se+1)-1,O=N[K],Q=K+1,G=N[Q];if(0>s(O,H))Q<B&&0>s(G,O)?(N[se]=G,N[Q]=H,se=Q):(N[se]=O,N[K]=H,se=K);else if(Q<B&&0>s(G,H))N[se]=G,N[Q]=H,se=Q;else break e}}return F}function s(N,F){var H=N.sortIndex-F.sortIndex;return H!==0?H:N.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,d=l.now();e.unstable_now=function(){return l.now()-d}}var f=[],h=[],p=1,g=null,_=3,x=!1,v=!1,S=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function A(N){for(var F=n(h);F!==null;){if(F.callback===null)r(h);else if(F.startTime<=N)r(h),F.sortIndex=F.expirationTime,t(f,F);else break;F=n(h)}}function P(N){if(S=!1,A(N),!v)if(n(f)!==null)v=!0,R||(R=!0,z());else{var F=n(h);F!==null&&D(P,F.startTime-N)}}var R=!1,q=-1,J=5,ne=-1;function I(){return w?!0:!(e.unstable_now()-ne<J)}function W(){if(w=!1,R){var N=e.unstable_now();ne=N;var F=!0;try{e:{v=!1,S&&(S=!1,j(q),q=-1),x=!0;var H=_;try{t:{for(A(N),g=n(f);g!==null&&!(g.expirationTime>N&&I());){var se=g.callback;if(typeof se=="function"){g.callback=null,_=g.priorityLevel;var B=se(g.expirationTime<=N);if(N=e.unstable_now(),typeof B=="function"){g.callback=B,A(N),F=!0;break t}g===n(f)&&r(f),A(N)}else r(f);g=n(f)}if(g!==null)F=!0;else{var V=n(h);V!==null&&D(P,V.startTime-N),F=!1}}break e}finally{g=null,_=H,x=!1}F=void 0}}finally{F?z():R=!1}}}var z;if(typeof T=="function")z=function(){T(W)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,U=L.port2;L.port1.onmessage=W,z=function(){U.postMessage(null)}}else z=function(){k(W,0)};function D(N,F){q=k(function(){N(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(N){N.callback=null},e.unstable_forceFrameRate=function(N){0>N||125<N?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<N?Math.floor(1e3/N):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_next=function(N){switch(_){case 1:case 2:case 3:var F=3;break;default:F=_}var H=_;_=F;try{return N()}finally{_=H}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(N,F){switch(N){case 1:case 2:case 3:case 4:case 5:break;default:N=3}var H=_;_=N;try{return F()}finally{_=H}},e.unstable_scheduleCallback=function(N,F,H){var se=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?se+H:se):H=se,N){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=H+B,N={id:p++,callback:F,priorityLevel:N,startTime:H,expirationTime:B,sortIndex:-1},H>se?(N.sortIndex=H,t(h,N),n(f)===null&&N===n(h)&&(S?(j(q),q=-1):S=!0,D(P,H-se))):(N.sortIndex=B,t(f,N),v||x||(v=!0,R||(R=!0,z()))),N},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(N){var F=_;return function(){var H=_;_=F;try{return N.apply(this,arguments)}finally{_=H}}}})(Sp)),Sp}var Z0;function TA(){return Z0||(Z0=1,bp.exports=jA()),bp.exports}var wp={exports:{}},In={};/**
27
- * @license React
28
- * react-dom.production.js
29
- *
30
- * Copyright (c) Meta Platforms, Inc. and affiliates.
31
- *
32
- * This source code is licensed under the MIT license found in the
33
- * LICENSE file in the root directory of this source tree.
34
- */var eS;function AA(){if(eS)return In;eS=1;var e=Eh();function t(f){var h="https://react.dev/errors/"+f;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+f+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},s=Symbol.for("react.portal");function a(f,h,p){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:g==null?null:""+g,children:f,containerInfo:h,implementation:p}}var l=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(f,h){if(f==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return In.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,In.createPortal=function(f,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return a(f,h,null,p)},In.flushSync=function(f){var h=l.T,p=r.p;try{if(l.T=null,r.p=2,f)return f()}finally{l.T=h,r.p=p,r.d.f()}},In.preconnect=function(f,h){typeof f=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(f,h))},In.prefetchDNS=function(f){typeof f=="string"&&r.d.D(f)},In.preinit=function(f,h){if(typeof f=="string"&&h&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin),_=typeof h.integrity=="string"?h.integrity:void 0,x=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(f,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:_,fetchPriority:x}):p==="script"&&r.d.X(f,{crossOrigin:g,integrity:_,fetchPriority:x,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},In.preinitModule=function(f,h){if(typeof f=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=d(h.as,h.crossOrigin);r.d.M(f,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(f)},In.preload=function(f,h){if(typeof f=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin);r.d.L(f,p,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},In.preloadModule=function(f,h){if(typeof f=="string")if(h){var p=d(h.as,h.crossOrigin);r.d.m(f,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(f)},In.requestFormReset=function(f){r.d.r(f)},In.unstable_batchedUpdates=function(f,h){return f(h)},In.useFormState=function(f,h,p){return l.H.useFormState(f,h,p)},In.useFormStatus=function(){return l.H.useHostTransitionStatus()},In.version="19.2.4",In}var tS;function IC(){if(tS)return wp.exports;tS=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(),wp.exports=AA(),wp.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 nS;function DA(){if(nS)return ql;nS=1;var e=TA(),t=Eh(),n=IC();function r(i){var o="https://react.dev/errors/"+i;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function a(i){var o=i,u=i;if(i.alternate)for(;o.return;)o=o.return;else{i=o;do o=i,(o.flags&4098)!==0&&(u=o.return),i=o.return;while(i)}return o.tag===3?u:null}function l(i){if(i.tag===13){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function d(i){if(i.tag===31){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function f(i){if(a(i)!==i)throw Error(r(188))}function h(i){var o=i.alternate;if(!o){if(o=a(i),o===null)throw Error(r(188));return o!==i?null:i}for(var u=i,m=o;;){var y=u.return;if(y===null)break;var b=y.alternate;if(b===null){if(m=y.return,m!==null){u=m;continue}break}if(y.child===b.child){for(b=y.child;b;){if(b===u)return f(y),i;if(b===m)return f(y),o;b=b.sibling}throw Error(r(188))}if(u.return!==m.return)u=y,m=b;else{for(var E=!1,M=y.child;M;){if(M===u){E=!0,u=y,m=b;break}if(M===m){E=!0,m=y,u=b;break}M=M.sibling}if(!E){for(M=b.child;M;){if(M===u){E=!0,u=b,m=y;break}if(M===m){E=!0,m=b,u=y;break}M=M.sibling}if(!E)throw Error(r(189))}}if(u.alternate!==m)throw Error(r(190))}if(u.tag!==3)throw Error(r(188));return u.stateNode.current===u?i:o}function p(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i;for(i=i.child;i!==null;){if(o=p(i),o!==null)return o;i=i.sibling}return null}var g=Object.assign,_=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),T=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),I=Symbol.for("react.memo_cache_sentinel"),W=Symbol.iterator;function z(i){return i===null||typeof i!="object"?null:(i=W&&i[W]||i["@@iterator"],typeof i=="function"?i:null)}var L=Symbol.for("react.client.reference");function U(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===L?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case S:return"Fragment";case k:return"Profiler";case w:return"StrictMode";case P:return"Suspense";case R:return"SuspenseList";case ne:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case v:return"Portal";case T:return i.displayName||"Context";case j:return(i._context.displayName||"Context")+".Consumer";case A:var o=i.render;return i=i.displayName,i||(i=o.displayName||o.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case q:return o=i.displayName||null,o!==null?o:U(i.type)||"Memo";case J:o=i._payload,i=i._init;try{return U(i(o))}catch{}}return null}var D=Array.isArray,N=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},se=[],B=-1;function V(i){return{current:i}}function K(i){0>B||(i.current=se[B],se[B]=null,B--)}function O(i,o){B++,se[B]=i.current,i.current=o}var Q=V(null),G=V(null),Z=V(null),te=V(null);function Se(i,o){switch(O(Z,o),O(G,i),O(Q,null),o.nodeType){case 9:case 11:i=(i=o.documentElement)&&(i=i.namespaceURI)?p0(i):0;break;default:if(i=o.tagName,o=o.namespaceURI)o=p0(o),i=g0(o,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(Q),O(Q,i)}function le(){K(Q),K(G),K(Z)}function Ce(i){i.memoizedState!==null&&O(te,i);var o=Q.current,u=g0(o,i.type);o!==u&&(O(G,i),O(Q,u))}function Re(i){G.current===i&&(K(Q),K(G)),te.current===i&&(K(te),Fl._currentValue=H)}var Oe,De;function Ue(i){if(Oe===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);Oe=o&&o[1]||"",De=-1<u.stack.indexOf(`
43
- at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
44
- `+Oe+i+De}var st=!1;function it(i,o){if(!i||st)return"";st=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={DetermineComponentFrameRoot:function(){try{if(o){var ge=function(){throw Error()};if(Object.defineProperty(ge.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ge,[])}catch(oe){var ae=oe}Reflect.construct(i,[],ge)}else{try{ge.call()}catch(oe){ae=oe}i.call(ge.prototype)}}else{try{throw Error()}catch(oe){ae=oe}(ge=i())&&typeof ge.catch=="function"&&ge.catch(function(){})}}catch(oe){if(oe&&ae&&typeof oe.stack=="string")return[oe.stack,ae.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=m.DetermineComponentFrameRoot(),E=b[0],M=b[1];if(E&&M){var Y=E.split(`
45
- `),ie=M.split(`
46
- `);for(y=m=0;m<Y.length&&!Y[m].includes("DetermineComponentFrameRoot");)m++;for(;y<ie.length&&!ie[y].includes("DetermineComponentFrameRoot");)y++;if(m===Y.length||y===ie.length)for(m=Y.length-1,y=ie.length-1;1<=m&&0<=y&&Y[m]!==ie[y];)y--;for(;1<=m&&0<=y;m--,y--)if(Y[m]!==ie[y]){if(m!==1||y!==1)do if(m--,y--,0>y||Y[m]!==ie[y]){var de=`
47
- `+Y[m].replace(" at new "," at ");return i.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",i.displayName)),de}while(1<=m&&0<=y);break}}}finally{st=!1,Error.prepareStackTrace=u}return(u=i?i.displayName||i.name:"")?Ue(u):""}function ye(i,o){switch(i.tag){case 26:case 27:case 5:return Ue(i.type);case 16:return Ue("Lazy");case 13:return i.child!==o&&o!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return it(i.type,!1);case 11:return it(i.type.render,!1);case 1:return it(i.type,!0);case 31:return Ue("Activity");default:return""}}function ze(i){try{var o="",u=null;do o+=ye(i,u),u=i,i=i.return;while(i);return o}catch(m){return`
48
- Error generating stack: `+m.message+`
49
- `+m.stack}}var ve=Object.prototype.hasOwnProperty,ue=e.unstable_scheduleCallback,Ee=e.unstable_cancelCallback,_t=e.unstable_shouldYield,Js=e.unstable_requestPaint,Yt=e.unstable_now,tl=e.unstable_getCurrentPriorityLevel,me=e.unstable_ImmediatePriority,ke=e.unstable_UserBlockingPriority,$e=e.unstable_NormalPriority,Xe=e.unstable_LowPriority,ut=e.unstable_IdlePriority,un=e.log,Kn=e.unstable_setDisableYieldValue,zt=null,pt=null;function On(i){if(typeof un=="function"&&Kn(i),pt&&typeof pt.setStrictMode=="function")try{pt.setStrictMode(zt,i)}catch{}}var xt=Math.clz32?Math.clz32:Oa,zr=Math.log,ir=Math.LN2;function Oa(i){return i>>>=0,i===0?32:31-(zr(i)/ir|0)|0}var $r=256,Ia=262144,Pa=4194304;function Zr(i){var o=i&42;if(o!==0)return o;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Ba(i,o,u){var m=i.pendingLanes;if(m===0)return 0;var y=0,b=i.suspendedLanes,E=i.pingedLanes;i=i.warmLanes;var M=m&134217727;return M!==0?(m=M&~b,m!==0?y=Zr(m):(E&=M,E!==0?y=Zr(E):u||(u=M&~i,u!==0&&(y=Zr(u))))):(M=m&~b,M!==0?y=Zr(M):E!==0?y=Zr(E):u||(u=m&~i,u!==0&&(y=Zr(u)))),y===0?0:o!==0&&o!==y&&(o&b)===0&&(b=y&-y,u=o&-o,b>=u||b===32&&(u&4194048)!==0)?o:y}function Fi(i,o){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&o)===0}function nl(i,o){switch(i){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 tu(){var i=Pa;return Pa<<=1,(Pa&62914560)===0&&(Pa=4194304),i}function za(i){for(var o=[],u=0;31>u;u++)o.push(i);return o}function Zs(i,o){i.pendingLanes|=o,o!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function fe(i,o,u,m,y,b){var E=i.pendingLanes;i.pendingLanes=u,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=u,i.entangledLanes&=u,i.errorRecoveryDisabledLanes&=u,i.shellSuspendCounter=0;var M=i.entanglements,Y=i.expirationTimes,ie=i.hiddenUpdates;for(u=E&~u;0<u;){var de=31-xt(u),ge=1<<de;M[de]=0,Y[de]=-1;var ae=ie[de];if(ae!==null)for(ie[de]=null,de=0;de<ae.length;de++){var oe=ae[de];oe!==null&&(oe.lane&=-536870913)}u&=~ge}m!==0&&he(i,m,0),b!==0&&y===0&&i.tag!==0&&(i.suspendedLanes|=b&~(E&~o))}function he(i,o,u){i.pendingLanes|=o,i.suspendedLanes&=~o;var m=31-xt(o);i.entangledLanes|=o,i.entanglements[m]=i.entanglements[m]|1073741824|u&261930}function Te(i,o){var u=i.entangledLanes|=o;for(i=i.entanglements;u;){var m=31-xt(u),y=1<<m;y&o|i[m]&o&&(i[m]|=o),u&=~y}}function Pe(i,o){var u=o&-o;return u=(u&42)!==0?1:Qe(u),(u&(i.suspendedLanes|o))!==0?0:u}function Qe(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=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:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function We(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function dt(){var i=F.p;return i!==0?i:(i=window.event,i===void 0?32:z0(i.type))}function jn(i,o){var u=F.p;try{return F.p=i,o()}finally{F.p=u}}var It=Math.random().toString(36).slice(2),yt="__reactFiber$"+It,Yn="__reactProps$"+It,$a="__reactContainer$"+It,of="__reactEvents$"+It,lj="__reactListeners$"+It,cj="__reactHandles$"+It,ny="__reactResources$"+It,rl="__reactMarker$"+It;function lf(i){delete i[yt],delete i[Yn],delete i[of],delete i[lj],delete i[cj]}function Ha(i){var o=i[yt];if(o)return o;for(var u=i.parentNode;u;){if(o=u[$a]||u[yt]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(i=w0(i);i!==null;){if(u=i[yt])return u;i=w0(i)}return o}i=u,u=i.parentNode}return null}function Fa(i){if(i=i[yt]||i[$a]){var o=i.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return i}return null}function sl(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i.stateNode;throw Error(r(33))}function Ua(i){var o=i[ny];return o||(o=i[ny]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function yn(i){i[rl]=!0}var ry=new Set,sy={};function Ui(i,o){Va(i,o),Va(i+"Capture",o)}function Va(i,o){for(sy[i]=o,i=0;i<o.length;i++)ry.add(o[i])}var uj=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),iy={},ay={};function dj(i){return ve.call(ay,i)?!0:ve.call(iy,i)?!1:uj.test(i)?ay[i]=!0:(iy[i]=!0,!1)}function nu(i,o,u){if(dj(o))if(u===null)i.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":i.removeAttribute(o);return;case"boolean":var m=o.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){i.removeAttribute(o);return}}i.setAttribute(o,""+u)}}function ru(i,o,u){if(u===null)i.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(o);return}i.setAttribute(o,""+u)}}function ys(i,o,u,m){if(m===null)i.removeAttribute(u);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(u);return}i.setAttributeNS(o,u,""+m)}}function yr(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function oy(i){var o=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function hj(i,o,u){var m=Object.getOwnPropertyDescriptor(i.constructor.prototype,o);if(!i.hasOwnProperty(o)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var y=m.get,b=m.set;return Object.defineProperty(i,o,{configurable:!0,get:function(){return y.call(this)},set:function(E){u=""+E,b.call(this,E)}}),Object.defineProperty(i,o,{enumerable:m.enumerable}),{getValue:function(){return u},setValue:function(E){u=""+E},stopTracking:function(){i._valueTracker=null,delete i[o]}}}}function cf(i){if(!i._valueTracker){var o=oy(i)?"checked":"value";i._valueTracker=hj(i,o,""+i[o])}}function ly(i){if(!i)return!1;var o=i._valueTracker;if(!o)return!0;var u=o.getValue(),m="";return i&&(m=oy(i)?i.checked?"true":"false":i.value),i=m,i!==u?(o.setValue(i),!0):!1}function su(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var fj=/[\n"\\]/g;function vr(i){return i.replace(fj,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function uf(i,o,u,m,y,b,E,M){i.name="",E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?i.type=E:i.removeAttribute("type"),o!=null?E==="number"?(o===0&&i.value===""||i.value!=o)&&(i.value=""+yr(o)):i.value!==""+yr(o)&&(i.value=""+yr(o)):E!=="submit"&&E!=="reset"||i.removeAttribute("value"),o!=null?df(i,E,yr(o)):u!=null?df(i,E,yr(u)):m!=null&&i.removeAttribute("value"),y==null&&b!=null&&(i.defaultChecked=!!b),y!=null&&(i.checked=y&&typeof y!="function"&&typeof y!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?i.name=""+yr(M):i.removeAttribute("name")}function cy(i,o,u,m,y,b,E,M){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(i.type=b),o!=null||u!=null){if(!(b!=="submit"&&b!=="reset"||o!=null)){cf(i);return}u=u!=null?""+yr(u):"",o=o!=null?""+yr(o):u,M||o===i.value||(i.value=o),i.defaultValue=o}m=m??y,m=typeof m!="function"&&typeof m!="symbol"&&!!m,i.checked=M?i.checked:!!m,i.defaultChecked=!!m,E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(i.name=E),cf(i)}function df(i,o,u){o==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+u||(i.defaultValue=""+u)}function Wa(i,o,u,m){if(i=i.options,o){o={};for(var y=0;y<u.length;y++)o["$"+u[y]]=!0;for(u=0;u<i.length;u++)y=o.hasOwnProperty("$"+i[u].value),i[u].selected!==y&&(i[u].selected=y),y&&m&&(i[u].defaultSelected=!0)}else{for(u=""+yr(u),o=null,y=0;y<i.length;y++){if(i[y].value===u){i[y].selected=!0,m&&(i[y].defaultSelected=!0);return}o!==null||i[y].disabled||(o=i[y])}o!==null&&(o.selected=!0)}}function uy(i,o,u){if(o!=null&&(o=""+yr(o),o!==i.value&&(i.value=o),u==null)){i.defaultValue!==o&&(i.defaultValue=o);return}i.defaultValue=u!=null?""+yr(u):""}function dy(i,o,u,m){if(o==null){if(m!=null){if(u!=null)throw Error(r(92));if(D(m)){if(1<m.length)throw Error(r(93));m=m[0]}u=m}u==null&&(u=""),o=u}u=yr(o),i.defaultValue=u,m=i.textContent,m===u&&m!==""&&m!==null&&(i.value=m),cf(i)}function Ga(i,o){if(o){var u=i.firstChild;if(u&&u===i.lastChild&&u.nodeType===3){u.nodeValue=o;return}}i.textContent=o}var mj=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 hy(i,o,u){var m=o.indexOf("--")===0;u==null||typeof u=="boolean"||u===""?m?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="":m?i.setProperty(o,u):typeof u!="number"||u===0||mj.has(o)?o==="float"?i.cssFloat=u:i[o]=(""+u).trim():i[o]=u+"px"}function fy(i,o,u){if(o!=null&&typeof o!="object")throw Error(r(62));if(i=i.style,u!=null){for(var m in u)!u.hasOwnProperty(m)||o!=null&&o.hasOwnProperty(m)||(m.indexOf("--")===0?i.setProperty(m,""):m==="float"?i.cssFloat="":i[m]="");for(var y in o)m=o[y],o.hasOwnProperty(y)&&u[y]!==m&&hy(i,y,m)}else for(var b in o)o.hasOwnProperty(b)&&hy(i,b,o[b])}function hf(i){if(i.indexOf("-")===-1)return!1;switch(i){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 pj=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"]]),gj=/^[\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 iu(i){return gj.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function vs(){}var ff=null;function mf(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var qa=null,Ka=null;function my(i){var o=Fa(i);if(o&&(i=o.stateNode)){var u=i[Yn]||null;e:switch(i=o.stateNode,o.type){case"input":if(uf(i,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name),o=u.name,u.type==="radio"&&o!=null){for(u=i;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll('input[name="'+vr(""+o)+'"][type="radio"]'),o=0;o<u.length;o++){var m=u[o];if(m!==i&&m.form===i.form){var y=m[Yn]||null;if(!y)throw Error(r(90));uf(m,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name)}}for(o=0;o<u.length;o++)m=u[o],m.form===i.form&&ly(m)}break e;case"textarea":uy(i,u.value,u.defaultValue);break e;case"select":o=u.value,o!=null&&Wa(i,!!u.multiple,o,!1)}}}var pf=!1;function py(i,o,u){if(pf)return i(o,u);pf=!0;try{var m=i(o);return m}finally{if(pf=!1,(qa!==null||Ka!==null)&&(Gu(),qa&&(o=qa,i=Ka,Ka=qa=null,my(o),i)))for(o=0;o<i.length;o++)my(i[o])}}function il(i,o){var u=i.stateNode;if(u===null)return null;var m=u[Yn]||null;if(m===null)return null;u=m[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(i=i.type,m=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!m;break e;default:i=!1}if(i)return null;if(u&&typeof u!="function")throw Error(r(231,o,typeof u));return u}var bs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gf=!1;if(bs)try{var al={};Object.defineProperty(al,"passive",{get:function(){gf=!0}}),window.addEventListener("test",al,al),window.removeEventListener("test",al,al)}catch{gf=!1}var ei=null,_f=null,au=null;function gy(){if(au)return au;var i,o=_f,u=o.length,m,y="value"in ei?ei.value:ei.textContent,b=y.length;for(i=0;i<u&&o[i]===y[i];i++);var E=u-i;for(m=1;m<=E&&o[u-m]===y[b-m];m++);return au=y.slice(i,1<m?1-m:void 0)}function ou(i){var o=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&o===13&&(i=13)):i=o,i===10&&(i=13),32<=i||i===13?i:0}function lu(){return!0}function _y(){return!1}function Xn(i){function o(u,m,y,b,E){this._reactName=u,this._targetInst=y,this.type=m,this.nativeEvent=b,this.target=E,this.currentTarget=null;for(var M in i)i.hasOwnProperty(M)&&(u=i[M],this[M]=u?u(b):b[M]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?lu:_y,this.isPropagationStopped=_y,this}return g(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=lu)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=lu)},persist:function(){},isPersistent:lu}),o}var Vi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cu=Xn(Vi),ol=g({},Vi,{view:0,detail:0}),_j=Xn(ol),xf,yf,ll,uu=g({},ol,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bf,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ll&&(ll&&i.type==="mousemove"?(xf=i.screenX-ll.screenX,yf=i.screenY-ll.screenY):yf=xf=0,ll=i),xf)},movementY:function(i){return"movementY"in i?i.movementY:yf}}),xy=Xn(uu),xj=g({},uu,{dataTransfer:0}),yj=Xn(xj),vj=g({},ol,{relatedTarget:0}),vf=Xn(vj),bj=g({},Vi,{animationName:0,elapsedTime:0,pseudoElement:0}),Sj=Xn(bj),wj=g({},Vi,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Cj=Xn(wj),kj=g({},Vi,{data:0}),yy=Xn(kj),Ej={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nj={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"},jj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Tj(i){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(i):(i=jj[i])?!!o[i]:!1}function bf(){return Tj}var Aj=g({},ol,{key:function(i){if(i.key){var o=Ej[i.key]||i.key;if(o!=="Unidentified")return o}return i.type==="keypress"?(i=ou(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Nj[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bf,charCode:function(i){return i.type==="keypress"?ou(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ou(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Dj=Xn(Aj),Lj=g({},uu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vy=Xn(Lj),Rj=g({},ol,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bf}),Mj=Xn(Rj),Oj=g({},Vi,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ij=Xn(Oj),Pj=g({},uu,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Bj=Xn(Pj),zj=g({},Vi,{newState:0,oldState:0}),$j=Xn(zj),Hj=[9,13,27,32],Sf=bs&&"CompositionEvent"in window,cl=null;bs&&"documentMode"in document&&(cl=document.documentMode);var Fj=bs&&"TextEvent"in window&&!cl,by=bs&&(!Sf||cl&&8<cl&&11>=cl),Sy=" ",wy=!1;function Cy(i,o){switch(i){case"keyup":return Hj.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ky(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ya=!1;function Uj(i,o){switch(i){case"compositionend":return ky(o);case"keypress":return o.which!==32?null:(wy=!0,Sy);case"textInput":return i=o.data,i===Sy&&wy?null:i;default:return null}}function Vj(i,o){if(Ya)return i==="compositionend"||!Sf&&Cy(i,o)?(i=gy(),au=_f=ei=null,Ya=!1,i):null;switch(i){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 by&&o.locale!=="ko"?null:o.data;default:return null}}var Wj={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 Ey(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o==="input"?!!Wj[i.type]:o==="textarea"}function Ny(i,o,u,m){qa?Ka?Ka.push(m):Ka=[m]:qa=m,o=Zu(o,"onChange"),0<o.length&&(u=new cu("onChange","change",null,u,m),i.push({event:u,listeners:o}))}var ul=null,dl=null;function Gj(i){c0(i,0)}function du(i){var o=sl(i);if(ly(o))return i}function jy(i,o){if(i==="change")return o}var Ty=!1;if(bs){var wf;if(bs){var Cf="oninput"in document;if(!Cf){var Ay=document.createElement("div");Ay.setAttribute("oninput","return;"),Cf=typeof Ay.oninput=="function"}wf=Cf}else wf=!1;Ty=wf&&(!document.documentMode||9<document.documentMode)}function Dy(){ul&&(ul.detachEvent("onpropertychange",Ly),dl=ul=null)}function Ly(i){if(i.propertyName==="value"&&du(dl)){var o=[];Ny(o,dl,i,mf(i)),py(Gj,o)}}function qj(i,o,u){i==="focusin"?(Dy(),ul=o,dl=u,ul.attachEvent("onpropertychange",Ly)):i==="focusout"&&Dy()}function Kj(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return du(dl)}function Yj(i,o){if(i==="click")return du(o)}function Xj(i,o){if(i==="input"||i==="change")return du(o)}function Qj(i,o){return i===o&&(i!==0||1/i===1/o)||i!==i&&o!==o}var ar=typeof Object.is=="function"?Object.is:Qj;function hl(i,o){if(ar(i,o))return!0;if(typeof i!="object"||i===null||typeof o!="object"||o===null)return!1;var u=Object.keys(i),m=Object.keys(o);if(u.length!==m.length)return!1;for(m=0;m<u.length;m++){var y=u[m];if(!ve.call(o,y)||!ar(i[y],o[y]))return!1}return!0}function Ry(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function My(i,o){var u=Ry(i);i=0;for(var m;u;){if(u.nodeType===3){if(m=i+u.textContent.length,i<=o&&m>=o)return{node:u,offset:o-i};i=m}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Ry(u)}}function Oy(i,o){return i&&o?i===o?!0:i&&i.nodeType===3?!1:o&&o.nodeType===3?Oy(i,o.parentNode):"contains"in i?i.contains(o):i.compareDocumentPosition?!!(i.compareDocumentPosition(o)&16):!1:!1}function Iy(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var o=su(i.document);o instanceof i.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)i=o.contentWindow;else break;o=su(i.document)}return o}function kf(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o&&(o==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||o==="textarea"||i.contentEditable==="true")}var Jj=bs&&"documentMode"in document&&11>=document.documentMode,Xa=null,Ef=null,fl=null,Nf=!1;function Py(i,o,u){var m=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;Nf||Xa==null||Xa!==su(m)||(m=Xa,"selectionStart"in m&&kf(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),fl&&hl(fl,m)||(fl=m,m=Zu(Ef,"onSelect"),0<m.length&&(o=new cu("onSelect","select",null,o,u),i.push({event:o,listeners:m}),o.target=Xa)))}function Wi(i,o){var u={};return u[i.toLowerCase()]=o.toLowerCase(),u["Webkit"+i]="webkit"+o,u["Moz"+i]="moz"+o,u}var Qa={animationend:Wi("Animation","AnimationEnd"),animationiteration:Wi("Animation","AnimationIteration"),animationstart:Wi("Animation","AnimationStart"),transitionrun:Wi("Transition","TransitionRun"),transitionstart:Wi("Transition","TransitionStart"),transitioncancel:Wi("Transition","TransitionCancel"),transitionend:Wi("Transition","TransitionEnd")},jf={},By={};bs&&(By=document.createElement("div").style,"AnimationEvent"in window||(delete Qa.animationend.animation,delete Qa.animationiteration.animation,delete Qa.animationstart.animation),"TransitionEvent"in window||delete Qa.transitionend.transition);function Gi(i){if(jf[i])return jf[i];if(!Qa[i])return i;var o=Qa[i],u;for(u in o)if(o.hasOwnProperty(u)&&u in By)return jf[i]=o[u];return i}var zy=Gi("animationend"),$y=Gi("animationiteration"),Hy=Gi("animationstart"),Zj=Gi("transitionrun"),eT=Gi("transitionstart"),tT=Gi("transitioncancel"),Fy=Gi("transitionend"),Uy=new Map,Tf="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(" ");Tf.push("scrollEnd");function Hr(i,o){Uy.set(i,o),Ui(o,[i])}var hu=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},br=[],Ja=0,Af=0;function fu(){for(var i=Ja,o=Af=Ja=0;o<i;){var u=br[o];br[o++]=null;var m=br[o];br[o++]=null;var y=br[o];br[o++]=null;var b=br[o];if(br[o++]=null,m!==null&&y!==null){var E=m.pending;E===null?y.next=y:(y.next=E.next,E.next=y),m.pending=y}b!==0&&Vy(u,y,b)}}function mu(i,o,u,m){br[Ja++]=i,br[Ja++]=o,br[Ja++]=u,br[Ja++]=m,Af|=m,i.lanes|=m,i=i.alternate,i!==null&&(i.lanes|=m)}function Df(i,o,u,m){return mu(i,o,u,m),pu(i)}function qi(i,o){return mu(i,null,null,o),pu(i)}function Vy(i,o,u){i.lanes|=u;var m=i.alternate;m!==null&&(m.lanes|=u);for(var y=!1,b=i.return;b!==null;)b.childLanes|=u,m=b.alternate,m!==null&&(m.childLanes|=u),b.tag===22&&(i=b.stateNode,i===null||i._visibility&1||(y=!0)),i=b,b=b.return;return i.tag===3?(b=i.stateNode,y&&o!==null&&(y=31-xt(u),i=b.hiddenUpdates,m=i[y],m===null?i[y]=[o]:m.push(o),o.lane=u|536870912),b):null}function pu(i){if(50<Ol)throw Ol=0,$m=null,Error(r(185));for(var o=i.return;o!==null;)i=o,o=i.return;return i.tag===3?i.stateNode:null}var Za={};function nT(i,o,u,m){this.tag=i,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function or(i,o,u,m){return new nT(i,o,u,m)}function Lf(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ss(i,o){var u=i.alternate;return u===null?(u=or(i.tag,o,i.key,i.mode),u.elementType=i.elementType,u.type=i.type,u.stateNode=i.stateNode,u.alternate=i,i.alternate=u):(u.pendingProps=o,u.type=i.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=i.flags&65011712,u.childLanes=i.childLanes,u.lanes=i.lanes,u.child=i.child,u.memoizedProps=i.memoizedProps,u.memoizedState=i.memoizedState,u.updateQueue=i.updateQueue,o=i.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=i.sibling,u.index=i.index,u.ref=i.ref,u.refCleanup=i.refCleanup,u}function Wy(i,o){i.flags&=65011714;var u=i.alternate;return u===null?(i.childLanes=0,i.lanes=o,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=u.childLanes,i.lanes=u.lanes,i.child=u.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=u.memoizedProps,i.memoizedState=u.memoizedState,i.updateQueue=u.updateQueue,i.type=u.type,o=u.dependencies,i.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),i}function gu(i,o,u,m,y,b){var E=0;if(m=i,typeof i=="function")Lf(i)&&(E=1);else if(typeof i=="string")E=oA(i,u,Q.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ne:return i=or(31,u,o,y),i.elementType=ne,i.lanes=b,i;case S:return Ki(u.children,y,b,o);case w:E=8,y|=24;break;case k:return i=or(12,u,o,y|2),i.elementType=k,i.lanes=b,i;case P:return i=or(13,u,o,y),i.elementType=P,i.lanes=b,i;case R:return i=or(19,u,o,y),i.elementType=R,i.lanes=b,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case T:E=10;break e;case j:E=9;break e;case A:E=11;break e;case q:E=14;break e;case J:E=16,m=null;break e}E=29,u=Error(r(130,i===null?"null":typeof i,"")),m=null}return o=or(E,u,o,y),o.elementType=i,o.type=m,o.lanes=b,o}function Ki(i,o,u,m){return i=or(7,i,m,o),i.lanes=u,i}function Rf(i,o,u){return i=or(6,i,null,o),i.lanes=u,i}function Gy(i){var o=or(18,null,null,0);return o.stateNode=i,o}function Mf(i,o,u){return o=or(4,i.children!==null?i.children:[],i.key,o),o.lanes=u,o.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},o}var qy=new WeakMap;function Sr(i,o){if(typeof i=="object"&&i!==null){var u=qy.get(i);return u!==void 0?u:(o={value:i,source:o,stack:ze(o)},qy.set(i,o),o)}return{value:i,source:o,stack:ze(o)}}var eo=[],to=0,_u=null,ml=0,wr=[],Cr=0,ti=null,es=1,ts="";function ws(i,o){eo[to++]=ml,eo[to++]=_u,_u=i,ml=o}function Ky(i,o,u){wr[Cr++]=es,wr[Cr++]=ts,wr[Cr++]=ti,ti=i;var m=es;i=ts;var y=32-xt(m)-1;m&=~(1<<y),u+=1;var b=32-xt(o)+y;if(30<b){var E=y-y%5;b=(m&(1<<E)-1).toString(32),m>>=E,y-=E,es=1<<32-xt(o)+y|u<<y|m,ts=b+i}else es=1<<b|u<<y|m,ts=i}function Of(i){i.return!==null&&(ws(i,1),Ky(i,1,0))}function If(i){for(;i===_u;)_u=eo[--to],eo[to]=null,ml=eo[--to],eo[to]=null;for(;i===ti;)ti=wr[--Cr],wr[Cr]=null,ts=wr[--Cr],wr[Cr]=null,es=wr[--Cr],wr[Cr]=null}function Yy(i,o){wr[Cr++]=es,wr[Cr++]=ts,wr[Cr++]=ti,es=o.id,ts=o.overflow,ti=i}var Tn=null,Lt=null,lt=!1,ni=null,kr=!1,Pf=Error(r(519));function ri(i){var o=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw pl(Sr(o,i)),Pf}function Xy(i){var o=i.stateNode,u=i.type,m=i.memoizedProps;switch(o[yt]=i,o[Yn]=m,u){case"dialog":nt("cancel",o),nt("close",o);break;case"iframe":case"object":case"embed":nt("load",o);break;case"video":case"audio":for(u=0;u<Pl.length;u++)nt(Pl[u],o);break;case"source":nt("error",o);break;case"img":case"image":case"link":nt("error",o),nt("load",o);break;case"details":nt("toggle",o);break;case"input":nt("invalid",o),cy(o,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":nt("invalid",o);break;case"textarea":nt("invalid",o),dy(o,m.value,m.defaultValue,m.children)}u=m.children,typeof u!="string"&&typeof u!="number"&&typeof u!="bigint"||o.textContent===""+u||m.suppressHydrationWarning===!0||f0(o.textContent,u)?(m.popover!=null&&(nt("beforetoggle",o),nt("toggle",o)),m.onScroll!=null&&nt("scroll",o),m.onScrollEnd!=null&&nt("scrollend",o),m.onClick!=null&&(o.onclick=vs),o=!0):o=!1,o||ri(i,!0)}function Qy(i){for(Tn=i.return;Tn;)switch(Tn.tag){case 5:case 31:case 13:kr=!1;return;case 27:case 3:kr=!0;return;default:Tn=Tn.return}}function no(i){if(i!==Tn)return!1;if(!lt)return Qy(i),lt=!0,!1;var o=i.tag,u;if((u=o!==3&&o!==27)&&((u=o===5)&&(u=i.type,u=!(u!=="form"&&u!=="button")||tp(i.type,i.memoizedProps)),u=!u),u&&Lt&&ri(i),Qy(i),o===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Lt=S0(i)}else if(o===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Lt=S0(i)}else o===27?(o=Lt,_i(i.type)?(i=ap,ap=null,Lt=i):Lt=o):Lt=Tn?Nr(i.stateNode.nextSibling):null;return!0}function Yi(){Lt=Tn=null,lt=!1}function Bf(){var i=ni;return i!==null&&(er===null?er=i:er.push.apply(er,i),ni=null),i}function pl(i){ni===null?ni=[i]:ni.push(i)}var zf=V(null),Xi=null,Cs=null;function si(i,o,u){O(zf,o._currentValue),o._currentValue=u}function ks(i){i._currentValue=zf.current,K(zf)}function $f(i,o,u){for(;i!==null;){var m=i.alternate;if((i.childLanes&o)!==o?(i.childLanes|=o,m!==null&&(m.childLanes|=o)):m!==null&&(m.childLanes&o)!==o&&(m.childLanes|=o),i===u)break;i=i.return}}function Hf(i,o,u,m){var y=i.child;for(y!==null&&(y.return=i);y!==null;){var b=y.dependencies;if(b!==null){var E=y.child;b=b.firstContext;e:for(;b!==null;){var M=b;b=y;for(var Y=0;Y<o.length;Y++)if(M.context===o[Y]){b.lanes|=u,M=b.alternate,M!==null&&(M.lanes|=u),$f(b.return,u,i),m||(E=null);break e}b=M.next}}else if(y.tag===18){if(E=y.return,E===null)throw Error(r(341));E.lanes|=u,b=E.alternate,b!==null&&(b.lanes|=u),$f(E,u,i),E=null}else E=y.child;if(E!==null)E.return=y;else for(E=y;E!==null;){if(E===i){E=null;break}if(y=E.sibling,y!==null){y.return=E.return,E=y;break}E=E.return}y=E}}function ro(i,o,u,m){i=null;for(var y=o,b=!1;y!==null;){if(!b){if((y.flags&524288)!==0)b=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var E=y.alternate;if(E===null)throw Error(r(387));if(E=E.memoizedProps,E!==null){var M=y.type;ar(y.pendingProps.value,E.value)||(i!==null?i.push(M):i=[M])}}else if(y===te.current){if(E=y.alternate,E===null)throw Error(r(387));E.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(i!==null?i.push(Fl):i=[Fl])}y=y.return}i!==null&&Hf(o,i,u,m),o.flags|=262144}function xu(i){for(i=i.firstContext;i!==null;){if(!ar(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Qi(i){Xi=i,Cs=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function An(i){return Jy(Xi,i)}function yu(i,o){return Xi===null&&Qi(i),Jy(i,o)}function Jy(i,o){var u=o._currentValue;if(o={context:o,memoizedValue:u,next:null},Cs===null){if(i===null)throw Error(r(308));Cs=o,i.dependencies={lanes:0,firstContext:o},i.flags|=524288}else Cs=Cs.next=o;return u}var rT=typeof AbortController<"u"?AbortController:function(){var i=[],o=this.signal={aborted:!1,addEventListener:function(u,m){i.push(m)}};this.abort=function(){o.aborted=!0,i.forEach(function(u){return u()})}},sT=e.unstable_scheduleCallback,iT=e.unstable_NormalPriority,nn={$$typeof:T,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ff(){return{controller:new rT,data:new Map,refCount:0}}function gl(i){i.refCount--,i.refCount===0&&sT(iT,function(){i.controller.abort()})}var _l=null,Uf=0,so=0,io=null;function aT(i,o){if(_l===null){var u=_l=[];Uf=0,so=Gm(),io={status:"pending",value:void 0,then:function(m){u.push(m)}}}return Uf++,o.then(Zy,Zy),o}function Zy(){if(--Uf===0&&_l!==null){io!==null&&(io.status="fulfilled");var i=_l;_l=null,so=0,io=null;for(var o=0;o<i.length;o++)(0,i[o])()}}function oT(i,o){var u=[],m={status:"pending",value:null,reason:null,then:function(y){u.push(y)}};return i.then(function(){m.status="fulfilled",m.value=o;for(var y=0;y<u.length;y++)(0,u[y])(o)},function(y){for(m.status="rejected",m.reason=y,y=0;y<u.length;y++)(0,u[y])(void 0)}),m}var ev=N.S;N.S=function(i,o){Pb=Yt(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&aT(i,o),ev!==null&&ev(i,o)};var Ji=V(null);function Vf(){var i=Ji.current;return i!==null?i:Nt.pooledCache}function vu(i,o){o===null?O(Ji,Ji.current):O(Ji,o.pool)}function tv(){var i=Vf();return i===null?null:{parent:nn._currentValue,pool:i}}var ao=Error(r(460)),Wf=Error(r(474)),bu=Error(r(542)),Su={then:function(){}};function nv(i){return i=i.status,i==="fulfilled"||i==="rejected"}function rv(i,o,u){switch(u=i[u],u===void 0?i.push(o):u!==o&&(o.then(vs,vs),o=u),o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,iv(i),i;default:if(typeof o.status=="string")o.then(vs,vs);else{if(i=Nt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=o,i.status="pending",i.then(function(m){if(o.status==="pending"){var y=o;y.status="fulfilled",y.value=m}},function(m){if(o.status==="pending"){var y=o;y.status="rejected",y.reason=m}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,iv(i),i}throw ea=o,ao}}function Zi(i){try{var o=i._init;return o(i._payload)}catch(u){throw u!==null&&typeof u=="object"&&typeof u.then=="function"?(ea=u,ao):u}}var ea=null;function sv(){if(ea===null)throw Error(r(459));var i=ea;return ea=null,i}function iv(i){if(i===ao||i===bu)throw Error(r(483))}var oo=null,xl=0;function wu(i){var o=xl;return xl+=1,oo===null&&(oo=[]),rv(oo,i,o)}function yl(i,o){o=o.props.ref,i.ref=o!==void 0?o:null}function Cu(i,o){throw o.$$typeof===_?Error(r(525)):(i=Object.prototype.toString.call(o),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":i)))}function av(i){function o(ee,X){if(i){var re=ee.deletions;re===null?(ee.deletions=[X],ee.flags|=16):re.push(X)}}function u(ee,X){if(!i)return null;for(;X!==null;)o(ee,X),X=X.sibling;return null}function m(ee){for(var X=new Map;ee!==null;)ee.key!==null?X.set(ee.key,ee):X.set(ee.index,ee),ee=ee.sibling;return X}function y(ee,X){return ee=Ss(ee,X),ee.index=0,ee.sibling=null,ee}function b(ee,X,re){return ee.index=re,i?(re=ee.alternate,re!==null?(re=re.index,re<X?(ee.flags|=67108866,X):re):(ee.flags|=67108866,X)):(ee.flags|=1048576,X)}function E(ee){return i&&ee.alternate===null&&(ee.flags|=67108866),ee}function M(ee,X,re,pe){return X===null||X.tag!==6?(X=Rf(re,ee.mode,pe),X.return=ee,X):(X=y(X,re),X.return=ee,X)}function Y(ee,X,re,pe){var Ie=re.type;return Ie===S?de(ee,X,re.props.children,pe,re.key):X!==null&&(X.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===J&&Zi(Ie)===X.type)?(X=y(X,re.props),yl(X,re),X.return=ee,X):(X=gu(re.type,re.key,re.props,null,ee.mode,pe),yl(X,re),X.return=ee,X)}function ie(ee,X,re,pe){return X===null||X.tag!==4||X.stateNode.containerInfo!==re.containerInfo||X.stateNode.implementation!==re.implementation?(X=Mf(re,ee.mode,pe),X.return=ee,X):(X=y(X,re.children||[]),X.return=ee,X)}function de(ee,X,re,pe,Ie){return X===null||X.tag!==7?(X=Ki(re,ee.mode,pe,Ie),X.return=ee,X):(X=y(X,re),X.return=ee,X)}function ge(ee,X,re){if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return X=Rf(""+X,ee.mode,re),X.return=ee,X;if(typeof X=="object"&&X!==null){switch(X.$$typeof){case x:return re=gu(X.type,X.key,X.props,null,ee.mode,re),yl(re,X),re.return=ee,re;case v:return X=Mf(X,ee.mode,re),X.return=ee,X;case J:return X=Zi(X),ge(ee,X,re)}if(D(X)||z(X))return X=Ki(X,ee.mode,re,null),X.return=ee,X;if(typeof X.then=="function")return ge(ee,wu(X),re);if(X.$$typeof===T)return ge(ee,yu(ee,X),re);Cu(ee,X)}return null}function ae(ee,X,re,pe){var Ie=X!==null?X.key:null;if(typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint")return Ie!==null?null:M(ee,X,""+re,pe);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case x:return re.key===Ie?Y(ee,X,re,pe):null;case v:return re.key===Ie?ie(ee,X,re,pe):null;case J:return re=Zi(re),ae(ee,X,re,pe)}if(D(re)||z(re))return Ie!==null?null:de(ee,X,re,pe,null);if(typeof re.then=="function")return ae(ee,X,wu(re),pe);if(re.$$typeof===T)return ae(ee,X,yu(ee,re),pe);Cu(ee,re)}return null}function oe(ee,X,re,pe,Ie){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return ee=ee.get(re)||null,M(X,ee,""+pe,Ie);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case x:return ee=ee.get(pe.key===null?re:pe.key)||null,Y(X,ee,pe,Ie);case v:return ee=ee.get(pe.key===null?re:pe.key)||null,ie(X,ee,pe,Ie);case J:return pe=Zi(pe),oe(ee,X,re,pe,Ie)}if(D(pe)||z(pe))return ee=ee.get(re)||null,de(X,ee,pe,Ie,null);if(typeof pe.then=="function")return oe(ee,X,re,wu(pe),Ie);if(pe.$$typeof===T)return oe(ee,X,re,yu(X,pe),Ie);Cu(X,pe)}return null}function Ae(ee,X,re,pe){for(var Ie=null,ht=null,Le=X,Ke=X=0,ot=null;Le!==null&&Ke<re.length;Ke++){Le.index>Ke?(ot=Le,Le=null):ot=Le.sibling;var ft=ae(ee,Le,re[Ke],pe);if(ft===null){Le===null&&(Le=ot);break}i&&Le&&ft.alternate===null&&o(ee,Le),X=b(ft,X,Ke),ht===null?Ie=ft:ht.sibling=ft,ht=ft,Le=ot}if(Ke===re.length)return u(ee,Le),lt&&ws(ee,Ke),Ie;if(Le===null){for(;Ke<re.length;Ke++)Le=ge(ee,re[Ke],pe),Le!==null&&(X=b(Le,X,Ke),ht===null?Ie=Le:ht.sibling=Le,ht=Le);return lt&&ws(ee,Ke),Ie}for(Le=m(Le);Ke<re.length;Ke++)ot=oe(Le,ee,Ke,re[Ke],pe),ot!==null&&(i&&ot.alternate!==null&&Le.delete(ot.key===null?Ke:ot.key),X=b(ot,X,Ke),ht===null?Ie=ot:ht.sibling=ot,ht=ot);return i&&Le.forEach(function(Si){return o(ee,Si)}),lt&&ws(ee,Ke),Ie}function He(ee,X,re,pe){if(re==null)throw Error(r(151));for(var Ie=null,ht=null,Le=X,Ke=X=0,ot=null,ft=re.next();Le!==null&&!ft.done;Ke++,ft=re.next()){Le.index>Ke?(ot=Le,Le=null):ot=Le.sibling;var Si=ae(ee,Le,ft.value,pe);if(Si===null){Le===null&&(Le=ot);break}i&&Le&&Si.alternate===null&&o(ee,Le),X=b(Si,X,Ke),ht===null?Ie=Si:ht.sibling=Si,ht=Si,Le=ot}if(ft.done)return u(ee,Le),lt&&ws(ee,Ke),Ie;if(Le===null){for(;!ft.done;Ke++,ft=re.next())ft=ge(ee,ft.value,pe),ft!==null&&(X=b(ft,X,Ke),ht===null?Ie=ft:ht.sibling=ft,ht=ft);return lt&&ws(ee,Ke),Ie}for(Le=m(Le);!ft.done;Ke++,ft=re.next())ft=oe(Le,ee,Ke,ft.value,pe),ft!==null&&(i&&ft.alternate!==null&&Le.delete(ft.key===null?Ke:ft.key),X=b(ft,X,Ke),ht===null?Ie=ft:ht.sibling=ft,ht=ft);return i&&Le.forEach(function(xA){return o(ee,xA)}),lt&&ws(ee,Ke),Ie}function Ct(ee,X,re,pe){if(typeof re=="object"&&re!==null&&re.type===S&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case x:e:{for(var Ie=re.key;X!==null;){if(X.key===Ie){if(Ie=re.type,Ie===S){if(X.tag===7){u(ee,X.sibling),pe=y(X,re.props.children),pe.return=ee,ee=pe;break e}}else if(X.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===J&&Zi(Ie)===X.type){u(ee,X.sibling),pe=y(X,re.props),yl(pe,re),pe.return=ee,ee=pe;break e}u(ee,X);break}else o(ee,X);X=X.sibling}re.type===S?(pe=Ki(re.props.children,ee.mode,pe,re.key),pe.return=ee,ee=pe):(pe=gu(re.type,re.key,re.props,null,ee.mode,pe),yl(pe,re),pe.return=ee,ee=pe)}return E(ee);case v:e:{for(Ie=re.key;X!==null;){if(X.key===Ie)if(X.tag===4&&X.stateNode.containerInfo===re.containerInfo&&X.stateNode.implementation===re.implementation){u(ee,X.sibling),pe=y(X,re.children||[]),pe.return=ee,ee=pe;break e}else{u(ee,X);break}else o(ee,X);X=X.sibling}pe=Mf(re,ee.mode,pe),pe.return=ee,ee=pe}return E(ee);case J:return re=Zi(re),Ct(ee,X,re,pe)}if(D(re))return Ae(ee,X,re,pe);if(z(re)){if(Ie=z(re),typeof Ie!="function")throw Error(r(150));return re=Ie.call(re),He(ee,X,re,pe)}if(typeof re.then=="function")return Ct(ee,X,wu(re),pe);if(re.$$typeof===T)return Ct(ee,X,yu(ee,re),pe);Cu(ee,re)}return typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint"?(re=""+re,X!==null&&X.tag===6?(u(ee,X.sibling),pe=y(X,re),pe.return=ee,ee=pe):(u(ee,X),pe=Rf(re,ee.mode,pe),pe.return=ee,ee=pe),E(ee)):u(ee,X)}return function(ee,X,re,pe){try{xl=0;var Ie=Ct(ee,X,re,pe);return oo=null,Ie}catch(Le){if(Le===ao||Le===bu)throw Le;var ht=or(29,Le,null,ee.mode);return ht.lanes=pe,ht.return=ee,ht}finally{}}}var ta=av(!0),ov=av(!1),ii=!1;function Gf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qf(i,o){i=i.updateQueue,o.updateQueue===i&&(o.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ai(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function oi(i,o,u){var m=i.updateQueue;if(m===null)return null;if(m=m.shared,(gt&2)!==0){var y=m.pending;return y===null?o.next=o:(o.next=y.next,y.next=o),m.pending=o,o=pu(i),Vy(i,null,u),o}return mu(i,m,o,u),pu(i)}function vl(i,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194048)!==0)){var m=o.lanes;m&=i.pendingLanes,u|=m,o.lanes=u,Te(i,u)}}function Kf(i,o){var u=i.updateQueue,m=i.alternate;if(m!==null&&(m=m.updateQueue,u===m)){var y=null,b=null;if(u=u.firstBaseUpdate,u!==null){do{var E={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};b===null?y=b=E:b=b.next=E,u=u.next}while(u!==null);b===null?y=b=o:b=b.next=o}else y=b=o;u={baseState:m.baseState,firstBaseUpdate:y,lastBaseUpdate:b,shared:m.shared,callbacks:m.callbacks},i.updateQueue=u;return}i=u.lastBaseUpdate,i===null?u.firstBaseUpdate=o:i.next=o,u.lastBaseUpdate=o}var Yf=!1;function bl(){if(Yf){var i=io;if(i!==null)throw i}}function Sl(i,o,u,m){Yf=!1;var y=i.updateQueue;ii=!1;var b=y.firstBaseUpdate,E=y.lastBaseUpdate,M=y.shared.pending;if(M!==null){y.shared.pending=null;var Y=M,ie=Y.next;Y.next=null,E===null?b=ie:E.next=ie,E=Y;var de=i.alternate;de!==null&&(de=de.updateQueue,M=de.lastBaseUpdate,M!==E&&(M===null?de.firstBaseUpdate=ie:M.next=ie,de.lastBaseUpdate=Y))}if(b!==null){var ge=y.baseState;E=0,de=ie=Y=null,M=b;do{var ae=M.lane&-536870913,oe=ae!==M.lane;if(oe?(at&ae)===ae:(m&ae)===ae){ae!==0&&ae===so&&(Yf=!0),de!==null&&(de=de.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var Ae=i,He=M;ae=o;var Ct=u;switch(He.tag){case 1:if(Ae=He.payload,typeof Ae=="function"){ge=Ae.call(Ct,ge,ae);break e}ge=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=He.payload,ae=typeof Ae=="function"?Ae.call(Ct,ge,ae):Ae,ae==null)break e;ge=g({},ge,ae);break e;case 2:ii=!0}}ae=M.callback,ae!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=y.callbacks,oe===null?y.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:M.tag,payload:M.payload,callback:M.callback,next:null},de===null?(ie=de=oe,Y=ge):de=de.next=oe,E|=ae;if(M=M.next,M===null){if(M=y.shared.pending,M===null)break;oe=M,M=oe.next,oe.next=null,y.lastBaseUpdate=oe,y.shared.pending=null}}while(!0);de===null&&(Y=ge),y.baseState=Y,y.firstBaseUpdate=ie,y.lastBaseUpdate=de,b===null&&(y.shared.lanes=0),hi|=E,i.lanes=E,i.memoizedState=ge}}function lv(i,o){if(typeof i!="function")throw Error(r(191,i));i.call(o)}function cv(i,o){var u=i.callbacks;if(u!==null)for(i.callbacks=null,i=0;i<u.length;i++)lv(u[i],o)}var lo=V(null),ku=V(0);function uv(i,o){i=Ms,O(ku,i),O(lo,o),Ms=i|o.baseLanes}function Xf(){O(ku,Ms),O(lo,lo.current)}function Qf(){Ms=ku.current,K(lo),K(ku)}var lr=V(null),Er=null;function li(i){var o=i.alternate;O(Xt,Xt.current&1),O(lr,i),Er===null&&(o===null||lo.current!==null||o.memoizedState!==null)&&(Er=i)}function Jf(i){O(Xt,Xt.current),O(lr,i),Er===null&&(Er=i)}function dv(i){i.tag===22?(O(Xt,Xt.current),O(lr,i),Er===null&&(Er=i)):ci()}function ci(){O(Xt,Xt.current),O(lr,lr.current)}function cr(i){K(lr),Er===i&&(Er=null),K(Xt)}var Xt=V(0);function Eu(i){for(var o=i;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||sp(u)||ip(u)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Es=0,qe=null,St=null,rn=null,Nu=!1,co=!1,na=!1,ju=0,wl=0,uo=null,lT=0;function Vt(){throw Error(r(321))}function Zf(i,o){if(o===null)return!1;for(var u=0;u<o.length&&u<i.length;u++)if(!ar(i[u],o[u]))return!1;return!0}function em(i,o,u,m,y,b){return Es=b,qe=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,N.H=i===null||i.memoizedState===null?Kv:pm,na=!1,b=u(m,y),na=!1,co&&(b=fv(o,u,m,y)),hv(i),b}function hv(i){N.H=El;var o=St!==null&&St.next!==null;if(Es=0,rn=St=qe=null,Nu=!1,wl=0,uo=null,o)throw Error(r(300));i===null||sn||(i=i.dependencies,i!==null&&xu(i)&&(sn=!0))}function fv(i,o,u,m){qe=i;var y=0;do{if(co&&(uo=null),wl=0,co=!1,25<=y)throw Error(r(301));if(y+=1,rn=St=null,i.updateQueue!=null){var b=i.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}N.H=Yv,b=o(u,m)}while(co);return b}function cT(){var i=N.H,o=i.useState()[0];return o=typeof o.then=="function"?Cl(o):o,i=i.useState()[0],(St!==null?St.memoizedState:null)!==i&&(qe.flags|=1024),o}function tm(){var i=ju!==0;return ju=0,i}function nm(i,o,u){o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~u}function rm(i){if(Nu){for(i=i.memoizedState;i!==null;){var o=i.queue;o!==null&&(o.pending=null),i=i.next}Nu=!1}Es=0,rn=St=qe=null,co=!1,wl=ju=0,uo=null}function Fn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rn===null?qe.memoizedState=rn=i:rn=rn.next=i,rn}function Qt(){if(St===null){var i=qe.alternate;i=i!==null?i.memoizedState:null}else i=St.next;var o=rn===null?qe.memoizedState:rn.next;if(o!==null)rn=o,St=i;else{if(i===null)throw qe.alternate===null?Error(r(467)):Error(r(310));St=i,i={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},rn===null?qe.memoizedState=rn=i:rn=rn.next=i}return rn}function Tu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Cl(i){var o=wl;return wl+=1,uo===null&&(uo=[]),i=rv(uo,i,o),o=qe,(rn===null?o.memoizedState:rn.next)===null&&(o=o.alternate,N.H=o===null||o.memoizedState===null?Kv:pm),i}function Au(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Cl(i);if(i.$$typeof===T)return An(i)}throw Error(r(438,String(i)))}function sm(i){var o=null,u=qe.updateQueue;if(u!==null&&(o=u.memoCache),o==null){var m=qe.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(o={data:m.data.map(function(y){return y.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),u===null&&(u=Tu(),qe.updateQueue=u),u.memoCache=o,u=o.data[o.index],u===void 0)for(u=o.data[o.index]=Array(i),m=0;m<i;m++)u[m]=I;return o.index++,u}function Ns(i,o){return typeof o=="function"?o(i):o}function Du(i){var o=Qt();return im(o,St,i)}function im(i,o,u){var m=i.queue;if(m===null)throw Error(r(311));m.lastRenderedReducer=u;var y=i.baseQueue,b=m.pending;if(b!==null){if(y!==null){var E=y.next;y.next=b.next,b.next=E}o.baseQueue=y=b,m.pending=null}if(b=i.baseState,y===null)i.memoizedState=b;else{o=y.next;var M=E=null,Y=null,ie=o,de=!1;do{var ge=ie.lane&-536870913;if(ge!==ie.lane?(at&ge)===ge:(Es&ge)===ge){var ae=ie.revertLane;if(ae===0)Y!==null&&(Y=Y.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),ge===so&&(de=!0);else if((Es&ae)===ae){ie=ie.next,ae===so&&(de=!0);continue}else ge={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},Y===null?(M=Y=ge,E=b):Y=Y.next=ge,qe.lanes|=ae,hi|=ae;ge=ie.action,na&&u(b,ge),b=ie.hasEagerState?ie.eagerState:u(b,ge)}else ae={lane:ge,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},Y===null?(M=Y=ae,E=b):Y=Y.next=ae,qe.lanes|=ge,hi|=ge;ie=ie.next}while(ie!==null&&ie!==o);if(Y===null?E=b:Y.next=M,!ar(b,i.memoizedState)&&(sn=!0,de&&(u=io,u!==null)))throw u;i.memoizedState=b,i.baseState=E,i.baseQueue=Y,m.lastRenderedState=b}return y===null&&(m.lanes=0),[i.memoizedState,m.dispatch]}function am(i){var o=Qt(),u=o.queue;if(u===null)throw Error(r(311));u.lastRenderedReducer=i;var m=u.dispatch,y=u.pending,b=o.memoizedState;if(y!==null){u.pending=null;var E=y=y.next;do b=i(b,E.action),E=E.next;while(E!==y);ar(b,o.memoizedState)||(sn=!0),o.memoizedState=b,o.baseQueue===null&&(o.baseState=b),u.lastRenderedState=b}return[b,m]}function mv(i,o,u){var m=qe,y=Qt(),b=lt;if(b){if(u===void 0)throw Error(r(407));u=u()}else u=o();var E=!ar((St||y).memoizedState,u);if(E&&(y.memoizedState=u,sn=!0),y=y.queue,cm(_v.bind(null,m,y,i),[i]),y.getSnapshot!==o||E||rn!==null&&rn.memoizedState.tag&1){if(m.flags|=2048,ho(9,{destroy:void 0},gv.bind(null,m,y,u,o),null),Nt===null)throw Error(r(349));b||(Es&127)!==0||pv(m,o,u)}return u}function pv(i,o,u){i.flags|=16384,i={getSnapshot:o,value:u},o=qe.updateQueue,o===null?(o=Tu(),qe.updateQueue=o,o.stores=[i]):(u=o.stores,u===null?o.stores=[i]:u.push(i))}function gv(i,o,u,m){o.value=u,o.getSnapshot=m,xv(o)&&yv(i)}function _v(i,o,u){return u(function(){xv(o)&&yv(i)})}function xv(i){var o=i.getSnapshot;i=i.value;try{var u=o();return!ar(i,u)}catch{return!0}}function yv(i){var o=qi(i,2);o!==null&&tr(o,i,2)}function om(i){var o=Fn();if(typeof i=="function"){var u=i;if(i=u(),na){On(!0);try{u()}finally{On(!1)}}}return o.memoizedState=o.baseState=i,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ns,lastRenderedState:i},o}function vv(i,o,u,m){return i.baseState=u,im(i,St,typeof m=="function"?m:Ns)}function uT(i,o,u,m,y){if(Mu(i))throw Error(r(485));if(i=o.action,i!==null){var b={payload:y,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(E){b.listeners.push(E)}};N.T!==null?u(!0):b.isTransition=!1,m(b),u=o.pending,u===null?(b.next=o.pending=b,bv(o,b)):(b.next=u.next,o.pending=u.next=b)}}function bv(i,o){var u=o.action,m=o.payload,y=i.state;if(o.isTransition){var b=N.T,E={};N.T=E;try{var M=u(y,m),Y=N.S;Y!==null&&Y(E,M),Sv(i,o,M)}catch(ie){lm(i,o,ie)}finally{b!==null&&E.types!==null&&(b.types=E.types),N.T=b}}else try{b=u(y,m),Sv(i,o,b)}catch(ie){lm(i,o,ie)}}function Sv(i,o,u){u!==null&&typeof u=="object"&&typeof u.then=="function"?u.then(function(m){wv(i,o,m)},function(m){return lm(i,o,m)}):wv(i,o,u)}function wv(i,o,u){o.status="fulfilled",o.value=u,Cv(o),i.state=u,o=i.pending,o!==null&&(u=o.next,u===o?i.pending=null:(u=u.next,o.next=u,bv(i,u)))}function lm(i,o,u){var m=i.pending;if(i.pending=null,m!==null){m=m.next;do o.status="rejected",o.reason=u,Cv(o),o=o.next;while(o!==m)}i.action=null}function Cv(i){i=i.listeners;for(var o=0;o<i.length;o++)(0,i[o])()}function kv(i,o){return o}function Ev(i,o){if(lt){var u=Nt.formState;if(u!==null){e:{var m=qe;if(lt){if(Lt){t:{for(var y=Lt,b=kr;y.nodeType!==8;){if(!b){y=null;break t}if(y=Nr(y.nextSibling),y===null){y=null;break t}}b=y.data,y=b==="F!"||b==="F"?y:null}if(y){Lt=Nr(y.nextSibling),m=y.data==="F!";break e}}ri(m)}m=!1}m&&(o=u[0])}}return u=Fn(),u.memoizedState=u.baseState=o,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:kv,lastRenderedState:o},u.queue=m,u=Wv.bind(null,qe,m),m.dispatch=u,m=om(!1),b=mm.bind(null,qe,!1,m.queue),m=Fn(),y={state:o,dispatch:null,action:i,pending:null},m.queue=y,u=uT.bind(null,qe,y,b,u),y.dispatch=u,m.memoizedState=i,[o,u,!1]}function Nv(i){var o=Qt();return jv(o,St,i)}function jv(i,o,u){if(o=im(i,o,kv)[0],i=Du(Ns)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var m=Cl(o)}catch(E){throw E===ao?bu:E}else m=o;o=Qt();var y=o.queue,b=y.dispatch;return u!==o.memoizedState&&(qe.flags|=2048,ho(9,{destroy:void 0},dT.bind(null,y,u),null)),[m,b,i]}function dT(i,o){i.action=o}function Tv(i){var o=Qt(),u=St;if(u!==null)return jv(o,u,i);Qt(),o=o.memoizedState,u=Qt();var m=u.queue.dispatch;return u.memoizedState=i,[o,m,!1]}function ho(i,o,u,m){return i={tag:i,create:u,deps:m,inst:o,next:null},o=qe.updateQueue,o===null&&(o=Tu(),qe.updateQueue=o),u=o.lastEffect,u===null?o.lastEffect=i.next=i:(m=u.next,u.next=i,i.next=m,o.lastEffect=i),i}function Av(){return Qt().memoizedState}function Lu(i,o,u,m){var y=Fn();qe.flags|=i,y.memoizedState=ho(1|o,{destroy:void 0},u,m===void 0?null:m)}function Ru(i,o,u,m){var y=Qt();m=m===void 0?null:m;var b=y.memoizedState.inst;St!==null&&m!==null&&Zf(m,St.memoizedState.deps)?y.memoizedState=ho(o,b,u,m):(qe.flags|=i,y.memoizedState=ho(1|o,b,u,m))}function Dv(i,o){Lu(8390656,8,i,o)}function cm(i,o){Ru(2048,8,i,o)}function hT(i){qe.flags|=4;var o=qe.updateQueue;if(o===null)o=Tu(),qe.updateQueue=o,o.events=[i];else{var u=o.events;u===null?o.events=[i]:u.push(i)}}function Lv(i){var o=Qt().memoizedState;return hT({ref:o,nextImpl:i}),function(){if((gt&2)!==0)throw Error(r(440));return o.impl.apply(void 0,arguments)}}function Rv(i,o){return Ru(4,2,i,o)}function Mv(i,o){return Ru(4,4,i,o)}function Ov(i,o){if(typeof o=="function"){i=i();var u=o(i);return function(){typeof u=="function"?u():o(null)}}if(o!=null)return i=i(),o.current=i,function(){o.current=null}}function Iv(i,o,u){u=u!=null?u.concat([i]):null,Ru(4,4,Ov.bind(null,o,i),u)}function um(){}function Pv(i,o){var u=Qt();o=o===void 0?null:o;var m=u.memoizedState;return o!==null&&Zf(o,m[1])?m[0]:(u.memoizedState=[i,o],i)}function Bv(i,o){var u=Qt();o=o===void 0?null:o;var m=u.memoizedState;if(o!==null&&Zf(o,m[1]))return m[0];if(m=i(),na){On(!0);try{i()}finally{On(!1)}}return u.memoizedState=[m,o],m}function dm(i,o,u){return u===void 0||(Es&1073741824)!==0&&(at&261930)===0?i.memoizedState=o:(i.memoizedState=u,i=zb(),qe.lanes|=i,hi|=i,u)}function zv(i,o,u,m){return ar(u,o)?u:lo.current!==null?(i=dm(i,u,m),ar(i,o)||(sn=!0),i):(Es&42)===0||(Es&1073741824)!==0&&(at&261930)===0?(sn=!0,i.memoizedState=u):(i=zb(),qe.lanes|=i,hi|=i,o)}function $v(i,o,u,m,y){var b=F.p;F.p=b!==0&&8>b?b:8;var E=N.T,M={};N.T=M,mm(i,!1,o,u);try{var Y=y(),ie=N.S;if(ie!==null&&ie(M,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var de=oT(Y,m);kl(i,o,de,hr(i))}else kl(i,o,m,hr(i))}catch(ge){kl(i,o,{then:function(){},status:"rejected",reason:ge},hr())}finally{F.p=b,E!==null&&M.types!==null&&(E.types=M.types),N.T=E}}function fT(){}function hm(i,o,u,m){if(i.tag!==5)throw Error(r(476));var y=Hv(i).queue;$v(i,y,o,H,u===null?fT:function(){return Fv(i),u(m)})}function Hv(i){var o=i.memoizedState;if(o!==null)return o;o={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ns,lastRenderedState:H},next:null};var u={};return o.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ns,lastRenderedState:u},next:null},i.memoizedState=o,i=i.alternate,i!==null&&(i.memoizedState=o),o}function Fv(i){var o=Hv(i);o.next===null&&(o=i.alternate.memoizedState),kl(i,o.next.queue,{},hr())}function fm(){return An(Fl)}function Uv(){return Qt().memoizedState}function Vv(){return Qt().memoizedState}function mT(i){for(var o=i.return;o!==null;){switch(o.tag){case 24:case 3:var u=hr();i=ai(u);var m=oi(o,i,u);m!==null&&(tr(m,o,u),vl(m,o,u)),o={cache:Ff()},i.payload=o;return}o=o.return}}function pT(i,o,u){var m=hr();u={lane:m,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Mu(i)?Gv(o,u):(u=Df(i,o,u,m),u!==null&&(tr(u,i,m),qv(u,o,m)))}function Wv(i,o,u){var m=hr();kl(i,o,u,m)}function kl(i,o,u,m){var y={lane:m,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Mu(i))Gv(o,y);else{var b=i.alternate;if(i.lanes===0&&(b===null||b.lanes===0)&&(b=o.lastRenderedReducer,b!==null))try{var E=o.lastRenderedState,M=b(E,u);if(y.hasEagerState=!0,y.eagerState=M,ar(M,E))return mu(i,o,y,0),Nt===null&&fu(),!1}catch{}finally{}if(u=Df(i,o,y,m),u!==null)return tr(u,i,m),qv(u,o,m),!0}return!1}function mm(i,o,u,m){if(m={lane:2,revertLane:Gm(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Mu(i)){if(o)throw Error(r(479))}else o=Df(i,u,m,2),o!==null&&tr(o,i,2)}function Mu(i){var o=i.alternate;return i===qe||o!==null&&o===qe}function Gv(i,o){co=Nu=!0;var u=i.pending;u===null?o.next=o:(o.next=u.next,u.next=o),i.pending=o}function qv(i,o,u){if((u&4194048)!==0){var m=o.lanes;m&=i.pendingLanes,u|=m,o.lanes=u,Te(i,u)}}var El={readContext:An,use:Au,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useLayoutEffect:Vt,useInsertionEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useSyncExternalStore:Vt,useId:Vt,useHostTransitionStatus:Vt,useFormState:Vt,useActionState:Vt,useOptimistic:Vt,useMemoCache:Vt,useCacheRefresh:Vt};El.useEffectEvent=Vt;var Kv={readContext:An,use:Au,useCallback:function(i,o){return Fn().memoizedState=[i,o===void 0?null:o],i},useContext:An,useEffect:Dv,useImperativeHandle:function(i,o,u){u=u!=null?u.concat([i]):null,Lu(4194308,4,Ov.bind(null,o,i),u)},useLayoutEffect:function(i,o){return Lu(4194308,4,i,o)},useInsertionEffect:function(i,o){Lu(4,2,i,o)},useMemo:function(i,o){var u=Fn();o=o===void 0?null:o;var m=i();if(na){On(!0);try{i()}finally{On(!1)}}return u.memoizedState=[m,o],m},useReducer:function(i,o,u){var m=Fn();if(u!==void 0){var y=u(o);if(na){On(!0);try{u(o)}finally{On(!1)}}}else y=o;return m.memoizedState=m.baseState=y,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:y},m.queue=i,i=i.dispatch=pT.bind(null,qe,i),[m.memoizedState,i]},useRef:function(i){var o=Fn();return i={current:i},o.memoizedState=i},useState:function(i){i=om(i);var o=i.queue,u=Wv.bind(null,qe,o);return o.dispatch=u,[i.memoizedState,u]},useDebugValue:um,useDeferredValue:function(i,o){var u=Fn();return dm(u,i,o)},useTransition:function(){var i=om(!1);return i=$v.bind(null,qe,i.queue,!0,!1),Fn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,o,u){var m=qe,y=Fn();if(lt){if(u===void 0)throw Error(r(407));u=u()}else{if(u=o(),Nt===null)throw Error(r(349));(at&127)!==0||pv(m,o,u)}y.memoizedState=u;var b={value:u,getSnapshot:o};return y.queue=b,Dv(_v.bind(null,m,b,i),[i]),m.flags|=2048,ho(9,{destroy:void 0},gv.bind(null,m,b,u,o),null),u},useId:function(){var i=Fn(),o=Nt.identifierPrefix;if(lt){var u=ts,m=es;u=(m&~(1<<32-xt(m)-1)).toString(32)+u,o="_"+o+"R_"+u,u=ju++,0<u&&(o+="H"+u.toString(32)),o+="_"}else u=lT++,o="_"+o+"r_"+u.toString(32)+"_";return i.memoizedState=o},useHostTransitionStatus:fm,useFormState:Ev,useActionState:Ev,useOptimistic:function(i){var o=Fn();o.memoizedState=o.baseState=i;var u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=u,o=mm.bind(null,qe,!0,u),u.dispatch=o,[i,o]},useMemoCache:sm,useCacheRefresh:function(){return Fn().memoizedState=mT.bind(null,qe)},useEffectEvent:function(i){var o=Fn(),u={impl:i};return o.memoizedState=u,function(){if((gt&2)!==0)throw Error(r(440));return u.impl.apply(void 0,arguments)}}},pm={readContext:An,use:Au,useCallback:Pv,useContext:An,useEffect:cm,useImperativeHandle:Iv,useInsertionEffect:Rv,useLayoutEffect:Mv,useMemo:Bv,useReducer:Du,useRef:Av,useState:function(){return Du(Ns)},useDebugValue:um,useDeferredValue:function(i,o){var u=Qt();return zv(u,St.memoizedState,i,o)},useTransition:function(){var i=Du(Ns)[0],o=Qt().memoizedState;return[typeof i=="boolean"?i:Cl(i),o]},useSyncExternalStore:mv,useId:Uv,useHostTransitionStatus:fm,useFormState:Nv,useActionState:Nv,useOptimistic:function(i,o){var u=Qt();return vv(u,St,i,o)},useMemoCache:sm,useCacheRefresh:Vv};pm.useEffectEvent=Lv;var Yv={readContext:An,use:Au,useCallback:Pv,useContext:An,useEffect:cm,useImperativeHandle:Iv,useInsertionEffect:Rv,useLayoutEffect:Mv,useMemo:Bv,useReducer:am,useRef:Av,useState:function(){return am(Ns)},useDebugValue:um,useDeferredValue:function(i,o){var u=Qt();return St===null?dm(u,i,o):zv(u,St.memoizedState,i,o)},useTransition:function(){var i=am(Ns)[0],o=Qt().memoizedState;return[typeof i=="boolean"?i:Cl(i),o]},useSyncExternalStore:mv,useId:Uv,useHostTransitionStatus:fm,useFormState:Tv,useActionState:Tv,useOptimistic:function(i,o){var u=Qt();return St!==null?vv(u,St,i,o):(u.baseState=i,[i,u.queue.dispatch])},useMemoCache:sm,useCacheRefresh:Vv};Yv.useEffectEvent=Lv;function gm(i,o,u,m){o=i.memoizedState,u=u(m,o),u=u==null?o:g({},o,u),i.memoizedState=u,i.lanes===0&&(i.updateQueue.baseState=u)}var _m={enqueueSetState:function(i,o,u){i=i._reactInternals;var m=hr(),y=ai(m);y.payload=o,u!=null&&(y.callback=u),o=oi(i,y,m),o!==null&&(tr(o,i,m),vl(o,i,m))},enqueueReplaceState:function(i,o,u){i=i._reactInternals;var m=hr(),y=ai(m);y.tag=1,y.payload=o,u!=null&&(y.callback=u),o=oi(i,y,m),o!==null&&(tr(o,i,m),vl(o,i,m))},enqueueForceUpdate:function(i,o){i=i._reactInternals;var u=hr(),m=ai(u);m.tag=2,o!=null&&(m.callback=o),o=oi(i,m,u),o!==null&&(tr(o,i,u),vl(o,i,u))}};function Xv(i,o,u,m,y,b,E){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(m,b,E):o.prototype&&o.prototype.isPureReactComponent?!hl(u,m)||!hl(y,b):!0}function Qv(i,o,u,m){i=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,m),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,m),o.state!==i&&_m.enqueueReplaceState(o,o.state,null)}function ra(i,o){var u=o;if("ref"in o){u={};for(var m in o)m!=="ref"&&(u[m]=o[m])}if(i=i.defaultProps){u===o&&(u=g({},u));for(var y in i)u[y]===void 0&&(u[y]=i[y])}return u}function Jv(i){hu(i)}function Zv(i){console.error(i)}function eb(i){hu(i)}function Ou(i,o){try{var u=i.onUncaughtError;u(o.value,{componentStack:o.stack})}catch(m){setTimeout(function(){throw m})}}function tb(i,o,u){try{var m=i.onCaughtError;m(u.value,{componentStack:u.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function xm(i,o,u){return u=ai(u),u.tag=3,u.payload={element:null},u.callback=function(){Ou(i,o)},u}function nb(i){return i=ai(i),i.tag=3,i}function rb(i,o,u,m){var y=u.type.getDerivedStateFromError;if(typeof y=="function"){var b=m.value;i.payload=function(){return y(b)},i.callback=function(){tb(o,u,m)}}var E=u.stateNode;E!==null&&typeof E.componentDidCatch=="function"&&(i.callback=function(){tb(o,u,m),typeof y!="function"&&(fi===null?fi=new Set([this]):fi.add(this));var M=m.stack;this.componentDidCatch(m.value,{componentStack:M!==null?M:""})})}function gT(i,o,u,m,y){if(u.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(o=u.alternate,o!==null&&ro(o,u,y,!0),u=lr.current,u!==null){switch(u.tag){case 31:case 13:return Er===null?qu():u.alternate===null&&Wt===0&&(Wt=3),u.flags&=-257,u.flags|=65536,u.lanes=y,m===Su?u.flags|=16384:(o=u.updateQueue,o===null?u.updateQueue=new Set([m]):o.add(m),Um(i,m,y)),!1;case 22:return u.flags|=65536,m===Su?u.flags|=16384:(o=u.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([m])},u.updateQueue=o):(u=o.retryQueue,u===null?o.retryQueue=new Set([m]):u.add(m)),Um(i,m,y)),!1}throw Error(r(435,u.tag))}return Um(i,m,y),qu(),!1}if(lt)return o=lr.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=y,m!==Pf&&(i=Error(r(422),{cause:m}),pl(Sr(i,u)))):(m!==Pf&&(o=Error(r(423),{cause:m}),pl(Sr(o,u))),i=i.current.alternate,i.flags|=65536,y&=-y,i.lanes|=y,m=Sr(m,u),y=xm(i.stateNode,m,y),Kf(i,y),Wt!==4&&(Wt=2)),!1;var b=Error(r(520),{cause:m});if(b=Sr(b,u),Ml===null?Ml=[b]:Ml.push(b),Wt!==4&&(Wt=2),o===null)return!0;m=Sr(m,u),u=o;do{switch(u.tag){case 3:return u.flags|=65536,i=y&-y,u.lanes|=i,i=xm(u.stateNode,m,i),Kf(u,i),!1;case 1:if(o=u.type,b=u.stateNode,(u.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(fi===null||!fi.has(b))))return u.flags|=65536,y&=-y,u.lanes|=y,y=nb(y),rb(y,i,u,m),Kf(u,y),!1}u=u.return}while(u!==null);return!1}var ym=Error(r(461)),sn=!1;function Dn(i,o,u,m){o.child=i===null?ov(o,null,u,m):ta(o,i.child,u,m)}function sb(i,o,u,m,y){u=u.render;var b=o.ref;if("ref"in m){var E={};for(var M in m)M!=="ref"&&(E[M]=m[M])}else E=m;return Qi(o),m=em(i,o,u,E,b,y),M=tm(),i!==null&&!sn?(nm(i,o,y),js(i,o,y)):(lt&&M&&Of(o),o.flags|=1,Dn(i,o,m,y),o.child)}function ib(i,o,u,m,y){if(i===null){var b=u.type;return typeof b=="function"&&!Lf(b)&&b.defaultProps===void 0&&u.compare===null?(o.tag=15,o.type=b,ab(i,o,b,m,y)):(i=gu(u.type,null,m,o,o.mode,y),i.ref=o.ref,i.return=o,o.child=i)}if(b=i.child,!Nm(i,y)){var E=b.memoizedProps;if(u=u.compare,u=u!==null?u:hl,u(E,m)&&i.ref===o.ref)return js(i,o,y)}return o.flags|=1,i=Ss(b,m),i.ref=o.ref,i.return=o,o.child=i}function ab(i,o,u,m,y){if(i!==null){var b=i.memoizedProps;if(hl(b,m)&&i.ref===o.ref)if(sn=!1,o.pendingProps=m=b,Nm(i,y))(i.flags&131072)!==0&&(sn=!0);else return o.lanes=i.lanes,js(i,o,y)}return vm(i,o,u,m,y)}function ob(i,o,u,m){var y=m.children,b=i!==null?i.memoizedState:null;if(i===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((o.flags&128)!==0){if(b=b!==null?b.baseLanes|u:u,i!==null){for(m=o.child=i.child,y=0;m!==null;)y=y|m.lanes|m.childLanes,m=m.sibling;m=y&~b}else m=0,o.child=null;return lb(i,o,b,u,m)}if((u&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},i!==null&&vu(o,b!==null?b.cachePool:null),b!==null?uv(o,b):Xf(),dv(o);else return m=o.lanes=536870912,lb(i,o,b!==null?b.baseLanes|u:u,u,m)}else b!==null?(vu(o,b.cachePool),uv(o,b),ci(),o.memoizedState=null):(i!==null&&vu(o,null),Xf(),ci());return Dn(i,o,y,u),o.child}function Nl(i,o){return i!==null&&i.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function lb(i,o,u,m,y){var b=Vf();return b=b===null?null:{parent:nn._currentValue,pool:b},o.memoizedState={baseLanes:u,cachePool:b},i!==null&&vu(o,null),Xf(),dv(o),i!==null&&ro(i,o,m,!0),o.childLanes=y,null}function Iu(i,o){return o=Bu({mode:o.mode,children:o.children},i.mode),o.ref=i.ref,i.child=o,o.return=i,o}function cb(i,o,u){return ta(o,i.child,null,u),i=Iu(o,o.pendingProps),i.flags|=2,cr(o),o.memoizedState=null,i}function _T(i,o,u){var m=o.pendingProps,y=(o.flags&128)!==0;if(o.flags&=-129,i===null){if(lt){if(m.mode==="hidden")return i=Iu(o,m),o.lanes=536870912,Nl(null,i);if(Jf(o),(i=Lt)?(i=b0(i,kr),i=i!==null&&i.data==="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:ti!==null?{id:es,overflow:ts}:null,retryLane:536870912,hydrationErrors:null},u=Gy(i),u.return=o,o.child=u,Tn=o,Lt=null)):i=null,i===null)throw ri(o);return o.lanes=536870912,null}return Iu(o,m)}var b=i.memoizedState;if(b!==null){var E=b.dehydrated;if(Jf(o),y)if(o.flags&256)o.flags&=-257,o=cb(i,o,u);else if(o.memoizedState!==null)o.child=i.child,o.flags|=128,o=null;else throw Error(r(558));else if(sn||ro(i,o,u,!1),y=(u&i.childLanes)!==0,sn||y){if(m=Nt,m!==null&&(E=Pe(m,u),E!==0&&E!==b.retryLane))throw b.retryLane=E,qi(i,E),tr(m,i,E),ym;qu(),o=cb(i,o,u)}else i=b.treeContext,Lt=Nr(E.nextSibling),Tn=o,lt=!0,ni=null,kr=!1,i!==null&&Yy(o,i),o=Iu(o,m),o.flags|=4096;return o}return i=Ss(i.child,{mode:m.mode,children:m.children}),i.ref=o.ref,o.child=i,i.return=o,i}function Pu(i,o){var u=o.ref;if(u===null)i!==null&&i.ref!==null&&(o.flags|=4194816);else{if(typeof u!="function"&&typeof u!="object")throw Error(r(284));(i===null||i.ref!==u)&&(o.flags|=4194816)}}function vm(i,o,u,m,y){return Qi(o),u=em(i,o,u,m,void 0,y),m=tm(),i!==null&&!sn?(nm(i,o,y),js(i,o,y)):(lt&&m&&Of(o),o.flags|=1,Dn(i,o,u,y),o.child)}function ub(i,o,u,m,y,b){return Qi(o),o.updateQueue=null,u=fv(o,m,u,y),hv(i),m=tm(),i!==null&&!sn?(nm(i,o,b),js(i,o,b)):(lt&&m&&Of(o),o.flags|=1,Dn(i,o,u,b),o.child)}function db(i,o,u,m,y){if(Qi(o),o.stateNode===null){var b=Za,E=u.contextType;typeof E=="object"&&E!==null&&(b=An(E)),b=new u(m,b),o.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=_m,o.stateNode=b,b._reactInternals=o,b=o.stateNode,b.props=m,b.state=o.memoizedState,b.refs={},Gf(o),E=u.contextType,b.context=typeof E=="object"&&E!==null?An(E):Za,b.state=o.memoizedState,E=u.getDerivedStateFromProps,typeof E=="function"&&(gm(o,u,E,m),b.state=o.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(E=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),E!==b.state&&_m.enqueueReplaceState(b,b.state,null),Sl(o,m,b,y),bl(),b.state=o.memoizedState),typeof b.componentDidMount=="function"&&(o.flags|=4194308),m=!0}else if(i===null){b=o.stateNode;var M=o.memoizedProps,Y=ra(u,M);b.props=Y;var ie=b.context,de=u.contextType;E=Za,typeof de=="object"&&de!==null&&(E=An(de));var ge=u.getDerivedStateFromProps;de=typeof ge=="function"||typeof b.getSnapshotBeforeUpdate=="function",M=o.pendingProps!==M,de||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(M||ie!==E)&&Qv(o,b,m,E),ii=!1;var ae=o.memoizedState;b.state=ae,Sl(o,m,b,y),bl(),ie=o.memoizedState,M||ae!==ie||ii?(typeof ge=="function"&&(gm(o,u,ge,m),ie=o.memoizedState),(Y=ii||Xv(o,u,Y,m,ae,ie,E))?(de||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(o.flags|=4194308)):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=m,o.memoizedState=ie),b.props=m,b.state=ie,b.context=E,m=Y):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),m=!1)}else{b=o.stateNode,qf(i,o),E=o.memoizedProps,de=ra(u,E),b.props=de,ge=o.pendingProps,ae=b.context,ie=u.contextType,Y=Za,typeof ie=="object"&&ie!==null&&(Y=An(ie)),M=u.getDerivedStateFromProps,(ie=typeof M=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(E!==ge||ae!==Y)&&Qv(o,b,m,Y),ii=!1,ae=o.memoizedState,b.state=ae,Sl(o,m,b,y),bl();var oe=o.memoizedState;E!==ge||ae!==oe||ii||i!==null&&i.dependencies!==null&&xu(i.dependencies)?(typeof M=="function"&&(gm(o,u,M,m),oe=o.memoizedState),(de=ii||Xv(o,u,de,m,ae,oe,Y)||i!==null&&i.dependencies!==null&&xu(i.dependencies))?(ie||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(m,oe,Y),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(m,oe,Y)),typeof b.componentDidUpdate=="function"&&(o.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof b.componentDidUpdate!="function"||E===i.memoizedProps&&ae===i.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||E===i.memoizedProps&&ae===i.memoizedState||(o.flags|=1024),o.memoizedProps=m,o.memoizedState=oe),b.props=m,b.state=oe,b.context=Y,m=de):(typeof b.componentDidUpdate!="function"||E===i.memoizedProps&&ae===i.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||E===i.memoizedProps&&ae===i.memoizedState||(o.flags|=1024),m=!1)}return b=m,Pu(i,o),m=(o.flags&128)!==0,b||m?(b=o.stateNode,u=m&&typeof u.getDerivedStateFromError!="function"?null:b.render(),o.flags|=1,i!==null&&m?(o.child=ta(o,i.child,null,y),o.child=ta(o,null,u,y)):Dn(i,o,u,y),o.memoizedState=b.state,i=o.child):i=js(i,o,y),i}function hb(i,o,u,m){return Yi(),o.flags|=256,Dn(i,o,u,m),o.child}var bm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Sm(i){return{baseLanes:i,cachePool:tv()}}function wm(i,o,u){return i=i!==null?i.childLanes&~u:0,o&&(i|=dr),i}function fb(i,o,u){var m=o.pendingProps,y=!1,b=(o.flags&128)!==0,E;if((E=b)||(E=i!==null&&i.memoizedState===null?!1:(Xt.current&2)!==0),E&&(y=!0,o.flags&=-129),E=(o.flags&32)!==0,o.flags&=-33,i===null){if(lt){if(y?li(o):ci(),(i=Lt)?(i=b0(i,kr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:ti!==null?{id:es,overflow:ts}:null,retryLane:536870912,hydrationErrors:null},u=Gy(i),u.return=o,o.child=u,Tn=o,Lt=null)):i=null,i===null)throw ri(o);return ip(i)?o.lanes=32:o.lanes=536870912,null}var M=m.children;return m=m.fallback,y?(ci(),y=o.mode,M=Bu({mode:"hidden",children:M},y),m=Ki(m,y,u,null),M.return=o,m.return=o,M.sibling=m,o.child=M,m=o.child,m.memoizedState=Sm(u),m.childLanes=wm(i,E,u),o.memoizedState=bm,Nl(null,m)):(li(o),Cm(o,M))}var Y=i.memoizedState;if(Y!==null&&(M=Y.dehydrated,M!==null)){if(b)o.flags&256?(li(o),o.flags&=-257,o=km(i,o,u)):o.memoizedState!==null?(ci(),o.child=i.child,o.flags|=128,o=null):(ci(),M=m.fallback,y=o.mode,m=Bu({mode:"visible",children:m.children},y),M=Ki(M,y,u,null),M.flags|=2,m.return=o,M.return=o,m.sibling=M,o.child=m,ta(o,i.child,null,u),m=o.child,m.memoizedState=Sm(u),m.childLanes=wm(i,E,u),o.memoizedState=bm,o=Nl(null,m));else if(li(o),ip(M)){if(E=M.nextSibling&&M.nextSibling.dataset,E)var ie=E.dgst;E=ie,m=Error(r(419)),m.stack="",m.digest=E,pl({value:m,source:null,stack:null}),o=km(i,o,u)}else if(sn||ro(i,o,u,!1),E=(u&i.childLanes)!==0,sn||E){if(E=Nt,E!==null&&(m=Pe(E,u),m!==0&&m!==Y.retryLane))throw Y.retryLane=m,qi(i,m),tr(E,i,m),ym;sp(M)||qu(),o=km(i,o,u)}else sp(M)?(o.flags|=192,o.child=i.child,o=null):(i=Y.treeContext,Lt=Nr(M.nextSibling),Tn=o,lt=!0,ni=null,kr=!1,i!==null&&Yy(o,i),o=Cm(o,m.children),o.flags|=4096);return o}return y?(ci(),M=m.fallback,y=o.mode,Y=i.child,ie=Y.sibling,m=Ss(Y,{mode:"hidden",children:m.children}),m.subtreeFlags=Y.subtreeFlags&65011712,ie!==null?M=Ss(ie,M):(M=Ki(M,y,u,null),M.flags|=2),M.return=o,m.return=o,m.sibling=M,o.child=m,Nl(null,m),m=o.child,M=i.child.memoizedState,M===null?M=Sm(u):(y=M.cachePool,y!==null?(Y=nn._currentValue,y=y.parent!==Y?{parent:Y,pool:Y}:y):y=tv(),M={baseLanes:M.baseLanes|u,cachePool:y}),m.memoizedState=M,m.childLanes=wm(i,E,u),o.memoizedState=bm,Nl(i.child,m)):(li(o),u=i.child,i=u.sibling,u=Ss(u,{mode:"visible",children:m.children}),u.return=o,u.sibling=null,i!==null&&(E=o.deletions,E===null?(o.deletions=[i],o.flags|=16):E.push(i)),o.child=u,o.memoizedState=null,u)}function Cm(i,o){return o=Bu({mode:"visible",children:o},i.mode),o.return=i,i.child=o}function Bu(i,o){return i=or(22,i,null,o),i.lanes=0,i}function km(i,o,u){return ta(o,i.child,null,u),i=Cm(o,o.pendingProps.children),i.flags|=2,o.memoizedState=null,i}function mb(i,o,u){i.lanes|=o;var m=i.alternate;m!==null&&(m.lanes|=o),$f(i.return,o,u)}function Em(i,o,u,m,y,b){var E=i.memoizedState;E===null?i.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:m,tail:u,tailMode:y,treeForkCount:b}:(E.isBackwards=o,E.rendering=null,E.renderingStartTime=0,E.last=m,E.tail=u,E.tailMode=y,E.treeForkCount=b)}function pb(i,o,u){var m=o.pendingProps,y=m.revealOrder,b=m.tail;m=m.children;var E=Xt.current,M=(E&2)!==0;if(M?(E=E&1|2,o.flags|=128):E&=1,O(Xt,E),Dn(i,o,m,u),m=lt?ml:0,!M&&i!==null&&(i.flags&128)!==0)e:for(i=o.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&mb(i,u,o);else if(i.tag===19)mb(i,u,o);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break e;for(;i.sibling===null;){if(i.return===null||i.return===o)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(y){case"forwards":for(u=o.child,y=null;u!==null;)i=u.alternate,i!==null&&Eu(i)===null&&(y=u),u=u.sibling;u=y,u===null?(y=o.child,o.child=null):(y=u.sibling,u.sibling=null),Em(o,!1,y,u,b,m);break;case"backwards":case"unstable_legacy-backwards":for(u=null,y=o.child,o.child=null;y!==null;){if(i=y.alternate,i!==null&&Eu(i)===null){o.child=y;break}i=y.sibling,y.sibling=u,u=y,y=i}Em(o,!0,u,null,b,m);break;case"together":Em(o,!1,null,null,void 0,m);break;default:o.memoizedState=null}return o.child}function js(i,o,u){if(i!==null&&(o.dependencies=i.dependencies),hi|=o.lanes,(u&o.childLanes)===0)if(i!==null){if(ro(i,o,u,!1),(u&o.childLanes)===0)return null}else return null;if(i!==null&&o.child!==i.child)throw Error(r(153));if(o.child!==null){for(i=o.child,u=Ss(i,i.pendingProps),o.child=u,u.return=o;i.sibling!==null;)i=i.sibling,u=u.sibling=Ss(i,i.pendingProps),u.return=o;u.sibling=null}return o.child}function Nm(i,o){return(i.lanes&o)!==0?!0:(i=i.dependencies,!!(i!==null&&xu(i)))}function xT(i,o,u){switch(o.tag){case 3:Se(o,o.stateNode.containerInfo),si(o,nn,i.memoizedState.cache),Yi();break;case 27:case 5:Ce(o);break;case 4:Se(o,o.stateNode.containerInfo);break;case 10:si(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Jf(o),null;break;case 13:var m=o.memoizedState;if(m!==null)return m.dehydrated!==null?(li(o),o.flags|=128,null):(u&o.child.childLanes)!==0?fb(i,o,u):(li(o),i=js(i,o,u),i!==null?i.sibling:null);li(o);break;case 19:var y=(i.flags&128)!==0;if(m=(u&o.childLanes)!==0,m||(ro(i,o,u,!1),m=(u&o.childLanes)!==0),y){if(m)return pb(i,o,u);o.flags|=128}if(y=o.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),O(Xt,Xt.current),m)break;return null;case 22:return o.lanes=0,ob(i,o,u,o.pendingProps);case 24:si(o,nn,i.memoizedState.cache)}return js(i,o,u)}function gb(i,o,u){if(i!==null)if(i.memoizedProps!==o.pendingProps)sn=!0;else{if(!Nm(i,u)&&(o.flags&128)===0)return sn=!1,xT(i,o,u);sn=(i.flags&131072)!==0}else sn=!1,lt&&(o.flags&1048576)!==0&&Ky(o,ml,o.index);switch(o.lanes=0,o.tag){case 16:e:{var m=o.pendingProps;if(i=Zi(o.elementType),o.type=i,typeof i=="function")Lf(i)?(m=ra(i,m),o.tag=1,o=db(null,o,i,m,u)):(o.tag=0,o=vm(null,o,i,m,u));else{if(i!=null){var y=i.$$typeof;if(y===A){o.tag=11,o=sb(null,o,i,m,u);break e}else if(y===q){o.tag=14,o=ib(null,o,i,m,u);break e}}throw o=U(i)||i,Error(r(306,o,""))}}return o;case 0:return vm(i,o,o.type,o.pendingProps,u);case 1:return m=o.type,y=ra(m,o.pendingProps),db(i,o,m,y,u);case 3:e:{if(Se(o,o.stateNode.containerInfo),i===null)throw Error(r(387));m=o.pendingProps;var b=o.memoizedState;y=b.element,qf(i,o),Sl(o,m,null,u);var E=o.memoizedState;if(m=E.cache,si(o,nn,m),m!==b.cache&&Hf(o,[nn],u,!0),bl(),m=E.element,b.isDehydrated)if(b={element:m,isDehydrated:!1,cache:E.cache},o.updateQueue.baseState=b,o.memoizedState=b,o.flags&256){o=hb(i,o,m,u);break e}else if(m!==y){y=Sr(Error(r(424)),o),pl(y),o=hb(i,o,m,u);break e}else{switch(i=o.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(Lt=Nr(i.firstChild),Tn=o,lt=!0,ni=null,kr=!0,u=ov(o,null,m,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling}else{if(Yi(),m===y){o=js(i,o,u);break e}Dn(i,o,m,u)}o=o.child}return o;case 26:return Pu(i,o),i===null?(u=N0(o.type,null,o.pendingProps,null))?o.memoizedState=u:lt||(u=o.type,i=o.pendingProps,m=ed(Z.current).createElement(u),m[yt]=o,m[Yn]=i,Ln(m,u,i),yn(m),o.stateNode=m):o.memoizedState=N0(o.type,i.memoizedProps,o.pendingProps,i.memoizedState),null;case 27:return Ce(o),i===null&&lt&&(m=o.stateNode=C0(o.type,o.pendingProps,Z.current),Tn=o,kr=!0,y=Lt,_i(o.type)?(ap=y,Lt=Nr(m.firstChild)):Lt=y),Dn(i,o,o.pendingProps.children,u),Pu(i,o),i===null&&(o.flags|=4194304),o.child;case 5:return i===null&&lt&&((y=m=Lt)&&(m=KT(m,o.type,o.pendingProps,kr),m!==null?(o.stateNode=m,Tn=o,Lt=Nr(m.firstChild),kr=!1,y=!0):y=!1),y||ri(o)),Ce(o),y=o.type,b=o.pendingProps,E=i!==null?i.memoizedProps:null,m=b.children,tp(y,b)?m=null:E!==null&&tp(y,E)&&(o.flags|=32),o.memoizedState!==null&&(y=em(i,o,cT,null,null,u),Fl._currentValue=y),Pu(i,o),Dn(i,o,m,u),o.child;case 6:return i===null&&lt&&((i=u=Lt)&&(u=YT(u,o.pendingProps,kr),u!==null?(o.stateNode=u,Tn=o,Lt=null,i=!0):i=!1),i||ri(o)),null;case 13:return fb(i,o,u);case 4:return Se(o,o.stateNode.containerInfo),m=o.pendingProps,i===null?o.child=ta(o,null,m,u):Dn(i,o,m,u),o.child;case 11:return sb(i,o,o.type,o.pendingProps,u);case 7:return Dn(i,o,o.pendingProps,u),o.child;case 8:return Dn(i,o,o.pendingProps.children,u),o.child;case 12:return Dn(i,o,o.pendingProps.children,u),o.child;case 10:return m=o.pendingProps,si(o,o.type,m.value),Dn(i,o,m.children,u),o.child;case 9:return y=o.type._context,m=o.pendingProps.children,Qi(o),y=An(y),m=m(y),o.flags|=1,Dn(i,o,m,u),o.child;case 14:return ib(i,o,o.type,o.pendingProps,u);case 15:return ab(i,o,o.type,o.pendingProps,u);case 19:return pb(i,o,u);case 31:return _T(i,o,u);case 22:return ob(i,o,u,o.pendingProps);case 24:return Qi(o),m=An(nn),i===null?(y=Vf(),y===null&&(y=Nt,b=Ff(),y.pooledCache=b,b.refCount++,b!==null&&(y.pooledCacheLanes|=u),y=b),o.memoizedState={parent:m,cache:y},Gf(o),si(o,nn,y)):((i.lanes&u)!==0&&(qf(i,o),Sl(o,null,null,u),bl()),y=i.memoizedState,b=o.memoizedState,y.parent!==m?(y={parent:m,cache:m},o.memoizedState=y,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=y),si(o,nn,m)):(m=b.cache,si(o,nn,m),m!==y.cache&&Hf(o,[nn],u,!0))),Dn(i,o,o.pendingProps.children,u),o.child;case 29:throw o.pendingProps}throw Error(r(156,o.tag))}function Ts(i){i.flags|=4}function jm(i,o,u,m,y){if((o=(i.mode&32)!==0)&&(o=!1),o){if(i.flags|=16777216,(y&335544128)===y)if(i.stateNode.complete)i.flags|=8192;else if(Ub())i.flags|=8192;else throw ea=Su,Wf}else i.flags&=-16777217}function _b(i,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!L0(o))if(Ub())i.flags|=8192;else throw ea=Su,Wf}function zu(i,o){o!==null&&(i.flags|=4),i.flags&16384&&(o=i.tag!==22?tu():536870912,i.lanes|=o,go|=o)}function jl(i,o){if(!lt)switch(i.tailMode){case"hidden":o=i.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?i.tail=null:u.sibling=null;break;case"collapsed":u=i.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?o||i.tail===null?i.tail=null:i.tail.sibling=null:m.sibling=null}}function Rt(i){var o=i.alternate!==null&&i.alternate.child===i.child,u=0,m=0;if(o)for(var y=i.child;y!==null;)u|=y.lanes|y.childLanes,m|=y.subtreeFlags&65011712,m|=y.flags&65011712,y.return=i,y=y.sibling;else for(y=i.child;y!==null;)u|=y.lanes|y.childLanes,m|=y.subtreeFlags,m|=y.flags,y.return=i,y=y.sibling;return i.subtreeFlags|=m,i.childLanes=u,o}function yT(i,o,u){var m=o.pendingProps;switch(If(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rt(o),null;case 1:return Rt(o),null;case 3:return u=o.stateNode,m=null,i!==null&&(m=i.memoizedState.cache),o.memoizedState.cache!==m&&(o.flags|=2048),ks(nn),le(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(i===null||i.child===null)&&(no(o)?Ts(o):i===null||i.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Bf())),Rt(o),null;case 26:var y=o.type,b=o.memoizedState;return i===null?(Ts(o),b!==null?(Rt(o),_b(o,b)):(Rt(o),jm(o,y,null,m,u))):b?b!==i.memoizedState?(Ts(o),Rt(o),_b(o,b)):(Rt(o),o.flags&=-16777217):(i=i.memoizedProps,i!==m&&Ts(o),Rt(o),jm(o,y,i,m,u)),null;case 27:if(Re(o),u=Z.current,y=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==m&&Ts(o);else{if(!m){if(o.stateNode===null)throw Error(r(166));return Rt(o),null}i=Q.current,no(o)?Xy(o):(i=C0(y,m,u),o.stateNode=i,Ts(o))}return Rt(o),null;case 5:if(Re(o),y=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==m&&Ts(o);else{if(!m){if(o.stateNode===null)throw Error(r(166));return Rt(o),null}if(b=Q.current,no(o))Xy(o);else{var E=ed(Z.current);switch(b){case 1:b=E.createElementNS("http://www.w3.org/2000/svg",y);break;case 2:b=E.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;default:switch(y){case"svg":b=E.createElementNS("http://www.w3.org/2000/svg",y);break;case"math":b=E.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;case"script":b=E.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof m.is=="string"?E.createElement("select",{is:m.is}):E.createElement("select"),m.multiple?b.multiple=!0:m.size&&(b.size=m.size);break;default:b=typeof m.is=="string"?E.createElement(y,{is:m.is}):E.createElement(y)}}b[yt]=o,b[Yn]=m;e:for(E=o.child;E!==null;){if(E.tag===5||E.tag===6)b.appendChild(E.stateNode);else if(E.tag!==4&&E.tag!==27&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===o)break e;for(;E.sibling===null;){if(E.return===null||E.return===o)break e;E=E.return}E.sibling.return=E.return,E=E.sibling}o.stateNode=b;e:switch(Ln(b,y,m),y){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&Ts(o)}}return Rt(o),jm(o,o.type,i===null?null:i.memoizedProps,o.pendingProps,u),null;case 6:if(i&&o.stateNode!=null)i.memoizedProps!==m&&Ts(o);else{if(typeof m!="string"&&o.stateNode===null)throw Error(r(166));if(i=Z.current,no(o)){if(i=o.stateNode,u=o.memoizedProps,m=null,y=Tn,y!==null)switch(y.tag){case 27:case 5:m=y.memoizedProps}i[yt]=o,i=!!(i.nodeValue===u||m!==null&&m.suppressHydrationWarning===!0||f0(i.nodeValue,u)),i||ri(o,!0)}else i=ed(i).createTextNode(m),i[yt]=o,o.stateNode=i}return Rt(o),null;case 31:if(u=o.memoizedState,i===null||i.memoizedState!==null){if(m=no(o),u!==null){if(i===null){if(!m)throw Error(r(318));if(i=o.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[yt]=o}else Yi(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Rt(o),i=!1}else u=Bf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),i=!0;if(!i)return o.flags&256?(cr(o),o):(cr(o),null);if((o.flags&128)!==0)throw Error(r(558))}return Rt(o),null;case 13:if(m=o.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(y=no(o),m!==null&&m.dehydrated!==null){if(i===null){if(!y)throw Error(r(318));if(y=o.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(r(317));y[yt]=o}else Yi(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Rt(o),y=!1}else y=Bf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=y),y=!0;if(!y)return o.flags&256?(cr(o),o):(cr(o),null)}return cr(o),(o.flags&128)!==0?(o.lanes=u,o):(u=m!==null,i=i!==null&&i.memoizedState!==null,u&&(m=o.child,y=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(y=m.alternate.memoizedState.cachePool.pool),b=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(b=m.memoizedState.cachePool.pool),b!==y&&(m.flags|=2048)),u!==i&&u&&(o.child.flags|=8192),zu(o,o.updateQueue),Rt(o),null);case 4:return le(),i===null&&Xm(o.stateNode.containerInfo),Rt(o),null;case 10:return ks(o.type),Rt(o),null;case 19:if(K(Xt),m=o.memoizedState,m===null)return Rt(o),null;if(y=(o.flags&128)!==0,b=m.rendering,b===null)if(y)jl(m,!1);else{if(Wt!==0||i!==null&&(i.flags&128)!==0)for(i=o.child;i!==null;){if(b=Eu(i),b!==null){for(o.flags|=128,jl(m,!1),i=b.updateQueue,o.updateQueue=i,zu(o,i),o.subtreeFlags=0,i=u,u=o.child;u!==null;)Wy(u,i),u=u.sibling;return O(Xt,Xt.current&1|2),lt&&ws(o,m.treeForkCount),o.child}i=i.sibling}m.tail!==null&&Yt()>Vu&&(o.flags|=128,y=!0,jl(m,!1),o.lanes=4194304)}else{if(!y)if(i=Eu(b),i!==null){if(o.flags|=128,y=!0,i=i.updateQueue,o.updateQueue=i,zu(o,i),jl(m,!0),m.tail===null&&m.tailMode==="hidden"&&!b.alternate&&!lt)return Rt(o),null}else 2*Yt()-m.renderingStartTime>Vu&&u!==536870912&&(o.flags|=128,y=!0,jl(m,!1),o.lanes=4194304);m.isBackwards?(b.sibling=o.child,o.child=b):(i=m.last,i!==null?i.sibling=b:o.child=b,m.last=b)}return m.tail!==null?(i=m.tail,m.rendering=i,m.tail=i.sibling,m.renderingStartTime=Yt(),i.sibling=null,u=Xt.current,O(Xt,y?u&1|2:u&1),lt&&ws(o,m.treeForkCount),i):(Rt(o),null);case 22:case 23:return cr(o),Qf(),m=o.memoizedState!==null,i!==null?i.memoizedState!==null!==m&&(o.flags|=8192):m&&(o.flags|=8192),m?(u&536870912)!==0&&(o.flags&128)===0&&(Rt(o),o.subtreeFlags&6&&(o.flags|=8192)):Rt(o),u=o.updateQueue,u!==null&&zu(o,u.retryQueue),u=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),m=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(m=o.memoizedState.cachePool.pool),m!==u&&(o.flags|=2048),i!==null&&K(Ji),null;case 24:return u=null,i!==null&&(u=i.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),ks(nn),Rt(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function vT(i,o){switch(If(o),o.tag){case 1:return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 3:return ks(nn),le(),i=o.flags,(i&65536)!==0&&(i&128)===0?(o.flags=i&-65537|128,o):null;case 26:case 27:case 5:return Re(o),null;case 31:if(o.memoizedState!==null){if(cr(o),o.alternate===null)throw Error(r(340));Yi()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 13:if(cr(o),i=o.memoizedState,i!==null&&i.dehydrated!==null){if(o.alternate===null)throw Error(r(340));Yi()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 19:return K(Xt),null;case 4:return le(),null;case 10:return ks(o.type),null;case 22:case 23:return cr(o),Qf(),i!==null&&K(Ji),i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 24:return ks(nn),null;case 25:return null;default:return null}}function xb(i,o){switch(If(o),o.tag){case 3:ks(nn),le();break;case 26:case 27:case 5:Re(o);break;case 4:le();break;case 31:o.memoizedState!==null&&cr(o);break;case 13:cr(o);break;case 19:K(Xt);break;case 10:ks(o.type);break;case 22:case 23:cr(o),Qf(),i!==null&&K(Ji);break;case 24:ks(nn)}}function Tl(i,o){try{var u=o.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var y=m.next;u=y;do{if((u.tag&i)===i){m=void 0;var b=u.create,E=u.inst;m=b(),E.destroy=m}u=u.next}while(u!==y)}}catch(M){bt(o,o.return,M)}}function ui(i,o,u){try{var m=o.updateQueue,y=m!==null?m.lastEffect:null;if(y!==null){var b=y.next;m=b;do{if((m.tag&i)===i){var E=m.inst,M=E.destroy;if(M!==void 0){E.destroy=void 0,y=o;var Y=u,ie=M;try{ie()}catch(de){bt(y,Y,de)}}}m=m.next}while(m!==b)}}catch(de){bt(o,o.return,de)}}function yb(i){var o=i.updateQueue;if(o!==null){var u=i.stateNode;try{cv(o,u)}catch(m){bt(i,i.return,m)}}}function vb(i,o,u){u.props=ra(i.type,i.memoizedProps),u.state=i.memoizedState;try{u.componentWillUnmount()}catch(m){bt(i,o,m)}}function Al(i,o){try{var u=i.ref;if(u!==null){switch(i.tag){case 26:case 27:case 5:var m=i.stateNode;break;case 30:m=i.stateNode;break;default:m=i.stateNode}typeof u=="function"?i.refCleanup=u(m):u.current=m}}catch(y){bt(i,o,y)}}function ns(i,o){var u=i.ref,m=i.refCleanup;if(u!==null)if(typeof m=="function")try{m()}catch(y){bt(i,o,y)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(y){bt(i,o,y)}else u.current=null}function bb(i){var o=i.type,u=i.memoizedProps,m=i.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":u.autoFocus&&m.focus();break e;case"img":u.src?m.src=u.src:u.srcSet&&(m.srcset=u.srcSet)}}catch(y){bt(i,i.return,y)}}function Tm(i,o,u){try{var m=i.stateNode;FT(m,i.type,u,o),m[Yn]=o}catch(y){bt(i,i.return,y)}}function Sb(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&_i(i.type)||i.tag===4}function Am(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Sb(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&_i(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Dm(i,o,u){var m=i.tag;if(m===5||m===6)i=i.stateNode,o?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(i,o):(o=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,o.appendChild(i),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=vs));else if(m!==4&&(m===27&&_i(i.type)&&(u=i.stateNode,o=null),i=i.child,i!==null))for(Dm(i,o,u),i=i.sibling;i!==null;)Dm(i,o,u),i=i.sibling}function $u(i,o,u){var m=i.tag;if(m===5||m===6)i=i.stateNode,o?u.insertBefore(i,o):u.appendChild(i);else if(m!==4&&(m===27&&_i(i.type)&&(u=i.stateNode),i=i.child,i!==null))for($u(i,o,u),i=i.sibling;i!==null;)$u(i,o,u),i=i.sibling}function wb(i){var o=i.stateNode,u=i.memoizedProps;try{for(var m=i.type,y=o.attributes;y.length;)o.removeAttributeNode(y[0]);Ln(o,m,u),o[yt]=i,o[Yn]=u}catch(b){bt(i,i.return,b)}}var As=!1,an=!1,Lm=!1,Cb=typeof WeakSet=="function"?WeakSet:Set,vn=null;function bT(i,o){if(i=i.containerInfo,Zm=od,i=Iy(i),kf(i)){if("selectionStart"in i)var u={start:i.selectionStart,end:i.selectionEnd};else e:{u=(u=i.ownerDocument)&&u.defaultView||window;var m=u.getSelection&&u.getSelection();if(m&&m.rangeCount!==0){u=m.anchorNode;var y=m.anchorOffset,b=m.focusNode;m=m.focusOffset;try{u.nodeType,b.nodeType}catch{u=null;break e}var E=0,M=-1,Y=-1,ie=0,de=0,ge=i,ae=null;t:for(;;){for(var oe;ge!==u||y!==0&&ge.nodeType!==3||(M=E+y),ge!==b||m!==0&&ge.nodeType!==3||(Y=E+m),ge.nodeType===3&&(E+=ge.nodeValue.length),(oe=ge.firstChild)!==null;)ae=ge,ge=oe;for(;;){if(ge===i)break t;if(ae===u&&++ie===y&&(M=E),ae===b&&++de===m&&(Y=E),(oe=ge.nextSibling)!==null)break;ge=ae,ae=ge.parentNode}ge=oe}u=M===-1||Y===-1?null:{start:M,end:Y}}else u=null}u=u||{start:0,end:0}}else u=null;for(ep={focusedElem:i,selectionRange:u},od=!1,vn=o;vn!==null;)if(o=vn,i=o.child,(o.subtreeFlags&1028)!==0&&i!==null)i.return=o,vn=i;else for(;vn!==null;){switch(o=vn,b=o.alternate,i=o.flags,o.tag){case 0:if((i&4)!==0&&(i=o.updateQueue,i=i!==null?i.events:null,i!==null))for(u=0;u<i.length;u++)y=i[u],y.ref.impl=y.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&b!==null){i=void 0,u=o,y=b.memoizedProps,b=b.memoizedState,m=u.stateNode;try{var Ae=ra(u.type,y);i=m.getSnapshotBeforeUpdate(Ae,b),m.__reactInternalSnapshotBeforeUpdate=i}catch(He){bt(u,u.return,He)}}break;case 3:if((i&1024)!==0){if(i=o.stateNode.containerInfo,u=i.nodeType,u===9)rp(i);else if(u===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":rp(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=o.sibling,i!==null){i.return=o.return,vn=i;break}vn=o.return}}function kb(i,o,u){var m=u.flags;switch(u.tag){case 0:case 11:case 15:Ls(i,u),m&4&&Tl(5,u);break;case 1:if(Ls(i,u),m&4)if(i=u.stateNode,o===null)try{i.componentDidMount()}catch(E){bt(u,u.return,E)}else{var y=ra(u.type,o.memoizedProps);o=o.memoizedState;try{i.componentDidUpdate(y,o,i.__reactInternalSnapshotBeforeUpdate)}catch(E){bt(u,u.return,E)}}m&64&&yb(u),m&512&&Al(u,u.return);break;case 3:if(Ls(i,u),m&64&&(i=u.updateQueue,i!==null)){if(o=null,u.child!==null)switch(u.child.tag){case 27:case 5:o=u.child.stateNode;break;case 1:o=u.child.stateNode}try{cv(i,o)}catch(E){bt(u,u.return,E)}}break;case 27:o===null&&m&4&&wb(u);case 26:case 5:Ls(i,u),o===null&&m&4&&bb(u),m&512&&Al(u,u.return);break;case 12:Ls(i,u);break;case 31:Ls(i,u),m&4&&jb(i,u);break;case 13:Ls(i,u),m&4&&Tb(i,u),m&64&&(i=u.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(u=AT.bind(null,u),XT(i,u))));break;case 22:if(m=u.memoizedState!==null||As,!m){o=o!==null&&o.memoizedState!==null||an,y=As;var b=an;As=m,(an=o)&&!b?Rs(i,u,(u.subtreeFlags&8772)!==0):Ls(i,u),As=y,an=b}break;case 30:break;default:Ls(i,u)}}function Eb(i){var o=i.alternate;o!==null&&(i.alternate=null,Eb(o)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(o=i.stateNode,o!==null&&lf(o)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Pt=null,Qn=!1;function Ds(i,o,u){for(u=u.child;u!==null;)Nb(i,o,u),u=u.sibling}function Nb(i,o,u){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(zt,u)}catch{}switch(u.tag){case 26:an||ns(u,o),Ds(i,o,u),u.memoizedState?u.memoizedState.count--:u.stateNode&&(u=u.stateNode,u.parentNode.removeChild(u));break;case 27:an||ns(u,o);var m=Pt,y=Qn;_i(u.type)&&(Pt=u.stateNode,Qn=!1),Ds(i,o,u),zl(u.stateNode),Pt=m,Qn=y;break;case 5:an||ns(u,o);case 6:if(m=Pt,y=Qn,Pt=null,Ds(i,o,u),Pt=m,Qn=y,Pt!==null)if(Qn)try{(Pt.nodeType===9?Pt.body:Pt.nodeName==="HTML"?Pt.ownerDocument.body:Pt).removeChild(u.stateNode)}catch(b){bt(u,o,b)}else try{Pt.removeChild(u.stateNode)}catch(b){bt(u,o,b)}break;case 18:Pt!==null&&(Qn?(i=Pt,y0(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,u.stateNode),Co(i)):y0(Pt,u.stateNode));break;case 4:m=Pt,y=Qn,Pt=u.stateNode.containerInfo,Qn=!0,Ds(i,o,u),Pt=m,Qn=y;break;case 0:case 11:case 14:case 15:ui(2,u,o),an||ui(4,u,o),Ds(i,o,u);break;case 1:an||(ns(u,o),m=u.stateNode,typeof m.componentWillUnmount=="function"&&vb(u,o,m)),Ds(i,o,u);break;case 21:Ds(i,o,u);break;case 22:an=(m=an)||u.memoizedState!==null,Ds(i,o,u),an=m;break;default:Ds(i,o,u)}}function jb(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Co(i)}catch(u){bt(o,o.return,u)}}}function Tb(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Co(i)}catch(u){bt(o,o.return,u)}}function ST(i){switch(i.tag){case 31:case 13:case 19:var o=i.stateNode;return o===null&&(o=i.stateNode=new Cb),o;case 22:return i=i.stateNode,o=i._retryCache,o===null&&(o=i._retryCache=new Cb),o;default:throw Error(r(435,i.tag))}}function Hu(i,o){var u=ST(i);o.forEach(function(m){if(!u.has(m)){u.add(m);var y=DT.bind(null,i,m);m.then(y,y)}})}function Jn(i,o){var u=o.deletions;if(u!==null)for(var m=0;m<u.length;m++){var y=u[m],b=i,E=o,M=E;e:for(;M!==null;){switch(M.tag){case 27:if(_i(M.type)){Pt=M.stateNode,Qn=!1;break e}break;case 5:Pt=M.stateNode,Qn=!1;break e;case 3:case 4:Pt=M.stateNode.containerInfo,Qn=!0;break e}M=M.return}if(Pt===null)throw Error(r(160));Nb(b,E,y),Pt=null,Qn=!1,b=y.alternate,b!==null&&(b.return=null),y.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)Ab(o,i),o=o.sibling}var Fr=null;function Ab(i,o){var u=i.alternate,m=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Jn(o,i),Zn(i),m&4&&(ui(3,i,i.return),Tl(3,i),ui(5,i,i.return));break;case 1:Jn(o,i),Zn(i),m&512&&(an||u===null||ns(u,u.return)),m&64&&As&&(i=i.updateQueue,i!==null&&(m=i.callbacks,m!==null&&(u=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=u===null?m:u.concat(m))));break;case 26:var y=Fr;if(Jn(o,i),Zn(i),m&512&&(an||u===null||ns(u,u.return)),m&4){var b=u!==null?u.memoizedState:null;if(m=i.memoizedState,u===null)if(m===null)if(i.stateNode===null){e:{m=i.type,u=i.memoizedProps,y=y.ownerDocument||y;t:switch(m){case"title":b=y.getElementsByTagName("title")[0],(!b||b[rl]||b[yt]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=y.createElement(m),y.head.insertBefore(b,y.querySelector("head > title"))),Ln(b,m,u),b[yt]=i,yn(b),m=b;break e;case"link":var E=A0("link","href",y).get(m+(u.href||""));if(E){for(var M=0;M<E.length;M++)if(b=E[M],b.getAttribute("href")===(u.href==null||u.href===""?null:u.href)&&b.getAttribute("rel")===(u.rel==null?null:u.rel)&&b.getAttribute("title")===(u.title==null?null:u.title)&&b.getAttribute("crossorigin")===(u.crossOrigin==null?null:u.crossOrigin)){E.splice(M,1);break t}}b=y.createElement(m),Ln(b,m,u),y.head.appendChild(b);break;case"meta":if(E=A0("meta","content",y).get(m+(u.content||""))){for(M=0;M<E.length;M++)if(b=E[M],b.getAttribute("content")===(u.content==null?null:""+u.content)&&b.getAttribute("name")===(u.name==null?null:u.name)&&b.getAttribute("property")===(u.property==null?null:u.property)&&b.getAttribute("http-equiv")===(u.httpEquiv==null?null:u.httpEquiv)&&b.getAttribute("charset")===(u.charSet==null?null:u.charSet)){E.splice(M,1);break t}}b=y.createElement(m),Ln(b,m,u),y.head.appendChild(b);break;default:throw Error(r(468,m))}b[yt]=i,yn(b),m=b}i.stateNode=m}else D0(y,i.type,i.stateNode);else i.stateNode=T0(y,m,i.memoizedProps);else b!==m?(b===null?u.stateNode!==null&&(u=u.stateNode,u.parentNode.removeChild(u)):b.count--,m===null?D0(y,i.type,i.stateNode):T0(y,m,i.memoizedProps)):m===null&&i.stateNode!==null&&Tm(i,i.memoizedProps,u.memoizedProps)}break;case 27:Jn(o,i),Zn(i),m&512&&(an||u===null||ns(u,u.return)),u!==null&&m&4&&Tm(i,i.memoizedProps,u.memoizedProps);break;case 5:if(Jn(o,i),Zn(i),m&512&&(an||u===null||ns(u,u.return)),i.flags&32){y=i.stateNode;try{Ga(y,"")}catch(Ae){bt(i,i.return,Ae)}}m&4&&i.stateNode!=null&&(y=i.memoizedProps,Tm(i,y,u!==null?u.memoizedProps:y)),m&1024&&(Lm=!0);break;case 6:if(Jn(o,i),Zn(i),m&4){if(i.stateNode===null)throw Error(r(162));m=i.memoizedProps,u=i.stateNode;try{u.nodeValue=m}catch(Ae){bt(i,i.return,Ae)}}break;case 3:if(rd=null,y=Fr,Fr=td(o.containerInfo),Jn(o,i),Fr=y,Zn(i),m&4&&u!==null&&u.memoizedState.isDehydrated)try{Co(o.containerInfo)}catch(Ae){bt(i,i.return,Ae)}Lm&&(Lm=!1,Db(i));break;case 4:m=Fr,Fr=td(i.stateNode.containerInfo),Jn(o,i),Zn(i),Fr=m;break;case 12:Jn(o,i),Zn(i);break;case 31:Jn(o,i),Zn(i),m&4&&(m=i.updateQueue,m!==null&&(i.updateQueue=null,Hu(i,m)));break;case 13:Jn(o,i),Zn(i),i.child.flags&8192&&i.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(Uu=Yt()),m&4&&(m=i.updateQueue,m!==null&&(i.updateQueue=null,Hu(i,m)));break;case 22:y=i.memoizedState!==null;var Y=u!==null&&u.memoizedState!==null,ie=As,de=an;if(As=ie||y,an=de||Y,Jn(o,i),an=de,As=ie,Zn(i),m&8192)e:for(o=i.stateNode,o._visibility=y?o._visibility&-2:o._visibility|1,y&&(u===null||Y||As||an||sa(i)),u=null,o=i;;){if(o.tag===5||o.tag===26){if(u===null){Y=u=o;try{if(b=Y.stateNode,y)E=b.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none";else{M=Y.stateNode;var ge=Y.memoizedProps.style,ae=ge!=null&&ge.hasOwnProperty("display")?ge.display:null;M.style.display=ae==null||typeof ae=="boolean"?"":(""+ae).trim()}}catch(Ae){bt(Y,Y.return,Ae)}}}else if(o.tag===6){if(u===null){Y=o;try{Y.stateNode.nodeValue=y?"":Y.memoizedProps}catch(Ae){bt(Y,Y.return,Ae)}}}else if(o.tag===18){if(u===null){Y=o;try{var oe=Y.stateNode;y?v0(oe,!0):v0(Y.stateNode,!1)}catch(Ae){bt(Y,Y.return,Ae)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===i)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break e;for(;o.sibling===null;){if(o.return===null||o.return===i)break e;u===o&&(u=null),o=o.return}u===o&&(u=null),o.sibling.return=o.return,o=o.sibling}m&4&&(m=i.updateQueue,m!==null&&(u=m.retryQueue,u!==null&&(m.retryQueue=null,Hu(i,u))));break;case 19:Jn(o,i),Zn(i),m&4&&(m=i.updateQueue,m!==null&&(i.updateQueue=null,Hu(i,m)));break;case 30:break;case 21:break;default:Jn(o,i),Zn(i)}}function Zn(i){var o=i.flags;if(o&2){try{for(var u,m=i.return;m!==null;){if(Sb(m)){u=m;break}m=m.return}if(u==null)throw Error(r(160));switch(u.tag){case 27:var y=u.stateNode,b=Am(i);$u(i,b,y);break;case 5:var E=u.stateNode;u.flags&32&&(Ga(E,""),u.flags&=-33);var M=Am(i);$u(i,M,E);break;case 3:case 4:var Y=u.stateNode.containerInfo,ie=Am(i);Dm(i,ie,Y);break;default:throw Error(r(161))}}catch(de){bt(i,i.return,de)}i.flags&=-3}o&4096&&(i.flags&=-4097)}function Db(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var o=i;Db(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),i=i.sibling}}function Ls(i,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)kb(i,o.alternate,o),o=o.sibling}function sa(i){for(i=i.child;i!==null;){var o=i;switch(o.tag){case 0:case 11:case 14:case 15:ui(4,o,o.return),sa(o);break;case 1:ns(o,o.return);var u=o.stateNode;typeof u.componentWillUnmount=="function"&&vb(o,o.return,u),sa(o);break;case 27:zl(o.stateNode);case 26:case 5:ns(o,o.return),sa(o);break;case 22:o.memoizedState===null&&sa(o);break;case 30:sa(o);break;default:sa(o)}i=i.sibling}}function Rs(i,o,u){for(u=u&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var m=o.alternate,y=i,b=o,E=b.flags;switch(b.tag){case 0:case 11:case 15:Rs(y,b,u),Tl(4,b);break;case 1:if(Rs(y,b,u),m=b,y=m.stateNode,typeof y.componentDidMount=="function")try{y.componentDidMount()}catch(ie){bt(m,m.return,ie)}if(m=b,y=m.updateQueue,y!==null){var M=m.stateNode;try{var Y=y.shared.hiddenCallbacks;if(Y!==null)for(y.shared.hiddenCallbacks=null,y=0;y<Y.length;y++)lv(Y[y],M)}catch(ie){bt(m,m.return,ie)}}u&&E&64&&yb(b),Al(b,b.return);break;case 27:wb(b);case 26:case 5:Rs(y,b,u),u&&m===null&&E&4&&bb(b),Al(b,b.return);break;case 12:Rs(y,b,u);break;case 31:Rs(y,b,u),u&&E&4&&jb(y,b);break;case 13:Rs(y,b,u),u&&E&4&&Tb(y,b);break;case 22:b.memoizedState===null&&Rs(y,b,u),Al(b,b.return);break;case 30:break;default:Rs(y,b,u)}o=o.sibling}}function Rm(i,o){var u=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),i=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(i=o.memoizedState.cachePool.pool),i!==u&&(i!=null&&i.refCount++,u!=null&&gl(u))}function Mm(i,o){i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&gl(i))}function Ur(i,o,u,m){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)Lb(i,o,u,m),o=o.sibling}function Lb(i,o,u,m){var y=o.flags;switch(o.tag){case 0:case 11:case 15:Ur(i,o,u,m),y&2048&&Tl(9,o);break;case 1:Ur(i,o,u,m);break;case 3:Ur(i,o,u,m),y&2048&&(i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&gl(i)));break;case 12:if(y&2048){Ur(i,o,u,m),i=o.stateNode;try{var b=o.memoizedProps,E=b.id,M=b.onPostCommit;typeof M=="function"&&M(E,o.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(Y){bt(o,o.return,Y)}}else Ur(i,o,u,m);break;case 31:Ur(i,o,u,m);break;case 13:Ur(i,o,u,m);break;case 23:break;case 22:b=o.stateNode,E=o.alternate,o.memoizedState!==null?b._visibility&2?Ur(i,o,u,m):Dl(i,o):b._visibility&2?Ur(i,o,u,m):(b._visibility|=2,fo(i,o,u,m,(o.subtreeFlags&10256)!==0||!1)),y&2048&&Rm(E,o);break;case 24:Ur(i,o,u,m),y&2048&&Mm(o.alternate,o);break;default:Ur(i,o,u,m)}}function fo(i,o,u,m,y){for(y=y&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var b=i,E=o,M=u,Y=m,ie=E.flags;switch(E.tag){case 0:case 11:case 15:fo(b,E,M,Y,y),Tl(8,E);break;case 23:break;case 22:var de=E.stateNode;E.memoizedState!==null?de._visibility&2?fo(b,E,M,Y,y):Dl(b,E):(de._visibility|=2,fo(b,E,M,Y,y)),y&&ie&2048&&Rm(E.alternate,E);break;case 24:fo(b,E,M,Y,y),y&&ie&2048&&Mm(E.alternate,E);break;default:fo(b,E,M,Y,y)}o=o.sibling}}function Dl(i,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var u=i,m=o,y=m.flags;switch(m.tag){case 22:Dl(u,m),y&2048&&Rm(m.alternate,m);break;case 24:Dl(u,m),y&2048&&Mm(m.alternate,m);break;default:Dl(u,m)}o=o.sibling}}var Ll=8192;function mo(i,o,u){if(i.subtreeFlags&Ll)for(i=i.child;i!==null;)Rb(i,o,u),i=i.sibling}function Rb(i,o,u){switch(i.tag){case 26:mo(i,o,u),i.flags&Ll&&i.memoizedState!==null&&lA(u,Fr,i.memoizedState,i.memoizedProps);break;case 5:mo(i,o,u);break;case 3:case 4:var m=Fr;Fr=td(i.stateNode.containerInfo),mo(i,o,u),Fr=m;break;case 22:i.memoizedState===null&&(m=i.alternate,m!==null&&m.memoizedState!==null?(m=Ll,Ll=16777216,mo(i,o,u),Ll=m):mo(i,o,u));break;default:mo(i,o,u)}}function Mb(i){var o=i.alternate;if(o!==null&&(i=o.child,i!==null)){o.child=null;do o=i.sibling,i.sibling=null,i=o;while(i!==null)}}function Rl(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var m=o[u];vn=m,Ib(m,i)}Mb(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Ob(i),i=i.sibling}function Ob(i){switch(i.tag){case 0:case 11:case 15:Rl(i),i.flags&2048&&ui(9,i,i.return);break;case 3:Rl(i);break;case 12:Rl(i);break;case 22:var o=i.stateNode;i.memoizedState!==null&&o._visibility&2&&(i.return===null||i.return.tag!==13)?(o._visibility&=-3,Fu(i)):Rl(i);break;default:Rl(i)}}function Fu(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var m=o[u];vn=m,Ib(m,i)}Mb(i)}for(i=i.child;i!==null;){switch(o=i,o.tag){case 0:case 11:case 15:ui(8,o,o.return),Fu(o);break;case 22:u=o.stateNode,u._visibility&2&&(u._visibility&=-3,Fu(o));break;default:Fu(o)}i=i.sibling}}function Ib(i,o){for(;vn!==null;){var u=vn;switch(u.tag){case 0:case 11:case 15:ui(8,u,o);break;case 23:case 22:if(u.memoizedState!==null&&u.memoizedState.cachePool!==null){var m=u.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:gl(u.memoizedState.cache)}if(m=u.child,m!==null)m.return=u,vn=m;else e:for(u=i;vn!==null;){m=vn;var y=m.sibling,b=m.return;if(Eb(m),m===u){vn=null;break e}if(y!==null){y.return=b,vn=y;break e}vn=b}}}var wT={getCacheForType:function(i){var o=An(nn),u=o.data.get(i);return u===void 0&&(u=i(),o.data.set(i,u)),u},cacheSignal:function(){return An(nn).controller.signal}},CT=typeof WeakMap=="function"?WeakMap:Map,gt=0,Nt=null,tt=null,at=0,vt=0,ur=null,di=!1,po=!1,Om=!1,Ms=0,Wt=0,hi=0,ia=0,Im=0,dr=0,go=0,Ml=null,er=null,Pm=!1,Uu=0,Pb=0,Vu=1/0,Wu=null,fi=null,dn=0,mi=null,_o=null,Os=0,Bm=0,zm=null,Bb=null,Ol=0,$m=null;function hr(){return(gt&2)!==0&&at!==0?at&-at:N.T!==null?Gm():dt()}function zb(){if(dr===0)if((at&536870912)===0||lt){var i=Ia;Ia<<=1,(Ia&3932160)===0&&(Ia=262144),dr=i}else dr=536870912;return i=lr.current,i!==null&&(i.flags|=32),dr}function tr(i,o,u){(i===Nt&&(vt===2||vt===9)||i.cancelPendingCommit!==null)&&(xo(i,0),pi(i,at,dr,!1)),Zs(i,u),((gt&2)===0||i!==Nt)&&(i===Nt&&((gt&2)===0&&(ia|=u),Wt===4&&pi(i,at,dr,!1)),rs(i))}function $b(i,o,u){if((gt&6)!==0)throw Error(r(327));var m=!u&&(o&127)===0&&(o&i.expiredLanes)===0||Fi(i,o),y=m?NT(i,o):Fm(i,o,!0),b=m;do{if(y===0){po&&!m&&pi(i,o,0,!1);break}else{if(u=i.current.alternate,b&&!kT(u)){y=Fm(i,o,!1),b=!1;continue}if(y===2){if(b=o,i.errorRecoveryDisabledLanes&b)var E=0;else E=i.pendingLanes&-536870913,E=E!==0?E:E&536870912?536870912:0;if(E!==0){o=E;e:{var M=i;y=Ml;var Y=M.current.memoizedState.isDehydrated;if(Y&&(xo(M,E).flags|=256),E=Fm(M,E,!1),E!==2){if(Om&&!Y){M.errorRecoveryDisabledLanes|=b,ia|=b,y=4;break e}b=er,er=y,b!==null&&(er===null?er=b:er.push.apply(er,b))}y=E}if(b=!1,y!==2)continue}}if(y===1){xo(i,0),pi(i,o,0,!0);break}e:{switch(m=i,b=y,b){case 0:case 1:throw Error(r(345));case 4:if((o&4194048)!==o)break;case 6:pi(m,o,dr,!di);break e;case 2:er=null;break;case 3:case 5:break;default:throw Error(r(329))}if((o&62914560)===o&&(y=Uu+300-Yt(),10<y)){if(pi(m,o,dr,!di),Ba(m,0,!0)!==0)break e;Os=o,m.timeoutHandle=_0(Hb.bind(null,m,u,er,Wu,Pm,o,dr,ia,go,di,b,"Throttled",-0,0),y);break e}Hb(m,u,er,Wu,Pm,o,dr,ia,go,di,b,null,-0,0)}}break}while(!0);rs(i)}function Hb(i,o,u,m,y,b,E,M,Y,ie,de,ge,ae,oe){if(i.timeoutHandle=-1,ge=o.subtreeFlags,ge&8192||(ge&16785408)===16785408){ge={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:vs},Rb(o,b,ge);var Ae=(b&62914560)===b?Uu-Yt():(b&4194048)===b?Pb-Yt():0;if(Ae=cA(ge,Ae),Ae!==null){Os=b,i.cancelPendingCommit=Ae(Yb.bind(null,i,o,b,u,m,y,E,M,Y,de,ge,null,ae,oe)),pi(i,b,E,!ie);return}}Yb(i,o,b,u,m,y,E,M,Y)}function kT(i){for(var o=i;;){var u=o.tag;if((u===0||u===11||u===15)&&o.flags&16384&&(u=o.updateQueue,u!==null&&(u=u.stores,u!==null)))for(var m=0;m<u.length;m++){var y=u[m],b=y.getSnapshot;y=y.value;try{if(!ar(b(),y))return!1}catch{return!1}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function pi(i,o,u,m){o&=~Im,o&=~ia,i.suspendedLanes|=o,i.pingedLanes&=~o,m&&(i.warmLanes|=o),m=i.expirationTimes;for(var y=o;0<y;){var b=31-xt(y),E=1<<b;m[b]=-1,y&=~E}u!==0&&he(i,u,o)}function Gu(){return(gt&6)===0?(Il(0),!1):!0}function Hm(){if(tt!==null){if(vt===0)var i=tt.return;else i=tt,Cs=Xi=null,rm(i),oo=null,xl=0,i=tt;for(;i!==null;)xb(i.alternate,i),i=i.return;tt=null}}function xo(i,o){var u=i.timeoutHandle;u!==-1&&(i.timeoutHandle=-1,WT(u)),u=i.cancelPendingCommit,u!==null&&(i.cancelPendingCommit=null,u()),Os=0,Hm(),Nt=i,tt=u=Ss(i.current,null),at=o,vt=0,ur=null,di=!1,po=Fi(i,o),Om=!1,go=dr=Im=ia=hi=Wt=0,er=Ml=null,Pm=!1,(o&8)!==0&&(o|=o&32);var m=i.entangledLanes;if(m!==0)for(i=i.entanglements,m&=o;0<m;){var y=31-xt(m),b=1<<y;o|=i[y],m&=~b}return Ms=o,fu(),u}function Fb(i,o){qe=null,N.H=El,o===ao||o===bu?(o=sv(),vt=3):o===Wf?(o=sv(),vt=4):vt=o===ym?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,ur=o,tt===null&&(Wt=1,Ou(i,Sr(o,i.current)))}function Ub(){var i=lr.current;return i===null?!0:(at&4194048)===at?Er===null:(at&62914560)===at||(at&536870912)!==0?i===Er:!1}function Vb(){var i=N.H;return N.H=El,i===null?El:i}function Wb(){var i=N.A;return N.A=wT,i}function qu(){Wt=4,di||(at&4194048)!==at&&lr.current!==null||(po=!0),(hi&134217727)===0&&(ia&134217727)===0||Nt===null||pi(Nt,at,dr,!1)}function Fm(i,o,u){var m=gt;gt|=2;var y=Vb(),b=Wb();(Nt!==i||at!==o)&&(Wu=null,xo(i,o)),o=!1;var E=Wt;e:do try{if(vt!==0&&tt!==null){var M=tt,Y=ur;switch(vt){case 8:Hm(),E=6;break e;case 3:case 2:case 9:case 6:lr.current===null&&(o=!0);var ie=vt;if(vt=0,ur=null,yo(i,M,Y,ie),u&&po){E=0;break e}break;default:ie=vt,vt=0,ur=null,yo(i,M,Y,ie)}}ET(),E=Wt;break}catch(de){Fb(i,de)}while(!0);return o&&i.shellSuspendCounter++,Cs=Xi=null,gt=m,N.H=y,N.A=b,tt===null&&(Nt=null,at=0,fu()),E}function ET(){for(;tt!==null;)Gb(tt)}function NT(i,o){var u=gt;gt|=2;var m=Vb(),y=Wb();Nt!==i||at!==o?(Wu=null,Vu=Yt()+500,xo(i,o)):po=Fi(i,o);e:do try{if(vt!==0&&tt!==null){o=tt;var b=ur;t:switch(vt){case 1:vt=0,ur=null,yo(i,o,b,1);break;case 2:case 9:if(nv(b)){vt=0,ur=null,qb(o);break}o=function(){vt!==2&&vt!==9||Nt!==i||(vt=7),rs(i)},b.then(o,o);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:nv(b)?(vt=0,ur=null,qb(o)):(vt=0,ur=null,yo(i,o,b,7));break;case 5:var E=null;switch(tt.tag){case 26:E=tt.memoizedState;case 5:case 27:var M=tt;if(E?L0(E):M.stateNode.complete){vt=0,ur=null;var Y=M.sibling;if(Y!==null)tt=Y;else{var ie=M.return;ie!==null?(tt=ie,Ku(ie)):tt=null}break t}}vt=0,ur=null,yo(i,o,b,5);break;case 6:vt=0,ur=null,yo(i,o,b,6);break;case 8:Hm(),Wt=6;break e;default:throw Error(r(462))}}jT();break}catch(de){Fb(i,de)}while(!0);return Cs=Xi=null,N.H=m,N.A=y,gt=u,tt!==null?0:(Nt=null,at=0,fu(),Wt)}function jT(){for(;tt!==null&&!_t();)Gb(tt)}function Gb(i){var o=gb(i.alternate,i,Ms);i.memoizedProps=i.pendingProps,o===null?Ku(i):tt=o}function qb(i){var o=i,u=o.alternate;switch(o.tag){case 15:case 0:o=ub(u,o,o.pendingProps,o.type,void 0,at);break;case 11:o=ub(u,o,o.pendingProps,o.type.render,o.ref,at);break;case 5:rm(o);default:xb(u,o),o=tt=Wy(o,Ms),o=gb(u,o,Ms)}i.memoizedProps=i.pendingProps,o===null?Ku(i):tt=o}function yo(i,o,u,m){Cs=Xi=null,rm(o),oo=null,xl=0;var y=o.return;try{if(gT(i,y,o,u,at)){Wt=1,Ou(i,Sr(u,i.current)),tt=null;return}}catch(b){if(y!==null)throw tt=y,b;Wt=1,Ou(i,Sr(u,i.current)),tt=null;return}o.flags&32768?(lt||m===1?i=!0:po||(at&536870912)!==0?i=!1:(di=i=!0,(m===2||m===9||m===3||m===6)&&(m=lr.current,m!==null&&m.tag===13&&(m.flags|=16384))),Kb(o,i)):Ku(o)}function Ku(i){var o=i;do{if((o.flags&32768)!==0){Kb(o,di);return}i=o.return;var u=yT(o.alternate,o,Ms);if(u!==null){tt=u;return}if(o=o.sibling,o!==null){tt=o;return}tt=o=i}while(o!==null);Wt===0&&(Wt=5)}function Kb(i,o){do{var u=vT(i.alternate,i);if(u!==null){u.flags&=32767,tt=u;return}if(u=i.return,u!==null&&(u.flags|=32768,u.subtreeFlags=0,u.deletions=null),!o&&(i=i.sibling,i!==null)){tt=i;return}tt=i=u}while(i!==null);Wt=6,tt=null}function Yb(i,o,u,m,y,b,E,M,Y){i.cancelPendingCommit=null;do Yu();while(dn!==0);if((gt&6)!==0)throw Error(r(327));if(o!==null){if(o===i.current)throw Error(r(177));if(b=o.lanes|o.childLanes,b|=Af,fe(i,u,b,E,M,Y),i===Nt&&(tt=Nt=null,at=0),_o=o,mi=i,Os=u,Bm=b,zm=y,Bb=m,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,LT($e,function(){return e0(),null})):(i.callbackNode=null,i.callbackPriority=0),m=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||m){m=N.T,N.T=null,y=F.p,F.p=2,E=gt,gt|=4;try{bT(i,o,u)}finally{gt=E,F.p=y,N.T=m}}dn=1,Xb(),Qb(),Jb()}}function Xb(){if(dn===1){dn=0;var i=mi,o=_o,u=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||u){u=N.T,N.T=null;var m=F.p;F.p=2;var y=gt;gt|=4;try{Ab(o,i);var b=ep,E=Iy(i.containerInfo),M=b.focusedElem,Y=b.selectionRange;if(E!==M&&M&&M.ownerDocument&&Oy(M.ownerDocument.documentElement,M)){if(Y!==null&&kf(M)){var ie=Y.start,de=Y.end;if(de===void 0&&(de=ie),"selectionStart"in M)M.selectionStart=ie,M.selectionEnd=Math.min(de,M.value.length);else{var ge=M.ownerDocument||document,ae=ge&&ge.defaultView||window;if(ae.getSelection){var oe=ae.getSelection(),Ae=M.textContent.length,He=Math.min(Y.start,Ae),Ct=Y.end===void 0?He:Math.min(Y.end,Ae);!oe.extend&&He>Ct&&(E=Ct,Ct=He,He=E);var ee=My(M,He),X=My(M,Ct);if(ee&&X&&(oe.rangeCount!==1||oe.anchorNode!==ee.node||oe.anchorOffset!==ee.offset||oe.focusNode!==X.node||oe.focusOffset!==X.offset)){var re=ge.createRange();re.setStart(ee.node,ee.offset),oe.removeAllRanges(),He>Ct?(oe.addRange(re),oe.extend(X.node,X.offset)):(re.setEnd(X.node,X.offset),oe.addRange(re))}}}}for(ge=[],oe=M;oe=oe.parentNode;)oe.nodeType===1&&ge.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;M<ge.length;M++){var pe=ge[M];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}od=!!Zm,ep=Zm=null}finally{gt=y,F.p=m,N.T=u}}i.current=o,dn=2}}function Qb(){if(dn===2){dn=0;var i=mi,o=_o,u=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||u){u=N.T,N.T=null;var m=F.p;F.p=2;var y=gt;gt|=4;try{kb(i,o.alternate,o)}finally{gt=y,F.p=m,N.T=u}}dn=3}}function Jb(){if(dn===4||dn===3){dn=0,Js();var i=mi,o=_o,u=Os,m=Bb;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?dn=5:(dn=0,_o=mi=null,Zb(i,i.pendingLanes));var y=i.pendingLanes;if(y===0&&(fi=null),We(u),o=o.stateNode,pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(zt,o,void 0,(o.current.flags&128)===128)}catch{}if(m!==null){o=N.T,y=F.p,F.p=2,N.T=null;try{for(var b=i.onRecoverableError,E=0;E<m.length;E++){var M=m[E];b(M.value,{componentStack:M.stack})}}finally{N.T=o,F.p=y}}(Os&3)!==0&&Yu(),rs(i),y=i.pendingLanes,(u&261930)!==0&&(y&42)!==0?i===$m?Ol++:(Ol=0,$m=i):Ol=0,Il(0)}}function Zb(i,o){(i.pooledCacheLanes&=o)===0&&(o=i.pooledCache,o!=null&&(i.pooledCache=null,gl(o)))}function Yu(){return Xb(),Qb(),Jb(),e0()}function e0(){if(dn!==5)return!1;var i=mi,o=Bm;Bm=0;var u=We(Os),m=N.T,y=F.p;try{F.p=32>u?32:u,N.T=null,u=zm,zm=null;var b=mi,E=Os;if(dn=0,_o=mi=null,Os=0,(gt&6)!==0)throw Error(r(331));var M=gt;if(gt|=4,Ob(b.current),Lb(b,b.current,E,u),gt=M,Il(0,!1),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(zt,b)}catch{}return!0}finally{F.p=y,N.T=m,Zb(i,o)}}function t0(i,o,u){o=Sr(u,o),o=xm(i.stateNode,o,2),i=oi(i,o,2),i!==null&&(Zs(i,2),rs(i))}function bt(i,o,u){if(i.tag===3)t0(i,i,u);else for(;o!==null;){if(o.tag===3){t0(o,i,u);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(fi===null||!fi.has(m))){i=Sr(u,i),u=nb(2),m=oi(o,u,2),m!==null&&(rb(u,m,o,i),Zs(m,2),rs(m));break}}o=o.return}}function Um(i,o,u){var m=i.pingCache;if(m===null){m=i.pingCache=new CT;var y=new Set;m.set(o,y)}else y=m.get(o),y===void 0&&(y=new Set,m.set(o,y));y.has(u)||(Om=!0,y.add(u),i=TT.bind(null,i,o,u),o.then(i,i))}function TT(i,o,u){var m=i.pingCache;m!==null&&m.delete(o),i.pingedLanes|=i.suspendedLanes&u,i.warmLanes&=~u,Nt===i&&(at&u)===u&&(Wt===4||Wt===3&&(at&62914560)===at&&300>Yt()-Uu?(gt&2)===0&&xo(i,0):Im|=u,go===at&&(go=0)),rs(i)}function n0(i,o){o===0&&(o=tu()),i=qi(i,o),i!==null&&(Zs(i,o),rs(i))}function AT(i){var o=i.memoizedState,u=0;o!==null&&(u=o.retryLane),n0(i,u)}function DT(i,o){var u=0;switch(i.tag){case 31:case 13:var m=i.stateNode,y=i.memoizedState;y!==null&&(u=y.retryLane);break;case 19:m=i.stateNode;break;case 22:m=i.stateNode._retryCache;break;default:throw Error(r(314))}m!==null&&m.delete(o),n0(i,u)}function LT(i,o){return ue(i,o)}var Xu=null,vo=null,Vm=!1,Qu=!1,Wm=!1,gi=0;function rs(i){i!==vo&&i.next===null&&(vo===null?Xu=vo=i:vo=vo.next=i),Qu=!0,Vm||(Vm=!0,MT())}function Il(i,o){if(!Wm&&Qu){Wm=!0;do for(var u=!1,m=Xu;m!==null;){if(i!==0){var y=m.pendingLanes;if(y===0)var b=0;else{var E=m.suspendedLanes,M=m.pingedLanes;b=(1<<31-xt(42|i)+1)-1,b&=y&~(E&~M),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(u=!0,a0(m,b))}else b=at,b=Ba(m,m===Nt?b:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(b&3)===0||Fi(m,b)||(u=!0,a0(m,b));m=m.next}while(u);Wm=!1}}function RT(){r0()}function r0(){Qu=Vm=!1;var i=0;gi!==0&&VT()&&(i=gi);for(var o=Yt(),u=null,m=Xu;m!==null;){var y=m.next,b=s0(m,o);b===0?(m.next=null,u===null?Xu=y:u.next=y,y===null&&(vo=u)):(u=m,(i!==0||(b&3)!==0)&&(Qu=!0)),m=y}dn!==0&&dn!==5||Il(i),gi!==0&&(gi=0)}function s0(i,o){for(var u=i.suspendedLanes,m=i.pingedLanes,y=i.expirationTimes,b=i.pendingLanes&-62914561;0<b;){var E=31-xt(b),M=1<<E,Y=y[E];Y===-1?((M&u)===0||(M&m)!==0)&&(y[E]=nl(M,o)):Y<=o&&(i.expiredLanes|=M),b&=~M}if(o=Nt,u=at,u=Ba(i,i===o?u:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),m=i.callbackNode,u===0||i===o&&(vt===2||vt===9)||i.cancelPendingCommit!==null)return m!==null&&m!==null&&Ee(m),i.callbackNode=null,i.callbackPriority=0;if((u&3)===0||Fi(i,u)){if(o=u&-u,o===i.callbackPriority)return o;switch(m!==null&&Ee(m),We(u)){case 2:case 8:u=ke;break;case 32:u=$e;break;case 268435456:u=ut;break;default:u=$e}return m=i0.bind(null,i),u=ue(u,m),i.callbackPriority=o,i.callbackNode=u,o}return m!==null&&m!==null&&Ee(m),i.callbackPriority=2,i.callbackNode=null,2}function i0(i,o){if(dn!==0&&dn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var u=i.callbackNode;if(Yu()&&i.callbackNode!==u)return null;var m=at;return m=Ba(i,i===Nt?m:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),m===0?null:($b(i,m,o),s0(i,Yt()),i.callbackNode!=null&&i.callbackNode===u?i0.bind(null,i):null)}function a0(i,o){if(Yu())return null;$b(i,o,!0)}function MT(){GT(function(){(gt&6)!==0?ue(me,RT):r0()})}function Gm(){if(gi===0){var i=so;i===0&&(i=$r,$r<<=1,($r&261888)===0&&($r=256)),gi=i}return gi}function o0(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:iu(""+i)}function l0(i,o){var u=o.ownerDocument.createElement("input");return u.name=o.name,u.value=o.value,i.id&&u.setAttribute("form",i.id),o.parentNode.insertBefore(u,o),i=new FormData(i),u.parentNode.removeChild(u),i}function OT(i,o,u,m,y){if(o==="submit"&&u&&u.stateNode===y){var b=o0((y[Yn]||null).action),E=m.submitter;E&&(o=(o=E[Yn]||null)?o0(o.formAction):E.getAttribute("formAction"),o!==null&&(b=o,E=null));var M=new cu("action","action",null,m,y);i.push({event:M,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(gi!==0){var Y=E?l0(y,E):new FormData(y);hm(u,{pending:!0,data:Y,method:y.method,action:b},null,Y)}}else typeof b=="function"&&(M.preventDefault(),Y=E?l0(y,E):new FormData(y),hm(u,{pending:!0,data:Y,method:y.method,action:b},b,Y))},currentTarget:y}]})}}for(var qm=0;qm<Tf.length;qm++){var Km=Tf[qm],IT=Km.toLowerCase(),PT=Km[0].toUpperCase()+Km.slice(1);Hr(IT,"on"+PT)}Hr(zy,"onAnimationEnd"),Hr($y,"onAnimationIteration"),Hr(Hy,"onAnimationStart"),Hr("dblclick","onDoubleClick"),Hr("focusin","onFocus"),Hr("focusout","onBlur"),Hr(Zj,"onTransitionRun"),Hr(eT,"onTransitionStart"),Hr(tT,"onTransitionCancel"),Hr(Fy,"onTransitionEnd"),Va("onMouseEnter",["mouseout","mouseover"]),Va("onMouseLeave",["mouseout","mouseover"]),Va("onPointerEnter",["pointerout","pointerover"]),Va("onPointerLeave",["pointerout","pointerover"]),Ui("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ui("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ui("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ui("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ui("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ui("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Pl="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(" "),BT=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Pl));function c0(i,o){o=(o&4)!==0;for(var u=0;u<i.length;u++){var m=i[u],y=m.event;m=m.listeners;e:{var b=void 0;if(o)for(var E=m.length-1;0<=E;E--){var M=m[E],Y=M.instance,ie=M.currentTarget;if(M=M.listener,Y!==b&&y.isPropagationStopped())break e;b=M,y.currentTarget=ie;try{b(y)}catch(de){hu(de)}y.currentTarget=null,b=Y}else for(E=0;E<m.length;E++){if(M=m[E],Y=M.instance,ie=M.currentTarget,M=M.listener,Y!==b&&y.isPropagationStopped())break e;b=M,y.currentTarget=ie;try{b(y)}catch(de){hu(de)}y.currentTarget=null,b=Y}}}}function nt(i,o){var u=o[of];u===void 0&&(u=o[of]=new Set);var m=i+"__bubble";u.has(m)||(u0(o,i,2,!1),u.add(m))}function Ym(i,o,u){var m=0;o&&(m|=4),u0(u,i,m,o)}var Ju="_reactListening"+Math.random().toString(36).slice(2);function Xm(i){if(!i[Ju]){i[Ju]=!0,ry.forEach(function(u){u!=="selectionchange"&&(BT.has(u)||Ym(u,!1,i),Ym(u,!0,i))});var o=i.nodeType===9?i:i.ownerDocument;o===null||o[Ju]||(o[Ju]=!0,Ym("selectionchange",!1,o))}}function u0(i,o,u,m){switch(z0(o)){case 2:var y=hA;break;case 8:y=fA;break;default:y=dp}u=y.bind(null,o,u,i),y=void 0,!gf||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(y=!0),m?y!==void 0?i.addEventListener(o,u,{capture:!0,passive:y}):i.addEventListener(o,u,!0):y!==void 0?i.addEventListener(o,u,{passive:y}):i.addEventListener(o,u,!1)}function Qm(i,o,u,m,y){var b=m;if((o&1)===0&&(o&2)===0&&m!==null)e:for(;;){if(m===null)return;var E=m.tag;if(E===3||E===4){var M=m.stateNode.containerInfo;if(M===y)break;if(E===4)for(E=m.return;E!==null;){var Y=E.tag;if((Y===3||Y===4)&&E.stateNode.containerInfo===y)return;E=E.return}for(;M!==null;){if(E=Ha(M),E===null)return;if(Y=E.tag,Y===5||Y===6||Y===26||Y===27){m=b=E;continue e}M=M.parentNode}}m=m.return}py(function(){var ie=b,de=mf(u),ge=[];e:{var ae=Uy.get(i);if(ae!==void 0){var oe=cu,Ae=i;switch(i){case"keypress":if(ou(u)===0)break e;case"keydown":case"keyup":oe=Dj;break;case"focusin":Ae="focus",oe=vf;break;case"focusout":Ae="blur",oe=vf;break;case"beforeblur":case"afterblur":oe=vf;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":oe=xy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":oe=yj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":oe=Mj;break;case zy:case $y:case Hy:oe=Sj;break;case Fy:oe=Ij;break;case"scroll":case"scrollend":oe=_j;break;case"wheel":oe=Bj;break;case"copy":case"cut":case"paste":oe=Cj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":oe=vy;break;case"toggle":case"beforetoggle":oe=$j}var He=(o&4)!==0,Ct=!He&&(i==="scroll"||i==="scrollend"),ee=He?ae!==null?ae+"Capture":null:ae;He=[];for(var X=ie,re;X!==null;){var pe=X;if(re=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||re===null||ee===null||(pe=il(X,ee),pe!=null&&He.push(Bl(X,pe,re))),Ct)break;X=X.return}0<He.length&&(ae=new oe(ae,Ae,null,u,de),ge.push({event:ae,listeners:He}))}}if((o&7)===0){e:{if(ae=i==="mouseover"||i==="pointerover",oe=i==="mouseout"||i==="pointerout",ae&&u!==ff&&(Ae=u.relatedTarget||u.fromElement)&&(Ha(Ae)||Ae[$a]))break e;if((oe||ae)&&(ae=de.window===de?de:(ae=de.ownerDocument)?ae.defaultView||ae.parentWindow:window,oe?(Ae=u.relatedTarget||u.toElement,oe=ie,Ae=Ae?Ha(Ae):null,Ae!==null&&(Ct=a(Ae),He=Ae.tag,Ae!==Ct||He!==5&&He!==27&&He!==6)&&(Ae=null)):(oe=null,Ae=ie),oe!==Ae)){if(He=xy,pe="onMouseLeave",ee="onMouseEnter",X="mouse",(i==="pointerout"||i==="pointerover")&&(He=vy,pe="onPointerLeave",ee="onPointerEnter",X="pointer"),Ct=oe==null?ae:sl(oe),re=Ae==null?ae:sl(Ae),ae=new He(pe,X+"leave",oe,u,de),ae.target=Ct,ae.relatedTarget=re,pe=null,Ha(de)===ie&&(He=new He(ee,X+"enter",Ae,u,de),He.target=re,He.relatedTarget=Ct,pe=He),Ct=pe,oe&&Ae)t:{for(He=zT,ee=oe,X=Ae,re=0,pe=ee;pe;pe=He(pe))re++;pe=0;for(var Ie=X;Ie;Ie=He(Ie))pe++;for(;0<re-pe;)ee=He(ee),re--;for(;0<pe-re;)X=He(X),pe--;for(;re--;){if(ee===X||X!==null&&ee===X.alternate){He=ee;break t}ee=He(ee),X=He(X)}He=null}else He=null;oe!==null&&d0(ge,ae,oe,He,!1),Ae!==null&&Ct!==null&&d0(ge,Ct,Ae,He,!0)}}e:{if(ae=ie?sl(ie):window,oe=ae.nodeName&&ae.nodeName.toLowerCase(),oe==="select"||oe==="input"&&ae.type==="file")var ht=jy;else if(Ey(ae))if(Ty)ht=Xj;else{ht=Kj;var Le=qj}else oe=ae.nodeName,!oe||oe.toLowerCase()!=="input"||ae.type!=="checkbox"&&ae.type!=="radio"?ie&&hf(ie.elementType)&&(ht=jy):ht=Yj;if(ht&&(ht=ht(i,ie))){Ny(ge,ht,u,de);break e}Le&&Le(i,ae,ie),i==="focusout"&&ie&&ae.type==="number"&&ie.memoizedProps.value!=null&&df(ae,"number",ae.value)}switch(Le=ie?sl(ie):window,i){case"focusin":(Ey(Le)||Le.contentEditable==="true")&&(Xa=Le,Ef=ie,fl=null);break;case"focusout":fl=Ef=Xa=null;break;case"mousedown":Nf=!0;break;case"contextmenu":case"mouseup":case"dragend":Nf=!1,Py(ge,u,de);break;case"selectionchange":if(Jj)break;case"keydown":case"keyup":Py(ge,u,de)}var Ke;if(Sf)e:{switch(i){case"compositionstart":var ot="onCompositionStart";break e;case"compositionend":ot="onCompositionEnd";break e;case"compositionupdate":ot="onCompositionUpdate";break e}ot=void 0}else Ya?Cy(i,u)&&(ot="onCompositionEnd"):i==="keydown"&&u.keyCode===229&&(ot="onCompositionStart");ot&&(by&&u.locale!=="ko"&&(Ya||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&Ya&&(Ke=gy()):(ei=de,_f="value"in ei?ei.value:ei.textContent,Ya=!0)),Le=Zu(ie,ot),0<Le.length&&(ot=new yy(ot,i,null,u,de),ge.push({event:ot,listeners:Le}),Ke?ot.data=Ke:(Ke=ky(u),Ke!==null&&(ot.data=Ke)))),(Ke=Fj?Uj(i,u):Vj(i,u))&&(ot=Zu(ie,"onBeforeInput"),0<ot.length&&(Le=new yy("onBeforeInput","beforeinput",null,u,de),ge.push({event:Le,listeners:ot}),Le.data=Ke)),OT(ge,i,ie,u,de)}c0(ge,o)})}function Bl(i,o,u){return{instance:i,listener:o,currentTarget:u}}function Zu(i,o){for(var u=o+"Capture",m=[];i!==null;){var y=i,b=y.stateNode;if(y=y.tag,y!==5&&y!==26&&y!==27||b===null||(y=il(i,u),y!=null&&m.unshift(Bl(i,y,b)),y=il(i,o),y!=null&&m.push(Bl(i,y,b))),i.tag===3)return m;i=i.return}return[]}function zT(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function d0(i,o,u,m,y){for(var b=o._reactName,E=[];u!==null&&u!==m;){var M=u,Y=M.alternate,ie=M.stateNode;if(M=M.tag,Y!==null&&Y===m)break;M!==5&&M!==26&&M!==27||ie===null||(Y=ie,y?(ie=il(u,b),ie!=null&&E.unshift(Bl(u,ie,Y))):y||(ie=il(u,b),ie!=null&&E.push(Bl(u,ie,Y)))),u=u.return}E.length!==0&&i.push({event:o,listeners:E})}var $T=/\r\n?/g,HT=/\u0000|\uFFFD/g;function h0(i){return(typeof i=="string"?i:""+i).replace($T,`
50
- `).replace(HT,"")}function f0(i,o){return o=h0(o),h0(i)===o}function wt(i,o,u,m,y,b){switch(u){case"children":typeof m=="string"?o==="body"||o==="textarea"&&m===""||Ga(i,m):(typeof m=="number"||typeof m=="bigint")&&o!=="body"&&Ga(i,""+m);break;case"className":ru(i,"class",m);break;case"tabIndex":ru(i,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":ru(i,u,m);break;case"style":fy(i,m,b);break;case"data":if(o!=="object"){ru(i,"data",m);break}case"src":case"href":if(m===""&&(o!=="a"||u!=="href")){i.removeAttribute(u);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){i.removeAttribute(u);break}m=iu(""+m),i.setAttribute(u,m);break;case"action":case"formAction":if(typeof m=="function"){i.setAttribute(u,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof b=="function"&&(u==="formAction"?(o!=="input"&&wt(i,o,"name",y.name,y,null),wt(i,o,"formEncType",y.formEncType,y,null),wt(i,o,"formMethod",y.formMethod,y,null),wt(i,o,"formTarget",y.formTarget,y,null)):(wt(i,o,"encType",y.encType,y,null),wt(i,o,"method",y.method,y,null),wt(i,o,"target",y.target,y,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){i.removeAttribute(u);break}m=iu(""+m),i.setAttribute(u,m);break;case"onClick":m!=null&&(i.onclick=vs);break;case"onScroll":m!=null&&nt("scroll",i);break;case"onScrollEnd":m!=null&&nt("scrollend",i);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(r(61));if(u=m.__html,u!=null){if(y.children!=null)throw Error(r(60));i.innerHTML=u}}break;case"multiple":i.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":i.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){i.removeAttribute("xlink:href");break}u=iu(""+m),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":m!=null&&typeof m!="function"&&typeof m!="symbol"?i.setAttribute(u,""+m):i.removeAttribute(u);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":m&&typeof m!="function"&&typeof m!="symbol"?i.setAttribute(u,""):i.removeAttribute(u);break;case"capture":case"download":m===!0?i.setAttribute(u,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?i.setAttribute(u,m):i.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?i.setAttribute(u,m):i.removeAttribute(u);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?i.removeAttribute(u):i.setAttribute(u,m);break;case"popover":nt("beforetoggle",i),nt("toggle",i),nu(i,"popover",m);break;case"xlinkActuate":ys(i,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":ys(i,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":ys(i,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":ys(i,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":ys(i,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":ys(i,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":ys(i,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":ys(i,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":ys(i,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":nu(i,"is",m);break;case"innerText":case"textContent":break;default:(!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(u=pj.get(u)||u,nu(i,u,m))}}function Jm(i,o,u,m,y,b){switch(u){case"style":fy(i,m,b);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(r(61));if(u=m.__html,u!=null){if(y.children!=null)throw Error(r(60));i.innerHTML=u}}break;case"children":typeof m=="string"?Ga(i,m):(typeof m=="number"||typeof m=="bigint")&&Ga(i,""+m);break;case"onScroll":m!=null&&nt("scroll",i);break;case"onScrollEnd":m!=null&&nt("scrollend",i);break;case"onClick":m!=null&&(i.onclick=vs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!sy.hasOwnProperty(u))e:{if(u[0]==="o"&&u[1]==="n"&&(y=u.endsWith("Capture"),o=u.slice(2,y?u.length-7:void 0),b=i[Yn]||null,b=b!=null?b[u]:null,typeof b=="function"&&i.removeEventListener(o,b,y),typeof m=="function")){typeof b!="function"&&b!==null&&(u in i?i[u]=null:i.hasAttribute(u)&&i.removeAttribute(u)),i.addEventListener(o,m,y);break e}u in i?i[u]=m:m===!0?i.setAttribute(u,""):nu(i,u,m)}}}function Ln(i,o,u){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":nt("error",i),nt("load",i);var m=!1,y=!1,b;for(b in u)if(u.hasOwnProperty(b)){var E=u[b];if(E!=null)switch(b){case"src":m=!0;break;case"srcSet":y=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:wt(i,o,b,E,u,null)}}y&&wt(i,o,"srcSet",u.srcSet,u,null),m&&wt(i,o,"src",u.src,u,null);return;case"input":nt("invalid",i);var M=b=E=y=null,Y=null,ie=null;for(m in u)if(u.hasOwnProperty(m)){var de=u[m];if(de!=null)switch(m){case"name":y=de;break;case"type":E=de;break;case"checked":Y=de;break;case"defaultChecked":ie=de;break;case"value":b=de;break;case"defaultValue":M=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(r(137,o));break;default:wt(i,o,m,de,u,null)}}cy(i,b,M,Y,ie,E,y,!1);return;case"select":nt("invalid",i),m=E=b=null;for(y in u)if(u.hasOwnProperty(y)&&(M=u[y],M!=null))switch(y){case"value":b=M;break;case"defaultValue":E=M;break;case"multiple":m=M;default:wt(i,o,y,M,u,null)}o=b,u=E,i.multiple=!!m,o!=null?Wa(i,!!m,o,!1):u!=null&&Wa(i,!!m,u,!0);return;case"textarea":nt("invalid",i),b=y=m=null;for(E in u)if(u.hasOwnProperty(E)&&(M=u[E],M!=null))switch(E){case"value":m=M;break;case"defaultValue":y=M;break;case"children":b=M;break;case"dangerouslySetInnerHTML":if(M!=null)throw Error(r(91));break;default:wt(i,o,E,M,u,null)}dy(i,m,y,b);return;case"option":for(Y in u)if(u.hasOwnProperty(Y)&&(m=u[Y],m!=null))switch(Y){case"selected":i.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:wt(i,o,Y,m,u,null)}return;case"dialog":nt("beforetoggle",i),nt("toggle",i),nt("cancel",i),nt("close",i);break;case"iframe":case"object":nt("load",i);break;case"video":case"audio":for(m=0;m<Pl.length;m++)nt(Pl[m],i);break;case"image":nt("error",i),nt("load",i);break;case"details":nt("toggle",i);break;case"embed":case"source":case"link":nt("error",i),nt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ie in u)if(u.hasOwnProperty(ie)&&(m=u[ie],m!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:wt(i,o,ie,m,u,null)}return;default:if(hf(o)){for(de in u)u.hasOwnProperty(de)&&(m=u[de],m!==void 0&&Jm(i,o,de,m,u,void 0));return}}for(M in u)u.hasOwnProperty(M)&&(m=u[M],m!=null&&wt(i,o,M,m,u,null))}function FT(i,o,u,m){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var y=null,b=null,E=null,M=null,Y=null,ie=null,de=null;for(oe in u){var ge=u[oe];if(u.hasOwnProperty(oe)&&ge!=null)switch(oe){case"checked":break;case"value":break;case"defaultValue":Y=ge;default:m.hasOwnProperty(oe)||wt(i,o,oe,null,m,ge)}}for(var ae in m){var oe=m[ae];if(ge=u[ae],m.hasOwnProperty(ae)&&(oe!=null||ge!=null))switch(ae){case"type":b=oe;break;case"name":y=oe;break;case"checked":ie=oe;break;case"defaultChecked":de=oe;break;case"value":E=oe;break;case"defaultValue":M=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,o));break;default:oe!==ge&&wt(i,o,ae,oe,m,ge)}}uf(i,E,M,Y,ie,de,b,y);return;case"select":oe=E=M=ae=null;for(b in u)if(Y=u[b],u.hasOwnProperty(b)&&Y!=null)switch(b){case"value":break;case"multiple":oe=Y;default:m.hasOwnProperty(b)||wt(i,o,b,null,m,Y)}for(y in m)if(b=m[y],Y=u[y],m.hasOwnProperty(y)&&(b!=null||Y!=null))switch(y){case"value":ae=b;break;case"defaultValue":M=b;break;case"multiple":E=b;default:b!==Y&&wt(i,o,y,b,m,Y)}o=M,u=E,m=oe,ae!=null?Wa(i,!!u,ae,!1):!!m!=!!u&&(o!=null?Wa(i,!!u,o,!0):Wa(i,!!u,u?[]:"",!1));return;case"textarea":oe=ae=null;for(M in u)if(y=u[M],u.hasOwnProperty(M)&&y!=null&&!m.hasOwnProperty(M))switch(M){case"value":break;case"children":break;default:wt(i,o,M,null,m,y)}for(E in m)if(y=m[E],b=u[E],m.hasOwnProperty(E)&&(y!=null||b!=null))switch(E){case"value":ae=y;break;case"defaultValue":oe=y;break;case"children":break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(r(91));break;default:y!==b&&wt(i,o,E,y,m,b)}uy(i,ae,oe);return;case"option":for(var Ae in u)if(ae=u[Ae],u.hasOwnProperty(Ae)&&ae!=null&&!m.hasOwnProperty(Ae))switch(Ae){case"selected":i.selected=!1;break;default:wt(i,o,Ae,null,m,ae)}for(Y in m)if(ae=m[Y],oe=u[Y],m.hasOwnProperty(Y)&&ae!==oe&&(ae!=null||oe!=null))switch(Y){case"selected":i.selected=ae&&typeof ae!="function"&&typeof ae!="symbol";break;default:wt(i,o,Y,ae,m,oe)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var He in u)ae=u[He],u.hasOwnProperty(He)&&ae!=null&&!m.hasOwnProperty(He)&&wt(i,o,He,null,m,ae);for(ie in m)if(ae=m[ie],oe=u[ie],m.hasOwnProperty(ie)&&ae!==oe&&(ae!=null||oe!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(r(137,o));break;default:wt(i,o,ie,ae,m,oe)}return;default:if(hf(o)){for(var Ct in u)ae=u[Ct],u.hasOwnProperty(Ct)&&ae!==void 0&&!m.hasOwnProperty(Ct)&&Jm(i,o,Ct,void 0,m,ae);for(de in m)ae=m[de],oe=u[de],!m.hasOwnProperty(de)||ae===oe||ae===void 0&&oe===void 0||Jm(i,o,de,ae,m,oe);return}}for(var ee in u)ae=u[ee],u.hasOwnProperty(ee)&&ae!=null&&!m.hasOwnProperty(ee)&&wt(i,o,ee,null,m,ae);for(ge in m)ae=m[ge],oe=u[ge],!m.hasOwnProperty(ge)||ae===oe||ae==null&&oe==null||wt(i,o,ge,ae,m,oe)}function m0(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function UT(){if(typeof performance.getEntriesByType=="function"){for(var i=0,o=0,u=performance.getEntriesByType("resource"),m=0;m<u.length;m++){var y=u[m],b=y.transferSize,E=y.initiatorType,M=y.duration;if(b&&M&&m0(E)){for(E=0,M=y.responseEnd,m+=1;m<u.length;m++){var Y=u[m],ie=Y.startTime;if(ie>M)break;var de=Y.transferSize,ge=Y.initiatorType;de&&m0(ge)&&(Y=Y.responseEnd,E+=de*(Y<M?1:(M-ie)/(Y-ie)))}if(--m,o+=8*(b+E)/(y.duration/1e3),i++,10<i)break}}if(0<i)return o/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Zm=null,ep=null;function ed(i){return i.nodeType===9?i:i.ownerDocument}function p0(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function g0(i,o){if(i===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&o==="foreignObject"?0:i}function tp(i,o){return i==="textarea"||i==="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 np=null;function VT(){var i=window.event;return i&&i.type==="popstate"?i===np?!1:(np=i,!0):(np=null,!1)}var _0=typeof setTimeout=="function"?setTimeout:void 0,WT=typeof clearTimeout=="function"?clearTimeout:void 0,x0=typeof Promise=="function"?Promise:void 0,GT=typeof queueMicrotask=="function"?queueMicrotask:typeof x0<"u"?function(i){return x0.resolve(null).then(i).catch(qT)}:_0;function qT(i){setTimeout(function(){throw i})}function _i(i){return i==="head"}function y0(i,o){var u=o,m=0;do{var y=u.nextSibling;if(i.removeChild(u),y&&y.nodeType===8)if(u=y.data,u==="/$"||u==="/&"){if(m===0){i.removeChild(y),Co(o);return}m--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")m++;else if(u==="html")zl(i.ownerDocument.documentElement);else if(u==="head"){u=i.ownerDocument.head,zl(u);for(var b=u.firstChild;b;){var E=b.nextSibling,M=b.nodeName;b[rl]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&b.rel.toLowerCase()==="stylesheet"||u.removeChild(b),b=E}}else u==="body"&&zl(i.ownerDocument.body);u=y}while(u);Co(o)}function v0(i,o){var u=i;i=0;do{var m=u.nextSibling;if(u.nodeType===1?o?(u._stashedDisplay=u.style.display,u.style.display="none"):(u.style.display=u._stashedDisplay||"",u.getAttribute("style")===""&&u.removeAttribute("style")):u.nodeType===3&&(o?(u._stashedText=u.nodeValue,u.nodeValue=""):u.nodeValue=u._stashedText||""),m&&m.nodeType===8)if(u=m.data,u==="/$"){if(i===0)break;i--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||i++;u=m}while(u)}function rp(i){var o=i.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var u=o;switch(o=o.nextSibling,u.nodeName){case"HTML":case"HEAD":case"BODY":rp(u),lf(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}i.removeChild(u)}}function KT(i,o,u,m){for(;i.nodeType===1;){var y=u;if(i.nodeName.toLowerCase()!==o.toLowerCase()){if(!m&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(m){if(!i[rl])switch(o){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(b=i.getAttribute("rel"),b==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(b!==y.rel||i.getAttribute("href")!==(y.href==null||y.href===""?null:y.href)||i.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin)||i.getAttribute("title")!==(y.title==null?null:y.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(b=i.getAttribute("src"),(b!==(y.src==null?null:y.src)||i.getAttribute("type")!==(y.type==null?null:y.type)||i.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin))&&b&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(o==="input"&&i.type==="hidden"){var b=y.name==null?null:""+y.name;if(y.type==="hidden"&&i.getAttribute("name")===b)return i}else return i;if(i=Nr(i.nextSibling),i===null)break}return null}function YT(i,o,u){if(o==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!u||(i=Nr(i.nextSibling),i===null))return null;return i}function b0(i,o){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!o||(i=Nr(i.nextSibling),i===null))return null;return i}function sp(i){return i.data==="$?"||i.data==="$~"}function ip(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function XT(i,o){var u=i.ownerDocument;if(i.data==="$~")i._reactRetry=o;else if(i.data!=="$?"||u.readyState!=="loading")o();else{var m=function(){o(),u.removeEventListener("DOMContentLoaded",m)};u.addEventListener("DOMContentLoaded",m),i._reactRetry=m}}function Nr(i){for(;i!=null;i=i.nextSibling){var o=i.nodeType;if(o===1||o===3)break;if(o===8){if(o=i.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return i}var ap=null;function S0(i){i=i.nextSibling;for(var o=0;i;){if(i.nodeType===8){var u=i.data;if(u==="/$"||u==="/&"){if(o===0)return Nr(i.nextSibling);o--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||o++}i=i.nextSibling}return null}function w0(i){i=i.previousSibling;for(var o=0;i;){if(i.nodeType===8){var u=i.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(o===0)return i;o--}else u!=="/$"&&u!=="/&"||o++}i=i.previousSibling}return null}function C0(i,o,u){switch(o=ed(u),i){case"html":if(i=o.documentElement,!i)throw Error(r(452));return i;case"head":if(i=o.head,!i)throw Error(r(453));return i;case"body":if(i=o.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function zl(i){for(var o=i.attributes;o.length;)i.removeAttributeNode(o[0]);lf(i)}var jr=new Map,k0=new Set;function td(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Is=F.d;F.d={f:QT,r:JT,D:ZT,C:eA,L:tA,m:nA,X:sA,S:rA,M:iA};function QT(){var i=Is.f(),o=Gu();return i||o}function JT(i){var o=Fa(i);o!==null&&o.tag===5&&o.type==="form"?Fv(o):Is.r(i)}var bo=typeof document>"u"?null:document;function E0(i,o,u){var m=bo;if(m&&typeof o=="string"&&o){var y=vr(o);y='link[rel="'+i+'"][href="'+y+'"]',typeof u=="string"&&(y+='[crossorigin="'+u+'"]'),k0.has(y)||(k0.add(y),i={rel:i,crossOrigin:u,href:o},m.querySelector(y)===null&&(o=m.createElement("link"),Ln(o,"link",i),yn(o),m.head.appendChild(o)))}}function ZT(i){Is.D(i),E0("dns-prefetch",i,null)}function eA(i,o){Is.C(i,o),E0("preconnect",i,o)}function tA(i,o,u){Is.L(i,o,u);var m=bo;if(m&&i&&o){var y='link[rel="preload"][as="'+vr(o)+'"]';o==="image"&&u&&u.imageSrcSet?(y+='[imagesrcset="'+vr(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(y+='[imagesizes="'+vr(u.imageSizes)+'"]')):y+='[href="'+vr(i)+'"]';var b=y;switch(o){case"style":b=So(i);break;case"script":b=wo(i)}jr.has(b)||(i=g({rel:"preload",href:o==="image"&&u&&u.imageSrcSet?void 0:i,as:o},u),jr.set(b,i),m.querySelector(y)!==null||o==="style"&&m.querySelector($l(b))||o==="script"&&m.querySelector(Hl(b))||(o=m.createElement("link"),Ln(o,"link",i),yn(o),m.head.appendChild(o)))}}function nA(i,o){Is.m(i,o);var u=bo;if(u&&i){var m=o&&typeof o.as=="string"?o.as:"script",y='link[rel="modulepreload"][as="'+vr(m)+'"][href="'+vr(i)+'"]',b=y;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=wo(i)}if(!jr.has(b)&&(i=g({rel:"modulepreload",href:i},o),jr.set(b,i),u.querySelector(y)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(Hl(b)))return}m=u.createElement("link"),Ln(m,"link",i),yn(m),u.head.appendChild(m)}}}function rA(i,o,u){Is.S(i,o,u);var m=bo;if(m&&i){var y=Ua(m).hoistableStyles,b=So(i);o=o||"default";var E=y.get(b);if(!E){var M={loading:0,preload:null};if(E=m.querySelector($l(b)))M.loading=5;else{i=g({rel:"stylesheet",href:i,"data-precedence":o},u),(u=jr.get(b))&&op(i,u);var Y=E=m.createElement("link");yn(Y),Ln(Y,"link",i),Y._p=new Promise(function(ie,de){Y.onload=ie,Y.onerror=de}),Y.addEventListener("load",function(){M.loading|=1}),Y.addEventListener("error",function(){M.loading|=2}),M.loading|=4,nd(E,o,m)}E={type:"stylesheet",instance:E,count:1,state:M},y.set(b,E)}}}function sA(i,o){Is.X(i,o);var u=bo;if(u&&i){var m=Ua(u).hoistableScripts,y=wo(i),b=m.get(y);b||(b=u.querySelector(Hl(y)),b||(i=g({src:i,async:!0},o),(o=jr.get(y))&&lp(i,o),b=u.createElement("script"),yn(b),Ln(b,"link",i),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},m.set(y,b))}}function iA(i,o){Is.M(i,o);var u=bo;if(u&&i){var m=Ua(u).hoistableScripts,y=wo(i),b=m.get(y);b||(b=u.querySelector(Hl(y)),b||(i=g({src:i,async:!0,type:"module"},o),(o=jr.get(y))&&lp(i,o),b=u.createElement("script"),yn(b),Ln(b,"link",i),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},m.set(y,b))}}function N0(i,o,u,m){var y=(y=Z.current)?td(y):null;if(!y)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(o=So(u.href),u=Ua(y).hoistableStyles,m=u.get(o),m||(m={type:"style",instance:null,count:0,state:null},u.set(o,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){i=So(u.href);var b=Ua(y).hoistableStyles,E=b.get(i);if(E||(y=y.ownerDocument||y,E={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(i,E),(b=y.querySelector($l(i)))&&!b._p&&(E.instance=b,E.state.loading=5),jr.has(i)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},jr.set(i,u),b||aA(y,i,u,E.state))),o&&m===null)throw Error(r(528,""));return E}if(o&&m!==null)throw Error(r(529,""));return null;case"script":return o=u.async,u=u.src,typeof u=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=wo(u),u=Ua(y).hoistableScripts,m=u.get(o),m||(m={type:"script",instance:null,count:0,state:null},u.set(o,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function So(i){return'href="'+vr(i)+'"'}function $l(i){return'link[rel="stylesheet"]['+i+"]"}function j0(i){return g({},i,{"data-precedence":i.precedence,precedence:null})}function aA(i,o,u,m){i.querySelector('link[rel="preload"][as="style"]['+o+"]")?m.loading=1:(o=i.createElement("link"),m.preload=o,o.addEventListener("load",function(){return m.loading|=1}),o.addEventListener("error",function(){return m.loading|=2}),Ln(o,"link",u),yn(o),i.head.appendChild(o))}function wo(i){return'[src="'+vr(i)+'"]'}function Hl(i){return"script[async]"+i}function T0(i,o,u){if(o.count++,o.instance===null)switch(o.type){case"style":var m=i.querySelector('style[data-href~="'+vr(u.href)+'"]');if(m)return o.instance=m,yn(m),m;var y=g({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return m=(i.ownerDocument||i).createElement("style"),yn(m),Ln(m,"style",y),nd(m,u.precedence,i),o.instance=m;case"stylesheet":y=So(u.href);var b=i.querySelector($l(y));if(b)return o.state.loading|=4,o.instance=b,yn(b),b;m=j0(u),(y=jr.get(y))&&op(m,y),b=(i.ownerDocument||i).createElement("link"),yn(b);var E=b;return E._p=new Promise(function(M,Y){E.onload=M,E.onerror=Y}),Ln(b,"link",m),o.state.loading|=4,nd(b,u.precedence,i),o.instance=b;case"script":return b=wo(u.src),(y=i.querySelector(Hl(b)))?(o.instance=y,yn(y),y):(m=u,(y=jr.get(b))&&(m=g({},u),lp(m,y)),i=i.ownerDocument||i,y=i.createElement("script"),yn(y),Ln(y,"link",m),i.head.appendChild(y),o.instance=y);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(m=o.instance,o.state.loading|=4,nd(m,u.precedence,i));return o.instance}function nd(i,o,u){for(var m=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=m.length?m[m.length-1]:null,b=y,E=0;E<m.length;E++){var M=m[E];if(M.dataset.precedence===o)b=M;else if(b!==y)break}b?b.parentNode.insertBefore(i,b.nextSibling):(o=u.nodeType===9?u.head:u,o.insertBefore(i,o.firstChild))}function op(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.title==null&&(i.title=o.title)}function lp(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.integrity==null&&(i.integrity=o.integrity)}var rd=null;function A0(i,o,u){if(rd===null){var m=new Map,y=rd=new Map;y.set(u,m)}else y=rd,m=y.get(u),m||(m=new Map,y.set(u,m));if(m.has(i))return m;for(m.set(i,null),u=u.getElementsByTagName(i),y=0;y<u.length;y++){var b=u[y];if(!(b[rl]||b[yt]||i==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var E=b.getAttribute(o)||"";E=i+E;var M=m.get(E);M?M.push(b):m.set(E,[b])}}return m}function D0(i,o,u){i=i.ownerDocument||i,i.head.insertBefore(u,o==="title"?i.querySelector("head > title"):null)}function oA(i,o,u){if(u===1||o.itemProp!=null)return!1;switch(i){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 i=o.disabled,typeof o.precedence=="string"&&i==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 L0(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function lA(i,o,u,m){if(u.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var y=So(m.href),b=o.querySelector($l(y));if(b){o=b._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(i.count++,i=sd.bind(i),o.then(i,i)),u.state.loading|=4,u.instance=b,yn(b);return}b=o.ownerDocument||o,m=j0(m),(y=jr.get(y))&&op(m,y),b=b.createElement("link"),yn(b);var E=b;E._p=new Promise(function(M,Y){E.onload=M,E.onerror=Y}),Ln(b,"link",m),u.instance=b}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(u,o),(o=u.state.preload)&&(u.state.loading&3)===0&&(i.count++,u=sd.bind(i),o.addEventListener("load",u),o.addEventListener("error",u))}}var cp=0;function cA(i,o){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0<i.count||0<i.imgCount?function(u){var m=setTimeout(function(){if(i.stylesheets&&ad(i,i.stylesheets),i.unsuspend){var b=i.unsuspend;i.unsuspend=null,b()}},6e4+o);0<i.imgBytes&&cp===0&&(cp=62500*UT());var y=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&ad(i,i.stylesheets),i.unsuspend)){var b=i.unsuspend;i.unsuspend=null,b()}},(i.imgBytes>cp?50:800)+o);return i.unsuspend=u,function(){i.unsuspend=null,clearTimeout(m),clearTimeout(y)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var id=null;function ad(i,o){i.stylesheets=null,i.unsuspend!==null&&(i.count++,id=new Map,o.forEach(uA,i),id=null,sd.call(i))}function uA(i,o){if(!(o.state.loading&4)){var u=id.get(i);if(u)var m=u.get(null);else{u=new Map,id.set(i,u);for(var y=i.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<y.length;b++){var E=y[b];(E.nodeName==="LINK"||E.getAttribute("media")!=="not all")&&(u.set(E.dataset.precedence,E),m=E)}m&&u.set(null,m)}y=o.instance,E=y.getAttribute("data-precedence"),b=u.get(E)||m,b===m&&u.set(null,y),u.set(E,y),this.count++,m=sd.bind(this),y.addEventListener("load",m),y.addEventListener("error",m),b?b.parentNode.insertBefore(y,b.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(y,i.firstChild)),o.state.loading|=4}}var Fl={$$typeof:T,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function dA(i,o,u,m,y,b,E,M,Y){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=za(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=za(0),this.hiddenUpdates=za(null),this.identifierPrefix=m,this.onUncaughtError=y,this.onCaughtError=b,this.onRecoverableError=E,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Y,this.incompleteTransitions=new Map}function R0(i,o,u,m,y,b,E,M,Y,ie,de,ge){return i=new dA(i,o,u,E,Y,ie,de,ge,M),o=1,b===!0&&(o|=24),b=or(3,null,null,o),i.current=b,b.stateNode=i,o=Ff(),o.refCount++,i.pooledCache=o,o.refCount++,b.memoizedState={element:m,isDehydrated:u,cache:o},Gf(b),i}function M0(i){return i?(i=Za,i):Za}function O0(i,o,u,m,y,b){y=M0(y),m.context===null?m.context=y:m.pendingContext=y,m=ai(o),m.payload={element:u},b=b===void 0?null:b,b!==null&&(m.callback=b),u=oi(i,m,o),u!==null&&(tr(u,i,o),vl(u,i,o))}function I0(i,o){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var u=i.retryLane;i.retryLane=u!==0&&u<o?u:o}}function up(i,o){I0(i,o),(i=i.alternate)&&I0(i,o)}function P0(i){if(i.tag===13||i.tag===31){var o=qi(i,67108864);o!==null&&tr(o,i,67108864),up(i,67108864)}}function B0(i){if(i.tag===13||i.tag===31){var o=hr();o=Qe(o);var u=qi(i,o);u!==null&&tr(u,i,o),up(i,o)}}var od=!0;function hA(i,o,u,m){var y=N.T;N.T=null;var b=F.p;try{F.p=2,dp(i,o,u,m)}finally{F.p=b,N.T=y}}function fA(i,o,u,m){var y=N.T;N.T=null;var b=F.p;try{F.p=8,dp(i,o,u,m)}finally{F.p=b,N.T=y}}function dp(i,o,u,m){if(od){var y=hp(m);if(y===null)Qm(i,o,m,ld,u),$0(i,m);else if(pA(y,i,o,u,m))m.stopPropagation();else if($0(i,m),o&4&&-1<mA.indexOf(i)){for(;y!==null;){var b=Fa(y);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var E=Zr(b.pendingLanes);if(E!==0){var M=b;for(M.pendingLanes|=2,M.entangledLanes|=2;E;){var Y=1<<31-xt(E);M.entanglements[1]|=Y,E&=~Y}rs(b),(gt&6)===0&&(Vu=Yt()+500,Il(0))}}break;case 31:case 13:M=qi(b,2),M!==null&&tr(M,b,2),Gu(),up(b,2)}if(b=hp(m),b===null&&Qm(i,o,m,ld,u),b===y)break;y=b}y!==null&&m.stopPropagation()}else Qm(i,o,m,null,u)}}function hp(i){return i=mf(i),fp(i)}var ld=null;function fp(i){if(ld=null,i=Ha(i),i!==null){var o=a(i);if(o===null)i=null;else{var u=o.tag;if(u===13){if(i=l(o),i!==null)return i;i=null}else if(u===31){if(i=d(o),i!==null)return i;i=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;i=null}else o!==i&&(i=null)}}return ld=i,null}function z0(i){switch(i){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(tl()){case me:return 2;case ke:return 8;case $e:case Xe:return 32;case ut:return 268435456;default:return 32}default:return 32}}var mp=!1,xi=null,yi=null,vi=null,Ul=new Map,Vl=new Map,bi=[],mA="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 $0(i,o){switch(i){case"focusin":case"focusout":xi=null;break;case"dragenter":case"dragleave":yi=null;break;case"mouseover":case"mouseout":vi=null;break;case"pointerover":case"pointerout":Ul.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vl.delete(o.pointerId)}}function Wl(i,o,u,m,y,b){return i===null||i.nativeEvent!==b?(i={blockedOn:o,domEventName:u,eventSystemFlags:m,nativeEvent:b,targetContainers:[y]},o!==null&&(o=Fa(o),o!==null&&P0(o)),i):(i.eventSystemFlags|=m,o=i.targetContainers,y!==null&&o.indexOf(y)===-1&&o.push(y),i)}function pA(i,o,u,m,y){switch(o){case"focusin":return xi=Wl(xi,i,o,u,m,y),!0;case"dragenter":return yi=Wl(yi,i,o,u,m,y),!0;case"mouseover":return vi=Wl(vi,i,o,u,m,y),!0;case"pointerover":var b=y.pointerId;return Ul.set(b,Wl(Ul.get(b)||null,i,o,u,m,y)),!0;case"gotpointercapture":return b=y.pointerId,Vl.set(b,Wl(Vl.get(b)||null,i,o,u,m,y)),!0}return!1}function H0(i){var o=Ha(i.target);if(o!==null){var u=a(o);if(u!==null){if(o=u.tag,o===13){if(o=l(u),o!==null){i.blockedOn=o,jn(i.priority,function(){B0(u)});return}}else if(o===31){if(o=d(u),o!==null){i.blockedOn=o,jn(i.priority,function(){B0(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){i.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}i.blockedOn=null}function cd(i){if(i.blockedOn!==null)return!1;for(var o=i.targetContainers;0<o.length;){var u=hp(i.nativeEvent);if(u===null){u=i.nativeEvent;var m=new u.constructor(u.type,u);ff=m,u.target.dispatchEvent(m),ff=null}else return o=Fa(u),o!==null&&P0(o),i.blockedOn=u,!1;o.shift()}return!0}function F0(i,o,u){cd(i)&&u.delete(o)}function gA(){mp=!1,xi!==null&&cd(xi)&&(xi=null),yi!==null&&cd(yi)&&(yi=null),vi!==null&&cd(vi)&&(vi=null),Ul.forEach(F0),Vl.forEach(F0)}function ud(i,o){i.blockedOn===o&&(i.blockedOn=null,mp||(mp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,gA)))}var dd=null;function U0(i){dd!==i&&(dd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){dd===i&&(dd=null);for(var o=0;o<i.length;o+=3){var u=i[o],m=i[o+1],y=i[o+2];if(typeof m!="function"){if(fp(m||u)===null)continue;break}var b=Fa(u);b!==null&&(i.splice(o,3),o-=3,hm(b,{pending:!0,data:y,method:u.method,action:m},m,y))}}))}function Co(i){function o(Y){return ud(Y,i)}xi!==null&&ud(xi,i),yi!==null&&ud(yi,i),vi!==null&&ud(vi,i),Ul.forEach(o),Vl.forEach(o);for(var u=0;u<bi.length;u++){var m=bi[u];m.blockedOn===i&&(m.blockedOn=null)}for(;0<bi.length&&(u=bi[0],u.blockedOn===null);)H0(u),u.blockedOn===null&&bi.shift();if(u=(i.ownerDocument||i).$$reactFormReplay,u!=null)for(m=0;m<u.length;m+=3){var y=u[m],b=u[m+1],E=y[Yn]||null;if(typeof b=="function")E||U0(u);else if(E){var M=null;if(b&&b.hasAttribute("formAction")){if(y=b,E=b[Yn]||null)M=E.formAction;else if(fp(y)!==null)continue}else M=E.action;typeof M=="function"?u[m+1]=M:(u.splice(m,3),m-=3),U0(u)}}}function V0(){function i(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(E){return y=E})},focusReset:"manual",scroll:"manual"})}function o(){y!==null&&(y(),y=null),m||setTimeout(u,20)}function u(){if(!m&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var m=!1,y=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(u,100),function(){m=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),y!==null&&(y(),y=null)}}}function pp(i){this._internalRoot=i}hd.prototype.render=pp.prototype.render=function(i){var o=this._internalRoot;if(o===null)throw Error(r(409));var u=o.current,m=hr();O0(u,m,i,o,null,null)},hd.prototype.unmount=pp.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var o=i.containerInfo;O0(i.current,2,null,i,null,null),Gu(),o[$a]=null}};function hd(i){this._internalRoot=i}hd.prototype.unstable_scheduleHydration=function(i){if(i){var o=dt();i={blockedOn:null,target:i,priority:o};for(var u=0;u<bi.length&&o!==0&&o<bi[u].priority;u++);bi.splice(u,0,i),u===0&&H0(i)}};var W0=t.version;if(W0!=="19.2.4")throw Error(r(527,W0,"19.2.4"));F.findDOMNode=function(i){var o=i._reactInternals;if(o===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=h(o),i=i!==null?p(i):null,i=i===null?null:i.stateNode,i};var _A={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:N,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var fd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!fd.isDisabled&&fd.supportsFiber)try{zt=fd.inject(_A),pt=fd}catch{}}return ql.createRoot=function(i,o){if(!s(i))throw Error(r(299));var u=!1,m="",y=Jv,b=Zv,E=eb;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onUncaughtError!==void 0&&(y=o.onUncaughtError),o.onCaughtError!==void 0&&(b=o.onCaughtError),o.onRecoverableError!==void 0&&(E=o.onRecoverableError)),o=R0(i,1,!1,null,null,u,m,null,y,b,E,V0),i[$a]=o.current,Xm(i),new pp(o)},ql.hydrateRoot=function(i,o,u){if(!s(i))throw Error(r(299));var m=!1,y="",b=Jv,E=Zv,M=eb,Y=null;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(y=u.identifierPrefix),u.onUncaughtError!==void 0&&(b=u.onUncaughtError),u.onCaughtError!==void 0&&(E=u.onCaughtError),u.onRecoverableError!==void 0&&(M=u.onRecoverableError),u.formState!==void 0&&(Y=u.formState)),o=R0(i,1,!0,o,u??null,m,y,Y,b,E,M,V0),o.context=M0(null),u=o.current,m=hr(),m=Qe(m),y=ai(m),y.callback=null,oi(u,y,m),u=m,o.current.lanes=u,Zs(o,u),rs(o),i[$a]=o.current,Xm(i),new hd(o)},ql.version="19.2.4",ql}var rS;function LA(){if(rS)return vp.exports;rS=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(),vp.exports=DA(),vp.exports}var RA=LA();const MA=kh(RA),sS=e=>{let t;const n=new Set,r=(h,p)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const _=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(x=>x(t,_))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>f,subscribe:h=>(n.add(h),()=>n.delete(h))},f=t=e(r,s,d);return d},OA=(e=>e?sS(e):sS),IA=e=>e;function PA(e,t=IA){const n=Li.useSyncExternalStore(e.subscribe,Li.useCallback(()=>t(e.getState()),[e,t]),Li.useCallback(()=>t(e.getInitialState()),[e,t]));return Li.useDebugValue(n),n}const iS=e=>{const t=OA(e),n=r=>PA(t,r);return Object.assign(n,t),n},xr=(e=>e?iS(e):iS);async function Ne(e,t={}){const n=localStorage.getItem("openfox_token"),r={...t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers,...n?{"x-session-token":n}:{}};return fetch(e,{...t,headers:r})}async function BA(e,t){try{return(await Ne(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageIndex:t})})).ok}catch{return!1}}const Me={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",LLM_DISABLE_XML_PROTECTION:"llm.disableXmlProtection",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",KEYBINDINGS:"keybindings"};function md(e,t){return n=>({loading:{...n.loading,[e]:t}})}function aS(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const PC=[Me.DISPLAY_SHOW_THINKING,Me.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Me.DISPLAY_SHOW_STATS,Me.DISPLAY_SHOW_AGENT_DEFINITIONS,Me.DISPLAY_SHOW_WORKFLOW_BARS,Me.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Me.DISPLAY_FOLLOW_SYSTEM_THEME,Me.DISPLAY_SHOW_OPEN_IN_EDITOR];function Nh(){return{showThinking:tn(e=>e.settings[Me.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:tn(e=>e.settings[Me.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:tn(e=>e.settings[Me.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:tn(e=>e.settings[Me.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:tn(e=>e.settings[Me.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:tn(e=>e.settings[Me.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true"}}const tn=xr(e=>({settings:{},loading:{},getSetting:async t=>{e(md(t,!0));try{const r=await(await Ne(`/api/settings/${t}`)).json();return e(aS(t,r.value??"")),r.value}catch{return e(md(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await Ne(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(s=>[s,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(md(t,!0));try{const s=await(await Ne(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(aS(t,s.value??""))}catch{e(md(t,!1))}}})),Cp=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:PC,SETTINGS_KEYS:Me,useDisplaySettings:Nh,useSettingsStore:tn},Symbol.toStringTag,{value:"Module"}));function zA(){const[e,t]=C.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=C.useRef(window.innerHeight);return C.useEffect(()=>{const r=window.visualViewport;if(!r)return;const s=()=>{const a=r.offsetTop,l=r.height,d=n.current-l>100;t({offsetTop:a,height:l,keyboardVisible:d})};return s(),r.addEventListener("resize",s),r.addEventListener("scroll",s),()=>{r.removeEventListener("resize",s),r.removeEventListener("scroll",s)}},[]),e}function $A(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,s,a,l=[],d="",f=e.split("/");for(f[0]||f.shift();s=f.shift();)n=s[0],n==="*"?(l.push(n),d+=s[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=s.indexOf("?",1),a=s.indexOf(".",1),l.push(s.substring(1,~r?r:~a?a:s.length)),d+=~r&&!~a?"(?:/([^/]+?))?":"/([^/]+?)",~a&&(d+=(~r?"?":"")+"\\"+s.substring(a))):d+="/"+s;return{keys:l,pattern:new RegExp("^"+d+(t?"(?=$|/)":"/?$"),"i")}}var kp={exports:{}},Ep={};/**
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 oS;function HA(){if(oS)return Ep;oS=1;var e=Eh();function t(g,_){return g===_&&(g!==0||1/g===1/_)||g!==g&&_!==_}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,a=e.useLayoutEffect,l=e.useDebugValue;function d(g,_){var x=_(),v=r({inst:{value:x,getSnapshot:_}}),S=v[0].inst,w=v[1];return a(function(){S.value=x,S.getSnapshot=_,f(S)&&w({inst:S})},[g,x,_]),s(function(){return f(S)&&w({inst:S}),g(function(){f(S)&&w({inst:S})})},[g]),l(x),x}function f(g){var _=g.getSnapshot;g=g.value;try{var x=_();return!n(g,x)}catch{return!0}}function h(g,_){return _()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:d;return Ep.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Ep}var lS;function FA(){return lS||(lS=1,kp.exports=HA()),kp.exports}var UA=FA();const VA=NA.useInsertionEffect,WA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",GA=WA?C.useLayoutEffect:C.useEffect,qA=VA||GA,BC=e=>{const t=C.useRef([e,(...n)=>t[0](...n)]).current;return qA(()=>{t[0]=e}),t[1]},KA="popstate",G_="pushState",q_="replaceState",YA="hashchange",cS=[KA,G_,q_,YA],XA=e=>{for(const t of cS)addEventListener(t,e);return()=>{for(const t of cS)removeEventListener(t,e)}},zC=(e,t)=>UA.useSyncExternalStore(XA,e,t),uS=()=>location.search,QA=({ssrSearch:e}={})=>zC(uS,e!=null?()=>e:uS),dS=()=>location.pathname,JA=({ssrPath:e}={})=>zC(dS,e!=null?()=>e:dS),ZA=(e,{replace:t=!1,state:n=null}={})=>history[t?q_:G_](n,"",e),eD=(e={})=>[JA(e),ZA],hS=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[hS]>"u"){for(const e of[G_,q_]){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,hS,{value:!0})}const tD=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",$C=(e="")=>e==="/"?"":e,nD=(e,t)=>e[0]==="~"?e.slice(1):$C(t)+e,rD=(e="",t)=>tD(fS($C(e)),fS(t)),fS=e=>{try{return decodeURI(e)}catch{return e}},HC={hook:eD,searchHook:QA,parser:$A,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},FC=C.createContext(HC),Ko=()=>C.useContext(FC),UC={},VC=C.createContext(UC),sD=()=>C.useContext(VC),jh=e=>{const[t,n]=e.hook(e);return[rD(e.base,t),BC((r,s)=>e.aroundNav(n,nD(r,e.base),s))]},Jr=()=>jh(Ko()),K_=(e,t,n,r)=>{const{pattern:s,keys:a}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),l=s.exec(n)||[],[d,...f]=l;return d!==void 0?[!0,(()=>{const h=a!==!1?Object.fromEntries(a.map((g,_)=>[g,f[_]])):l.groups;let p={...f};return h&&Object.assign(p,h),p})(),...r?[d]:[]]:[!1,null]},Y_=e=>K_(Ko().parser,e,Jr()[0]),iD=({children:e,...t})=>{var p,g,_;const n=Ko(),r=t.hook?HC:n;let s=r;const[a,l=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];a&&(t.ssrSearch=l,t.ssrPath=a),t.hrefs=t.hrefs??((g=t.hook)==null?void 0:g.hrefs),t.searchHook=t.searchHook??((_=t.hook)==null?void 0:_.searchHook);let d=C.useRef({}),f=d.current,h=f;for(let x in r){const v=x==="base"?r[x]+(t[x]??""):t[x]??r[x];f===h&&v!==h[x]&&(d.current=h={...h}),h[x]=v,(v!==r[x]||v!==s[x])&&(s=h)}return C.createElement(FC.Provider,{value:s,children:e})},mS=({children:e,component:t},n)=>t?C.createElement(t,{params:n}):typeof e=="function"?e(n):e,aD=e=>{let t=C.useRef(UC);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,s])=>s!==n[r])?e:n},Kl=({path:e,nest:t,match:n,...r})=>{const s=Ko(),[a]=jh(s),[l,d,f]=n??K_(s.parser,e,a,t),h=aD({...sD(),...d});if(!l)return null;const p=f?C.createElement(iD,{base:f},mS(r,h)):mS(r,h);return C.createElement(VC.Provider,{value:h,children:p})},gr=C.forwardRef((e,t)=>{const n=Ko(),[r,s]=jh(n),{to:a="",href:l=a,onClick:d,asChild:f,children:h,className:p,replace:g,state:_,transition:x,...v}=e,S=BC(k=>{k.ctrlKey||k.metaKey||k.altKey||k.shiftKey||k.button!==0||(d==null||d(k),k.defaultPrevented||(k.preventDefault(),s(l,e)))}),w=n.hrefs(l[0]==="~"?l.slice(1):n.base+l,n);return f&&C.isValidElement(h)?C.cloneElement(h,{onClick:S,href:w}):C.createElement("a",{...v,onClick:S,href:w,className:p!=null&&p.call?p(r===l):p,children:h,ref:t})}),WC=e=>Array.isArray(e)?e.flatMap(t=>WC(t&&t.type===C.Fragment?t.props.children:t)):[e],oD=({children:e,location:t})=>{const n=Ko(),[r]=jh(n);for(const s of WC(e)){let a=0;if(C.isValidElement(s)&&(a=K_(n.parser,s.props.path,t||r,s.props.nest))[0])return C.cloneElement(s,{match:a})}return null};function lD(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function GC(){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 cD{constructor(t){ce(this,"ws",null);ce(this,"handlers",new Set);ce(this,"statusHandler",null);ce(this,"baseUrl");ce(this,"isReconnecting",!1);ce(this,"connectingPromise",null);ce(this,"lastCloseCode",0);ce(this,"reconnectAttempts",0);ce(this,"manualReconnectScheduled",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,r;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((s,a)=>{try{const l=this.getUrl();this.ws=new WebSocket(l);const d=setTimeout(()=>{var f;((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING&&(this.ws.close(),a(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var f;clearTimeout(d),this.isReconnecting=!1,this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"connected"),s()},this.ws.onclose=f=>{var h,p,g;clearTimeout(d),this.lastCloseCode=f.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),a(new Error(`Connection closed: ${f.code}`))):(this.connectingPromise=null,(g=this.statusHandler)==null||g.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=f=>{clearTimeout(d),console.error("WebSocket error:",f),this.connectingPromise=null,a(f)},this.ws.onmessage=f=>{try{const h=JSON.parse(f.data);lD(h)&&this.handlers.forEach(p=>p(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(l){this.connectingPromise=null,a(l)}}),this.connectingPromise)))}attemptReconnect(){var s;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(s=this.statusHandler)==null||s.call(this,"reconnecting");const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{})},r)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const r=GC(),s={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(s)),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 uD=window.location.protocol==="https:"?"wss:":"ws:";let Tg=window.location.port;Tg||(Tg=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const dD=`${uD}//${window.location.hostname}:${Tg}/ws`,Ft=new cD(dD);function hD(e){return{...e.temperature!=null&&{temperature:e.temperature},...e.topP!=null&&{topP:e.topP},...e.topK!=null&&{topK:e.topK},...e.maxTokens!=null&&{maxTokens:e.maxTokens}}}function pS(e){e&&xe.getState().updateContextState({...e,dynamicContextChanged:e.dynamicContextChanged??!1})}async function gS(e,t,n){const r=await Ne(`/api/providers/${e}/models/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const s=await r.json();throw new Error(s.error??"Failed to update model")}return r.json()}function _S(e,t,n,r){return e.map(s=>s.id===t?{...s,models:s.models.map(a=>a.id===n?{...a,...r,source:"user"}:a)}:s)}const fD=3e4;function Ag(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return""}}const Ot=xr((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const n=await Ne("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json();e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await Ne("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json(),a=xe.getState().currentSession;if(a!=null&&a.providerId&&a.providerModel){e({llmStatus:r.llmStatus,backend:r.backend});return}e({model:r.model,llmStatus:r.llmStatus,backend:r.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:r,providers:s}=t();if(n===r)return!0;e({activating:!0,error:null});try{const a=await Ne(`/api/providers/${n}/activate`,{method:"POST"});if(!a.ok){const d=await a.json();throw new Error(d.error??"Failed to activate provider")}const l=await a.json();return e({activeProviderId:l.activeProviderId,model:l.model,backend:l.backend,providers:s.map(d=>({...d,isActive:d.id===l.activeProviderId})),activating:!1}),!0}catch(a){return e({error:a instanceof Error?a.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(n,r)=>{var d;const{providers:s,defaultModelSelection:a}=t();let l=r;if(!l){const f=a?a.split("/"):[],h=f[0],p=f.slice(1).join("/")??"";if(h===n&&p)l=p;else{const g=s.find(_=>_.id===n);l=((d=g==null?void 0:g.models[0])==null?void 0:d.id)??""}}e({activeProviderId:n,model:l,defaultModelSelection:`${n}/${l}`,providers:s.map(f=>({...f,isActive:f.id===n}))})},updateModelContext:async(n,r,s)=>{e({activating:!0,error:null});try{const a=await gS(n,r,{contextWindow:s}),{providers:l}=t();return e({providers:_S(l,n,r,{contextWindow:s}),activating:!1}),pS(a.contextState),!0}catch(a){return e({error:a instanceof Error?a.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(n,r,s)=>{e({activating:!0,error:null});try{const a=await gS(n,r,s),{providers:l}=t(),d={...s.contextWindow!==void 0&&{contextWindow:s.contextWindow},...hD({temperature:s.temperature??void 0,topP:s.topP??void 0,topK:s.topK??void 0,maxTokens:s.maxTokens??void 0}),...s.supportsVision!==void 0&&{supportsVision:s.supportsVision}};return e({providers:_S(l,n,r,d),activating:!1}),pS(a.contextState),!0}catch(a){return e({error:a instanceof Error?a.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await Ne(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const l=await r.json();throw new Error(l.error??"Failed to refresh models")}const s=await r.json(),{providers:a}=t();return e({providers:a.map(l=>l.id===n?{...l,models:s.models,status:s.status}:l),activating:!1}),!0}catch(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const s=setInterval(()=>{r()},fD);e({autoRefreshInterval:s})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(s=>s.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:s}=t(),a=r.find(d=>d.id===s);if(!a)return 2e5;const l=a.models.find(d=>d.id===n);return(l==null?void 0:l.contextWindow)??2e5}})),Ut=xr((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await Ne("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const s=await Ne("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!s.ok){const l=await s.json().catch(()=>({}));return{error:{code:l.code||"UNKNOWN",path:l.path,message:l.error}}}const a=await s.json();return await t().listProjects(),a.project}catch{return null}},loadProject:async n=>{try{const r=await Ne(`/api/projects/${n}`);if(!r.ok)return null;const s=await r.json();return e({currentProject:s.project}),t().projects.length===0&&await t().listProjects(),s.project}catch{return null}},updateProject:async(n,r)=>{var s;try{const a=await Ne(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)return null;const l=await a.json();return((s=t().currentProject)==null?void 0:s.id)===n&&e({currentProject:l.project}),await t().listProjects(),l.project}catch{return null}},deleteProject:async n=>{var r;try{return(await Ne(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var s;try{const a=await Ne(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!a.ok)return!1;if(((s=t().currentProject)==null?void 0:s.id)===n){const l=await a.json();e({currentProject:l.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),zi=async(e,t,n)=>{try{const r=await Ne(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?{success:!0}:{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}},Th=async(e,t,n)=>{try{const r=await Ne(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),s=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:s.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function qC(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let pd=[];const yc=xr()((e,t)=>{function n(){if(pd.length===0)return;const s=pd;pd=[],e(a=>{const l={...a.logs};for(const d of s){const f=l[d.processId]??[];l[d.processId]=[...f,{offset:f.length,content:d.content,timestamp:Date.now(),stream:d.stream}]}return{logs:l}})}const r=qC(n);return{processes:[],logs:{},loading:!1,setProcesses:s=>e({processes:s}),addProcess:s=>e(a=>({processes:[...a.processes,s]})),updateProcess:(s,a)=>e(l=>({processes:l.processes.map(d=>d.id===s?{...d,...a}:d)})),removeProcess:s=>e(a=>({processes:a.processes.filter(l=>l.id!==s),logs:Object.fromEntries(Object.entries(a.logs).filter(([l])=>l!==s))})),stopProcess:async(s,a)=>{try{(await Ne(`/api/sessions/${a}/background-process/${s}/stop`,{method:"POST"})).ok&&t().removeProcess(s)}catch{}},appendLog:(s,a,l)=>{pd.push({processId:s,stream:a,content:l}),r()},setLogs:(s,a)=>e(l=>({logs:{...l.logs,[s]:a}})),clearLogs:s=>e(a=>({logs:{...a.logs,[s]:[]}})),handleMessage:(s,a)=>{switch(s){case"backgroundProcess.started":{const{processId:l,name:d,pid:f,status:h}=a;e(p=>({processes:[...p.processes,{id:l,sessionId:"",name:d,command:"",cwd:"",pid:f,status:h,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const l=a.processId,d=a.stream,f=a.content;t().appendLog(l,d,f);break}case"backgroundProcess.exited":{const l=a.processId,d=a.exitCode;e(f=>({processes:f.processes.map(h=>h.id===l?{...h,status:"exited",exitCode:d}:h)}));break}case"backgroundProcess.removed":{const l=a.processId;t().removeProcess(l);break}}}}}),mD={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Ho=null,$d=null;function pD(e){$d=e}function fa(){return mD}function Np(){Ho===null&&(Ho=requestAnimationFrame(()=>{Ho=null,$d==null||$d()}))}function ya(){Ho!==null&&(cancelAnimationFrame(Ho),Ho=null)}let gd=[];const hs=xr()((e,t)=>{function n(){if(gd.length===0)return;const s=gd;gd=[],e(a=>({logs:[...a.logs,...s]}))}const r=qC(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:s=>{t().workdir!==s&&(e({workdir:s,status:null,logs:[],config:null,loading:!0}),s&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const s=t().workdir;if(s)try{const l=await(await Ne(`/api/dev-server?workdir=${encodeURIComponent(s)}`)).json();e({status:l,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const s=t().workdir;if(s)try{const l=await(await Ne(`/api/dev-server/config?workdir=${encodeURIComponent(s)}`)).json();e({config:l.config??null})}catch{}},fetchLogs:async()=>{const s=t().workdir;if(s)try{const d=(await(await Ne(`/api/dev-server/logs?workdir=${encodeURIComponent(s)}`)).json()).logs.map(f=>({stream:f.stream,content:f.content}));e({logs:d})}catch{}},start:async()=>{const s=t().workdir;if(s)try{const l=await(await Ne(`/api/dev-server/start?workdir=${encodeURIComponent(s)}`,{method:"POST"})).json();e({status:l,logs:[]})}catch{}},stop:async()=>{const s=t().workdir;if(s)try{const l=await(await Ne(`/api/dev-server/stop?workdir=${encodeURIComponent(s)}`,{method:"POST"})).json();e({status:l})}catch{}},restart:async()=>{const s=t().workdir;if(s)try{const l=await(await Ne(`/api/dev-server/restart?workdir=${encodeURIComponent(s)}`,{method:"POST"})).json();e({status:l,logs:[]})}catch{}},saveConfig:async s=>{const a=t().workdir;if(a)try{const d=await(await Ne(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();e({config:d.config??s}),t().fetchStatus()}catch{}},handleMessage:s=>{const a=t().workdir;if(a)switch(s.type){case"devServer.output":{const l=s.payload;if(l.workdir!==a)return;gd.push({stream:l.stream,content:l.content}),r();break}case"devServer.state":{const l=s.payload;if(l.workdir!==a)return;e(d=>({status:d.status?{...d.status,state:l.state,errorMessage:l.errorMessage}:d.status}));break}}}}}),gD=[{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"}],_D=[{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"}],KC={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"},Ri={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},YC={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Dg={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Ri},waiting_for_user:{...Ri},phase_done:{...Ri},phase_blocked:{...Ri},new_message:{...YC}},agentOverrides:{}};function XC(e,t,n){var a;const r=e.events[t];if(!n)return r;const s=(a=e.agentOverrides[n])==null?void 0:a[t];return s?{soundEnabled:s.soundEnabled??r.soundEnabled,browserNotification:s.browserNotification??r.browserNotification,customSoundUrl:s.customSoundUrl!==void 0?s.customSoundUrl:r.customSoundUrl}:r}const _a=xr((e,t)=>({settings:Dg,loaded:!1,load:()=>{tn.getState().getSetting(Me.NOTIFICATION_SETTINGS);const r=tn.subscribe(a=>{const l=a.settings[Me.NOTIFICATION_SETTINGS];if(l!==void 0)try{const d=JSON.parse(l);e({settings:xS(d),loaded:!0})}catch{e({loaded:!0})}}),s=tn.getState().settings[Me.NOTIFICATION_SETTINGS];if(s)try{const a=JSON.parse(s);e({settings:xS(a),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),jp(n)},updateEvent:(n,r)=>{const s=t().settings,a={...s,events:{...s.events,[n]:{...s.events[n],...r}}};e({settings:a}),jp(a)},updateAgentOverride:(n,r,s)=>{var f;const a=t().settings,l={...a.agentOverrides};if(s===null){if(l[n]){const h={...l[n]};delete h[r],Object.keys(h).length===0?delete l[n]:l[n]=h}}else l[n]={...l[n],[r]:{...((f=l[n])==null?void 0:f[r])??{},...s}};const d={...a,agentOverrides:l};e({settings:d}),jp(d)}}));function jp(e){tn.getState().setSetting(Me.NOTIFICATION_SETTINGS,JSON.stringify(e))}function xS(e){var t,n,r,s,a;return{soundEnabled:e.soundEnabled??Dg.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Dg.browserNotificationEnabled,events:{complete:{...Ri,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Ri,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Ri,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...Ri,...(s=e.events)==null?void 0:s.phase_blocked},new_message:{...YC,...(a=e.events)==null?void 0:a.new_message}},agentOverrides:e.agentOverrides??{}}}const yS=new Map;function xD(e){let t=yS.get(e);return t||(t=new Audio(e),t.volume=.5,yS.set(e,t)),t}let QC=typeof Notification<"u"?Notification.permission:"denied";function yD(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(QC=e,e))}const vD={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},bD={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 SD(e){typeof Notification>"u"||QC==="granted"&&(document.hasFocus()||new Notification(vD[e],{body:bD[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function zc(e,t){const{settings:n}=_a.getState(),r=XC(n,e,t);if(n.soundEnabled&&r.soundEnabled){const s=r.customSoundUrl??KC[e],a=xD(s);a.currentTime=0,a.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&SD(e)}const wD=e=>zc("complete",e),CD=e=>zc("phase_done",e),kD=e=>zc("phase_blocked",e),vS=e=>zc("waiting_for_user",e),ED=e=>zc("new_message",e),bS=new Map;function dc(e,t){var a;const n=t===((a=e.currentSession)==null?void 0:a.id)?e.currentSession:null,r=e.sessions.find(l=>l.id===t),s=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return s==="planner"?"planner":s==="builder"?"build":"planner"}function ND(e,t){if(e.type==="chat.done"){const n=e.payload,r=dc(t,e.sessionId),s=n.agentType??r;n.reason==="complete"&&wD(s),n.reason==="waiting_for_user"&&vS(s);return}if(e.type==="chat.path_confirmation"){const n=dc(t,e.sessionId);vS(n);return}if(e.type==="task.completed"){const n=dc(t,e.sessionId);CD(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=bS.get(e.sessionId)??null;if(bS.set(e.sessionId,n.phase),r===n.phase)return;const s=dc(t,e.sessionId);n.phase==="blocked"&&kD(s)}}const Tp=new Set;function Zt(e,t){return t!==null&&e.sessionId===t}function jD(e,t,n){return e.id!==void 0||Zt(e,t)||n===!0&&e.sessionId!==void 0}function TD(e,t){return e.includes(t)?e:[...e,t]}function SS(e,t){return e.filter(n=>n!==t)}function AD(e,t){const n=e.find(a=>a.id===t.id),r=t.messageCount??t.messages.length,s=n?{...n,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(a=>a.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(a=>a.status.type==="passed").length,messageCount:r};return n?e.map(a=>a.id===t.id?s:a):[s,...e]}function DD(e,t,n){return e.map(r=>{const s=(n==null?void 0:n.id)===r.id?n:null,a=t.find(l=>l.id===r.id);return{...r,title:r.title??(a==null?void 0:a.title),mode:(s==null?void 0:s.mode)??(a==null?void 0:a.mode)??r.mode,phase:(s==null?void 0:s.phase)??(a==null?void 0:a.phase)??r.phase,isRunning:r.isRunning&&(a==null?void 0:a.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function wS(e,t,n,r){var d;const s=e.sessionId,a=(d=n().currentSession)==null?void 0:d.id,l=s&&s!==a;if(t(f=>({sessions:f.sessions.map(h=>h.id===s?r(h):h)})),!l){const f=n().currentSession;if(f){const h=r(f);t(()=>({currentSession:h}))}}}function CS(e,t,n){var l,d,f,h,p,g,_,x,v,S,w,k,j,T,A,P,R,q,J,ne,I,W,z;const r=n();ND(e,r);const s=((l=r.currentSession)==null?void 0:l.id)??null,a=()=>{const L=e.sessionId;!L||L===s||t(U=>({unreadSessionIds:TD(U.unreadSessionIds,L)}))};switch(e.type){case"session.state":{const L=e.payload;if(!jD(e,s,r.pendingSessionCreate))break;ya();const U=L.messages.find(N=>N.isStreaming)??null,D=n().pendingSessionCreate===!0;if(t({currentSession:L.session,sessions:AD(n().sessions,L.session),unreadSessionIds:SS(n().unreadSessionIds,L.session.id),messages:L.messages,streamingMessageId:(U==null?void 0:U.id)??null,streamingMessage:U,currentTodos:[],pendingPathConfirmations:L.pendingConfirmations??[],error:null,...D?{pendingSessionCreate:L.session.id}:{}}),L.session.providerId){const N=Ot.getState();N.providers.find(H=>H.id===L.session.providerId)&&N.syncFromSession(L.session.providerId,L.session.providerModel??"")}break}case"session.list":{const L=e.payload;t(U=>({sessions:DD(L.sessions,U.sessions,U.currentSession)}));break}case"session.deleted":{const L=e.payload;t(U=>({unreadSessionIds:SS(U.unreadSessionIds,L.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const L=e.payload;wS(e,t,n,U=>({...U,isRunning:L.isRunning})),L.isRunning||t({abortInProgress:!1,queuedMessages:[]});break}case"chat.message":{if(!Zt(e,((d=n().currentSession)==null?void 0:d.id)??null)){a();break}const L=e.payload;t(U=>{if(U.messages.some(N=>N.id===L.message.id))return U;const D=L.message.role==="user";return{messages:[...U.messages,L.message],sessions:U.sessions.map(N=>N.id===e.sessionId&&D?{...N,messageCount:N.messageCount+1}:N),streamingMessageId:L.message.isStreaming?L.message.id:U.streamingMessageId,streamingMessage:L.message.isStreaming?L.message:U.streamingMessage}});break}case"chat.message_updated":{if(!Zt(e,((f=n().currentSession)==null?void 0:f.id)??null)){a();break}const L=e.payload,U=L.updates.isStreaming===!1&&n().streamingMessageId===L.messageId;U&&ya(),t(D=>{const N=D.streamingMessage;if(N&&N.id===L.messageId){const F={...N,...L.updates};return{messages:D.messages.map(H=>H.id===L.messageId?F:H),streamingMessageId:U?null:D.streamingMessageId,streamingMessage:U?null:{...N,...L.updates}}}return{messages:D.messages.map(F=>F.id===L.messageId?{...F,...L.updates}:F),streamingMessageId:U?null:D.streamingMessageId}});break}case"chat.delta":{if(!Zt(e,((h=n().currentSession)==null?void 0:h.id)??null)){a();break}const L=e.payload;if(!Tp.has(L.messageId)){Tp.add(L.messageId);const D=L.subAgentType?"sub-agent":dc(n(),e.sessionId);ED(D)}const U=fa();U.messageId=L.messageId,U.deltaContent+=L.content,Np();break}case"chat.thinking":{if(!Zt(e,((p=n().currentSession)==null?void 0:p.id)??null)){a();break}const L=e.payload,U=fa();U.messageId=L.messageId,U.thinkingContent+=L.content,Np();break}case"chat.tool_preparing":{if(!Zt(e,((g=n().currentSession)==null?void 0:g.id)??null)){a();break}const L=e.payload,U=n().streamingMessage;if(!U||U.id!==L.messageId||((_=U.toolCalls)==null?void 0:_.find((N,F)=>F===L.index)))return;t(N=>{const F=N.streamingMessage.preparingToolCalls??[],H=F.findIndex(B=>B.index===L.index);let se;return H>=0?se=F.map((B,V)=>V===H?{...B,arguments:L.arguments}:B):se=[...F,{index:L.index,name:L.name,...L.arguments?{arguments:L.arguments}:{}}],{streamingMessage:{...N.streamingMessage,preparingToolCalls:se}}});break}case"chat.tool_call":{if(!Zt(e,((x=n().currentSession)==null?void 0:x.id)??null)){a();break}const L=e.payload,U=D=>{var se;const N=(se=D.preparingToolCalls)==null?void 0:se.filter((B,V)=>{var K;return B.name===L.tool?(K=D.preparingToolCalls)==null?void 0:K.slice(0,V).some(Q=>Q.name===L.tool):!0}),F=fa(),H=F.toolOutput.filter(B=>B.callId===L.callId);return H.length>0&&(F.toolOutput=F.toolOutput.filter(B=>B.callId!==L.callId)),{...D,toolCalls:[...D.toolCalls??[],{id:L.callId,name:L.tool,arguments:L.args,startedAt:Date.now(),...H.length>0?{streamingOutput:H.map(B=>({stream:B.stream,content:B.content,timestamp:Date.now()}))}:{}}],...N&&N.length>0?{preparingToolCalls:N}:{preparingToolCalls:void 0}}};t(D=>{const N=D.streamingMessage;return N&&N.id===L.messageId?{streamingMessage:U(N)}:{messages:D.messages.map(F=>F.id===L.messageId?U(F):F)}});break}case"chat.tool_output":{if(!Zt(e,((v=n().currentSession)==null?void 0:v.id)??null)){a();break}const L=e.payload,U=fa();U.messageId=L.messageId,U.toolOutput.push({messageId:L.messageId,callId:L.callId,stream:L.stream,content:L.output}),Np();break}case"chat.tool_result":{if(!Zt(e,((S=n().currentSession)==null?void 0:S.id)??null)){a();break}const L=e.payload,U=D=>{var F;const N=(F=D.toolCalls)==null?void 0:F.map(H=>H.id===L.callId?{...H,result:L.result}:H);return{...D,toolCalls:N}};t(D=>{const N=D.streamingMessage;return N&&N.id===L.messageId?{streamingMessage:U(N)}:{messages:D.messages.map(F=>F.id===L.messageId?U(F):F)}});break}case"chat.vision_fallback":{if(!Zt(e,((w=n().currentSession)==null?void 0:w.id)??null)){a();break}const L=e.payload;t(U=>{const D=`${L.messageId}-${L.attachmentId}`,N={...U.visionFallbackByMessage};return N[D]={type:L.type,attachmentId:L.attachmentId,filename:L.filename,description:L.description},{visionFallbackByMessage:N}});break}case"chat.todo":{if(!Zt(e,((k=n().currentSession)==null?void 0:k.id)??null)){a();break}const L=e.payload;t({currentTodos:L.todos});break}case"chat.progress":{if(!Zt(e,((j=n().currentSession)==null?void 0:j.id)??null)){a();break}const L=e.payload;console.warn("Progress:",L.message,L.phase);break}case"chat.format_retry":{if(!Zt(e,((T=n().currentSession)==null?void 0:T.id)??null)){a();break}const L=e.payload;console.warn("Format retry:",L.attempt,"/",L.maxAttempts);break}case"chat.done":{if(!Zt(e,((A=n().currentSession)==null?void 0:A.id)??null)){a();break}ya();const L=fa();L.messageId=null,L.deltaContent="",L.thinkingContent="",L.toolOutput=[],Tp.delete(e.payload.messageId);const U=e.payload,D=U.stats;t(N=>{const F=N.streamingMessage,H=F&&F.id===U.messageId?{...F,isStreaming:!1,stats:D??F.stats}:null;return{messages:N.messages.map(se=>se.id===U.messageId?H??{...se,isStreaming:!1,stats:D??se.stats,completeReason:U.reason}:se),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Zt(e,((P=n().currentSession)==null?void 0:P.id)??null)){a();break}ya();const L=fa(),U=e.payload;console.error("Chat error:",U.error,"recoverable:",U.recoverable),U.recoverable||(L.messageId=null,L.deltaContent="",L.thinkingContent="",L.toolOutput=[]),t(D=>({error:{code:"CHAT_ERROR",message:U.error},streamingMessageId:U.recoverable?D.streamingMessageId:null,...U.recoverable?{}:{messages:D.streamingMessage?D.messages.map(N=>N.id===D.streamingMessage.id?D.streamingMessage:N):D.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Zt(e,((R=n().currentSession)==null?void 0:R.id)??null)){a();break}const L=e.payload,U={callId:L.callId,tool:L.tool,paths:L.paths,workdir:L.workdir,reason:L.reason};t(D=>({pendingPathConfirmations:[...D.pendingPathConfirmations,U]}));break}case"chat.ask_user":{if(!Zt(e,((q=n().currentSession)==null?void 0:q.id)??null)){a();return}const L=e.payload;t({pendingQuestion:{callId:L.callId,question:L.question}});break}case"mode.changed":{if(!Zt(e,((J=n().currentSession)==null?void 0:J.id)??null)){a();break}const L=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,mode:L.mode}:null}));break}case"phase.changed":{const L=e.payload;wS(e,t,n,U=>({...U,phase:L.phase}));break}case"criteria.updated":{if(!Zt(e,((ne=n().currentSession)==null?void 0:ne.id)??null)){a();break}const L=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,criteria:L.criteria}:null}));break}case"metadata.updated":{if(!Zt(e,((I=n().currentSession)==null?void 0:I.id)??null)){a();break}const L=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,metadataEntries:{...U.currentSession.metadataEntries,[L.key]:L.entries}}:null}));break}case"context.state":{const L=e.payload,U=Zt(e,((W=n().currentSession)==null?void 0:W.id)??null);L.subAgentId?U&&n().updateSubAgentContextState(L.subAgentId,L.context):U?t({contextState:L.context}):a();break}case"session.name_generated":{const L=e.payload,U=e.sessionId,D=(z=n().currentSession)==null?void 0:z.id;t(N=>{const F=N.sessions.map(se=>se.id===U?{...se,title:L.name,updatedAt:new Date().toISOString()}:se),H=D===U?N.currentSession?{...N.currentSession,title:L.name,updatedAt:new Date().toISOString()}:null:N.currentSession;return{sessions:F,currentSession:H}});break}case"queue.state":{const L=e.payload;t({queuedMessages:L.messages??[]});break}case"git.status":{const L=e.payload;t({gitStatus:{branch:L.branch,diff:L.diff}});break}case"devServer.output":case"devServer.state":{hs.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{yc.getState().handleMessage(e.type,e.payload);break}case"error":{const L=e.payload;console.error("Server error:",L),t({error:{code:L.code,message:L.message},streamingMessageId:null});break}}}let Yl=!1,ss=null;const Ap=new Set,_d=new Map;function kS(e,t,n){return e==null?void 0:e.map(r=>{const s=t.filter(a=>a.callId===r.id);return s.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...s.map(a=>({stream:a.stream,content:a.content,timestamp:Date.now()}))]})})}async function ES(e,t,n,r,s){try{const l=await(await Ne(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();l.queueState&&s({queuedMessages:l.queueState})}catch(a){console.error("Error queueing message:",a)}}const xe=xr((e,t)=>(pD(()=>{const n=fa();if(!n.messageId)return;const r=n.deltaContent.length>0,s=n.thinkingContent.length>0,a=n.toolOutput.length>0;if(!r&&!s&&!a)return;const l=n.deltaContent,d=n.thinkingContent,f=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(h=>{const p=h.streamingMessage;if(p&&p.id===n.messageId){const g={...p};if(r&&(g.content=g.content+l),s&&(g.thinkingContent=(g.thinkingContent??"")+d),a){const _=new Set;g.toolCalls=kS(g.toolCalls,f,_);const x=f.filter(v=>!_.has(v.callId));x.length>0&&n.toolOutput.push(...x)}return{streamingMessage:g}}if(a){const g=new Set,_=h.messages.map(v=>v.id!==n.messageId?v:{...v,toolCalls:kS(v.toolCalls,f,g)}),x=f.filter(v=>!g.has(v.callId));return x.length>0&&n.toolOutput.push(...x),{messages:_}}return h})}),{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestion:null,visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let r=!1;try{r=(await(await Ne("/api/auth")).json()).requiresAuth}catch{}if(r&&!Ft.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Ft.onStatusChange(s=>{var a;if(e({connectionStatus:s}),s==="connected"){t().listSessions(void 0),Ut.getState().listProjects();const l=(a=t().currentSession)==null?void 0:a.id;l&&t().loadSession(l)}});try{await Ft.connect(),Yl||(Yl=!0,ss=Ft.subscribe(s=>{CS(s,e,t)}))}catch(s){console.error("Failed to connect:",s);const a=Ft.getLastCloseCode();if(!Ft.hasToken()&&(a===1006||a===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}ss&&(ss(),ss=null),Yl=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Ft.disconnect(),ss&&(ss(),ss=null),Yl=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Ft.disconnect(),ss&&(ss(),ss=null),Yl=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async n=>{try{const r=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:n})});if(!r.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:s}=await r.json();Ft.setToken(s),e({showPasswordModal:!1}),t().connect();const{listProjects:a}=Ut.getState(),{fetchConfig:l}=Ot.getState();a(),l(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Ft.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,r)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const a=await Ne("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:r})});if(!a.ok)return e({pendingSessionCreate:!1}),null;const l=await a.json();try{Ft.send("session.load",{sessionId:l.session.id})}catch{}return l.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!Ap.has(n)){Ap.add(n);try{const r=t().currentSession;!r||r.id!==n?(ya(),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(l=>l!==n),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmations:[],queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1})):e({unreadSessionIds:t().unreadSessionIds.filter(l=>l!==n)});const s=await Ne(`/api/sessions/${n}`);if(!s.ok)return;const a=await s.json();e({currentSession:a.session,messages:a.messages??[],contextState:a.contextState,queuedMessages:a.queueState??[]}),Ft.send("session.load",{sessionId:n});try{const l=await Ne(`/api/sessions/${n}/background-processes`);if(l.ok){const d=await l.json();yc.getState().setProcesses(d.processes??[])}}catch{}}catch{}finally{Ap.delete(n)}}},listSessions:async(n,r=20)=>{const s=n??"global";if(_d.has(s))return _d.get(s);const a=(async()=>{try{const l=new URLSearchParams;l.set("limit",String(r)),n&&l.set("projectId",n);const f=await(await Ne(`/api/sessions?${l.toString()}`)).json(),h=f.sessions??[];e(p=>({sessions:h.map(g=>{var x,v;const _=p.sessions.find(S=>S.id===g.id);return{...g,title:g.title??(_==null?void 0:_.title),mode:((x=p.currentSession)==null?void 0:x.id)===g.id?p.currentSession.mode:(_==null?void 0:_.mode)??g.mode,phase:((v=p.currentSession)==null?void 0:v.id)===g.id?p.currentSession.phase:(_==null?void 0:_.phase)??g.phase,isRunning:g.isRunning&&(_==null?void 0:_.isRunning)!==!1,messageCount:g.messageCount,recentUserPrompts:g.recentUserPrompts}}),sessionsHasMore:n?f.hasMore??!1:!0}))}catch{}finally{_d.delete(s)}})();return _d.set(s,a),a},loadMoreSessions:async n=>{const r=t();if(!(r.sessionsPaginationLoading||!r.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const s=new URLSearchParams;s.set("limit","20"),s.set("offset",String(r.sessions.length)),s.set("projectId",n);const l=await(await Ne(`/api/sessions?${s.toString()}`)).json(),d=l.sessions??[];e(f=>({sessions:[...f.sessions,...d.map(h=>{const p=f.sessions.find(g=>g.id===h.id);return(p==null?void 0:p.isRunning)===!1?{...h,isRunning:!1}:h})],sessionsHasMore:l.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var r;try{return(await Ne(`/api/sessions/${n}`,{method:"DELETE"})).ok?(await t().listSessions(),((r=t().currentSession)==null?void 0:r.id)===n&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(n,r)=>{var s;try{const a=await Ne(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r})});if(!a.ok)return!1;if(await t().listSessions(),((s=t().currentSession)==null?void 0:s.id)===n){const d=await a.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await Ne(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{ya(),e(n=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?n.unreadSessionIds.filter(r=>r!==n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,r,s)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a){e({streamingMessageId:null});try{const f=await(await Ne(`/api/sessions/${a}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:r,messageKind:s==null?void 0:s.messageKind})})).json();f.queueState&&e({queuedMessages:f.queueState})}catch(d){console.error("Error sending message:",d)}}},stopGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n&&!t().abortInProgress){ya(),e({abortInProgress:!0});try{await Ne(`/api/sessions/${n}/stop`,{method:"POST"})}catch(s){console.error("Error stopping generation:",s)}}},continueGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n){e({streamingMessageId:null});try{await Ne(`/api/sessions/${n}/continue`,{method:"POST"})}catch(s){console.error("Error continuing generation:",s)}}},launchRunner:(n,r,s,a)=>{e({streamingMessageId:null});const l={};n!=null&&n.trim()&&(l.content=n),r&&r.length>0&&(l.attachments=r),s&&(l.workflowId=s),a&&(l.subGroup=a),Ft.send("runner.launch",l)},switchMode:async n=>{var s;const r=(s=t().currentSession)==null?void 0:s.id;if(r)try{const a=await Ne(`/api/sessions/${r}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!a.ok){console.error("Failed to switch mode:",await a.json());return}const l=await a.json();l.session&&e({currentSession:l.session})}catch(a){console.error("Error switching mode:",a)}},switchDangerLevel:async n=>{var s;const r=(s=t().currentSession)==null?void 0:s.id;if(r)try{const a=await Ne(`/api/sessions/${r}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!a.ok){console.error("Failed to switch danger level:",await a.json());return}const l=await a.json();l.session&&e({currentSession:l.session})}catch(a){console.error("Error switching danger level:",a)}},acceptAndBuild:(n,r,s,a)=>{var f;e({streamingMessageId:null});const l={};n&&(l.workflowId=n),r!=null&&r.trim()&&(l.content=r),s&&s.length>0&&(l.attachments=s),a&&(l.subGroup=a);const d=(f=t().currentSession)==null?void 0:f.id;d&&Ne(`/api/sessions/${d}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{Ft.send("runner.launch",l)})},editCriteria:async n=>{var s;const r=(s=t().currentSession)==null?void 0:s.id;if(r)try{const a=await Ne(`/api/sessions/${r}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});a.ok||console.error("Failed to update criteria:",await a.json())}catch(a){console.error("Error updating criteria:",a)}},compactContext:()=>{Ft.send("context.compact",{})},setSessionProvider:async(n,r)=>{var s,a;try{const l=(s=t().currentSession)==null?void 0:s.id;if(!l)return null;const d=await Ne(`/api/sessions/${l}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...r?{model:r}:{}})});if(!d.ok)return null;const f=await d.json();if(e({currentSession:f.session,messages:f.messages??[],contextState:f.contextState}),(a=f.session)!=null&&a.providerId){const h=Ot.getState();h.providers.find(g=>g.id===f.session.providerId)&&h.syncFromSession(f.session.providerId,f.session.providerModel??"")}return f.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,r)=>{e(s=>({subAgentContextStates:{...s.subAgentContextStates,[n]:r}}))},clearSubAgentContextState:n=>{e(r=>{const s={...r.subAgentContextStates};return delete s[n],{subAgentContextStates:s}})},confirmPath:async(n,r,s=!1)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{await Ne(`/api/sessions/${a}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:r,alwaysAllow:s})})}catch(d){console.error("Error confirming path:",d)}},answerQuestion:async(n,r)=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s){try{await Ne(`/api/sessions/${s}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:r})})}catch(l){console.error("Error answering question:",l)}e({pendingQuestion:null})}},queueAsap:async(n,r,s)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;a&&await ES(a,n,r,s,e)},queueCompletion:async(n,r,s)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;a&&await ES(a,n,r,s,e)},cancelQueued:async n=>{var s;const r=(s=t().currentSession)==null?void 0:s.id;if(r)try{const l=await(await Ne(`/api/sessions/${r}/queue/${n}`,{method:"DELETE"})).json();l.queueState&&e({queuedMessages:l.queueState})}catch(a){console.error("Error canceling queued message:",a)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{CS(n,e,t)}}));function Ah(){return xe(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function LD(){return xe(e=>e.abortInProgress)}function RD(){const e=xe(r=>r.connect),t=xe(r=>r.connectionStatus),n=_a(r=>r.load);return C.useEffect(()=>{e()},[e]),C.useEffect(()=>{t==="connected"&&n()},[t,n]),{connectionStatus:t}}const MD="modulepreload",OD=function(e){return"/"+e},NS={},$=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),f=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));s=l(n.map(h=>{if(h=OD(h),h in NS)return;NS[h]=!0;const p=h.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const _=document.createElement("link");if(_.rel=p?"stylesheet":MD,p||(_.as="script"),_.crossOrigin="",_.href=h,f&&_.setAttribute("nonce",f),document.head.appendChild(_),p)return new Promise((x,v)=>{_.addEventListener("load",x),_.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return s.then(l=>{for(const d of l||[])d.status==="rejected"&&a(d.reason);return t().catch(a)})},JC=[{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"}],fs=[{id:"dark",name:"Dark",tokens:{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60"}},{id:"light",name:"Light",tokens:{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225"}},{id:"monokai",name:"Monokai",tokens:{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62"}},{id:"dracula",name:"Dracula",tokens:{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90"}},{id:"nord",name:"Nord",tokens:{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"76 86 106","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"76 86 106"}}];function jS(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Gt=xr((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:jS(),followSystemTheme:!0,applySavedTheme:()=>{const{getSavedTheme:n,applyPreset:r,applyTokens:s}=t(),a=n();if(a)try{const l=JSON.parse(a);l.preset&&l.tokens?(r(l.preset),e({basePreset:l.preset}),s(l.tokens)):l.preset?r(l.preset):l.tokens&&s(l.tokens)}catch{r("dark")}else r("dark")},applyPreset:n=>{fs.find(s=>s.id===n)&&(e({currentPreset:n,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1}),t().applyTheme())},startCustomizing:()=>{var s;const{currentPreset:n}=t(),r=((s=fs.find(a=>a.id===n))==null?void 0:s.tokens)??{};e({basePreset:n,customTokens:{...r},isCustom:!0,isCustomizing:!0})},setCustomToken:(n,r)=>{e(s=>({customTokens:{...s.customTokens,[n]:r}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:n}=t();t().saveTheme(JSON.stringify({tokens:n})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:n=>{e({customTokens:n,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var l,d;const{basePreset:n,customTokens:r,isCustom:s}=t();if(s&&n)return{...((l=fs.find(h=>h.id===n))==null?void 0:l.tokens)??{},...r};if(s)return{...JC.reduce((f,h)=>({...f,[h.key]:h.defaultValue}),{}),...r};const a=fs.find(f=>f.id===t().currentPreset);return(a==null?void 0:a.tokens)??((d=fs[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const n=t().getActiveTheme(),r=document.documentElement;Object.entries(n).forEach(([s,a])=>{r.style.setProperty(`--${s}`,a)})},getSavedTheme:()=>{try{const n=localStorage.getItem("openfox:theme");if(!n)return null;if(n[0]!=="{")return JSON.stringify({preset:n});const r=JSON.parse(n);if(r.preset)return JSON.stringify({preset:r.preset});if(r.tokens)return JSON.stringify({tokens:r.tokens})}catch{return null}return null},saveTheme:async n=>{localStorage.setItem("openfox:theme",n);const{useSettingsStore:r}=await $(async()=>{const{useSettingsStore:s}=await Promise.resolve().then(()=>Cp);return{useSettingsStore:s}},void 0);await r.getState().setSetting(Me.DISPLAY_THEME,n)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:n=>{e({followSystemTheme:n}),$(async()=>{const{useSettingsStore:r,SETTINGS_KEYS:s}=await Promise.resolve().then(()=>Cp);return{useSettingsStore:r,SETTINGS_KEYS:s}},void 0).then(({useSettingsStore:r,SETTINGS_KEYS:s})=>{r.getState().setSetting(s.DISPLAY_FOLLOW_SYSTEM_THEME,String(n))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const n=window.matchMedia("(prefers-color-scheme: dark)"),r=a=>{const{followSystemTheme:l}=t();l&&(t().applyPreset(a?"dark":"light"),t().saveTheme(JSON.stringify({preset:a?"dark":"light"})))};r(n.matches);const s=a=>r(a.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0})},addUserPreset:n=>{const{basePreset:r,customTokens:s,currentPreset:a}=t(),l={id:"custom-"+Date.now(),name:n,basePreset:r||a,tokens:{...s}},d=[...t().userPresets,l];e({userPresets:d}),t().saveUserPresets()},applyUserPreset:n=>{const r=t().userPresets[n];r&&(e({currentPreset:r.basePreset,basePreset:r.basePreset,customTokens:{...r.tokens},isCustom:!0,isCustomizing:!1}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:r.basePreset,tokens:r.tokens})).catch(()=>{}))},deleteUserPreset:n=>{const r=t().userPresets.filter((s,a)=>a!==n);e({userPresets:r}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:jS()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),$(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>Cp);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting(Me.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function ID({canLoad:e,projectId:t,currentProjectId:n}){const r=Ut(l=>l.loadProject),s=xe(l=>l.listSessions),a=xe(l=>l.clearSession);C.useEffect(()=>{e&&t&&(n!==t&&r(t),s(t),a())},[e,t,n,r,s,a])}function PD({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:s}){const a=xe(h=>h.loadSession),l=Ut(h=>h.loadProject),d=xe(h=>h.listSessions),f=xe(h=>h.pendingSessionCreate);C.useEffect(()=>{e&&t&&r!==t&&l(t)},[e,t,r,l]),C.useEffect(()=>{e&&n&&s!==n&&a(n),e&&t&&d(t)},[e,n,s,a,d,f,t])}function BD({className:e="w-5 h-5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function ZC({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function zD({className:e="w-5 h-5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function $D({className:e="w-3 h-3 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function HD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function gs({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Br({className:e="w-3 h-3 text-text-muted",rotate:t}){return c.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function FD({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function X_({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function UD({className:e="w-3 h-3"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function Q_({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[c.jsx("circle",{cx:"12",cy:"5",r:"2"}),c.jsx("circle",{cx:"12",cy:"12",r:"2"}),c.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Ec({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function J_({className:e="w-5 h-5 text-accent-primary"}){return c.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function VD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"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 WD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function GD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function ek({className:e="w-3 h-3"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function qD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function TS({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function tk({className:e="w-[18px] h-[18px]"}){return c.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[c.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function KD({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),c.jsx("path",{d:"M9.5 2h4.5v4.5"}),c.jsx("path",{d:"M14 2L7.5 8.5"})]})}function YD({className:e="w-3 h-3",color:t}){return c.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{d:"M8 5v14l11-7z"})})}function $i({className:e="w-3 h-3 text-accent-primary"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function XD({className:e="w-5 h-5"}){return c.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function Z_({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function QD({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function JD({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return c.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[c.jsx("title",{children:"Running"}),c.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),c.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function ZD({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function eL({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function nk({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function tL({className:e="w-3.5 h-3.5 shrink-0",color:t}){return c.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function nL({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"4 17 10 11 4 5"}),c.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function $c({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function ex(){return c.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function rL({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Lg({className:e="w-2.5 h-2.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Hc({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function rk({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function sL({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function iL({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function AS({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function Rg(){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 DS(e,t){const n=Ft.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Rg(),type:e,payload:t}))}const Kr=xr((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const r=await Ne(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const s=await r.json();e({sessions:s});const a=Ft.ws;if(a&&a.readyState===WebSocket.OPEN)for(const l of s)a.send(JSON.stringify({id:Rg(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const s=await Ne("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(s.ok){const a=await s.json();e(d=>({sessions:[...d.sessions,a]}));const l=Ft.ws;l&&l.readyState===WebSocket.OPEN&&l.send(JSON.stringify({id:Rg(),type:"terminal.subscribe",payload:{sessionId:a.id}}))}}catch(s){console.error("Failed to create terminal:",s)}},writeSession:(n,r)=>{DS("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,s)=>{DS("terminal.resize",{sessionId:n,cols:r,rows:s})},killSession:async n=>{try{(await Ne(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(s=>({sessions:s.sessions.filter(a=>a.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(s=>{const a=s.sessions.filter(l=>l.id!==r);return a.length===0&&s.isOpen?{sessions:[],isOpen:!1}:{sessions:a}});break}}}}));Ft.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&Kr.getState().handleMessage(e)});const Io={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function Mg(e){if(!e)return structuredClone(Io);try{const t=JSON.parse(e);return{terminalToggle:t.terminalToggle??structuredClone(Io.terminalToggle),quickAction:t.quickAction??structuredClone(Io.quickAction),agentSwitching:t.agentSwitching??structuredClone(Io.agentSwitching)}}catch{return structuredClone(Io)}}function LS(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function sk(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 aL(e){return e.type==="double-press"}function ik(e){return e.type==="chord"}function oL(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.code===`Key${t.toUpperCase()}`:t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function ak(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),s=t.modifiers.includes("alt"),a=t.modifiers.includes("shift");return oL(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===s&&e.shiftKey===a}function tx(){const e=tn(t=>t.settings[Me.KEYBINDINGS]);return Mg(e)}function lL(e,t,n){const r=C.useRef(0),s=C.useRef(t);s.current=t,C.useEffect(()=>{if(!e)return;const a=e.threshold??300,l=d=>{if(d.key!==e.key)return;const f=e.key==="Control",h=e.key==="Shift",p=e.key==="Alt",g=e.key==="Meta";if(!f&&d.ctrlKey||!h&&d.shiftKey||!p&&d.altKey||!g&&d.metaKey)return;const _=Date.now();_-r.current<a?(d.preventDefault(),d.stopPropagation(),s.current(),r.current=0):r.current=_};return window.addEventListener("keydown",l,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",l,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function cL(e,t){const n=C.useRef(t);n.current=t,C.useEffect(()=>{if(!e)return;const r=s=>{ak(s,e)&&(s.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function ok(e,t,n){lL(e&&aL(e)?e:void 0,t,n),cL(e&&ik(e)?e:void 0,t)}function uL(e,t,n){const r=C.useRef(n);r.current=n,C.useEffect(()=>{const s=a=>{for(let l=0;l<e.length;l++){const d=e[l];if(!d)continue;const f=t[l];if(f&&ik(d)&&ak(a,d)){a.preventDefault(),r.current(f.id);return}}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,t])}var La=IC();const Dh=C.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},s)=>c.jsx("button",{ref:s,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Dh.displayName="IconButton";const dL="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",Oi=C.forwardRef((e,t)=>c.jsx(Dh,{ref:t,icon:dL,title:"Edit",...e}));Oi.displayName="EditButton";const hL="M6 18L18 6M6 6l12 12",nx=C.forwardRef((e,t)=>c.jsx(Dh,{ref:t,icon:hL,...e}));nx.displayName="CloseButton";const fL={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[90vh] flex-1"};function Et({label:e,title:t,size:n="md",minHeight:r,children:s,footer:a,className:l,onClose:d,isOpen:f,closeOnBackdropClick:h=!0,closeOnEscape:p=!0,showCloseButton:g=!0}){const[_,x]=C.useState(!1),v=f!==void 0,S=v?f:_,w=C.useCallback(()=>{v||x(!0)},[v]),k=C.useCallback(()=>{v||x(!1),d==null||d()},[v,d]);C.useEffect(()=>{if(!S||!p)return;const T=A=>{A.key==="Escape"&&(A.stopPropagation(),k())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[S,k,p]);const j=e&&(typeof e=="string"?c.jsx("button",{type:"button",onClick:w,className:l,children:e}):c.jsx("span",{onClick:w,className:l,style:{cursor:"pointer"},children:e}));return c.jsxs(c.Fragment,{children:[j,S&&(typeof document<"u"?La.createPortal(c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:h?k:void 0}),c.jsxs("div",{className:`relative w-full ${fL[n]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||g)&&c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&c.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),g&&c.jsx(nx,{onClick:k,className:"ml-auto","aria-label":"Close"})]}),c.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:r?{minHeight:r}:void 0,children:s}),a&&c.jsx("div",{className:"px-4 py-3 border-t border-border",children:a})]})]}),document.body):null)]})}function mL({value:e,defaultUrl:t,disabled:n,onChange:r}){const s=e??t;return c.jsxs("div",{className:"relative",children:[c.jsx("select",{value:s,disabled:n,onChange:a=>{const l=a.target.value;r(l===t?null:l)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:_D.map(({url:a,label:l})=>c.jsx("option",{value:a,title:l,children:l.split(" ")[0]},a))}),c.jsx(Br,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const RS=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function pL(){const e=_a(f=>f.settings),t=_a(f=>f.update),n=_a(f=>f.updateEvent),r=_a(f=>f.updateAgentOverride),s=_a(f=>f.load);C.useEffect(()=>{s()},[s]);const a=async()=>{await yD()==="granted"&&t({...e,browserNotificationEnabled:!0})},l=(f,h,p,g)=>{f==="general"?n(h,{[p]:g}):r(f,h,{[p]:g})},d=(f,h,p)=>{f==="general"?n(h,{customSoundUrl:p}):r(f,h,{customSoundUrl:p})};return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),c.jsx(MS,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:f=>t({...e,soundEnabled:f})}),c.jsx(MS,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:f=>{f&&typeof Notification<"u"&&Notification.permission!=="granted"?a():t({...e,browserNotificationEnabled:f})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&c.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),c.jsx("div",{className:"border border-border rounded overflow-hidden",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:c.jsxs("tr",{className:"border-b border-border",children:[c.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),RS.map(f=>c.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:f.label},f.key))]})}),c.jsx("tbody",{children:gD.map(f=>c.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[c.jsx("td",{className:"px-3 py-2",children:c.jsx("div",{className:"text-text-primary text-xs",children:f.label})}),RS.map(h=>{const p=XC(e,f.key,h.key==="general"?void 0:h.key),g=KC[f.key];return c.jsx("td",{className:"px-2 py-2 align-top",children:c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:c.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:_=>l(h.key,f.key,"soundEnabled",_.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),c.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:c.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:_=>l(h.key,f.key,"browserNotification",_.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&c.jsx(mL,{value:p.customSoundUrl,defaultUrl:g,disabled:!e.soundEnabled,onChange:_=>d(h.key,f.key,_)})]})},h.key)})]},f.key))})]})})]})]})}function MS({label:e,description:t,checked:n,onChange:r}){return c.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[c.jsx("div",{className:"pt-0.5",children:c.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:s=>{s.preventDefault(),r(!n)},children:c.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})}),c.jsxs("div",{children:[c.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),c.jsx("div",{className:"text-xs text-text-muted",children:t})]})]})}const Ze=C.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...s},a)=>{const l="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},f={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return c.jsx("button",{ref:a,className:`${l} ${d[e]} ${f[t]} ${n}`,...s,children:r})});Ze.displayName="Button";async function rx(e,t,n){t({loading:!0});try{const s=await(await Ne(e)).json();t({defaults:s.defaults??[],userItems:s.userItems??[],...n?{projectItems:s.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const is=xr((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchSkills:async()=>{await rx("/api/skills",e,!0)},toggleSkill:async n=>{try{const s=await(await Ne(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(a=>({defaults:a.defaults.map(l=>l.id===n?{...l,enabled:s.enabled}:l),userItems:a.userItems.map(l=>l.id===n?{...l,enabled:s.enabled}:l)}))}catch{}},fetchSkill:async n=>{try{const r=await Ne(`/api/skills/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const s=await zi("POST","/api/skills",{...n,destination:r});return s.success&&await t().fetchSkills(),s},updateSkill:async(n,r)=>{const s=await zi("PUT",`/api/skills/${n}`,r);return s.success&&await t().fetchSkills(),s},deleteSkill:async n=>{try{const r=await Ne(`/api/skills/${n}`,{method:"DELETE"}),s=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:s.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>Th(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),r)}));function sx(){const[e,t]=C.useState({id:null,type:null}),n=C.useCallback(a=>t({id:a,type:"delete"}),[]),r=C.useCallback(()=>t({id:null,type:null}),[]),s=C.useCallback((a,l)=>e.id===a&&e.type===l,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:s}}function ix({onConfirm:e,onCancel:t}){return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),c.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function ax({onClick:e}){return c.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:c.jsx($c,{})})}function Qd({onClick:e}){return c.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:c.jsx(X_,{})})}function ka({label:e,value:t,onChange:n,placeholder:r,readOnly:s,hint:a,mono:l}){return c.jsxs("div",{children:[c.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,a&&c.jsx("span",{className:"text-text-muted ml-1",children:a})]}),c.jsx("input",{value:t,onChange:d=>n(d.target.value),readOnly:s,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${l?"font-mono":""} ${s?"opacity-60":""}`})]})}function gL({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return c.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[c.jsx(Ze,{variant:"secondary",onClick:e,children:"Cancel"}),c.jsx(Ze,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function ox({message:e}){return c.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function lk({description:e,onNew:t,loading:n,hasItems:r,children:s}){return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("p",{className:"text-text-secondary text-sm",children:e}),c.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:c.jsx(Ze,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?c.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?s:c.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function ck({label:e="Custom",children:t}){return c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),c.jsx("div",{className:"space-y-2",children:t})]})}function uk({description:e,onNew:t,newLabel:n="+ New"}){return c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("p",{className:"text-text-secondary text-sm",children:e}),c.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:c.jsx(Ze,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function dk({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:s,onDelete:a,children:l}){return c.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[c.jsx("div",{className:"min-w-0 flex-1 mr-3",children:l}),c.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&c.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:c.jsx(Ec,{})}),c.jsx(Qd,{onClick:s}),!e&&r&&c.jsx(Oi,{onClick:r}),!e&&(t?c.jsx(ix,{onConfirm:()=>{a==null||a()},onCancel:()=>{}}):c.jsx(ax,{onClick:()=>a==null?void 0:a()}))]})]})}function _L({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:s,onView:a,onEdit:l,onDuplicate:d,onDelete:f}){return c.jsxs(dk,{isBuiltIn:r,isConfirmingDelete:s,onView:a,onEdit:l,onDuplicate:d,onDelete:f,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),c.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&c.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function hk({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:s}){return e&&!t?c.jsx("div",{className:"text-text-muted text-sm",children:n}):t?c.jsx("div",{className:"space-y-4",children:s}):r?c.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function fk({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:s="My Item",idPlaceholder:a="my-item",nameHint:l,readOnlyId:d=!1,readOnlyHint:f="(read-only)",onNameChange:h,onIdChange:p}){return c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:n,value:e,onChange:h,placeholder:s,hint:l}),c.jsx(ka,{label:r,value:t,onChange:p,readOnly:d,placeholder:a,hint:d?f:void 0,mono:!0})]})}function mk(e={}){const{initialData:t={}}=e,[n,r]=C.useState("list"),[s,a]=C.useState(null),[l,d]=C.useState(""),[f,h]=C.useState(!1),[p,g]=C.useState(t),_=C.useCallback(()=>{g(t),d(""),a(null)},[t]),x=C.useCallback(k=>{r(k),k==="list"&&_()},[_]),v=C.useCallback(k=>{g(j=>typeof k=="function"?k(j):k)},[]),S=C.useCallback((k,j={})=>{a(k),r("edit"),g({...j}),d("")},[]),w=C.useCallback(()=>{a(null),r("edit"),g(t),d("")},[t]);return{view:n,editingId:s,formError:l,saving:f,formData:p,setView:x,setEditingId:a,setFormError:d,setFormData:v,setSaving:h,resetForm:_,startEditing:S,startNew:w}}function OS({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:s,onDuplicate:a,onDelete:l}){return c.jsx(_L,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:s,onDuplicate:a,onDelete:l})}function xL({isOpen:e}){const t=is(N=>N.defaults),n=is(N=>N.userItems),r=is(N=>N.projectItems),s=is(N=>N.loading),a=is(N=>N.fetchSkills),l=is(N=>N.fetchSkill),d=is(N=>N.fetchDefaultContent),f=is(N=>N.createSkill),h=is(N=>N.updateSkill),p=is(N=>N.deleteSkill),{view:g,editingId:_,formError:x,saving:v,formData:S,setView:w,setEditingId:k,setFormError:j,setFormData:T,setSaving:A}=mk(),{clearConfirm:P}=sx();C.useEffect(()=>{e&&(a(),w("list"),k(null),P())},[e,a,P]);const R=(N,F,H,se)=>{T({name:se??N.metadata.name,id:H??N.metadata.id,description:N.metadata.description??"",version:N.metadata.version??"1.0.0",prompt:N.prompt,isReadOnly:F,destination:"user"})},q=async N=>{if(t.some(H=>H.id===N)){const H=await d(N);if(!H)return;R(H,!0),k(N),j(""),w("edit")}else{const H=await l(N);if(!H)return;R(H,!0),k(N),j(""),w("edit")}},J=async N=>{const H=t.some(B=>B.id===N)?await d(N):await l(N);if(!H)return;const se=`${N}-copy-${Date.now()}`;R(H,!1,se,`${H.metadata.name} (copy)`),k(null),j(""),w("edit")},ne=()=>{T({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),w("edit")},I=async N=>{const F=await l(N);F&&(R(F,!1),k(N),j(""),w("edit"))},W=async N=>{await p(N),P()},z=async()=>{const N=_??S.id;if(!N||!S.name||!S.prompt){j("Name, ID, and prompt are required.");return}A(!0),j("");const F={metadata:{id:N,name:S.name,description:S.description,version:S.version},prompt:S.prompt},H=_?await h(_,F):await f(F,S.destination);if(A(!1),!H.success){j(H.error??"Failed to save skill.");return}w("list")},L=N=>{T(F=>({...F,name:N})),_||T(F=>({...F,id:N.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},U=S.isReadOnly;if(g==="edit")return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex justify-between items-center mb-3",children:[c.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:U?S.name:_?"Edit Skill":"New Skill"}),c.jsx("button",{onClick:()=>w("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),x&&c.jsx(ox,{message:x}),c.jsxs("div",{className:"space-y-3 mb-3",children:[c.jsx(fk,{name:S.name,id:S.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:L,onIdChange:()=>{}}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:"Description",value:S.description,onChange:N=>T(F=>({...F,description:N})),placeholder:"What this skill does...",readOnly:U}),c.jsx(ka,{label:"Version",value:S.version,onChange:N=>T(F=>({...F,version:N})),placeholder:"1.0.0",readOnly:U})]})]}),c.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),c.jsx("textarea",{value:S.prompt,onChange:N=>T(F=>({...F,prompt:N.target.value})),readOnly:U,placeholder:"The system prompt for this skill...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!_&&c.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[c.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),c.jsxs("select",{value:S.destination,onChange:N=>T(F=>({...F,destination:N.target.value})),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[c.jsx("option",{value:"user",children:"Global config"}),c.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:()=>w("list"),children:"Cancel"}),U?c.jsx(Ze,{variant:"primary",onClick:()=>{T(N=>({...N,name:N.name+" (copy)",id:`${_}-copy-${Date.now()}`,isReadOnly:!1})),k(null)},children:"Duplicate & Customize"}):c.jsx(Ze,{variant:"primary",onClick:z,disabled:v||!S.name||!S.id||!S.prompt,children:v?"Saving...":"Save"})]})]});function D({items:N}){return N.map(F=>c.jsx(OS,{skill:F,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>q(F.id),onEdit:()=>I(F.id),onDuplicate:()=>J(F.id),onDelete:()=>W(F.id)},F.id))}return c.jsxs("div",{children:[c.jsx(uk,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:ne}),c.jsxs(hk,{loading:s,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),c.jsx("div",{className:"space-y-2",children:t.map(N=>c.jsx(OS,{skill:N,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>q(N.id),onDuplicate:()=>J(N.id)},N.id))})]}),n.length>0&&c.jsx(ck,{children:c.jsx(D,{items:n})}),r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),c.jsx("div",{className:"space-y-2",children:c.jsx(D,{items:r})})]})]})]})}function Lh(){const e=tn(s=>s.settings),t=tn(s=>s.loading),n=tn(s=>s.getSetting),r=tn(s=>s.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function yL({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:s}=Lh(),a=t[Me.GLOBAL_INSTRUCTIONS]??"",l=n[Me.GLOBAL_INSTRUCTIONS]??!1,[d,f]=C.useState(a),[h,p]=C.useState(!1),[g,_]=C.useState(!1);C.useEffect(()=>{e&&r(Me.GLOBAL_INSTRUCTIONS)},[e,r]),C.useEffect(()=>{f(a),p(!1)},[a]);const x=async()=>{_(!0),await s(Me.GLOBAL_INSTRUCTIONS,d),_(!1),p(!1)},v=()=>{f(a),p(!1)},S=l||g;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),c.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),c.jsx("textarea",{value:d,onChange:w=>{f(w.target.value),p(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:S})]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",onClick:v,disabled:!h,children:"Discard"}),c.jsx(Ze,{variant:"primary",onClick:x,disabled:!h||S,children:g?"Saving...":"Save"})]})]})}function vL(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),s=parseInt(t[3]??"0",16);return`${n} ${r} ${s}`}return e}function ma(e){const t=e.split(" ").map(n=>parseInt(n,10));return t.length===3&&t.every(n=>!isNaN(n))?`#${t.map(n=>(n??0).toString(16).padStart(2,"0")).join("")}`:e}function bL({isOpen:e,isNew:t,basePresetId:n,presetName:r,initialTokens:s,onClose:a,onSave:l}){const[d,f]=C.useState(s),[h,p]=C.useState(r);C.useEffect(()=>{f(s),p(r)},[s,r]);const g=(w,k)=>{const j=k.startsWith("#")?vL(k):k;f(T=>({...T,[w]:j}))},_=()=>{l(h.trim()||"Untitled",{...d})},x=JC.reduce((w,k)=>{const j=k.category;return w[j]||(w[j]=[]),w[j].push(k),w},{}),v={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},S=fs.find(w=>w.id===n);return c.jsx(Et,{isOpen:e,onClose:a,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:c.jsxs("div",{className:"flex gap-2 justify-end",children:[c.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),c.jsx("button",{type:"button",onClick:_,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),c.jsx("input",{type:"text",value:h,onChange:w=>p(w.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!t&&c.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",c.jsx("span",{className:"text-text-primary",children:S==null?void 0:S.name})]}),Object.entries(x).map(([w,k])=>c.jsxs("div",{className:"space-y-3",children:[c.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:v[w]??w}),c.jsx("div",{className:"grid grid-cols-2 gap-3",children:k.map(j=>c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{htmlFor:j.key,className:"text-xs text-text-muted",children:j.label}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"color",id:j.key,value:ma(d[j.key]??j.defaultValue),onChange:T=>g(j.key,T.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent"}),c.jsx("input",{type:"text",value:d[j.key]??j.defaultValue,onChange:T=>g(j.key,T.target.value),className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},j.key))})]},w))]})})}function SL(){const[e,t]=C.useState(null),n=Gt(A=>A.currentPreset),r=Gt(A=>A.isCustom),s=Gt(A=>A.basePreset),a=Gt(A=>A.userPresets),l=Gt(A=>A.applyPreset),d=Gt(A=>A.applyUserPreset),f=Gt(A=>A.deleteUserPreset),h=Gt(A=>A.saveTheme),p=Gt(A=>A.followSystemTheme),g=Gt(A=>A.setFollowSystemTheme),_=A=>{l(A),h(JSON.stringify({preset:A})).catch(()=>{})},x=A=>{d(A)},v=A=>{const P=fs.find(R=>R.id===A);P&&t({type:"new",presetIndex:a.length,basePresetId:A,presetName:P.name+" Copy",tokens:{...P.tokens}})},S=A=>{const P=a[A];if(!P)return;const R=fs.find(J=>J.id===P.basePreset),q=R?{...R.tokens,...P.tokens}:P.tokens;t({type:"edit",presetIndex:A,basePresetId:P.basePreset,presetName:P.name,tokens:q})},w=(A,P)=>{if(!e)return;const R=[...a];if(e.type==="new"){const q={id:"custom-"+Date.now(),name:A,basePreset:e.basePresetId,tokens:P};R.push(q);const J=R.length-1;Gt.setState({userPresets:R}),Gt.getState().saveUserPresets(),Gt.getState().applyUserPreset(J)}else{const q=R[e.presetIndex];q&&(R[e.presetIndex]={...q,name:A,tokens:P}),Gt.setState({userPresets:R}),Gt.getState().saveUserPresets(),Gt.getState().applyUserPreset(e.presetIndex)}t(null)},k=()=>{t(null)},j=(A,P)=>{A.stopPropagation(),f(P)},T=r?s:n;return c.jsxs("div",{className:"space-y-4",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("button",{type:"button",role:"switch","aria-checked":p,onClick:()=>g(!p),className:`relative w-10 h-5 rounded-full transition-colors ${p?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,children:c.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${p?"translate-x-5":"translate-x-0"}`})}),c.jsx("span",{className:"text-sm text-text-secondary",children:"Follow system theme"})]}),c.jsx("div",{className:"grid grid-cols-5 gap-2",children:fs.map(A=>c.jsxs("div",{className:"relative group",children:[c.jsxs("button",{type:"button",onClick:()=>_(A.id),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${T===A.id&&!r?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[c.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:ma(A.tokens["color-bg-primary"]??"#000"),borderColor:ma(A.tokens["color-border"]??"#000")},children:c.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ma(A.tokens["color-text-primary"]??"#fff")}})}),c.jsx("span",{className:"text-xs",children:A.name})]}),c.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),v(A.id)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:c.jsx("span",{className:"text-xs",children:"✎"})})]},A.id))}),a.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),c.jsx("div",{className:"grid grid-cols-5 gap-2",children:a.map((A,P)=>{const R=fs.find(J=>J.id===A.basePreset),q=R?{...R.tokens,...A.tokens}:A.tokens;return c.jsxs("div",{className:"relative group",children:[c.jsxs("button",{type:"button",onClick:()=>x(P),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${r&&s===A.basePreset&&T===A.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[c.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:ma(q["color-bg-primary"]??"#000"),borderColor:ma(q["color-border"]??"#000")},children:c.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ma(q["color-text-primary"]??"#fff")}})}),c.jsx("span",{className:"text-xs truncate w-full text-center",children:A.name})]}),c.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),S(P)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:c.jsx("span",{className:"text-xs",children:"✎"})}),c.jsx("button",{type:"button",onClick:J=>j(J,P),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:c.jsx(Hc,{className:"w-3 h-3"})})]},A.id)})})]}),e&&c.jsx(bL,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:k,onSave:w})]})}function wL(){return c.jsx(SL,{})}function CL(){const{settings:e,loading:t,getSetting:n,setSetting:r}=Lh(),s=t[Me.DISPLAY_SHOW_THINKING]??!1,a=[{key:Me.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Me.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Me.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Me.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Me.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:Me.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but very slow - does not affect red/green diff coloring"}],l=Object.fromEntries(a.map(p=>[p.key,e[p.key]??"true"])),[d,f]=C.useState(()=>Object.fromEntries(a.map(p=>[p.key,l[p.key]==="true"])));C.useEffect(()=>{a.forEach(p=>n(p.key))},[n]),C.useEffect(()=>{f(Object.fromEntries(a.map(p=>[p.key,l[p.key]==="true"])))},[JSON.stringify(l)]);const h=async p=>{const g=String(!d[p]);f(_=>({..._,[p]:!_[p]})),await r(p,g)};return s?c.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):c.jsxs("div",{className:"space-y-6",children:[c.jsx(wL,{}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),c.jsx("div",{className:"space-y-4",children:a.map(({key:p,label:g,description:_})=>c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm text-text-primary",children:g}),c.jsx("div",{className:"text-xs text-text-muted",children:_})]}),c.jsx("button",{type:"button",onClick:()=>h(p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d[p]?"bg-accent-primary":"bg-bg-tertiary"}`,children:c.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d[p]?"translate-x-6":"translate-x-1"}`})})]},p))})]})]})}function kL({label:e,binding:t,isRecording:n,onStartRecording:r,onBindingRecorded:s,onCancelRecording:a}){const l=C.useRef(null),d=C.useRef(0),f=C.useRef("");return C.useEffect(()=>{if(!n)return;const h=new Set(["Control","Shift","Alt","Meta"]);let p=[];const g=x=>{if(x.preventDefault(),x.stopPropagation(),x.key==="Escape"){a();return}if(h.has(x.key)){x.ctrlKey&&!p.includes("ctrl")&&p.push("ctrl"),x.metaKey&&!p.includes("meta")&&p.push("meta"),x.altKey&&!p.includes("alt")&&p.push("alt"),x.shiftKey&&!p.includes("shift")&&p.push("shift");return}if(p.length>0||x.ctrlKey||x.metaKey||x.altKey||x.shiftKey){const w=[...p];x.ctrlKey&&!w.includes("ctrl")&&w.push("ctrl"),x.metaKey&&!w.includes("meta")&&w.push("meta"),x.altKey&&!w.includes("alt")&&w.push("alt"),x.shiftKey&&!w.includes("shift")&&w.push("shift"),s({type:"chord",key:LS(x),modifiers:w});return}const v=Date.now(),S=LS(x);if(S===f.current&&v-d.current<400){s({type:"double-press",key:S,threshold:300});return}d.current=v,f.current=S},_=x=>{x.key==="Control"&&(p=p.filter(v=>v!=="ctrl")),x.key==="Shift"&&(p=p.filter(v=>v!=="shift")),x.key==="Alt"&&(p=p.filter(v=>v!=="alt")),x.key==="Meta"&&(p=p.filter(v=>v!=="meta"))};return window.addEventListener("keydown",g,!0),window.addEventListener("keyup",_,!0),()=>{window.removeEventListener("keydown",g,!0),window.removeEventListener("keyup",_,!0)}},[n,s,a]),c.jsxs("div",{ref:l,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${n?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[c.jsx("span",{className:"text-sm text-text-primary",children:e}),c.jsx("div",{className:"flex items-center gap-2",children:n?c.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):c.jsx("button",{type:"button",onClick:r,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:sk(t)})})]})}function EL(){const{settings:e,loading:t,getSetting:n,setSetting:r}=Lh(),s=e[Me.KEYBINDINGS],a=t[Me.KEYBINDINGS]??!1,l=Mg(s),[d,f]=C.useState(null);C.useEffect(()=>{n(Me.KEYBINDINGS)},[n]);const h=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction},...l.agentSwitching.map((x,v)=>({id:`agentSwitching.${v}`,label:`Switch to Agent ${v+1}`,binding:x}))],p=x=>{f(x)},g=C.useCallback(x=>{if(!d)return;const v=Mg(s),S=structuredClone(v);if(d.startsWith("agentSwitching.")){const w=parseInt(d.split(".")[1],10);S.agentSwitching[w]=x}else d==="terminalToggle"?S.terminalToggle=x:d==="quickAction"&&(S.quickAction=x);f(null),r(Me.KEYBINDINGS,JSON.stringify(S))},[d,s,r]),_=()=>{r(Me.KEYBINDINGS,JSON.stringify(Io))};return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),c.jsx("button",{type:"button",onClick:_,disabled:a,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),a?c.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):c.jsx("div",{className:"space-y-1",children:h.map(x=>c.jsx(kL,{label:x.label,binding:x.binding,isRecording:d===x.id,onStartRecording:()=>p(x.id),onBindingRecorded:g,onCancelRecording:()=>f(null)},x.id))})]})}function Dp({enabled:e,onClick:t}){return c.jsx("button",{type:"button",onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"}`,children:c.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function NL({onClose:e}){const[,t]=Jr(),{settings:n,loading:r,getSetting:s,setSetting:a}=Lh(),l=n[Me.LLM_DISABLE_XML_PROTECTION]==="true",d=n[Me.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",f=n[Me.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",h=r[Me.LLM_DISABLE_XML_PROTECTION]??!1,[p,g]=C.useState({xmlProtection:l,openInEditor:d,dynamicPrompt:f});C.useEffect(()=>{g({xmlProtection:l,openInEditor:d,dynamicPrompt:f})},[l,d,f]),C.useEffect(()=>{s(Me.LLM_DISABLE_XML_PROTECTION),s(Me.DISPLAY_SHOW_OPEN_IN_EDITOR),s(Me.LLM_DYNAMIC_SYSTEM_PROMPT)},[s]);const _=()=>{const w=!p.xmlProtection;g(k=>({...k,xmlProtection:w})),a(Me.LLM_DISABLE_XML_PROTECTION,String(w))},x=()=>{const w=!p.openInEditor;g(k=>({...k,openInEditor:w})),a(Me.DISPLAY_SHOW_OPEN_IN_EDITOR,String(w))},v=()=>{const w=!p.dynamicPrompt;g(k=>({...k,dynamicPrompt:w})),a(Me.LLM_DYNAMIC_SYSTEM_PROMPT,String(w))};function S(){e(),t("/onboarding")}return h?c.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{children:c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{className:"flex-1 min-w-0 mr-3",children:[c.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Dynamic System Prompt"}),c.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Rebuild the system prompt on every turn. When disabled, changes are applied on demand via the context header for better cache performance."})]}),c.jsx(Dp,{enabled:p.dynamicPrompt,onClick:v})]})}),c.jsx("hr",{className:"border-border"}),c.jsx("div",{children:c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Disable XML Tool Call Protection"}),c.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Allow the model to output XML tool call format instead of JSON function calls. Some third-party providers may require this."})]}),c.jsx(Dp,{enabled:p.xmlProtection,onClick:_})]})}),c.jsx("hr",{className:"border-border"}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Integrations"}),c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm text-text-primary",children:'Show "Open in VSCode" links'}),c.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Display a link on file reads to open the file directly in VS Code."})]}),c.jsx(Dp,{enabled:p.openInEditor,onClick:x})]})]}),c.jsx("hr",{className:"border-border"}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),c.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),c.jsx(Ze,{variant:"secondary",onClick:S,children:"Launch Onboarding"})]})]})}function ko({label:e,active:t,onClick:n}){return c.jsx("button",{onClick:n,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function jL({isOpen:e,onClose:t}){const[n,r]=C.useState("instructions"),s=()=>{try{Ft.send("context.checkDynamic",{})}catch{}t()};return c.jsx(Et,{isOpen:e,onClose:s,title:"Settings",size:"xl",minHeight:"500px",children:c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[c.jsx(ko,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),c.jsx(ko,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),c.jsx(ko,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),c.jsx(ko,{label:"Display",active:n==="display",onClick:()=>r("display")}),c.jsx(ko,{label:"Shortcuts",active:n==="keybindings",onClick:()=>r("keybindings")}),c.jsx(ko,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced")})]}),n==="instructions"&&c.jsx(yL,{isOpen:e}),n==="skills"&&c.jsx(xL,{isOpen:e}),n==="notifications"&&c.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:c.jsx(pL,{})}),n==="display"&&c.jsx(CL,{}),n==="keybindings"&&c.jsx(EL,{}),n==="advanced"&&c.jsx(NL,{onClose:t})]})})}/**
59
- * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
60
- * @license MIT
61
- *
62
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
63
- * @license MIT
64
- *
65
- * Originally forked from (with the author's permission):
66
- * Fabrice Bellard's javascript vt100 for jslinux:
67
- * http://bellard.org/jslinux/
68
- * Copyright (c) 2011 Fabrice Bellard
69
- */var pk=Object.defineProperty,TL=Object.getOwnPropertyDescriptor,AL=(e,t)=>{for(var n in t)pk(e,n,{get:t[n],enumerable:!0})},Kt=(e,t,n,r)=>{for(var s=r>1?void 0:r?TL(t,n):t,a=e.length-1,l;a>=0;a--)(l=e[a])&&(s=(r?l(t,n,s):l(s))||s);return r&&s&&pk(t,n,s),s},je=(e,t)=>(n,r)=>t(n,r,e),IS="Terminal input",Og={get:()=>IS,set:e=>IS=e},PS="Too much output to announce, navigate to rows manually to read",Ig={get:()=>PS,set:e=>PS=e};function DL(e){return e.replace(/\r?\n/g,"\r")}function LL(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function RL(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function ML(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let s=e.clipboardData.getData("text/plain");gk(s,t,n,r)}}function gk(e,t,n,r){e=DL(e),e=LL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function _k(e,t,n){let r=n.getBoundingClientRect(),s=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${s}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function BS(e,t,n,r,s){_k(e,t,n),s&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ti(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Rh(e,t=0,n=e.length){let r="";for(let s=t;s<n;++s){let a=e[s];a>65535?(a-=65536,r+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):r+=String.fromCharCode(a)}return r}var OL=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,s=0;if(this._interim){let a=e.charCodeAt(s++);56320<=a&&a<=57343?t[r++]=(this._interim-55296)*1024+a-56320+65536:(t[r++]=this._interim,t[r++]=a),this._interim=0}for(let a=s;a<n;++a){let l=e.charCodeAt(a);if(55296<=l&&l<=56319){if(++a>=n)return this._interim=l,r;let d=e.charCodeAt(a);56320<=d&&d<=57343?t[r++]=(l-55296)*1024+d-56320+65536:(t[r++]=l,t[r++]=d);continue}l!==65279&&(t[r++]=l)}return r}},IL=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,n){let r=t.length;if(!r)return 0;let s=0,a,l,d,f,h=0,p=0;if(this.interim[0]){let x=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let S=0,w;for(;(w=this.interim[++S]&63)&&S<4;)v<<=6,v|=w;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,j=k-S;for(;p<j;){if(p>=r)return 0;if(w=t[p++],(w&192)!==128){p--,x=!0;break}else this.interim[S++]=w,v<<=6,v|=w&63}x||(k===2?v<128?p--:n[s++]=v:k===3?v<2048||v>=55296&&v<=57343||v===65279||(n[s++]=v):v<65536||v>1114111||(n[s++]=v)),this.interim.fill(0)}let g=r-4,_=p;for(;_<r;){for(;_<g&&!((a=t[_])&128)&&!((l=t[_+1])&128)&&!((d=t[_+2])&128)&&!((f=t[_+3])&128);)n[s++]=a,n[s++]=l,n[s++]=d,n[s++]=f,_+=4;if(a=t[_++],a<128)n[s++]=a;else if((a&224)===192){if(_>=r)return this.interim[0]=a,s;if(l=t[_++],(l&192)!==128){_--;continue}if(h=(a&31)<<6|l&63,h<128){_--;continue}n[s++]=h}else if((a&240)===224){if(_>=r)return this.interim[0]=a,s;if(l=t[_++],(l&192)!==128){_--;continue}if(_>=r)return this.interim[0]=a,this.interim[1]=l,s;if(d=t[_++],(d&192)!==128){_--;continue}if(h=(a&15)<<12|(l&63)<<6|d&63,h<2048||h>=55296&&h<=57343||h===65279)continue;n[s++]=h}else if((a&248)===240){if(_>=r)return this.interim[0]=a,s;if(l=t[_++],(l&192)!==128){_--;continue}if(_>=r)return this.interim[0]=a,this.interim[1]=l,s;if(d=t[_++],(d&192)!==128){_--;continue}if(_>=r)return this.interim[0]=a,this.interim[1]=l,this.interim[2]=d,s;if(f=t[_++],(f&192)!==128){_--;continue}if(h=(a&7)<<18|(l&63)<<12|(d&63)<<6|f&63,h<65536||h>1114111)continue;n[s++]=h}}return s}},xk="",Mi=" ",Fc=class yk{constructor(){this.fg=0,this.bg=0,this.extended=new Jd}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new yk;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Jd=class vk{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new vk(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Pr=class bk extends Fc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Jd,this.combinedData=""}static fromCharData(t){let n=new bk;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ti(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let s=t[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(r-55296)*1024+s-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},zS="di$target",Pg="di$dependencies",Lp=new Map;function PL(e){return e[Pg]||[]}function Nn(e){if(Lp.has(e))return Lp.get(e);let t=function(n,r,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");BL(t,n,s)};return t._id=e,Lp.set(e,t),t}function BL(e,t,n){t[zS]===t?t[Pg].push({id:e,index:n}):(t[Pg]=[{id:e,index:n}],t[zS]=t)}var Gn=Nn("BufferService"),Sk=Nn("CoreMouseService"),Ra=Nn("CoreService"),zL=Nn("CharsetService"),lx=Nn("InstantiationService"),wk=Nn("LogService"),qn=Nn("OptionsService"),Ck=Nn("OscLinkService"),$L=Nn("UnicodeService"),Uc=Nn("DecorationService"),Bg=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var p;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],s=this._optionsService.rawOptions.linkHandler,a=new Pr,l=n.getTrimmedLength(),d=-1,f=-1,h=!1;for(let g=0;g<l;g++)if(!(f===-1&&!n.hasContent(g))){if(n.loadCell(g,a),a.hasExtendedAttrs()&&a.extended.urlId)if(f===-1){f=g,d=a.extended.urlId;continue}else h=a.extended.urlId!==d;else f!==-1&&(h=!0);if(h||f!==-1&&g===l-1){let _=(p=this._oscLinkService.getLinkData(d))==null?void 0:p.uri;if(_){let x={start:{x:f+1,y:e},end:{x:g+(!h&&g===l-1?1:0),y:e}},v=!1;if(!(s!=null&&s.allowNonHttpProtocols))try{let S=new URL(_);["http:","https:"].includes(S.protocol)||(v=!0)}catch{v=!0}v||r.push({text:_,range:x,activate:(S,w)=>s?s.activate(S,w,x):HL(S,w),hover:(S,w)=>{var k;return(k=s==null?void 0:s.hover)==null?void 0:k.call(s,S,w,x)},leave:(S,w)=>{var k;return(k=s==null?void 0:s.leave)==null?void 0:k.call(s,S,w,x)}})}h=!1,a.hasExtendedAttrs()&&a.extended.urlId?(f=g,d=a.extended.urlId):(f=-1,d=-1)}}t(r)}};Bg=Kt([je(0,Gn),je(1,qn),je(2,Ck)],Bg);function HL(e,t){if(confirm(`Do you want to navigate to ${t}?
70
-
71
- WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Mh=Nn("CharSizeService"),Ys=Nn("CoreBrowserService"),cx=Nn("MouseService"),Xs=Nn("RenderService"),FL=Nn("SelectionService"),kk=Nn("CharacterJoinerService"),Yo=Nn("ThemeService"),Ek=Nn("LinkProviderService"),UL=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$S.isErrorNoTelemetry(e)?new $S(e.message+`
72
-
73
- `+e.stack):new Error(e.message+`
74
-
75
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},VL=new UL;function Hd(e){WL(e)||VL.onUnexpectedError(e)}var zg="Canceled";function WL(e){return e instanceof GL?!0:e instanceof Error&&e.name===zg&&e.message===zg}var GL=class extends Error{constructor(){super(zg),this.name=this.message}};function qL(e){return new Error(`Illegal argument: ${e}`)}var $S=class $g extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof $g)return t;let n=new $g;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Hg=class Nk extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Nk.prototype)}};function fr(e,t=0){return e[e.length-(1+t)]}var KL;(e=>{function t(a){return a<0}e.isLessThan=t;function n(a){return a<=0}e.isLessThanOrEqual=n;function r(a){return a>0}e.isGreaterThan=r;function s(a){return a===0}e.isNeitherLessOrGreaterThan=s,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(KL||(KL={}));function YL(e,t){let n=this,r=!1,s;return function(){return r||(r=!0,t||(s=e.apply(n,arguments))),s}}var jk;(e=>{function t(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*s(A){yield A}e.single=s;function a(A){return t(A)?A:s(A)}e.wrap=a;function l(A){return A||n}e.from=l;function*d(A){for(let P=A.length-1;P>=0;P--)yield A[P]}e.reverse=d;function f(A){return!A||A[Symbol.iterator]().next().done===!0}e.isEmpty=f;function h(A){return A[Symbol.iterator]().next().value}e.first=h;function p(A,P){let R=0;for(let q of A)if(P(q,R++))return!0;return!1}e.some=p;function g(A,P){for(let R of A)if(P(R))return R}e.find=g;function*_(A,P){for(let R of A)P(R)&&(yield R)}e.filter=_;function*x(A,P){let R=0;for(let q of A)yield P(q,R++)}e.map=x;function*v(A,P){let R=0;for(let q of A)yield*P(q,R++)}e.flatMap=v;function*S(...A){for(let P of A)yield*P}e.concat=S;function w(A,P,R){let q=R;for(let J of A)q=P(q,J);return q}e.reduce=w;function*k(A,P,R=A.length){for(P<0&&(P+=A.length),R<0?R+=A.length:R>A.length&&(R=A.length);P<R;P++)yield A[P]}e.slice=k;function j(A,P=Number.POSITIVE_INFINITY){let R=[];if(P===0)return[R,A];let q=A[Symbol.iterator]();for(let J=0;J<P;J++){let ne=q.next();if(ne.done)return[R,e.empty()];R.push(ne.value)}return[R,{[Symbol.iterator](){return q}}]}e.consume=j;async function T(A){let P=[];for await(let R of A)P.push(R);return Promise.resolve(P)}e.asyncToArray=T})(jk||(jk={}));function ja(e){if(jk.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function XL(...e){return Bt(()=>ja(e))}function Bt(e){return{dispose:YL(()=>{e()})}}var Tk=class Ak{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ja(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ak.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Tk.DISABLE_DISPOSED_WARNING=!1;var Ii=Tk,et=class{constructor(){this._store=new Ii,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};et.None=Object.freeze({dispose(){}});var Vo=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Gs=typeof window=="object"?window:globalThis,Fg=class Ug{constructor(t){this.element=t,this.next=Ug.Undefined,this.prev=Ug.Undefined}};Fg.Undefined=new Fg(void 0);var $t=Fg,HS=class{constructor(){this._first=$t.Undefined,this._last=$t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===$t.Undefined}clear(){let e=this._first;for(;e!==$t.Undefined;){let t=e.next;e.prev=$t.Undefined,e.next=$t.Undefined,e=t}this._first=$t.Undefined,this._last=$t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new $t(e);if(this._first===$t.Undefined)this._first=n,this._last=n;else if(t){let s=this._last;this._last=n,n.prev=s,s.next=n}else{let s=this._first;this._first=n,n.next=s,s.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==$t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==$t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==$t.Undefined&&e.next!==$t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===$t.Undefined&&e.next===$t.Undefined?(this._first=$t.Undefined,this._last=$t.Undefined):e.next===$t.Undefined?(this._last=this._last.prev,this._last.next=$t.Undefined):e.prev===$t.Undefined&&(this._first=this._first.next,this._first.prev=$t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==$t.Undefined;)yield e.element,e=e.next}},QL=globalThis.performance&&typeof globalThis.performance.now=="function",JL=class Dk{static create(t){return new Dk(t)}constructor(t){this._now=QL&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Mn;(e=>{e.None=()=>et.None;function t(z,L){return g(z,()=>{},0,void 0,!0,void 0,L)}e.defer=t;function n(z){return(L,U=null,D)=>{let N=!1,F;return F=z(H=>{if(!N)return F?F.dispose():N=!0,L.call(U,H)},null,D),N&&F.dispose(),F}}e.once=n;function r(z,L,U){return h((D,N=null,F)=>z(H=>D.call(N,L(H)),null,F),U)}e.map=r;function s(z,L,U){return h((D,N=null,F)=>z(H=>{L(H),D.call(N,H)},null,F),U)}e.forEach=s;function a(z,L,U){return h((D,N=null,F)=>z(H=>L(H)&&D.call(N,H),null,F),U)}e.filter=a;function l(z){return z}e.signal=l;function d(...z){return(L,U=null,D)=>{let N=XL(...z.map(F=>F(H=>L.call(U,H))));return p(N,D)}}e.any=d;function f(z,L,U,D){let N=U;return r(z,F=>(N=L(N,F),N),D)}e.reduce=f;function h(z,L){let U,D={onWillAddFirstListener(){U=z(N.fire,N)},onDidRemoveLastListener(){U==null||U.dispose()}},N=new we(D);return L==null||L.add(N),N.event}function p(z,L){return L instanceof Array?L.push(z):L&&L.add(z),z}function g(z,L,U=100,D=!1,N=!1,F,H){let se,B,V,K=0,O,Q={leakWarningThreshold:F,onWillAddFirstListener(){se=z(Z=>{K++,B=L(B,Z),D&&!V&&(G.fire(B),B=void 0),O=()=>{let te=B;B=void 0,V=void 0,(!D||K>1)&&G.fire(te),K=0},typeof U=="number"?(clearTimeout(V),V=setTimeout(O,U)):V===void 0&&(V=0,queueMicrotask(O))})},onWillRemoveListener(){N&&K>0&&(O==null||O())},onDidRemoveLastListener(){O=void 0,se.dispose()}},G=new we(Q);return H==null||H.add(G),G.event}e.debounce=g;function _(z,L=0,U){return e.debounce(z,(D,N)=>D?(D.push(N),D):[N],L,void 0,!0,void 0,U)}e.accumulate=_;function x(z,L=(D,N)=>D===N,U){let D=!0,N;return a(z,F=>{let H=D||!L(F,N);return D=!1,N=F,H},U)}e.latch=x;function v(z,L,U){return[e.filter(z,L,U),e.filter(z,D=>!L(D),U)]}e.split=v;function S(z,L=!1,U=[],D){let N=U.slice(),F=z(B=>{N?N.push(B):se.fire(B)});D&&D.add(F);let H=()=>{N==null||N.forEach(B=>se.fire(B)),N=null},se=new we({onWillAddFirstListener(){F||(F=z(B=>se.fire(B)),D&&D.add(F))},onDidAddFirstListener(){N&&(L?setTimeout(H):H())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return D&&D.add(se),se.event}e.buffer=S;function w(z,L){return(U,D,N)=>{let F=L(new j);return z(function(H){let se=F.evaluate(H);se!==k&&U.call(D,se)},void 0,N)}}e.chain=w;let k=Symbol("HaltChainable");class j{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(U=>(L(U),U)),this}filter(L){return this.steps.push(U=>L(U)?U:k),this}reduce(L,U){let D=U;return this.steps.push(N=>(D=L(D,N),D)),this}latch(L=(U,D)=>U===D){let U=!0,D;return this.steps.push(N=>{let F=U||!L(N,D);return U=!1,D=N,F?N:k}),this}evaluate(L){for(let U of this.steps)if(L=U(L),L===k)break;return L}}function T(z,L,U=D=>D){let D=(...se)=>H.fire(U(...se)),N=()=>z.on(L,D),F=()=>z.removeListener(L,D),H=new we({onWillAddFirstListener:N,onDidRemoveLastListener:F});return H.event}e.fromNodeEventEmitter=T;function A(z,L,U=D=>D){let D=(...se)=>H.fire(U(...se)),N=()=>z.addEventListener(L,D),F=()=>z.removeEventListener(L,D),H=new we({onWillAddFirstListener:N,onDidRemoveLastListener:F});return H.event}e.fromDOMEventEmitter=A;function P(z){return new Promise(L=>n(z)(L))}e.toPromise=P;function R(z){let L=new we;return z.then(U=>{L.fire(U)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}e.fromPromise=R;function q(z,L){return z(U=>L.fire(U))}e.forward=q;function J(z,L,U){return L(U),z(D=>L(D))}e.runAndSubscribe=J;class ne{constructor(L,U){this._observable=L,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new we(D),U&&U.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,U){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function I(z,L){return new ne(z,L).emitter.event}e.fromObservable=I;function W(z){return(L,U,D)=>{let N=0,F=!1,H={beginUpdate(){N++},endUpdate(){N--,N===0&&(z.reportChanges(),F&&(F=!1,L.call(U)))},handlePossibleChange(){},handleChange(){F=!0}};z.addObserver(H),z.reportChanges();let se={dispose(){z.removeObserver(H)}};return D instanceof Ii?D.add(se):Array.isArray(D)&&D.push(se),se}}e.fromObservableLight=W})(Mn||(Mn={}));var Vg=class Wg{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Wg._idPool++}`,Wg.all.add(this)}start(t){this._stopWatch=new JL,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Vg.all=new Set,Vg._idPool=0;var ZL=Vg,eR=-1,Lk=class Rk{constructor(t,n,r=(Rk._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[a,l]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${l}):`;console.warn(d),console.warn(a);let f=new rR(d,a);this._errorHandler(f)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,s]of this._stacks)(!t||n<s)&&(t=[r,s],n=s);return t}};Lk._idPool=1;var tR=Lk,nR=class Mk{constructor(t){this.value=t}static create(){let t=new Error;return new Mk(t.stack??"")}print(){console.warn(this.value.split(`
76
- `).slice(2).join(`
77
- `))}},rR=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},sR=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},iR=0,Rp=class{constructor(e){this.value=e,this.id=iR++}},aR=2,oR,we=class{constructor(t){var n,r,s,a;this._size=0,this._options=t,this._leakageMon=(n=this._options)!=null&&n.leakWarningThreshold?new tR((t==null?void 0:t.onListenerError)??Hd,((r=this._options)==null?void 0:r.leakWarningThreshold)??eR):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new ZL(this._options._profName):void 0,this._deliveryQueue=(a=this._options)==null?void 0:a.deliveryQueue}dispose(){var t,n,r,s;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(r=(n=this._options)==null?void 0:n.onDidRemoveLastListener)==null||r.call(n),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(t,n,r)=>{var d,f,h,p,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let _=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(_);let x=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new sR(`${_}. HINT: Stack shows most frequent listener (${x[1]}-times)`,x[0]);return(((d=this._options)==null?void 0:d.onListenerError)||Hd)(v),et.None}if(this._disposed)return et.None;n&&(t=t.bind(n));let s=new Rp(t),a;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=nR.create(),a=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Rp?(this._deliveryQueue??(this._deliveryQueue=new lR),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(f=this._options)==null?void 0:f.onWillAddFirstListener)==null||h.call(f,this),this._listeners=s,(g=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||g.call(p,this)),this._size++;let l=Bt(()=>{a==null||a(),this._removeListener(s)});return r instanceof Ii?r.add(l):Array.isArray(r)&&r.push(l),l}),this._event}_removeListener(t){var a,l,d,f;if((l=(a=this._options)==null?void 0:a.onWillRemoveListener)==null||l.call(a,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(f=(d=this._options)==null?void 0:d.onDidRemoveLastListener)==null||f.call(d,this),this._size=0;return}let n=this._listeners,r=n.indexOf(t);if(r===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[r]=void 0;let s=this._deliveryQueue.current===this;if(this._size*aR<=n.length){let h=0;for(let p=0;p<n.length;p++)n[p]?n[h++]=n[p]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=h}}_deliver(t,n){var s;if(!t)return;let r=((s=this._options)==null?void 0:s.onListenerError)||Hd;if(!r){t.value(n);return}try{t.value(n)}catch(a){r(a)}}_deliverQueue(t){let n=t.current._listeners;for(;t.i<t.end;)this._deliver(n[t.i++],t.value);t.reset()}fire(t){var n,r,s,a;if((n=this._deliveryQueue)!=null&&n.current&&(this._deliverQueue(this._deliveryQueue),(r=this._perfMon)==null||r.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Rp)this._deliver(this._listeners,t);else{let l=this._deliveryQueue;l.enqueue(this,t,this._listeners.length),this._deliverQueue(l)}(a=this._perfMon)==null||a.stop()}hasListeners(){return this._size>0}},lR=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Gg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Gg.INSTANCE=new Gg;var ux=Gg;function cR(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}ux.INSTANCE.onDidChangeZoomLevel;function uR(e){return ux.INSTANCE.getZoomFactor(e)}ux.INSTANCE.onDidChangeFullscreen;var Xo=typeof navigator=="object"?navigator.userAgent:"",qg=Xo.indexOf("Firefox")>=0,dR=Xo.indexOf("AppleWebKit")>=0,dx=Xo.indexOf("Chrome")>=0,hR=!dx&&Xo.indexOf("Safari")>=0;Xo.indexOf("Electron/")>=0;Xo.indexOf("Android")>=0;var Mp=!1;if(typeof Gs.matchMedia=="function"){let e=Gs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Gs.matchMedia("(display-mode: fullscreen)");Mp=e.matches,cR(Gs,e,({matches:n})=>{Mp&&t.matches||(Mp=n)})}var $o="en",Kg=!1,Yg=!1,Fd=!1,Ok=!1,xd,Ud=$o,FS=$o,fR,qr,Ea=globalThis,Rn,RC;typeof Ea.vscode<"u"&&typeof Ea.vscode.process<"u"?Rn=Ea.vscode.process:typeof process<"u"&&typeof((RC=process==null?void 0:process.versions)==null?void 0:RC.node)=="string"&&(Rn=process);var MC,mR=typeof((MC=Rn==null?void 0:Rn.versions)==null?void 0:MC.electron)=="string",pR=mR&&(Rn==null?void 0:Rn.type)==="renderer",OC;if(typeof Rn=="object"){Kg=Rn.platform==="win32",Yg=Rn.platform==="darwin",Fd=Rn.platform==="linux",Fd&&Rn.env.SNAP&&Rn.env.SNAP_REVISION,Rn.env.CI||Rn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,xd=$o,Ud=$o;let e=Rn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);xd=t.userLocale,FS=t.osLocale,Ud=t.resolvedLanguage||$o,fR=(OC=t.languagePack)==null?void 0:OC.translationsConfigFile}catch{}Ok=!0}else typeof navigator=="object"&&!pR?(qr=navigator.userAgent,Kg=qr.indexOf("Windows")>=0,Yg=qr.indexOf("Macintosh")>=0,(qr.indexOf("Macintosh")>=0||qr.indexOf("iPad")>=0||qr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Fd=qr.indexOf("Linux")>=0,(qr==null?void 0:qr.indexOf("Mobi"))>=0,Ud=globalThis._VSCODE_NLS_LANGUAGE||$o,xd=navigator.language.toLowerCase(),FS=xd):console.error("Unable to resolve platform.");var Ik=Kg,ps=Yg,gR=Fd,US=Ok,_s=qr,wi=Ud,_R;(e=>{function t(){return wi}e.value=t;function n(){return wi.length===2?wi==="en":wi.length>=3?wi[0]==="e"&&wi[1]==="n"&&wi[2]==="-":!1}e.isDefaultVariant=n;function r(){return wi==="en"}e.isDefault=r})(_R||(_R={}));var xR=typeof Ea.postMessage=="function"&&!Ea.importScripts;(()=>{if(xR){let e=[];Ea.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,s=e.length;r<s;r++){let a=e[r];if(a.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),a.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Ea.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var yR=!!(_s&&_s.indexOf("Chrome")>=0);_s&&_s.indexOf("Firefox")>=0;!yR&&_s&&_s.indexOf("Safari")>=0;_s&&_s.indexOf("Edg/")>=0;_s&&_s.indexOf("Android")>=0;var Eo=typeof navigator=="object"?navigator:{};US||document.queryCommandSupported&&document.queryCommandSupported("copy")||Eo&&Eo.clipboard&&Eo.clipboard.writeText,US||Eo&&Eo.clipboard&&Eo.clipboard.readText;var hx=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Op=new hx,VS=new hx,WS=new hx,vR=new Array(230),Pk;(e=>{function t(d){return Op.keyCodeToStr(d)}e.toString=t;function n(d){return Op.strToKeyCode(d)}e.fromString=n;function r(d){return VS.keyCodeToStr(d)}e.toUserSettingsUS=r;function s(d){return WS.keyCodeToStr(d)}e.toUserSettingsGeneral=s;function a(d){return VS.strToKeyCode(d)||WS.strToKeyCode(d)}e.fromUserSettings=a;function l(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Op.keyCodeToStr(d)}e.toElectronAccelerator=l})(Pk||(Pk={}));var bR=class Bk{constructor(t,n,r,s,a){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=s,this.keyCode=a}equals(t){return t instanceof Bk&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${t}${n}${r}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new SR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},SR=class{constructor(e){if(e.length===0)throw qL("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function wR(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Pk.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(qg)switch(t){case 59:return 85;case 60:if(gR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ps)return 57;break}else if(dR&&(ps&&t===93||!ps&&t===92))return 57;return vR[t]||0}var CR=ps?256:2048,kR=512,ER=1024,NR=ps?2048:256,GS=class{constructor(e){var n;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=wR(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=CR),this.altKey&&(t|=kR),this.shiftKey&&(t|=ER),this.metaKey&&(t|=NR),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new bR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},qS=new WeakMap;function jR(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var TR=class{static getSameOriginWindowChain(e){let t=qS.get(e);if(!t){t=[],qS.set(e,t);let n=e,r;do r=jR(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,s=this.getSameOriginWindowChain(e);for(let a of s){let l=a.window.deref();if(n+=(l==null?void 0:l.scrollY)??0,r+=(l==null?void 0:l.scrollX)??0,l===t||!a.iframeElement)break;let d=a.iframeElement.getBoundingClientRect();n+=d.top,r+=d.left}return{top:n,left:r}}},yd=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=TR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},KS=class{constructor(e,t=0,n=0){var s;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(dx){let a=navigator.userAgent.match(/Chrome\/(\d+)/);r=(a?parseInt(a[1]):123)<=122}if(e){let a=e,l=e,d=((s=e.view)==null?void 0:s.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")r?this.deltaY=a.wheelDeltaY/(120*d):this.deltaY=a.wheelDeltaY/120;else if(typeof l.VERTICAL_AXIS<"u"&&l.axis===l.VERTICAL_AXIS)this.deltaY=-l.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?qg&&!ps?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")hR&&Ik?this.deltaX=-(a.wheelDeltaX/120):r?this.deltaX=a.wheelDeltaX/(120*d):this.deltaX=a.wheelDeltaX/120;else if(typeof l.HORIZONTAL_AXIS<"u"&&l.axis===l.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?qg&&!ps?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},zk=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),AR;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof DR?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:zk})})(AR||(AR={}));var DR=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?zk:(this._emitter||(this._emitter=new we),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},fx=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Hg("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Hg("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},LR=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Hg("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=Bt(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},RR;(e=>{async function t(r){let s,a=await Promise.all(r.map(l=>l.then(d=>d,d=>{s||(s=d)})));if(typeof s<"u")throw s;return a}e.settled=t;function n(r){return new Promise(async(s,a)=>{try{await r(s,a)}catch(l){a(l)}})}e.withAsyncBody=n})(RR||(RR={}));var YS=class Ar{static fromArray(t){return new Ar(n=>{n.emitMany(t)})}static fromPromise(t){return new Ar(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ar(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new Ar(async n=>{await Promise.all(t.map(async r=>{for await(let s of r)n.emitOne(s)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new we,queueMicrotask(async()=>{let r={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(t(r)),this.resolve()}catch(s){this.reject(s)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Ar(async r=>{for await(let s of t)r.emitOne(n(s))})}map(t){return Ar.map(this,t)}static filter(t,n){return new Ar(async r=>{for await(let s of t)n(s)&&r.emitOne(s)})}filter(t){return Ar.filter(this,t)}static coalesce(t){return Ar.filter(t,n=>!!n)}coalesce(){return Ar.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return Ar.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};YS.EMPTY=YS.fromArray([]);var{getWindow:ms,getWindowId:MR,onDidRegisterWindow:OR}=(function(){let e=new Map,t={window:Gs,disposables:new Ii};e.set(Gs.vscodeWindowId,t);let n=new we,r=new we,s=new we;function a(l,d){return(typeof l=="number"?e.get(l):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(l){if(e.has(l.vscodeWindowId))return et.None;let d=new Ii,f={window:l,disposables:d.add(new Ii)};return e.set(l.vscodeWindowId,f),d.add(Bt(()=>{e.delete(l.vscodeWindowId),r.fire(l)})),d.add(Fe(l,Sn.BEFORE_UNLOAD,()=>{s.fire(l)})),n.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(l){return l.vscodeWindowId},hasWindow(l){return e.has(l)},getWindowById:a,getWindow(l){var h;let d=l;if((h=d==null?void 0:d.ownerDocument)!=null&&h.defaultView)return d.ownerDocument.defaultView.window;let f=l;return f!=null&&f.view?f.view.window:Gs},getDocument(l){return ms(l).document}}})(),IR=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Fe(e,t,n,r){return new IR(e,t,n,r)}var XS=function(e,t,n,r){return Fe(e,t,n,r)},mx,PR=class extends LR{constructor(e){super(),this.defaultTarget=e&&ms(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},QS=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Hd(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,s=a=>{n.set(a,!1);let l=e.get(a)??[];for(t.set(a,l),e.set(a,[]),r.set(a,!0);l.length>0;)l.sort(QS.sort),l.shift().execute();r.set(a,!1)};mx=(a,l,d=0)=>{let f=MR(a),h=new QS(l,d),p=e.get(f);return p||(p=[],e.set(f,p)),p.push(h),n.get(f)||(n.set(f,!0),a.requestAnimationFrame(()=>s(f))),h}})();function BR(e){let t=e.getBoundingClientRect(),n=ms(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Sn={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},zR=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=nr(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=nr(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=nr(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=nr(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=nr(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=nr(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=nr(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=nr(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=nr(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=nr(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=nr(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=nr(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=nr(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=nr(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function nr(e){return typeof e=="number"?`${e}px`:e}function vc(e){return new zR(e)}var $k=class{constructor(){this._hooks=new Ii,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=s;let a=e;try{e.setPointerCapture(t),this._hooks.add(Bt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=ms(e)}this._hooks.add(Fe(a,Sn.POINTER_MOVE,l=>{if(l.buttons!==n){this.stopMonitoring(!0);return}l.preventDefault(),this._pointerMoveCallback(l)})),this._hooks.add(Fe(a,Sn.POINTER_UP,l=>this.stopMonitoring(!0)))}};function $R(e,t,n){let r=null,s=null;if(typeof n.value=="function"?(r="value",s=n.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",s=n.get),!s)throw new Error("not supported");let a=`$memoize$${t}`;n[r]=function(...l){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,l)}),this[a]}}var ls;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ls||(ls={}));var hc=class Pn extends et{constructor(){super(),this.dispatched=!1,this.targets=new HS,this.ignoreTargets=new HS,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Mn.runAndSubscribe(OR,({window:t,disposables:n})=>{n.add(Fe(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(Fe(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(Fe(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Gs,disposables:this._store}))}static addTarget(t){if(!Pn.isTouchDevice())return et.None;Pn.INSTANCE||(Pn.INSTANCE=new Pn);let n=Pn.INSTANCE.targets.push(t);return Bt(n)}static ignoreTarget(t){if(!Pn.isTouchDevice())return et.None;Pn.INSTANCE||(Pn.INSTANCE=new Pn);let n=Pn.INSTANCE.ignoreTargets.push(t);return Bt(n)}static isTouchDevice(){return"ontouchstart"in Gs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,s=t.targetTouches.length;r<s;r++){let a=t.targetTouches.item(r);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let l=this.newGestureEvent(ls.Start,a.target);l.pageX=a.pageX,l.pageY=a.pageY,this.dispatchEvent(l)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),s=Object.keys(this.activeTouches).length;for(let a=0,l=n.changedTouches.length;a<l;a++){let d=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let f=this.activeTouches[d.identifier],h=Date.now()-f.initialTimeStamp;if(h<Pn.HOLD_DELAY&&Math.abs(f.initialPageX-fr(f.rollingPageX))<30&&Math.abs(f.initialPageY-fr(f.rollingPageY))<30){let p=this.newGestureEvent(ls.Tap,f.initialTarget);p.pageX=fr(f.rollingPageX),p.pageY=fr(f.rollingPageY),this.dispatchEvent(p)}else if(h>=Pn.HOLD_DELAY&&Math.abs(f.initialPageX-fr(f.rollingPageX))<30&&Math.abs(f.initialPageY-fr(f.rollingPageY))<30){let p=this.newGestureEvent(ls.Contextmenu,f.initialTarget);p.pageX=fr(f.rollingPageX),p.pageY=fr(f.rollingPageY),this.dispatchEvent(p)}else if(s===1){let p=fr(f.rollingPageX),g=fr(f.rollingPageY),_=fr(f.rollingTimestamps)-f.rollingTimestamps[0],x=p-f.rollingPageX[0],v=g-f.rollingPageY[0],S=[...this.targets].filter(w=>f.initialTarget instanceof Node&&w.contains(f.initialTarget));this.inertia(t,S,r,Math.abs(x)/_,x>0?1:-1,p,Math.abs(v)/_,v>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(ls.End,f.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===ls.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>Pn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===ls.Change||t.type===ls.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let s=0,a=t.initialTarget;for(;a&&a!==r;)s++,a=a.parentElement;n.push([s,r])}n.sort((r,s)=>r[0]-s[0]);for(let[r,s]of n)s.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,s,a,l,d,f,h){this.handle=mx(t,()=>{let p=Date.now(),g=p-r,_=0,x=0,v=!0;s+=Pn.SCROLL_FRICTION*g,d+=Pn.SCROLL_FRICTION*g,s>0&&(v=!1,_=a*s*g),d>0&&(v=!1,x=f*d*g);let S=this.newGestureEvent(ls.Change);S.translationX=_,S.translationY=x,n.forEach(w=>w.dispatchEvent(S)),v||this.inertia(t,n,p,s,a,l+_,d,f,h+x)})}onTouchMove(t){let n=Date.now();for(let r=0,s=t.changedTouches.length;r<s;r++){let a=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],d=this.newGestureEvent(ls.Change,l.initialTarget);d.translationX=a.pageX-fr(l.rollingPageX),d.translationY=a.pageY-fr(l.rollingPageY),d.pageX=a.pageX,d.pageY=a.pageY,this.dispatchEvent(d),l.rollingPageX.length>3&&(l.rollingPageX.shift(),l.rollingPageY.shift(),l.rollingTimestamps.shift()),l.rollingPageX.push(a.pageX),l.rollingPageY.push(a.pageY),l.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};hc.SCROLL_FRICTION=-.005,hc.HOLD_DELAY=700,hc.CLEAR_TAP_COUNT_TIME=400,Kt([$R],hc,"isTouchDevice",1);var HR=hc,px=class extends et{onclick(e,t){this._register(Fe(e,Sn.CLICK,n=>t(new yd(ms(e),n))))}onmousedown(e,t){this._register(Fe(e,Sn.MOUSE_DOWN,n=>t(new yd(ms(e),n))))}onmouseover(e,t){this._register(Fe(e,Sn.MOUSE_OVER,n=>t(new yd(ms(e),n))))}onmouseleave(e,t){this._register(Fe(e,Sn.MOUSE_LEAVE,n=>t(new yd(ms(e),n))))}onkeydown(e,t){this._register(Fe(e,Sn.KEY_DOWN,n=>t(new GS(n))))}onkeyup(e,t){this._register(Fe(e,Sn.KEY_UP,n=>t(new GS(n))))}oninput(e,t){this._register(Fe(e,Sn.INPUT,t))}onblur(e,t){this._register(Fe(e,Sn.BLUR,t))}onfocus(e,t){this._register(Fe(e,Sn.FOCUS,t))}onchange(e,t){this._register(Fe(e,Sn.CHANGE,t))}ignoreGesture(e){return HR.ignoreTarget(e)}},JS=11,FR=class extends px{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=JS+"px",this.domNode.style.height=JS+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new $k),this._register(XS(this.bgDomNode,Sn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(XS(this.domNode,Sn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new PR),this._pointerdownScheduleRepeatTimer=this._register(new fx)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ms(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},UR=class Xg{constructor(t,n,r,s,a,l,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,s=s|0,a=a|0,l=l|0,d=d|0),this.rawScrollLeft=s,this.rawScrollTop=d,n<0&&(n=0),s+n>r&&(s=r-n),s<0&&(s=0),a<0&&(a=0),d+a>l&&(d=l-a),d<0&&(d=0),this.width=n,this.scrollWidth=r,this.scrollLeft=s,this.height=a,this.scrollHeight=l,this.scrollTop=d}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Xg(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Xg(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,s=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,l=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:s,scrollLeftChanged:a,heightChanged:l,scrollHeightChanged:d,scrollTopChanged:f}}},VR=class extends et{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new UR(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var r;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new e1(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=e1.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},ZS=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Ip(e,t){let n=t-e;return function(r){return e+n*qR(r)}}function WR(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var e1=class Qg{constructor(t,n,r,s){this.from=t,this.to=n,this.duration=s,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,r){if(Math.abs(t-n)>2.5*r){let s,a;return t<n?(s=t+.75*r,a=n-.75*r):(s=t-.75*r,a=n+.75*r),WR(Ip(t,s),Ip(a,n),.33)}return Ip(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),s=this.scrollTop(n);return new ZS(r,s,!1)}return new ZS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return Qg.start(t,n,r)}static start(t,n,r){r=r+10;let s=Date.now()-10;return new Qg(t,n,s,r)}};function GR(e){return Math.pow(e,3)}function qR(e){return 1-GR(1-e)}var KR=class extends et{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new fx)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},YR=140,Hk=class extends px{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new KR(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new $k),this._shouldRender=!0,this.domNode=vc(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Fe(this.domNode.domNode,Sn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new FR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=vc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Fe(this.slider.domNode,Sn.POINTER_DOWN,s=>{s.button===0&&(s.preventDefault(),this._sliderPointerDown(s))})),this.onclick(this.slider.domNode,s=>{s.leftButton&&s.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(e);n<=s&&s<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let s=BR(this.domNode.domNode);t=e.pageX-s.left,n=e.pageY-s.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{let a=this._sliderOrthogonalPointerPosition(s),l=Math.abs(a-n);if(Ik&&l>YR){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let d=this._sliderPointerPosition(s)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(d))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Fk=class Jg{constructor(t,n,r,s,a,l){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=s,this._scrollSize=a,this._scrollPosition=l,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Jg(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,s,a){let l=Math.max(0,r-t),d=Math.max(0,l-2*n),f=s>0&&s>r;if(!f)return{computedAvailableSize:Math.round(l),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(r*d/s))),p=(d-h)/(s-r),g=a*p;return{computedAvailableSize:Math.round(l),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:p,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=Jg._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},XR=class extends Hk{constructor(e,t,n){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Fk(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,s.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},QR=class extends Hk{constructor(e,t,n){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Fk(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,s.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},JR=500,t1=50,ZR=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Zg=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,s=this._rear;do{let a=s===this._front?t:Math.pow(2,-r);if(t-=a,n+=this._memory[s].score*a,s===this._front)break;s=(this._capacity+s-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(dx){let n=ms(t.browserEvent),r=uR(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let s=null,a=new ZR(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(s=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,s)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let s=Math.abs(t.deltaX),a=Math.abs(t.deltaY),l=Math.abs(n.deltaX),d=Math.abs(n.deltaY),f=Math.max(Math.min(s,l),1),h=Math.max(Math.min(a,d),1),p=Math.max(s,l),g=Math.max(a,d);p%f===0&&g%h===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Zg.INSTANCE=new Zg;var e5=Zg,t5=class extends px{constructor(e,t,n){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=r5(t),this._scrollable=n,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let r={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new QR(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new XR(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vc(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new fx),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ja(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ps&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new KS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ja(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new KS(n))};this._mouseWheelToDispose.push(Fe(this._listenOnDomNode,Sn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var s;if((s=e.browserEvent)!=null&&s.defaultPrevented)return;let t=e5.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,l=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&l+a===0?l=a=0:Math.abs(a)>=Math.abs(l)?l=0:a=0),this._options.flipAxes&&([a,l]=[l,a]);let d=!ps&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!l&&(l=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(l=l*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),h={};if(a){let p=t1*a,g=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(h,g)}if(l){let p=t1*l,g=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(h,g)}h=this._scrollable.validateScrollPosition(h),(f.scrollLeft!==h.scrollLeft||f.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",s=t?" top":"",a=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${s}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),JR)}},n5=class extends t5{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function r5(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,ps&&(t.className+=" mac"),t}var e_=class extends et{constructor(e,t,n,r,s,a,l,d){super(),this._bufferService=n,this._optionsService=l,this._renderService=d,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new VR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>mx(r.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new n5(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Mn.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Bt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Bt(()=>this._styleElement.remove())),this._register(Mn.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
78
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};e_=Kt([je(2,Gn),je(3,Ys),je(4,Sk),je(5,Yo),je(6,qn),je(7,Xs)],e_);var t_=class extends et{constructor(e,t,n,r,s){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=s,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(a=>this._removeDecoration(a))),this._register(Bt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};t_=Kt([je(1,Gn),je(2,Ys),je(3,Uc),je(4,Xs)],t_);var s5=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},as={full:0,left:0,center:0,right:0},Ci={full:0,left:0,center:0,right:0},Xl={full:0,left:0,center:0,right:0},Zd=class extends et{constructor(e,t,n,r,s,a,l,d){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=s,this._optionsService=a,this._themeService=l,this._coreBrowserService=d,this._colorZoneStore=new s5,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(Bt(()=>{var p;return(p=this._canvas)==null?void 0:p.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Ci.full=this._canvas.width,Ci.left=e,Ci.center=t,Ci.right=e,this._refreshDrawHeightConstants(),Xl.full=1,Xl.left=1,Xl.center=1+Ci.left,Xl.right=1+Ci.left+Ci.center}_refreshDrawHeightConstants(){as.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);as.left=t,as.center=t,as.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*as.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*as.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*as.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*as.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Xl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-as[e.position||"full"]/2),Ci[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+as[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Zd=Kt([je(2,Gn),je(3,Uc),je(4,Xs),je(5,qn),je(6,Yo),je(7,Ys)],Zd);var _e;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
79
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(_e||(_e={}));var Vd;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Vd||(Vd={}));var Uk;(e=>e.ST=`${_e.ESC}\\`)(Uk||(Uk={}));var n_=class{constructor(e,t,n,r,s,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=s,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${_e.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};n_=Kt([je(2,Gn),je(3,qn),je(4,Ra),je(5,Xs)],n_);var wn=0,Cn=0,kn=0,qt=0,n1={css:"#00000000",rgba:0},cn;(e=>{function t(s,a,l,d){return d!==void 0?`#${oa(s)}${oa(a)}${oa(l)}${oa(d)}`:`#${oa(s)}${oa(a)}${oa(l)}`}e.toCss=t;function n(s,a,l,d=255){return(s<<24|a<<16|l<<8|d)>>>0}e.toRgba=n;function r(s,a,l,d){return{css:e.toCss(s,a,l,d),rgba:e.toRgba(s,a,l,d)}}e.toColor=r})(cn||(cn={}));var Mt;(e=>{function t(f,h){if(qt=(h.rgba&255)/255,qt===1)return{css:h.css,rgba:h.rgba};let p=h.rgba>>24&255,g=h.rgba>>16&255,_=h.rgba>>8&255,x=f.rgba>>24&255,v=f.rgba>>16&255,S=f.rgba>>8&255;wn=x+Math.round((p-x)*qt),Cn=v+Math.round((g-v)*qt),kn=S+Math.round((_-S)*qt);let w=cn.toCss(wn,Cn,kn),k=cn.toRgba(wn,Cn,kn);return{css:w,rgba:k}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function r(f,h,p){let g=Wd.ensureContrastRatio(f.rgba,h.rgba,p);if(g)return cn.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=r;function s(f){let h=(f.rgba|255)>>>0;return[wn,Cn,kn]=Wd.toChannels(h),{css:cn.toCss(wn,Cn,kn),rgba:h}}e.opaque=s;function a(f,h){return qt=Math.round(h*255),[wn,Cn,kn]=Wd.toChannels(f.rgba),{css:cn.toCss(wn,Cn,kn,qt),rgba:cn.toRgba(wn,Cn,kn,qt)}}e.opacity=a;function l(f,h){return qt=f.rgba&255,a(f,qt*h/255)}e.multiplyOpacity=l;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(Mt||(Mt={}));var Ht;(e=>{let t,n;try{let s=document.createElement("canvas");s.width=1,s.height=1;let a=s.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return wn=parseInt(s.slice(1,2).repeat(2),16),Cn=parseInt(s.slice(2,3).repeat(2),16),kn=parseInt(s.slice(3,4).repeat(2),16),cn.toColor(wn,Cn,kn);case 5:return wn=parseInt(s.slice(1,2).repeat(2),16),Cn=parseInt(s.slice(2,3).repeat(2),16),kn=parseInt(s.slice(3,4).repeat(2),16),qt=parseInt(s.slice(4,5).repeat(2),16),cn.toColor(wn,Cn,kn,qt);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let a=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return wn=parseInt(a[1]),Cn=parseInt(a[2]),kn=parseInt(a[3]),qt=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),cn.toColor(wn,Cn,kn,qt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=s,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[wn,Cn,kn,qt]=t.getImageData(0,0,1,1).data,qt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:cn.toRgba(wn,Cn,kn,qt),css:s}}e.toColor=r})(Ht||(Ht={}));var Vn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,s,a){let l=r/255,d=s/255,f=a/255,h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),p=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return h*.2126+p*.7152+g*.0722}e.relativeLuminance2=n})(Vn||(Vn={}));var Wd;(e=>{function t(l,d){if(qt=(d&255)/255,qt===1)return d;let f=d>>24&255,h=d>>16&255,p=d>>8&255,g=l>>24&255,_=l>>16&255,x=l>>8&255;return wn=g+Math.round((f-g)*qt),Cn=_+Math.round((h-_)*qt),kn=x+Math.round((p-x)*qt),cn.toRgba(wn,Cn,kn)}e.blend=t;function n(l,d,f){let h=Vn.relativeLuminance(l>>8),p=Vn.relativeLuminance(d>>8);if(Ps(h,p)<f){if(p<h){let x=r(l,d,f),v=Ps(h,Vn.relativeLuminance(x>>8));if(v<f){let S=s(l,d,f),w=Ps(h,Vn.relativeLuminance(S>>8));return v>w?x:S}return x}let g=s(l,d,f),_=Ps(h,Vn.relativeLuminance(g>>8));if(_<f){let x=r(l,d,f),v=Ps(h,Vn.relativeLuminance(x>>8));return _>v?g:x}return g}}e.ensureContrastRatio=n;function r(l,d,f){let h=l>>24&255,p=l>>16&255,g=l>>8&255,_=d>>24&255,x=d>>16&255,v=d>>8&255,S=Ps(Vn.relativeLuminance2(_,x,v),Vn.relativeLuminance2(h,p,g));for(;S<f&&(_>0||x>0||v>0);)_-=Math.max(0,Math.ceil(_*.1)),x-=Math.max(0,Math.ceil(x*.1)),v-=Math.max(0,Math.ceil(v*.1)),S=Ps(Vn.relativeLuminance2(_,x,v),Vn.relativeLuminance2(h,p,g));return(_<<24|x<<16|v<<8|255)>>>0}e.reduceLuminance=r;function s(l,d,f){let h=l>>24&255,p=l>>16&255,g=l>>8&255,_=d>>24&255,x=d>>16&255,v=d>>8&255,S=Ps(Vn.relativeLuminance2(_,x,v),Vn.relativeLuminance2(h,p,g));for(;S<f&&(_<255||x<255||v<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),S=Ps(Vn.relativeLuminance2(_,x,v),Vn.relativeLuminance2(h,p,g));return(_<<24|x<<16|v<<8|255)>>>0}e.increaseLuminance=s;function a(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=a})(Wd||(Wd={}));function oa(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ps(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var i5=class extends Fc{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},eh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Pr}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),s=0,a=0,l=0,d=t.getFg(0),f=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==f){if(h-s>1){let p=this._getJoinedRanges(r,l,a,t,s);for(let g=0;g<p.length;g++)n.push(p[g])}s=h,l=a,d=this._workCell.fg,f=this._workCell.bg}a+=this._workCell.getChars().length||Mi.length}if(this._bufferService.cols-s>1){let h=this._getJoinedRanges(r,l,a,t,s);for(let p=0;p<h.length;p++)n.push(h[p])}return n}_getJoinedRanges(e,t,n,r,s){let a=e.substring(t,n),l=[];try{l=this._characterJoiners[0].handler(a)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let f=this._characterJoiners[d].handler(a);for(let h=0;h<f.length;h++)eh._mergeRanges(l,f[h])}catch(f){console.error(f)}return this._stringRangesToCellRanges(l,r,s),l}_stringRangesToCellRanges(e,t,n){let r=0,s=!1,a=0,l=e[r];if(l){for(let d=n;d<this._bufferService.cols;d++){let f=t.getWidth(d),h=t.getString(d).length||Mi.length;if(f!==0){if(!s&&l[0]<=a&&(l[0]=d,s=!0),l[1]<=a){if(l[1]=d,l=e[++r],!l)break;l[0]<=a?(l[0]=d,s=!0):s=!1}a+=h}}l&&(l[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(n){if(t[1]<=s[0])return e[r-1][1]=t[1],e;if(t[1]<=s[1])return e[r-1][1]=Math.max(t[1],s[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=s[0])return e.splice(r,0,t),e;if(t[1]<=s[1])return s[0]=Math.min(t[0],s[0]),e;t[0]<s[1]&&(s[0]=Math.min(t[0],s[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};eh=Kt([je(0,Gn)],eh);function a5(e){return 57508<=e&&e<=57558}function o5(e){return 9472<=e&&e<=9631}function l5(e){return a5(e)||o5(e)}function c5(){return{css:{canvas:vd(),cell:vd()},device:{canvas:vd(),cell:vd(),char:{width:0,height:0,left:0,top:0}}}}function vd(){return{width:0,height:0}}var r_=class{constructor(e,t,n,r,s,a,l){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=s,this._decorationService=a,this._themeService=l,this._workCell=new Pr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,s,a,l,d,f,h,p){let g=[],_=this._characterJoinerService.getJoinedCharacters(t),x=this._themeService.colors,v=e.getNoBgTrimmedLength();n&&v<a+1&&(v=a+1);let S,w=0,k="",j=0,T=0,A=0,P=0,R=!1,q=0,J=!1,ne=0,I=0,W=[],z=h!==-1&&p!==-1;for(let L=0;L<v;L++){e.loadCell(L,this._workCell);let U=this._workCell.getWidth();if(U===0)continue;let D=!1,N=L>=I,F=L,H=this._workCell;if(_.length>0&&L===_[0][0]&&N){let De=_.shift(),Ue=this._isCellInSelection(De[0],t);for(j=De[0]+1;j<De[1];j++)N&&(N=Ue===this._isCellInSelection(j,t));N&&(N=!n||a<De[0]||a>=De[1]),N?(D=!0,H=new i5(this._workCell,e.translateToString(!0,De[0],De[1]),De[1]-De[0]),F=De[1]-1,U=H.getWidth()):I=De[1]}let se=this._isCellInSelection(L,t),B=n&&L===a,V=z&&L>=h&&L<=p,K=!1;this._decorationService.forEachDecorationAtCell(L,t,void 0,De=>{K=!0});let O=H.getChars()||Mi;if(O===" "&&(H.isUnderline()||H.isOverline())&&(O=" "),ne=U*d-f.get(O,H.isBold(),H.isItalic()),!S)S=this._document.createElement("span");else if(w&&(se&&J||!se&&!J&&H.bg===T)&&(se&&J&&x.selectionForeground||H.fg===A)&&H.extended.ext===P&&V===R&&ne===q&&!B&&!D&&!K&&N){H.isInvisible()?k+=Mi:k+=O,w++;continue}else w&&(S.textContent=k),S=this._document.createElement("span"),w=0,k="";if(T=H.bg,A=H.fg,P=H.extended.ext,R=V,q=ne,J=se,D&&a>=L&&a<=F&&(a=L),!this._coreService.isCursorHidden&&B&&this._coreService.isCursorInitialized){if(W.push("xterm-cursor"),this._coreBrowserService.isFocused)l&&W.push("xterm-cursor-blink"),W.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":W.push("xterm-cursor-outline");break;case"block":W.push("xterm-cursor-block");break;case"bar":W.push("xterm-cursor-bar");break;case"underline":W.push("xterm-cursor-underline");break}}if(H.isBold()&&W.push("xterm-bold"),H.isItalic()&&W.push("xterm-italic"),H.isDim()&&W.push("xterm-dim"),H.isInvisible()?k=Mi:k=H.getChars()||Mi,H.isUnderline()&&(W.push(`xterm-underline-${H.extended.underlineStyle}`),k===" "&&(k=" "),!H.isUnderlineColorDefault()))if(H.isUnderlineColorRGB())S.style.textDecorationColor=`rgb(${Fc.toColorRGB(H.getUnderlineColor()).join(",")})`;else{let De=H.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&H.isBold()&&De<8&&(De+=8),S.style.textDecorationColor=x.ansi[De].css}H.isOverline()&&(W.push("xterm-overline"),k===" "&&(k=" ")),H.isStrikethrough()&&W.push("xterm-strikethrough"),V&&(S.style.textDecoration="underline");let Q=H.getFgColor(),G=H.getFgColorMode(),Z=H.getBgColor(),te=H.getBgColorMode(),Se=!!H.isInverse();if(Se){let De=Q;Q=Z,Z=De;let Ue=G;G=te,te=Ue}let le,Ce,Re=!1;this._decorationService.forEachDecorationAtCell(L,t,void 0,De=>{De.options.layer!=="top"&&Re||(De.backgroundColorRGB&&(te=50331648,Z=De.backgroundColorRGB.rgba>>8&16777215,le=De.backgroundColorRGB),De.foregroundColorRGB&&(G=50331648,Q=De.foregroundColorRGB.rgba>>8&16777215,Ce=De.foregroundColorRGB),Re=De.options.layer==="top")}),!Re&&se&&(le=this._coreBrowserService.isFocused?x.selectionBackgroundOpaque:x.selectionInactiveBackgroundOpaque,Z=le.rgba>>8&16777215,te=50331648,Re=!0,x.selectionForeground&&(G=50331648,Q=x.selectionForeground.rgba>>8&16777215,Ce=x.selectionForeground)),Re&&W.push("xterm-decoration-top");let Oe;switch(te){case 16777216:case 33554432:Oe=x.ansi[Z],W.push(`xterm-bg-${Z}`);break;case 50331648:Oe=cn.toColor(Z>>16,Z>>8&255,Z&255),this._addStyle(S,`background-color:#${r1((Z>>>0).toString(16),"0",6)}`);break;case 0:default:Se?(Oe=x.foreground,W.push("xterm-bg-257")):Oe=x.background}switch(le||H.isDim()&&(le=Mt.multiplyOpacity(Oe,.5)),G){case 16777216:case 33554432:H.isBold()&&Q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Q+=8),this._applyMinimumContrast(S,Oe,x.ansi[Q],H,le,void 0)||W.push(`xterm-fg-${Q}`);break;case 50331648:let De=cn.toColor(Q>>16&255,Q>>8&255,Q&255);this._applyMinimumContrast(S,Oe,De,H,le,Ce)||this._addStyle(S,`color:#${r1(Q.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(S,Oe,x.foreground,H,le,Ce)||Se&&W.push("xterm-fg-257")}W.length&&(S.className=W.join(" "),W.length=0),!B&&!D&&!K&&N?w++:S.textContent=k,ne!==this.defaultSpacing&&(S.style.letterSpacing=`${ne}px`),g.push(S),L=F}return S&&w&&(S.textContent=k),g}_applyMinimumContrast(e,t,n,r,s,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||l5(r.getCode()))return!1;let l=this._getContrastCache(r),d;if(!s&&!a&&(d=l.getColor(t.rgba,n.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);d=Mt.ensureContrastRatio(s||t,a||n,f),l.setColor((s||t).rgba,(a||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};r_=Kt([je(1,kk),je(2,qn),je(3,Ys),je(4,Ra),je(5,Uc),je(6,Yo)],r_);function r1(e,t,n){for(;e.length<n;)e=t+e;return e}var u5=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[n,r,s,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let l=this._measure(e,0);return l>0&&(this._flat[r]=l),l}let s=e;t&&(s+="B"),n&&(s+="I");let a=this._holey.get(s);if(a===void 0){let l=0;t&&(l|=1),n&&(l|=2),a=this._measure(e,l),a>0&&this._holey.set(s,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},d5=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let s=e.buffers.active.ydisp,a=t[1]-s,l=n[1]-s,d=Math.max(a,0),f=Math.min(l,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=l,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function h5(){return new d5}var Pp="xterm-dom-renderer-owner-",Tr="xterm-rows",bd="xterm-fg-",s1="xterm-bg-",Ql="xterm-focus",Sd="xterm-selection",f5=1,s_=class extends et{constructor(e,t,n,r,s,a,l,d,f,h,p,g,_,x){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=s,this._helperContainer=a,this._linkifier2=l,this._charSizeService=f,this._optionsService=h,this._bufferService=p,this._coreService=g,this._coreBrowserService=_,this._themeService=x,this._terminalClass=f5++,this._rowElements=[],this._selectionRenderModel=h5(),this.onRequestRedraw=this._register(new we).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Tr),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Sd),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=c5(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(v=>this._injectCss(v))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(r_,document),this._element.classList.add(Pp+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(v=>this._handleLinkHover(v))),this._register(this._linkifier2.onHideLinkUnderline(v=>this._handleLinkLeave(v))),this._register(Bt(()=>{this._element.classList.remove(Pp+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new u5(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Tr} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Tr} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Tr} .xterm-dim { color: ${Mt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${s} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Tr}.${Ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Tr}.${Ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Tr}.${Ql} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Sd} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Sd} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Sd} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,l]of e.ansi.entries())t+=`${this._terminalSelector} .${bd}${a} { color: ${l.css}; }${this._terminalSelector} .${bd}${a}.xterm-dim { color: ${Mt.multiplyOpacity(l,.5).css}; }${this._terminalSelector} .${s1}${a} { background-color: ${l.css}; }`;t+=`${this._terminalSelector} .${bd}257 { color: ${Mt.opaque(e.background).css}; }${this._terminalSelector} .${bd}257.xterm-dim { color: ${Mt.multiplyOpacity(Mt.opaque(e.background),.5).css}; }${this._terminalSelector} .${s1}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ql),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ql),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,l=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(a,f?t[0]:e[0],f?e[0]:t[0],l-a+1))}else{let f=r===a?e[0]:0,h=a===s?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(a,f,h));let p=l-a-1;if(d.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,p)),a!==l){let g=s===l?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,r=1){let s=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,l=this.dimensions.css.cell.width*(n-t);return a+l>this.dimensions.css.canvas.width&&(l=this.dimensions.css.canvas.width-a),s.style.height=`${r*this.dimensions.css.cell.height}px`,s.style.top=`${e*this.dimensions.css.cell.height}px`,s.style.left=`${a}px`,s.style.width=`${l}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,s=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,l=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let h=f+n.ydisp,p=this._rowElements[f],g=n.lines.get(h);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,h,h===r,l,d,s,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Pp}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,s,a){n<0&&(e=0),r<0&&(t=0);let l=this._bufferService.rows-1;n=Math.max(Math.min(n,l),0),r=Math.max(Math.min(r,l),0),s=Math.min(s,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,h=Math.min(d.x,s-1),p=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let x=n;x<=r;++x){let v=x+d.ydisp,S=this._rowElements[x],w=d.lines.get(v);if(!S||!w)break;S.replaceChildren(...this._rowFactory.createRow(w,v,v===f,g,_,h,p,this.dimensions.css.cell.width,this._widthCache,a?x===n?e:0:-1,a?(x===r?t:s)-1:-1))}}};s_=Kt([je(7,lx),je(8,Mh),je(9,qn),je(10,Gn),je(11,Ra),je(12,Ys),je(13,Yo)],s_);var i_=class extends et{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new p5(this._optionsService))}catch{this._measureStrategy=this._register(new m5(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};i_=Kt([je(2,qn)],i_);var Vk=class extends et{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},m5=class extends Vk{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},p5=class extends Vk{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},g5=class extends et{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new _5(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Mn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Fe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Fe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},_5=class extends et{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Vo),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Bt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Fe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},x5=class extends et{constructor(){super(),this.linkProviders=[],this._register(Bt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function gx(e,t,n){let r=n.getBoundingClientRect(),s=e.getComputedStyle(n),a=parseInt(s.getPropertyValue("padding-left")),l=parseInt(s.getPropertyValue("padding-top"));return[t.clientX-r.left-a,t.clientY-r.top-l]}function y5(e,t,n,r,s,a,l,d,f){if(!a)return;let h=gx(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(f?l/2:0))/l),h[1]=Math.ceil(h[1]/d),h[0]=Math.min(Math.max(h[0],1),r+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),s),h}var a_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,s){return y5(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(e,t){let n=gx(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};a_=Kt([je(0,Xs),je(1,Mh)],a_);var v5=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Wk={};AL(Wk,{getSafariVersion:()=>S5,isChromeOS:()=>Yk,isFirefox:()=>Gk,isIpad:()=>w5,isIphone:()=>C5,isLegacyEdge:()=>b5,isLinux:()=>_x,isMac:()=>th,isNode:()=>Oh,isSafari:()=>qk,isWindows:()=>Kk});var Oh=typeof process<"u"&&"title"in process,Vc=Oh?"node":navigator.userAgent,Wc=Oh?"node":navigator.platform,Gk=Vc.includes("Firefox"),b5=Vc.includes("Edge"),qk=/^((?!chrome|android).)*safari/i.test(Vc);function S5(){if(!qk)return 0;let e=Vc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var th=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Wc),w5=Wc==="iPad",C5=Wc==="iPhone",Kk=["Windows","Win16","Win32","WinCE"].includes(Wc),_x=Wc.indexOf("Linux")>=0,Yk=/\bCrOS\b/.test(Vc),Xk=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),s=e.timeRemaining(),n*1.5>s){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=s}this.clear()}},k5=class extends Xk{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},E5=class extends Xk{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},nh=!Oh&&"requestIdleCallback"in window?E5:k5,N5=class{constructor(){this._queue=new nh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},o_=class extends et{constructor(e,t,n,r,s,a,l,d,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=s,this._coreBrowserService=d,this._renderer=this._register(new Vo),this._pausedResizeTask=new N5,this._observerDisposable=this._register(new Vo),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new v5((h,p)=>this._renderRows(h,p),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new j5(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Bt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(l.onResize(()=>this._fullRefresh())),this._register(l.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(l.cols,l.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(l.buffer.y,l.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Bt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};o_=Kt([je(2,qn),je(3,Mh),je(4,Ra),je(5,Uc),je(6,Gn),je(7,Ys),je(8,Yo)],o_);var j5=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function T5(e,t,n,r){let s=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return L5(s,a,e,t,n,r)+Ih(a,t,n,r)+R5(s,a,e,t,n,r);let l;if(a===t)return l=s>e?"D":"C",jc(Math.abs(s-e),Nc(l,r));l=a>t?"D":"C";let d=Math.abs(a-t),f=D5(a>t?e:s,n)+(d-1)*n.cols+1+A5(a>t?s:e);return jc(f,Nc(l,r))}function A5(e,t){return e-1}function D5(e,t){return t.cols-e}function L5(e,t,n,r,s,a){return Ih(t,r,s,a).length===0?"":jc(Jk(e,t,e,t-Ta(t,s),!1,s).length,Nc("D",a))}function Ih(e,t,n,r){let s=e-Ta(e,n),a=t-Ta(t,n),l=Math.abs(s-a)-M5(e,t,n);return jc(l,Nc(Qk(e,t),r))}function R5(e,t,n,r,s,a){let l;Ih(t,r,s,a).length>0?l=r-Ta(r,s):l=t;let d=r,f=O5(e,t,n,r,s,a);return jc(Jk(e,l,n,d,f==="C",s).length,Nc(f,a))}function M5(e,t,n){var l;let r=0,s=e-Ta(e,n),a=t-Ta(t,n);for(let d=0;d<Math.abs(s-a);d++){let f=Qk(e,t)==="A"?-1:1;(l=n.buffer.lines.get(s+f*d))!=null&&l.isWrapped&&r++}return r}function Ta(e,t){let n=0,r=t.buffer.lines.get(e),s=r==null?void 0:r.isWrapped;for(;s&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),s=r==null?void 0:r.isWrapped;return n}function O5(e,t,n,r,s,a){let l;return Ih(n,r,s,a).length>0?l=r-Ta(r,s):l=t,e<n&&l<=r||e>=n&&l<r?"C":"D"}function Qk(e,t){return e>t?"A":"B"}function Jk(e,t,n,r,s,a){let l=e,d=t,f="";for(;(l!==n||d!==r)&&d>=0&&d<a.buffer.lines.length;)l+=s?1:-1,s&&l>a.cols-1?(f+=a.buffer.translateBufferLineToString(d,!1,e,l),l=0,e=0,d++):!s&&l<0&&(f+=a.buffer.translateBufferLineToString(d,!1,0,e+1),l=a.cols-1,e=l,d--);return f+a.buffer.translateBufferLineToString(d,!1,e,l)}function Nc(e,t){let n=t?"O":"[";return _e.ESC+n+e}function jc(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var I5=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function i1(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Bp=50,P5=15,B5=50,z5=500,$5=" ",H5=new RegExp($5,"g"),l_=class extends et{constructor(e,t,n,r,s,a,l,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=s,this._mouseService=a,this._optionsService=l,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Pr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new I5(this._bufferService),this._activeSelectionMode=0,this._register(Bt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let s=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let l=e[1];l<=t[1];l++){let d=n.translateBufferLineToString(l,!0,s,a);r.push(d)}}else{let s=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],s));for(let a=e[1]+1;a<=t[1]-1;a++){let l=n.lines.get(a),d=n.translateBufferLineToString(a,!0);l!=null&&l.isWrapped?r[r.length-1]+=d:r.push(d)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),l=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?r[r.length-1]+=l:r.push(l)}}return r.map(s=>s.replace(H5," ")).join(Kk?`\r
80
- `:`
81
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),_x&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var s,a;let n=(a=(s=this._linkifier.currentLink)==null?void 0:s.link)==null?void 0:a.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=i1(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=gx(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Bp),Bp),t/=Bp,t/Math.abs(t)+Math.round(t*(P5-1)))}shouldForceSelection(e){return th?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),B5)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(th&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<z5&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=T5(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let s=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:s>1&&t!==r&&(n+=s-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,a=s.lines.get(e[1]);if(!a)return;let l=s.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(a,e[0]),f=d,h=e[0]-d,p=0,g=0,_=0,x=0;if(l.charAt(d)===" "){for(;d>0&&l.charAt(d-1)===" ";)d--;for(;f<l.length&&l.charAt(f+1)===" ";)f++}else{let w=e[0],k=e[0];a.getWidth(w)===0&&(p++,w--),a.getWidth(k)===2&&(g++,k++);let j=a.getString(k).length;for(j>1&&(x+=j-1,f+=j-1);w>0&&d>0&&!this._isCharWordSeparator(a.loadCell(w-1,this._workCell));){a.loadCell(w-1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===0?(p++,w--):T>1&&(_+=T-1,d-=T-1),d--,w--}for(;k<a.length&&f+1<l.length&&!this._isCharWordSeparator(a.loadCell(k+1,this._workCell));){a.loadCell(k+1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,k++):T>1&&(x+=T-1,f+=T-1),f++,k++}}f++;let v=d+h-p+_,S=Math.min(this._bufferService.cols,f-d+p+g-_-x);if(!(!t&&l.slice(d,f).trim()==="")){if(n&&v===0&&a.getCodePoint(0)!==32){let w=s.lines.get(e[1]-1);if(w&&a.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let j=this._bufferService.cols-k.start;v-=j,S+=j}}}if(r&&v+S===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let w=s.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(S+=k.length)}}return{start:v,length:S}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=i1(n,this._bufferService.cols)}};l_=Kt([je(3,Gn),je(4,Ra),je(5,cx),je(6,qn),je(7,Xs),je(8,Ys)],l_);var a1=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},o1=class{constructor(){this._color=new a1,this._css=new a1}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},hn=Object.freeze((()=>{let e=[Ht.toColor("#2e3436"),Ht.toColor("#cc0000"),Ht.toColor("#4e9a06"),Ht.toColor("#c4a000"),Ht.toColor("#3465a4"),Ht.toColor("#75507b"),Ht.toColor("#06989a"),Ht.toColor("#d3d7cf"),Ht.toColor("#555753"),Ht.toColor("#ef2929"),Ht.toColor("#8ae234"),Ht.toColor("#fce94f"),Ht.toColor("#729fcf"),Ht.toColor("#ad7fa8"),Ht.toColor("#34e2e2"),Ht.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],s=t[n/6%6|0],a=t[n%6];e.push({css:cn.toCss(r,s,a),rgba:cn.toRgba(r,s,a)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:cn.toCss(r,r,r),rgba:cn.toRgba(r,r,r)})}return e})()),pa=Ht.toColor("#ffffff"),fc=Ht.toColor("#000000"),l1=Ht.toColor("#ffffff"),c1=fc,Jl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},F5=pa,c_=class extends et{constructor(e){super(),this._optionsService=e,this._contrastCache=new o1,this._halfContrastCache=new o1,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:pa,background:fc,cursor:l1,cursorAccent:c1,selectionForeground:void 0,selectionBackgroundTransparent:Jl,selectionBackgroundOpaque:Mt.blend(fc,Jl),selectionInactiveBackgroundTransparent:Jl,selectionInactiveBackgroundOpaque:Mt.blend(fc,Jl),scrollbarSliderBackground:Mt.opacity(pa,.2),scrollbarSliderHoverBackground:Mt.opacity(pa,.4),scrollbarSliderActiveBackground:Mt.opacity(pa,.5),overviewRulerBorder:pa,ansi:hn.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=kt(e.foreground,pa),t.background=kt(e.background,fc),t.cursor=Mt.blend(t.background,kt(e.cursor,l1)),t.cursorAccent=Mt.blend(t.background,kt(e.cursorAccent,c1)),t.selectionBackgroundTransparent=kt(e.selectionBackground,Jl),t.selectionBackgroundOpaque=Mt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=kt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Mt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?kt(e.selectionForeground,n1):void 0,t.selectionForeground===n1&&(t.selectionForeground=void 0),Mt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Mt.opacity(t.selectionBackgroundTransparent,.3)),Mt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Mt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=kt(e.scrollbarSliderBackground,Mt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=kt(e.scrollbarSliderHoverBackground,Mt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=kt(e.scrollbarSliderActiveBackground,Mt.opacity(t.foreground,.5)),t.overviewRulerBorder=kt(e.overviewRulerBorder,F5),t.ansi=hn.slice(),t.ansi[0]=kt(e.black,hn[0]),t.ansi[1]=kt(e.red,hn[1]),t.ansi[2]=kt(e.green,hn[2]),t.ansi[3]=kt(e.yellow,hn[3]),t.ansi[4]=kt(e.blue,hn[4]),t.ansi[5]=kt(e.magenta,hn[5]),t.ansi[6]=kt(e.cyan,hn[6]),t.ansi[7]=kt(e.white,hn[7]),t.ansi[8]=kt(e.brightBlack,hn[8]),t.ansi[9]=kt(e.brightRed,hn[9]),t.ansi[10]=kt(e.brightGreen,hn[10]),t.ansi[11]=kt(e.brightYellow,hn[11]),t.ansi[12]=kt(e.brightBlue,hn[12]),t.ansi[13]=kt(e.brightMagenta,hn[13]),t.ansi[14]=kt(e.brightCyan,hn[14]),t.ansi[15]=kt(e.brightWhite,hn[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=kt(e.extendedAnsi[r],hn[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};c_=Kt([je(0,qn)],c_);function kt(e,t){if(e!==void 0)try{return Ht.toColor(e)}catch{}return t}var U5=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},V5=class{constructor(){this._services=new U5,this._services.set(lx,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=PL(e).sort((a,l)=>a.index-l.index),r=[];for(let a of n){let l=this._services.get(a.id);if(!l)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);r.push(l)}let s=n.length>0?n[0].index:t.length;if(t.length!==s)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${s+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},W5={trace:0,debug:1,info:2,warn:3,error:4,off:5},G5="xterm.js: ",u_=class extends et{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=W5[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":G5)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};u_=Kt([je(0,qn)],u_);var u1=class extends et{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let s=t-1;s>=0;s--)this.set(e+s+n,this.get(e+s));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Je=3,ln=Object.freeze(new Fc),wd=0,zp=2,mc=class Zk{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Je);let s=n||Pr.fromCharData([0,xk,1,0]);for(let a=0;a<t;++a)this.setCell(a,s);this.length=t}get(t){let n=this._data[t*Je+0],r=n&2097151;return[this._data[t*Je+1],n&2097152?this._combined[t]:r?Ti(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Je+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Je+0]=t|2097152|n[2]<<22):this._data[t*Je+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Je+0]>>22}hasWidth(t){return this._data[t*Je+0]&12582912}getFg(t){return this._data[t*Je+1]}getBg(t){return this._data[t*Je+2]}hasContent(t){return this._data[t*Je+0]&4194303}getCodePoint(t){let n=this._data[t*Je+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Je+0]&2097152}getString(t){let n=this._data[t*Je+0];return n&2097152?this._combined[t]:n&2097151?Ti(n&2097151):""}isProtected(t){return this._data[t*Je+2]&536870912}loadCell(t,n){return wd=t*Je,n.content=this._data[wd+0],n.fg=this._data[wd+1],n.bg=this._data[wd+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Je+0]=n.content,this._data[t*Je+1]=n.fg,this._data[t*Je+2]=n.bg}setCellFromCodepoint(t,n,r,s){s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*Je+0]=n|r<<22,this._data[t*Je+1]=s.fg,this._data[t*Je+2]=s.bg}addCodepointToCell(t,n,r){let s=this._data[t*Je+0];s&2097152?this._combined[t]+=Ti(n):s&2097151?(this._combined[t]=Ti(s&2097151)+Ti(n),s&=-2097152,s|=2097152):s=n|1<<22,r&&(s&=-12582913,s|=r<<22),this._data[t*Je+0]=s}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let s=new Pr;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,s));for(let a=0;a<n;++a)this.setCell(t+a,r)}else for(let s=t;s<this.length;++s)this.setCell(s,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let s=new Pr;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,s));for(let a=this.length-n;a<this.length;++a)this.setCell(a,r)}else for(let s=t;s<this.length;++s)this.setCell(s,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,s=!1){if(s){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*zp<this._data.buffer.byteLength;let r=t*Je;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let s=new Uint32Array(r);s.set(this._data),this._data=s}for(let s=this.length;s<t;++s)this.setCell(s,n)}else{this._data=this._data.subarray(0,r);let s=Object.keys(this._combined);for(let l=0;l<s.length;l++){let d=parseInt(s[l],10);d>=t&&delete this._combined[d]}let a=Object.keys(this._extendedAttrs);for(let l=0;l<a.length;l++){let d=parseInt(a[l],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,r*4*zp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*zp<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new Zk(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Je+0]&4194303)return t+(this._data[t*Je+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Je+0]&4194303||this._data[t*Je+2]&50331648)return t+(this._data[t*Je+0]>>22);return 0}copyCellsFrom(t,n,r,s,a){let l=t._data;if(a)for(let f=s-1;f>=0;f--){for(let h=0;h<Je;h++)this._data[(r+f)*Je+h]=l[(n+f)*Je+h];l[(n+f)*Je+2]&268435456&&(this._extendedAttrs[r+f]=t._extendedAttrs[n+f])}else for(let f=0;f<s;f++){for(let h=0;h<Je;h++)this._data[(r+f)*Je+h]=l[(n+f)*Je+h];l[(n+f)*Je+2]&268435456&&(this._extendedAttrs[r+f]=t._extendedAttrs[n+f])}let d=Object.keys(t._combined);for(let f=0;f<d.length;f++){let h=parseInt(d[f],10);h>=n&&(this._combined[h-n+r]=t._combined[h])}}translateToString(t,n,r,s){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),s&&(s.length=0);let a="";for(;n<r;){let l=this._data[n*Je+0],d=l&2097151,f=l&2097152?this._combined[n]:d?Ti(d):Mi;if(a+=f,s)for(let h=0;h<f.length;++h)s.push(n);n+=l>>22||1}return s&&s.push(n),a}};function q5(e,t,n,r,s,a){let l=[];for(let d=0;d<e.length-1;d++){let f=d,h=e.get(++f);if(!h.isWrapped)continue;let p=[e.get(d)];for(;f<e.length&&h.isWrapped;)p.push(h),h=e.get(++f);if(!a&&r>=d&&r<f){d+=p.length-1;continue}let g=0,_=Tc(p,g,t),x=1,v=0;for(;x<p.length;){let w=Tc(p,x,t),k=w-v,j=n-_,T=Math.min(k,j);p[g].copyCellsFrom(p[x],v,_,T,!1),_+=T,_===n&&(g++,_=0),v+=T,v===w&&(x++,v=0),_===0&&g!==0&&p[g-1].getWidth(n-1)===2&&(p[g].copyCellsFrom(p[g-1],n-1,_++,1,!1),p[g-1].setCell(n-1,s))}p[g].replaceCells(_,n,s);let S=0;for(let w=p.length-1;w>0&&(w>g||p[w].getTrimmedLength()===0);w--)S++;S>0&&(l.push(d+p.length-S),l.push(S)),d+=p.length-1}return l}function K5(e,t){let n=[],r=0,s=t[r],a=0;for(let l=0;l<e.length;l++)if(s===l){let d=t[++r];e.onDeleteEmitter.fire({index:l-a,amount:d}),l+=d-1,a+=d,s=t[++r]}else n.push(l);return{layout:n,countRemoved:a}}function Y5(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function X5(e,t,n){let r=[],s=e.map((f,h)=>Tc(e,h,t)).reduce((f,h)=>f+h),a=0,l=0,d=0;for(;d<s;){if(s-d<n){r.push(s-d);break}a+=n;let f=Tc(e,l,t);a>f&&(a-=f,l++);let h=e[l].getWidth(a-1)===2;h&&a--;let p=h?n-1:n;r.push(p),d+=p}return r}function Tc(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,s=e[t+1].getWidth(0)===2;return r&&s?n-1:n}var e2=class t2{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=t2._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ja(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};e2._nextId=1;var Q5=e2,_n={},ga=_n.B;_n[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};_n.A={"#":"£"};_n.B=void 0;_n[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};_n.C=_n[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_n.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};_n.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};_n.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};_n.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};_n.E=_n[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};_n.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};_n.H=_n[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_n["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var d1=4294967295,h1=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ln.clone(),this.savedCharset=ga,this.markers=[],this._nullCell=Pr.fromCharData([0,xk,1,0]),this._whitespaceCell=Pr.fromCharData([0,Mi,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new nh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Jd),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Jd),this._whitespaceCell}getBlankLine(e,t){return new mc(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>d1?d1:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ln);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(ln),r=0,s=this._getCorrectBufferLength(t);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<e)for(let l=0;l<this.lines.length;l++)r+=+this.lines.get(l).resize(e,n);let a=0;if(this._rows<t)for(let l=this._rows;l<t;l++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new mc(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new mc(e,n)));else for(let l=this._rows;l>t;l--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let l=this.lines.length-s;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=s}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let a=0;a<this.lines.length;a++)r+=+this.lines.get(a).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=q5(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ln),n);if(r.length>0){let s=K5(this.lines,r);Y5(this.lines,s.layout),this._reflowLargerAdjustViewport(e,t,s.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(ln),s=n;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new mc(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(ln),s=[],a=0;for(let l=this.lines.length-1;l>=0;l--){let d=this.lines.get(l);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let f=[d];for(;d.isWrapped&&l>0;)d=this.lines.get(--l),f.unshift(d);if(!n){let T=this.ybase+this.y;if(T>=l&&T<l+f.length)continue}let h=f[f.length-1].getTrimmedLength(),p=X5(f,this._cols,e),g=p.length-f.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+g):_=Math.max(0,this.lines.length-this.lines.maxLength+g);let x=[];for(let T=0;T<g;T++){let A=this.getBlankLine(ln,!0);x.push(A)}x.length>0&&(s.push({start:l+f.length+a,newLines:x}),a+=x.length),f.push(...x);let v=p.length-1,S=p[v];S===0&&(v--,S=p[v]);let w=f.length-g-1,k=h;for(;w>=0;){let T=Math.min(k,S);if(f[v]===void 0)break;if(f[v].copyCellsFrom(f[w],k-T,S-T,T,!0),S-=T,S===0&&(v--,S=p[v]),k-=T,k===0){w--;let A=Math.max(w,0);k=Tc(f,A,this._cols)}}for(let T=0;T<f.length;T++)p[T]<e&&f[T].setCell(p[T],r);let j=g-_;for(;j-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+g,this.ybase+t-1)}if(s.length>0){let l=[],d=[];for(let S=0;S<this.lines.length;S++)d.push(this.lines.get(S));let f=this.lines.length,h=f-1,p=0,g=s[p];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let _=0;for(let S=Math.min(this.lines.maxLength-1,f+a-1);S>=0;S--)if(g&&g.start>h+_){for(let w=g.newLines.length-1;w>=0;w--)this.lines.set(S--,g.newLines[w]);S++,l.push({index:h+1,amount:g.newLines.length}),_+=g.newLines.length,g=s[++p]}else this.lines.set(S,d[h--]);let x=0;for(let S=l.length-1;S>=0;S--)l[S].index+=x,this.lines.onInsertEmitter.fire(l[S]),x+=l[S].amount;let v=Math.max(0,f+a-this.lines.maxLength);v>0&&this.lines.onTrimEmitter.fire(v)}}translateBufferLineToString(e,t,n=0,r){let s=this.lines.get(e);return s?s.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Q5(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},J5=class extends et{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new h1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new h1(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},n2=2,r2=1,d_=class extends et{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,n2),this.rows=Math.max(e.rawOptions.rows||0,r2),this.buffers=this._register(new J5(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let s=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let l=n.lines.isFull;a===n.lines.length-1?l?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),l?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let l=a-s+1;n.lines.shiftElements(s+1,l-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};d_=Kt([je(0,qn)],d_);var No={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:th,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Z5=["normal","bold","100","200","300","400","500","600","700","800","900"],e3=class extends et{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...No};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Bt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in No))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in No))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=No[e]),!t3(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=No[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Z5.includes(t)?t:No[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function t3(e){return e==="block"||e==="underline"||e==="bar"}function pc(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&pc(e[r],t-1);return n}var f1=Object.freeze({insertMode:!1}),m1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),h_=class extends et{constructor(t,n,r){super(),this._bufferService=t,this._logService=n,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=pc(f1),this.decPrivateModes=pc(m1)}reset(){this.modes=pc(f1),this.decPrivateModes=pc(m1)}triggerDataEvent(t,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(s=>s.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(n=>n.charCodeAt(0))),this._onBinary.fire(t))}};h_=Kt([je(0,Gn),je(1,wk),je(2,qn)],h_);var p1={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function $p(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Hp=String.fromCharCode,g1={DEFAULT:e=>{let t=[$p(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Hp(t[0])}${Hp(t[1])}${Hp(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${$p(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${$p(e,!0)};${e.x};${e.y}${t}`}},f_=class extends et{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new we),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(p1))this.addProtocol(r,p1[r]);for(let r of Object.keys(g1))this.addEncoding(r,g1[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=r+0,Math.abs(e.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};f_=Kt([je(0,Gn),je(1,Ra),je(2,qn)],f_);var Fp=[[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]],n3=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],fn;function r3(e,t){let n=0,r=t.length-1,s;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(s=n+r>>1,e>t[s][1])n=s+1;else if(e<t[s][0])r=s-1;else return!0;return!1}var s3=class{constructor(){if(this.version="6",!fn){fn=new Uint8Array(65536),fn.fill(1),fn[0]=0,fn.fill(0,1,32),fn.fill(0,127,160),fn.fill(2,4352,4448),fn[9001]=2,fn[9002]=2,fn.fill(2,11904,42192),fn[12351]=1,fn.fill(2,44032,55204),fn.fill(2,63744,64256),fn.fill(2,65040,65050),fn.fill(2,65072,65136),fn.fill(2,65280,65377),fn.fill(2,65504,65511);for(let e=0;e<Fp.length;++e)fn.fill(0,Fp[e][0],Fp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?fn[e]:r3(e,n3)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let s=va.extractWidth(t);s===0?r=!1:s>n&&(n=s)}return va.createPropertyValue(0,n,r)}},va=class Gd{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new s3;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,s=t.length;for(let a=0;a<s;++a){let l=t.charCodeAt(a);if(55296<=l&&l<=56319){if(++a>=s)return n+this.wcwidth(l);let h=t.charCodeAt(a);56320<=h&&h<=57343?l=(l-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let d=this.charProperties(l,r),f=Gd.extractWidth(d);Gd.extractShouldJoin(d)&&(f-=Gd.extractWidth(r)),n+=f,r=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},i3=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function _1(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Zl=2147483647,a3=256,s2=class m_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>a3)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new m_;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let s=t[r];if(Array.isArray(s))for(let a=0;a<s.length;++a)n.addSubParam(s[a]);else n.addParam(s)}return n}clone(){let t=new m_(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,s=this._subParamsIdx[n]&255;s-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,s))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Zl?Zl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Zl?Zl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,s=this._subParamsIdx[n]&255;s-r>0&&(t[n]=this._subParams.slice(r,s))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,s=r[n-1];r[n-1]=~s?Math.min(s*10+t,Zl):t}},ec=[],o3=class{constructor(){this._state=0,this._active=ec,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ec}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ec,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ec,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Rh(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=ec,this._id=-1,this._state=0}}},mr=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Rh(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},tc=[],l3=class{constructor(){this._handlers=Object.create(null),this._active=tc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=tc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=tc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||tc,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Rh(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,s=this._stack.fallThrough,this._stack.paused=!1),!s&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=tc,this._ident=0}},gc=new s2;gc.addParam(0);var x1=class{constructor(e){this._handler=e,this._data="",this._params=gc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():gc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Rh(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=gc,this._data="",this._hitLimit=!1,n));return this._params=gc,this._data="",this._hitLimit=!1,t}},c3=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let s=0;s<e.length;s++)this.table[t<<8|e[s]]=n<<4|r}},Lr=160,u3=(function(){let e=new c3(4095),t=Array.apply(null,Array(256)).map((d,f)=>f),n=(d,f)=>t.slice(d,f),r=n(32,127),s=n(0,24);s.push(25),s.push.apply(s,n(28,32));let a=n(0,14),l;e.setDefault(1,0),e.addMany(r,0,2,0);for(l in a)e.addMany([24,26,153,154],l,3,0),e.addMany(n(128,144),l,3,0),e.addMany(n(144,152),l,3,0),e.add(156,l,0,0),e.add(27,l,11,1),e.add(157,l,4,8),e.addMany([152,158,159],l,0,7),e.add(155,l,11,3),e.add(144,l,11,9);return e.addMany(s,0,3,0),e.addMany(s,1,3,1),e.add(127,1,0,1),e.addMany(s,8,0,8),e.addMany(s,3,3,3),e.add(127,3,0,3),e.addMany(s,4,3,4),e.add(127,4,0,4),e.addMany(s,6,3,6),e.addMany(s,5,3,5),e.add(127,5,0,5),e.addMany(s,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(s,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(s,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(s,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(s,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(s,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(s,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Lr,0,2,0),e.add(Lr,8,5,8),e.add(Lr,6,0,6),e.add(Lr,11,0,11),e.add(Lr,13,13,13),e})(),d3=class extends et{constructor(e=u3){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new s2,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Bt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new o3),this._dcsParser=this._register(new l3),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let s=0;s<e.intermediates.length;++s){let a=e.intermediates.charCodeAt(s);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,s){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=s}parse(e,t,n){let r=0,s=0,a=0,l;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&f>-1){for(;f>=0&&(l=d[f](this._params),l!==!0);f--)if(l instanceof Promise)return this._parseStack.handlerPos=f,l}this._parseStack.handlers=[];break;case 4:if(n===!1&&f>-1){for(;f>=0&&(l=d[f](),l!==!0);f--)if(l instanceof Promise)return this._parseStack.handlerPos=f,l}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],l=this._dcsParser.unhook(r!==24&&r!==26,n),l)return l;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],l=this._oscParser.end(r!==24&&r!==26,n),l)return l;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=a;d<t;++d){switch(r=e[d],s=this._transitions.table[this.currentState<<8|(r<160?r:Lr)],s>>4){case 2:for(let _=d+1;;++_){if(_>=t||(r=e[_])<32||r>126&&r<Lr){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Lr){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Lr){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Lr){this._printHandler(e,d,_),d=_-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|r],h=f?f.length-1:-1;for(;h>=0&&(l=f[h](this._params),l!==!0);h--)if(l instanceof Promise)return this._preserveStack(3,f,h,s,d),l;h<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++d<t&&(r=e[d])>47&&r<60);d--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let p=this._escHandlers[this._collect<<8|r],g=p?p.length-1:-1;for(;g>=0&&(l=p[g](),l!==!0);g--)if(l instanceof Promise)return this._preserveStack(4,p,g,s,d),l;g<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let _=d+1;;++_)if(_>=t||(r=e[_])===24||r===26||r===27||r>127&&r<Lr){this._dcsParser.put(e,d,_),d=_-1;break}break;case 14:if(l=this._dcsParser.unhook(r!==24&&r!==26),l)return this._preserveStack(6,[],0,s,d),l;r===27&&(s|=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 _=d+1;;_++)if(_>=t||(r=e[_])<32||r>127&&r<Lr){this._oscParser.put(e,d,_),d=_-1;break}break;case 6:if(l=this._oscParser.end(r!==24&&r!==26),l)return this._preserveStack(5,[],0,s,d),l;r===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=s&15}}},h3=/^([\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})$/,f3=/^[\da-f]+$/;function y1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=h3.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),f3.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let s=0;s<3;++s){let a=parseInt(t.slice(n*s,n*s+n),16);r[s]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return r}}function Up(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function m3(e,t=16){let[n,r,s]=e;return`rgb:${Up(n,t)}/${Up(r,t)}/${Up(s,t)}`}var p3={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ki=131072,v1=10;function b1(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var S1=5e3,w1=0,g3=class extends et{constructor(e,t,n,r,s,a,l,d,f=new d3){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=s,this._oscLinkService=a,this._coreMouseService=l,this._unicodeService=d,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new OL,this._utf8Decoder=new IL,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ln.clone(),this._eraseAttrDataInternal=ln.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new p_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,p)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:p.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,p,g)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:p,data:g})}),this._parser.setDcsHandlerFallback((h,p,g)=>{p==="HOOK"&&(g=g.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:p,payload:g})}),this._parser.setPrintHandler((h,p,g)=>this.print(h,p,g)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(_e.BEL,()=>this.bell()),this._parser.setExecuteHandler(_e.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(_e.BS,()=>this.backspace()),this._parser.setExecuteHandler(_e.HT,()=>this.tab()),this._parser.setExecuteHandler(_e.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(_e.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Vd.IND,()=>this.index()),this._parser.setExecuteHandler(Vd.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Vd.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new mr(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new mr(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new mr(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new mr(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new mr(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new mr(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new mr(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new mr(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new mr(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new mr(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new mr(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new mr(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in _n)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new x1((h,p)=>this.requestStatusString(h,p)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),S1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${S1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,s=this._activeBuffer.y,a=0,l=this._parseStack.paused;if(l){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ki&&(a=this._parseStack.position+ki)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ki&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ki))),l||this._dirtyRowTracker.clearRange(),e.length>ki)for(let h=a;h<e.length;h+=ki){let p=h+ki<e.length?h+ki:e.length,g=typeof e=="string"?this._stringDecoder.decode(e.substring(h,p),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,p),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,g))return this._preserveStack(r,s,g,h),this._logSlowResolvingAsync(n),n}else if(!l){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,h))return this._preserveStack(r,s,h,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),f=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);f<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(f,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,n){let r,s,a=this._charsetService.charset,l=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,f=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,p=this._curAttrData,g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&g.getWidth(this._activeBuffer.x-1)===2&&g.setCellFromCodepoint(this._activeBuffer.x-1,0,1,p);let _=this._parser.precedingJoinState;for(let x=t;x<n;++x){if(r=e[x],r<127&&a){let k=a[String.fromCharCode(r)];k&&(r=k.charCodeAt(0))}let v=this._unicodeService.charProperties(r,_);s=va.extractWidth(v);let S=va.extractShouldJoin(v),w=S?va.extractWidth(_):0;if(_=v,l&&this._onA11yChar.fire(Ti(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-w>d){if(f){let k=g,j=this._activeBuffer.x-w;for(this._activeBuffer.x=w,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&g instanceof mc&&g.copyCellsFrom(k,j,0,w,!1);j<d;)k.setCellFromCodepoint(j++,0,1,p)}else if(this._activeBuffer.x=d-1,s===2)continue}if(S&&this._activeBuffer.x){let k=g.getWidth(this._activeBuffer.x-1)?1:2;g.addCodepointToCell(this._activeBuffer.x-k,r,s);for(let j=s-w;--j>=0;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,p);continue}if(h&&(g.insertCells(this._activeBuffer.x,s-w,this._activeBuffer.getNullCell(p)),g.getWidth(d-1)===2&&g.setCellFromCodepoint(d-1,0,1,p)),g.setCellFromCodepoint(this._activeBuffer.x++,r,s,p),s>0)for(;--s;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}this._parser.precedingJoinState=_,this._activeBuffer.x<d&&n-t>0&&g.getWidth(this._activeBuffer.x)===0&&!g.hasContent(this._activeBuffer.x)&&g.setCellFromCodepoint(this._activeBuffer.x,0,1,p),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>b1(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new x1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new mr(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,s=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),s),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&r.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(s-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(ln));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=va.extractWidth(t),s=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),l=new Uint32Array(a.length*n),d=0;for(let h=0;h<a.length;){let p=a.codePointAt(h)||0;l[d++]=p,h+=p>65535?2:1}let f=d;for(let h=1;h<n;++h)l.copyWithin(f,0,d),f+=d;return this.print(l,0,f),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(_e.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(_e.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(_e.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(_e.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(_e.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ga),this._charsetService.setgCharset(1,ga),this._charsetService.setgCharset(2,ga),this._charsetService.setgCharset(3,ga);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(S=>(S[S.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",S[S.SET=1]="SET",S[S.RESET=2]="RESET",S[S.PERMANENTLY_SET=3]="PERMANENTLY_SET",S[S.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let r=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:a}=this._coreMouseService,l=this._coreService,{buffers:d,cols:f}=this._bufferService,{active:h,alt:p}=d,g=this._optionsService.rawOptions,_=(S,w)=>(l.triggerDataEvent(`${_e.ESC}[${t?"":"?"}${S};${w}$y`),!0),x=S=>S?1:2,v=e.params[0];return t?v===2?_(v,4):v===4?_(v,x(l.modes.insertMode)):v===12?_(v,3):v===20?_(v,x(g.convertEol)):_(v,0):v===1?_(v,x(r.applicationCursorKeys)):v===3?_(v,g.windowOptions.setWinLines?f===80?2:f===132?1:0:0):v===6?_(v,x(r.origin)):v===7?_(v,x(r.wraparound)):v===8?_(v,3):v===9?_(v,x(s==="X10")):v===12?_(v,x(g.cursorBlink)):v===25?_(v,x(!l.isCursorHidden)):v===45?_(v,x(r.reverseWraparound)):v===66?_(v,x(r.applicationKeypad)):v===67?_(v,4):v===1e3?_(v,x(s==="VT200")):v===1002?_(v,x(s==="DRAG")):v===1003?_(v,x(s==="ANY")):v===1004?_(v,x(r.sendFocus)):v===1005?_(v,4):v===1006?_(v,x(a==="SGR")):v===1015?_(v,4):v===1016?_(v,x(a==="SGR_PIXELS")):v===1048?_(v,1):v===47||v===1047||v===1049?_(v,x(h===p)):v===2004?_(v,x(r.bracketedPasteMode)):v===2026?_(v,x(r.synchronizedOutput)):_(v,0)}_updateAttrColor(e,t,n,r,s){return t===2?(e|=50331648,e&=-16777216,e|=Fc.fromColorRGB([n,r,s])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],s=0,a=0;do{if(r[a+s]=e.params[t+a],e.hasSubParams(t+a)){let l=e.getSubParams(t+a),d=0;do r[1]===5&&(s=1),r[a+d+1+s]=l[d];while(++d<l.length&&d+a+1+s<r.length);break}if(r[1]===5&&a+s>=2||r[1]===2&&a+s>=5)break;r[1]&&(s=1)}while(++a+t<e.length&&a+s<r.length);for(let l=2;l<r.length;++l)r[l]===-1&&(r[l]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=ln.fg,e.bg=ln.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let s=0;s<t;s++)n=e.params[s],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(s)?e.getSubParams(s)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=ln.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=ln.bg&16777215):n===38||n===48||n===58?s+=this._extractColor(e,s,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=ln.fg&16777215,r.bg&=-67108864,r.bg|=ln.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${_e.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ln.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!b1(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${_e.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>v1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>v1&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),s=n.shift();if(/^\d+$/.exec(r)){let a=parseInt(r);if(C1(a))if(s==="?")t.push({type:0,index:a});else{let l=y1(s);l&&t.push({type:1,index:a,color:l})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,s=n.findIndex(a=>a.startsWith("id="));return s!==-1&&(r=n[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let s=y1(n[r]);s&&this._onColor.fire([{type:1,index:this._specialColors[t],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let s=parseInt(n[r]);C1(s)&&t.push({type:2,index:s})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,ga),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(p3[e[0]],_n[e[1]]||ga),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ln.clone(),this._eraseAttrDataInternal=ln.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Pr;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=l=>(this._coreService.triggerDataEvent(`${_e.ESC}${l}${_e.ESC}\\`),!0),r=this._bufferService.buffer,s=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},p_=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(w1=e,e=t,t=w1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};p_=Kt([je(0,Gn)],p_);function C1(e){return 0<=e&&e<256}var _3=5e7,k1=12,x3=50,y3=class extends et{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>_3)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],s=this._action(r,t);if(s){let l=d=>performance.now()-n>=k1?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);s.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(l);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=k1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>x3&&(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()}},g_=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let d=t.addMarker(t.ybase+t.y),f={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(f,d)),this._dataByLinkId.set(f.id,f),f.id}let n=e,r=this._getEntryIdKey(n),s=this._entriesWithId.get(r);if(s)return this.addLineToLink(s.id,t.ybase+t.y),s.id;let a=t.addMarker(t.ybase+t.y),l={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._entriesWithId.set(l.key,l),this._dataByLinkId.set(l.id,l),l.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};g_=Kt([je(0,Gn)],g_);var E1=!1,v3=class extends et{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Vo),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new V5,this.optionsService=this._register(new e3(e)),this._instantiationService.setService(qn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(d_)),this._instantiationService.setService(Gn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(u_)),this._instantiationService.setService(wk,this._logService),this.coreService=this._register(this._instantiationService.createInstance(h_)),this._instantiationService.setService(Ra,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(f_)),this._instantiationService.setService(Sk,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(va)),this._instantiationService.setService($L,this.unicodeService),this._charsetService=this._instantiationService.createInstance(i3),this._instantiationService.setService(zL,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(g_),this._instantiationService.setService(Ck,this._oscLinkService),this._inputHandler=this._register(new g3(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Mn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Mn.forward(this._bufferService.onResize,this._onResize)),this._register(Mn.forward(this.coreService.onData,this._onData)),this._register(Mn.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new y3((t,n)=>this._inputHandler.parse(t,n))),this._register(Mn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!E1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),E1=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,n2),t=Math.max(t,r2),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(_1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(_1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Bt(()=>{for(let t of e)t.dispose()})}}},b3={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function S3(e,t,n,r){var l;let s={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?s.key=_e.ESC+"OA":s.key=_e.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?s.key=_e.ESC+"OD":s.key=_e.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?s.key=_e.ESC+"OC":s.key=_e.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?s.key=_e.ESC+"OB":s.key=_e.ESC+"[B");break;case 8:s.key=e.ctrlKey?"\b":_e.DEL,e.altKey&&(s.key=_e.ESC+s.key);break;case 9:if(e.shiftKey){s.key=_e.ESC+"[Z";break}s.key=_e.HT,s.cancel=!0;break;case 13:s.key=e.altKey?_e.ESC+_e.CR:_e.CR,s.cancel=!0;break;case 27:s.key=_e.ESC,e.altKey&&(s.key=_e.ESC+_e.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;a?s.key=_e.ESC+"[1;"+(a+1)+"D":t?s.key=_e.ESC+"OD":s.key=_e.ESC+"[D";break;case 39:if(e.metaKey)break;a?s.key=_e.ESC+"[1;"+(a+1)+"C":t?s.key=_e.ESC+"OC":s.key=_e.ESC+"[C";break;case 38:if(e.metaKey)break;a?s.key=_e.ESC+"[1;"+(a+1)+"A":t?s.key=_e.ESC+"OA":s.key=_e.ESC+"[A";break;case 40:if(e.metaKey)break;a?s.key=_e.ESC+"[1;"+(a+1)+"B":t?s.key=_e.ESC+"OB":s.key=_e.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(s.key=_e.ESC+"[2~");break;case 46:a?s.key=_e.ESC+"[3;"+(a+1)+"~":s.key=_e.ESC+"[3~";break;case 36:a?s.key=_e.ESC+"[1;"+(a+1)+"H":t?s.key=_e.ESC+"OH":s.key=_e.ESC+"[H";break;case 35:a?s.key=_e.ESC+"[1;"+(a+1)+"F":t?s.key=_e.ESC+"OF":s.key=_e.ESC+"[F";break;case 33:e.shiftKey?s.type=2:e.ctrlKey?s.key=_e.ESC+"[5;"+(a+1)+"~":s.key=_e.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:e.ctrlKey?s.key=_e.ESC+"[6;"+(a+1)+"~":s.key=_e.ESC+"[6~";break;case 112:a?s.key=_e.ESC+"[1;"+(a+1)+"P":s.key=_e.ESC+"OP";break;case 113:a?s.key=_e.ESC+"[1;"+(a+1)+"Q":s.key=_e.ESC+"OQ";break;case 114:a?s.key=_e.ESC+"[1;"+(a+1)+"R":s.key=_e.ESC+"OR";break;case 115:a?s.key=_e.ESC+"[1;"+(a+1)+"S":s.key=_e.ESC+"OS";break;case 116:a?s.key=_e.ESC+"[15;"+(a+1)+"~":s.key=_e.ESC+"[15~";break;case 117:a?s.key=_e.ESC+"[17;"+(a+1)+"~":s.key=_e.ESC+"[17~";break;case 118:a?s.key=_e.ESC+"[18;"+(a+1)+"~":s.key=_e.ESC+"[18~";break;case 119:a?s.key=_e.ESC+"[19;"+(a+1)+"~":s.key=_e.ESC+"[19~";break;case 120:a?s.key=_e.ESC+"[20;"+(a+1)+"~":s.key=_e.ESC+"[20~";break;case 121:a?s.key=_e.ESC+"[21;"+(a+1)+"~":s.key=_e.ESC+"[21~";break;case 122:a?s.key=_e.ESC+"[23;"+(a+1)+"~":s.key=_e.ESC+"[23~";break;case 123:a?s.key=_e.ESC+"[24;"+(a+1)+"~":s.key=_e.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?s.key=_e.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?s.key=_e.DEL:e.keyCode===219?s.key=_e.ESC:e.keyCode===220?s.key=_e.FS:e.keyCode===221&&(s.key=_e.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let d=(l=b3[e.keyCode])==null?void 0:l[e.shiftKey?1:0];if(d)s.key=_e.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(f);e.shiftKey&&(h=h.toUpperCase()),s.key=_e.ESC+h}else if(e.keyCode===32)s.key=_e.ESC+(e.ctrlKey?_e.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),s.key=_e.ESC+f,s.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?s.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(s.key=_e.US),e.key==="@"&&(s.key=_e.NUL));break}return s}var Jt=0,w3=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new nh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new nh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((s,a)=>this._getKey(s)-this._getKey(a)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let s=0;s<r.length;s++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[s]=e[t],t++):r[s]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Jt=this._search(t),Jt===-1)||this._getKey(this._array[Jt])!==t)return!1;do if(this._array[Jt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Jt),!0;while(++Jt<this._array.length&&this._getKey(this._array[Jt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((s,a)=>s-a),t=0,n=new Array(this._array.length-e.length),r=0;for(let s=0;s<this._array.length;s++)e[t]===s?t++:n[r++]=this._array[s];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Jt=this._search(e),!(Jt<0||Jt>=this._array.length)&&this._getKey(this._array[Jt])===e))do yield this._array[Jt];while(++Jt<this._array.length&&this._getKey(this._array[Jt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Jt=this._search(e),!(Jt<0||Jt>=this._array.length)&&this._getKey(this._array[Jt])===e))do t(this._array[Jt]);while(++Jt<this._array.length&&this._getKey(this._array[Jt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,s=this._getKey(this._array[r]);if(s>e)n=r-1;else if(s<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Vp=0,N1=0,C3=class extends et{constructor(){super(),this._decorations=new w3(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Bt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new k3(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,s=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,s=r+(a.options.width??1),e>=r&&e<s&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,s=>{Vp=s.options.x??0,N1=Vp+(s.options.width??1),e>=Vp&&e<N1&&(!n||(s.options.layer??"bottom")===n)&&r(s)})}},k3=class extends Ii{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Ht.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ht.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},E3=1e3,N3=class{constructor(e,t=E3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let s=r-this._lastRefreshMs,a=this._debounceThresholdMS-s;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},j1=20,rh=class extends et{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new N3(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
82
- `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Fe(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Bt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<j1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
83
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===j1+1&&(this._liveRegion.textContent+=Ig.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let s=e;s<=t;s++){let a=n.lines.get(n.ydisp+s),l=[],d=(a==null?void 0:a.translateToString(!0,void 0,void 0,l))||"",f=(n.ydisp+s+1).toString(),h=this._rowElements[s];h&&(d.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=d,this._rowColumns.set(h,l)),h.setAttribute("aria-posinset",f),h.setAttribute("aria-setsize",r),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],s=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(s===a||e.relatedTarget!==r)return;let l,d;if(t===0?(l=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(l=this._rowElements.shift(),d=n,this._rowContainer.removeChild(l)),l.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:((d=r.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let s=({node:f,offset:h})=>{let p=f instanceof Text?f.parentNode:f,g=parseInt(p==null?void 0:p.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(p);if(!_)return console.warn("columns is null. Race condition?"),null;let x=h<_.length?_[h]:_.slice(-1)[0]+1;return x>=this._terminal.cols&&(++g,x=0),{row:g,column:x}},a=s(t),l=s(n);if(!(!a||!l)){if(a.row>l.row||a.row===l.row&&a.column>=l.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(l.row-a.row)*this._terminal.cols-a.column+l.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var s,a;e.style.transform="";let t=e.getBoundingClientRect().width,n=(a=(s=this._rowColumns.get(e))==null?void 0:s.slice(-1))==null?void 0:a[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};rh=Kt([je(1,lx),je(2,Ys),je(3,Xs)],rh);var __=class extends et{constructor(e,t,n,r,s){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Bt(()=>{var a;ja(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Fe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Fe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Fe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Fe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let s=n[r];if(s.classList.contains("xterm"))break;if(s.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var r,s;(!this._activeProviderReplies||!t)&&((r=this._activeProviderReplies)==null||r.forEach(a=>{a==null||a.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,l]of this._linkProviderService.linkProviders.entries())t?(s=this._activeProviderReplies)!=null&&s.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):l.provideLinks(e.y,d=>{var h,p;if(this._isMouseOut)return;let f=d==null?void 0:d.map(g=>({link:g}));(h=this._activeProviderReplies)==null||h.set(a,f),n=this._checkLinkProviderResult(a,e,n),((p=this._activeProviderReplies)==null?void 0:p.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let s=t.get(r);if(s)for(let a=0;a<s.length;a++){let l=s[a],d=l.link.range.start.y<e?0:l.link.range.start.x,f=l.link.range.end.y>e?this._bufferService.cols:l.link.range.end.x;for(let h=d;h<=f;h++){if(n.has(h)){s.splice(a--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var a;if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),s=!1;for(let l=0;l<e;l++)(!this._activeProviderReplies.has(l)||this._activeProviderReplies.get(l))&&(s=!0);if(!s&&r){let l=r.find(d=>this._linkAtPosition(d.link,t));l&&(n=!0,this._handleNewLink(l))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let l=0;l<this._activeProviderReplies.size;l++){let d=(a=this._activeProviderReplies.get(l))==null?void 0:a.find(f=>this._linkAtPosition(f.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j3(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ja(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.pointerCursor},set:n=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.underline},set:n=>{var r,s,a;(r=this._currentLink)!=null&&r.state&&((a=(s=this._currentLink)==null?void 0:s.state)==null?void 0:a.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,n){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(e,t,n){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,s=t.y*this._bufferService.cols+t.x;return n<=s&&s<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,s){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:s}}};__=Kt([je(1,cx),je(2,Xs),je(3,Gn),je(4,Ek)],__);function j3(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var T3=class extends v3{constructor(e={}){super(e),this._linkifier=this._register(new Vo),this.browser=Wk,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Vo),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(C3),this._instantiationService.setService(Uc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(x5),this._instantiationService.setService(Ek,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bg)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Mn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Mn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Mn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Mn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Bt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let s=Mt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${_e.ESC}]${r};${m3(s)}${Uk.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=cn.toColor(...t.color));else{let a=n;this._themeService.modifyColors(l=>l[a]=cn.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(rh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,s=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*s,l=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=l+"px",this.textarea.style.width=a+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Fe(this.element,"copy",t=>{this.hasSelection()&&RL(t,this._selectionService)}));let e=t=>ML(t,this.textarea,this.coreService,this.optionsService);this._register(Fe(this.textarea,"paste",e)),this._register(Fe(this.element,"paste",e)),Gk?this._register(Fe(this.element,"mousedown",t=>{t.button===2&&BS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Fe(this.element,"contextmenu",t=>{BS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),_x&&this._register(Fe(this.element,"auxclick",t=>{t.button===1&&_k(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Fe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Fe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Fe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Fe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Fe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Fe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Fe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var s;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((s=this.element)==null?void 0:s.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Fe(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Og.get()),Yk||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(g5,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ys,this._coreBrowserService),this._register(Fe(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Fe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(i_,this._document,this._helperContainer),this._instantiationService.setService(Mh,this._charSizeService),this._themeService=this._instantiationService.createInstance(c_),this._instantiationService.setService(Yo,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(eh),this._instantiationService.setService(kk,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(o_,this.rows,this.screenElement)),this._instantiationService.setService(Xs,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(n_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(a_),this._instantiationService.setService(cx,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(__,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(e_,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(l_,this.element,this.screenElement,r)),this._instantiationService.setService(FL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(Mn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(t_,this.screenElement)),this._register(Fe(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(rh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zd,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zd,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(s_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){var h,p,g,_,x;let l=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!l)return!1;let d,f;switch(a.overrideType||a.type){case"mousemove":f=32,a.buttons===void 0?(d=3,a.button!==void 0&&(d=a.button<3?a.button:3)):d=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":f=0,d=a.button<3?a.button:3;break;case"mousedown":f=1,d=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let v=a.deltaY;if(v===0||e.coreMouseService.consumeWheelEvent(a,(_=(g=(p=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:p.device)==null?void 0:g.cell)==null?void 0:_.height,(x=e._coreBrowserService)==null?void 0:x.dpr)===0)return!1;f=v<0?0:1,d=4;break;default:return!1}return f===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:l.col,row:l.row,x:l.x,y:l.y,button:d,action:f,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s={mouseup:a=>(n(a),a.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(a)),wheel:a=>(n(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&n(a)},mousemove:a=>{a.buttons||n(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),a&8?r.mousemove||(t.addEventListener("mousemove",s.mousemove),r.mousemove=s.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),a&16?r.wheel||(t.addEventListener("wheel",s.wheel,{passive:!1}),r.wheel=s.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),a&2?r.mouseup||(r.mouseup=s.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),a&4?r.mousedrag||(r.mousedrag=s.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Fe(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return n(a),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(a)})),this._register(Fe(t,"wheel",a=>{var l,d,f,h,p;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(h=(f=(d=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:d.device)==null?void 0:f.cell)==null?void 0:h.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return this.cancel(a,!0);let g=_e.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){gk(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=S3(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===_e.ETX||n.key===_e.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(A3(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(ln));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(_e.ESC+"[I"):this.coreService.triggerDataEvent(_e.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[6;${s};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function A3(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var D3=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},L3=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Pr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},T1=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new L3(t)}getNullCell(){return new Pr}},R3=class extends et{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new T1(this._core.buffers.normal,"normal"),this._alternate=new T1(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)}},M3=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},O3=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},I3=["cols","rows"],os=0,P3=class extends et{constructor(e){super(),this._core=this._register(new T3(e)),this._addonManager=this._register(new D3),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,s)=>{this._checkReadonlyOptions(r),this._core.options[r]=s};for(let r in this._core.options){let s={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,s)}}_checkReadonlyOptions(e){if(I3.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new M3(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new O3(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new R3(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
84
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Og.get()},set promptLabel(e){Og.set(e)},get tooMuchOutput(){return Ig.get()},set tooMuchOutput(e){Ig.set(e)}}}_verifyIntegers(...e){for(os of e)if(os===1/0||isNaN(os)||os%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(os of e)if(os&&(os===1/0||isNaN(os)||os%1!==0||os<0))throw new Error("This API only accepts positive integers")}};/**
85
- * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
86
- * @license MIT
87
- *
88
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
89
- * @license MIT
90
- *
91
- * Originally forked from (with the author's permission):
92
- * Fabrice Bellard's javascript vt100 for jslinux:
93
- * http://bellard.org/jslinux/
94
- * Copyright (c) 2011 Fabrice Bellard
95
- */var B3=2,z3=1,$3=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let n=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(n._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,r=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(r.getPropertyValue("height")),a=Math.max(0,parseInt(r.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),d={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},f=d.top+d.bottom,h=d.right+d.left,p=s-f,g=a-h-n;return{cols:Math.max(B3,Math.floor(g/t.css.cell.width)),rows:Math.max(z3,Math.floor(p/t.css.cell.height))}}};function H3({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const s=C.useRef(null),a=C.useRef(e),l=C.useRef(null),d=C.useRef(null),f=Kr(p=>p.writeSession),h=Kr(p=>p.resizeSession);return C.useEffect(()=>{a.current=e},[e]),C.useEffect(()=>{if(!n)return;const p=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),C.useEffect(()=>{if(!s.current)return;const p=new P3({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new $3;p.loadAddon(g),l.current={term:p,fitAddon:g},s.current.addEventListener("keydown",S=>{S.key==="Escape"&&n&&(S.preventDefault(),S.stopPropagation(),n())}),p.open(s.current);const _=s.current.querySelector(".xterm");_&&(_.style.padding="8px"),g.fit(),r&&setTimeout(()=>{p.focus()},150);const x=new ResizeObserver(()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{requestAnimationFrame(()=>{var w;g.fit&&g.fit();const S=(w=l.current)==null?void 0:w.term;S&&S.cols>0&&S.rows>0&&h(a.current,S.cols,S.rows)})},100)});x.observe(s.current),p.onData(S=>{if(S==="\x1B"&&n){n();return}f(a.current,S)}),p.onKey(S=>{S.key==="\x1B"&&n&&(S.domEvent.stopPropagation(),n())});const v=Ft.subscribe(S=>{const w=S.payload;if(S.type==="terminal.output"&&(w==null?void 0:w.sessionId)===a.current){const k=w==null?void 0:w.data;k&&p.write(k)}});return()=>{v(),x.disconnect(),d.current&&clearTimeout(d.current),p.dispose(),l.current=null}},[e,f,h]),c.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[c.jsx("div",{}),c.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:c.jsx(rk,{})})]}),c.jsx("div",{ref:s,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),n())}})]})}const i2="openfox-chat-textarea";function a2(){const e=document.getElementById(i2);e&&e.focus()}function F3(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 U3({isOpen:e,onClose:t}){const n=Kr(v=>v.createSession),r=Kr(v=>v.killSession),s=Kr(v=>v.sessions),a=Kr(v=>v.setWorkdir),l=Kr(v=>v.fetchSessions),d=Ut(v=>v.currentProject),[f,h]=C.useState(!0),p=C.useRef(null),g=C.useRef(!1),_=C.useRef(!1),x=C.useCallback(()=>{t()},[t]);return C.useEffect(()=>{d!=null&&d.workdir&&a(d.workdir)},[d==null?void 0:d.workdir,a]),C.useEffect(()=>{e?(h(!0),l(d==null?void 0:d.id).finally(()=>h(!1))):a2()},[e,l,d==null?void 0:d.id]),C.useEffect(()=>{e&&s.length===0&&!f&&!_.current&&(_.current=!0,n(void 0,d==null?void 0:d.id))},[e,s.length,f,n,d==null?void 0:d.id]),C.useEffect(()=>{e?(g.current=!0,setTimeout(()=>{var v;(v=p.current)==null||v.focus(),setTimeout(()=>{g.current=!1},200)},100)):_.current=!1},[e]),C.useEffect(()=>{if(!e)return;const v=S=>{g.current||S.key==="Escape"&&(S.preventDefault(),t())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[e,t]),e?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:x}),c.jsxs("div",{ref:p,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:v=>v.stopPropagation(),onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),x())},children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:()=>n(void 0,d==null?void 0:d.id),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:c.jsx(XD,{})}),c.jsx("button",{onClick:t,className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:c.jsx(Hc,{})})]})]}),c.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:f?c.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):s.length===0?c.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"mb-4",children:"No terminal sessions"}),c.jsx("button",{onClick:()=>n(void 0,d==null?void 0:d.id),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):c.jsx("div",{className:`grid ${F3(s.length)} gap-2 h-full auto-rows-fr`,children:s.map(v=>c.jsx(H3,{sessionId:v.id,onClose:()=>r(v.id),onEscape:x,autoFocus:s.length===1},v.id))})})]})]}):null}function Gc({items:e,trigger:t,minWidth:n="120px",isOpen:r,onOpenChange:s}){const[a,l]=C.useState(!1),d=r!==void 0,f=d?r:a,h=I=>{if(d){const W=typeof I=="function"?I(a):I;s==null||s(W)}else l(I)},[p,g]=C.useState(null),_=C.useRef(null),x=C.useRef(null),[v,S]=C.useState(0),w=C.useRef(0),k=C.useRef(e),j=C.useCallback(()=>{if(!_.current)return;const I=_.current.getBoundingClientRect(),W=200,L=window.innerHeight-I.bottom<W;g({top:L?I.top-W-4:I.bottom+4,left:I.left,alignToTop:L})},[]);C.useEffect(()=>{k.current=e},[e]),C.useEffect(()=>{function I(W){if(x.current){const z=W.target;x.current.contains(z)||h(!1)}}return f&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[f]),C.useEffect(()=>{f&&j()},[f,j]),C.useEffect(()=>{if(!f)return;setTimeout(()=>{var W;(W=x.current)==null||W.focus()},0);function I(W){const z=k.current,L=z.filter(D=>!T(D)),U=A(w.current,z);switch(W.key){case"ArrowDown":if(W.preventDefault(),W.stopPropagation(),U<L.length-1){const D=P(w.current+1,z);w.current=D,S(D)}break;case"ArrowUp":if(W.preventDefault(),W.stopPropagation(),U>0){const D=R(w.current-1,z);w.current=D,S(D)}break;case"Enter":W.preventDefault(),W.stopPropagation(),q(w.current,z);break;case"Escape":W.preventDefault(),W.stopPropagation(),h(!1);break}}return window.addEventListener("keydown",I,!0),()=>window.removeEventListener("keydown",I,!0)},[f,e]);function T(I){var L;const W=I.label;return W?String(((L=W.props)==null?void 0:L.className)??"").includes("cursor-default"):!1}function A(I,W){let z=0;for(let L=0;L<I;L++){const U=W[L];U&&!T(U)&&z++}return z}function P(I,W){for(let z=I;z<W.length;z++){const L=W[z];if(L&&!T(L))return z}return I}function R(I,W){for(let z=I;z>=0;z--){const L=W[z];if(L&&!T(L))return z}return I}function q(I,W){var L;const z=W[I];!z||T(z)||((L=z.onClick)==null||L.call(z),z.href&&(window.history.pushState(null,"",z.href),window.dispatchEvent(new PopStateEvent("popstate"))),h(!1))}C.useEffect(()=>{f&&(S(e.findIndex(I=>!T(I))),w.current=e.findIndex(I=>!T(I)))},[f,e]);const J=I=>{I.stopPropagation(),f||j(),h(!f)},ne=p&&c.jsx("div",{ref:x,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${p.alignToTop?"mb-1":"mt-1"}`,style:{top:p.top,left:p.left,minWidth:n},tabIndex:-1,children:e.map((I,W)=>{const L=!T(I)&&W===v,U=c.jsxs(c.Fragment,{children:[I.icon&&c.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:I.icon}),I.label]});return I.href?c.jsx(gr,{href:I.href,onClick:D=>{var N;(N=I.onClick)==null||N.call(I,D),h(!1)},onAuxClick:()=>h(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${I.danger?"text-accent-error hover:bg-accent-error/10":L?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${W!==e.length-1?"border-b border-border":""}`,children:U},W):c.jsx("button",{onClick:D=>{var N;(N=I.onClick)==null||N.call(I,D),I.closeOnClick!==!1&&h(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${I.danger?"text-accent-error hover:bg-accent-error/10":L?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${W!==e.length-1?"border-b border-border":""}`,children:U},W)})});return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"relative",children:c.jsx("div",{ref:_,onClick:J,children:t})}),f&&La.createPortal(ne,document.body)]})}function V3({projects:e,currentProject:t}){const n=Ut(l=>l.loadProject),r=Ut(l=>l.toggleStar),a=C.useMemo(()=>{const l=e.filter(f=>f.isStarred).sort((f,h)=>f.name.localeCompare(h.name)),d=e.filter(f=>!f.isStarred).sort((f,h)=>f.name.localeCompare(h.name));return[...l,...d]},[e]).map(l=>({label:c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[c.jsx("span",{className:"truncate flex-1",children:l.name}),c.jsx("button",{onClick:d=>{d.stopPropagation(),d.preventDefault(),d.nativeEvent.stopImmediatePropagation(),r(l.id,!l.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:l.isStarred?"Unstar project":"Star project",children:l.isStarred?c.jsx(ZD,{className:"w-3.5 h-3.5 text-yellow-500"}):c.jsx(eL,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:l.id===t.id?c.jsx(gs,{}):void 0,href:`/p/${l.id}`,closeOnClick:!0,onClick:()=>{n(l.id)}}));return c.jsx(Gc,{items:a,trigger:c.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:t.name,children:[t.name,c.jsx(Br,{})]}),minWidth:"250px"})}function o2(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],s=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${r} ${s}/${a}/${l}`}function Ph(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function W3(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),s=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=Math.floor((r.getTime()-s.getTime())/(1e3*60*60*24)),l=Ph(e);if(a===0)return`today ${l}`;if(a===1)return`yesterday ${l}`;if(a<7)return`${a} days ago ${l}`;{const d=t.getFullYear(),f=String(t.getMonth()+1).padStart(2,"0"),h=String(t.getDate()).padStart(2,"0");return`${d}/${f}/${h} ${l}`}}function l2(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 G3(e){const{year:t,month:n,day:r}=l2(e);return`${t}-${n}-${r}`}function c2(e){const t=new Map;for(const s of e){const a=G3(s.updatedAt);t.has(a)||t.set(a,[]),t.get(a).push(s)}for(const[s,a]of t)a.sort((l,d)=>{const f=new Date(l.updatedAt).getTime();return new Date(d.updatedAt).getTime()-f});const n=Array.from(t.keys()).sort((s,a)=>a.localeCompare(s)),r=new Map;for(const s of n)r.set(s,t.get(s));return r}function q3({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:s}){var p;const a=xe(g=>g.loadSession),l=e.filter(g=>g.projectId===t.id).slice(0,15),d=c2(l),f=C.useMemo(()=>{const g=[];g.push({label:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx($i,{className:"w-4 h-4 text-accent-primary"}),c.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[_,x]of d){const v=x[0];if(v){g.push({label:c.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:o2(v.updatedAt)}),onClick:()=>{}});for(const S of x)g.push({label:c.jsxs("div",{className:"min-w-[160px]",children:[c.jsx("div",{className:"truncate text-sm",children:S.title??S.id.slice(0,8)}),c.jsx("div",{className:"text-text-muted text-xs",children:Ph(S.updatedAt)})]}),icon:S.id===(n==null?void 0:n.id)?c.jsx(gs,{}):void 0,href:`/p/${t.id}/s/${S.id}`,onClick:()=>{a(S.id)}})}}return g},[t.id,d,n==null?void 0:n.id]),h=n?((p=n.metadata)==null?void 0:p.title)??n.id.slice(0,8):"No session selected";return c.jsx(Gc,{items:f,isOpen:r,onOpenChange:s,trigger:c.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:h,"data-testid":"header-session-dropdown",children:[h,c.jsx(Br,{})]}),minWidth:"280px"})}function K3({items:e,trigger:t,isActive:n=!1}){const[r,s]=C.useState(!1),a=C.useRef(null);return C.useEffect(()=>{function l(d){a.current&&!a.current.contains(d.target)&&s(!1)}if(r)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]),c.jsxs("div",{className:"relative",ref:a,children:[c.jsxs("button",{type:"button",onClick:()=>s(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?c.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,c.jsx(Br,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&c.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((l,d)=>{const f=l.label&&typeof l.label=="object"&&l.label.type===gr?l.label:null;if(f){const h=f.props.href||"";return c.jsxs(gr,{href:h,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[l.icon,f.props.children]},d)}return l.href?c.jsxs("a",{href:l.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[l.icon,l.label]},d):c.jsxs("button",{type:"button",onClick:()=>{var h;(h=l.onClick)==null||h.call(l),s(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[l.icon,l.label]},d)})})]})}function Y3({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const s=t.filter(l=>l.projectId===e.id).sort((l,d)=>new Date(d.updatedAt).getTime()-new Date(l.updatedAt).getTime()).slice(0,5),a=[{label:c.jsxs(gr,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[c.jsx($i,{className:"w-3 h-3 text-accent-primary"}),c.jsx("span",{className:"text-sm",children:"New Session"})]})},...s.map(l=>({label:c.jsx(gr,{href:`/p/${e.id}/s/${l.id}`,className:"flex items-center gap-2 truncate text-sm",children:c.jsx("span",{children:l.title??l.id.slice(0,8)})}),icon:l.id===(n==null?void 0:n.id)?c.jsx(gs,{className:"w-3 h-3"}):void 0})),{label:c.jsxs(gr,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[c.jsx($D,{className:"w-3 h-3"}),c.jsx("span",{className:"text-sm",children:"Projects"})]})}];return c.jsx(K3,{items:a,trigger:c.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function X3({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=C.useState(!1),[s,a]=C.useState(!1),[l,d]=C.useState(!!document.fullscreenElement);C.useEffect(()=>{const A=()=>d(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",A),()=>document.removeEventListener("fullscreenchange",A)},[]);const[f]=Jr(),h=f.startsWith("/p/"),p=/^\/p\/[^/]+\/s\/[^/]+$/.test(f),g=xe(A=>A.currentSession),_=xe(A=>A.sessions),x=Ut(A=>A.currentProject),v=Ut(A=>A.projects),S=Ot(A=>A.startAutoRefresh),w=Ot(A=>A.stopAutoRefresh),k=Kr(A=>A.setOpen),j=Kr(A=>A.isOpen);C.useEffect(()=>{const A=()=>a(!0);return window.addEventListener("open-session-dropdown",A),()=>window.removeEventListener("open-session-dropdown",A)},[]);const T=tx();return ok(T.terminalToggle,()=>{Kr.getState().toggleOpen()},{capture:!0}),C.useEffect(()=>(S(),()=>w()),[S,w]),c.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&h&&c.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle session list",children:c.jsx(TS,{})}),c.jsx(gr,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),x&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),c.jsx("span",{className:"hidden md:inline",children:c.jsx(V3,{projects:v,currentProject:x})}),c.jsx("span",{className:"md:hidden",children:c.jsx(Y3,{currentProject:x,sessions:_,currentSession:g,projectIdFromUrl:h&&f.split("/")[2]||null},x==null?void 0:x.id)}),c.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),c.jsx("span",{className:"hidden md:inline",children:c.jsx(q3,{sessions:_,currentProject:x,currentSession:g,isOpen:s,onOpenChange:a})})]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p&&c.jsx("button",{onClick:()=>{var A,P,R;document.fullscreenElement?(A=document.exitFullscreen)==null||A.call(document):(R=(P=document.documentElement).requestFullscreen)==null||R.call(P)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:l?"Exit fullscreen":"Enter fullscreen",children:l?c.jsx(VD,{}):c.jsx(WD,{})}),h&&c.jsx("button",{onClick:()=>k(!j),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${j?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:c.jsx(nL,{})}),c.jsx("button",{onClick:()=>r(!0),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Settings",children:c.jsx(QD,{})}),c.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),window.location.reload()},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:c.jsx(qD,{})}),t&&p&&c.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle sidebar",children:c.jsx(TS,{})})]}),c.jsx(jL,{isOpen:n,onClose:()=>r(!1)}),c.jsx(U3,{isOpen:j,onClose:()=>k(!1)})]})}function Q3({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:s="Cancel",saveLabel:a=n?"Saving...":"Save"}){return c.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:e,children:s}),c.jsx(Ze,{variant:"primary",onClick:t,disabled:r??n,children:a})]})}function J3({isOpen:e,onClose:t,project:n}){const r=Ut(A=>A.updateProject),s=()=>{try{Ft.send("context.checkDynamic",{})}catch{}t()},[a,l]=C.useState(n.customInstructions??""),[d,f]=C.useState(n.dangerLevel??""),[h,p]=C.useState(!1),[g,_]=C.useState(!1),[x,v]=C.useState(!1),S=h||g;C.useEffect(()=>{l(n.customInstructions??""),f(n.dangerLevel??""),p(!1),_(!1)},[n]);const w=A=>{l(A.target.value),p(!0)},k=A=>{f(A),_(!0)},j=async()=>{v(!0);const A=d===""?null:d;await r(n.id,{customInstructions:a||null,dangerLevel:A}),v(!1),p(!1),_(!1),s()},T=()=>{l(n.customInstructions??""),f(n.dangerLevel??""),p(!1),_(!1),s()};return c.jsx(Et,{isOpen:e,onClose:T,title:`${n.name} Settings`,size:"lg",footer:c.jsx(Q3,{onCancel:T,onSave:j,saving:x,saveDisabled:!S||x}),children:c.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),c.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Default danger level for new sessions in this project. Existing sessions are not affected."}),c.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[c.jsx("button",{type:"button",onClick:()=>k(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${d===""?"bg-bg-tertiary text-text-primary border border-border":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Use global default (Normal)",children:"Default"}),c.jsx("button",{type:"button",onClick:()=>k("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${d==="normal"?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),c.jsx("button",{type:"button",onClick:()=>k("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${d==="dangerous"?"bg-red-500/20 text-red-400 border border-red-500/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),c.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),c.jsxs("div",{className:"flex-1 min-h-[150px] pb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),c.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files."}),c.jsx("textarea",{value:a,onChange:w,placeholder:"Enter project-specific instructions...",className:"w-full h-full px-3 py-2 mb-3 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:x})]})]})})}const Z3={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},eM="M6 18L18 6M6 6l12 12";function qc({onClick:e,className:t="",size:n="md",variant:r="default"}){const s=r==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":r==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":r==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return c.jsx(Dh,{onClick:e,icon:eM,iconSize:Z3[n],className:`${s} ${t}`,title:"Close"})}function u2({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Jr(),[s,a]=C.useState(!1),l=xe(P=>P.sessions),d=xe(P=>P.currentSession),f=xe(P=>P.unreadSessionIds),h=xe(P=>P.deleteSession),p=xe(P=>P.deleteAllSessions),g=xe(P=>P.loadMoreSessions),_=xe(P=>P.sessionsHasMore),x=xe(P=>P.sessionsPaginationLoading),v=Ut(P=>P.currentProject),S=C.useRef(null),w=C.useCallback(()=>{_&&!x&&v&&g(v.id)},[_,x,v,g]);C.useEffect(()=>{if(!S.current||!_)return;const P=new IntersectionObserver(R=>{const q=R[0];q&&q.isIntersecting&&w()},{threshold:.1});return P.observe(S.current),()=>P.disconnect()},[_,w]);const k=l.filter(P=>P.projectId===(v==null?void 0:v.id)),j=(P,R)=>{R==null||R.stopPropagation(),confirm("Delete this session?")&&(h(P),(d==null?void 0:d.id)===P&&r(`/p/${e}`))},T=(P,R)=>{R==null||R.stopPropagation();const q=l.find(I=>I.id===P),J=(q==null?void 0:q.title)??P.slice(0,6),ne=prompt("Rename session:",J);if(ne!==null&&ne.trim()!==""){const I=xe.getState().renameSession;I(P,ne.trim())}},A=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(p(e),r(`/p/${e}`))};return c.jsxs(c.Fragment,{children:[t&&n&&c.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),c.jsxs("aside",{className:`
96
- ${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
97
- md:relative md:h-auto md:translate-x-0
98
-
99
- fixed z-50 h-[calc(100vh-32px)]
100
- w-[300px] bg-secondary border-r border-border flex flex-col
101
- transition-all duration-300 ease-in-out
102
- ${t?"translate-x-0":"-translate-x-full"}
103
- `,children:[c.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[c.jsx(gr,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),c.jsx(Gc,{items:[{label:"Edit project settings",onClick:()=>a(!0)},{label:"Delete all sessions",onClick:A,danger:!0}],trigger:c.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:c.jsx(Q_,{})})}),n&&c.jsx(qc,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),v&&c.jsx(J3,{isOpen:s,onClose:()=>a(!1),project:v}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:k.length===0?c.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"divide-y divide-border",children:tM(k,d,f,j,T,e)}),x&&c.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),c.jsx("div",{ref:S,className:"h-px"})]})})]})]})}function tM(e,t,n,r,s,a){const l=c2(e);return Array.from(l).map(([d,f])=>{const h=f[0];return h?c.jsxs("div",{children:[c.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:o2(h.updatedAt)}),f.map(p=>{const g=(t==null?void 0:t.id)===p.id,_=n.includes(p.id),x=p.isRunning;return c.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${g?"bg-bg-tertiary":""}`,children:c.jsxs(gr,{href:`/p/${a}/s/${p.id}`,className:`block ${g?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[c.jsxs("div",{className:"flex justify-between items-center mb-1",children:[c.jsx("span",{className:`font-medium truncate text-sm ${g?"text-accent-primary":"text-text-primary"}`,children:p.title??p.id.slice(0,6)}),c.jsx(Gc,{items:[{label:"Rename session",onClick:v=>s(p.id,v)},{label:"Delete session",onClick:v=>r(p.id,v),danger:!0}],trigger:c.jsx("button",{onClick:v=>v.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:c.jsx(Q_,{})})})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[x?c.jsx(JD,{}):_&&!g?c.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,c.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Ph(p.updatedAt)}),c.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[p.messageCount," messages"]})]})]})},p.id)})]},d):null})}const A1=["⠋","⠙","⠹","⠸","⠼","⠴"];function nM(){var d;const e=Ut(f=>f.currentProject),t=xe(f=>f.currentSession),n=Ah(),r=!1,s=C.useRef(0),a=C.useRef(null);C.useEffect(()=>(n?(a.current=window.setInterval(()=>{s.current=(s.current+1)%A1.length,l()},150),l()):(a.current&&(clearInterval(a.current),a.current=null),l()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t,r]);const l=()=>{var g;const h=(g=t==null?void 0:t.metadata)==null?void 0:g.title,p=n?`${A1[s.current]} `:"";e&&h?document.title=`${p}${e.name} - ${h} | OpenFox`:e?document.title=`${p}${e.name} | OpenFox`:document.title=`${p}OpenFox`};return typeof window<"u"&&((d=t==null?void 0:t.metadata)!=null&&d.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function d2(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],s=n[n.length-1],a=n.slice(1,-1).join("/"),l=t-r.length-s.length-3;if(l<0)return e;const d=a.slice(0,Math.floor(l/2)),f=a.slice(-Math.ceil(l/2));return`/${r}/${d}...${f}/${s}`}function h2({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const s=()=>{r(),t()};return c.jsx(Et,{isOpen:e,onClose:t,title:"Delete Project",size:"sm",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project"," ",c.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",onClick:t,children:"Cancel"}),c.jsx(Ze,{variant:"danger",onClick:s,children:"Delete"})]})]})})}const Bh=C.forwardRef(({className:e="",...t},n)=>c.jsx("input",{ref:n,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...t}));Bh.displayName="Input";function rM(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 f2({isOpen:e,onClose:t,path:n,onRetry:r}){const[s,a]=C.useState(!1),[l,d]=C.useState(null),[f,h]=C.useState(null);C.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const A=await(await Ne("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:A.sudoAvailable,userInGroup:A.userInGroup,groupHasWrite:A.groupHasWrite,groupName:A.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},g=C.useCallback(async T=>{a(!0),d(null);try{const P=await(await Ne("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:T})})).json();P.success?(r(),t()):P.sudoAvailable?d("Failed to fix permissions: "+(P.error||"Unknown error")):d(`Passwordless sudo is not available. Please fix permissions manually:
104
-
105
- `+(T==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(A){d("Failed to fix permissions: "+(A instanceof Error?A.message:"Unknown error"))}finally{a(!1)}},[n,r,t]),_=(f==null?void 0:f.userInGroup)??!1,x=(f==null?void 0:f.groupHasWrite)??!1,v=(f==null?void 0:f.sudoAvailable)??!1,S=(f==null?void 0:f.groupName)??"",w=_&&!x,k=!_&&x,j=!_&&!x;return c.jsx(Et,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"text-sm text-text-secondary",children:[c.jsx("p",{children:w?c.jsxs(c.Fragment,{children:["The group ",c.jsx("strong",{children:S})," doesn't have write access:"]}):k?c.jsxs(c.Fragment,{children:["You're not a member of group ",c.jsx("strong",{children:S}),":"]}):c.jsxs(c.Fragment,{children:["You're not a member of group ",c.jsx("strong",{children:S})," and it doesn't have write access:"]})}),c.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),l?c.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:l}):f?c.jsxs("div",{className:"flex flex-col gap-2",children:[w&&c.jsxs(c.Fragment,{children:[c.jsx(Ze,{type:"button",variant:"primary",onClick:()=>g("group"),disabled:s||!v,className:"w-full",children:s?"Granting access...":"Extend group permissions"}),c.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),c.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),k&&c.jsxs(c.Fragment,{children:[c.jsx(Ze,{type:"button",variant:"primary",onClick:()=>g("join_group"),disabled:s||!v,className:"w-full",children:s?"Joining group...":"Join group"}),c.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),c.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",S," $USER"]})]}),j&&c.jsxs(c.Fragment,{children:[c.jsx(Ze,{type:"button",variant:"primary",onClick:()=>g("join_group_and_group"),disabled:s||!v,className:"w-full",children:s?"Joining group...":"Join group & grant write permissions"}),c.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),c.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",S," $USER",c.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!v&&!l&&c.jsxs("div",{className:"text-xs text-text-secondary",children:[c.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),c.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),c.jsx("div",{className:"flex justify-end",children:c.jsx(Ze,{type:"button",variant:"secondary",onClick:t,disabled:s,children:"Cancel"})})]}):null]})})}function sM({isOpen:e,onClose:t}){const[,n]=Jr(),[r,s]=C.useState(""),[a,l]=C.useState(null),[d,f]=C.useState(!1),[h,p]=C.useState(""),[g,_]=C.useState(null),x=C.useRef(null);C.useEffect(()=>{e&&(Ne("/api/config").then(A=>A.json()).then(A=>{A.workdir&&p(A.workdir)}),s(""),l(null),f(!1),_(null),setTimeout(()=>{var A;(A=x.current)==null||A.focus()},100))},[e]);const v=C.useCallback(async A=>{A.preventDefault();const P=rM(r);if(!P.valid){l(P.error);return}const R=`${h}/${r}`;await k(R)},[r,n,t,h]),S=C.useCallback(()=>{_(null)},[]),w=C.useCallback(async()=>{const A=`${h}/${r}`;await k(A)},[h,r,n,t,_,l,f]);async function k(A){f(!0),l(null),_(null);try{const P=await Ne("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,workdir:A})});if(!P.ok){const J=await P.json().catch(()=>({}));if(J.code==="EACCES"){_(A),f(!1);return}throw new Error(J.error||"Failed to create project")}const q=(await P.json()).project;t(),n(`/p/${q.id}`)}catch(P){l(P instanceof Error?P.message:"Failed to create project"),f(!1)}}const j=C.useCallback(()=>{s(""),l(null),t()},[t]),T=r?`${h}/${r}`:"";return c.jsxs(c.Fragment,{children:[c.jsx(Et,{isOpen:e,onClose:j,title:"Create New Project",size:"sm",children:c.jsxs("form",{onSubmit:v,className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),c.jsx(Bh,{ref:x,id:"project-name",value:r,onChange:A=>{s(A.target.value),l(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),r&&c.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",c.jsx("span",{className:"font-mono",children:T})]}),a&&c.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:a})]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{type:"button",variant:"secondary",onClick:j,disabled:d,children:"Cancel"}),c.jsx(Ze,{type:"submit",variant:"primary",disabled:d||!r.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx($i,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&c.jsx(f2,{isOpen:!!g,onClose:S,path:g,onRetry:w})]})}const iM={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Kc({size:e="md",className:t=""}){return c.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${iM[e]} ${t}`})}function aM({text:e,...t}){return c.jsxs("div",{className:"text-center",children:[c.jsx(Kc,{...t,className:"mx-auto mb-4"}),e&&c.jsx("div",{className:"text-text-secondary",children:e})]})}function m2({onSelect:e,onClose:t,initialPath:n}){const[r,s]=C.useState(null),[a,l]=C.useState(!0),[d,f]=C.useState(""),[h,p]=C.useState(-1),g=C.useRef(null),_=C.useRef([]),x=C.useCallback(async j=>{l(!0),f(""),p(-1);try{const T=j?`/api/directories?path=${encodeURIComponent(j)}`:"/api/directories",P=await(await Ne(T)).json();s(P)}catch(T){console.error("Failed to load directories:",T)}finally{l(!1)}},[]);C.useEffect(()=>{x(n)},[n,x]);const v=((r==null?void 0:r.current)??"").split("/").filter(Boolean).map((j,T,A)=>({name:j,path:"/"+A.slice(0,T+1).join("/")})),S=(r==null?void 0:r.directories.filter(j=>d===""||j.name.toLowerCase().includes(d.toLowerCase())))??[],w=[...r!=null&&r.parent?[{type:"parent",path:r.parent,name:".."}]:[],...S.map(j=>({type:"dir",path:j.path,name:j.name}))];C.useEffect(()=>{p(d?0:-1)},[d,S.length]),C.useEffect(()=>{var j;h>=0&&_.current[h]&&((j=_.current[h])==null||j.scrollIntoView({block:"nearest"}))},[h]);const k=j=>{var T;if(j.key==="ArrowDown")j.preventDefault(),p(A=>Math.min(A+1,w.length-1));else if(j.key==="ArrowUp")j.preventDefault(),p(A=>Math.max(A-1,0));else if(j.key==="Enter"){if(j.preventDefault(),h>=0&&w[h]){const A=w[h];A.type,x(A.path)}}else j.key==="Escape"&&(f(""),(T=g.current)==null||T.focus())};return c.jsxs(Et,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",children:[r&&c.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30 -mx-4 -mt-4 mb-4 border-b border-border",children:c.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[v.map((j,T)=>c.jsxs("span",{className:"flex items-center shrink-0",children:[c.jsx("span",{className:"text-text-muted",children:"/"}),c.jsx("button",{onClick:()=>x(j.path),className:`px-1 ${T===v.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:j.name})]},j.path)),v.length===0&&c.jsx("button",{onClick:()=>x("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),c.jsx("div",{className:"px-4 mb-3",children:c.jsxs("div",{className:"relative",children:[c.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none flex items-center justify-center",children:c.jsx(ex,{})}),c.jsx(Bh,{autoFocus:!0,ref:g,value:d,onChange:j=>f(j.target.value),onKeyDown:k,placeholder:"Filter directories...",className:"w-full pl-9"})]})}),c.jsx("div",{className:"flex-1 overflow-y-auto -mx-4",children:a?c.jsx("div",{className:"p-8 text-center",children:c.jsx(Kc,{size:"sm"})}):w.length===0?c.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:d?"No matching directories":"No subdirectories"}):c.jsx("div",{className:"divide-y divide-border",children:w.map((j,T)=>c.jsxs("button",{ref:A=>{_.current[T]=A},onClick:()=>x(j.path),onDoubleClick:()=>e(j.path),className:`w-full p-3 flex items-center gap-3 text-left transition-colors ${T===h?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary/50"}`,children:[j.type==="parent"?c.jsx(BD,{className:"w-5 h-5 text-text-muted"}):c.jsx(J_,{className:"w-5 h-5"}),c.jsx("span",{className:"flex-1",children:j.name}),T===h&&c.jsx("span",{className:"text-xs text-text-muted",children:"⏎ navigate · dbl-click select"})]},j.path))})}),c.jsxs("div",{className:"flex flex-col gap-2 pt-4 border-t border-border mt-4 -mx-4 -mb-4 p-4",children:[(r==null?void 0:r.current)&&c.jsx("button",{onClick:()=>e(r.current),className:"w-full px-4 py-2 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Select this folder"}),c.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]})]})}function oM({isOpen:e,onClose:t}){const[,n]=Jr(),[r,s]=C.useState(!1),[a,l]=C.useState(null),[d,f]=C.useState(!1),h=Ut(I=>I.projects),p=Ut(I=>I.createProject),g=Ut(I=>I.listProjects),_=Ut(I=>I.deleteProject),[x,v]=C.useState(null),[S,w]=C.useState(null),[k,j]=C.useState(null);C.useEffect(()=>{Ne("/api/config").then(I=>I.json()).then(I=>{I.workdir&&l(I.workdir)})},[]),C.useEffect(()=>{e&&g()},[e,g]);const T=I=>{n(`/p/${I}`),t()},A=(I,W)=>{W.stopPropagation(),v(I)},P=()=>{x&&(_(x.id),v(null))},R=async I=>{const W=I.split("/").filter(Boolean).pop()??"",z=await p(W,I);return g(),w(I),q(z)?(j(z.error.path||I),!1):!0};function q(I){return I!=null&&typeof I=="object"&&"error"in I&&I.error!=null&&typeof I.error=="object"&&"code"in I.error&&I.error.code==="EACCES"}const J=C.useCallback(()=>{j(null)},[]),ne=C.useCallback(async()=>{if(j(null),S){const I=S.split("/").filter(Boolean).pop()??"",W=await p(I,S);g(),w(S),q(W)&&j(W.error.path||S)}},[S,p,g,j]);return C.useEffect(()=>{if(S){const I=h.find(W=>W.workdir===S);I&&(n(`/p/${I.id}`),t(),w(null))}},[h,S,n,t]),e?c.jsxs(Et,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:c.jsx("div",{className:"flex justify-end gap-2",children:c.jsx(Ze,{variant:"secondary",onClick:t,children:"Close"})}),children:[c.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[c.jsxs("div",{className:"w-full sm:w-1/2 border-b sm:border-b-0 sm:border-r border-border flex flex-col max-h-[40vh] sm:max-h-[50vh]",children:[c.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:c.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:h.length===0?c.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[c.jsx("p",{className:"mb-2",children:"No recent projects"}),c.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):c.jsx("div",{className:"divide-y divide-border",children:h.map(I=>c.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[c.jsxs("button",{onClick:()=>T(I.id),className:"flex-1 flex items-center gap-3 text-left",children:[c.jsx(J_,{className:"w-5 h-5 text-accent-primary"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"font-medium truncate",children:I.name}),c.jsx("div",{className:"text-xs text-text-muted truncate",children:d2(I.workdir,32)})]})]}),c.jsx("button",{onClick:W=>A(I,W),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:c.jsx($c,{className:"w-4 h-4"})})]},I.id))})})]}),c.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:c.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[c.jsx(Ze,{variant:"primary",onClick:()=>f(!0),children:"Select existing project"}),c.jsx(Ze,{variant:"secondary",onClick:()=>s(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&c.jsx(sM,{isOpen:r,onClose:()=>s(!1)}),x&&c.jsx(h2,{isOpen:!0,onClose:()=>v(null),projectName:x.name,onConfirm:P}),d&&c.jsx(m2,{initialPath:a??void 0,onSelect:I=>{R(I).then(W=>{W&&f(!1)})},onClose:()=>f(!1)}),k&&c.jsx(f2,{isOpen:!0,onClose:J,path:k,onRetry:ne})]}):null}function lM(){const[e,t]=C.useState(!1),[n,r]=C.useState(null),s=xe(v=>v.sessions),a=Ut(v=>v.projects),l=Ut(v=>v.loading),d=Ut(v=>v.listProjects),f=xe(v=>v.listSessions),h=Ut(v=>v.deleteProject),p=xe(v=>v.connectionStatus);C.useEffect(()=>{p==="connected"&&(d(),f())},[p,d,f]);const g=[...a].sort((v,S)=>{const w=s.filter(A=>A.workdir.startsWith(v.workdir)),k=s.filter(A=>A.workdir.startsWith(S.workdir)),j=w.length>0?new Date(w.reduce((A,P)=>new Date(P.updatedAt)>new Date(A.updatedAt)?P:A).updatedAt).getTime():new Date(v.updatedAt).getTime();return(k.length>0?new Date(k.reduce((A,P)=>new Date(P.updatedAt)>new Date(A.updatedAt)?P:A).updatedAt).getTime():new Date(S.updatedAt).getTime())-j}),_=v=>{const S=a.find(w=>w.id===v);return S?s.filter(w=>w.workdir.startsWith(S.workdir)).sort((w,k)=>new Date(k.updatedAt).getTime()-new Date(w.updatedAt).getTime()).slice(0,5):[]},x=()=>{t(!0)};return c.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[c.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[c.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),c.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),c.jsx(Ze,{variant:"primary",onClick:x,children:"Open Project"})]}),g.map(v=>{const S=_(v.id);return c.jsx("div",{className:"mb-6 md:mb-8",children:c.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[c.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[c.jsxs(gr,{href:`/p/${v.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[c.jsx(J_,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),c.jsx("span",{className:"text-text-primary font-semibold",children:v.name})]}),c.jsx(gr,{href:`/p/${v.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"}),c.jsx("button",{type:"button",onClick:()=>r({id:v.id,name:v.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:c.jsx($c,{className:"w-4 h-4"})})]}),c.jsx("div",{className:"divide-y divide-border",children:S.length>0?S.map(w=>{const k=a.find(T=>w.workdir.startsWith(T.workdir)),j=k?`/p/${k.id}/s/${w.id}`:"#";return c.jsx(gr,{href:j,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:c.jsx("div",{className:"flex-1 min-w-0",children:c.jsx("div",{className:"text-sm text-text-muted truncate",children:w.title??w.id.slice(0,8)})})}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx("span",{className:"text-text-muted text-xs",children:W3(w.updatedAt)}),c.jsxs("span",{className:"text-text-muted text-xs",children:[w.messageCount," msgs"]})]})]})},w.id)}):c.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},v.id)}),g.length===0&&!l&&c.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),l&&c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(Kc,{})})]}),e&&c.jsx(oM,{isOpen:e,onClose:()=>t(!1)}),n&&c.jsx(h2,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>h(n.id)})]})}function cM(){const[,e]=Y_("/p/:projectId/new"),[,t]=Jr(),n=e==null?void 0:e.projectId,r=xe(l=>l.createSession),s=xe(l=>l.resetPendingSessionCreate),a=C.useCallback(async()=>{if(!n)return;const l=await r(n);l?(t(`/p/${n}/s/${l.id}`),s()):(t(`/p/${n}`),s())},[n,r,t,s]);return C.useEffect(()=>{a()},[a]),c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx(Kc,{})})}function uM(){const e=Ut(t=>t.currentProject);return c.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:c.jsxs("div",{className:"max-w-md",children:[c.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),c.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),c.jsxs("div",{className:"flex flex-col gap-3",children:[e&&c.jsx(gr,{href:`/p/${e.id}/new`,"data-testid":"create-new-session-button",className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),c.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const nc=e=>Math.round(e*10)/10;function dM(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function x_(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function hM(e){return`${e.providerId}::${e.model}`}function fM(e){return`${e.providerName} > ${e.model}`}function D1(e){let t=0,n=0,r=0,s=0,a=0,l=0;const d=[],f=[];let h=0;for(const[_,x]of e.entries()){const v=x.stats,S=x_(v);t+=v.totalTime,n+=v.toolTime,r+=v.prefillTokens,s+=v.generationTokens;const w=v.prefillSpeed>0?v.prefillTokens/v.prefillSpeed:0,k=v.generationSpeed>0?v.generationTokens/v.generationSpeed:0;a+=w,l+=k,d.push({messageId:x.id,timestamp:x.timestamp,...S,mode:v.mode,responseIndex:_+1,prefillTokens:v.prefillTokens,generationTokens:v.generationTokens,prefillSpeed:v.prefillSpeed,generationSpeed:v.generationSpeed,totalTime:v.totalTime,aiTime:v.totalTime-v.toolTime,toolTime:v.toolTime});const j=v.llmCalls??[];for(const T of j)h+=1,f.push({messageId:x.id,timestamp:T.timestamp??x.timestamp,providerId:T.providerId,providerName:T.providerName,backend:T.backend,model:T.model,mode:v.mode,responseIndex:_+1,sessionCallIndex:h,callIndex:T.callIndex,promptTokens:T.promptTokens,completionTokens:T.completionTokens,ttft:T.ttft,completionTime:T.completionTime,prefillSpeed:T.prefillSpeed,generationSpeed:T.generationSpeed,totalTime:T.totalTime,...T.temperature!==void 0&&{temperature:T.temperature},...T.topP!==void 0&&{topP:T.topP},...T.topK!==void 0&&{topK:T.topK},...T.maxTokens!==void 0&&{maxTokens:T.maxTokens}})}const p=a>0?nc(r/a):0,g=l>0?nc(s/l):0;return{totalTime:nc(t),aiTime:nc(t-n),toolTime:nc(n),prefillTokens:r,generationTokens:s,avgPrefillSpeed:p,avgGenerationSpeed:g,responseCount:e.length,llmCallCount:f.length,dataPoints:d,callDataPoints:f}}function mM(e){const t=e.filter(s=>s.stats!==void 0&&s.stats!==null&&dM(s.stats)).sort((s,a)=>new Date(s.timestamp).getTime()-new Date(a.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const s of t){const a=hM(x_(s.stats)),l=n.get(a)??[];n.set(a,[...l,s])}const r=Array.from(n.entries()).map(([s,a])=>{const l=x_(a[0].stats),d=D1(a);return{...l,key:s,label:fM(l),...d}});return{...D1(t),modelGroups:r}}function pM(e){return C.useMemo(()=>mM(e),[e])}function p2(){var s;const e=xe(a=>a.gitStatus),t=xe(a=>a.currentSession),[n,r]=C.useState(!0);return C.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((s=e==null?void 0:e.diff)==null?void 0:s.files)??[],loading:n,error:null}}}function sh(e){return e.toLocaleString("en-US").replace(/,/g," ")}function L1(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function gM(e){if(!Number.isFinite(e))return"0s";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=Math.round(e%60);return`${t}m${n}s`}const R1=["▁","▂","▃","▄","▅","▆","▇","█"];function _M(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 xM(e,t){if(e===t){const s=Math.max(Math.abs(e)*.05,1);return{minY:e-s,maxY:t+s}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function yM(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,_)=>g.x-_.x),r=n[0].x,s=n[n.length-1].x,a=Math.min(...n.map(g=>g.y)),l=Math.max(...n.map(g=>g.y)),{minY:d,maxY:f}=xM(a,l),h=Array.from({length:t},()=>" "),p=new Map;for(const g of n){const _=s===r?0:Math.round((g.x-r)/(s-r)*(t-1)),x=p.get(_)??[];p.set(_,[...x,g.y])}for(const[g,_]of p){const x=Math.max(..._);h[g]=R1[_M(x,d,f)]??R1[0]}return{blocks:h.join(""),minX:r,maxX:s,minY:d,maxY:f}}function M1(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function O1({data:e,width:t=60,height:n=78,label:r,xLabel:s,yLabel:a,showAxes:l=!0,formatY:d=M1,formatX:f=M1}){const h=C.useMemo(()=>{const p=yM(e,t),g=Math.max(t*6,240),_=10,x=8,S=[...e].sort((T,A)=>T.x-A.x).map(T=>{const A=p.maxX===p.minX?g/2:_+(T.x-p.minX)/(p.maxX-p.minX)*(g-_*2),P=p.maxY===p.minY?n/2:x+(p.maxY-T.y)/(p.maxY-p.minY)*(n-x*2);return{...T,cx:A,cy:P,leftPercent:A/g*100,topPercent:P/n*100}}),w=S.map((T,A)=>`${A===0?"M":"L"} ${T.cx.toFixed(1)} ${T.cy.toFixed(1)}`).join(" "),j=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(T=>({value:T,y:p.maxY===p.minY?n/2:x+(p.maxY-T)/(p.maxY-p.minY)*(n-x*2)}));return{...p,chartWidth:g,points:S,path:w,gridLines:j}},[e,n,t]);return e.length===0?c.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&c.jsx("div",{className:"mb-1",children:r}),c.jsx("div",{children:"No data"})]}):c.jsxs("div",{className:"font-mono text-xs",children:[r&&c.jsx("div",{className:"text-text-secondary mb-2",children:r}),c.jsxs("div",{className:"flex gap-3",children:[l&&c.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(p=>c.jsx("span",{children:d(p.value)},`${p.value}-${p.y}`))}),c.jsx("div",{className:"flex-1 min-w-0",children:c.jsxs("div",{className:"relative h-[78px]",children:[c.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(p=>c.jsx("line",{x1:"0",x2:h.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),h.points.map(p=>c.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),h.points.length>1&&c.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(p=>c.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${f(p.x)} -> ${d(p.y)}`,children:c.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),l&&c.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[c.jsx("span",{className:"w-12"}),c.jsxs("span",{className:"flex-1 flex justify-between",children:[c.jsx("span",{children:f(h.minX)}),c.jsx("span",{children:s}),c.jsx("span",{children:f(h.maxX)})]})]}),a&&l&&c.jsx("div",{className:"text-text-muted mt-1 text-center",children:a})]})}function vM({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:s=60}){const a=e.map(d=>({x:d.x,y:d.ppSpeed})),l=e.map(d=>({x:d.x,y:d.tgSpeed}));return c.jsxs("div",{className:"space-y-5",children:[c.jsx(O1,{data:a,width:s,label:t,xLabel:r}),c.jsx(O1,{data:l,width:s,label:n,xLabel:r})]})}function bM(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((s,a)=>s.callIndex-a.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function SM(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 wM(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 CM(e){return e.callDataPoints.length>0?wM(e):SM(e)}function Wp(e){if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=e%60;return`${t}m ${n.toFixed(0)}s`}function Na(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function _c(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function kM(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Na(t)} ctx`:`${Na(t)}-${Na(n)} ctx`}function ih(e){return`${_c(e)} t/s`}function g2(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function EM(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 NM({isOpen:e,onClose:t,stats:n}){const r=C.useRef(null),[s,a]=C.useState({}),[l,d]=C.useState(()=>{var v;return((v=n.modelGroups[0])==null?void 0:v.key)??""});C.useEffect(()=>{var v;n.modelGroups.some(S=>S.key===l)||d(((v=n.modelGroups[0])==null?void 0:v.key)??"")},[l,n.modelGroups]);const f=C.useMemo(()=>n.modelGroups.find(v=>v.key===l)??n.modelGroups[0],[l,n.modelGroups]),h=C.useMemo(()=>f?bM(f):[],[f]),p=C.useMemo(()=>f?CM(f):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[f]),g=C.useCallback(v=>{a(S=>({...S,[v]:!S[v]}))},[]),_=C.useCallback(()=>{if(!f)return;const v=EM(f);navigator.clipboard.writeText(JSON.stringify(v,null,2)).catch(S=>console.error("Failed to copy:",S))},[f]),x=C.useCallback(async()=>{if(r.current)try{const v=(await $(async()=>{const{default:k}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:k}},[])).default,S=await v(r.current,{backgroundColor:"#1a1a1a",scale:2}),w=document.createElement("a");w.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,w.href=S.toDataURL("image/png"),w.click()}catch(v){console.error("Failed to export PNG:",v),_()}},[_]);return c.jsx(Et,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:c.jsxs("div",{ref:r,className:"space-y-6",children:[c.jsx("section",{children:c.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(v=>c.jsx("button",{onClick:()=>d(v.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${v.key===(f==null?void 0:f.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:v.label,children:v.label},v.key))})}),f&&c.jsxs("section",{children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[c.jsx(Bs,{label:"AI Time",value:Wp(f.aiTime)}),c.jsx(Bs,{label:"Total Time",value:Wp(f.totalTime)}),c.jsx(Bs,{label:"Tool Time",value:Wp(f.toolTime)}),c.jsx(Bs,{label:"Responses",value:f.responseCount.toString()}),c.jsx(Bs,{label:"LLM Calls",value:f.llmCallCount.toString()})]}),c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[c.jsx(Bs,{label:"Prefill Tokens",value:Na(f.prefillTokens),subValue:`@ ${_c(f.avgPrefillSpeed)} tok/s`}),c.jsx(Bs,{label:"Gen Tokens",value:Na(f.generationTokens),subValue:`@ ${_c(f.avgGenerationSpeed)} tok/s`}),c.jsx(Bs,{label:"Avg PP Speed",value:`${_c(f.avgPrefillSpeed)}`,subValue:"tok/s"}),c.jsx(Bs,{label:"Avg TG Speed",value:`${_c(f.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),f&&p.points.length>1&&c.jsxs("section",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:_,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),c.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),c.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:c.jsx(vM,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),f&&c.jsxs("section",{children:[c.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",f.responseCount," responses)"]}),c.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:c.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[c.jsxs("colgroup",{children:[c.jsx("col",{className:"w-[7%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[10%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[11%]"}),c.jsx("col",{className:"w-[2%]"})]}),c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[c.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),c.jsx("th",{className:"px-2 py-2"})]})}),c.jsx("tbody",{children:h.map((v,S)=>c.jsxs(C.Fragment,{children:[c.jsx(jM,{row:v,index:S,isExpanded:s[v.messageId]??!1,onToggle:v.isExpandable?()=>g(v.messageId):void 0}),(s[v.messageId]??!1)&&v.calls.map((w,k)=>c.jsx(TM,{dataPoint:w,index:k},`${w.messageId}-${w.callIndex}`))]},v.messageId))})]})})]})]})})}function Bs({label:e,value:t,subValue:n}){return c.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[c.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),c.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&c.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function jM({row:e,index:t,isExpanded:n,onToggle:r}){const s=e.calls.length>0?kM(e.calls.map(a=>a.promptTokens)):`${Na(e.prefillTokens)} ctx`;return c.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[c.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:g2(e.timestamp)}),c.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:s.replace(/ ctx$/,"")}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.prefillSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.generationSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function TM({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return c.jsxs(c.Fragment,{children:[c.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[c.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:g2(e.timestamp)}),c.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Na(e.promptTokens)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.prefillSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.generationSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),c.jsx("td",{className:"px-2 py-2"})]}),n&&c.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:c.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:c.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&c.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&c.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&c.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&c.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const AM={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"}},DM=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function LM(e){return AM[e]??{icon:"○",color:"text-text-muted"}}function _2(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const zh=C.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:s}=LM(t);return c.jsx("span",{className:`${s} ${n}`,children:r})});function I1({entries:e,title:t}){const n=C.useMemo(()=>e.reduce((r,s)=>(r[s.status]=(r[s.status]??0)+1,r),{}),[e]);return c.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[c.jsx("span",{children:t}),Object.keys(n).length>0&&c.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:DM.map(r=>{const s=n[r];return s?c.jsxs("span",{className:"flex items-center gap-0.5",children:[c.jsx(zh,{status:r}),c.jsx("span",{children:s})]},r):null})})]})}const RM=C.memo(function({entries:t,title:n}){return t.length===0?null:c.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&c.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:c.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),c.jsx("div",{className:"bg-primary",children:t.map((r,s)=>c.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${s>0?"border-t border-border":""}`,children:[c.jsx(zh,{status:r.status}),c.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[c.jsxs("span",{className:"text-text-muted",children:["[",r.id,"]"]})," ",_2(r.description)]})]},r.id??s))})]})}),MM="#6b7280";function Ac(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??MM}const mt=xr(e=>{const t=async()=>{await rx("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await Ne(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const s=await zi("POST","/api/agents",{...n,destination:r});return s.success&&await t(),s},updateAgent:async(n,r)=>{const s=await zi("PUT",`/api/agents/${n}`,r);return s.success&&await t(),s},deleteAgent:async n=>{try{const r=await Ne(`/api/agents/${n}`,{method:"DELETE"}),s=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:s.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r)=>Th(`/api/agents/${n}/duplicate`,t,r)}}),jt=xr((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const r=await(await Ne("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const r=await(await Ne("/api/workflows")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],activeWorkflowId:r.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async n=>{try{const r=await Ne(`/api/workflows/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/workflows/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createWorkflow:async(n,r)=>{const s=await zi("POST","/api/workflows",{...n,destination:r});return s.success&&await t().fetchWorkflows(),s},updateWorkflow:async(n,r)=>{const s=await zi("PUT",`/api/workflows/${n}`,r);return s.success&&await t().fetchWorkflows(),s},deleteWorkflow:async n=>{try{const r=await Ne(`/api/workflows/${n}`,{method:"DELETE"}),s=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:s.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r)=>Th(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),r)})),OM={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function IM(e,t){await Ne(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function Cd({id:e,agents:t}){const n=Ac(t,e),r=t.find(s=>s.id===e);return c.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function PM({id:e}){const t=jt(l=>l.defaults),n=jt(l=>l.userItems),s=C.useMemo(()=>[...t,...n],[t,n]).find(l=>l.id===e),a=(s==null?void 0:s.color)??"#3b82f6";return c.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${a}20`,color:a},children:(s==null?void 0:s.name)??e})}function BM({entries:e,sessionId:t}){const[n,r]=C.useState(e),[s,a]=C.useState(!1),[l,d]=C.useState(null),[f,h]=C.useState(""),[p,g]=C.useState(""),[_,x]=C.useState(!1),[v,S]=C.useState(!1),w=mt(N=>N.defaults),k=mt(N=>N.userItems),j=mt(N=>N.projectItems),T=C.useMemo(()=>[...w,...k,...j],[w,k,j]),A=C.useRef(null),P=C.useRef(null);C.useEffect(()=>{r(e)},[e]),C.useEffect(()=>{var N;s&&((N=A.current)==null||N.focus())},[s]),C.useEffect(()=>{var N;l&&((N=P.current)==null||N.focus())},[l]);const R=C.useCallback(N=>{r(N),IM(t,N)},[t]),q=C.useCallback(()=>{var se;const N=f.trim();if(!N)return;const F=String(n.length),H=[...n,{id:F,description:N,status:"pending"}];R(H),h(""),(se=A.current)==null||se.focus()},[n,f,R]),J=C.useCallback(()=>{a(!1),h("")},[]),ne=C.useCallback((N,F)=>{d(N),g(F)},[]),I=C.useCallback(()=>{if(!l)return;const N=p.trim(),F=n.map(H=>H.id===l?{...H,description:N||H.description}:H);R(F),d(null)},[l,p,n,R]),W=C.useCallback(N=>{const F=n.map(H=>H.id===N?{...H,status:OM[H.status]??"pending"}:H);R(F)},[n,R]),z=C.useCallback(N=>{R(n.filter(F=>F.id!==N))},[n,R]),L=C.useCallback(()=>{R([]),x(!1)},[R]),U=C.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),q()),N.key==="Escape"&&J()},[q,J]),D=C.useCallback(N=>{N.key==="Enter"&&I(),N.key==="Escape"&&d(null)},[I]);return c.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[c.jsxs("div",{className:"bg-primary",children:[n.length===0&&!s&&c.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",c.jsx("button",{onClick:()=>S(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((N,F)=>{const H=N.status,se=l===N.id;return c.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${F>0?"border-t border-border":""}`,children:[c.jsx("button",{onClick:()=>W(N.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${N.status} (click to cycle)`,children:c.jsx(zh,{status:H})}),c.jsx("div",{className:"flex-1 min-w-0",children:se?c.jsx("input",{ref:P,value:p,onChange:B=>g(B.target.value),onBlur:I,onKeyDown:D,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):c.jsxs("button",{onClick:()=>ne(N.id,N.description),className:"text-xs text-text-primary text-left hover:text-accent-primary transition-colors w-full truncate cursor-pointer",title:"Click to edit",children:["[",N.id,"] ",_2(N.description)]})}),c.jsx("button",{onClick:()=>z(N.id),className:"flex-shrink-0 opacity-0 group-hover:opacity-100 text-text-muted hover:text-accent-error transition-all ml-0.5 cursor-pointer flex items-center self-center",title:"Delete criterion",children:c.jsx(Hc,{className:"w-4 h-4"})})]},N.id)})]}),s&&c.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),c.jsx("input",{ref:A,value:f,onChange:N=>h(N.target.value),onKeyDown:U,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),c.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[s?c.jsxs(c.Fragment,{children:[c.jsxs("button",{onClick:q,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[c.jsx($i,{className:"w-3 h-3"}),"Add"]}),c.jsx("button",{onClick:J,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):c.jsxs("button",{onClick:()=>a(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[c.jsx($i,{className:"w-3 h-3"}),"Add"]}),n.length>0&&c.jsxs("button",{onClick:()=>x(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[c.jsx($c,{className:"w-3 h-3"}),"Clear all"]}),c.jsx("button",{onClick:()=>S(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:c.jsx(ek,{className:"w-3 h-3"})})]}),_&&c.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:c.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[c.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:L,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),c.jsx("button",{onClick:()=>x(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),c.jsx(Et,{isOpen:v,onClose:()=>S(!1),title:"About Acceptance Criteria",size:"md",children:c.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[c.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),c.jsxs("p",{children:["To use this feature, start in ",c.jsx(Cd,{id:"planner",agents:T})," mode and",c.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",c.jsx(PM,{id:"default"})," builtin workflow to launch the automation part."]}),c.jsx("p",{children:"This workflow will automatically:"}),c.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[c.jsxs("li",{children:["Launch the ",c.jsx(Cd,{id:"builder",agents:T}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),c.jsxs("li",{children:["Then launch the ",c.jsx(Cd,{id:"verifier",agents:T})," subagent, that will verify each criterion. If every criterion is fulfilled, then it goes to the next step, otherwise, it gives feedback to the main agent until 100% of the criteria are met."]}),c.jsxs("li",{children:["Launch a ",c.jsx(Cd,{id:"code_reviewer",agents:T})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),c.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:c.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function zM({isOpen:e,onClose:t}){const n=hs(S=>S.config),r=hs(S=>S.saveConfig),[s,a]=C.useState(""),[l,d]=C.useState(""),[f,h]=C.useState(!1),[p,g]=C.useState(!1),[_,x]=C.useState(!1);C.useEffect(()=>{e&&(a((n==null?void 0:n.command)??""),d((n==null?void 0:n.url)??""),h((n==null?void 0:n.hotReload)??!1),g((n==null?void 0:n.disableInspect)??!1))},[e,n]);const v=async()=>{!s.trim()||!l.trim()||(x(!0),await r({command:s.trim(),url:l.trim(),hotReload:f,disableInspect:p}),x(!1),t())};return c.jsx(Et,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),c.jsx("input",{className:"input w-full",type:"text",value:s,onChange:S=>a(S.target.value),placeholder:"npm run dev"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),c.jsx("input",{className:"input w-full",type:"text",value:l,onChange:S=>d(S.target.value),placeholder:"http://localhost:3000"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"hotReload",checked:f,onChange:S=>h(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),c.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:S=>g(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),c.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[c.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),c.jsx("button",{className:"btn btn-primary",onClick:v,disabled:_||!s.trim()||!l.trim(),children:_?"Saving...":"Save"})]})]})})}const P1={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"},$M={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"},B1={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},HM="text-text-primary";function FM(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,s="text-text-primary",a;try{for(;(a=n.exec(e))!==null;){if(a.index>r){const h=e.slice(r,a.index);h&&t.push({text:h,className:s})}const l=a[1];if(!l)continue;const d=l.split(";").map(Number);if(d.length===0||d[0]===0){s="text-text-primary";continue}const f=[];for(const h of d)if(h>=30&&h<=37){const p=P1[h];p&&f.push(p)}else if(h>=40&&h<=47){const p=$M[h];p&&f.push(p)}else if(h>=90&&h<=97){const p=P1[h];p&&f.push(p)}else if(h in B1){const p=B1[h];p&&f.push(p)}else h===39?f.push(HM):h===49&&(s=s.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));f.length>0&&(s=f.join(" ")),r=n.lastIndex}if(r<e.length){const l=e.slice(r);l&&t.push({text:l,className:s})}return t}catch(l){return console.warn("ANSI parsing failed, stripping codes:",l),[{text:UM(e),className:"text-text-primary"}]}}function UM(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function ah(e){const t=FM(e),n=[];return t.forEach((r,s)=>{const a=r.text.split(`
106
- `);a.forEach((l,d)=>{n.push(Li.createElement("span",{key:`${s}-${d}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},l)),d<a.length-1&&n.push(Li.createElement("br",{key:`${s}-${d}-br`}))})}),n.length===1?n[0]:n}function x2({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return c.jsx("pre",{ref:t,className:n,children:e.length===0?c.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((r,s)=>c.jsx("span",{className:r.stream==="stderr"?"text-accent-warning":"",children:ah(r.content)},s))})}const y2=C.memo(function({title:t,logs:n,onClose:r,preClassName:s}){const a=C.useRef(null);return C.useEffect(()=>{a.current&&(a.current.scrollTop=a.current.scrollHeight)},[n]),c.jsx(Et,{isOpen:!0,onClose:r,title:t,size:"full",children:c.jsx(x2,{logs:n,preRef:a,preClassName:s})})}),VM=C.memo(function({logs:t,anchorRef:n,isHiding:r,onExpand:s,onClose:a}){const[l,d]=C.useState(null),f=C.useRef(null);return C.useEffect(()=>{var p;const h=(p=n.current)==null?void 0:p.getBoundingClientRect();h&&d({bottom:window.innerHeight-h.bottom,right:window.innerWidth-h.right,width:h.width,height:h.height})},[n]),C.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[t]),l?c.jsxs("div",{className:"relative",children:[c.jsx("pre",{ref:f,className:"fixed z-50 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border overflow-auto transition-all duration-150 ease-out select-text",style:{bottom:l.bottom,right:l.right,width:l.width*2,maxHeight:l.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1},children:t.map((h,p)=>c.jsx("span",{className:h.stream==="stderr"?"text-accent-warning":"",children:ah(h.content)},p))}),c.jsx("button",{onClick:()=>{a(),s()},className:"fixed z-50 px-2 py-1 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors duration-150",style:{bottom:l.bottom+8,right:l.right+8},children:"Expand"})]}):null}),WM=C.memo(function({workdir:t}){const n=hs(z=>z.setWorkdir),r=hs(z=>z.status),s=hs(z=>z.config),a=hs(z=>z.logs),l=hs(z=>z.start),d=hs(z=>z.stop),f=hs(z=>z.fetchLogs),h=xe(z=>z.currentSession),[p,g]=C.useState(!1),[_,x]=C.useState(!1),[v,S]=C.useState(!1),[w,k]=C.useState(!1),j=C.useRef(null),T=C.useRef(null),A=C.useRef(null),P=C.useRef(null),R=C.useRef(null),q=()=>{const z=r==null?void 0:r.inspectProxyPort;if(!z){r!=null&&r.url&&window.open(r.url,"_blank");return}const L=`${window.location.protocol}//${window.location.hostname}:${z}`,U=window.open(L,"_blank");if(U){R.current=U;const D=()=>{var F;!R.current||R.current.closed||(R.current.postMessage({type:"setFoxSessionId",sessionId:(h==null?void 0:h.id)??null},"*"),R.current.postMessage({type:"setFoxSessionTitle",sessionTitle:((F=h==null?void 0:h.metadata)==null?void 0:F.title)??null},"*"),R.current.postMessage({type:"setFoxInspectEnabled",enabled:!(s!=null&&s.disableInspect)},"*"))},N=setInterval(()=>{D(),(!R.current||R.current.closed)&&clearInterval(N)},500);setTimeout(()=>clearInterval(N),5e3)}},J=(r==null?void 0:r.state)??"off",ne=s!==null,I=J==="running"||J==="warning";C.useEffect(()=>{n(t??null)},[t,n]),C.useEffect(()=>{I&&f()},[I,f]),C.useEffect(()=>{A.current&&I&&(A.current.scrollTop=A.current.scrollHeight)},[a,I]);const W=()=>{I?d():l()};return c.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${J==="running"?"bg-accent-success":J==="warning"?"bg-accent-warning":J==="error"?"bg-accent-error":"bg-text-muted"}`}),c.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),c.jsx("button",{onClick:()=>g(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:c.jsx(GD,{})})]}),ne?c.jsxs(c.Fragment,{children:[J==="running"||J==="warning"?c.jsxs("div",{className:"flex gap-2",children:[c.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:[c.jsx(nk,{}),"Stop"]}),(r==null?void 0:r.url)&&c.jsxs("button",{onClick:()=>q(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:r.url,children:[c.jsx(KD,{}),"Open"]})]}):c.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&&c.jsxs("div",{ref:P,className:"relative",onMouseEnter:()=>{T.current&&clearTimeout(T.current),j.current=setTimeout(()=>{S(!0),k(!1)},500)},onMouseLeave:()=>{j.current&&clearTimeout(j.current),k(!0),T.current=setTimeout(()=>S(!1),150)},children:[c.jsx(x2,{logs:a,preRef:A,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),(v||w)&&P.current&&La.createPortal(c.jsx(VM,{logs:a,anchorRef:P,isHiding:w,onExpand:()=>x(!0),onClose:()=>S(!1)}),document.body)]})]}):c.jsx("button",{onClick:()=>g(!0),className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),c.jsx(zM,{isOpen:p,onClose:()=>g(!1)}),_&&c.jsx(y2,{title:"Dev Server Logs",logs:a,onClose:()=>x(!1)})]})}),GM=C.memo(function({sessionId:t}){var x;const n=yc(v=>v.processes),r=yc(v=>v.stopProcess),[s,a]=C.useState(null),[l,d]=C.useState([]),f=n.filter(v=>v.status!=="exited"),h=f.filter(v=>v.status==="running").length;if(n.length===0)return null;const p=v=>{switch(v){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},g=v=>{const S=yc.getState().logs[v]??[];d(S.map(w=>({content:w.content,stream:w.stream}))),a(v)},_=v=>{t&&r(v,t)};return c.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[c.jsx("div",{className:"flex items-center justify-between",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),c.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),c.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),c.jsx("div",{className:"space-y-2",children:f.map(v=>c.jsx("div",{className:"border border-border rounded p-2",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[c.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(v.status)}`}),c.jsx("span",{className:"text-sm text-text-primary truncate",title:v.name,children:v.name}),c.jsxs("span",{className:"text-xs text-text-muted",children:["[",v.status,"]"]})]}),c.jsxs("div",{className:"flex gap-1 ml-2",children:[c.jsx("button",{onClick:()=>g(v.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),c.jsx("button",{onClick:()=>_(v.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},v.id))}),s&&c.jsx(y2,{title:((x=f.find(v=>v.id===s))==null?void 0:x.name)??"",logs:l,onClose:()=>{a(null),d([])}})]})});function qM({isOpen:e,onClose:t,versionInfo:n}){const[r,s]=C.useState("ready"),[a,l]=C.useState("waiting"),[d,f]=C.useState(""),[h,p]=C.useState(n),[g,_]=C.useState(!1),x=C.useRef(!1);C.useEffect(()=>{if(e){if(n){p(n);return}fetch("/api/auto-update/check").then(w=>w.json()).then(w=>{p({current:w.current,latest:w.latest}),_(w.isService??!1)}).catch(()=>{})}},[e]),C.useEffect(()=>{if(!e||r!=="updating")return;const w=setInterval(()=>{f(k=>k.length>=3?"":k+".")},400);return()=>clearInterval(w)},[e,r]);const v=C.useCallback(async()=>{s("updating"),l("waiting"),x.current=!1;const w=(h==null?void 0:h.current)==="1.0.0"&&(h==null?void 0:h.latest)==="1.1.0",k=await Ne("/api/auto-update",{method:"POST"}),{isService:j}=await k.json();if(w){setTimeout(()=>{s("reloading"),localStorage.setItem("openfox_updated_to",(h==null?void 0:h.latest)??"unknown"),localStorage.setItem("update_pending","true"),setTimeout(()=>window.location.reload(),1e3)},5e3);return}if(!j){setTimeout(()=>{s("complete")},8e3);return}let T=!1;const A=setInterval(async()=>{try{(await fetch("/api/health")).ok&&x.current&&(T=!0,clearInterval(A),s("reloading"),localStorage.setItem("openfox_updated_to",(h==null?void 0:h.latest)??"unknown"),localStorage.setItem("update_pending","true"),window.location.reload())}catch{x.current=!0}},2e3);setTimeout(()=>{T||l("takingLonger")},6e4),setTimeout(()=>{T||(clearInterval(A),s("failed"))},12e4)},[h==null?void 0:h.current,h==null?void 0:h.latest]);C.useEffect(()=>{e&&(s("ready"),l("waiting"),f(""),x.current=!1)},[e]);const S=r!=="updating";return c.jsxs(Et,{isOpen:e,onClose:S?t:void 0,title:r==="failed"?"Update Failed":r==="complete"?"Update Complete":"New OpenFox Version Available",size:"sm",closeOnBackdropClick:S,showCloseButton:S,children:[c.jsxs("div",{className:"flex flex-col gap-4",children:[h&&c.jsxs("div",{className:"flex justify-between text-sm",children:[c.jsx("span",{className:"text-text-muted",children:"Current version"}),c.jsx("span",{className:"text-text-primary font-mono",children:h.current})]}),h&&c.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[c.jsx("span",{className:"text-text-muted",children:"Latest version"}),c.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:h.latest})]}),r==="updating"&&c.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[c.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),c.jsx("p",{className:"text-xs text-text-muted text-center",children:a==="takingLonger"?"Taking longer than expected…":`Updating${d}`})]}),r==="reloading"&&c.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[c.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),c.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Update complete, reloading",d]})]}),r==="complete"&&c.jsx("div",{className:"flex flex-col gap-3 mt-2",children:c.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h==null?void 0:h.latest,". Please relaunch OpenFox to use the new version."]})}),r==="failed"&&c.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[c.jsx("span",{children:"⚠️"}),c.jsx("p",{className:"text-text-secondary",children:"The update timed out. The server may need to be updated manually."})]}),c.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),c.jsxs("p",{className:"text-xs text-text-muted",children:["Run this command in your terminal to complete the update, then start the service with"," ",c.jsx("span",{className:"font-mono text-text-secondary",children:"openfox service start"}),"."]})]})]}),r==="ready"&&c.jsx("button",{onClick:v,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="complete"||r==="failed")&&c.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"}),r==="ready"&&g&&c.jsx("div",{className:"flex justify-center mt-2",children:c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[c.jsx("span",{children:"⚠️"}),c.jsx("p",{className:"text-text-secondary",children:"Server will restart to apply this update. Sessions in progress will be interrupted."})]})})]})}function KM({file:e}){const t=d2(e.path,28),n=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",r=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"";return c.jsxs("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:[c.jsx("span",{className:`truncate ${n}`,title:e.path,children:t}),r&&c.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:r})]})}function YM(){const{diff:e}=p2();return e.loading?c.jsx("div",{className:"mt-3",children:c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[c.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),c.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?c.jsx("div",{className:"mt-3",children:c.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):c.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:c.jsx("div",{className:"pr-1",children:e.files.map((t,n)=>c.jsx(KM,{file:t},n))})})}function z1({messages:e,workdir:t}){var S,w,k,j;const[n,r]=C.useState(!1),[s,a]=C.useState(!1),[l,d]=C.useState(!1),[f,h]=C.useState(!1),p=pM(e),{branch:g}=p2(),_=Ot(T=>T.version),x=xe(T=>T.currentSession),v=C.useCallback(async()=>{a(!0);try{const T=await fetch("/api/auto-update/check");if(T.ok){const A=await T.json();d(A.isUpdateAvailable)}}catch{}finally{a(!1)}},[]);return C.useEffect(()=>{v()},[v]),C.useEffect(()=>{if(new URLSearchParams(window.location.search).get("test-update")==="1"){d(!0),h(!0);const A=new URL(window.location.href);A.searchParams.delete("test-update"),window.history.replaceState({},"",A.toString())}},[]),c.jsxs("div",{className:"flex flex-col h-full",children:[p&&c.jsxs("div",{className:"mb-4",children:[c.jsx("button",{onClick:()=>r(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:c.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[c.jsx("span",{className:"text-text-secondary",children:gM(p.aiTime)}),c.jsx("span",{className:"w-px h-3 bg-border"}),c.jsx("span",{className:"text-text-secondary",children:L1(p.avgPrefillSpeed)}),c.jsx("span",{children:"pp"}),c.jsx("span",{className:"w-px h-3 bg-border"}),c.jsx("span",{className:"text-text-secondary",children:L1(p.avgGenerationSpeed)}),c.jsx("span",{children:"tg"})]})}),c.jsx(NM,{isOpen:n,onClose:()=>r(!1),stats:p})]}),c.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto",children:c.jsxs("div",{className:"mt-4",children:[c.jsx(I1,{entries:((S=x==null?void 0:x.metadataEntries)==null?void 0:S.criteria)??[],title:"Acceptance Criteria"}),x&&c.jsx(BM,{entries:((w=x==null?void 0:x.metadataEntries)==null?void 0:w.criteria)??[],sessionId:x.id}),x&&(((j=(k=x.metadataEntries)==null?void 0:k.review_findings)==null?void 0:j.length)??0)>0&&c.jsxs("div",{className:"mt-6",children:[c.jsx(I1,{entries:x.metadataEntries.review_findings,title:"Review Findings"}),c.jsx(RM,{entries:x.metadataEntries.review_findings})]})]})}),g&&c.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[c.jsx(HD,{}),c.jsx("span",{className:"truncate text-text-secondary",title:g,children:g})]}),c.jsx(YM,{}),c.jsx(WM,{workdir:t}),c.jsx(GM,{sessionId:x==null?void 0:x.id}),_&&c.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[c.jsxs("div",{className:"flex items-center justify-center gap-1",children:[c.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",c.jsxs("span",{className:"font-mono",children:["v",_]}),c.jsx("button",{onClick:()=>v(),disabled:s,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:c.jsx(Z_,{className:`w-3 h-3 ${s?"animate-spin":""}`})})]}),l&&c.jsx("button",{onClick:()=>h(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"})]}),c.jsx(qM,{isOpen:f,onClose:()=>h(!1),versionInfo:null})]})}function XM({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const s=xe(a=>a.currentSession);return c.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&c.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),c.jsxs("div",{className:"flex h-full",children:[c.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?c.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary",children:c.jsx(z1,{messages:r,workdir:s==null?void 0:s.workdir})}):c.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),c.jsx("aside",{className:`
107
- md:hidden
108
- p-4 overflow-y-auto bg-secondary
109
- transition-all duration-300 ease-in-out
110
- fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
111
- ${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
112
- `,children:c.jsx(z1,{messages:r,workdir:s==null?void 0:s.workdir})})]})]})}function QM(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function v2({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const s=n==="sm"?"w-12":"w-20",a=n==="sm"?"h-1":"h-1.5";return c.jsx("div",{className:`${a} bg-bg-tertiary rounded-full overflow-hidden ${s} ${r}`,children:c.jsx("div",{className:`h-full transition-all duration-300 ${QM(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function JM({dangerZone:e,size:t="md"}){return e?c.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function $1(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function ZM(){const e=xe(j=>j.contextState),t=xe(j=>j.currentSession),n=xe(j=>j.compactContext),[r,s]=C.useState(!1),[a,l]=C.useState(!1),[d,f]=C.useState(!1),h=C.useRef(!1);if(C.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!h.current&&l(!1),h.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),!e||!t)return null;const{currentTokens:p,maxTokens:g,compactionCount:_,dangerZone:x,dynamicContextChanged:v}=e,S=Math.round(p/g*100),w=t.isRunning,k=()=>{Ft.send("context.applyDynamic",{}),l(!0)};return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:$1(S,x),children:[sh(p)," / ",sh(g)]}),c.jsxs("span",{className:$1(S,x),children:["(",S,"%)"]}),c.jsx(v2,{percent:S,dangerZone:x}),c.jsx(JM,{dangerZone:x}),_>0&&c.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[_,"x"]})]}),c.jsx("div",{className:"flex-1 flex justify-end",children:c.jsxs("div",{className:"relative",children:[c.jsx("button",{onClick:()=>s(!r),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:c.jsx(tk,{})}),r&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>s(!1)}),c.jsxs("div",{className:"absolute right-0 top-full mt-1.5 z-50 bg-bg-secondary border border-border rounded-lg shadow-xl py-1 min-w-[160px]",children:[c.jsx("button",{onClick:()=>{w||n(),s(!1)},disabled:w,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:w?"Cannot compact while running":"Compact context",children:c.jsx("span",{className:x?"text-accent-error":"",children:"Compact"})}),v&&c.jsx("button",{onClick:()=>{s(!1),f(!0)},disabled:w,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:w?"Cannot apply while running":"Apply dynamic context",children:c.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]})})]})}),v&&!a&&c.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[c.jsx("span",{children:"System prompt has changed —"}),c.jsx("button",{onClick:()=>f(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),c.jsx("button",{onClick:()=>l(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:c.jsx(Hc,{})})]})}),c.jsxs(Et,{isOpen:d,onClose:()=>f(!1),title:"Update system prompt",size:"sm",children:[c.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix."}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:()=>f(!1),className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),c.jsx("button",{onClick:()=>{k(),f(!1)},disabled:w,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Update"})]})]})]})}function eO({stats:e,onClose:t}){var n;return c.jsx(Et,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"flex items-center gap-3",children:c.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",e.mode]})}),c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[c.jsx(kd,{label:"Total Time",value:`${e.totalTime.toFixed(1)}s`}),c.jsx(kd,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),c.jsx(kd,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),c.jsx(kd,{label:"LLM Calls",value:String(((n=e.llmCalls)==null?void 0:n.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((r,s)=>c.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",s+1]}),c.jsxs("span",{className:"text-xs text-text-muted",children:[r.ttft.toFixed(2),"s TTFT · ",r.completionTime.toFixed(2),"s gen"]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",c.jsxs("span",{className:"text-text-primary",children:[r.promptTokens," → ",r.completionTokens]})]}),c.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[r.temperature!==void 0&&c.jsx(Ed,{label:"temp",value:r.temperature.toFixed(2)}),r.topP!==void 0&&c.jsx(Ed,{label:"topP",value:r.topP.toFixed(2)}),r.topK!==void 0&&c.jsx(Ed,{label:"topK",value:String(r.topK)}),r.maxTokens!==void 0&&c.jsx(Ed,{label:"maxTok",value:String(r.maxTokens)})]})]})]},s))]})]})})}function kd({label:e,value:t}){return c.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[c.jsx("div",{className:"text-xs text-text-muted",children:e}),c.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function Ed({label:e,value:t}){return c.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[c.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}function b2(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const tO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rO={};function H1(e,t){return(rO.jsx?nO:tO).test(e)}const sO=/[ \t\n\f\r]/g;function $h(e){return typeof e=="object"?e.type==="text"?F1(e.value):!1:F1(e)}function F1(e){return e.replace(sO,"")===""}class Yc{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Yc.prototype.normal={};Yc.prototype.property={};Yc.prototype.space=void 0;function S2(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Yc(n,r,t)}function y_(e){return e.toLowerCase()}class sr{constructor(t,n){this.attribute=n,this.property=t}}sr.prototype.attribute="";sr.prototype.booleanish=!1;sr.prototype.boolean=!1;sr.prototype.commaOrSpaceSeparated=!1;sr.prototype.commaSeparated=!1;sr.prototype.defined=!1;sr.prototype.mustUseProperty=!1;sr.prototype.number=!1;sr.prototype.overloadedBoolean=!1;sr.prototype.property="";sr.prototype.spaceSeparated=!1;sr.prototype.space=void 0;let iO=0;const Ye=Ma(),on=Ma(),v_=Ma(),be=Ma(),At=Ma(),Fo=Ma(),pr=Ma();function Ma(){return 2**++iO}const b_=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ye,booleanish:on,commaOrSpaceSeparated:pr,commaSeparated:Fo,number:be,overloadedBoolean:v_,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),Gp=Object.keys(b_);class xx extends sr{constructor(t,n,r,s){let a=-1;if(super(t,n),U1(this,"space",s),typeof r=="number")for(;++a<Gp.length;){const l=Gp[a];U1(this,Gp[a],(r&b_[l])===b_[l])}}}xx.prototype.defined=!0;function U1(e,t,n){n&&(e[t]=n)}function Qo(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const a=new xx(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[y_(r)]=r,n[y_(a.attribute)]=r}return new Yc(t,n,e.space)}const w2=Qo({properties:{ariaActiveDescendant:null,ariaAtomic:on,ariaAutoComplete:null,ariaBusy:on,ariaChecked:on,ariaColCount:be,ariaColIndex:be,ariaColSpan:be,ariaControls:At,ariaCurrent:null,ariaDescribedBy:At,ariaDetails:null,ariaDisabled:on,ariaDropEffect:At,ariaErrorMessage:null,ariaExpanded:on,ariaFlowTo:At,ariaGrabbed:on,ariaHasPopup:null,ariaHidden:on,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:At,ariaLevel:be,ariaLive:null,ariaModal:on,ariaMultiLine:on,ariaMultiSelectable:on,ariaOrientation:null,ariaOwns:At,ariaPlaceholder:null,ariaPosInSet:be,ariaPressed:on,ariaReadOnly:on,ariaRelevant:null,ariaRequired:on,ariaRoleDescription:At,ariaRowCount:be,ariaRowIndex:be,ariaRowSpan:be,ariaSelected:on,ariaSetSize:be,ariaSort:null,ariaValueMax:be,ariaValueMin:be,ariaValueNow:be,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function C2(e,t){return t in e?e[t]:t}function k2(e,t){return C2(e,t.toLowerCase())}const aO=Qo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Fo,acceptCharset:At,accessKey:At,action:null,allow:null,allowFullScreen:Ye,allowPaymentRequest:Ye,allowUserMedia:Ye,alt:null,as:null,async:Ye,autoCapitalize:null,autoComplete:At,autoFocus:Ye,autoPlay:Ye,blocking:At,capture:null,charSet:null,checked:Ye,cite:null,className:At,cols:be,colSpan:null,content:null,contentEditable:on,controls:Ye,controlsList:At,coords:be|Fo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ye,defer:Ye,dir:null,dirName:null,disabled:Ye,download:v_,draggable:on,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ye,formTarget:null,headers:At,height:be,hidden:v_,high:be,href:null,hrefLang:null,htmlFor:At,httpEquiv:At,id:null,imageSizes:null,imageSrcSet:null,inert:Ye,inputMode:null,integrity:null,is:null,isMap:Ye,itemId:null,itemProp:At,itemRef:At,itemScope:Ye,itemType:At,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ye,low:be,manifest:null,max:null,maxLength:be,media:null,method:null,min:null,minLength:be,multiple:Ye,muted:Ye,name:null,nonce:null,noModule:Ye,noValidate:Ye,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ye,optimum:be,pattern:null,ping:At,placeholder:null,playsInline:Ye,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ye,referrerPolicy:null,rel:At,required:Ye,reversed:Ye,rows:be,rowSpan:be,sandbox:At,scope:null,scoped:Ye,seamless:Ye,selected:Ye,shadowRootClonable:Ye,shadowRootDelegatesFocus:Ye,shadowRootMode:null,shape:null,size:be,sizes:null,slot:null,span:be,spellCheck:on,src:null,srcDoc:null,srcLang:null,srcSet:null,start:be,step:null,style:null,tabIndex:be,target:null,title:null,translate:null,type:null,typeMustMatch:Ye,useMap:null,value:on,width:be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:At,axis:null,background:null,bgColor:null,border:be,borderColor:null,bottomMargin:be,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ye,declare:Ye,event:null,face:null,frame:null,frameBorder:null,hSpace:be,leftMargin:be,link:null,longDesc:null,lowSrc:null,marginHeight:be,marginWidth:be,noResize:Ye,noHref:Ye,noShade:Ye,noWrap:Ye,object:null,profile:null,prompt:null,rev:null,rightMargin:be,rules:null,scheme:null,scrolling:on,standby:null,summary:null,text:null,topMargin:be,valueType:null,version:null,vAlign:null,vLink:null,vSpace:be,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ye,disableRemotePlayback:Ye,prefix:null,property:null,results:be,security:null,unselectable:null},space:"html",transform:k2}),oO=Qo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pr,accentHeight:be,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:be,amplitude:be,arabicForm:null,ascent:be,attributeName:null,attributeType:null,azimuth:be,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:be,by:null,calcMode:null,capHeight:be,className:At,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:be,diffuseConstant:be,direction:null,display:null,dur:null,divisor:be,dominantBaseline:null,download:Ye,dx:null,dy:null,edgeMode:null,editable:null,elevation:be,enableBackground:null,end:null,event:null,exponent:be,externalResourcesRequired:null,fill:null,fillOpacity:be,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Fo,g2:Fo,glyphName:Fo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:be,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:be,horizOriginX:be,horizOriginY:be,id:null,ideographic:be,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:be,k:be,k1:be,k2:be,k3:be,k4:be,kernelMatrix:pr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:be,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:be,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:be,overlineThickness:be,paintOrder:null,panose1:null,path:null,pathLength:be,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:At,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:be,pointsAtY:be,pointsAtZ:be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pr,rev:pr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pr,requiredFeatures:pr,requiredFonts:pr,requiredFormats:pr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:be,specularExponent:be,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:be,strikethroughThickness:be,string:null,stroke:null,strokeDashArray:pr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:be,strokeOpacity:be,strokeWidth:null,style:null,surfaceScale:be,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pr,tabIndex:be,tableValues:null,target:null,targetX:be,targetY:be,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:be,underlineThickness:be,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:be,values:null,vAlphabetic:be,vMathematical:be,vectorEffect:null,vHanging:be,vIdeographic:be,version:null,vertAdvY:be,vertOriginX:be,vertOriginY:be,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:be,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:C2}),E2=Qo({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()}}),N2=Qo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:k2}),j2=Qo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),lO={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"},cO=/[A-Z]/g,V1=/-[a-z]/g,uO=/^data[-\w.:]+$/i;function T2(e,t){const n=y_(t);let r=t,s=sr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&uO.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(V1,hO);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!V1.test(a)){let l=a.replace(cO,dO);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}s=xx}return new s(r,t)}function dO(e){return"-"+e.toLowerCase()}function hO(e){return e.charAt(1).toUpperCase()}const A2=S2([w2,aO,E2,N2,j2],"html"),Xc=S2([w2,oO,E2,N2,j2],"svg");function D2(e){return e.join(" ").trim()}var jo={},qp,W1;function fO(){if(W1)return qp;W1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,d=/^\s+|\s+$/g,f=`
113
- `,h="/",p="*",g="",_="comment",x="declaration";function v(w,k){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];k=k||{};var j=1,T=1;function A(U){var D=U.match(t);D&&(j+=D.length);var N=U.lastIndexOf(f);T=~N?U.length-N:T+U.length}function P(){var U={line:j,column:T};return function(D){return D.position=new R(U),ne(),D}}function R(U){this.start=U,this.end={line:j,column:T},this.source=k.source}R.prototype.content=w;function q(U){var D=new Error(k.source+":"+j+":"+T+": "+U);if(D.reason=U,D.filename=k.source,D.line=j,D.column=T,D.source=w,!k.silent)throw D}function J(U){var D=U.exec(w);if(D){var N=D[0];return A(N),w=w.slice(N.length),D}}function ne(){J(n)}function I(U){var D;for(U=U||[];D=W();)D!==!1&&U.push(D);return U}function W(){var U=P();if(!(h!=w.charAt(0)||p!=w.charAt(1))){for(var D=2;g!=w.charAt(D)&&(p!=w.charAt(D)||h!=w.charAt(D+1));)++D;if(D+=2,g===w.charAt(D-1))return q("End of comment missing");var N=w.slice(2,D-2);return T+=2,A(N),w=w.slice(D),T+=2,U({type:_,comment:N})}}function z(){var U=P(),D=J(r);if(D){if(W(),!J(s))return q("property missing ':'");var N=J(a),F=U({type:x,property:S(D[0].replace(e,g)),value:N?S(N[0].replace(e,g)):g});return J(l),F}}function L(){var U=[];I(U);for(var D;D=z();)D!==!1&&(U.push(D),I(U));return U}return ne(),L()}function S(w){return w?w.replace(d,g):g}return qp=v,qp}var G1;function mO(){if(G1)return jo;G1=1;var e=jo&&jo.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(jo,"__esModule",{value:!0}),jo.default=n;const t=e(fO());function n(r,s){let a=null;if(!r||typeof r!="string")return a;const l=(0,t.default)(r),d=typeof s=="function";return l.forEach(f=>{if(f.type!=="declaration")return;const{property:h,value:p}=f;d?s(h,p,f):p&&(a=a||{},a[h]=p)}),a}return jo}var rc={},q1;function pO(){if(q1)return rc;q1=1,Object.defineProperty(rc,"__esModule",{value:!0}),rc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,a=function(h){return!h||n.test(h)||e.test(h)},l=function(h,p){return p.toUpperCase()},d=function(h,p){return"".concat(p,"-")},f=function(h,p){return p===void 0&&(p={}),a(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(s,d):h=h.replace(r,d),h.replace(t,l))};return rc.camelCase=f,rc}var sc,K1;function gO(){if(K1)return sc;K1=1;var e=sc&&sc.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(mO()),n=pO();function r(s,a){var l={};return!s||typeof s!="string"||(0,t.default)(s,function(d,f){d&&f&&(l[(0,n.camelCase)(d,a)]=f)}),l}return r.default=r,sc=r,sc}var _O=gO();const xO=kh(_O),L2=R2("end"),yx=R2("start");function R2(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 yO(e){const t=yx(e),n=L2(e);if(t&&n)return{start:t,end:n}}function bc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Y1(e.position):"start"in e||"end"in e?Y1(e):"line"in e||"column"in e?S_(e):""}function S_(e){return X1(e&&e.line)+":"+X1(e&&e.column)}function Y1(e){return S_(e&&e.start)+"-"+S_(e&&e.end)}function X1(e){return e&&typeof e=="number"?e:1}class Hn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",a={},l=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?s=t:!a.cause&&t&&(l=!0,s=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const f=r.indexOf(":");f===-1?a.ruleId=r:(a.source=r.slice(0,f),a.ruleId=r.slice(f+1))}if(!a.place&&a.ancestors&&a.ancestors){const f=a.ancestors[a.ancestors.length-1];f&&(a.place=f.position)}const d=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=d?d.line:void 0,this.name=bc(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=l&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Hn.prototype.file="";Hn.prototype.name="";Hn.prototype.reason="";Hn.prototype.message="";Hn.prototype.stack="";Hn.prototype.column=void 0;Hn.prototype.line=void 0;Hn.prototype.ancestors=void 0;Hn.prototype.cause=void 0;Hn.prototype.fatal=void 0;Hn.prototype.place=void 0;Hn.prototype.ruleId=void 0;Hn.prototype.source=void 0;const vx={}.hasOwnProperty,vO=new Map,bO=/[A-Z]/g,SO=new Set(["table","tbody","thead","tfoot","tr"]),wO=new Set(["td","th"]),M2="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function CO(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=LO(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=DO(n,t.jsx,t.jsxs)}const s={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"?Xc:A2,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=O2(s,e,void 0);return a&&typeof a!="string"?a:s.create(e,s.Fragment,{children:a||void 0},void 0)}function O2(e,t,n){if(t.type==="element")return kO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return EO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return jO(e,t,n);if(t.type==="mdxjsEsm")return NO(e,t);if(t.type==="root")return TO(e,t,n);if(t.type==="text")return AO(e,t)}function kO(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Xc,e.schema=s),e.ancestors.push(t);const a=P2(e,t.tagName,!1),l=RO(e,t);let d=Sx(e,t);return SO.has(t.tagName)&&(d=d.filter(function(f){return typeof f=="string"?!$h(f):!0})),I2(e,l,a,t),bx(l,d),e.ancestors.pop(),e.schema=r,e.create(t,a,l,n)}function EO(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)}Dc(e,t.position)}function NO(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Dc(e,t.position)}function jO(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Xc,e.schema=s),e.ancestors.push(t);const a=t.name===null?e.Fragment:P2(e,t.name,!0),l=MO(e,t),d=Sx(e,t);return I2(e,l,a,t),bx(l,d),e.ancestors.pop(),e.schema=r,e.create(t,a,l,n)}function TO(e,t,n){const r={};return bx(r,Sx(e,t)),e.create(t,e.Fragment,r,n)}function AO(e,t){return t.value}function I2(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function bx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function DO(e,t,n){return r;function r(s,a,l,d){const h=Array.isArray(l.children)?n:t;return d?h(a,l,d):h(a,l)}}function LO(e,t){return n;function n(r,s,a,l){const d=Array.isArray(a.children),f=yx(r);return t(s,a,l,d,{columnNumber:f?f.column-1:void 0,fileName:e,lineNumber:f?f.line:void 0},void 0)}}function RO(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&vx.call(t.properties,s)){const a=OO(e,s,t.properties[s]);if(a){const[l,d]=a;e.tableCellAlignToStyle&&l==="align"&&typeof d=="string"&&wO.has(t.tagName)?r=d:n[l]=d}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function MO(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const l=a.expression;l.type;const d=l.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else Dc(e,t.position);else{const s=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const d=r.value.data.estree.body[0];d.type,a=e.evaluater.evaluateExpression(d.expression)}else Dc(e,t.position);else a=r.value===null?!0:r.value;n[s]=a}return n}function Sx(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:vO;for(;++r<t.children.length;){const a=t.children[r];let l;if(e.passKeys){const f=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(f){const h=s.get(f)||0;l=f+"-"+h,s.set(f,h+1)}}const d=O2(e,a,l);d!==void 0&&n.push(d)}return n}function OO(e,t,n){const r=T2(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?b2(n):D2(n)),r.property==="style"){let s=typeof n=="object"?n:IO(e,String(n));return e.stylePropertyNameCase==="css"&&(s=PO(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?lO[r.property]||r.property:r.attribute,n]}}function IO(e,t){try{return xO(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Hn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=M2+"#cannot-parse-style-attribute",s}}function P2(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let a=-1,l;for(;++a<s.length;){const d=H1(s[a])?{type:"Identifier",name:s[a]}:{type:"Literal",value:s[a]};l=l?{type:"MemberExpression",object:l,property:d,computed:!!(a&&d.type==="Literal"),optional:!1}:d}r=l}else r=H1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return vx.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Dc(e)}function Dc(e,t){const n=new Hn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=M2+"#cannot-handle-mdx-estrees-without-createevaluater",n}function PO(e){const t={};let n;for(n in e)vx.call(e,n)&&(t[BO(n)]=e[n]);return t}function BO(e){let t=e.replace(bO,zO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function zO(e){return"-"+e.toLowerCase()}const Kp={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"]},$O={};function wx(e,t){const n=$O,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return B2(e,r,s)}function B2(e,t,n){if(HO(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 Q1(e.children,t,n)}return Array.isArray(e)?Q1(e,t,n):""}function Q1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=B2(e[s],t,n);return r.join("")}function HO(e){return!!(e&&typeof e=="object")}const J1=document.createElement("i");function Cx(e){const t="&"+e+";";J1.innerHTML=t;const n=J1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function _r(e,t,n,r){const s=e.length;let a=0,l;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)l=Array.from(r),l.unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);a<r.length;)l=r.slice(a,a+1e4),l.unshift(t,0),e.splice(...l),a+=1e4,t+=1e4}function Rr(e,t){return e.length>0?(_r(e,e.length,0,t),e):t}const Z1={}.hasOwnProperty;function z2(e){const t={};let n=-1;for(;++n<e.length;)FO(t,e[n]);return t}function FO(e,t){let n;for(n in t){const s=(Z1.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let l;if(a)for(l in a){Z1.call(s,l)||(s[l]=[]);const d=a[l];UO(s[l],Array.isArray(d)?d:d?[d]:[])}}}function UO(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);_r(e,0,0,r)}function $2(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 Xr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Wn=Hi(/[A-Za-z]/),$n=Hi(/[\dA-Za-z]/),VO=Hi(/[#-'*+\--9=?A-Z^-~]/);function oh(e){return e!==null&&(e<32||e===127)}const w_=Hi(/\d/),WO=Hi(/[\dA-Fa-f]/),GO=Hi(/[!-/:-@[-`{-~]/);function Be(e){return e!==null&&e<-2}function Tt(e){return e!==null&&(e<0||e===32)}function rt(e){return e===-2||e===-1||e===32}const Hh=Hi(new RegExp("\\p{P}|\\p{S}","u")),Aa=Hi(/\s/);function Hi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Jo(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const a=e.charCodeAt(n);let l="";if(a===37&&$n(e.charCodeAt(n+1))&&$n(e.charCodeAt(n+2)))s=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(l=String.fromCharCode(a));else if(a>55295&&a<57344){const d=e.charCodeAt(n+1);a<56320&&d>56319&&d<57344?(l=String.fromCharCode(a,d),s=1):l="�"}else l=String.fromCharCode(a);l&&(t.push(e.slice(r,n),encodeURIComponent(l)),r=n+s+1,l=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function ct(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let a=0;return l;function l(f){return rt(f)?(e.enter(n),d(f)):t(f)}function d(f){return rt(f)&&a++<s?(e.consume(f),d):(e.exit(n),t(f))}}const qO={tokenize:KO};function KO(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),ct(e,t,"linePrefix")}function s(d){return e.enter("paragraph"),a(d)}function a(d){const f=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=f),n=f,l(d)}function l(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return Be(d)?(e.consume(d),e.exit("chunkText"),a):(e.consume(d),l)}}const YO={tokenize:XO},ew={tokenize:QO};function XO(e){const t=this,n=[];let r=0,s,a,l;return d;function d(T){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,f,h)(T)}return h(T)}function f(T){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&j();const A=t.events.length;let P=A,R;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){R=t.events[P][1].end;break}k(r);let q=A;for(;q<t.events.length;)t.events[q][1].end={...R},q++;return _r(t.events,P+1,0,t.events.slice(A)),t.events.length=q,h(T)}return d(T)}function h(T){if(r===n.length){if(!s)return _(T);if(s.currentConstruct&&s.currentConstruct.concrete)return v(T);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ew,p,g)(T)}function p(T){return s&&j(),k(r),_(T)}function g(T){return t.parser.lazy[t.now().line]=r!==n.length,l=t.now().offset,v(T)}function _(T){return t.containerState={},e.attempt(ew,x,v)(T)}function x(T){return r++,n.push([t.currentConstruct,t.containerState]),_(T)}function v(T){if(T===null){s&&j(),k(0),e.consume(T);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:a}),S(T)}function S(T){if(T===null){w(e.exit("chunkFlow"),!0),k(0),e.consume(T);return}return Be(T)?(e.consume(T),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,d):(e.consume(T),S)}function w(T,A){const P=t.sliceStream(T);if(A&&P.push(null),T.previous=a,a&&(a.next=T),a=T,s.defineSkip(T.start),s.write(P),t.parser.lazy[T.start.line]){let R=s.events.length;for(;R--;)if(s.events[R][1].start.offset<l&&(!s.events[R][1].end||s.events[R][1].end.offset>l))return;const q=t.events.length;let J=q,ne,I;for(;J--;)if(t.events[J][0]==="exit"&&t.events[J][1].type==="chunkFlow"){if(ne){I=t.events[J][1].end;break}ne=!0}for(k(r),R=q;R<t.events.length;)t.events[R][1].end={...I},R++;_r(t.events,J+1,0,t.events.slice(q)),t.events.length=R}}function k(T){let A=n.length;for(;A-- >T;){const P=n[A];t.containerState=P[1],P[0].exit.call(t,e)}n.length=T}function j(){s.write([null]),a=void 0,s=void 0,t.containerState._closeFlow=void 0}}function QO(e,t,n){return ct(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Wo(e){if(e===null||Tt(e)||Aa(e))return 1;if(Hh(e))return 2}function Fh(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const a=e[s].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const C_={name:"attention",resolveAll:JO,tokenize:ZO};function JO(e,t){let n=-1,r,s,a,l,d,f,h,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;f=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[r][1].end},_={...e[n][1].start};tw(g,-f),tw(_,f),l={type:f>1?"strongSequence":"emphasisSequence",start:g,end:{...e[r][1].end}},d={type:f>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:_},a={type:f>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:f>1?"strong":"emphasis",start:{...l.start},end:{...d.end}},e[r][1].end={...l.start},e[n][1].start={...d.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=Rr(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=Rr(h,[["enter",s,t],["enter",l,t],["exit",l,t],["enter",a,t]]),h=Rr(h,Fh(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=Rr(h,[["exit",a,t],["enter",d,t],["exit",d,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,h=Rr(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,_r(e,r-1,n-r+3,h),n=r+h.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function ZO(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=Wo(r);let a;return l;function l(f){return a=f,e.enter("attentionSequence"),d(f)}function d(f){if(f===a)return e.consume(f),d;const h=e.exit("attentionSequence"),p=Wo(f),g=!p||p===2&&s||n.includes(f),_=!s||s===2&&p||n.includes(r);return h._open=!!(a===42?g:g&&(s||!_)),h._close=!!(a===42?_:_&&(p||!g)),t(f)}}function tw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const e4={name:"autolink",tokenize:t4};function t4(e,t,n){let r=0;return s;function s(x){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(x){return Wn(x)?(e.consume(x),l):x===64?n(x):h(x)}function l(x){return x===43||x===45||x===46||$n(x)?(r=1,d(x)):h(x)}function d(x){return x===58?(e.consume(x),r=0,f):(x===43||x===45||x===46||$n(x))&&r++<32?(e.consume(x),d):(r=0,h(x))}function f(x){return x===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):x===null||x===32||x===60||oh(x)?n(x):(e.consume(x),f)}function h(x){return x===64?(e.consume(x),p):VO(x)?(e.consume(x),h):n(x)}function p(x){return $n(x)?g(x):n(x)}function g(x){return x===46?(e.consume(x),r=0,p):x===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):_(x)}function _(x){if((x===45||$n(x))&&r++<63){const v=x===45?_:g;return e.consume(x),v}return n(x)}}const Qc={partial:!0,tokenize:n4};function n4(e,t,n){return r;function r(a){return rt(a)?ct(e,s,"linePrefix")(a):s(a)}function s(a){return a===null||Be(a)?t(a):n(a)}}const H2={continuation:{tokenize:s4},exit:i4,name:"blockQuote",tokenize:r4};function r4(e,t,n){const r=this;return s;function s(l){if(l===62){const d=r.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),a}return n(l)}function a(l){return rt(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(l))}}function s4(e,t,n){const r=this;return s;function s(l){return rt(l)?ct(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):a(l)}function a(l){return e.attempt(H2,t,n)(l)}}function i4(e){e.exit("blockQuote")}const F2={name:"characterEscape",tokenize:a4};function a4(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),s}function s(a){return GO(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const U2={name:"characterReference",tokenize:o4};function o4(e,t,n){const r=this;let s=0,a,l;return d;function d(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),f}function f(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),a=31,l=$n,p(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,l=WO,p):(e.enter("characterReferenceValue"),a=7,l=w_,p(g))}function p(g){if(g===59&&s){const _=e.exit("characterReferenceValue");return l===$n&&!Cx(r.sliceSerialize(_))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return l(g)&&s++<a?(e.consume(g),p):n(g)}}const nw={partial:!0,tokenize:c4},rw={concrete:!0,name:"codeFenced",tokenize:l4};function l4(e,t,n){const r=this,s={partial:!0,tokenize:P};let a=0,l=0,d;return f;function f(R){return h(R)}function h(R){const q=r.events[r.events.length-1];return a=q&&q[1].type==="linePrefix"?q[2].sliceSerialize(q[1],!0).length:0,d=R,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(R)}function p(R){return R===d?(l++,e.consume(R),p):l<3?n(R):(e.exit("codeFencedFenceSequence"),rt(R)?ct(e,g,"whitespace")(R):g(R))}function g(R){return R===null||Be(R)?(e.exit("codeFencedFence"),r.interrupt?t(R):e.check(nw,S,A)(R)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),_(R))}function _(R){return R===null||Be(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(R)):rt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ct(e,x,"whitespace")(R)):R===96&&R===d?n(R):(e.consume(R),_)}function x(R){return R===null||Be(R)?g(R):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),v(R))}function v(R){return R===null||Be(R)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(R)):R===96&&R===d?n(R):(e.consume(R),v)}function S(R){return e.attempt(s,A,w)(R)}function w(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),k}function k(R){return a>0&&rt(R)?ct(e,j,"linePrefix",a+1)(R):j(R)}function j(R){return R===null||Be(R)?e.check(nw,S,A)(R):(e.enter("codeFlowValue"),T(R))}function T(R){return R===null||Be(R)?(e.exit("codeFlowValue"),j(R)):(e.consume(R),T)}function A(R){return e.exit("codeFenced"),t(R)}function P(R,q,J){let ne=0;return I;function I(D){return R.enter("lineEnding"),R.consume(D),R.exit("lineEnding"),W}function W(D){return R.enter("codeFencedFence"),rt(D)?ct(R,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):z(D)}function z(D){return D===d?(R.enter("codeFencedFenceSequence"),L(D)):J(D)}function L(D){return D===d?(ne++,R.consume(D),L):ne>=l?(R.exit("codeFencedFenceSequence"),rt(D)?ct(R,U,"whitespace")(D):U(D)):J(D)}function U(D){return D===null||Be(D)?(R.exit("codeFencedFence"),q(D)):J(D)}}}function c4(e,t,n){const r=this;return s;function s(l){return l===null?n(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a)}function a(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}const Yp={name:"codeIndented",tokenize:d4},u4={partial:!0,tokenize:h4};function d4(e,t,n){const r=this;return s;function s(h){return e.enter("codeIndented"),ct(e,a,"linePrefix",5)(h)}function a(h){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?l(h):n(h)}function l(h){return h===null?f(h):Be(h)?e.attempt(u4,l,f)(h):(e.enter("codeFlowValue"),d(h))}function d(h){return h===null||Be(h)?(e.exit("codeFlowValue"),l(h)):(e.consume(h),d)}function f(h){return e.exit("codeIndented"),t(h)}}function h4(e,t,n){const r=this;return s;function s(l){return r.parser.lazy[r.now().line]?n(l):Be(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s):ct(e,a,"linePrefix",5)(l)}function a(l){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(l):Be(l)?s(l):n(l)}}const f4={name:"codeText",previous:p4,resolve:m4,tokenize:g4};function m4(e){let t=e.length-4,n=3,r,s;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;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function p4(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function g4(e,t,n){let r=0,s,a;return l;function l(g){return e.enter("codeText"),e.enter("codeTextSequence"),d(g)}function d(g){return g===96?(e.consume(g),r++,d):(e.exit("codeTextSequence"),f(g))}function f(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),f):g===96?(a=e.enter("codeTextSequence"),s=0,p(g)):Be(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),f):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||Be(g)?(e.exit("codeTextData"),f(g)):(e.consume(g),h)}function p(g){return g===96?(e.consume(g),s++,p):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(a.type="codeTextData",h(g))}}class _4{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 s=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&ic(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ic(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ic(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ic(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ic(this.left,n.reverse())}}}function ic(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function V2(e){const t={};let n=-1,r,s,a,l,d,f,h;const p=new _4(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(f=r[1]._tokenizer.events,a=0,a<f.length&&f[a][1].type==="lineEndingBlank"&&(a+=2),a<f.length&&f[a][1].type==="content"))for(;++a<f.length&&f[a][1].type!=="content";)f[a][1].type==="chunkText"&&(f[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,x4(p,n)),n=t[n],h=!0);else if(r[1]._container){for(a=n,s=void 0;a--;)if(l=p.get(a),l[1].type==="lineEnding"||l[1].type==="lineEndingBlank")l[0]==="enter"&&(s&&(p.get(s)[1].type="lineEndingBlank"),l[1].type="lineEnding",s=a);else if(!(l[1].type==="linePrefix"||l[1].type==="listItemIndent"))break;s&&(r[1].end={...p.get(s)[1].start},d=p.slice(s,n),d.unshift(r),p.splice(s,n-s+1,d))}}return _r(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function x4(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const a=[];let l=n._tokenizer;l||(l=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));const d=l.events,f=[],h={};let p,g,_=-1,x=n,v=0,S=0;const w=[S];for(;x;){for(;e.get(++s)[1]!==x;);a.push(s),x._tokenizer||(p=r.sliceStream(x),x.next||p.push(null),g&&l.defineSkip(x.start),x._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(p),x._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),g=x,x=x.next}for(x=n;++_<d.length;)d[_][0]==="exit"&&d[_-1][0]==="enter"&&d[_][1].type===d[_-1][1].type&&d[_][1].start.line!==d[_][1].end.line&&(S=_+1,w.push(S),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(l.events=[],x?(x._tokenizer=void 0,x.previous=void 0):w.pop(),_=w.length;_--;){const k=d.slice(w[_],w[_+1]),j=a.pop();f.push([j,j+k.length-1]),e.splice(j,2,k)}for(f.reverse(),_=-1;++_<f.length;)h[v+f[_][0]]=v+f[_][1],v+=f[_][1]-f[_][0]-1;return h}const y4={resolve:b4,tokenize:S4},v4={partial:!0,tokenize:w4};function b4(e){return V2(e),e}function S4(e,t){let n;return r;function r(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(d)}function s(d){return d===null?a(d):Be(d)?e.check(v4,l,a)(d):(e.consume(d),s)}function a(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function l(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function w4(e,t,n){const r=this;return s;function s(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),ct(e,a,"linePrefix")}function a(l){if(l===null||Be(l))return n(l);const d=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}function W2(e,t,n,r,s,a,l,d,f){const h=f||Number.POSITIVE_INFINITY;let p=0;return g;function g(k){return k===60?(e.enter(r),e.enter(s),e.enter(a),e.consume(k),e.exit(a),_):k===null||k===32||k===41||oh(k)?n(k):(e.enter(r),e.enter(l),e.enter(d),e.enter("chunkString",{contentType:"string"}),S(k))}function _(k){return k===62?(e.enter(a),e.consume(k),e.exit(a),e.exit(s),e.exit(r),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),x(k))}function x(k){return k===62?(e.exit("chunkString"),e.exit(d),_(k)):k===null||k===60||Be(k)?n(k):(e.consume(k),k===92?v:x)}function v(k){return k===60||k===62||k===92?(e.consume(k),x):x(k)}function S(k){return!p&&(k===null||k===41||Tt(k))?(e.exit("chunkString"),e.exit(d),e.exit(l),e.exit(r),t(k)):p<h&&k===40?(e.consume(k),p++,S):k===41?(e.consume(k),p--,S):k===null||k===32||k===40||oh(k)?n(k):(e.consume(k),k===92?w:S)}function w(k){return k===40||k===41||k===92?(e.consume(k),S):S(k)}}function G2(e,t,n,r,s,a){const l=this;let d=0,f;return h;function h(x){return e.enter(r),e.enter(s),e.consume(x),e.exit(s),e.enter(a),p}function p(x){return d>999||x===null||x===91||x===93&&!f||x===94&&!d&&"_hiddenFootnoteSupport"in l.parser.constructs?n(x):x===93?(e.exit(a),e.enter(s),e.consume(x),e.exit(s),e.exit(r),t):Be(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),g(x))}function g(x){return x===null||x===91||x===93||Be(x)||d++>999?(e.exit("chunkString"),p(x)):(e.consume(x),f||(f=!rt(x)),x===92?_:g)}function _(x){return x===91||x===92||x===93?(e.consume(x),d++,g):g(x)}}function q2(e,t,n,r,s,a){let l;return d;function d(_){return _===34||_===39||_===40?(e.enter(r),e.enter(s),e.consume(_),e.exit(s),l=_===40?41:_,f):n(_)}function f(_){return _===l?(e.enter(s),e.consume(_),e.exit(s),e.exit(r),t):(e.enter(a),h(_))}function h(_){return _===l?(e.exit(a),f(l)):_===null?n(_):Be(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),ct(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(_))}function p(_){return _===l||_===null||Be(_)?(e.exit("chunkString"),h(_)):(e.consume(_),_===92?g:p)}function g(_){return _===l||_===92?(e.consume(_),p):p(_)}}function Sc(e,t){let n;return r;function r(s){return Be(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):rt(s)?ct(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const C4={name:"definition",tokenize:E4},k4={partial:!0,tokenize:N4};function E4(e,t,n){const r=this;let s;return a;function a(x){return e.enter("definition"),l(x)}function l(x){return G2.call(r,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function d(x){return s=Xr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),f):n(x)}function f(x){return Tt(x)?Sc(e,h)(x):h(x)}function h(x){return W2(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function p(x){return e.attempt(k4,g,g)(x)}function g(x){return rt(x)?ct(e,_,"whitespace")(x):_(x)}function _(x){return x===null||Be(x)?(e.exit("definition"),r.parser.defined.push(s),t(x)):n(x)}}function N4(e,t,n){return r;function r(d){return Tt(d)?Sc(e,s)(d):n(d)}function s(d){return q2(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function a(d){return rt(d)?ct(e,l,"whitespace")(d):l(d)}function l(d){return d===null||Be(d)?t(d):n(d)}}const j4={name:"hardBreakEscape",tokenize:T4};function T4(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),s}function s(a){return Be(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const A4={name:"headingAtx",resolve:D4,tokenize:L4};function D4(e,t){let n=e.length-2,r=3,s,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},_r(e,r,n-r+1,[["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t]])),e}function L4(e,t,n){let r=0;return s;function s(p){return e.enter("atxHeading"),a(p)}function a(p){return e.enter("atxHeadingSequence"),l(p)}function l(p){return p===35&&r++<6?(e.consume(p),l):p===null||Tt(p)?(e.exit("atxHeadingSequence"),d(p)):n(p)}function d(p){return p===35?(e.enter("atxHeadingSequence"),f(p)):p===null||Be(p)?(e.exit("atxHeading"),t(p)):rt(p)?ct(e,d,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function f(p){return p===35?(e.consume(p),f):(e.exit("atxHeadingSequence"),d(p))}function h(p){return p===null||p===35||Tt(p)?(e.exit("atxHeadingText"),d(p)):(e.consume(p),h)}}const R4=["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"],sw=["pre","script","style","textarea"],M4={concrete:!0,name:"htmlFlow",resolveTo:P4,tokenize:B4},O4={partial:!0,tokenize:$4},I4={partial:!0,tokenize:z4};function P4(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 B4(e,t,n){const r=this;let s,a,l,d,f;return h;function h(O){return p(O)}function p(O){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(O),g}function g(O){return O===33?(e.consume(O),_):O===47?(e.consume(O),a=!0,S):O===63?(e.consume(O),s=3,r.interrupt?t:B):Wn(O)?(e.consume(O),l=String.fromCharCode(O),w):n(O)}function _(O){return O===45?(e.consume(O),s=2,x):O===91?(e.consume(O),s=5,d=0,v):Wn(O)?(e.consume(O),s=4,r.interrupt?t:B):n(O)}function x(O){return O===45?(e.consume(O),r.interrupt?t:B):n(O)}function v(O){const Q="CDATA[";return O===Q.charCodeAt(d++)?(e.consume(O),d===Q.length?r.interrupt?t:z:v):n(O)}function S(O){return Wn(O)?(e.consume(O),l=String.fromCharCode(O),w):n(O)}function w(O){if(O===null||O===47||O===62||Tt(O)){const Q=O===47,G=l.toLowerCase();return!Q&&!a&&sw.includes(G)?(s=1,r.interrupt?t(O):z(O)):R4.includes(l.toLowerCase())?(s=6,Q?(e.consume(O),k):r.interrupt?t(O):z(O)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(O):a?j(O):T(O))}return O===45||$n(O)?(e.consume(O),l+=String.fromCharCode(O),w):n(O)}function k(O){return O===62?(e.consume(O),r.interrupt?t:z):n(O)}function j(O){return rt(O)?(e.consume(O),j):I(O)}function T(O){return O===47?(e.consume(O),I):O===58||O===95||Wn(O)?(e.consume(O),A):rt(O)?(e.consume(O),T):I(O)}function A(O){return O===45||O===46||O===58||O===95||$n(O)?(e.consume(O),A):P(O)}function P(O){return O===61?(e.consume(O),R):rt(O)?(e.consume(O),P):T(O)}function R(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),f=O,q):rt(O)?(e.consume(O),R):J(O)}function q(O){return O===f?(e.consume(O),f=null,ne):O===null||Be(O)?n(O):(e.consume(O),q)}function J(O){return O===null||O===34||O===39||O===47||O===60||O===61||O===62||O===96||Tt(O)?P(O):(e.consume(O),J)}function ne(O){return O===47||O===62||rt(O)?T(O):n(O)}function I(O){return O===62?(e.consume(O),W):n(O)}function W(O){return O===null||Be(O)?z(O):rt(O)?(e.consume(O),W):n(O)}function z(O){return O===45&&s===2?(e.consume(O),N):O===60&&s===1?(e.consume(O),F):O===62&&s===4?(e.consume(O),V):O===63&&s===3?(e.consume(O),B):O===93&&s===5?(e.consume(O),se):Be(O)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(O4,K,L)(O)):O===null||Be(O)?(e.exit("htmlFlowData"),L(O)):(e.consume(O),z)}function L(O){return e.check(I4,U,K)(O)}function U(O){return e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),D}function D(O){return O===null||Be(O)?L(O):(e.enter("htmlFlowData"),z(O))}function N(O){return O===45?(e.consume(O),B):z(O)}function F(O){return O===47?(e.consume(O),l="",H):z(O)}function H(O){if(O===62){const Q=l.toLowerCase();return sw.includes(Q)?(e.consume(O),V):z(O)}return Wn(O)&&l.length<8?(e.consume(O),l+=String.fromCharCode(O),H):z(O)}function se(O){return O===93?(e.consume(O),B):z(O)}function B(O){return O===62?(e.consume(O),V):O===45&&s===2?(e.consume(O),B):z(O)}function V(O){return O===null||Be(O)?(e.exit("htmlFlowData"),K(O)):(e.consume(O),V)}function K(O){return e.exit("htmlFlow"),t(O)}}function z4(e,t,n){const r=this;return s;function s(l){return Be(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a):n(l)}function a(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}function $4(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Qc,t,n)}}const H4={name:"htmlText",tokenize:F4};function F4(e,t,n){const r=this;let s,a,l;return d;function d(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),f}function f(B){return B===33?(e.consume(B),h):B===47?(e.consume(B),P):B===63?(e.consume(B),T):Wn(B)?(e.consume(B),J):n(B)}function h(B){return B===45?(e.consume(B),p):B===91?(e.consume(B),a=0,v):Wn(B)?(e.consume(B),j):n(B)}function p(B){return B===45?(e.consume(B),x):n(B)}function g(B){return B===null?n(B):B===45?(e.consume(B),_):Be(B)?(l=g,F(B)):(e.consume(B),g)}function _(B){return B===45?(e.consume(B),x):g(B)}function x(B){return B===62?N(B):B===45?_(B):g(B)}function v(B){const V="CDATA[";return B===V.charCodeAt(a++)?(e.consume(B),a===V.length?S:v):n(B)}function S(B){return B===null?n(B):B===93?(e.consume(B),w):Be(B)?(l=S,F(B)):(e.consume(B),S)}function w(B){return B===93?(e.consume(B),k):S(B)}function k(B){return B===62?N(B):B===93?(e.consume(B),k):S(B)}function j(B){return B===null||B===62?N(B):Be(B)?(l=j,F(B)):(e.consume(B),j)}function T(B){return B===null?n(B):B===63?(e.consume(B),A):Be(B)?(l=T,F(B)):(e.consume(B),T)}function A(B){return B===62?N(B):T(B)}function P(B){return Wn(B)?(e.consume(B),R):n(B)}function R(B){return B===45||$n(B)?(e.consume(B),R):q(B)}function q(B){return Be(B)?(l=q,F(B)):rt(B)?(e.consume(B),q):N(B)}function J(B){return B===45||$n(B)?(e.consume(B),J):B===47||B===62||Tt(B)?ne(B):n(B)}function ne(B){return B===47?(e.consume(B),N):B===58||B===95||Wn(B)?(e.consume(B),I):Be(B)?(l=ne,F(B)):rt(B)?(e.consume(B),ne):N(B)}function I(B){return B===45||B===46||B===58||B===95||$n(B)?(e.consume(B),I):W(B)}function W(B){return B===61?(e.consume(B),z):Be(B)?(l=W,F(B)):rt(B)?(e.consume(B),W):ne(B)}function z(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),s=B,L):Be(B)?(l=z,F(B)):rt(B)?(e.consume(B),z):(e.consume(B),U)}function L(B){return B===s?(e.consume(B),s=void 0,D):B===null?n(B):Be(B)?(l=L,F(B)):(e.consume(B),L)}function U(B){return B===null||B===34||B===39||B===60||B===61||B===96?n(B):B===47||B===62||Tt(B)?ne(B):(e.consume(B),U)}function D(B){return B===47||B===62||Tt(B)?ne(B):n(B)}function N(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),t):n(B)}function F(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),H}function H(B){return rt(B)?ct(e,se,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):se(B)}function se(B){return e.enter("htmlTextData"),l(B)}}const kx={name:"labelEnd",resolveAll:G4,resolveTo:q4,tokenize:K4},U4={tokenize:Y4},V4={tokenize:X4},W4={tokenize:Q4};function G4(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 s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&_r(e,0,e.length,n),e}function q4(e,t){let n=e.length,r=0,s,a,l,d;for(;n--;)if(s=e[n][1],a){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(l){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(a=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(l=n);const f={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[a][1].start},end:{...e[l][1].end}},p={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[l-2][1].start}};return d=[["enter",f,t],["enter",h,t]],d=Rr(d,e.slice(a+1,a+r+3)),d=Rr(d,[["enter",p,t]]),d=Rr(d,Fh(t.parser.constructs.insideSpan.null,e.slice(a+r+4,l-3),t)),d=Rr(d,[["exit",p,t],e[l-2],e[l-1],["exit",h,t]]),d=Rr(d,e.slice(l+1)),d=Rr(d,[["exit",f,t]]),_r(e,a,e.length,d),e}function K4(e,t,n){const r=this;let s=r.events.length,a,l;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){a=r.events[s][1];break}return d;function d(_){return a?a._inactive?g(_):(l=r.parser.defined.includes(Xr(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(_),e.exit("labelMarker"),e.exit("labelEnd"),f):n(_)}function f(_){return _===40?e.attempt(U4,p,l?p:g)(_):_===91?e.attempt(V4,p,l?h:g)(_):l?p(_):g(_)}function h(_){return e.attempt(W4,p,g)(_)}function p(_){return t(_)}function g(_){return a._balanced=!0,n(_)}}function Y4(e,t,n){return r;function r(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),s}function s(g){return Tt(g)?Sc(e,a)(g):a(g)}function a(g){return g===41?p(g):W2(e,l,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function l(g){return Tt(g)?Sc(e,f)(g):p(g)}function d(g){return n(g)}function f(g){return g===34||g===39||g===40?q2(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):p(g)}function h(g){return Tt(g)?Sc(e,p)(g):p(g)}function p(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function X4(e,t,n){const r=this;return s;function s(d){return G2.call(r,e,a,l,"reference","referenceMarker","referenceString")(d)}function a(d){return r.parser.defined.includes(Xr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function l(d){return n(d)}}function Q4(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),s}function s(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const J4={name:"labelStartImage",resolveAll:kx.resolveAll,tokenize:Z4};function Z4(e,t,n){const r=this;return s;function s(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),a}function a(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),l):n(d)}function l(d){return d===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(d):t(d)}}const eI={name:"labelStartLink",resolveAll:kx.resolveAll,tokenize:tI};function tI(e,t,n){const r=this;return s;function s(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),a}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const Xp={name:"lineEnding",tokenize:nI};function nI(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ct(e,t,"linePrefix")}}const qd={name:"thematicBreak",tokenize:rI};function rI(e,t,n){let r=0,s;return a;function a(h){return e.enter("thematicBreak"),l(h)}function l(h){return s=h,d(h)}function d(h){return h===s?(e.enter("thematicBreakSequence"),f(h)):r>=3&&(h===null||Be(h))?(e.exit("thematicBreak"),t(h)):n(h)}function f(h){return h===s?(e.consume(h),r++,f):(e.exit("thematicBreakSequence"),rt(h)?ct(e,d,"whitespace")(h):d(h))}}const rr={continuation:{tokenize:oI},exit:cI,name:"list",tokenize:aI},sI={partial:!0,tokenize:uI},iI={partial:!0,tokenize:lI};function aI(e,t,n){const r=this,s=r.events[r.events.length-1];let a=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,l=0;return d;function d(x){const v=r.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(v==="listUnordered"?!r.containerState.marker||x===r.containerState.marker:w_(x)){if(r.containerState.type||(r.containerState.type=v,e.enter(v,{_container:!0})),v==="listUnordered")return e.enter("listItemPrefix"),x===42||x===45?e.check(qd,n,h)(x):h(x);if(!r.interrupt||x===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),f(x)}return n(x)}function f(x){return w_(x)&&++l<10?(e.consume(x),f):(!r.interrupt||l<2)&&(r.containerState.marker?x===r.containerState.marker:x===41||x===46)?(e.exit("listItemValue"),h(x)):n(x)}function h(x){return e.enter("listItemMarker"),e.consume(x),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||x,e.check(Qc,r.interrupt?n:p,e.attempt(sI,_,g))}function p(x){return r.containerState.initialBlankLine=!0,a++,_(x)}function g(x){return rt(x)?(e.enter("listItemPrefixWhitespace"),e.consume(x),e.exit("listItemPrefixWhitespace"),_):n(x)}function _(x){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(x)}}function oI(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Qc,s,a);function s(d){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ct(e,t,"listItemIndent",r.containerState.size+1)(d)}function a(d){return r.containerState.furtherBlankLines||!rt(d)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(d)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(iI,t,l)(d))}function l(d){return r.containerState._closeFlow=!0,r.interrupt=void 0,ct(e,e.attempt(rr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function lI(e,t,n){const r=this;return ct(e,s,"listItemIndent",r.containerState.size+1);function s(a){const l=r.events[r.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(a):n(a)}}function cI(e){e.exit(this.containerState.type)}function uI(e,t,n){const r=this;return ct(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(a){const l=r.events[r.events.length-1];return!rt(a)&&l&&l[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const iw={name:"setextUnderline",resolveTo:dI,tokenize:hI};function dI(e,t){let n=e.length,r,s,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const l={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",a?(e.splice(s,0,["enter",l,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=l,e.push(["exit",l,t]),e}function hI(e,t,n){const r=this;let s;return a;function a(h){let p=r.events.length,g;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){g=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||g)?(e.enter("setextHeadingLine"),s=h,l(h)):n(h)}function l(h){return e.enter("setextHeadingLineSequence"),d(h)}function d(h){return h===s?(e.consume(h),d):(e.exit("setextHeadingLineSequence"),rt(h)?ct(e,f,"lineSuffix")(h):f(h))}function f(h){return h===null||Be(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const fI={tokenize:mI};function mI(e){const t=this,n=e.attempt(Qc,r,e.attempt(this.parser.constructs.flowInitial,s,ct(e,e.attempt(this.parser.constructs.flow,s,e.attempt(y4,s)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const pI={resolveAll:Y2()},gI=K2("string"),_I=K2("text");function K2(e){return{resolveAll:Y2(e==="text"?xI:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],a=n.attempt(s,l,d);return l;function l(p){return h(p)?a(p):d(p)}function d(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),f}function f(p){return h(p)?(n.exit("data"),a(p)):(n.consume(p),f)}function h(p){if(p===null)return!0;const g=s[p];let _=-1;if(g)for(;++_<g.length;){const x=g[_];if(!x.previous||x.previous.call(r,r.previous))return!0}return!1}}}function Y2(e){return t;function t(n,r){let s=-1,a;for(;++s<=n.length;)a===void 0?n[s]&&n[s][1].type==="data"&&(a=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==a+2&&(n[a][1].end=n[s-1][1].end,n.splice(a+2,s-a-2),s=a+2),a=void 0);return e?e(n,r):n}}function xI(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],s=t.sliceStream(r);let a=s.length,l=-1,d=0,f;for(;a--;){const h=s[a];if(typeof h=="string"){for(l=h.length;h.charCodeAt(l-1)===32;)d++,l--;if(l)break;l=-1}else if(h===-2)f=!0,d++;else if(h!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const h={type:n===e.length||f||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:r.start._bufferIndex+l,_index:r.start._index+a,line:r.end.line,column:r.end.column-d,offset:r.end.offset-d},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const yI={42:rr,43:rr,45:rr,48:rr,49:rr,50:rr,51:rr,52:rr,53:rr,54:rr,55:rr,56:rr,57:rr,62:H2},vI={91:C4},bI={[-2]:Yp,[-1]:Yp,32:Yp},SI={35:A4,42:qd,45:[iw,qd],60:M4,61:iw,95:qd,96:rw,126:rw},wI={38:U2,92:F2},CI={[-5]:Xp,[-4]:Xp,[-3]:Xp,33:J4,38:U2,42:C_,60:[e4,H4],91:eI,92:[j4,F2],93:kx,95:C_,96:f4},kI={null:[C_,pI]},EI={null:[42,95]},NI={null:[]},jI=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:EI,contentInitial:vI,disable:NI,document:yI,flow:SI,flowInitial:bI,insideSpan:kI,string:wI,text:CI},Symbol.toStringTag,{value:"Module"}));function TI(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 s={},a=[];let l=[],d=[];const f={attempt:q(P),check:q(R),consume:j,enter:T,exit:A,interrupt:q(R,{interrupt:!0})},h={code:null,containerState:{},defineSkip:S,events:[],now:v,parser:e,previous:null,sliceSerialize:_,sliceStream:x,write:g};let p=t.tokenize.call(h,f);return t.resolveAll&&a.push(t),h;function g(W){return l=Rr(l,W),w(),l[l.length-1]!==null?[]:(J(t,0),h.events=Fh(a,h.events,h),h.events)}function _(W,z){return DI(x(W),z)}function x(W){return AI(l,W)}function v(){const{_bufferIndex:W,_index:z,line:L,column:U,offset:D}=r;return{_bufferIndex:W,_index:z,line:L,column:U,offset:D}}function S(W){s[W.line]=W.column,I()}function w(){let W;for(;r._index<l.length;){const z=l[r._index];if(typeof z=="string")for(W=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===W&&r._bufferIndex<z.length;)k(z.charCodeAt(r._bufferIndex));else k(z)}}function k(W){p=p(W)}function j(W){Be(W)?(r.line++,r.column=1,r.offset+=W===-3?2:1,I()):W!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===l[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=W}function T(W,z){const L=z||{};return L.type=W,L.start=v(),h.events.push(["enter",L,h]),d.push(L),L}function A(W){const z=d.pop();return z.end=v(),h.events.push(["exit",z,h]),z}function P(W,z){J(W,z.from)}function R(W,z){z.restore()}function q(W,z){return L;function L(U,D,N){let F,H,se,B;return Array.isArray(U)?K(U):"tokenize"in U?K([U]):V(U);function V(Z){return te;function te(Se){const le=Se!==null&&Z[Se],Ce=Se!==null&&Z.null,Re=[...Array.isArray(le)?le:le?[le]:[],...Array.isArray(Ce)?Ce:Ce?[Ce]:[]];return K(Re)(Se)}}function K(Z){return F=Z,H=0,Z.length===0?N:O(Z[H])}function O(Z){return te;function te(Se){return B=ne(),se=Z,Z.partial||(h.currentConstruct=Z),Z.name&&h.parser.constructs.disable.null.includes(Z.name)?G():Z.tokenize.call(z?Object.assign(Object.create(h),z):h,f,Q,G)(Se)}}function Q(Z){return W(se,B),D}function G(Z){return B.restore(),++H<F.length?O(F[H]):N}}}function J(W,z){W.resolveAll&&!a.includes(W)&&a.push(W),W.resolve&&_r(h.events,z,h.events.length-z,W.resolve(h.events.slice(z),h)),W.resolveTo&&(h.events=W.resolveTo(h.events,h))}function ne(){const W=v(),z=h.previous,L=h.currentConstruct,U=h.events.length,D=Array.from(d);return{from:U,restore:N};function N(){r=W,h.previous=z,h.currentConstruct=L,h.events.length=U,d=D,I()}}function I(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function AI(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,a=t.end._bufferIndex;let l;if(n===s)l=[e[n].slice(r,a)];else{if(l=e.slice(n,s),r>-1){const d=l[0];typeof d=="string"?l[0]=d.slice(r):l.shift()}a>0&&l.push(e[s].slice(0,a))}return l}function DI(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const a=e[n];let l;if(typeof a=="string")l=a;else switch(a){case-5:{l="\r";break}case-4:{l=`
114
- `;break}case-3:{l=`\r
115
- `;break}case-2:{l=t?" ":" ";break}case-1:{if(!t&&s)continue;l=" ";break}default:l=String.fromCharCode(a)}s=a===-2,r.push(l)}return r.join("")}function LI(e){const r={constructs:z2([jI,...(e||{}).extensions||[]]),content:s(qO),defined:[],document:s(YO),flow:s(fI),lazy:{},string:s(gI),text:s(_I)};return r;function s(a){return l;function l(d){return TI(r,a,d)}}}function RI(e){for(;!V2(e););return e}const aw=/[\0\t\n\r]/g;function MI(){let e=1,t="",n=!0,r;return s;function s(a,l,d){const f=[];let h,p,g,_,x;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(l||void 0).decode(a)),g=0,t="",n&&(a.charCodeAt(0)===65279&&g++,n=void 0);g<a.length;){if(aw.lastIndex=g,h=aw.exec(a),_=h&&h.index!==void 0?h.index:a.length,x=a.charCodeAt(_),!h){t=a.slice(g);break}if(x===10&&g===_&&r)f.push(-3),r=void 0;else switch(r&&(f.push(-5),r=void 0),g<_&&(f.push(a.slice(g,_)),e+=_-g),x){case 0:{f.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,f.push(-2);e++<p;)f.push(-1);break}case 10:{f.push(-4),e=1;break}default:r=!0,e=1}g=_+1}return d&&(r&&f.push(-5),t&&f.push(t),f.push(null)),f}}const OI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function II(e){return e.replace(OI,PI)}function PI(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),a=s===120||s===88;return $2(n.slice(a?2:1),a?16:10)}return Cx(n)||e}const X2={}.hasOwnProperty;function BI(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),zI(n)(RI(LI(n).document().write(MI()(e,t,!0))))}function zI(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(ve),autolinkProtocol:ne,autolinkEmail:ne,atxHeading:a(st),blockQuote:a(Ce),characterEscape:ne,characterReference:ne,codeFenced:a(Re),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:a(Re,l),codeText:a(Oe,l),codeTextData:ne,data:ne,codeFlowValue:ne,definition:a(De),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:a(Ue),hardBreakEscape:a(it),hardBreakTrailing:a(it),htmlFlow:a(ye,l),htmlFlowData:ne,htmlText:a(ye,l),htmlTextData:ne,image:a(ze),label:l,link:a(ve),listItem:a(Ee),listItemValue:_,listOrdered:a(ue,g),listUnordered:a(ue),paragraph:a(_t),reference:O,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:a(st),strong:a(Js),thematicBreak:a(tl)},exit:{atxHeading:f(),atxHeadingSequence:P,autolink:f(),autolinkEmail:le,autolinkProtocol:Se,blockQuote:f(),characterEscapeValue:I,characterReferenceMarkerHexadecimal:G,characterReferenceMarkerNumeric:G,characterReferenceValue:Z,characterReference:te,codeFenced:f(w),codeFencedFence:S,codeFencedFenceInfo:x,codeFencedFenceMeta:v,codeFlowValue:I,codeIndented:f(k),codeText:f(D),codeTextData:I,data:I,definition:f(),definitionDestinationString:A,definitionLabelString:j,definitionTitleString:T,emphasis:f(),hardBreakEscape:f(z),hardBreakTrailing:f(z),htmlFlow:f(L),htmlFlowData:I,htmlText:f(U),htmlTextData:I,image:f(F),label:se,labelText:H,lineEnding:W,link:f(N),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:Q,resourceDestinationString:B,resourceTitleString:V,resource:K,setextHeading:f(J),setextHeadingLineSequence:q,setextHeadingText:R,strong:f(),thematicBreak:f()}};Q2(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(me){let ke={type:"root",children:[]};const $e={stack:[ke],tokenStack:[],config:t,enter:d,exit:h,buffer:l,resume:p,data:n},Xe=[];let ut=-1;for(;++ut<me.length;)if(me[ut][1].type==="listOrdered"||me[ut][1].type==="listUnordered")if(me[ut][0]==="enter")Xe.push(ut);else{const un=Xe.pop();ut=s(me,un,ut)}for(ut=-1;++ut<me.length;){const un=t[me[ut][0]];X2.call(un,me[ut][1].type)&&un[me[ut][1].type].call(Object.assign({sliceSerialize:me[ut][2].sliceSerialize},$e),me[ut][1])}if($e.tokenStack.length>0){const un=$e.tokenStack[$e.tokenStack.length-1];(un[1]||ow).call($e,void 0,un[0])}for(ke.position={start:Ei(me.length>0?me[0][1].start:{line:1,column:1,offset:0}),end:Ei(me.length>0?me[me.length-2][1].end:{line:1,column:1,offset:0})},ut=-1;++ut<t.transforms.length;)ke=t.transforms[ut](ke)||ke;return ke}function s(me,ke,$e){let Xe=ke-1,ut=-1,un=!1,Kn,zt,pt,On;for(;++Xe<=$e;){const xt=me[Xe];switch(xt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{xt[0]==="enter"?ut++:ut--,On=void 0;break}case"lineEndingBlank":{xt[0]==="enter"&&(Kn&&!On&&!ut&&!pt&&(pt=Xe),On=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:On=void 0}if(!ut&&xt[0]==="enter"&&xt[1].type==="listItemPrefix"||ut===-1&&xt[0]==="exit"&&(xt[1].type==="listUnordered"||xt[1].type==="listOrdered")){if(Kn){let zr=Xe;for(zt=void 0;zr--;){const ir=me[zr];if(ir[1].type==="lineEnding"||ir[1].type==="lineEndingBlank"){if(ir[0]==="exit")continue;zt&&(me[zt][1].type="lineEndingBlank",un=!0),ir[1].type="lineEnding",zt=zr}else if(!(ir[1].type==="linePrefix"||ir[1].type==="blockQuotePrefix"||ir[1].type==="blockQuotePrefixWhitespace"||ir[1].type==="blockQuoteMarker"||ir[1].type==="listItemIndent"))break}pt&&(!zt||pt<zt)&&(Kn._spread=!0),Kn.end=Object.assign({},zt?me[zt][1].start:xt[1].end),me.splice(zt||Xe,0,["exit",Kn,xt[2]]),Xe++,$e++}if(xt[1].type==="listItemPrefix"){const zr={type:"listItem",_spread:!1,start:Object.assign({},xt[1].start),end:void 0};Kn=zr,me.splice(Xe,0,["enter",zr,xt[2]]),Xe++,$e++,pt=void 0,On=!0}}}return me[ke][1]._spread=un,$e}function a(me,ke){return $e;function $e(Xe){d.call(this,me(Xe),Xe),ke&&ke.call(this,Xe)}}function l(){this.stack.push({type:"fragment",children:[]})}function d(me,ke,$e){this.stack[this.stack.length-1].children.push(me),this.stack.push(me),this.tokenStack.push([ke,$e||void 0]),me.position={start:Ei(ke.start),end:void 0}}function f(me){return ke;function ke($e){me&&me.call(this,$e),h.call(this,$e)}}function h(me,ke){const $e=this.stack.pop(),Xe=this.tokenStack.pop();if(Xe)Xe[0].type!==me.type&&(ke?ke.call(this,me,Xe[0]):(Xe[1]||ow).call(this,me,Xe[0]));else throw new Error("Cannot close `"+me.type+"` ("+bc({start:me.start,end:me.end})+"): it’s not open");$e.position.end=Ei(me.end)}function p(){return wx(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function _(me){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(me),10),this.data.expectingFirstListItemValue=void 0}}function x(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=me}function v(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=me}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me.replace(/(\r?\n|\r)$/g,"")}function j(me){const ke=this.resume(),$e=this.stack[this.stack.length-1];$e.label=ke,$e.identifier=Xr(this.sliceSerialize(me)).toLowerCase()}function T(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.title=me}function A(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.url=me}function P(me){const ke=this.stack[this.stack.length-1];if(!ke.depth){const $e=this.sliceSerialize(me).length;ke.depth=$e}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function q(me){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(me).codePointAt(0)===61?1:2}function J(){this.data.setextHeadingSlurpLineEnding=void 0}function ne(me){const $e=this.stack[this.stack.length-1].children;let Xe=$e[$e.length-1];(!Xe||Xe.type!=="text")&&(Xe=Yt(),Xe.position={start:Ei(me.start),end:void 0},$e.push(Xe)),this.stack.push(Xe)}function I(me){const ke=this.stack.pop();ke.value+=this.sliceSerialize(me),ke.position.end=Ei(me.end)}function W(me){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const $e=ke.children[ke.children.length-1];$e.position.end=Ei(me.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(ne.call(this,me),I.call(this,me))}function z(){this.data.atHardBreak=!0}function L(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me}function U(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me}function D(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me}function N(){const me=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";me.type+="Reference",me.referenceType=ke,delete me.url,delete me.title}else delete me.identifier,delete me.label;this.data.referenceType=void 0}function F(){const me=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";me.type+="Reference",me.referenceType=ke,delete me.url,delete me.title}else delete me.identifier,delete me.label;this.data.referenceType=void 0}function H(me){const ke=this.sliceSerialize(me),$e=this.stack[this.stack.length-2];$e.label=II(ke),$e.identifier=Xr(ke).toLowerCase()}function se(){const me=this.stack[this.stack.length-1],ke=this.resume(),$e=this.stack[this.stack.length-1];if(this.data.inReference=!0,$e.type==="link"){const Xe=me.children;$e.children=Xe}else $e.alt=ke}function B(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.url=me}function V(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.title=me}function K(){this.data.inReference=void 0}function O(){this.data.referenceType="collapsed"}function Q(me){const ke=this.resume(),$e=this.stack[this.stack.length-1];$e.label=ke,$e.identifier=Xr(this.sliceSerialize(me)).toLowerCase(),this.data.referenceType="full"}function G(me){this.data.characterReferenceType=me.type}function Z(me){const ke=this.sliceSerialize(me),$e=this.data.characterReferenceType;let Xe;$e?(Xe=$2(ke,$e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Xe=Cx(ke);const ut=this.stack[this.stack.length-1];ut.value+=Xe}function te(me){const ke=this.stack.pop();ke.position.end=Ei(me.end)}function Se(me){I.call(this,me);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(me)}function le(me){I.call(this,me);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(me)}function Ce(){return{type:"blockquote",children:[]}}function Re(){return{type:"code",lang:null,meta:null,value:""}}function Oe(){return{type:"inlineCode",value:""}}function De(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ue(){return{type:"emphasis",children:[]}}function st(){return{type:"heading",depth:0,children:[]}}function it(){return{type:"break"}}function ye(){return{type:"html",value:""}}function ze(){return{type:"image",title:null,url:"",alt:null}}function ve(){return{type:"link",title:null,url:"",children:[]}}function ue(me){return{type:"list",ordered:me.type==="listOrdered",start:null,spread:me._spread,children:[]}}function Ee(me){return{type:"listItem",spread:me._spread,checked:null,children:[]}}function _t(){return{type:"paragraph",children:[]}}function Js(){return{type:"strong",children:[]}}function Yt(){return{type:"text",value:""}}function tl(){return{type:"thematicBreak"}}}function Ei(e){return{line:e.line,column:e.column,offset:e.offset}}function Q2(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Q2(e,r):$I(e,r)}}function $I(e,t){let n;for(n in t)if(X2.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 ow(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+bc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+bc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+bc({start:t.start,end:t.end})+") is still open")}function HI(e){const t=this;t.parser=n;function n(r){return BI(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function FI(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 UI(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
116
- `}]}function VI(e,t){const n=t.value?t.value+`
117
- `:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a}function WI(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GI(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qI(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Jo(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let l,d=e.footnoteCounts.get(r);d===void 0?(d=0,e.footnoteOrder.push(r),l=e.footnoteOrder.length):l=a+1,d+=1,e.footnoteCounts.set(r,d);const f={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(l)}]};e.patch(t,f);const h={type:"element",tagName:"sup",properties:{},children:[f]};return e.patch(t,h),e.applyData(t,h)}function KI(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 YI(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function J2(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 s=e.all(t),a=s[0];a&&a.type==="text"?a.value="["+a.value:s.unshift({type:"text",value:"["});const l=s[s.length-1];return l&&l.type==="text"?l.value+=r:s.push({type:"text",value:r}),s}function XI(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return J2(e,t);const s={src:Jo(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const a={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,a),e.applyData(t,a)}function QI(e,t){const n={src:Jo(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 JI(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 ZI(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return J2(e,t);const s={href:Jo(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const a={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function eP(e,t){const n={href:Jo(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 tP(e,t,n){const r=e.all(t),s=n?nP(n):Z2(t),a={},l=[];if(typeof t.checked=="boolean"){const p=r[0];let g;p&&p.type==="element"&&p.tagName==="p"?g=p:(g={type:"element",tagName:"p",properties:{},children:[]},r.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let d=-1;for(;++d<r.length;){const p=r[d];(s||d!==0||p.type!=="element"||p.tagName!=="p")&&l.push({type:"text",value:`
118
- `}),p.type==="element"&&p.tagName==="p"&&!s?l.push(...p.children):l.push(p)}const f=r[r.length-1];f&&(s||f.type!=="element"||f.tagName!=="p")&&l.push({type:"text",value:`
119
- `});const h={type:"element",tagName:"li",properties:a,children:l};return e.patch(t,h),e.applyData(t,h)}function nP(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=Z2(n[r])}return t}function Z2(e){const t=e.spread;return t??e.children.length>1}function rP(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const l=r[s];if(l.type==="element"&&l.tagName==="li"&&l.properties&&Array.isArray(l.properties.className)&&l.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function sP(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iP(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function aP(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oP(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const l={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],l),s.push(l)}if(n.length>0){const l={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},d=yx(t.children[1]),f=L2(t.children[t.children.length-1]);d&&f&&(l.position={start:d,end:f}),s.push(l)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,a),e.applyData(t,a)}function lP(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",l=n&&n.type==="table"?n.align:void 0,d=l?l.length:t.children.length;let f=-1;const h=[];for(;++f<d;){const g=t.children[f],_={},x=l?l[f]:void 0;x&&(_.align=x);let v={type:"element",tagName:a,properties:_,children:[]};g&&(v.children=e.all(g),e.patch(g,v),v=e.applyData(g,v)),h.push(v)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,p),e.applyData(t,p)}function cP(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const lw=9,cw=32;function uP(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const a=[];for(;r;)a.push(uw(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return a.push(uw(t.slice(s),s>0,!1)),a.join("")}function uw(e,t,n){let r=0,s=e.length;if(t){let a=e.codePointAt(r);for(;a===lw||a===cw;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(s-1);for(;a===lw||a===cw;)s--,a=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function dP(e,t){const n={type:"text",value:uP(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function hP(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const fP={blockquote:FI,break:UI,code:VI,delete:WI,emphasis:GI,footnoteReference:qI,heading:KI,html:YI,imageReference:XI,image:QI,inlineCode:JI,linkReference:ZI,link:eP,listItem:tP,list:rP,paragraph:sP,root:iP,strong:aP,table:oP,tableCell:cP,tableRow:lP,text:dP,thematicBreak:hP,toml:Nd,yaml:Nd,definition:Nd,footnoteDefinition:Nd};function Nd(){}const eE=-1,Uh=0,wc=1,lh=2,Ex=3,Nx=4,jx=5,Tx=6,tE=7,nE=8,dw=typeof self=="object"?self:globalThis,mP=(e,t)=>{const n=(s,a)=>(e.set(a,s),s),r=s=>{if(e.has(s))return e.get(s);const[a,l]=t[s];switch(a){case Uh:case eE:return n(l,s);case wc:{const d=n([],s);for(const f of l)d.push(r(f));return d}case lh:{const d=n({},s);for(const[f,h]of l)d[r(f)]=r(h);return d}case Ex:return n(new Date(l),s);case Nx:{const{source:d,flags:f}=l;return n(new RegExp(d,f),s)}case jx:{const d=n(new Map,s);for(const[f,h]of l)d.set(r(f),r(h));return d}case Tx:{const d=n(new Set,s);for(const f of l)d.add(r(f));return d}case tE:{const{name:d,message:f}=l;return n(new dw[d](f),s)}case nE:return n(BigInt(l),s);case"BigInt":return n(Object(BigInt(l)),s);case"ArrayBuffer":return n(new Uint8Array(l).buffer,l);case"DataView":{const{buffer:d}=new Uint8Array(l);return n(new DataView(d),l)}}return n(new dw[a](l),s)};return r},hw=e=>mP(new Map,e)(0),To="",{toString:pP}={},{keys:gP}=Object,ac=e=>{const t=typeof e;if(t!=="object"||!e)return[Uh,t];const n=pP.call(e).slice(8,-1);switch(n){case"Array":return[wc,To];case"Object":return[lh,To];case"Date":return[Ex,To];case"RegExp":return[Nx,To];case"Map":return[jx,To];case"Set":return[Tx,To];case"DataView":return[wc,n]}return n.includes("Array")?[wc,n]:n.includes("Error")?[tE,n]:[lh,n]},jd=([e,t])=>e===Uh&&(t==="function"||t==="symbol"),_P=(e,t,n,r)=>{const s=(l,d)=>{const f=r.push(l)-1;return n.set(d,f),f},a=l=>{if(n.has(l))return n.get(l);let[d,f]=ac(l);switch(d){case Uh:{let p=l;switch(f){case"bigint":d=nE,p=l.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+f);p=null;break;case"undefined":return s([eE],l)}return s([d,p],l)}case wc:{if(f){let _=l;return f==="DataView"?_=new Uint8Array(l.buffer):f==="ArrayBuffer"&&(_=new Uint8Array(l)),s([f,[..._]],l)}const p=[],g=s([d,p],l);for(const _ of l)p.push(a(_));return g}case lh:{if(f)switch(f){case"BigInt":return s([f,l.toString()],l);case"Boolean":case"Number":case"String":return s([f,l.valueOf()],l)}if(t&&"toJSON"in l)return a(l.toJSON());const p=[],g=s([d,p],l);for(const _ of gP(l))(e||!jd(ac(l[_])))&&p.push([a(_),a(l[_])]);return g}case Ex:return s([d,l.toISOString()],l);case Nx:{const{source:p,flags:g}=l;return s([d,{source:p,flags:g}],l)}case jx:{const p=[],g=s([d,p],l);for(const[_,x]of l)(e||!(jd(ac(_))||jd(ac(x))))&&p.push([a(_),a(x)]);return g}case Tx:{const p=[],g=s([d,p],l);for(const _ of l)(e||!jd(ac(_)))&&p.push(a(_));return g}}const{message:h}=l;return s([d,{name:f,message:h}],l)};return a},fw=(e,{json:t,lossy:n}={})=>{const r=[];return _P(!(t||n),!!t,new Map,r)(e),r},ch=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?hw(fw(e,t)):structuredClone(e):(e,t)=>hw(fw(e,t));function xP(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 yP(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function vP(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||xP,r=e.options.footnoteBackLabel||yP,s=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",l=e.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let f=-1;for(;++f<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[f]);if(!h)continue;const p=e.all(h),g=String(h.identifier).toUpperCase(),_=Jo(g.toLowerCase());let x=0;const v=[],S=e.footnoteCounts.get(g);for(;S!==void 0&&++x<=S;){v.length>0&&v.push({type:"text",value:" "});let j=typeof n=="string"?n:n(f,x);typeof j=="string"&&(j={type:"text",value:j}),v.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+_+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(f,x),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const w=p[p.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const j=w.children[w.children.length-1];j&&j.type==="text"?j.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...v)}else p.push(...v);const k={type:"element",tagName:"li",properties:{id:t+"fn-"+_},children:e.wrap(p,!0)};e.patch(h,k),d.push(k)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...ch(l),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
120
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(d,!0)},{type:"text",value:`
121
- `}]}}const Vh=(function(e){if(e==null)return CP;if(typeof e=="function")return Wh(e);if(typeof e=="object")return Array.isArray(e)?bP(e):SP(e);if(typeof e=="string")return wP(e);throw new Error("Expected function, string, or object as test")});function bP(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Vh(e[n]);return Wh(r);function r(...s){let a=-1;for(;++a<t.length;)if(t[a].apply(this,s))return!0;return!1}}function SP(e){const t=e;return Wh(n);function n(r){const s=r;let a;for(a in e)if(s[a]!==t[a])return!1;return!0}}function wP(e){return Wh(t);function t(n){return n&&n.type===e}}function Wh(e){return t;function t(n,r,s){return!!(kP(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function CP(){return!0}function kP(e){return e!==null&&typeof e=="object"&&"type"in e}const rE=[],EP=!0,k_=!1,NP="skip";function sE(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const a=Vh(s),l=r?-1:1;d(e,void 0,[])();function d(f,h,p){const g=f&&typeof f=="object"?f:{};if(typeof g.type=="string"){const x=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(_,"name",{value:"node ("+(f.type+(x?"<"+x+">":""))+")"})}return _;function _(){let x=rE,v,S,w;if((!t||a(f,h,p[p.length-1]||void 0))&&(x=jP(n(f,p)),x[0]===k_))return x;if("children"in f&&f.children){const k=f;if(k.children&&x[0]!==NP)for(S=(r?k.children.length:-1)+l,w=p.concat(k);S>-1&&S<k.children.length;){const j=k.children[S];if(v=d(j,S,w)(),v[0]===k_)return v;S=typeof v[1]=="number"?v[1]:S+l}}return x}}}function jP(e){return Array.isArray(e)?e:typeof e=="number"?[EP,e]:e==null?rE:[e]}function Ax(e,t,n,r){let s,a,l;typeof t=="function"&&typeof n!="function"?(a=void 0,l=t,s=n):(a=t,l=n,s=r),sE(e,a,d,s);function d(f,h){const p=h[h.length-1],g=p?p.children.indexOf(f):void 0;return l(f,g,p)}}const E_={}.hasOwnProperty,TP={};function AP(e,t){const n=t||TP,r=new Map,s=new Map,a=new Map,l={...fP,...n.handlers},d={all:h,applyData:LP,definitionById:r,footnoteById:s,footnoteCounts:a,footnoteOrder:[],handlers:l,one:f,options:n,patch:DP,wrap:MP};return Ax(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const g=p.type==="definition"?r:s,_=String(p.identifier).toUpperCase();g.has(_)||g.set(_,p)}}),d;function f(p,g){const _=p.type,x=d.handlers[_];if(E_.call(d.handlers,_)&&x)return x(d,p,g);if(d.options.passThrough&&d.options.passThrough.includes(_)){if("children"in p){const{children:S,...w}=p,k=ch(w);return k.children=d.all(p),k}return ch(p)}return(d.options.unknownHandler||RP)(d,p,g)}function h(p){const g=[];if("children"in p){const _=p.children;let x=-1;for(;++x<_.length;){const v=d.one(_[x],p);if(v){if(x&&_[x-1].type==="break"&&(!Array.isArray(v)&&v.type==="text"&&(v.value=mw(v.value)),!Array.isArray(v)&&v.type==="element")){const S=v.children[0];S&&S.type==="text"&&(S.value=mw(S.value))}Array.isArray(v)?g.push(...v):g.push(v)}}}return g}}function DP(e,t){e.position&&(t.position=yO(e))}function LP(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,a=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const l="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:l}}n.type==="element"&&a&&Object.assign(n.properties,ch(a)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function RP(e,t){const n=t.data||{},r="value"in t&&!(E_.call(n,"hProperties")||E_.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 MP(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
122
- `});++r<e.length;)r&&n.push({type:"text",value:`
123
- `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
124
- `}),n}function mw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function pw(e,t){const n=AP(e,t),r=n.one(e,void 0),s=vP(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&a.children.push({type:"text",value:`
125
- `},s),a}function OP(e,t){return e&&"run"in e?async function(n,r){const s=pw(n,{file:r,...t});await e.run(s,r)}:function(n,r){return pw(n,{file:r,...e||t})}}function gw(e){if(e)throw e}var Qp,_w;function IP(){if(_w)return Qp;_w=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},a=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var p=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!p&&!g)return!1;var _;for(_ in h);return typeof _>"u"||e.call(h,_)},l=function(h,p){n&&p.name==="__proto__"?n(h,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):h[p.name]=p.newValue},d=function(h,p){if(p==="__proto__")if(e.call(h,p)){if(r)return r(h,p).value}else return;return h[p]};return Qp=function f(){var h,p,g,_,x,v,S=arguments[0],w=1,k=arguments.length,j=!1;for(typeof S=="boolean"&&(j=S,S=arguments[1]||{},w=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});w<k;++w)if(h=arguments[w],h!=null)for(p in h)g=d(S,p),_=d(h,p),S!==_&&(j&&_&&(a(_)||(x=s(_)))?(x?(x=!1,v=g&&s(g)?g:[]):v=g&&a(g)?g:{},l(S,{name:p,newValue:f(j,v,_)})):typeof _<"u"&&l(S,{name:p,newValue:_}));return S},Qp}var PP=IP();const Jp=kh(PP);function N_(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 BP(){const e=[],t={run:n,use:r};return t;function n(...s){let a=-1;const l=s.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);d(null,...s);function d(f,...h){const p=e[++a];let g=-1;if(f){l(f);return}for(;++g<s.length;)(h[g]===null||h[g]===void 0)&&(h[g]=s[g]);s=h,p?zP(p,d)(...h):l(null,...h)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function zP(e,t){let n;return r;function r(...l){const d=e.length>l.length;let f;d&&l.push(s);try{f=e.apply(this,l)}catch(h){const p=h;if(d&&n)throw p;return s(p)}d||(f&&f.then&&typeof f.then=="function"?f.then(a,s):f instanceof Error?s(f):a(f))}function s(l,...d){n||(n=!0,t(l,...d))}function a(l){s(null,l)}}const ds={basename:$P,dirname:HP,extname:FP,join:UP,sep:"/"};function $P(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Jc(e);let n=0,r=-1,s=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(a){n=s+1;break}}else r<0&&(a=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let l=-1,d=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(a){n=s+1;break}}else l<0&&(a=!0,l=s+1),d>-1&&(e.codePointAt(s)===t.codePointAt(d--)?d<0&&(r=s):(d=-1,r=l));return n===r?r=l:r<0&&(r=e.length),e.slice(n,r)}function HP(e){if(Jc(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 FP(e){Jc(e);let t=e.length,n=-1,r=0,s=-1,a=0,l;for(;t--;){const d=e.codePointAt(t);if(d===47){if(l){r=t+1;break}continue}n<0&&(l=!0,n=t+1),d===46?s<0?s=t:a!==1&&(a=1):s>-1&&(a=-1)}return s<0||n<0||a===0||a===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function UP(...e){let t=-1,n;for(;++t<e.length;)Jc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":VP(n)}function VP(e){Jc(e);const t=e.codePointAt(0)===47;let n=WP(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function WP(e,t){let n="",r=0,s=-1,a=0,l=-1,d,f;for(;++l<=e.length;){if(l<e.length)d=e.codePointAt(l);else{if(d===47)break;d=47}if(d===47){if(!(s===l-1||a===1))if(s!==l-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(f=n.lastIndexOf("/"),f!==n.length-1){f<0?(n="",r=0):(n=n.slice(0,f),r=n.length-1-n.lastIndexOf("/")),s=l,a=0;continue}}else if(n.length>0){n="",r=0,s=l,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,l):n=e.slice(s+1,l),r=l-s-1;s=l,a=0}else d===46&&a>-1?a++:a=-1}return n}function Jc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const GP={cwd:qP};function qP(){return"/"}function j_(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function KP(e){if(typeof e=="string")e=new URL(e);else if(!j_(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 YP(e)}function YP(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 s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const Zp=["history","path","basename","stem","extname","dirname"];class iE{constructor(t){let n;t?j_(t)?n={path:t}:typeof t=="string"||XP(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":GP.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Zp.length;){const a=Zp[r];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let s;for(s in n)Zp.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?ds.basename(this.path):void 0}set basename(t){tg(t,"basename"),eg(t,"basename"),this.path=ds.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ds.dirname(this.path):void 0}set dirname(t){xw(this.basename,"dirname"),this.path=ds.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ds.extname(this.path):void 0}set extname(t){if(eg(t,"extname"),xw(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=ds.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){j_(t)&&(t=KP(t)),tg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ds.basename(this.path,this.extname):void 0}set stem(t){tg(t,"stem"),eg(t,"stem"),this.path=ds.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Hn(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function eg(e,t){if(e&&e.includes(ds.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ds.sep+"`")}function tg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function xw(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function XP(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const QP=(function(e){const r=this.constructor.prototype,s=r[e],a=function(){return s.apply(a,arguments)};return Object.setPrototypeOf(a,r),a}),JP={}.hasOwnProperty;class Dx extends QP{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=BP()}copy(){const t=new Dx;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Jp(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(sg("data",this.frozen),this.namespace[t]=n,this):JP.call(this.namespace,t)&&this.namespace[t]||void 0:t?(sg("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 s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Td(t),r=this.parser||this.Parser;return ng("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ng("process",this.parser||this.Parser),rg("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(a,l){const d=Td(t),f=r.parse(d);r.run(f,d,function(p,g,_){if(p||!g||!_)return h(p);const x=g,v=r.stringify(x,_);t6(v)?_.value=v:_.result=v,h(p,_)});function h(p,g){p||!g?l(p):a?a(g):n(void 0,g)}}}processSync(t){let n=!1,r;return this.freeze(),ng("processSync",this.parser||this.Parser),rg("processSync",this.compiler||this.Compiler),this.process(t,s),vw("processSync","process",n),r;function s(a,l){n=!0,gw(a),r=l}}run(t,n,r){yw(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?a(void 0,r):new Promise(a);function a(l,d){const f=Td(n);s.run(t,f,h);function h(p,g,_){const x=g||t;p?d(p):l?l(x):r(void 0,x,_)}}}runSync(t,n){let r=!1,s;return this.run(t,n,a),vw("runSync","run",r),s;function a(l,d){gw(l),s=d,r=!0}}stringify(t,n){this.freeze();const r=Td(n),s=this.compiler||this.Compiler;return rg("stringify",s),yw(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(sg("use",this.frozen),t!=null)if(typeof t=="function")f(t,n);else if(typeof t=="object")Array.isArray(t)?d(t):l(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(h){if(typeof h=="function")f(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[p,...g]=h;f(p,g)}else l(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function l(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(h.plugins),h.settings&&(s.settings=Jp(!0,s.settings,h.settings))}function d(h){let p=-1;if(h!=null)if(Array.isArray(h))for(;++p<h.length;){const g=h[p];a(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function f(h,p){let g=-1,_=-1;for(;++g<r.length;)if(r[g][0]===h){_=g;break}if(_===-1)r.push([h,...p]);else if(p.length>0){let[x,...v]=p;const S=r[_][1];N_(S)&&N_(x)&&(x=Jp(!0,S,x)),r[_]=[h,x,...v]}}}}const ZP=new Dx().freeze();function ng(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function rg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function sg(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 yw(e){if(!N_(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function vw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Td(e){return e6(e)?e:new iE(e)}function e6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function t6(e){return typeof e=="string"||n6(e)}function n6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const r6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",bw=[],Sw={allowDangerousHtml:!0},s6=/^(https?|ircs?|mailto|xmpp)$/i,i6=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function a6(e){const t=o6(e),n=l6(e);return c6(t.runSync(t.parse(n),n),e)}function o6(e){const t=e.rehypePlugins||bw,n=e.remarkPlugins||bw,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Sw}:Sw;return ZP().use(HI).use(n).use(OP,r).use(t)}function l6(e){const t=e.children||"",n=new iE;return typeof t=="string"&&(n.value=t),n}function c6(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,a=t.disallowedElements,l=t.skipHtml,d=t.unwrapDisallowed,f=t.urlTransform||u6;for(const p of i6)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+r6+p.id,void 0);return Ax(e,h),CO(e,{Fragment:c.Fragment,components:s,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function h(p,g,_){if(p.type==="raw"&&_&&typeof g=="number")return l?_.children.splice(g,1):_.children[g]={type:"text",value:p.value},g;if(p.type==="element"){let x;for(x in Kp)if(Object.hasOwn(Kp,x)&&Object.hasOwn(p.properties,x)){const v=p.properties[x],S=Kp[x];(S===null||S.includes(p.tagName))&&(p.properties[x]=f(String(v||""),x,p))}}if(p.type==="element"){let x=n?!n.includes(p.tagName):a?a.includes(p.tagName):!1;if(!x&&r&&typeof g=="number"&&(x=!r(p,g,_)),x&&_&&typeof g=="number")return d&&p.children?_.children.splice(g,1,...p.children):_.children.splice(g,1),g}}}function u6(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||s6.test(e.slice(0,t))?e:""}function uh(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function d6(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function h6(e,t,n){const s=Vh((n||{}).ignore||[]),a=f6(t);let l=-1;for(;++l<a.length;)sE(e,"text",d);function d(h,p){let g=-1,_;for(;++g<p.length;){const x=p[g],v=_?_.children:void 0;if(s(x,v?v.indexOf(x):void 0,_))return;_=x}if(_)return f(h,p)}function f(h,p){const g=p[p.length-1],_=a[l][0],x=a[l][1];let v=0;const w=g.children.indexOf(h);let k=!1,j=[];_.lastIndex=0;let T=_.exec(h.value);for(;T;){const A=T.index,P={index:T.index,input:T.input,stack:[...p,h]};let R=x(...T,P);if(typeof R=="string"&&(R=R.length>0?{type:"text",value:R}:void 0),R===!1?_.lastIndex=A+1:(v!==A&&j.push({type:"text",value:h.value.slice(v,A)}),Array.isArray(R)?j.push(...R):R&&j.push(R),v=A+T[0].length,k=!0),!_.global)break;T=_.exec(h.value)}return k?(v<h.value.length&&j.push({type:"text",value:h.value.slice(v)}),g.children.splice(w,1,...j)):j=[h],w+j.length}}function f6(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 s=n[r];t.push([m6(s[0]),p6(s[1])])}return t}function m6(e){return typeof e=="string"?new RegExp(d6(e),"g"):e}function p6(e){return typeof e=="function"?e:function(){return e}}const ig="phrasing",ag=["autolink","link","image","label"];function g6(){return{transforms:[w6],enter:{literalAutolink:x6,literalAutolinkEmail:og,literalAutolinkHttp:og,literalAutolinkWww:og},exit:{literalAutolink:S6,literalAutolinkEmail:b6,literalAutolinkHttp:y6,literalAutolinkWww:v6}}}function _6(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:ag},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:ag},{character:":",before:"[ps]",after:"\\/",inConstruct:ig,notInConstruct:ag}]}}function x6(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function og(e){this.config.enter.autolinkProtocol.call(this,e)}function y6(e){this.config.exit.autolinkProtocol.call(this,e)}function v6(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 b6(e){this.config.exit.autolinkEmail.call(this,e)}function S6(e){this.exit(e)}function w6(e){h6(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,C6],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),k6]],{ignore:["link","linkReference"]})}function C6(e,t,n,r,s){let a="";if(!aE(s)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!E6(n)))return!1;const l=N6(n+r);if(!l[0])return!1;const d={type:"link",title:null,url:a+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[d,{type:"text",value:l[1]}]:d}function k6(e,t,n,r){return!aE(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function E6(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 N6(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 s=uh(e,"(");let a=uh(e,")");for(;r!==-1&&s>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function aE(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Aa(n)||Hh(n))&&(!t||n!==47)}oE.peek=I6;function j6(){this.buffer()}function T6(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function A6(){this.buffer()}function D6(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function L6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Xr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function R6(e){this.exit(e)}function M6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Xr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function O6(e){this.exit(e)}function I6(){return"["}function oE(e,t,n,r){const s=n.createTracker(r);let a=s.move("[^");const l=n.enter("footnoteReference"),d=n.enter("reference");return a+=s.move(n.safe(n.associationId(e),{after:"]",before:a})),d(),l(),a+=s.move("]"),a}function P6(){return{enter:{gfmFootnoteCallString:j6,gfmFootnoteCall:T6,gfmFootnoteDefinitionLabelString:A6,gfmFootnoteDefinition:D6},exit:{gfmFootnoteCallString:L6,gfmFootnoteCall:R6,gfmFootnoteDefinitionLabelString:M6,gfmFootnoteDefinition:O6}}}function B6(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:oE},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,s,a,l){const d=a.createTracker(l);let f=d.move("[^");const h=a.enter("footnoteDefinition"),p=a.enter("label");return f+=d.move(a.safe(a.associationId(r),{before:f,after:"]"})),p(),f+=d.move("]:"),r.children&&r.children.length>0&&(d.shift(4),f+=d.move((t?`
126
- `:" ")+a.indentLines(a.containerFlow(r,d.current()),t?lE:z6))),h(),f}}function z6(e,t,n){return t===0?e:lE(e,t,n)}function lE(e,t,n){return(n?"":" ")+e}const $6=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];cE.peek=W6;function H6(){return{canContainEols:["delete"],enter:{strikethrough:U6},exit:{strikethrough:V6}}}function F6(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:$6}],handlers:{delete:cE}}}function U6(e){this.enter({type:"delete",children:[]},e)}function V6(e){this.exit(e)}function cE(e,t,n,r){const s=n.createTracker(r),a=n.enter("strikethrough");let l=s.move("~~");return l+=n.containerPhrasing(e,{...s.current(),before:l,after:"~"}),l+=s.move("~~"),a(),l}function W6(){return"~"}function G6(e){return e.length}function q6(e,t){const n=t||{},r=(n.align||[]).concat(),s=n.stringLength||G6,a=[],l=[],d=[],f=[];let h=0,p=-1;for(;++p<e.length;){const S=[],w=[];let k=-1;for(e[p].length>h&&(h=e[p].length);++k<e[p].length;){const j=K6(e[p][k]);if(n.alignDelimiters!==!1){const T=s(j);w[k]=T,(f[k]===void 0||T>f[k])&&(f[k]=T)}S.push(j)}l[p]=S,d[p]=w}let g=-1;if(typeof r=="object"&&"length"in r)for(;++g<h;)a[g]=ww(r[g]);else{const S=ww(r);for(;++g<h;)a[g]=S}g=-1;const _=[],x=[];for(;++g<h;){const S=a[g];let w="",k="";S===99?(w=":",k=":"):S===108?w=":":S===114&&(k=":");let j=n.alignDelimiters===!1?1:Math.max(1,f[g]-w.length-k.length);const T=w+"-".repeat(j)+k;n.alignDelimiters!==!1&&(j=w.length+j+k.length,j>f[g]&&(f[g]=j),x[g]=j),_[g]=T}l.splice(1,0,_),d.splice(1,0,x),p=-1;const v=[];for(;++p<l.length;){const S=l[p],w=d[p];g=-1;const k=[];for(;++g<h;){const j=S[g]||"";let T="",A="";if(n.alignDelimiters!==!1){const P=f[g]-(w[g]||0),R=a[g];R===114?T=" ".repeat(P):R===99?P%2?(T=" ".repeat(P/2+.5),A=" ".repeat(P/2-.5)):(T=" ".repeat(P/2),A=T):A=" ".repeat(P)}n.delimiterStart!==!1&&!g&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&j==="")&&(n.delimiterStart!==!1||g)&&k.push(" "),n.alignDelimiters!==!1&&k.push(T),k.push(j),n.alignDelimiters!==!1&&k.push(A),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||g!==h-1)&&k.push("|")}v.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return v.join(`
127
- `)}function K6(e){return e==null?"":String(e)}function ww(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}const Cw={}.hasOwnProperty;function Y6(e,t){const n=t||{};function r(s,...a){let l=r.invalid;const d=r.handlers;if(s&&Cw.call(s,e)){const f=String(s[e]);l=Cw.call(d,f)?d[f]:r.unknown}if(l)return l.call(this,s,...a)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}function X6(e,t,n,r){const s=n.enter("blockquote"),a=n.createTracker(r);a.move("> "),a.shift(2);const l=n.indentLines(n.containerFlow(e,a.current()),Q6);return s(),l}function Q6(e,t,n){return">"+(n?"":" ")+e}function J6(e,t){return kw(e,t.inConstruct,!0)&&!kw(e,t.notInConstruct,!1)}function kw(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 Ew(e,t,n,r){let s=-1;for(;++s<n.unsafe.length;)if(n.unsafe[s].character===`
128
- `&&J6(n.stack,n.unsafe[s]))return/[ \t]/.test(r.before)?"":" ";return`\\
129
- `}function Z6(e,t){const n=String(e);let r=n.indexOf(t),s=r,a=0,l=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===s?++a>l&&(l=a):a=1,s=r+t.length,r=n.indexOf(t,s);return l}function eB(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 tB(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 nB(e,t,n,r){const s=tB(n),a=e.value||"",l=s==="`"?"GraveAccent":"Tilde";if(eB(e,n)){const g=n.enter("codeIndented"),_=n.indentLines(a,rB);return g(),_}const d=n.createTracker(r),f=s.repeat(Math.max(Z6(a,s)+1,3)),h=n.enter("codeFenced");let p=d.move(f);if(e.lang){const g=n.enter(`codeFencedLang${l}`);p+=d.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...d.current()})),g()}if(e.lang&&e.meta){const g=n.enter(`codeFencedMeta${l}`);p+=d.move(" "),p+=d.move(n.safe(e.meta,{before:p,after:`
130
- `,encode:["`"],...d.current()})),g()}return p+=d.move(`
131
- `),a&&(p+=d.move(a+`
132
- `)),p+=d.move(f),h(),p}function rB(e,t,n){return(n?"":" ")+e}function Lx(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 sB(e,t,n,r){const s=Lx(n),a=s==='"'?"Quote":"Apostrophe",l=n.enter("definition");let d=n.enter("label");const f=n.createTracker(r);let h=f.move("[");return h+=f.move(n.safe(n.associationId(e),{before:h,after:"]",...f.current()})),h+=f.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=f.move("<"),h+=f.move(n.safe(e.url,{before:h,after:">",...f.current()})),h+=f.move(">")):(d=n.enter("destinationRaw"),h+=f.move(n.safe(e.url,{before:h,after:e.title?" ":`
133
- `,...f.current()}))),d(),e.title&&(d=n.enter(`title${a}`),h+=f.move(" "+s),h+=f.move(n.safe(e.title,{before:h,after:s,...f.current()})),h+=f.move(s),d()),l(),h}function iB(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Lc(e){return"&#x"+e.toString(16).toUpperCase()+";"}function dh(e,t,n){const r=Wo(e),s=Wo(t);return r===void 0?s===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}uE.peek=aB;function uE(e,t,n,r){const s=iB(n),a=n.enter("emphasis"),l=n.createTracker(r),d=l.move(s);let f=l.move(n.containerPhrasing(e,{after:s,before:d,...l.current()}));const h=f.charCodeAt(0),p=dh(r.before.charCodeAt(r.before.length-1),h,s);p.inside&&(f=Lc(h)+f.slice(1));const g=f.charCodeAt(f.length-1),_=dh(r.after.charCodeAt(0),g,s);_.inside&&(f=f.slice(0,-1)+Lc(g));const x=l.move(s);return a(),n.attentionEncodeSurroundingInfo={after:_.outside,before:p.outside},d+f+x}function aB(e,t,n){return n.options.emphasis||"*"}function oB(e,t){let n=!1;return Ax(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,k_}),!!((!e.depth||e.depth<3)&&wx(e)&&(t.options.setext||n))}function lB(e,t,n,r){const s=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(oB(e,n)){const p=n.enter("headingSetext"),g=n.enter("phrasing"),_=n.containerPhrasing(e,{...a.current(),before:`
134
- `,after:`
135
- `});return g(),p(),_+`
136
- `+(s===1?"=":"-").repeat(_.length-(Math.max(_.lastIndexOf("\r"),_.lastIndexOf(`
137
- `))+1))}const l="#".repeat(s),d=n.enter("headingAtx"),f=n.enter("phrasing");a.move(l+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
138
- `,...a.current()});return/^[\t ]/.test(h)&&(h=Lc(h.charCodeAt(0))+h.slice(1)),h=h?l+" "+h:l,n.options.closeAtx&&(h+=" "+l),f(),d(),h}dE.peek=cB;function dE(e){return e.value||""}function cB(){return"<"}hE.peek=uB;function hE(e,t,n,r){const s=Lx(n),a=s==='"'?"Quote":"Apostrophe",l=n.enter("image");let d=n.enter("label");const f=n.createTracker(r);let h=f.move("![");return h+=f.move(n.safe(e.alt,{before:h,after:"]",...f.current()})),h+=f.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=f.move("<"),h+=f.move(n.safe(e.url,{before:h,after:">",...f.current()})),h+=f.move(">")):(d=n.enter("destinationRaw"),h+=f.move(n.safe(e.url,{before:h,after:e.title?" ":")",...f.current()}))),d(),e.title&&(d=n.enter(`title${a}`),h+=f.move(" "+s),h+=f.move(n.safe(e.title,{before:h,after:s,...f.current()})),h+=f.move(s),d()),h+=f.move(")"),l(),h}function uB(){return"!"}fE.peek=dB;function fE(e,t,n,r){const s=e.referenceType,a=n.enter("imageReference");let l=n.enter("label");const d=n.createTracker(r);let f=d.move("![");const h=n.safe(e.alt,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),l();const p=n.stack;n.stack=[],l=n.enter("reference");const g=n.safe(n.associationId(e),{before:f,after:"]",...d.current()});return l(),n.stack=p,a(),s==="full"||!h||h!==g?f+=d.move(g+"]"):s==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function dB(){return"!"}mE.peek=hB;function mE(e,t,n){let r=e.value||"",s="`",a=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const l=n.unsafe[a],d=n.compilePattern(l);let f;if(l.atBreak)for(;f=d.exec(r);){let h=f.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(f.index+1)}}return s+r+s}function hB(){return"`"}function pE(e,t){const n=wx(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))}gE.peek=fB;function gE(e,t,n,r){const s=Lx(n),a=s==='"'?"Quote":"Apostrophe",l=n.createTracker(r);let d,f;if(pE(e,n)){const p=n.stack;n.stack=[],d=n.enter("autolink");let g=l.move("<");return g+=l.move(n.containerPhrasing(e,{before:g,after:">",...l.current()})),g+=l.move(">"),d(),n.stack=p,g}d=n.enter("link"),f=n.enter("label");let h=l.move("[");return h+=l.move(n.containerPhrasing(e,{before:h,after:"](",...l.current()})),h+=l.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=l.move("<"),h+=l.move(n.safe(e.url,{before:h,after:">",...l.current()})),h+=l.move(">")):(f=n.enter("destinationRaw"),h+=l.move(n.safe(e.url,{before:h,after:e.title?" ":")",...l.current()}))),f(),e.title&&(f=n.enter(`title${a}`),h+=l.move(" "+s),h+=l.move(n.safe(e.title,{before:h,after:s,...l.current()})),h+=l.move(s),f()),h+=l.move(")"),d(),h}function fB(e,t,n){return pE(e,n)?"<":"["}_E.peek=mB;function _E(e,t,n,r){const s=e.referenceType,a=n.enter("linkReference");let l=n.enter("label");const d=n.createTracker(r);let f=d.move("[");const h=n.containerPhrasing(e,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),l();const p=n.stack;n.stack=[],l=n.enter("reference");const g=n.safe(n.associationId(e),{before:f,after:"]",...d.current()});return l(),n.stack=p,a(),s==="full"||!h||h!==g?f+=d.move(g+"]"):s==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function mB(){return"["}function Rx(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 pB(e){const t=Rx(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 gB(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 xE(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 _B(e,t,n,r){const s=n.enter("list"),a=n.bulletCurrent;let l=e.ordered?gB(n):Rx(n);const d=e.ordered?l==="."?")":".":pB(n);let f=t&&n.bulletLastUsed?l===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((l==="*"||l==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(f=!0),xE(n)===l&&p){let g=-1;for(;++g<e.children.length;){const _=e.children[g];if(_&&_.type==="listItem"&&_.children&&_.children[0]&&_.children[0].type==="thematicBreak"){f=!0;break}}}}f&&(l=d),n.bulletCurrent=l;const h=n.containerFlow(e,r);return n.bulletLastUsed=l,n.bulletCurrent=a,s(),h}function xB(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 yB(e,t,n,r){const s=xB(n);let a=n.bulletCurrent||Rx(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let l=a.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(l=Math.ceil(l/4)*4);const d=n.createTracker(r);d.move(a+" ".repeat(l-a.length)),d.shift(l);const f=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,d.current()),p);return f(),h;function p(g,_,x){return _?(x?"":" ".repeat(l))+g:(x?a:a+" ".repeat(l-a.length))+g}}function vB(e,t,n,r){const s=n.enter("paragraph"),a=n.enter("phrasing"),l=n.containerPhrasing(e,r);return a(),s(),l}const bB=Vh(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function SB(e,t,n,r){return(e.children.some(function(l){return bB(l)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function wB(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}yE.peek=CB;function yE(e,t,n,r){const s=wB(n),a=n.enter("strong"),l=n.createTracker(r),d=l.move(s+s);let f=l.move(n.containerPhrasing(e,{after:s,before:d,...l.current()}));const h=f.charCodeAt(0),p=dh(r.before.charCodeAt(r.before.length-1),h,s);p.inside&&(f=Lc(h)+f.slice(1));const g=f.charCodeAt(f.length-1),_=dh(r.after.charCodeAt(0),g,s);_.inside&&(f=f.slice(0,-1)+Lc(g));const x=l.move(s+s);return a(),n.attentionEncodeSurroundingInfo={after:_.outside,before:p.outside},d+f+x}function CB(e,t,n){return n.options.strong||"*"}function kB(e,t,n,r){return n.safe(e.value,r)}function EB(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 NB(e,t,n){const r=(xE(n)+(n.options.ruleSpaces?" ":"")).repeat(EB(n));return n.options.ruleSpaces?r.slice(0,-1):r}const vE={blockquote:X6,break:Ew,code:nB,definition:sB,emphasis:uE,hardBreak:Ew,heading:lB,html:dE,image:hE,imageReference:fE,inlineCode:mE,link:gE,linkReference:_E,list:_B,listItem:yB,paragraph:vB,root:SB,strong:yE,text:kB,thematicBreak:NB};function jB(){return{enter:{table:TB,tableData:Nw,tableHeader:Nw,tableRow:DB},exit:{codeText:LB,table:AB,tableData:lg,tableHeader:lg,tableRow:lg}}}function TB(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 AB(e){this.exit(e),this.data.inTable=void 0}function DB(e){this.enter({type:"tableRow",children:[]},e)}function lg(e){this.exit(e)}function Nw(e){this.enter({type:"tableCell",children:[]},e)}function LB(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,RB));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function RB(e,t){return t==="|"?t:e}function MB(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
139
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:_,table:l,tableCell:f,tableRow:d}};function l(x,v,S,w){return h(p(x,S,w),x.align)}function d(x,v,S,w){const k=g(x,S,w),j=h([k]);return j.slice(0,j.indexOf(`
140
- `))}function f(x,v,S,w){const k=S.enter("tableCell"),j=S.enter("phrasing"),T=S.containerPhrasing(x,{...w,before:a,after:a});return j(),k(),T}function h(x,v){return q6(x,{align:v,alignDelimiters:r,padding:n,stringLength:s})}function p(x,v,S){const w=x.children;let k=-1;const j=[],T=v.enter("table");for(;++k<w.length;)j[k]=g(w[k],v,S);return T(),j}function g(x,v,S){const w=x.children;let k=-1;const j=[],T=v.enter("tableRow");for(;++k<w.length;)j[k]=f(w[k],x,v,S);return T(),j}function _(x,v,S){let w=vE.inlineCode(x,v,S);return S.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function OB(){return{exit:{taskListCheckValueChecked:jw,taskListCheckValueUnchecked:jw,paragraph:PB}}}function IB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:BB}}}function jw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function PB(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 s=t.children;let a=-1,l;for(;++a<s.length;){const d=s[a];if(d.type==="paragraph"){l=d;break}}l===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function BB(e,t,n,r){const s=e.children[0],a=typeof e.checked=="boolean"&&s&&s.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",d=n.createTracker(r);a&&d.move(l);let f=vE.listItem(e,t,n,{...r,...d.current()});return a&&(f=f.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),f;function h(p){return p+l}}function zB(){return[g6(),P6(),H6(),jB(),OB()]}function $B(e){return{extensions:[_6(),B6(e),F6(),MB(e),IB()]}}const HB={tokenize:qB,partial:!0},bE={tokenize:KB,partial:!0},SE={tokenize:YB,partial:!0},wE={tokenize:XB,partial:!0},FB={tokenize:QB,partial:!0},CE={name:"wwwAutolink",tokenize:WB,previous:EE},kE={name:"protocolAutolink",tokenize:GB,previous:NE},Qs={name:"emailAutolink",tokenize:VB,previous:jE},xs={};function UB(){return{text:xs}}let la=48;for(;la<123;)xs[la]=Qs,la++,la===58?la=65:la===91&&(la=97);xs[43]=Qs;xs[45]=Qs;xs[46]=Qs;xs[95]=Qs;xs[72]=[Qs,kE];xs[104]=[Qs,kE];xs[87]=[Qs,CE];xs[119]=[Qs,CE];function VB(e,t,n){const r=this;let s,a;return l;function l(g){return!T_(g)||!jE.call(r,r.previous)||Mx(r.events)?n(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(g))}function d(g){return T_(g)?(e.consume(g),d):g===64?(e.consume(g),f):n(g)}function f(g){return g===46?e.check(FB,p,h)(g):g===45||g===95||$n(g)?(a=!0,e.consume(g),f):p(g)}function h(g){return e.consume(g),s=!0,f}function p(g){return a&&s&&Wn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):n(g)}}function WB(e,t,n){const r=this;return s;function s(l){return l!==87&&l!==119||!EE.call(r,r.previous)||Mx(r.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(HB,e.attempt(bE,e.attempt(SE,a),n),n)(l))}function a(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function GB(e,t,n){const r=this;let s="",a=!1;return l;function l(g){return(g===72||g===104)&&NE.call(r,r.previous)&&!Mx(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(g),e.consume(g),d):n(g)}function d(g){if(Wn(g)&&s.length<5)return s+=String.fromCodePoint(g),e.consume(g),d;if(g===58){const _=s.toLowerCase();if(_==="http"||_==="https")return e.consume(g),f}return n(g)}function f(g){return g===47?(e.consume(g),a?h:(a=!0,f)):n(g)}function h(g){return g===null||oh(g)||Tt(g)||Aa(g)||Hh(g)?n(g):e.attempt(bE,e.attempt(SE,p),n)(g)}function p(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function qB(e,t,n){let r=0;return s;function s(l){return(l===87||l===119)&&r<3?(r++,e.consume(l),s):l===46&&r===3?(e.consume(l),a):n(l)}function a(l){return l===null?n(l):t(l)}}function KB(e,t,n){let r,s,a;return l;function l(h){return h===46||h===95?e.check(wE,f,d)(h):h===null||Tt(h)||Aa(h)||h!==45&&Hh(h)?f(h):(a=!0,e.consume(h),l)}function d(h){return h===95?r=!0:(s=r,r=void 0),e.consume(h),l}function f(h){return s||r||!a?n(h):t(h)}}function YB(e,t){let n=0,r=0;return s;function s(l){return l===40?(n++,e.consume(l),s):l===41&&r<n?a(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(wE,t,a)(l):l===null||Tt(l)||Aa(l)?t(l):(e.consume(l),s)}function a(l){return l===41&&r++,e.consume(l),s}}function XB(e,t,n){return r;function r(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),r):d===38?(e.consume(d),a):d===93?(e.consume(d),s):d===60||d===null||Tt(d)||Aa(d)?t(d):n(d)}function s(d){return d===null||d===40||d===91||Tt(d)||Aa(d)?t(d):r(d)}function a(d){return Wn(d)?l(d):n(d)}function l(d){return d===59?(e.consume(d),r):Wn(d)?(e.consume(d),l):n(d)}}function QB(e,t,n){return r;function r(a){return e.consume(a),s}function s(a){return $n(a)?n(a):t(a)}}function EE(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tt(e)}function NE(e){return!Wn(e)}function jE(e){return!(e===47||T_(e))}function T_(e){return e===43||e===45||e===46||e===95||$n(e)}function Mx(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 JB={tokenize:a8,partial:!0};function ZB(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:r8,continuation:{tokenize:s8},exit:i8}},text:{91:{name:"gfmFootnoteCall",tokenize:n8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:e8,resolveTo:t8}}}}function e8(e,t,n){const r=this;let s=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;s--;){const f=r.events[s][1];if(f.type==="labelImage"){l=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return d;function d(f){if(!l||!l._balanced)return n(f);const h=Xr(r.sliceSerialize({start:l.end,end:r.now()}));return h.codePointAt(0)!==94||!a.includes(h.slice(1))?n(f):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),t(f))}}function t8(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)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},d=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...d),e}function n8(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,l;return d;function d(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),f}function f(g){return g!==94?n(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(a>999||g===93&&!l||g===null||g===91||Tt(g))return n(g);if(g===93){e.exit("chunkString");const _=e.exit("gfmFootnoteCallString");return s.includes(Xr(r.sliceSerialize(_)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(g)}return Tt(g)||(l=!0),a++,e.consume(g),g===92?p:h}function p(g){return g===91||g===92||g===93?(e.consume(g),a++,h):h(g)}}function r8(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,l=0,d;return f;function f(v){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(v){return v===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(v)}function p(v){if(l>999||v===93&&!d||v===null||v===91||Tt(v))return n(v);if(v===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return a=Xr(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),_}return Tt(v)||(d=!0),l++,e.consume(v),v===92?g:p}function g(v){return v===91||v===92||v===93?(e.consume(v),l++,p):p(v)}function _(v){return v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),s.includes(a)||s.push(a),ct(e,x,"gfmFootnoteDefinitionWhitespace")):n(v)}function x(v){return t(v)}}function s8(e,t,n){return e.check(Qc,t,e.attempt(JB,t,n))}function i8(e){e.exit("gfmFootnoteDefinition")}function a8(e,t,n){const r=this;return ct(e,s,"gfmFootnoteDefinitionIndent",5);function s(a){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(a):n(a)}}function o8(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(l,d){let f=-1;for(;++f<l.length;)if(l[f][0]==="enter"&&l[f][1].type==="strikethroughSequenceTemporary"&&l[f][1]._close){let h=f;for(;h--;)if(l[h][0]==="exit"&&l[h][1].type==="strikethroughSequenceTemporary"&&l[h][1]._open&&l[f][1].end.offset-l[f][1].start.offset===l[h][1].end.offset-l[h][1].start.offset){l[f][1].type="strikethroughSequence",l[h][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},l[h][1].start),end:Object.assign({},l[f][1].end)},g={type:"strikethroughText",start:Object.assign({},l[h][1].end),end:Object.assign({},l[f][1].start)},_=[["enter",p,d],["enter",l[h][1],d],["exit",l[h][1],d],["enter",g,d]],x=d.parser.constructs.insideSpan.null;x&&_r(_,_.length,0,Fh(x,l.slice(h+1,f),d)),_r(_,_.length,0,[["exit",g,d],["enter",l[f][1],d],["exit",l[f][1],d],["exit",p,d]]),_r(l,h-1,f-h+3,_),f=h+_.length-2;break}}for(f=-1;++f<l.length;)l[f][1].type==="strikethroughSequenceTemporary"&&(l[f][1].type="data");return l}function a(l,d,f){const h=this.previous,p=this.events;let g=0;return _;function _(v){return h===126&&p[p.length-1][1].type!=="characterEscape"?f(v):(l.enter("strikethroughSequenceTemporary"),x(v))}function x(v){const S=Wo(h);if(v===126)return g>1?f(v):(l.consume(v),g++,x);if(g<2&&!n)return f(v);const w=l.exit("strikethroughSequenceTemporary"),k=Wo(v);return w._open=!k||k===2&&!!S,w._close=!S||S===2&&!!k,d(v)}}}class l8{constructor(){this.map=[]}add(t,n,r){c8(this,t,n,r)}consume(t){if(this.map.sort(function(a,l){return a[0]-l[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const a of s)t.push(a);s=r.pop()}this.map.length=0}}function c8(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function u8(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function d8(){return{flow:{null:{name:"table",tokenize:h8,resolveAll:f8}}}}function h8(e,t,n){const r=this;let s=0,a=0,l;return d;function d(I){let W=r.events.length-1;for(;W>-1;){const U=r.events[W][1].type;if(U==="lineEnding"||U==="linePrefix")W--;else break}const z=W>-1?r.events[W][1].type:null,L=z==="tableHead"||z==="tableRow"?R:f;return L===R&&r.parser.lazy[r.now().line]?n(I):L(I)}function f(I){return e.enter("tableHead"),e.enter("tableRow"),h(I)}function h(I){return I===124||(l=!0,a+=1),p(I)}function p(I){return I===null?n(I):Be(I)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),x):n(I):rt(I)?ct(e,p,"whitespace")(I):(a+=1,l&&(l=!1,s+=1),I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),l=!0,p):(e.enter("data"),g(I)))}function g(I){return I===null||I===124||Tt(I)?(e.exit("data"),p(I)):(e.consume(I),I===92?_:g)}function _(I){return I===92||I===124?(e.consume(I),g):g(I)}function x(I){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(I):(e.enter("tableDelimiterRow"),l=!1,rt(I)?ct(e,v,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):v(I))}function v(I){return I===45||I===58?w(I):I===124?(l=!0,e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),S):P(I)}function S(I){return rt(I)?ct(e,w,"whitespace")(I):w(I)}function w(I){return I===58?(a+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),k):I===45?(a+=1,k(I)):I===null||Be(I)?A(I):P(I)}function k(I){return I===45?(e.enter("tableDelimiterFiller"),j(I)):P(I)}function j(I){return I===45?(e.consume(I),j):I===58?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),T):(e.exit("tableDelimiterFiller"),T(I))}function T(I){return rt(I)?ct(e,A,"whitespace")(I):A(I)}function A(I){return I===124?v(I):I===null||Be(I)?!l||s!==a?P(I):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(I)):P(I)}function P(I){return n(I)}function R(I){return e.enter("tableRow"),q(I)}function q(I){return I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),q):I===null||Be(I)?(e.exit("tableRow"),t(I)):rt(I)?ct(e,q,"whitespace")(I):(e.enter("data"),J(I))}function J(I){return I===null||I===124||Tt(I)?(e.exit("data"),q(I)):(e.consume(I),I===92?ne:J)}function ne(I){return I===92||I===124?(e.consume(I),J):J(I)}}function f8(e,t){let n=-1,r=!0,s=0,a=[0,0,0,0],l=[0,0,0,0],d=!1,f=0,h,p,g;const _=new l8;for(;++n<e.length;){const x=e[n],v=x[1];x[0]==="enter"?v.type==="tableHead"?(d=!1,f!==0&&(Tw(_,t,f,h,p),p=void 0,f=0),h={type:"table",start:Object.assign({},v.start),end:Object.assign({},v.end)},_.add(n,0,[["enter",h,t]])):v.type==="tableRow"||v.type==="tableDelimiterRow"?(r=!0,g=void 0,a=[0,0,0,0],l=[0,n+1,0,0],d&&(d=!1,p={type:"tableBody",start:Object.assign({},v.start),end:Object.assign({},v.end)},_.add(n,0,[["enter",p,t]])),s=v.type==="tableDelimiterRow"?2:p?3:1):s&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(a[1]!==0&&(l[0]=l[1],g=Ad(_,t,a,s,void 0,g),a=[0,0,0,0]),l[2]=n)):v.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(l[0]=l[1],g=Ad(_,t,a,s,void 0,g)),a=l,l=[a[1],n,0,0])):v.type==="tableHead"?(d=!0,f=n):v.type==="tableRow"||v.type==="tableDelimiterRow"?(f=n,a[1]!==0?(l[0]=l[1],g=Ad(_,t,a,s,n,g)):l[1]!==0&&(g=Ad(_,t,l,s,n,g)),s=0):s&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")&&(l[3]=n)}for(f!==0&&Tw(_,t,f,h,p),_.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=u8(t.events,n))}return e}function Ad(e,t,n,r,s,a){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",d="tableContent";n[0]!==0&&(a.end=Object.assign({},Po(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const f=Po(t.events,n[1]);if(a={type:l,start:Object.assign({},f),end:Object.assign({},f)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const h=Po(t.events,n[2]),p=Po(t.events,n[3]),g={type:d,start:Object.assign({},h),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",g,t]]),r!==2){const _=t.events[n[2]],x=t.events[n[3]];if(_[1].end=Object.assign({},x[1].end),_[1].type="chunkText",_[1].contentType="text",n[3]>n[2]+1){const v=n[2]+1,S=n[3]-n[2]-1;e.add(v,S,[])}}e.add(n[3]+1,0,[["exit",g,t]])}return s!==void 0&&(a.end=Object.assign({},Po(t.events,s)),e.add(s,0,[["exit",a,t]]),a=void 0),a}function Tw(e,t,n,r,s){const a=[],l=Po(t.events,n);s&&(s.end=Object.assign({},l),a.push(["exit",s,t])),r.end=Object.assign({},l),a.push(["exit",r,t]),e.add(n+1,0,a)}function Po(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const m8={name:"tasklistCheck",tokenize:g8};function p8(){return{text:{91:m8}}}function g8(e,t,n){const r=this;return s;function s(f){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(f):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),a)}function a(f){return Tt(f)?(e.enter("taskListCheckValueUnchecked"),e.consume(f),e.exit("taskListCheckValueUnchecked"),l):f===88||f===120?(e.enter("taskListCheckValueChecked"),e.consume(f),e.exit("taskListCheckValueChecked"),l):n(f)}function l(f){return f===93?(e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):n(f)}function d(f){return Be(f)?t(f):rt(f)?e.check({tokenize:_8},t,n)(f):n(f)}}function _8(e,t,n){return ct(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function x8(e){return z2([UB(),ZB(),o8(e),d8(),p8()])}const y8={};function v8(e){const t=this,n=e||y8,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(x8(n)),a.push(zB()),l.push($B(n))}var A_=Object.defineProperty,b8=Object.getOwnPropertyDescriptor,S8=Object.getOwnPropertyNames,w8=Object.prototype.hasOwnProperty,Ox=(e,t)=>{let n={};for(var r in e)A_(n,r,{get:e[r],enumerable:!0});return A_(n,Symbol.toStringTag,{value:"Module"}),n},C8=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var s=S8(t),a=0,l=s.length,d;a<l;a++)d=s[a],!w8.call(e,d)&&d!==n&&A_(e,d,{get:(f=>t[f]).bind(null,d),enumerable:!(r=b8(t,d))||r.enumerable});return e},TE=(e,t,n)=>(C8(e,t,"default"),n);const Gh=[{id:"abap",name:"ABAP",import:(()=>$(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>$(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>$(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>$(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>$(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>$(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>$(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>$(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>$(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>$(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>$(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>$(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>$(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>$(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>$(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>$(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>$(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>$(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>$(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>$(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>$(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>$(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>$(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>$(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>$(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>$(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>$(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>$(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>$(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>$(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>$(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>$(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>$(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>$(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>$(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>$(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>$(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>$(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>$(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>$(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>$(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>$(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>$(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>$(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>$(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>$(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>$(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>$(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>$(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>$(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>$(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>$(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>$(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>$(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>$(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>$(()=>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:(()=>$(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>$(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>$(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>$(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>$(()=>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:(()=>$(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>$(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>$(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>$(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>$(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>$(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>$(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>$(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>$(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>$(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>$(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>$(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>$(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>$(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>$(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>$(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>$(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>$(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>$(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>$(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>$(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>$(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>$(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>$(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>$(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>$(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>$(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>$(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>$(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>$(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>$(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>$(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>$(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>$(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>$(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>$(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>$(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>$(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>$(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>$(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>$(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>$(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>$(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>$(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>$(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>$(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>$(()=>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:(()=>$(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>$(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>$(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>$(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>$(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>$(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>$(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>$(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>$(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>$(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>$(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>$(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>$(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>$(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>$(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>$(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>$(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>$(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>$(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>$(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>$(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>$(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>$(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>$(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>$(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>$(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>$(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>$(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>$(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>$(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>$(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>$(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>$(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>$(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>$(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>$(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>$(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>$(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>$(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>$(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>$(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>$(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>$(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>$(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>$(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>$(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>$(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>$(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>$(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>$(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>$(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>$(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>$(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>$(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>$(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>$(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>$(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>$(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>$(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>$(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>$(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>$(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>$(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>$(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>$(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>$(()=>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:(()=>$(()=>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:(()=>$(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>$(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>$(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>$(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>$(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>$(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>$(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>$(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>$(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>$(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>$(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>$(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>$(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>$(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>$(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>$(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>$(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>$(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>$(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>$(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>$(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>$(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>$(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>$(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>$(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>$(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>$(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>$(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>$(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>$(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>$(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>$(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>$(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>$(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>$(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>$(()=>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:(()=>$(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>$(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>$(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>$(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>$(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>$(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>$(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>$(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>$(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>$(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>$(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>$(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>$(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>$(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>$(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>$(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>$(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>$(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>$(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>$(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>$(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>$(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>$(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>$(()=>import("./zig-VOosw3JB.js"),[]))}],Ix=Object.fromEntries(Gh.map(e=>[e.id,e.import])),Px=Object.fromEntries(Gh.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),Bx={...Ix,...Px},zx=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>$(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>$(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>$(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>$(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>$(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>$(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>$(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>$(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>$(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>$(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>$(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>$(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>$(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>$(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>$(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>$(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>$(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>$(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>$(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>$(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>$(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>$(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>$(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>$(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>$(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>$(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>$(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>$(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>$(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>$(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>$(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>$(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>$(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>$(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>$(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>$(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>$(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>$(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>$(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>$(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>$(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>$(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>$(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>$(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>$(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>$(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>$(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>$(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>$(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>$(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>$(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>$(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>$(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>$(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>$(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>$(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>$(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>$(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>$(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>$(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>$(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>$(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>$(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>$(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>$(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],$x=Object.fromEntries(zx.map(e=>[e.id,e.import]));var Hx=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function k8(){return 2147483648}function E8(){return typeof performance<"u"?performance.now():Date.now()}const N8=(e,t)=>e+(t-e%t)%t;async function j8(e){let t,n;const r={};function s(x){n=x,r.HEAPU8=new Uint8Array(x),r.HEAPU32=new Uint32Array(x)}function a(x,v,S){r.HEAPU8.copyWithin(x,v,v+S)}function l(x){try{return t.grow(x-n.byteLength+65535>>>16),s(t.buffer),1}catch{}}function d(x){const v=r.HEAPU8.length;x=x>>>0;const S=k8();if(x>S)return!1;for(let w=1;w<=4;w*=2){let k=v*(1+.2/w);k=Math.min(k,x+100663296);const j=Math.min(S,N8(Math.max(x,k),65536));if(l(j))return!0}return!1}const f=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(x,v,S=1024){const w=v+S;let k=v;for(;x[k]&&!(k>=w);)++k;if(k-v>16&&x.buffer&&f)return f.decode(x.subarray(v,k));let j="";for(;v<k;){let T=x[v++];if(!(T&128)){j+=String.fromCharCode(T);continue}const A=x[v++]&63;if((T&224)===192){j+=String.fromCharCode((T&31)<<6|A);continue}const P=x[v++]&63;if((T&240)===224?T=(T&15)<<12|A<<6|P:T=(T&7)<<18|A<<12|P<<6|x[v++]&63,T<65536)j+=String.fromCharCode(T);else{const R=T-65536;j+=String.fromCharCode(55296|R>>10,56320|R&1023)}}return j}function p(x,v){return x?h(r.HEAPU8,x,v):""}const g={emscripten_get_now:E8,emscripten_memcpy_big:a,emscripten_resize_heap:d,fd_write:()=>0};async function _(){const v=await e({env:g,wasi_snapshot_preview1:g});t=v.memory,s(t.buffer),Object.assign(r,v),r.UTF8ToString=p}return await _(),r}var T8=Object.defineProperty,A8=(e,t,n)=>t in e?T8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pn=(e,t,n)=>A8(e,typeof t!="symbol"?t+"":t,n);let bn=null;function D8(e){throw new Hx(e.UTF8ToString(e.getLastOnigError()))}class qh{constructor(t){pn(this,"utf16Length"),pn(this,"utf8Length"),pn(this,"utf16Value"),pn(this,"utf8Value"),pn(this,"utf16OffsetToUtf8"),pn(this,"utf8OffsetToUtf16");const n=t.length,r=qh._utf8ByteLength(t),s=r!==n,a=s?new Uint32Array(n+1):null;s&&(a[n]=r);const l=s?new Uint32Array(r+1):null;s&&(l[r]=n);const d=new Uint8Array(r);let f=0;for(let h=0;h<n;h++){const p=t.charCodeAt(h);let g=p,_=!1;if(p>=55296&&p<=56319&&h+1<n){const x=t.charCodeAt(h+1);x>=56320&&x<=57343&&(g=(p-55296<<10)+65536|x-56320,_=!0)}s&&(a[h]=f,_&&(a[h+1]=f),g<=127?l[f+0]=h:g<=2047?(l[f+0]=h,l[f+1]=h):g<=65535?(l[f+0]=h,l[f+1]=h,l[f+2]=h):(l[f+0]=h,l[f+1]=h,l[f+2]=h,l[f+3]=h)),g<=127?d[f++]=g:g<=2047?(d[f++]=192|(g&1984)>>>6,d[f++]=128|(g&63)>>>0):g<=65535?(d[f++]=224|(g&61440)>>>12,d[f++]=128|(g&4032)>>>6,d[f++]=128|(g&63)>>>0):(d[f++]=240|(g&1835008)>>>18,d[f++]=128|(g&258048)>>>12,d[f++]=128|(g&4032)>>>6,d[f++]=128|(g&63)>>>0),_&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=d,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=l}static _utf8ByteLength(t){let n=0;for(let r=0,s=t.length;r<s;r++){const a=t.charCodeAt(r);let l=a,d=!1;if(a>=55296&&a<=56319&&r+1<s){const f=t.charCodeAt(r+1);f>=56320&&f<=57343&&(l=(a-55296<<10)+65536|f-56320,d=!0)}l<=127?n+=1:l<=2047?n+=2:l<=65535?n+=3:n+=4,d&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const Kh=class cs{constructor(t){if(pn(this,"id",++cs.LAST_ID),pn(this,"_onigBinding"),pn(this,"content"),pn(this,"utf16Length"),pn(this,"utf8Length"),pn(this,"utf16OffsetToUtf8"),pn(this,"utf8OffsetToUtf16"),pn(this,"ptr"),!bn)throw new Hx("Must invoke loadWasm first.");this._onigBinding=bn,this.content=t;const n=new qh(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!cs._sharedPtrInUse?(cs._sharedPtr||(cs._sharedPtr=bn.omalloc(1e4)),cs._sharedPtrInUse=!0,bn.HEAPU8.set(n.utf8Value,cs._sharedPtr),this.ptr=cs._sharedPtr):this.ptr=n.createString(bn)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===cs._sharedPtr?cs._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};pn(Kh,"LAST_ID",0);pn(Kh,"_sharedPtr",0);pn(Kh,"_sharedPtrInUse",!1);let AE=Kh;class L8{constructor(t){if(pn(this,"_onigBinding"),pn(this,"_ptr"),!bn)throw new Hx("Must invoke loadWasm first.");const n=[],r=[];for(let d=0,f=t.length;d<f;d++){const h=new qh(t[d]);n[d]=h.createString(bn),r[d]=h.utf8Length}const s=bn.omalloc(4*t.length);bn.HEAPU32.set(n,s/4);const a=bn.omalloc(4*t.length);bn.HEAPU32.set(r,a/4);const l=bn.createOnigScanner(s,a,t.length);for(let d=0,f=t.length;d<f;d++)bn.ofree(n[d]);bn.ofree(a),bn.ofree(s),l===0&&D8(bn),this._onigBinding=bn,this._ptr=l}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let s=0;if(typeof r=="number"&&(s=r),typeof t=="string"){t=new AE(t);const a=this._findNextMatchSync(t,n,!1,s);return t.dispose(),a}return this._findNextMatchSync(t,n,!1,s)}_findNextMatchSync(t,n,r,s){const a=this._onigBinding,l=a.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),s);if(l===0)return null;const d=a.HEAPU32;let f=l/4;const h=d[f++],p=d[f++],g=[];for(let _=0;_<p;_++){const x=t.convertUtf8OffsetToUtf16(d[f++]),v=t.convertUtf8OffsetToUtf16(d[f++]);g[_]={start:x,end:v,length:v-x}}return{index:h,captureIndices:g}}}function R8(e){return typeof e.instantiator=="function"}function M8(e){return typeof e.default=="function"}function O8(e){return typeof e.data<"u"}function I8(e){return typeof Response<"u"&&e instanceof Response}function P8(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 Dd;function Fx(e){if(Dd)return Dd;async function t(){bn=await j8(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),R8(r)?r=await r.instantiator(n):M8(r)?r=await r.default(n):(O8(r)&&(r=r.data),I8(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await B8(r)(n):r=await z8(r)(n):P8(r)?r=await cg(r)(n):r instanceof WebAssembly.Module?r=await cg(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await cg(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Dd=t(),Dd}function cg(e){return t=>WebAssembly.instantiate(e,t)}function B8(e){return t=>WebAssembly.instantiateStreaming(e,t)}function z8(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let DE;function $8(e){DE=e}function H8(){return DE}async function LE(e){return e&&await Fx(e),{createScanner(t){return new L8(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new AE(t)}}}const F8=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:LE,getDefaultWasmLoader:H8,loadWasm:Fx,setDefaultWasmLoader:$8},Symbol.toStringTag,{value:"Module"}));var RE=Ox({});TE(RE,F8);var Dt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function U8(e){return Ux(e)}function Ux(e){return Array.isArray(e)?V8(e):e instanceof RegExp?e:typeof e=="object"?W8(e):e}function V8(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Ux(e[n]);return t}function W8(e){let t={};for(let n in e)t[n]=Ux(e[n]);return t}function ME(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function OE(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?OE(e.substring(0,e.length-1)):e.substr(~t+1)}var ug=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ld=class{static hasCaptures(e){return e===null?!1:(ug.lastIndex=0,ug.test(e))}static replaceCaptures(e,t,n){return e.replace(ug,(r,s,a,l)=>{let d=n[parseInt(s||a,10)];if(d){let f=t.substring(d.start,d.end);for(;f[0]===".";)f=f.substring(1);switch(l){case"downcase":return f.toLowerCase();case"upcase":return f.toUpperCase();default:return f}}else return r})}};function IE(e,t){return e<t?-1:e>t?1:0}function PE(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 s=0;s<n;s++){let a=IE(e[s],t[s]);if(a!==0)return a}return 0}return n-r}function Aw(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 BE(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var zE=class{constructor(e){ce(this,"cache",new Map);this.fn=e}get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},hh=class{constructor(e,t,n){ce(this,"_cachedMatchRoot",new zE(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(K8(e),t)}static createFromParsedTheme(e,t){return X8(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(s=>G8(e.parent,s.parentScopes));return r?new $E(r.fontStyle,r.foreground,r.background):null}},dg=class Kd{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Kd(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Kd(n,t[r]);return n}push(t){return new Kd(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 G8(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!q8(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function q8(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var $E=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function K8(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let s=0,a=t.length;s<a;s++){let l=t[s];if(!l.settings)continue;let d;if(typeof l.scope=="string"){let g=l.scope;g=g.replace(/^[,]+/,""),g=g.replace(/[,]+$/,""),d=g.split(",")}else Array.isArray(l.scope)?d=l.scope:d=[""];let f=-1;if(typeof l.settings.fontStyle=="string"){f=0;let g=l.settings.fontStyle.split(" ");for(let _=0,x=g.length;_<x;_++)switch(g[_]){case"italic":f=f|1;break;case"bold":f=f|2;break;case"underline":f=f|4;break;case"strikethrough":f=f|8;break}}let h=null;typeof l.settings.foreground=="string"&&Aw(l.settings.foreground)&&(h=l.settings.foreground);let p=null;typeof l.settings.background=="string"&&Aw(l.settings.background)&&(p=l.settings.background);for(let g=0,_=d.length;g<_;g++){let v=d[g].trim().split(" "),S=v[v.length-1],w=null;v.length>1&&(w=v.slice(0,v.length-1),w.reverse()),n[r++]=new Y8(S,w,s,f,h,p)}}return n}var Y8=class{constructor(e,t,n,r,s,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=a}},zn=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(zn||{});function X8(e,t){e.sort((f,h)=>{let p=IE(f.scope,h.scope);return p!==0||(p=PE(f.parentScopes,h.parentScopes),p!==0)?p:f.index-h.index});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&e[0].scope==="";){let f=e.shift();f.fontStyle!==-1&&(n=f.fontStyle),f.foreground!==null&&(r=f.foreground),f.background!==null&&(s=f.background)}let a=new Q8(t),l=new $E(n,a.getId(r),a.getId(s)),d=new Z8(new D_(0,null,-1,0,0),[]);for(let f=0,h=e.length;f<h;f++){let p=e[f];d.insert(0,p.scope,p.parentScopes,p.fontStyle,a.getId(p.foreground),a.getId(p.background))}return new hh(a,l,d)}var Q8=class{constructor(e){ce(this,"_isFrozen");ce(this,"_lastColorId");ce(this,"_id2color");ce(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},J8=Object.freeze([]),D_=class HE{constructor(t,n,r,s,a){ce(this,"scopeDepth");ce(this,"parentScopes");ce(this,"fontStyle");ce(this,"foreground");ce(this,"background");this.scopeDepth=t,this.parentScopes=n||J8,this.fontStyle=r,this.foreground=s,this.background=a}clone(){return new HE(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,s=t.length;r<s;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,s){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Z8=class L_{constructor(t,n=[],r={}){ce(this,"_rulesWithParentScopes");this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,s=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=t.parentScopes.length||s>=n.parentScopes.length);){const a=n.parentScopes[s].length-t.parentScopes[r].length;if(a!==0)return a;r++,s++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),s,a;if(r===-1?(s=t,a=""):(s=t.substring(0,r),a=t.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(a)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(L_._cmpBySpecificity),n}insert(t,n,r,s,a,l){if(n===""){this._doInsertHere(t,r,s,a,l);return}let d=n.indexOf("."),f,h;d===-1?(f=n,h=""):(f=n.substring(0,d),h=n.substring(d+1));let p;this._children.hasOwnProperty(f)?p=this._children[f]:(p=new L_(this._mainRule.clone(),D_.cloneArr(this._rulesWithParentScopes)),this._children[f]=p),p.insert(t+1,h,r,s,a,l)}_doInsertHere(t,n,r,s,a){if(n===null){this._mainRule.acceptOverwrite(t,r,s,a);return}for(let l=0,d=this._rulesWithParentScopes.length;l<d;l++){let f=this._rulesWithParentScopes[l];if(PE(f.parentScopes,n)===0){f.acceptOverwrite(t,r,s,a);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new D_(t,n,r,s,a))}},Go=class Dr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Dr.getLanguageId(t),r=Dr.getTokenType(t),s=Dr.getFontStyle(t),a=Dr.getForeground(t),l=Dr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:a,background:l})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,s,a,l,d){let f=Dr.getLanguageId(t),h=Dr.getTokenType(t),p=Dr.containsBalancedBrackets(t)?1:0,g=Dr.getFontStyle(t),_=Dr.getForeground(t),x=Dr.getBackground(t);return n!==0&&(f=n),r!==8&&(h=r),s!==null&&(p=s?1:0),a!==-1&&(g=a),l!==0&&(_=l),d!==0&&(x=d),(f<<0|h<<8|p<<10|g<<11|_<<15|x<<24)>>>0}};function fh(e,t){const n=[],r=ez(e);let s=r.next();for(;s!==null;){let f=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":f=1;break;case"L":f=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let h=l();if(n.push({matcher:h,priority:f}),s!==",")break;s=r.next()}return n;function a(){if(s==="-"){s=r.next();const f=a();return h=>!!f&&!f(h)}if(s==="("){s=r.next();const f=d();return s===")"&&(s=r.next()),f}if(Dw(s)){const f=[];do f.push(s),s=r.next();while(Dw(s));return h=>t(f,h)}return null}function l(){const f=[];let h=a();for(;h;)f.push(h),h=a();return p=>f.every(g=>g(p))}function d(){const f=[];let h=l();for(;h&&(f.push(h),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");h=l()}return p=>f.some(g=>g(p))}}function Dw(e){return!!e&&!!e.match(/[\w\.:]+/)}function ez(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 FE(e){typeof e.dispose=="function"&&e.dispose()}var Rc=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},tz=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},nz=class{constructor(){ce(this,"_references",[]);ce(this,"_seenReferenceKeys",new Set);ce(this,"visitedRule",new Set)}get references(){return this._references}add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},rz=class{constructor(e,t){ce(this,"seenFullScopeRequests",new Set);ce(this,"seenPartialScopeRequests",new Set);ce(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Rc(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new nz;for(const n of e)sz(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof Rc){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 sz(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const a=n.lookup(t);e instanceof Rc?Yd({baseGrammar:a,selfGrammar:s},r):R_(e.ruleName,{baseGrammar:a,selfGrammar:s,repository:s.repository},r);const l=n.injections(e.scopeName);if(l)for(const d of l)r.add(new Rc(d))}function R_(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];mh([r],t,n)}}function Yd(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&mh(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&mh(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function mh(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?ME({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&mh(r.patterns,{...t,repository:s},n);const a=r.include;if(!a)continue;const l=UE(a);switch(l.kind){case 0:Yd({...t,selfGrammar:t.baseGrammar},n);break;case 1:Yd(t,n);break;case 2:R_(l.ruleName,{...t,repository:s},n);break;case 3:case 4:const d=l.scopeName===t.selfGrammar.scopeName?t.selfGrammar:l.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(d){const f={baseGrammar:t.baseGrammar,selfGrammar:d,repository:s};l.kind===4?R_(l.ruleName,f,n):Yd(f,n)}else l.kind===4?n.add(new tz(l.scopeName,l.ruleName)):n.add(new Rc(l.scopeName));break}}}var iz=class{constructor(){ce(this,"kind",0)}},az=class{constructor(){ce(this,"kind",1)}},oz=class{constructor(e){ce(this,"kind",2);this.ruleName=e}},lz=class{constructor(e){ce(this,"kind",3);this.scopeName=e}},cz=class{constructor(e,t){ce(this,"kind",4);this.scopeName=e,this.ruleName=t}};function UE(e){if(e==="$base")return new iz;if(e==="$self")return new az;const t=e.indexOf("#");if(t===-1)return new lz(e);if(t===0)return new oz(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new cz(n,r)}}var uz=/\\(\d+)/,Lw=/\\(\d+)/g,dz=-1,VE=-2;var Zc=class{constructor(e,t,n,r){ce(this,"$location");ce(this,"id");ce(this,"_nameIsCapturing");ce(this,"_name");ce(this,"_contentNameIsCapturing");ce(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Ld.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Ld.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${OE(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:Ld.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ld.replaceCaptures(this._contentName,e,t)}},hz=class extends Zc{constructor(t,n,r,s,a){super(t,n,r,s);ce(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=a}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,s){throw new Error("Not supported!")}},fz=class extends Zc{constructor(t,n,r,s,a){super(t,n,r,null);ce(this,"_match");ce(this,"captures");ce(this,"_cachedCompiledPatterns");this._match=new Mc(s,this.id),this.captures=a,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,s){return this._getCachedCompiledPatterns(t).compileAG(t,r,s)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Oc,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Rw=class extends Zc{constructor(t,n,r,s,a){super(t,n,r,s);ce(this,"hasMissingPatterns");ce(this,"patterns");ce(this,"_cachedCompiledPatterns");this.patterns=a.patterns,this.hasMissingPatterns=a.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,s){return this._getCachedCompiledPatterns(t).compileAG(t,r,s)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Oc,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},M_=class extends Zc{constructor(t,n,r,s,a,l,d,f,h,p){super(t,n,r,s);ce(this,"_begin");ce(this,"beginCaptures");ce(this,"_end");ce(this,"endHasBackReferences");ce(this,"endCaptures");ce(this,"applyEndPatternLast");ce(this,"hasMissingPatterns");ce(this,"patterns");ce(this,"_cachedCompiledPatterns");this._begin=new Mc(a,this.id),this.beginCaptures=l,this._end=new Mc(d||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=f,this.applyEndPatternLast=h||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,s){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,s)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Oc;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}},ph=class extends Zc{constructor(t,n,r,s,a,l,d,f,h){super(t,n,r,s);ce(this,"_begin");ce(this,"beginCaptures");ce(this,"whileCaptures");ce(this,"_while");ce(this,"whileHasBackReferences");ce(this,"hasMissingPatterns");ce(this,"patterns");ce(this,"_cachedCompiledPatterns");ce(this,"_cachedCompiledWhilePatterns");this._begin=new Mc(a,this.id),this.beginCaptures=l,this.whileCaptures=f,this._while=new Mc(d,VE),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=h.patterns,this.hasMissingPatterns=h.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,n){return this._while.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,s){return this._getCachedCompiledPatterns(t).compileAG(t,r,s)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Oc;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,s){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,s)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Oc,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},WE=class Bn{static createCaptureRule(t,n,r,s,a){return t.registerRule(l=>new hz(n,l,r,s,a))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new fz(t.$vscodeTextmateLocation,t.id,t.name,t.match,Bn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=ME({},r,t.repository));let a=t.patterns;return typeof a>"u"&&t.include&&(a=[{include:t.include}]),new Rw(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Bn._compilePatterns(a,n,r))}return t.while?new ph(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Bn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Bn._compileCaptures(t.whileCaptures||t.captures,n,r),Bn._compilePatterns(t.patterns,n,r)):new M_(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Bn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Bn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Bn._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let a=0;for(const l in t){if(l==="$vscodeTextmateLocation")continue;const d=parseInt(l,10);d>a&&(a=d)}for(let l=0;l<=a;l++)s[l]=null;for(const l in t){if(l==="$vscodeTextmateLocation")continue;const d=parseInt(l,10);let f=0;t[l].patterns&&(f=Bn.getCompiledRuleId(t[l],n,r)),s[d]=Bn.createCaptureRule(n,t[l].$vscodeTextmateLocation,t[l].name,t[l].contentName,f)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let a=0,l=t.length;a<l;a++){const d=t[a];let f=-1;if(d.include){const h=UE(d.include);switch(h.kind){case 0:case 1:f=Bn.getCompiledRuleId(r[d.include],n,r);break;case 2:let p=r[h.ruleName];p&&(f=Bn.getCompiledRuleId(p,n,r));break;case 3:case 4:const g=h.scopeName,_=h.kind===4?h.ruleName:null,x=n.getExternalGrammar(g,r);if(x)if(_){let v=x.repository[_];v&&(f=Bn.getCompiledRuleId(v,n,x.repository))}else f=Bn.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else f=Bn.getCompiledRuleId(d,n,r);if(f!==-1){const h=n.getRule(f);let p=!1;if((h instanceof Rw||h instanceof M_||h instanceof ph)&&h.hasMissingPatterns&&h.patterns.length===0&&(p=!0),p)continue;s.push(f)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},Mc=class GE{constructor(t,n){ce(this,"source");ce(this,"ruleId");ce(this,"hasAnchor");ce(this,"hasBackReferences");ce(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let s=0,a=[],l=!1;for(let d=0;d<r;d++)if(t.charAt(d)==="\\"&&d+1<r){const h=t.charAt(d+1);h==="z"?(a.push(t.substring(s,d)),a.push("$(?!\\n)(?<!\\n)"),s=d+2):(h==="A"||h==="G")&&(l=!0),d++}this.hasAnchor=l,s===0?this.source=t:(a.push(t.substring(s,r)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=uz.test(this.source):this.hasBackReferences=!1}clone(){return new GE(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(s=>t.substring(s.start,s.end));return Lw.lastIndex=0,this.source.replace(Lw,(s,a)=>BE(r[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],s=[],a,l,d,f;for(a=0,l=this.source.length;a<l;a++)d=this.source.charAt(a),t[a]=d,n[a]=d,r[a]=d,s[a]=d,d==="\\"&&a+1<l&&(f=this.source.charAt(a+1),f==="A"?(t[a+1]="￿",n[a+1]="￿",r[a+1]="A",s[a+1]="A"):f==="G"?(t[a+1]="￿",n[a+1]="G",r[a+1]="￿",s[a+1]="G"):(t[a+1]=f,n[a+1]=f,r[a+1]=f,s[a+1]=f),a++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.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}},Oc=class{constructor(){ce(this,"_items");ce(this,"_hasAnchors");ce(this,"_cached");ce(this,"_anchorCache");this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Mw(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(s=>s.resolveAnchors(t,n));return new Mw(e,r,this._items.map(s=>s.ruleId))}},Mw=class{constructor(e,t,n){ce(this,"scanner");this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
141
- `)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},hg=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Ws,mz=(Ws=class{constructor(t,n){ce(this,"_defaultAttributes");ce(this,"_embeddedLanguagesMatcher");ce(this,"_getBasicScopeAttributes",new zE(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new hg(n,r)}));this._defaultAttributes=new hg(t,8),this._embeddedLanguagesMatcher=new pz(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Ws._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(Ws.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}},ce(Ws,"_NULL_SCOPE_METADATA",new hg(0,0)),ce(Ws,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),Ws),pz=class{constructor(e){ce(this,"values");ce(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>BE(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])}},Ow=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function qE(e,t,n,r,s,a,l,d){const f=t.content.length;let h=!1,p=-1;if(l){const x=gz(e,t,n,r,s,a);s=x.stack,r=x.linePos,n=x.isFirstLine,p=x.anchorPosition}const g=Date.now();for(;!h;){if(d!==0&&Date.now()-g>d)return new Ow(s,!0);_()}return new Ow(s,!1);function _(){const x=_z(e,t,n,r,s,p);if(!x){a.produce(s,f),h=!0;return}const v=x.captureIndices,S=x.matchedRuleId,w=v&&v.length>0?v[0].end>r:!1;if(S===dz){const k=s.getRule(e);a.produce(s,v[0].start),s=s.withContentNameScopesList(s.nameScopesList),xc(e,t,n,s,a,k.endCaptures,v),a.produce(s,v[0].end);const j=s;if(s=s.parent,p=j.getAnchorPos(),!w&&j.getEnterPos()===r){s=j,a.produce(s,f),h=!0;return}}else{const k=e.getRule(S);a.produce(s,v[0].start);const j=s,T=k.getName(t.content,v),A=s.contentNameScopesList.pushAttributed(T,e);if(s=s.push(S,r,p,v[0].end===f,null,A,A),k instanceof M_){const P=k;xc(e,t,n,s,a,P.beginCaptures,v),a.produce(s,v[0].end),p=v[0].end;const R=P.getContentName(t.content,v),q=A.pushAttributed(R,e);if(s=s.withContentNameScopesList(q),P.endHasBackReferences&&(s=s.withEndRule(P.getEndWithResolvedBackReferences(t.content,v))),!w&&j.hasSameRuleAs(s)){s=s.pop(),a.produce(s,f),h=!0;return}}else if(k instanceof ph){const P=k;xc(e,t,n,s,a,P.beginCaptures,v),a.produce(s,v[0].end),p=v[0].end;const R=P.getContentName(t.content,v),q=A.pushAttributed(R,e);if(s=s.withContentNameScopesList(q),P.whileHasBackReferences&&(s=s.withEndRule(P.getWhileWithResolvedBackReferences(t.content,v))),!w&&j.hasSameRuleAs(s)){s=s.pop(),a.produce(s,f),h=!0;return}}else if(xc(e,t,n,s,a,k.captures,v),a.produce(s,v[0].end),s=s.pop(),!w){s=s.safePop(),a.produce(s,f),h=!0;return}}v[0].end>r&&(r=v[0].end,n=!1)}}function gz(e,t,n,r,s,a){let l=s.beginRuleCapturedEOL?0:-1;const d=[];for(let f=s;f;f=f.pop()){const h=f.getRule(e);h instanceof ph&&d.push({rule:h,stack:f})}for(let f=d.pop();f;f=d.pop()){const{ruleScanner:h,findOptions:p}=vz(f.rule,e,f.stack.endRule,n,r===l),g=h.findNextMatchSync(t,r,p);if(g){if(g.ruleId!==VE){s=f.stack.pop();break}g.captureIndices&&g.captureIndices.length&&(a.produce(f.stack,g.captureIndices[0].start),xc(e,t,n,f.stack,a,f.rule.whileCaptures,g.captureIndices),a.produce(f.stack,g.captureIndices[0].end),l=g.captureIndices[0].end,g.captureIndices[0].end>r&&(r=g.captureIndices[0].end,n=!1))}else{s=f.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:l,isFirstLine:n}}function _z(e,t,n,r,s,a){const l=xz(e,t,n,r,s,a),d=e.getInjections();if(d.length===0)return l;const f=yz(d,e,t,n,r,s,a);if(!f)return l;if(!l)return f;const h=l.captureIndices[0].start,p=f.captureIndices[0].start;return p<h||f.priorityMatch&&p===h?f:l}function xz(e,t,n,r,s,a){const l=s.getRule(e),{ruleScanner:d,findOptions:f}=KE(l,e,s.endRule,n,r===a),h=d.findNextMatchSync(t,r,f);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function yz(e,t,n,r,s,a,l){let d=Number.MAX_VALUE,f=null,h,p=0;const g=a.contentNameScopesList.getScopeNames();for(let _=0,x=e.length;_<x;_++){const v=e[_];if(!v.matcher(g))continue;const S=t.getRule(v.ruleId),{ruleScanner:w,findOptions:k}=KE(S,t,null,r,s===l),j=w.findNextMatchSync(n,s,k);if(!j)continue;const T=j.captureIndices[0].start;if(!(T>=d)&&(d=T,f=j.captureIndices,h=j.ruleId,p=v.priority,d===s))break}return f?{priorityMatch:p===-1,captureIndices:f,matchedRuleId:h}:null}function KE(e,t,n,r,s){return{ruleScanner:e.compileAG(t,n,r,s),findOptions:0}}function vz(e,t,n,r,s){return{ruleScanner:e.compileWhileAG(t,n,r,s),findOptions:0}}function xc(e,t,n,r,s,a,l){if(a.length===0)return;const d=t.content,f=Math.min(a.length,l.length),h=[],p=l[0].end;for(let g=0;g<f;g++){const _=a[g];if(_===null)continue;const x=l[g];if(x.length===0)continue;if(x.start>p)break;for(;h.length>0&&h[h.length-1].endPos<=x.start;)s.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?s.produceFromScopes(h[h.length-1].scopes,x.start):s.produce(r,x.start),_.retokenizeCapturedWithRuleId){const S=_.getName(d,l),w=r.contentNameScopesList.pushAttributed(S,e),k=_.getContentName(d,l),j=w.pushAttributed(k,e),T=r.push(_.retokenizeCapturedWithRuleId,x.start,-1,!1,null,w,j),A=e.createOnigString(d.substring(0,x.end));qE(e,A,n&&x.start===0,x.start,T,s,!1,0),FE(A);continue}const v=_.getName(d,l);if(v!==null){const w=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(v,e);h.push(new bz(w,x.end))}}for(;h.length>0;)s.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var bz=class{constructor(e,t){ce(this,"scopes");ce(this,"endPos");this.scopes=e,this.endPos=t}};function Sz(e,t,n,r,s,a,l,d){return new Cz(e,t,n,r,s,a,l,d)}function Iw(e,t,n,r,s){const a=fh(t,gh),l=WE.getCompiledRuleId(n,r,s.repository);for(const d of a)e.push({debugSelector:t,matcher:d.matcher,ruleId:l,grammar:s,priority:d.priority})}function gh(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let s=n;s<t.length;s++)if(wz(t[s],r))return n=s+1,!0;return!1})}function wz(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 Cz=class{constructor(e,t,n,r,s,a,l,d){ce(this,"_rootId");ce(this,"_lastRuleId");ce(this,"_ruleId2desc");ce(this,"_includedGrammars");ce(this,"_grammarRepository");ce(this,"_grammar");ce(this,"_injections");ce(this,"_basicScopeAttributesProvider");ce(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=d,this._basicScopeAttributesProvider=new mz(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=l,this._grammar=Pw(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const f of Object.keys(s)){const h=fh(f,gh);for(const p of h)this._tokenTypeMatchers.push({matcher:p.matcher,type:s[f]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const s=r.injections;if(s)for(let l in s)Iw(t,l,s[l],this,r);const a=this._grammarRepository.injections(n);a&&a.forEach(l=>{const d=this.getExternalGrammar(l);if(d){const f=d.injectionSelector;f&&Iw(t,f,d,this,d)}})}return t.sort((s,a)=>s.priority-a.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Pw(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=WE.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!t||t===O_.NULL){s=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),g=Go.set(0,h.languageId,h.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),_=this.getRule(this._rootId).getName(null,null);let x;_?x=Cc.createRootAndLookUpScopeName(_,g,this):x=Cc.createRoot("unknown",g),t=new O_(null,this._rootId,-1,-1,!1,null,x,x)}else s=!1,t.reset();e=e+`
142
- `;const a=this.createOnigString(e),l=a.content.length,d=new Ez(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),f=qE(this,a,s,0,t,d,!0,r);return FE(a),{lineLength:l,lineTokens:d,ruleStack:f.stack,stoppedEarly:f.stoppedEarly}}};function Pw(e,t){return e=U8(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 Cc=class us{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,s=(t==null?void 0:t.scopePath)??null;for(const a of n)s=dg.push(s,a.scopeNames),r=new us(r,s,a.encodedTokenAttributes);return r}static createRoot(t,n){return new us(null,new dg(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const s=r.getMetadataForScope(t),a=new dg(null,t),l=r.themeProvider.themeMatch(a),d=us.mergeAttributes(n,s,l);return new us(null,a,d)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return us.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 s=-1,a=0,l=0;return r!==null&&(s=r.fontStyle,a=r.foregroundId,l=r.backgroundId),Go.set(t,n.languageId,n.tokenType,null,s,a,l)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return us._pushAttributed(this,t,n);const r=t.split(/ /g);let s=this;for(const a of r)s=us._pushAttributed(s,a,n);return s}static _pushAttributed(t,n,r){const s=r.getMetadataForScope(n),a=t.scopePath.push(n),l=r.themeProvider.themeMatch(a),d=us.mergeAttributes(t.tokenAttributes,s,l);return new us(t,a,d)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var s;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((s=r.parent)==null?void 0:s.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},Mr,O_=(Mr=class{constructor(t,n,r,s,a,l,d,f){ce(this,"_stackElementBrand");ce(this,"_enterPos");ce(this,"_anchorPos");ce(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=a,this.endRule=l,this.nameScopesList=d,this.contentNameScopesList=f,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}equals(t){return t===null?!1:Mr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Cc.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){Mr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,s,a,l,d){return new Mr(this,t,n,r,s,a,l,d)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var r,s;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(s=this.contentNameScopesList)==null?void 0:s.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new Mr(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){var t,n,r;return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:((n=this.nameScopesList)==null?void 0:n.getExtensionIfDefined(((t=this.parent)==null?void 0:t.nameScopesList)??null))??[],contentNameScopesList:((r=this.contentNameScopesList)==null?void 0:r.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(t,n){const r=Cc.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new Mr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Cc.fromExtension(r,n.contentNameScopesList))}},ce(Mr,"NULL",new Mr(null,0,0,0,!1,null,null,null)),Mr),kz=class{constructor(e,t){ce(this,"balancedBracketScopes");ce(this,"unbalancedBracketScopes");ce(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):fh(n,gh).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>fh(n,gh).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}},Ez=class{constructor(e,t,n,r){ce(this,"_emitBinaryTokens");ce(this,"_lineText");ce(this,"_tokens");ce(this,"_binaryTokens");ce(this,"_lastTokenEndIndex");ce(this,"_tokenTypeOverrides");this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var r;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let s=(e==null?void 0:e.tokenAttributes)??0,a=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(a=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const l=(e==null?void 0:e.getScopeNames())??[];for(const d of this._tokenTypeOverrides)d.matcher(l)&&(s=Go.set(s,0,d.type,null,-1,0,0));this.balancedBracketSelectors&&(a=this.balancedBracketSelectors.match(l))}if(a&&(s=Go.set(s,0,8,a,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===s){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(s),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,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},Nz=class{constructor(e,t){ce(this,"_grammars",new Map);ce(this,"_rawGrammars",new Map);ce(this,"_injectionGrammars",new Map);ce(this,"_theme");this._onigLib=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,s){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,Sz(e,a,t,n,r,s,this,this._onigLib))}return this._grammars.get(e)}},jz=class{constructor(t){ce(this,"_options");ce(this,"_syncRegistry");ce(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new Nz(hh.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(hh.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 kz(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,s,a){const l=new rz(this._syncRegistry,t);for(;l.Q.length>0;)l.Q.map(d=>this._loadSingleGrammar(d.scopeName)),l.processQueue();return this._grammarForScopeName(t,n,r,s,a)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,s=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,s)}_grammarForScopeName(t,n=0,r=null,s=null,a=null){return this._syncRegistry.grammarForScopeName(t,n,r,s,a)}},I_=O_.NULL;function _h(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[s,a]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof a=="string"?n[s]=a:s===r&&Object.assign(n,a);return n}function Pi(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function Tz(e){return Array.isArray(e)?e:[e]}async function YE(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Yh(e){return!e||["plaintext","txt","text","plain"].includes(e)}function XE(e){return e==="ansi"||Yh(e)}function Xh(e){return e==="none"}function QE(e){return Xh(e)}const Az=/(\r?\n)/g;function Qh(e,t=!1){var a;if(e.length===0)return[["",0]];const n=e.split(Az);let r=0;const s=[];for(let l=0;l<n.length;l+=2){const d=t?n[l]+(n[l+1]||""):n[l];s.push([d,r]),r+=n[l].length,r+=((a=n[l+1])==null?void 0:a.length)||0}return s}const Bw={light:"#333333",dark:"#bbbbbb"},zw={light:"#fffffe",dark:"#1e1e1e"},$w="__shiki_resolved";function Vx(e){var d,f,h,p,g;if(e!=null&&e[$w])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 _=t.settings?t.settings.find(x=>!x.name&&!x.scope):void 0;(d=_==null?void 0:_.settings)!=null&&d.foreground&&(r=_.settings.foreground),(f=_==null?void 0:_.settings)!=null&&f.background&&(n=_.settings.background),!r&&((h=t==null?void 0:t.colors)!=null&&h["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Bw.light:Bw.dark),n||(n=t.type==="light"?zw.light:zw.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 s=0;const a=new Map;function l(_){var v;if(a.has(_))return a.get(_);s+=1;const x=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return(v=t.colorReplacements)!=null&&v[`#${x}`]?l(_):(a.set(_,x),x)}t.settings=t.settings.map(_=>{var w,k;const x=((w=_.settings)==null?void 0:w.foreground)&&!_.settings.foreground.startsWith("#"),v=((k=_.settings)==null?void 0:k.background)&&!_.settings.background.startsWith("#");if(!x&&!v)return _;const S={..._,settings:{..._.settings}};if(x){const j=l(_.settings.foreground);t.colorReplacements[j]=_.settings.foreground,S.settings.foreground=j}if(v){const j=l(_.settings.background);t.colorReplacements[j]=_.settings.background,S.settings.background=j}return S});for(const _ of Object.keys(t.colors||{}))if((_==="editor.foreground"||_==="editor.background"||_.startsWith("terminal.ansi"))&&!((g=t.colors[_])!=null&&g.startsWith("#"))){const x=l(t.colors[_]);t.colorReplacements[x]=t.colors[_],t.colors[_]=x}return Object.defineProperty(t,$w,{enumerable:!1,writable:!1,value:!0}),t}async function JE(e){return[...new Set((await Promise.all(e.filter(t=>!XE(t)).map(async t=>await YE(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function ZE(e){return(await Promise.all(e.map(async t=>QE(t)?null:Vx(await YE(t))))).filter(t=>!!t)}function eN(e,t){if(!t)return e;if(t[e]){const n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Dt(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Dz=class extends jz{constructor(t,n,r,s={}){super(t);ce(this,"_resolver");ce(this,"_themes");ce(this,"_langs");ce(this,"_alias");ce(this,"_resolvedThemes",new Map);ce(this,"_resolvedGrammars",new Map);ce(this,"_langMap",new Map);ce(this,"_langGraph",new Map);ce(this,"_textmateThemeCache",new WeakMap);ce(this,"_loadedThemesCache",null);ce(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=s,this._themes.map(a=>this.loadTheme(a)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Vx(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=hh.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=eN(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var a,l,d,f;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(h=>{var p;return(p=h.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const s=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(s.name=t.name,this._resolvedGrammars.set(t.name,s),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(l=(a=this._syncRegistry)==null?void 0:a._injectionGrammars)==null||l.delete(h.scopeName),(f=(d=this._syncRegistry)==null?void 0:d._grammars)==null||f.delete(h.scopeName),this.loadLanguage(this._langMap.get(h.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const s of t)this.resolveEmbeddedLanguages(s);const n=[...this._langGraph.entries()],r=n.filter(([s,a])=>!a);if(r.length){const s=n.filter(([a,l])=>{var d;return l?(d=l.embeddedLanguages||l.embeddedLangs)==null?void 0:d.some(f=>r.map(([h])=>h).includes(f)):!1}).filter(a=>!r.includes(a));throw new Dt(`Missing languages ${r.map(([a])=>`\`${a}\``).join(", ")}, required by ${s.map(([a])=>`\`${a}\``).join(", ")}`)}for(const[s,a]of n)this._resolver.addLanguage(a);for(const[s,a]of n)this.loadLanguage(a)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const n=t.embeddedLanguages??t.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}},Lz=class{constructor(e,t){ce(this,"_langs",new Map);ce(this,"_scopeToLang",new Map);ce(this,"_injections",new Map);ce(this,"_onigLib");this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const s=t.slice(0,r).join(".");n=[...n,...this._injections.get(s)||[]]}return n}};let oc=0;function Rz(e){oc+=1,e.warnings!==!1&&oc>=10&&oc%10===0&&console.warn(`[Shiki] ${oc} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Dt("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Vx),s=new Dz(new Lz(e.engine,n),r,n,e.langAlias);let a;function l(j){return eN(j,e.langAlias)}function d(j){w();const T=s.getGrammar(typeof j=="string"?j:j.name);if(!T)throw new Dt(`Language \`${j}\` not found, you may need to load it first`);return T}function f(j){if(j==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};w();const T=s.getTheme(j);if(!T)throw new Dt(`Theme \`${j}\` not found, you may need to load it first`);return T}function h(j){w();const T=f(j);return a!==j&&(s.setTheme(T),a=j),{theme:T,colorMap:s.getColorMap()}}function p(){return w(),s.getLoadedThemes()}function g(){return w(),s.getLoadedLanguages()}function _(...j){w(),s.loadLanguages(j.flat(1))}async function x(...j){return _(await JE(j))}function v(...j){w();for(const T of j.flat(1))s.loadTheme(T)}async function S(...j){return w(),v(await ZE(j))}function w(){if(t)throw new Dt("Shiki instance has been disposed")}function k(){t||(t=!0,s.dispose(),oc-=1)}return{setTheme:h,getTheme:f,getLanguage:d,getLoadedThemes:p,getLoadedLanguages:g,resolveLangAlias:l,loadLanguage:x,loadLanguageSync:_,loadTheme:S,loadThemeSync:v,dispose:k,[Symbol.dispose]:k}}async function Mz(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([ZE(e.themes||[]),JE(e.langs||[]),e.engine]);return Rz({...e,themes:t,langs:n,engine:r})}const tN=new WeakMap;function Jh(e,t){tN.set(e,t)}function Ic(e){return tN.get(e)}var Zh=class nN{constructor(...t){ce(this,"_stacks",{});ce(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,s]=t;this.lang=r,this._stacks={[s]: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 nN(Object.fromEntries(Tz(n).map(r=>[r,I_])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Oz(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Oz(e){const t=[],n=new Set;function r(s){var l;if(n.has(s))return;n.add(s);const a=(l=s==null?void 0:s.nameScopesList)==null?void 0:l.scopeName;a&&t.push(a),s.parent&&r(s.parent)}return r(e),t}function Iz(e,t){if(!(e instanceof Zh))throw new Dt("Invalid grammar state");return e.getInternalStack(t)}const Pz=/,/,Bz=/ /;function rN(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Yh(e.resolveLangAlias(n.lang||"text"))||Xh(r))return Qh(t).map(d=>[{content:d[0],offset:d[1]}]);const{theme:s,colorMap:a}=e.setTheme(r),l=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==l.name)throw new Dt(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${l.name}"`);if(!n.grammarState.themes.includes(s.name))throw new Dt(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return $z(t,l,s,a,n)}function zz(...e){if(e.length===2)return Ic(e[1]);const[t,n,r={}]=e,{lang:s="text",theme:a=t.getLoadedThemes()[0]}=r;if(Yh(s)||Xh(a))throw new Dt("Plain language does not have grammar state");if(s==="ansi")throw new Dt("ANSI language does not have grammar state");const{theme:l,colorMap:d}=t.setTheme(a),f=t.getLanguage(s);return new Zh(Wx(n,f,l,d,r).stateStack,f.name,l.name)}function $z(e,t,n,r,s){const a=Wx(e,t,n,r,s),l=new Zh(a.stateStack,t.name,n.name);return Jh(a.tokens,l),a.tokens}function Wx(e,t,n,r,s){const a=_h(n,s),{tokenizeMaxLineLength:l=0,tokenizeTimeLimit:d=500}=s,f=Qh(e);let h=s.grammarState?Iz(s.grammarState,n.name)??I_:s.grammarContextCode!=null?Wx(s.grammarContextCode,t,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:I_,p=[];const g=[];for(let _=0,x=f.length;_<x;_++){const[v,S]=f[_];if(v===""){p=[],g.push([]);continue}if(l>0&&v.length>=l){p=[],g.push([{content:v,offset:S,color:"",fontStyle:0}]);continue}let w,k,j;s.includeExplanation&&(w=t.tokenizeLine(v,h,d),k=w.tokens,j=0);const T=t.tokenizeLine2(v,h,d),A=T.tokens.length/2;for(let P=0;P<A;P++){const R=T.tokens[2*P],q=P+1<A?T.tokens[2*P+2]:v.length;if(R===q)continue;const J=T.tokens[2*P+1],ne=Pi(r[Go.getForeground(J)],a),I=Go.getFontStyle(J),W={content:v.substring(R,q),offset:S+R,color:ne,fontStyle:I};if(s.includeExplanation){const z=[];if(s.includeExplanation!=="scopeName")for(const U of n.settings){let D;switch(typeof U.scope){case"string":D=U.scope.split(Pz).map(N=>N.trim());break;case"object":D=U.scope;break;default:continue}z.push({settings:U,selectors:D.map(N=>N.split(Bz))})}W.explanation=[];let L=0;for(;R+L<q;){const U=k[j],D=v.substring(U.startIndex,U.endIndex);L+=D.length,W.explanation.push({content:D,scopes:s.includeExplanation==="scopeName"?Hz(U.scopes):Fz(z,U.scopes)}),j+=1}}p.push(W)}g.push(p),p=[],h=T.ruleStack}return{tokens:g,stateStack:h}}function Hz(e){return e.map(t=>({scopeName:t}))}function Fz(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const a=t[r];n[r]={scopeName:a,themeMatches:Vz(e,a,t.slice(0,r))}}return n}function Hw(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Uz(e,t,n){if(!Hw(e.at(-1),t))return!1;let r=e.length-2,s=n.length-1;for(;r>=0&&s>=0;)Hw(e[r],n[s])&&(r-=1),s-=1;return r===-1}function Vz(e,t,n){const r=[];for(const{selectors:s,settings:a}of e)for(const l of s)if(Uz(l,t,n)){r.push(a);break}return r}function sN(e,t,n,r=rN){const s=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),a=s.map(h=>{const p=r(e,t,{...n,theme:h.theme});return{tokens:p,state:Ic(p),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),l=Wz(...a.map(h=>h.tokens)),d=l[0].map((h,p)=>h.map((g,_)=>{const x={content:g.content,variants:{},offset:g.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=g.explanation),l.forEach((v,S)=>{const{content:w,explanation:k,offset:j,...T}=v[p][_];x.variants[s[S].color]=T}),x})),f=a[0].state?new Zh(Object.fromEntries(a.map(h=>{var p;return[h.theme,(p=h.state)==null?void 0:p.getInternalStack(h.theme)]})),a[0].state.lang):void 0;return f&&Jh(d,f),d}function Wz(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const s=e.map(f=>f[r]),a=t.map(()=>[]);t.forEach((f,h)=>f.push(a[h]));const l=s.map(()=>0),d=s.map(f=>f[0]);for(;d.every(f=>f);){const f=Math.min(...d.map(h=>h.content.length));for(let h=0;h<n;h++){const p=d[h];p.content.length===f?(a[h].push(p),l[h]+=1,d[h]=s[h][l[h]]):(a[h].push({...p,content:p.content.slice(0,f)}),d[h]={...p,content:p.content.slice(f),offset:p.offset+f})}}}return t}const Gz=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],qz=/["&'<>`]/g,Kz=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Yz=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Xz=/[|\\{}()[\]^$+*?.]/g,Fw=new WeakMap;function Qz(e,t){if(e=e.replace(t.subset?Jz(t.subset):qz,r),t.subset||t.escapeOnly)return e;return e.replace(Kz,n).replace(Yz,r);function n(s,a,l){return t.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,l.charCodeAt(a+2),t)}function r(s,a,l){return t.format(s.charCodeAt(0),l.charCodeAt(a+1),t)}}function Jz(e){let t=Fw.get(e);return t||(t=Zz(e),Fw.set(e,t)),t}function Zz(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(Xz,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const e$=/[\dA-Fa-f]/;function t$(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!e$.test(String.fromCharCode(t))?r:r+";"}const n$=/\d/;function r$(e,t,n){const r="&#"+String(e);return n&&t&&!n$.test(String.fromCharCode(t))?r:r+";"}const s$=["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"],fg={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},i$=["cent","copy","divide","gt","lt","not","para","times"],iN={}.hasOwnProperty,P_={};let Rd;for(Rd in fg)iN.call(fg,Rd)&&(P_[fg[Rd]]=Rd);const a$=/[^\dA-Za-z]/;function o$(e,t,n,r){const s=String.fromCharCode(e);if(iN.call(P_,s)){const a=P_[s],l="&"+a;return n&&s$.includes(a)&&!i$.includes(a)&&(!r||t&&t!==61&&a$.test(String.fromCharCode(t)))?l:l+";"}return""}function l$(e,t,n){let r=t$(e,t,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=o$(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const a=r$(e,t,n.omitOptionalSemicolons);a.length<r.length&&(r=a)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function Uo(e,t){return Qz(e,Object.assign({format:l$},t))}const c$=/^>|^->|<!--|-->|--!>|<!-$/g,u$=[">"],d$=["<",">"];function h$(e,t,n,r){return r.settings.bogusComments?"<?"+Uo(e.value,Object.assign({},r.settings.characterReferences,{subset:u$}))+">":"<!--"+e.value.replace(c$,s)+"-->";function s(a){return Uo(a,Object.assign({},r.settings.characterReferences,{subset:d$}))}}function f$(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const xn=oN(1),aN=oN(-1),m$=[];function oN(e){return t;function t(n,r,s){const a=n?n.children:m$;let l=(r||0)+e,d=a[l];if(!s)for(;d&&$h(d);)l+=e,d=a[l];return d}}const p$={}.hasOwnProperty;function lN(e){return t;function t(n,r,s){return p$.call(e,n.tagName)&&e[n.tagName](n,r,s)}}const Gx=lN({body:_$,caption:mg,colgroup:mg,dd:b$,dt:v$,head:mg,html:g$,li:y$,optgroup:S$,option:w$,p:x$,rp:Uw,rt:Uw,tbody:k$,td:Vw,tfoot:E$,th:Vw,thead:C$,tr:N$});function mg(e,t,n){const r=xn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&$h(r.value.charAt(0)))}function g$(e,t,n){const r=xn(n,t);return!r||r.type!=="comment"}function _$(e,t,n){const r=xn(n,t);return!r||r.type!=="comment"}function x$(e,t,n){const r=xn(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function y$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function v$(e,t,n){const r=xn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function b$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Uw(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function S$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function w$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function C$(e,t,n){const r=xn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function k$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function E$(e,t,n){return!xn(n,t)}function N$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Vw(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const j$=lN({body:D$,colgroup:L$,head:A$,html:T$,tbody:R$});function T$(e){const t=xn(e,-1);return!t||t.type!=="comment"}function A$(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 D$(e){const t=xn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&$h(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function L$(e,t,n){const r=aN(n,t),s=xn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Gx(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function R$(e,t,n){const r=aN(n,t),s=xn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Gx(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const Md={name:[[`
143
- \f\r &/=>`.split(""),`
144
- \f\r "&'/=>\``.split("")],[`\0
145
- \f\r "&'/<=>`.split(""),`\0
146
- \f\r "&'/<=>\``.split("")]],unquoted:[[`
147
- \f\r &>`.split(""),`\0
148
- \f\r "&'<=>\``.split("")],[`\0
149
- \f\r "&'<=>\``.split(""),`\0
150
- \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function M$(e,t,n,r){const s=r.schema,a=s.space==="svg"?!1:r.settings.omitOptionalTags;let l=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const d=[];let f;s.space==="html"&&e.tagName==="svg"&&(r.schema=Xc);const h=O$(r,e.properties),p=r.all(s.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=s,p&&(l=!1),(h||!a||!j$(e,t,n))&&(d.push("<",e.tagName,h?" "+h:""),l&&(s.space==="svg"||r.settings.closeSelfClosing)&&(f=h.charAt(h.length-1),(!r.settings.tightSelfClosing||f==="/"||f&&f!=='"'&&f!=="'")&&d.push(" "),d.push("/")),d.push(">")),d.push(p),!l&&(!a||!Gx(e,t,n))&&d.push("</"+e.tagName+">"),d.join("")}function O$(e,t){const n=[];let r=-1,s;if(t){for(s in t)if(t[s]!==null&&t[s]!==void 0){const a=I$(e,s,t[s]);a&&n.push(a)}}for(;++r<n.length;){const a=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&a!=='"'&&a!=="'"&&(n[r]+=" ")}return n.join("")}function I$(e,t,n){const r=T2(e.schema,t),s=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,a=e.settings.allowDangerousCharacters?0:1;let l=e.quote,d;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const f=Uo(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Md.name[s][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?b2:D2)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?f:(e.settings.preferUnquoted&&(d=Uo(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Md.unquoted[s][a]}))),d!==n&&(e.settings.quoteSmart&&uh(n,l)>uh(n,e.alternative)&&(l=e.alternative),d=l+Uo(n,Object.assign({},e.settings.characterReferences,{subset:(l==="'"?Md.single:Md.double)[s][a],attribute:!0}))+l),f+(d&&"="+d))}const P$=["<","&"];function cN(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Uo(e.value,Object.assign({},r.settings.characterReferences,{subset:P$}))}function B$(e,t,n,r){return r.settings.allowDangerousHtml?e.value:cN(e,t,n,r)}function z$(e,t,n,r){return r.all(e)}const $$=Y6("type",{invalid:H$,unknown:F$,handlers:{comment:h$,doctype:f$,element:M$,raw:B$,root:z$,text:cN}});function H$(e){throw new Error("Expected node, not `"+e+"`")}function F$(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const U$={},V$={},W$=[];function G$(e,t){const n=t||U$,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:q$,all:K$,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||Gz,characterReferences:n.characterReferences||V$,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Xc:A2,quote:r,alternative:s}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function q$(e,t,n){return $$(e,t,n,this)}function K$(e){const t=[],n=e&&e.children||W$;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const Ww=/\s+/g;function uN(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(Ww)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(Ww);for(const s of n)s&&!e.properties.class.includes(s)&&e.properties.class.push(s);return e}const Y$=/:?lang=["']([^"']+)["']/g,X$=/(?:```|~~~)([\w-]+)/g,Q$=/\\begin\{([\w-]+)\}/g,J$=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function Z$(e){const t=Qh(e,!0).map(([s])=>s);function n(s){if(s===e.length)return{line:t.length-1,character:t.at(-1).length};let a=s,l=0;for(const d of t){if(a<d.length)break;a-=d.length,l++}return{line:l,character:a}}function r(s,a){let l=0;for(let d=0;d<s;d++)l+=t[d].length;return l+=a,l}return{lines:t,indexToPos:n,posToIndex:r}}function e7(e,t,n){const r=new Set;for(const a of e.matchAll(Y$)){const l=a[1].toLowerCase().trim();l&&r.add(l)}for(const a of e.matchAll(X$)){const l=a[1].toLowerCase().trim();l&&r.add(l)}for(const a of e.matchAll(Q$)){const l=a[1].toLowerCase().trim();l&&r.add(l)}for(const a of e.matchAll(J$)){const l=a[1].toLowerCase().trim(),d=l.includes("/")?l.split("/").pop():l;d&&r.add(d)}if(!n)return[...r];const s=n.getBundledLanguages();return[...r].filter(a=>a&&s[a])}const t7=["color","background-color"];function n7(e,t){let n=0;const r=[];for(const s of t)s>n&&r.push({...e,content:e.content.slice(n,s),offset:e.offset+n}),n=s;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function r7(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,s)=>r-s);return n.length?e.map(r=>r.flatMap(s=>{const a=n.filter(l=>s.offset<l&&l<s.offset+s.content.length).map(l=>l-s.offset).sort((l,d)=>l-d);return a.length?n7(s,a):s})):e}function s7(e,t,n,r,s="css-vars"){const a={content:e.content,explanation:e.explanation,offset:e.offset},l=t.map(p=>xh(e.variants[p])),d=new Set(l.flatMap(p=>Object.keys(p))),f={},h=(p,g)=>{const _=g==="color"?"":g==="background-color"?"-bg":`-${g}`;return n+t[p]+(g==="color"?"":_)};return l.forEach((p,g)=>{for(const _ of d){const x=p[_]||"inherit";if(g===0&&r&&t7.includes(_))if(r==="light-dark()"&&l.length>1){const v=t.findIndex(w=>w==="light"),S=t.findIndex(w=>w==="dark");if(v===-1||S===-1)throw new Dt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');f[_]=`light-dark(${l[v][_]||"inherit"}, ${l[S][_]||"inherit"})`,s==="css-vars"&&(f[h(g,_)]=x)}else f[_]=x;else s==="css-vars"&&(f[h(g,_)]=x)}}),a.htmlStyle=f,a}function xh(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&zn.Italic&&(t["font-style"]="italic"),e.fontStyle&zn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&zn.Underline&&n.push("underline"),e.fontStyle&zn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function B_(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function i7(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let a=function(d){if(typeof d=="number"){if(d<0||d>n.source.length)throw new Dt(`Invalid decoration offset: ${d}. Code length: ${n.source.length}`);return{...s.indexToPos(d),offset:d}}else{const f=s.lines[d.line];if(f===void 0)throw new Dt(`Invalid decoration position ${JSON.stringify(d)}. Lines length: ${s.lines.length}`);let h=d.character;if(h<0&&(h=f.length+h),h<0||h>f.length)throw new Dt(`Invalid decoration position ${JSON.stringify(d)}. Line ${d.line} length: ${f.length}`);return{...d,character:h,offset:s.posToIndex(d.line,h)}}};var r=a;const s=Z$(n.source),l=(n.options.decorations||[]).map(d=>({...d,start:a(d.start),end:a(d.end)}));a7(l),e.set(n.meta,{decorations:l,converter:s,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 r7(n,t(this).decorations.flatMap(s=>[s.start.offset,s.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),s=[...n.children].filter(g=>g.type==="element"&&g.tagName==="span");if(s.length!==r.converter.lines.length)throw new Dt(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function a(g,_,x,v){const S=s[g];let w="",k=-1,j=-1;if(_===0&&(k=0),x===0&&(j=0),x===Number.POSITIVE_INFINITY&&(j=S.children.length),k===-1||j===-1)for(let A=0;A<S.children.length;A++)w+=dN(S.children[A]),k===-1&&w.length===_&&(k=A+1),j===-1&&w.length===x&&(j=A+1);if(k===-1)throw new Dt(`Failed to find start index for decoration ${JSON.stringify(v.start)}`);if(j===-1)throw new Dt(`Failed to find end index for decoration ${JSON.stringify(v.end)}`);const T=S.children.slice(k,j);if(!v.alwaysWrap&&T.length===S.children.length)d(S,v,"line");else if(!v.alwaysWrap&&T.length===1&&T[0].type==="element")d(T[0],v,"token");else{const A={type:"element",tagName:"span",properties:{},children:T};d(A,v,"wrapper"),S.children.splice(k,T.length,A)}}function l(g,_){s[g]=d(s[g],_,"line")}function d(g,_,x){var w;const v=_.properties||{},S=_.transform||(k=>k);return g.tagName=_.tagName||"span",g.properties={...g.properties,...v,class:g.properties.class},(w=_.properties)!=null&&w.class&&uN(g,_.properties.class),g=S(g,x)||g,g}const f=[],h=r.decorations.sort((g,_)=>_.start.offset-g.start.offset||g.end.offset-_.end.offset);for(const g of h){const{start:_,end:x}=g;if(_.line===x.line)a(_.line,_.character,x.character,g);else if(_.line<x.line){a(_.line,_.character,Number.POSITIVE_INFINITY,g);for(let v=_.line+1;v<x.line;v++)f.unshift(()=>l(v,g));a(x.line,0,x.character,g)}}f.forEach(g=>g())}}}function a7(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Dt(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const s=e[r],a=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,l=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,d=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,f=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(a||l||d||f){if(a&&l||d&&f||d&&n.start.offset===n.end.offset||l&&s.start.offset===s.end.offset)continue;throw new Dt(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function dN(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(dN).join(""):""}const o7=[i7()];function yh(e){const t=l7(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...o7]}function l7(e){const t=[],n=[],r=[];for(const s of e)switch(s.enforce){case"pre":t.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:t,post:n,normal:r}}var ba=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],pg={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function c7(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 Gw(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 u7(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)pg[r]&&t.push({type:"setDecoration",value:pg[r]});else if(r<=29){const s=pg[r-20];s&&(t.push({type:"resetDecoration",value:s}),s==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:ba[r-30]}});else if(r===38){const s=Gw(e);s&&t.push({type:"setForegroundColor",value:s})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:ba[r-40]}});else if(r===48){const s=Gw(e);s&&t.push({type:"setBackgroundColor",value:s})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:ba[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:ba[r-100+8]}})}return t}function d7(){let e=null,t=null,n=new Set;return{parse(r){const s=[];let a=0;do{const l=c7(r,a),d=l.sequence?r.substring(a,l.startPosition):r.substring(a);if(d.length>0&&s.push({value:d,foreground:e,background:t,decorations:new Set(n)}),l.sequence){const f=u7(l.sequence);for(const h of f)h.type==="resetAll"?(e=null,t=null,n.clear()):h.type==="resetForegroundColor"?e=null:h.type==="resetBackgroundColor"?t=null:h.type==="resetDecoration"&&n.delete(h.value);for(const h of f)h.type==="setForegroundColor"?e=h.value:h.type==="setBackgroundColor"?t=h.value:h.type==="setDecoration"&&n.add(h.value)}a=l.position}while(a<r.length);return s}}}var h7={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 f7(e=h7){function t(d){return e[d]}function n(d){return`#${d.map(f=>Math.max(0,Math.min(f,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let h=0;h<ba.length;h++)r.push(t(ba[h]));let d=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let p=0;p<6;p++)for(let g=0;g<6;g++)r.push(n([d[h],d[p],d[g]]));let f=8;for(let h=0;h<24;h++,f+=10)r.push(n([f,f,f]));return r}function a(d){return s()[d]}function l(d){switch(d.type){case"named":return t(d.name);case"rgb":return n(d.rgb);case"table":return a(d.index)}}return{value:l}}const m7=/#([0-9a-f]{3,8})/i,p7=/var\((--[\w-]+-ansi-[\w-]+)\)/,g7={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 _7(e,t,n){const r=_h(e,n),s=Qh(t),a=f7(Object.fromEntries(ba.map(d=>{var h;const f=`terminal.ansi${d[0].toUpperCase()}${d.substring(1)}`;return[d,((h=e.colors)==null?void 0:h[f])||g7[d]]}))),l=d7();return s.map(d=>l.parse(d[0]).map(f=>{let h,p;f.decorations.has("reverse")?(h=f.background?a.value(f.background):e.bg,p=f.foreground?a.value(f.foreground):e.fg):(h=f.foreground?a.value(f.foreground):e.fg,p=f.background?a.value(f.background):void 0),h=Pi(h,r),p=Pi(p,r),f.decorations.has("dim")&&(h=x7(h));let g=zn.None;return f.decorations.has("bold")&&(g|=zn.Bold),f.decorations.has("italic")&&(g|=zn.Italic),f.decorations.has("underline")&&(g|=zn.Underline),f.decorations.has("strikethrough")&&(g|=zn.Strikethrough),{content:f.value,offset:d[1],color:h,bgColor:p,fontStyle:g}}))}function x7(e){const t=e.match(m7);if(t){const r=t[1];if(r.length===8){const s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const s=r[0],a=r[1],l=r[2],d=r[3];return`#${s}${s}${a}${a}${l}${l}${Math.round(Number.parseInt(`${d}${d}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const s=r[0],a=r[1],l=r[2];return`#${s}${s}${a}${a}${l}${l}80`}}}const n=e.match(p7);return n?`var(${n[1]}-dim)`:e}function z_(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:s=e.getLoadedThemes()[0]}=n;if(!Yh(r)&&!Xh(s)&&r==="ansi"){const{theme:a}=e.setTheme(s);return _7(a,t,n)}return rN(e,t,n)}function vh(e,t,n){let r,s,a,l,d,f;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:p="--shiki-",colorsRendering:g="css-vars"}=n,_=Object.entries(n.themes).filter(k=>k[1]).map(k=>({color:k[0],theme:k[1]})).sort((k,j)=>k.color===h?-1:j.color===h?1:0);if(_.length===0)throw new Dt("`themes` option must not be empty");const x=sN(e,t,n,z_);if(f=Ic(x),h&&h!=="light-dark()"&&!_.some(k=>k.color===h))throw new Dt(`\`themes\` option must contain the defaultColor key \`${h}\``);const v=_.map(k=>e.getTheme(k.theme)),S=_.map(k=>k.color);a=x.map(k=>k.map(j=>s7(j,S,p,h,g))),f&&Jh(a,f);const w=_.map(k=>_h(k.theme,n));s=qw(_,v,w,p,h,"fg",g),r=qw(_,v,w,p,h,"bg",g),l=`shiki-themes ${v.map(k=>k.name).join(" ")}`,d=h?void 0:[s,r].join(";")}else if("theme"in n){const h=_h(n.theme,n);a=z_(e,t,n);const p=e.getTheme(n.theme);r=Pi(p.bg,h),s=Pi(p.fg,h),l=p.name,f=Ic(a)}else throw new Dt("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:s,bg:r,themeName:l,rootStyle:d,grammarState:f}}function qw(e,t,n,r,s,a,l){return e.map((d,f)=>{const h=Pi(t[f][a],n[f])||"inherit",p=`${r+d.color}${a==="bg"?"-bg":""}:${h}`;if(f===0&&s){if(s==="light-dark()"&&e.length>1){const g=e.findIndex(x=>x.color==="light"),_=e.findIndex(x=>x.color==="dark");if(g===-1||_===-1)throw new Dt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Pi(t[g][a],n[g])||"inherit"}, ${Pi(t[_][a],n[_])||"inherit"});${p}`}return h}return l==="css-vars"?p:null}).filter(d=>!!d).join(";")}const hN=/^\s+$/,y7=/^(\s*)(.*?)(\s*)$/;function bh(e,t,n,r={meta:{},options:n,codeToHast:(s,a)=>bh(e,s,a),codeToTokens:(s,a)=>vh(e,s,a)}){var v,S;let s=t;for(const w of yh(n))s=((v=w.preprocess)==null?void 0:v.call(r,s,n))||s;let{tokens:a,fg:l,bg:d,themeName:f,rootStyle:h,grammarState:p}=vh(e,s,n);const{mergeWhitespaces:g=!0,mergeSameStyleTokens:_=!1}=n;g===!0?a=b7(a):g==="never"&&(a=S7(a)),_&&(a=w7(a));const x={...r,get source(){return s}};for(const w of yh(n))a=((S=w.tokens)==null?void 0:S.call(x,a))||a;return v7(a,{...n,fg:l,bg:d,themeName:f,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},x,p)}function v7(e,t,n,r=Ic(e)){var S,w,k,j;const s=yh(t),a=[],l={type:"root",children:[]},{structure:d="classic",tabindex:f="0"}=t,h={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?h.style=t.rootStyle:h.style=`background-color:${t.bg};color:${t.fg}`),f!==!1&&f!=null&&(h.tabindex=f.toString());for(const[T,A]of Object.entries(t.meta||{}))T.startsWith("_")||(h[T]=A);let p={type:"element",tagName:"pre",properties:h,children:[],data:t.data},g={type:"element",tagName:"code",properties:{},children:a};const _=[],x={...n,structure:d,addClassToHast:uN,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return l},get pre(){return p},get code(){return g},get lines(){return _}};if(e.forEach((T,A)=>{var q,J;A&&(d==="inline"?l.children.push({type:"element",tagName:"br",properties:{},children:[]}):d==="classic"&&a.push({type:"text",value:`
151
- `}));let P={type:"element",tagName:"span",properties:{class:"line"},children:[]},R=0;for(const ne of T){let I={type:"element",tagName:"span",properties:{...ne.htmlAttrs},children:[{type:"text",value:ne.content}]};const W=B_(ne.htmlStyle||xh(ne));W&&(I.properties.style=W);for(const z of s)I=((q=z==null?void 0:z.span)==null?void 0:q.call(x,I,A+1,R,P,ne))||I;d==="inline"?l.children.push(I):d==="classic"&&P.children.push(I),R+=ne.content.length}if(d==="classic"){for(const ne of s)P=((J=ne==null?void 0:ne.line)==null?void 0:J.call(x,P,A+1))||P;_.push(P),a.push(P)}else d==="inline"&&_.push(P)}),d==="classic"){for(const T of s)g=((S=T==null?void 0:T.code)==null?void 0:S.call(x,g))||g;p.children.push(g);for(const T of s)p=((w=T==null?void 0:T.pre)==null?void 0:w.call(x,p))||p;l.children.push(p)}else if(d==="inline"){const T=[];let A={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const R of l.children)R.type==="element"&&R.tagName==="br"?(T.push(A),A={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(R.type==="element"||R.type==="text")&&A.children.push(R);T.push(A);let P={type:"element",tagName:"code",properties:{},children:T};for(const R of s)P=((k=R==null?void 0:R.code)==null?void 0:k.call(x,P))||P;l.children=[];for(let R=0;R<P.children.length;R++){R>0&&l.children.push({type:"element",tagName:"br",properties:{},children:[]});const q=P.children[R];q.type==="element"&&l.children.push(...q.children)}}let v=l;for(const T of s)v=((j=T==null?void 0:T.root)==null?void 0:j.call(x,v))||v;return r&&Jh(v,r),v}function b7(e){return e.map(t=>{const n=[];let r="",s;return t.forEach((a,l)=>{const d=!(a.fontStyle&&(a.fontStyle&zn.Underline||a.fontStyle&zn.Strikethrough));d&&hN.test(a.content)&&t[l+1]?(s===void 0&&(s=a.offset),r+=a.content):r?(d?n.push({...a,offset:s,content:r+a.content}):n.push({content:r,offset:s},a),s=void 0,r=""):n.push(a)}),n})}function S7(e){return e.map(t=>t.flatMap(n=>{if(hN.test(n.content))return n;const r=n.content.match(y7);if(!r)return n;const[,s,a,l]=r;if(!s&&!l)return n;const d=[{...n,offset:n.offset+s.length,content:a}];return s&&d.unshift({content:s,offset:n.offset}),l&&d.push({content:l,offset:n.offset+s.length+a.length}),d}))}function w7(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const s=n.at(-1),a=B_(s.htmlStyle||xh(s)),l=B_(r.htmlStyle||xh(r)),d=s.fontStyle&&(s.fontStyle&zn.Underline||s.fontStyle&zn.Strikethrough),f=r.fontStyle&&(r.fontStyle&zn.Underline||r.fontStyle&zn.Strikethrough);!d&&!f&&a===l?s.content+=r.content:n.push({...r})}return n})}const C7=G$;function k7(e,t,n){var a;const r={meta:{},options:n,codeToHast:(l,d)=>bh(e,l,d),codeToTokens:(l,d)=>vh(e,l,d)};let s=C7(bh(e,t,n,r));for(const l of yh(n))s=((a=l.postprocess)==null?void 0:a.call(r,s,n))||s;return s}async function E7(e){const t=await Mz(e);return{getLastGrammarState:(...n)=>zz(t,...n),codeToTokensBase:(n,r)=>z_(t,n,r),codeToTokensWithThemes:(n,r)=>sN(t,n,r),codeToTokens:(n,r)=>vh(t,n,r),codeToHast:(n,r)=>bh(t,n,r),codeToHtml:(n,r)=>k7(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function N7(e){const t=e.langs,n=e.themes,r=e.engine;async function s(a){function l(g){var _;if(typeof g=="string"){if(g=((_=a.langAlias)==null?void 0:_[g])||g,XE(g))return[];const x=t[g];if(!x)throw new Dt(`Language \`${g}\` is not included in this bundle. You may want to load it from external source.`);return x}return g}function d(g){if(QE(g))return"none";if(typeof g=="string"){const _=n[g];if(!_)throw new Dt(`Theme \`${g}\` is not included in this bundle. You may want to load it from external source.`);return _}return g}const f=(a.themes??[]).map(g=>d(g)),h=(a.langs??[]).map(g=>l(g)),p=await E7({engine:a.engine??r(),...a,themes:f,langs:h});return{...p,loadLanguage(...g){return p.loadLanguage(...g.map(l))},loadTheme(...g){return p.loadTheme(...g.map(d))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return s}function j7(e){let t;async function n(r={}){if(t){const s=await t;return await Promise.all([s.loadTheme(...r.themes||[]),s.loadLanguage(...r.langs||[])]),s}else{t=e({...r,themes:[],langs:[]});const s=await t;return await Promise.all([s.loadTheme(...r.themes||[]),s.loadLanguage(...r.langs||[])]),s}}return n}function T7(e,t){const n=j7(e);async function r(s,a){var f;const l=await n({langs:[a.lang],themes:"theme"in a?[a.theme]:Object.values(a.themes)}),d=await((f=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:f.call(t,s,a.lang,l));return d&&await l.loadLanguage(...d),l}return{getSingletonHighlighter(s){return n(s)},async codeToHtml(s,a){return(await r(s,a)).codeToHtml(s,a)},async codeToHast(s,a){return(await r(s,a)).codeToHast(s,a)},async codeToTokens(s,a){return(await r(s,a)).codeToTokens(s,a)},async codeToTokensBase(s,a){return(await r(s,a)).codeToTokensBase(s,a)},async codeToTokensWithThemes(s,a){return(await r(s,a)).codeToTokensWithThemes(s,a)},async getLastGrammarState(s,a){return(await n({langs:[a.lang],themes:[a.theme]})).getLastGrammarState(s,a)}}}var A7=Ox({bundledLanguages:()=>Bx,bundledLanguagesAlias:()=>Px,bundledLanguagesBase:()=>Ix,bundledLanguagesInfo:()=>Gh,bundledThemes:()=>$x,bundledThemesInfo:()=>zx,codeToHast:()=>mN,codeToHtml:()=>fN,codeToTokens:()=>pN,codeToTokensBase:()=>gN,codeToTokensWithThemes:()=>_N,createHighlighter:()=>ef,getLastGrammarState:()=>yN,getSingletonHighlighter:()=>xN});const ef=N7({langs:Bx,themes:$x,engine:()=>(0,RE.createOnigurumaEngine)($(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:fN,codeToHast:mN,codeToTokens:pN,codeToTokensBase:gN,codeToTokensWithThemes:_N,getSingletonHighlighter:xN,getLastGrammarState:yN}=T7(ef,{guessEmbeddedLanguages:e7}),Kw=4294967295;var D7=class{constructor(e,t={}){ce(this,"patterns");ce(this,"options");ce(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:s}=t;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(a=>{if(typeof a!="string")return a;const l=r==null?void 0:r.get(a);if(l){if(l instanceof RegExp)return l;if(n)return null;throw l}try{const d=s(a);return r==null||r.set(a,d),d}catch(d){if(r==null||r.set(a,d),n)return null;throw d}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,s=[];function a(l,d,f=0){return{index:l,captureIndices:d.indices.map(h=>h==null?{start:Kw,end:Kw,length:0}:{start:h[0]+f,end:h[1]+f,length:h[1]-h[0]})}}for(let l=0;l<this.regexps.length;l++){const d=this.regexps[l];if(d)try{d.lastIndex=t;const f=d.exec(r);if(!f)continue;if(f.index===t)return a(l,f,0);s.push([l,f,0])}catch(f){if(this.options.forgiving)continue;throw f}}if(s.length){const l=Math.min(...s.map(d=>d[1].index));for(const[d,f,h]of s)if(f.index===l)return a(d,f,h)}return null}};function Zo(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function L7(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const qx=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),En=String.raw;function el(e,t){if(e==null)throw new Error(t??"Value expected");return e}const vN=En`\[\^?`,bN=`c.? | C(?:-.?)?|${En`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${En`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${En`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${En`o\{[^\}]*\}?`}|${En`\d{1,3}`}`,Kx=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Od=new RegExp(En`
152
- \\ (?:
153
- ${bN}
154
- | [gk]<[^>]*>?
155
- | [gk]'[^']*'?
156
- | .
157
- )
158
- | \( (?:
159
- \? (?:
160
- [:=!>({]
161
- | <[=!]
162
- | <[^>]*>
163
- | '[^']*'
164
- | ~\|?
165
- | #(?:[^)\\]|\\.?)*
166
- | [^:)]*[:)]
167
- )?
168
- | \*[^\)]*\)?
169
- )?
170
- | (?:${Kx.source})+
171
- | ${vN}
172
- | .
173
- `.replace(/\s+/g,""),"gsu"),gg=new RegExp(En`
174
- \\ (?:
175
- ${bN}
176
- | .
177
- )
178
- | \[:(?:\^?\p{Alpha}+|\^):\]
179
- | ${vN}
180
- | &&
181
- | .
182
- `.replace(/\s+/g,""),"gsu");function R7(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=J7(n.flags),s=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop()},pushModX(g){s.push(g)},replaceCurrentModX(g){s[s.length-1]=g},singleline:n.rules.singleline};let l=[],d;for(Od.lastIndex=0;d=Od.exec(e);){const g=M7(a,e,d[0],Od.lastIndex);g.tokens?l.push(...g.tokens):g.token&&l.push(g.token),g.lastIndex!==void 0&&(Od.lastIndex=g.lastIndex)}const f=[];let h=0;l.filter(g=>g.type==="GroupOpen").forEach(g=>{g.kind==="capturing"?g.number=++h:g.raw==="("&&f.push(g)}),h||f.forEach((g,_)=>{g.kind="capturing",g.number=_+1});const p=h||f.length;return{tokens:l.map(g=>g.type==="EscapedNumber"?e9(g,p):g).flat(),flags:r}}function M7(e,t,n,r){const[s,a]=n;if(n==="["||n==="[^"){const l=O7(t,n,r);return{tokens:l.tokens,lastIndex:l.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(a))return{token:Yw(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:W7(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:wN(n)}}if(a==="K")return{token:CN("keep",n)};if(a==="N"||a==="R")return{token:Sa("newline",n,{negate:a==="N"})};if(a==="O")return{token:Sa("any",n)};if(a==="X")return{token:Sa("text_segment",n)};const l=SN(n,{inCharClass:!1});return Array.isArray(l)?{tokens:l}:{token:l}}if(s==="("){if(a==="*")return{token:Y7(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:K7(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Bo("group",n)};if(n==="(?>")return{token:Bo("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Bo(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Bo("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Bo("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:F7(n)}}if(e.getCurrentModX()){if(n==="#"){const l=t.indexOf(`
183
- `,r);return{lastIndex:l===-1?t.length:l}}if(/^\s$/.test(n)){const l=/\s+/y;return l.lastIndex=r,{lastIndex:l.exec(t)?l.lastIndex:r}}}if(n===".")return{token:Sa("dot",n)};if(n==="^"||n==="$"){const l=e.singleline?{"^":En`\A`,$:En`\Z`}[n]:n;return{token:Yw(l,n)}}return n==="|"?{token:P7(n)}:Kx.test(n)?{tokens:t9(n)}:{token:qs(Zo(n),n)}}function O7(e,t,n){const r=[Xw(t[1]==="^",t)];let s=1,a;for(gg.lastIndex=n;a=gg.exec(e);){const l=a[0];if(l[0]==="["&&l[1]!==":")s++,r.push(Xw(l[1]==="^",l));else if(l==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(qs(93,l));else if(s--,r.push(B7(l)),!s)break}else{const d=I7(l);Array.isArray(d)?r.push(...d):r.push(d)}}return{tokens:r,lastIndex:gg.lastIndex||e.length}}function I7(e){if(e[0]==="\\")return SN(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!qx.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Sa("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?z7(e):e==="&&"?$7(e):qs(Zo(e),e)}function SN(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return q7(e);if("dDhHsSwW".includes(n))return X7(e);if(e.startsWith(En`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Q7(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(l=>parseInt(l,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),a=new TextEncoder;return[...s].map(l=>{const d=[...a.encode(l)].map(f=>`\\x${f.toString(16)}`).join("");return qs(Zo(l),d)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return qs(Z7(e),e);if(Qw.has(n))return qs(Qw.get(n),e);if(/\d/.test(n))return H7(t,e);if(e==="\\")throw new Error(En`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return qs(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function P7(e){return{type:"Alternator",raw:e}}function Yw(e,t){return{type:"Assertion",kind:e,raw:t}}function wN(e){return{type:"Backreference",raw:e}}function qs(e,t){return{type:"Character",value:e,raw:t}}function B7(e){return{type:"CharacterClassClose",raw:e}}function z7(e){return{type:"CharacterClassHyphen",raw:e}}function $7(e){return{type:"CharacterClassIntersector",raw:e}}function Xw(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Sa(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function CN(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:el(n.flags),raw:t}}function H7(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function F7(e){return{type:"GroupClose",raw:e}}function Bo(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function U7(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function V7(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function W7(e){return{type:"Subroutine",raw:e}}const G7=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Qw=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function q7(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 qs(Zo(t.toUpperCase())-64,e)}function K7(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const s=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),a=Zw(n),l=Zw(r),d={};if(a&&(d.enable=a),l&&(d.disable=l),e.endsWith(")"))return t.replaceCurrentModX(s),CN("flags",e,{flags:d});if(e.endsWith(":"))return t.pushModX(s),t.numOpenGroups++,Bo("group",e,{...(a||l)&&{flags:d}});throw new Error(`Unexpected flag modifier "${e}"`)}function Y7(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:s}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const a=s?s.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[l,d,f]=a,h=G7.has(n)?n.toLowerCase():"custom";switch(h){case"fail":case"mismatch":case"skip":if(a.length>0)throw new Error(`Named callout arguments not allowed "${a}"`);break;case"error":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(typeof l=="string")throw new Error(`Named callout argument must be a number "${l}"`);break;case"max":if(!a.length||a.length>2)throw new Error(`Named callout must have one or two arguments "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument one must be a tag or number "${l}"`);if(a.length===2&&(typeof d=="number"||!/^[<>X]$/.test(d)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${d}"`);break;case"count":case"total_count":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof l=="number"||!/^[<>X]$/.test(l)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${l}"`);break;case"cmp":if(a.length!==3)throw new Error(`Named callout must have three arguments "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument one must be a tag or number "${l}"`);if(typeof d=="number"||!/^(?:[<>!=]=|[<>])$/.test(d))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${d}"`);if(typeof f=="string"&&!/^[A-Za-z_]\w*$/.test(f))throw new Error(`Named callout argument three must be a tag or number "${f}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${h}"`)}return U7(h,r??null,(s==null?void 0:s.split(","))??null,e)}function Jw(e){let t=null,n,r;if(e[0]==="{"){const{minStr:s,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,l=1e5;if(+s>l||a&&+a>l)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+s,r=a===void 0?+s:a===""?1/0:+a,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return V7(t,n,r,e)}function X7(e){const t=e[1].toLowerCase();return Sa({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Q7(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Sa("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function Zw(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 J7(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 Z7(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 e9(e,t){const{raw:n,inCharClass:r}=e,s=n.slice(1);if(!r&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=t))return[wN(n)];const a=[],l=s.match(/^[0-7]+|\d/g);for(let d=0;d<l.length;d++){const f=l[d];let h;if(d===0&&f!=="8"&&f!=="9"){if(h=parseInt(f,8),h>127)throw new Error(En`Octal encoded byte above 177 unsupported "${n}"`)}else h=Zo(f);a.push(qs(h,(d===0?"\\":"")+f))}return a}function t9(e){const t=[],n=new RegExp(Kx,"gy");let r;for(;r=n.exec(e);){const s=r[0];if(s[0]==="{"){const a=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(a){const{min:l,max:d}=a.groups;if(+l>+d&&s.endsWith("?")){n.lastIndex--,t.push(Jw(s.slice(0,-1)));continue}}}t.push(Jw(s))}return t}function kN(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 n9(e){return r9.has(e.type)}const r9=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function EN(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=R7(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(_,x)=>{const v=r.tokens[a.nextIndex];switch(a.parent=_,a.nextIndex++,v.type){case"Alternator":return Da();case"Assertion":return s9(v);case"Backreference":return i9(v,a);case"Character":return tf(v.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return a9(v,a,x);case"CharacterClassOpen":return o9(v,a,x);case"CharacterSet":return l9(v,a);case"Directive":return m9(v.kind,{flags:v.flags});case"GroupOpen":return c9(v,a,x);case"NamedCallout":return g9(v.kind,v.tag,v.arguments);case"Quantifier":return u9(v,a);case"Subroutine":return d9(v,a);default:throw new Error(`Unexpected token type "${v.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},l=x9(p9(r.flags));let d=l.body[0];for(;a.nextIndex<r.tokens.length;){const _=s(d,{});_.type==="Alternative"?(l.body.push(_),d=_):d.body.push(_)}const{capturingGroups:f,hasNumberedRef:h,namedGroupsByName:p,subroutines:g}=a;if(h&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:_}of g)if(typeof _=="number"){if(_>f.length)throw new Error("Subroutine uses a group number that's not defined");_&&(f[_-1].isSubroutined=!0)}else if(p.has(_)){if(p.get(_).length>1)throw new Error(En`Subroutine uses a duplicate group name "\g<${_}>"`);p.get(_)[0].isSubroutined=!0}else throw new Error(En`Subroutine uses a group name that's not defined "\g<${_}>"`);return l}function s9({kind:e}){return $_(el({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===En`\B`||e===En`\Y`})}function i9({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),s=(a,l=!1)=>{const d=t.capturingGroups.length;let f=!1;if(a>d)if(t.skipBackrefValidation)f=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,H_(l?d+1-a:a,{orphan:f})};if(n){const a=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(a)return s(+a.groups.num,!!a.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return H_(r)}return s(+r)}function a9(e,t,n){const{tokens:r,walk:s}=t,a=t.parent,l=a.body.at(-1),d=r[t.nextIndex];if(!n.isCheckingRangeEnd&&l&&l.type!=="CharacterClass"&&l.type!=="CharacterClassRange"&&d&&d.type!=="CharacterClassOpen"&&d.type!=="CharacterClassClose"&&d.type!=="CharacterClassIntersector"){const f=s(a,{...n,isCheckingRangeEnd:!0});if(l.type==="Character"&&f.type==="Character")return a.body.pop(),f9(l,f);throw new Error("Invalid character class range")}return tf(Zo("-"))}function o9({negate:e},t,n){const{tokens:r,walk:s}=t,a=[Xd()],l=r[t.nextIndex];let d=nC(l);for(;d.type!=="CharacterClassClose";){if(d.type==="CharacterClassIntersector")a.push(Xd()),t.nextIndex++;else{const h=a.at(-1);h.body.push(s(h,n))}d=nC(r[t.nextIndex],l)}const f=Xd({negate:e});return a.length===1?f.body=a[0].body:(f.kind="intersection",f.body=a.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,f}function l9({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:a,unicodePropertyMap:l}=r;if(e==="property"){const d=nf(n);if(qx.has(d)&&!(l!=null&&l.has(d)))e="posix",n=d;else return zo(n,{negate:t,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:a,unicodePropertyMap:l})}return e==="posix"?_9(n,{negate:t}):F_(e,{negate:t})}function c9(e,t,n){const{tokens:r,capturingGroups:s,namedGroupsByName:a,skipLookbehindValidation:l,walk:d}=t,f=y9(e),h=f.type==="AbsenceFunction",p=tC(f),g=p&&f.negate;if(f.type==="CapturingGroup"&&(s.push(f),f.name&&L7(a,f.name,[]).push(f)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let _=rC(r[t.nextIndex]);for(;_.type!=="GroupClose";){if(_.type==="Alternator")f.body.push(Da()),t.nextIndex++;else{const x=f.body.at(-1),v=d(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||g});if(x.body.push(v),(p||n.isInLookbehind)&&!l){const S="Lookbehind includes a pattern not allowed by Oniguruma";if(g||n.isInNegLookbehind){if(eC(v)||v.type==="CapturingGroup")throw new Error(S)}else if(eC(v)||tC(v)&&v.negate)throw new Error(S)}}_=rC(r[t.nextIndex])}return t.nextIndex++,f}function u9({kind:e,min:t,max:n},r){const s=r.parent,a=s.body.at(-1);if(!a||!n9(a))throw new Error("Quantifier requires a repeatable token");const l=jN(e,t,n,a);return s.body.pop(),l}function d9({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let s=e.slice(3,-1);const a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(a){const d=+a.groups.num,f=n.length;if(t.hasNumberedRef=!0,s={"":d,"+":f+d,"-":f+1-d}[a.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const l=TN(s);return r.push(l),l}function h9(e,t){return{type:"AbsenceFunction",kind:e,body:eu(t==null?void 0:t.body)}}function Da(e){return{type:"Alternative",body:AN(e==null?void 0:e.body)}}function $_(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function H_(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function NN(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!v9(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:eu(t==null?void 0:t.body)}}function tf(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 Xd(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:AN(e==null?void 0:e.body)}}function f9(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function F_(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 m9(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:el(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function p9(e){return{type:"Flags",...e}}function Yr(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:eu(e==null?void 0:e.body)}}function xa(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:eu(e==null?void 0:e.body)}}function g9(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function _9(e,t){const n=!!(t!=null&&t.negate);if(!qx.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function jN(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 x9(e,t){return{type:"Regex",body:eu(t==null?void 0:t.body),flags:e}}function TN(e){return{type:"Subroutine",ref:e}}function zo(e,t){var s;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(s=n.unicodePropertyMap)==null?void 0:s.get(nf(e));if(!r){if(n.normalizeUnknownPropertyNames)r=b9(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(En`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function y9({flags:e,kind:t,name:n,negate:r,number:s}){switch(t){case"absence_repeater":return h9("repeater");case"atomic":return Yr({atomic:!0});case"capturing":return NN(s,{name:n});case"group":return Yr({flags:e});case"lookahead":case"lookbehind":return xa({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function eu(e){if(e===void 0)e=[Da()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function AN(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 eC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function tC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function v9(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function b9(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 nf(e){return e.replace(/[- _]+/g,"").toLowerCase()}function nC(e,t){const n=t;return el(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function rC(e){return el(e,"Unclosed group")}function kc(e,t,n=null){function r(a,l){for(let d=0;d<a.length;d++){const f=s(a[d],l,d,a);d=Math.max(-1,d+f)}}function s(a,l=null,d=null,f=null){var k,j;let h=0,p=!1;const g={node:a,parent:l,key:d,container:f,root:e,remove(){Id(f).splice(Math.max(0,Ao(d)+h),1),h--,p=!0},removeAllNextSiblings(){return Id(f).splice(Ao(d)+1)},removeAllPrevSiblings(){const T=Ao(d)+h;return h-=T,Id(f).splice(0,Math.max(0,T))},replaceWith(T,A={}){const P=!!A.traverse;f?f[Math.max(0,Ao(d)+h)]=T:el(l,"Can't replace root node")[d]=T,P&&s(T,l,d,f),p=!0},replaceWithMultiple(T,A={}){const P=!!A.traverse;if(Id(f).splice(Math.max(0,Ao(d)+h),1,...T),h+=T.length-1,P){let R=0;for(let q=0;q<T.length;q++)R+=s(T[q],l,Ao(d)+q+R,f)}p=!0},skip(){p=!0}},{type:_}=a,x=t["*"],v=t[_],S=typeof x=="function"?x:x==null?void 0:x.enter,w=typeof v=="function"?v:v==null?void 0:v.enter;if(S==null||S(g,n),w==null||w(g,n),!p)switch(_){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(a.body,a);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":s(a.min,a,"min"),s(a.max,a,"max");break;case"Quantifier":s(a.body,a,"body");break;case"Regex":r(a.body,a),s(a.flags,a,"flags");break;default:throw new Error(`Unexpected node type "${_}"`)}return(k=v==null?void 0:v.exit)==null||k.call(v,g,n),(j=x==null?void 0:x.exit)==null||j.call(x,g,n),h}return s(e),e}function Id(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Ao(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const S9=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function w9(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function C9(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const Ir=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Yx(e,t,n,r){const s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1];let l=0,d="";for(const f of e.matchAll(s)){const{0:h,groups:{$skip:p}}=f;if(!p&&(!r||r===Ir.DEFAULT==!l)){n instanceof Function?d+=n(f,{context:l?Ir.CHAR_CLASS:Ir.DEFAULT,negated:a[a.length-1]}):d+=n;continue}h[0]==="["?(l++,a.push(h[1]==="^")):h==="]"&&l&&(l--,a.pop()),d+=h}return d}function DN(e,t,n,r){Yx(e,t,n,r)}function k9(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let a=0,l;for(;l=s.exec(e);){const{0:d,groups:{$skip:f}}=l;if(!f&&(!r||r===Ir.DEFAULT==!a))return l;d==="["?a++:d==="]"&&a&&a--,s.lastIndex==l.index&&s.lastIndex++}return null}function Pd(e,t,n){return!!k9(e,t,0,n)}function E9(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,s=0,a=1,l;for(;l=n.exec(e);){const[d]=l;if(d==="[")s++;else if(s)d==="]"&&s--;else if(d==="(")a++;else if(d===")"&&(a--,!a)){r=l.index;break}}return e.slice(t,r)}const sC=new RegExp(String.raw`(?<noncapturingStart>${S9})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function N9(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 s="(?>",a="(?:(?=(",l=[0],d=[];let f=0,h=0,p=NaN,g;do{g=!1;let _=0,x=0,v=!1,S;for(sC.lastIndex=Number.isNaN(p)?0:p+a.length;S=sC.exec(e);){const{0:w,index:k,groups:{capturingStart:j,noncapturingStart:T}}=S;if(w==="[")_++;else if(_)w==="]"&&_--;else if(w===s&&!v)p=k,v=!0;else if(v&&T)x++;else if(j)v?x++:(f++,l.push(f+h));else if(w===")"&&v){if(!x){h++;const A=f+h;if(e=`${e.slice(0,p)}${a}${e.slice(p+s.length,k)}))<$$${A}>)${e.slice(k+1)}`,g=!0,d.push(A),w9(n,A),r.size){const P=new Map;r.forEach((R,q)=>{P.set(q>=A?q+1:q,R.map(J=>J>=A?J+1:J))}),r=P}break}x--}}}while(g);return n.push(...d),e=Yx(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:_,groups:{backrefNum:x,wrappedBackrefNum:v}})=>{if(x){const S=+x;if(S>l.length-1)throw new Error(`Backref "${_}" greater than number of captures`);return`\\${l[S]}`}return`\\${v}`},Ir.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const LN=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,_g=new RegExp(String.raw`
184
- \\(?: \d+
185
- | c[A-Za-z]
186
- | [gk]<[^>]+>
187
- | [pPu]\{[^\}]+\}
188
- | u[A-Fa-f\d]{4}
189
- | x[A-Fa-f\d]{2}
190
- )
191
- | \((?: \? (?: [:=!>]
192
- | <(?:[=!]|[^>]+>)
193
- | [A-Za-z\-]+:
194
- | \(DEFINE\)
195
- ))?
196
- | (?<qBase>${LN})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
197
- | \\?.
198
- `.replace(/\s+/g,""),"gsu");function j9(e){if(!new RegExp(`${LN}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,s="",a=0,l;for(_g.lastIndex=0;l=_g.exec(e);){const{0:d,index:f,groups:{qBase:h,qMod:p,invalidQ:g}}=l;if(d==="[")a||(r=f),a++;else if(d==="]")a?a--:r=null;else if(!a)if(p==="+"&&s&&!s.startsWith("(")){if(g)throw new Error(`Invalid quantifier "${d}"`);let _=-1;if(/^\{\d+\}$/.test(h))e=C9(e,f+h.length,p,"");else{if(s===")"||s==="]"){const x=s===")"?n:r;if(x===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,x)}(?>${e.slice(x,f)}${h})${e.slice(f+d.length)}`}else e=`${e.slice(0,f-s.length)}(?>${s}${h})${e.slice(f+d.length)}`;_+=4}_g.lastIndex+=_}else d[0]==="("?t.push(f):d===")"&&(n=t.length?t.pop():null);s=d}return{pattern:e}}const Or=String.raw,T9=Or`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,U_=Or`\(\?R=(?<rDepth>[^\)]+)\)|${T9}`,rf=Or`\(\?<(?![=!])(?<captureName>[^>]+)>`,RN=Or`${rf}|(?<unnamed>\()(?!\?)`,ca=new RegExp(Or`${rf}|${U_}|\(\?|\\?.`,"gsu"),xg="Cannot use multiple overlapping recursions";function A9(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let s=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(U_,"su").test(e))return{pattern:e,captureTransfers:s,hiddenCaptures:n};if(r==="plugin"&&Pd(e,Or`\(\?\(DEFINE\)`,Ir.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const a=[],l=Pd(e,Or`\\[1-9]`,Ir.DEFAULT),d=new Map,f=[];let h=!1,p=0,g=0,_;for(ca.lastIndex=0;_=ca.exec(e);){const{0:x,groups:{captureName:v,rDepth:S,gRNameOrNum:w,gRDepth:k}}=_;if(x==="[")p++;else if(p)x==="]"&&p--;else if(S){if(iC(S),h)throw new Error(xg);if(l)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const j=e.slice(0,_.index),T=e.slice(ca.lastIndex);if(Pd(T,U_,Ir.DEFAULT))throw new Error(xg);const A=+S-1;e=aC(j,T,A,!1,n,a,g),s=lC(s,j,A,a.length,0,g);break}else if(w){iC(k);let j=!1;for(const z of f)if(z.name===w||z.num===+w){if(j=!0,z.hasRecursedWithin)throw new Error(xg);break}if(!j)throw new Error(Or`Recursive \g cannot be used outside the referenced group "${r==="external"?w:Or`\g<${w}&R=${k}>`}"`);const T=d.get(w),A=E9(e,T);if(l&&Pd(A,Or`${rf}|\((?!\?)`,Ir.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const P=e.slice(T,_.index),R=A.slice(P.length+x.length),q=a.length,J=+k-1,ne=aC(P,R,J,!0,n,a,g);s=lC(s,P,J,a.length-q,q,g);const I=e.slice(0,T),W=e.slice(T+A.length);e=`${I}${ne}${W}`,ca.lastIndex+=ne.length-x.length-P.length-R.length,f.forEach(z=>z.hasRecursedWithin=!0),h=!0}else if(v)g++,d.set(String(g),ca.lastIndex),d.set(v,ca.lastIndex),f.push({num:g,name:v});else if(x[0]==="("){const j=x==="(";j&&(g++,d.set(String(g),ca.lastIndex)),f.push(j?{num:g}:{})}else x===")"&&f.pop()}return n.push(...a),{pattern:e,captureTransfers:s,hiddenCaptures:n}}function iC(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function aC(e,t,n,r,s,a,l){const d=new Set;r&&DN(e+t,rf,({groups:{captureName:h}})=>{d.add(h)},Ir.DEFAULT);const f=[n,r?d:null,s,a,l];return`${e}${oC(`(?:${e}`,"forward",...f)}(?:)${oC(`${t})`,"backward",...f)}${t}`}function oC(e,t,n,r,s,a,l){const f=p=>t==="forward"?p+2:n-p+2-1;let h="";for(let p=0;p<n;p++){const g=f(p);h+=Yx(e,Or`${RN}|\\k<(?<backref>[^>]+)>`,({0:_,groups:{captureName:x,unnamed:v,backref:S}})=>{if(S&&r&&!r.has(S))return _;const w=`_$${g}`;if(v||x){const k=l+a.length+1;return a.push(k),D9(s,k),v?_:`(?<${x}${w}>`}return Or`\k<${S}${w}>`},Ir.DEFAULT)}return h}function D9(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function lC(e,t,n,r,s,a){if(e.size&&r){let l=0;DN(t,RN,()=>l++,Ir.DEFAULT);const d=a-l+s,f=new Map;return e.forEach((h,p)=>{const g=(r-l*n)/n,_=l*n,x=p>d+l?p+r:p,v=[];for(const S of h)if(S<=d)v.push(S);else if(S>d+l+g)v.push(S+r);else if(S<=d+l)for(let w=0;w<=n;w++)v.push(S+l*w);else for(let w=0;w<=n;w++)v.push(S+_+g*w);f.set(x,v)}),f}return e}var gn=String.fromCodePoint,Ge=String.raw,Qr={},sf=globalThis.RegExp;Qr.flagGroups=(()=>{try{new sf("(?i:)")}catch{return!1}return!0})();Qr.unicodeSets=(()=>{try{new sf("[[]]","v")}catch{return!1}return!0})();Qr.bugFlagVLiteralHyphenIsRange=Qr.unicodeSets?(()=>{try{new sf(Ge`[\d\-a]`,"v")}catch{return!0}return!1})():!1;Qr.bugNestedClassIgnoresNegation=Qr.unicodeSets&&new sf("[[^a]]","v").test("a");function Sh(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 Pc(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function V_(e,t){return cC[e]>=cC[t]}function L9(e,t){if(e==null)throw new Error(t??"Value expected");return e}var cC={ES2025:2025,ES2024:2024,ES2018:2018},R9={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function MN(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!R9[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=Qr.flagGroups?"ES2025":Qr.unicodeSets?"ES2024":"ES2018"),t}var M9="[ -\r ]",O9=new Set([gn(304),gn(305)]),zs=Ge`[\p{L}\p{M}\p{N}\p{Pc}]`;function ON(e){if(O9.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),s=B9.get(n),a=I9.get(n),l=P9.get(n);return[...r].length===1&&t.add(r),l&&t.add(l),s&&t.add(s),t.add(n),a&&t.add(a),[...t]}var Xx=new Map(`C Other
199
- Cc Control cntrl
200
- Cf Format
201
- Cn Unassigned
202
- Co Private_Use
203
- Cs Surrogate
204
- L Letter
205
- LC Cased_Letter
206
- Ll Lowercase_Letter
207
- Lm Modifier_Letter
208
- Lo Other_Letter
209
- Lt Titlecase_Letter
210
- Lu Uppercase_Letter
211
- M Mark Combining_Mark
212
- Mc Spacing_Mark
213
- Me Enclosing_Mark
214
- Mn Nonspacing_Mark
215
- N Number
216
- Nd Decimal_Number digit
217
- Nl Letter_Number
218
- No Other_Number
219
- P Punctuation punct
220
- Pc Connector_Punctuation
221
- Pd Dash_Punctuation
222
- Pe Close_Punctuation
223
- Pf Final_Punctuation
224
- Pi Initial_Punctuation
225
- Po Other_Punctuation
226
- Ps Open_Punctuation
227
- S Symbol
228
- Sc Currency_Symbol
229
- Sk Modifier_Symbol
230
- Sm Math_Symbol
231
- So Other_Symbol
232
- Z Separator
233
- Zl Line_Separator
234
- Zp Paragraph_Separator
235
- Zs Space_Separator
236
- ASCII
237
- ASCII_Hex_Digit AHex
238
- Alphabetic Alpha
239
- Any
240
- Assigned
241
- Bidi_Control Bidi_C
242
- Bidi_Mirrored Bidi_M
243
- Case_Ignorable CI
244
- Cased
245
- Changes_When_Casefolded CWCF
246
- Changes_When_Casemapped CWCM
247
- Changes_When_Lowercased CWL
248
- Changes_When_NFKC_Casefolded CWKCF
249
- Changes_When_Titlecased CWT
250
- Changes_When_Uppercased CWU
251
- Dash
252
- Default_Ignorable_Code_Point DI
253
- Deprecated Dep
254
- Diacritic Dia
255
- Emoji
256
- Emoji_Component EComp
257
- Emoji_Modifier EMod
258
- Emoji_Modifier_Base EBase
259
- Emoji_Presentation EPres
260
- Extended_Pictographic ExtPict
261
- Extender Ext
262
- Grapheme_Base Gr_Base
263
- Grapheme_Extend Gr_Ext
264
- Hex_Digit Hex
265
- IDS_Binary_Operator IDSB
266
- IDS_Trinary_Operator IDST
267
- ID_Continue IDC
268
- ID_Start IDS
269
- Ideographic Ideo
270
- Join_Control Join_C
271
- Logical_Order_Exception LOE
272
- Lowercase Lower
273
- Math
274
- Noncharacter_Code_Point NChar
275
- Pattern_Syntax Pat_Syn
276
- Pattern_White_Space Pat_WS
277
- Quotation_Mark QMark
278
- Radical
279
- Regional_Indicator RI
280
- Sentence_Terminal STerm
281
- Soft_Dotted SD
282
- Terminal_Punctuation Term
283
- Unified_Ideograph UIdeo
284
- Uppercase Upper
285
- Variation_Selector VS
286
- White_Space space
287
- XID_Continue XIDC
288
- XID_Start XIDS`.split(/\s/).map(e=>[nf(e),e])),I9=new Map([["s",gn(383)],[gn(383),"s"]]),P9=new Map([[gn(223),gn(7838)],[gn(107),gn(8490)],[gn(229),gn(8491)],[gn(969),gn(8486)]]),B9=new Map([Ni(453),Ni(456),Ni(459),Ni(498),...yg(8072,8079),...yg(8088,8095),...yg(8104,8111),Ni(8124),Ni(8140),Ni(8188)]),z9=new Map([["alnum",Ge`[\p{Alpha}\p{Nd}]`],["alpha",Ge`\p{Alpha}`],["ascii",Ge`\p{ASCII}`],["blank",Ge`[\p{Zs}\t]`],["cntrl",Ge`\p{Cc}`],["digit",Ge`\p{Nd}`],["graph",Ge`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",Ge`\p{Lower}`],["print",Ge`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",Ge`[\p{P}\p{S}]`],["space",Ge`\p{space}`],["upper",Ge`\p{Upper}`],["word",Ge`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",Ge`\p{AHex}`]]);function $9(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Ni(e){const t=gn(e);return[t.toLowerCase(),t]}function yg(e,t){return $9(e,t).map(n=>Ni(n))}var IN=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function H9(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};PN(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:V_(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};kc(e,F9,r);const s={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:s,prevFlags:null,globalFlags:s,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};kc(e,U9,a);const l={groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer};return kc(e,V9,l),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var F9={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:s}=e;if(s==="repeater"){const a=Yr();a.body[0].body.push(xa({negate:!0,body:r}),zo("Any"));const l=Yr();l.body[0].body.push(jN("greedy",0,1/0,a)),n(en(l,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const s=e.body.filter(a=>a.kind==="flags");for(let a=n+1;a<t.body.length;a++){const l=t.body[a];Pc(r,l,[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=zN(t.get(e));if(r){const s=Yr({flags:r});s.body[0].body=e.body,e.body=[en(s,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:s,remove:a,replaceWith:l},d){const{kind:f,negate:h}=e,{asciiWordBoundaries:p,avoidSubclass:g,supportedGNodes:_,wordIsAscii:x}=d;if(f==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(f==="line_end")l(en(xa({body:[Da({body:[$_("string_end")]}),Da({body:[tf(10)]})]}),t));else if(f==="line_start")l(en($s(Ge`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(f==="search_start")if(_.has(e))s.flags.sticky=!0,a();else{const v=r[n-1];if(v&&X9(v))l(en(xa({negate:!0}),t));else{if(g)throw new Error(Ge`Uses "\G" in a way that requires a subclass`);l(ji($_("string_start"),t)),d.strategy="clip_search"}}else if(!(f==="string_end"||f==="string_start"))if(f==="string_end_newline")l(en($s(Ge`(?=\n?\z)`),t));else if(f==="word_boundary"){if(!x&&!p){const v=`(?:(?<=${zs})(?!${zs})|(?<!${zs})(?=${zs}))`,S=`(?:(?<=${zs})(?=${zs})|(?<!${zs})(?!${zs}))`;l(en($s(h?S:v),t))}}else throw new Error(`Unexpected assertion kind "${f}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!bg(n)&&(n=vg(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!bg(r)&&(r=vg(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=Xd({body:[e]});n(en(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:a,spaceIsAscii:l,wordIsAscii:d}){const{kind:f,negate:h,value:p}=e;if(a&&(f==="digit"||p==="digit")){n(ji(F_("digit",{negate:h}),t));return}if(l&&(f==="space"||p==="space")){n(en(Sg($s(M9),h),t));return}if(d&&(f==="word"||p==="word")){n(ji(F_("word",{negate:h}),t));return}if(f==="any")n(ji(zo("Any"),t));else if(f==="digit")n(ji(zo("Nd",{negate:h}),t));else if(f!=="dot")if(f==="text_segment"){if(r==="strict")throw new Error(Ge`Use of "\X" requires non-strict accuracy`);const g="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",_=Ge`\p{RI}{2}|${g}(?:\u200D${g})*`;n(en($s(Ge`(?>\r\n|${s?Ge`\p{RGI_Emoji}`:_}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(f==="hex")n(ji(zo("AHex",{negate:h}),t));else if(f==="newline")n(en($s(h?`[^
289
- ]`:`(?>\r
290
- ?|[
291
- \v\f…\u2028\u2029])`),t));else if(f==="posix")if(!s&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let g={graph:"!-~",print:" -~"}[p];h&&(g=`\0-${gn(g.codePointAt(0)-1)}${gn(g.codePointAt(2)+1)}-􏿿`),n(en($s(`[${g}]`),t))}else n(en(Sg($s(z9.get(p)),h),t));else if(f==="property")Xx.has(nf(p))||(e.key="sc");else if(f==="space")n(ji(zo("space",{negate:h}),t));else if(f==="word")n(en(Sg($s(zs),h),t));else throw new Error(`Unexpected character set kind "${f}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:a,removeAllNextSiblings:l}){const{kind:d,flags:f}=e;if(d==="flags")if(!f.enable&&!f.disable)r();else{const h=Yr({flags:f});h.body[0].body=l(),s(en(h,t),{traverse:!0})}else if(d==="keep"){const h=n.body[0],g=n.body.length===1&&kN(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==g||g.body.length>1)throw new Error(Ge`Uses "\K" in a way that's unsupported`);const _=xa({behind:!0});_.body[0].body=a(),s(en(_,t))}else throw new Error(`Unexpected directive kind "${d}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(en(xa({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=Yr();t.body[0].body.push(e.body),e.body=en(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,s=!1;for(const a of e.body)if(a.body.length===1&&a.body[0].kind==="search_start")a.body.pop();else{const l=HN(a.body);l?(r=!0,Array.isArray(l)?n.push(...l):n.push(l)):s=!0}r&&!s&&n.forEach(a=>t.add(a))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(Ge`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!bg(n)&&(n=vg(n,t),e.ref=n)}},U9={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=e;r||n.set(e,[...t.get(s).map(({node:a})=>a)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:a,multiplexCapturesToLeftByRef:l,openRefs:d,reffedNodesByReferencer:f}){const h=s.get(e);if(h&&d.has(e.number)){const g=ji(uC(e.number),t);f.set(g,d.get(e.number)),n(g);return}d.set(e.number,e),l.set(e.number,[]),e.name&&Pc(l,e.name,[]);const p=l.get(e.name??e.number);for(let g=0;g<p.length;g++){const _=p[g];if(h===_.node||h&&h===_.origin||e===_.origin){p.splice(g,1);break}}if(l.get(e.number).push({node:e,origin:h}),e.name&&l.get(e.name).push({node:e,origin:h}),e.name){const g=Pc(a,e.name,new Map);let _=!1;if(h)_=!0;else for(const x of g.values())if(!x.hasDuplicateNameToRemove){_=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:_})}},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=Sh(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:s,ref:a}=e;if(s){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===a||p.number===a)););r.reffedNodesByReferencer.set(e,p);return}const l=r.subroutineRefMap.get(a),d=a===0,f=d?uC(0):BN(l,r.groupOriginByCopy,null);let h=f;if(!d){const p=zN(q9(l,_=>_.type==="Group"&&!!_.flags)),g=p?Sh(r.globalFlags,p):r.globalFlags;W9(g,r.currentFlags)||(h=Yr({flags:K9(g)}),h.body[0].body.push(f))}n(en(h,t),{traverse:!d})}},V9={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const a=r.reffedNodesByReferencer.get(e).filter(l=>G9(l,e));if(!a.length)n(en(xa({negate:!0}),t));else if(a.length>1){const l=Yr({atomic:!0,body:a.reverse().map(d=>Da({body:[H_(d.number)]}))});n(en(l,t))}else e.ref=a[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=NN();e.body.at(-1).body.push(s)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function PN(e){kc(e,{"*"({node:t,parent:n}){t.parent=n}})}function W9(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function G9(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=$N(n.parent);for(const s of r){if(s===n)break;if(s===e||FN(s,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function BN(e,t,n,r){const s=Array.isArray(e)?[]:{};for(const[a,l]of Object.entries(e))a==="parent"?s.parent=Array.isArray(n)?r:n:l&&typeof l=="object"?s[a]=BN(l,t,s,n):(a==="type"&&l==="CapturingGroup"&&t.set(s,t.get(e)??e),s[a]=l);return s}function uC(e){const t=TN(e);return t.isRecursive=!0,t}function q9(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function vg(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 zN(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(s=>{var a,l;(a=r.enable)!=null&&a[s]&&(delete n.disable[s],n.enable[s]=!0),(l=r.disable)!=null&&l[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function K9({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 $N(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function HN(e){const t=e.find(n=>n.kind==="search_start"||Q9(n,{negate:!1})||!Y9(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 s=HN(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function FN(e,t){const n=$N(e)??[];for(const r of n)if(r===t||FN(r,t))return!0;return!1}function Y9({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function X9(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function Q9(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&kN(e.body[0],{type:"Assertion",kind:"search_start"})}function bg(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function $s(e,t){const r=EN(e,{...t,unicodePropertyMap:Xx}).body;return r.length>1||r[0].body.length>1?Yr({body:r}):r[0].body[0]}function Sg(e,t){return e.negate=t,e}function ji(e,t){return e.parent=t,e}function en(e,t){return PN(e),e.parent=t,e}function J9(e,t){const n=MN(t),r=V_(n.target,"ES2024"),s=V_(n.target,"ES2025"),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw new Error("Invalid recursionLimit; use 2-20");let l=null,d=null;if(!s){const x=[e.flags.ignoreCase];kc(e,Z9,{getCurrentModI:()=>x.at(-1),popModI(){x.pop()},pushModI(v){x.push(v)},setHasCasedChar(){x.at(-1)?l=!0:d=!0}})}const f={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||l)&&!d)};let h=e;const p={accuracy:n.accuracy,appliedGlobalFlags:f,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:h,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!s&&l&&d),useFlagMods:s,useFlagV:r,verbose:n.verbose};function g(x){return p.lastNode=h,h=x,L9(eH[x.type],`Unexpected node type "${x.type}"`)(x,p,g)}const _={pattern:e.body.map(g).join("|"),flags:g(e.flags),options:{...e.options}};return r||(delete _.options.force.v,_.options.disable.v=!0,_.options.unicodeSetsPlugin=null),_._captureTransfers=new Map,_._hiddenCaptures=[],p.captureMap.forEach((x,v)=>{x.hidden&&_._hiddenCaptures.push(v),x.transferTo&&Pc(_._captureTransfers,x.transferTo,[]).push(v)}),_}var Z9={"*":{enter({node:e},t){if(hC(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Sh({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){hC(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Qx(gn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),UN(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&IN.has(e.value)&&t.setHasCasedChar()}},eH={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?Ge`\B`:Ge`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:s,number:a}=e,l={ignoreCase:t.currentFlags.ignoreCase},d=t.originMap.get(e);return d&&(l.hidden=!0,a>d.number&&(l.transferTo=d.number)),t.captureMap.set(a,l),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=gn(e),r=Do(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Qx(n)){const s=ON(n);return t.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:s,parent:a}=e;let{body:l}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Qr.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&l.some(fC)&&(l=[tf(45),...l.filter(h=>!fC(h))]);const d=()=>`[${s?"^":""}${l.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Qr.bugNestedClassIgnoresNegation)&&!s){const p=l.filter(g=>g.type==="CharacterClass"&&g.kind==="union"&&g.negate);if(p.length){const g=Yr(),_=g.body[0];return g.parent=a,_.parent=g,l=l.filter(x=>!p.includes(x)),e.body=l,l.length?(e.parent=_,_.body.push(e)):g.body.pop(),p.forEach(x=>{const v=Da({body:[x]});x.parent=v,v.parent=g,g.body.push(v)}),n(g)}}t.inCharClass=!0;const h=d();return t.inCharClass=!1,h}const f=l[0];if(r==="union"&&!s&&f&&((!t.useFlagV||!t.verbose)&&a.kind==="union"&&!(Qr.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind==="intersection"&&l.length===1&&f.type!=="CharacterClassRange"))return l.map(n).join("");if(!t.useFlagV&&a.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return d()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=Do(n,s),l=Do(r,s),d=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const f=UN(e);iH(f).forEach(p=>{d.add(Array.isArray(p)?`${Do(p[0],s)}-${Do(p[1],s)}`:Do(p,s))})}return`${a}-${l}${[...d].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},s){if(e==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":Ge`[^\n]`;if(e==="digit")return t?Ge`\D`:Ge`\d`;if(e==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&IN.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Ge`\P`:Ge`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?Ge`\W`:Ge`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},s,a){const l=s.currentFlags;n&&(s.currentFlags=Sh(l,n));const d=t.map(a).join("|"),f=!s.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!s.useFlagMods||!n)?d:`(?${aH(e,n,s.useFlagMods)}${d})`;return s.currentFlags=l,f},LookaroundAssertion({body:e,kind:t,negate:n},r,s){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(s).join("|")})`},Quantifier(e,t,n){return n(e.body)+oH(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return t===0?`(?R=${r})`:Ge`\g<${t}&R=${r}>`}},tH=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),nH=new Set(["-","\\","]","^","["]),rH=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),dC=new Map([[9,Ge`\t`],[10,Ge`\n`],[11,Ge`\v`],[12,Ge`\f`],[13,Ge`\r`],[8232,Ge`\u2028`],[8233,Ge`\u2029`],[65279,Ge`\uFEFF`]]),sH=new RegExp("^\\p{Cased}$","u");function Qx(e){return sH.test(e)}function UN(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,s=e.max.value,a=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return a;for(let l=r;l<=s;l++){const d=gn(l);if(!Qx(d))continue;const f=ON(d).filter(h=>{const p=h.codePointAt(0);return p<r||p>s});if(f.length&&(a.push(...f),n))break}return a}function Do(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(dC.has(e))return dC.get(e);if(e<32||e>126&&e<160||e>262143||t&&lH(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?rH:nH:tH,a=gn(e);return(s.has(a)?"\\":"")+a}function iH(e){const t=e.map(s=>s.codePointAt(0)).sort((s,a)=>s-a),n=[];let r=null;for(let s=0;s<t.length;s++)t[s+1]===t[s]+1?r??(r=t[s]):r===null?n.push(t[s]):(n.push([r,t[s]]),r=null);return n}function aH(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:s,disable:a}=t;r=(s!=null&&s.ignoreCase?"i":"")+(s!=null&&s.dotAll?"s":"")+(a?"-":"")+(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")}return`${r}:`}function oH({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 hC({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function lH(e){return e>47&&e<58}function fC({type:e,value:t}){return e==="Character"&&t===45}var Ai,Vs,wa,Di,Ca,Bc,W_,Bi,cH=(Bi=class extends RegExp{constructor(n,r,s){var t=(...EG)=>(super(...EG),aa(this,Bc),aa(this,Ai,new Map),aa(this,Vs,null),aa(this,wa),aa(this,Di,null),aa(this,Ca,null),ce(this,"rawOptions",{}),this);const a=!!(s!=null&&s.lazyCompile);if(n instanceof RegExp){if(s)throw new Error("Cannot provide options when copying a regexp");const l=n;t(l,r),Vr(this,wa,l.source),l instanceof Bi&&(Vr(this,Ai,Un(l,Ai)),Vr(this,Di,Un(l,Di)),Vr(this,Ca,Un(l,Ca)),this.rawOptions=l.rawOptions)}else{const l={hiddenCaptures:[],strategy:null,transfers:[],...s};t(a?"":n,r),Vr(this,wa,n),Vr(this,Ai,dH(l.hiddenCaptures,l.transfers)),Vr(this,Ca,l.strategy),this.rawOptions=s??{}}a||Vr(this,Vs,this)}get source(){return Un(this,wa)||"(?:)"}exec(n){if(!Un(this,Vs)){const{lazyCompile:a,...l}=this.rawOptions;Vr(this,Vs,new Bi(Un(this,wa),this.flags,l))}const r=this.global||this.sticky,s=this.lastIndex;if(Un(this,Ca)==="clip_search"&&r&&s){this.lastIndex=0;const a=_p(this,Bc,W_).call(this,n.slice(s));return a&&(uH(a,s,n,this.hasIndices),this.lastIndex+=s),a}return _p(this,Bc,W_).call(this,n)}},Ai=new WeakMap,Vs=new WeakMap,wa=new WeakMap,Di=new WeakMap,Ca=new WeakMap,Bc=new WeakSet,W_=function(n){Un(this,Vs).lastIndex=this.lastIndex;const r=q0(Bi.prototype,this,"exec").call(Un(this,Vs),n);if(this.lastIndex=Un(this,Vs).lastIndex,!r||!Un(this,Ai).size)return r;const s=[...r];r.length=1;let a;this.hasIndices&&(a=[...r.indices],r.indices.length=1);const l=[0];for(let d=1;d<s.length;d++){const{hidden:f,transferTo:h}=Un(this,Ai).get(d)??{};if(f?l.push(null):(l.push(r.length),r.push(s[d]),this.hasIndices&&r.indices.push(a[d])),h&&s[d]!==void 0){const p=l[h];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=s[d],this.hasIndices&&(r.indices[p]=a[d]),r.groups){Un(this,Di)||Vr(this,Di,hH(this.source));const g=Un(this,Di).get(h);g&&(r.groups[g]=s[d],this.hasIndices&&(r.indices.groups[g]=a[d]))}}}return r},Bi);function uH(e,t,n,r){if(e.index+=t,e.input=n,r){const s=e.indices;for(let l=0;l<s.length;l++){const d=s[l];d&&(s[l]=[d[0]+t,d[1]+t])}const a=s.groups;a&&Object.keys(a).forEach(l=>{const d=a[l];d&&(a[l]=[d[0]+t,d[1]+t])})}}function dH(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,s]of t)for(const a of s)Pc(n,a,{}).transferTo=r;return n}function hH(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,s=0,a;for(;a=t.exec(e);){const{0:l,groups:{capture:d,name:f}}=a;l==="["?r++:r?l==="]"&&r--:d&&(s++,f&&n.set(s,f))}return n}function fH(e,t){const n=mH(e,t);return n.options?new cH(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function mH(e,t){const n=MN(t),r=EN(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Xx}),s=H9(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),a=J9(s,n),l=A9(a.pattern,{captureTransfers:a._captureTransfers,hiddenCaptures:a._hiddenCaptures,mode:"external"}),d=j9(l.pattern),f=N9(d.pattern,{captureTransfers:l.captureTransfers,hiddenCaptures:l.hiddenCaptures}),h={pattern:f.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${a.flags}${a.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=f.hiddenCaptures.sort((v,S)=>v-S),g=Array.from(f.captureTransfers),_=s._strategy,x=h.pattern.length>=n.lazyCompileLength;(p.length||g.length||_||x)&&(h.options={...p.length&&{hiddenCaptures:p},...g.length&&{transfers:g},..._&&{strategy:_},...x&&{lazyCompile:x}})}return h}function VN(e,t){return fH(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function pH(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>VN(n,{target:t.target})),{createScanner(n){return new D7(n,t)},createString(n){return{content:n}}}}TE(Ox({bundledLanguages:()=>Bx,bundledLanguagesAlias:()=>Px,bundledLanguagesBase:()=>Ix,bundledLanguagesInfo:()=>Gh,bundledThemes:()=>$x,bundledThemesInfo:()=>zx,codeToHast:()=>mN,codeToHtml:()=>fN,codeToTokens:()=>pN,codeToTokensBase:()=>gN,codeToTokensWithThemes:()=>_N,createHighlighter:()=>ef,createJavaScriptRegexEngine:()=>pH,createOnigurumaEngine:()=>LE,defaultJavaScriptRegexConstructor:()=>VN,getLastGrammarState:()=>yN,getSingletonHighlighter:()=>xN,loadWasm:()=>Fx}),A7);let wg=null;const gH=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],_H=["github-dark-default","vitesse-light","monokai","dracula","nord"],xH={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord"};function yH(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function vH(){return wg||(wg=ef({themes:_H,langs:gH})),wg}const lc=new Map,bH=50;function SH(e,t,n){return`${e}|${t}|${n}`}async function WN(e,t,n="github-dark-default"){const r=SH(e,t,n),s=lc.get(r);if(s)return s;const l=(await vH()).codeToHtml(e,{lang:t,theme:n,transformers:[yH()]});if(lc.size>=bH){const d=lc.keys().next().value;d&&lc.delete(d)}return lc.set(r,l),l}const wH={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 af(e){var s;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=(s=t.split(".").pop())==null?void 0:s.toLowerCase();return r?wH[r]??"text":"text"}function GN(){const e=Gt(n=>n.currentPreset);return Gt(n=>n.isCustom)?"github-dark-default":xH[e]??"github-dark-default"}function qN(e=2e3){const[t,n]=C.useState(!1),r=C.useCallback(async s=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s);else{const a=document.createElement("textarea");a.value=s,a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}n(!0),setTimeout(()=>n(!1),e)}catch(a){console.error("Failed to copy:",a)}},[e]);return{copied:t,copy:r}}const CH=C.memo(function({language:t,codeString:n,showSyntaxHighlighting:r}){const{copied:s,copy:a}=qN(),[l,d]=C.useState(null),f=GN(),h=C.useRef(n);return C.useEffect(()=>{r&&(h.current=n,WN(n,t,f).then(p=>{h.current===n&&d(p)}))},[n,t,f,r]),c.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[c.jsxs("div",{className:"absolute bottom-0 right-0 flex items-center gap-2 px-2 py-1 text-xs text-text-muted/70 bg-bg-tertiary/60 rounded-tl rounded-tr z-10",children:[c.jsx("span",{children:t}),c.jsx("button",{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),a(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:s?c.jsx(gs,{}):c.jsx(X_,{})})]}),r&&l?c.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:l}}):c.jsx("div",{className:"overflow-x-auto",children:c.jsx("pre",{className:"my-0 px-4 py-3 overflow-x-auto font-mono text-sm whitespace-pre-wrap break-word",children:c.jsx("code",{className:`language-${t}`,children:n})})})]})});function kH(e,t){const n=e?"text-text-muted":"text-sky-400",r=e?"text-text-secondary":"text-amber-400";return{code({className:s,children:a,...l}){const d=/language-(\w+)/.exec(s||"");if(!d&&!String(a).includes(`
292
- `)){const g=e?"text-text-muted":"text-accent-secondary";return c.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${g} font-mono text-xs`,...l,children:a})}const h=(d==null?void 0:d[1])||"text",p=String(a).replace(/\n$/,"");return c.jsx(CH,{language:h,codeString:p,showSyntaxHighlighting:t})},p({children:s}){const a=e?"text-text-muted":"text-text-primary";return c.jsx("p",{className:`${a} mb-1.5 last:mb-0 leading-tight`,children:s})},ul({children:s}){return c.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:s})},ol({children:s}){return c.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:s})},li({children:s}){const a=e?"text-text-muted":"text-text-primary";return c.jsx("li",{className:`${a} text-sm list-item`,children:s})},h1({children:s}){return c.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:s})},h2({children:s}){return c.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:s})},h3({children:s}){return c.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:s})},h4({children:s}){return c.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:s})},strong({children:s}){return c.jsx("strong",{className:`font-bold ${r}`,children:s})},em({children:s}){return c.jsx("em",{className:e?"italic text-text-secondary":"italic",children:s})},a({href:s,children:a}){return c.jsx("a",{href:s,className:"text-accent-primary hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:a})},blockquote({children:s}){const a=e?"text-text-muted":"text-text-secondary";return c.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${a} italic text-sm`,children:s})},table({children:s}){return c.jsx("div",{className:"overflow-x-auto my-1.5",children:c.jsx("table",{className:"min-w-full border border-border",children:s})})},th({children:s}){return c.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:s})},td({children:s}){return c.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:s})},hr(){return c.jsx("hr",{className:"border-border my-2"})},input({checked:s,...a}){return c.jsx("input",{type:"checkbox",checked:s,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...a})}}}const Ks=C.memo(function({content:t,className:n="",muted:r=!1}){const{showSyntaxHighlighting:s}=Nh(),a=C.useMemo(()=>{let d=EH(t);return d=NH(d),d},[t]),l=C.useMemo(()=>kH(r,s),[r,s]);return c.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:c.jsx(a6,{remarkPlugins:[v8],components:l,children:a})})});function EH(e){let t=e.replace(/^(\s*)•\s/gm,"$1- ");return t=t.replace(/^(\d+)\.\s*\n(?=\S)/gm,"$1. "),t=t.replace(/^\|\s*$/gm,""),t=t.replace(/^\d+:\s/gm,""),t}function NH(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const s=e.lastIndexOf("```");return e.slice(s+3).includes(`
293
- `),e+"\n```"}return e}const jH=C.memo(function({content:t,variant:n="default"}){return n==="labeled"?c.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[c.jsx("span",{className:"text-purple-400",children:"thinking:"}),c.jsx("div",{className:"ml-1.5 mt-0.5",children:c.jsx(Ks,{content:t})})]}):c.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:c.jsx(Ks,{content:t,muted:!0})})});function KN({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}):e==="run_command"||e==="bash"?c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}const qo=C.memo(function({code:t,language:n,variant:r,showLineNumbers:s=!1,startLine:a=1}){const[l,d]=C.useState(null),f=GN(),h=C.useRef(t);if(C.useEffect(()=>{h.current=t,WN(t,n,f).then(g=>{h.current===t&&d(g)})},[t,n,f]),!l){const g=r==="inline"?"span":r==="block-nowrap"?"div":"pre";return c.jsx(g,{className:"language-",children:c.jsx("code",{className:"language-",children:t})})}if(r==="inline")return c.jsx("span",{dangerouslySetInnerHTML:{__html:l}});const p=s?"":"shiki-plain";return c.jsx("div",{className:p,style:{"--shiki-start":a},dangerouslySetInnerHTML:{__html:l}})});function YN({src:e,alt:t,isOpen:n,onClose:r}){return n?c.jsx(Et,{isOpen:n,onClose:r,title:"",size:"full",children:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const wh=C.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",s=t==="removed"?"line-through decoration-red-400/30":"";return c.jsx("div",{className:`border-l-[3px] ${r}`,children:c.jsx("div",{className:`min-w-0 py-3 ${s}`,children:c.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),TH=C.memo(function({oldString:t,newString:n,filePath:r}){const s=C.useMemo(()=>af(r),[r]),a=t.length>0,l=n.length>0;return!a&&!l?c.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):c.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[a&&c.jsx(wh,{type:"removed",children:c.jsx(qo,{code:t,language:s,variant:"block",showLineNumbers:!0})}),l&&c.jsx(wh,{type:"added",children:c.jsx(qo,{code:n,language:s,variant:"block",showLineNumbers:!0})})]})}),AH=C.memo(function({content:t,filePath:n}){const r=C.useMemo(()=>af(n),[n]);return c.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:c.jsx(wh,{type:"added",children:c.jsx(qo,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),DH=C.memo(function({regions:t,filePath:n}){const r=C.useMemo(()=>af(n),[n]);return t.length===0?c.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):c.jsx("div",{className:"space-y-2",children:t.map((s,a)=>c.jsx(RH,{region:s,language:r},a))})});function LH(e){const t=[];function n(r,s,a){const l=t[t.length-1];l&&l.type===r&&l.startLine+l.lines.length===s?l.lines.push(a):t.push({type:r,startLine:s,lines:[a]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const s=r.oldContent.split(`
294
- `);for(let l=0;l<s.length;l++)n("removed",r.startLine+l,s[l]);const a=r.newContent.split(`
295
- `);for(let l=0;l<a.length;l++)n("added",r.startLine+l,a[l])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const RH=C.memo(function({region:t,language:n}){const r=LH(t);return c.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((s,a)=>c.jsx(MH,{section:s,language:n},a))})}),MH=C.memo(function({section:t,language:n}){const r=t.lines.join(`
296
- `);return t.type==="context"?c.jsx("div",{children:c.jsx("div",{className:"min-w-0 py-3",children:c.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:c.jsx(qo,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):c.jsx(wh,{type:t.type,children:c.jsx(qo,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function mC(e){return e.split(`
297
- `).filter(t=>!t.startsWith(`
298
- [`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+: /,"")).join(`
299
- `)}const OH=C.memo(function({result:t,metadata:n,filePath:r,heightExpanded:s=!1}){const[a,l]=C.useState(!1),d=C.useMemo(()=>af(r),[r]),f=n==null?void 0:n.mimeType,h=n==null?void 0:n.base64Data;if(f!=null&&f.startsWith("image/")&&h){const S=`data:${f};base64,${h}`;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`rounded overflow-hidden border border-border ${s?"":"max-h-[45vh]"} flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors`,onClick:()=>l(!0),children:c.jsx("img",{src:S,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),c.jsx(YN,{src:S,alt:r,isOpen:a,onClose:()=>l(!1)})]})}if(!t)return c.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const p=t;if(d==="markdown"){const S=mC(p);return c.jsx("div",{className:`rounded overflow-hidden border border-border ${s?"":"max-h-[45vh]"} overflow-y-auto p-2`,children:c.jsx(Ks,{content:S})})}const g=mC(p),_=p.split(`
300
- `)[0],x=_==null?void 0:_.match(/^(\d+): /),v=x?parseInt(x[1],10):1;return c.jsx("div",{className:`rounded overflow-hidden border border-border ${s?"":"max-h-[45vh]"} overflow-y-auto`,children:c.jsx(qo,{code:g,language:d,variant:"block",showLineNumbers:!0,startLine:v})})}),IH={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"}},pC=C.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(a=>a.severity==="error"),r=t.filter(a=>a.severity==="warning"),s=t.filter(a=>a.severity==="info"||a.severity==="hint");return c.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[c.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[c.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&c.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&c.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),s.length>0&&c.jsxs("span",{className:"text-xs text-text-muted",children:[s.length," info"]})]}),c.jsx("div",{className:"max-h-48 overflow-y-auto",children:t.map((a,l)=>{const d=IH[a.severity];return c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${d.bg} border-b border-border last:border-b-0`,children:[c.jsx("span",{className:`${d.color} text-xs flex-shrink-0 w-4 text-center`,children:d.icon}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",a.range.start.line+1,":",a.range.start.character+1]}),a.code&&c.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",a.code,"]"]})]}),c.jsx("div",{className:"text-xs text-text-primary break-words",children:a.message})]})]},l)})})]})}),PH=C.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:s,status:a,result:l,error:d,durationMs:f}){const h=C.useRef(null),[p,g]=C.useState(0);C.useEffect(()=>{h.current&&a==="pending"&&(h.current.scrollTop=h.current.scrollHeight)},[s,a]),C.useEffect(()=>{if(a!=="pending"||!r)return;const S=setInterval(()=>{g(Date.now()-r)},100);return()=>clearInterval(S)},[a,r]);const _=n/1e3,x=a==="pending"?p/1e3:(f??0)/1e3,v=a==="pending"?(s==null?void 0:s.map(S=>S.content).join(""))??"":l??"";return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[c.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),c.jsx("code",{className:"text-text-primary break-all",children:t})]}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[a==="pending"&&c.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),a==="interrupted"&&c.jsx("span",{className:"text-red-400",children:"interrupted"}),c.jsxs("span",{className:a==="pending"?"text-text-secondary":"text-text-muted",children:[x.toFixed(1),"s / ",_,"s"]})]})]}),a==="pending"&&c.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(v||a==="pending")&&c.jsx("pre",{ref:h,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${a==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:a==="pending"&&s?s.map((S,w)=>c.jsx("span",{className:S.stream==="stderr"?"text-accent-warning":"",children:ah(S.content)},w)):ah(v)}),a==="error"&&d&&c.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:d}),a!=="pending"&&f!==void 0&&c.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",(f/1e3).toFixed(2),"s"]})]})});function BH(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 zH({confirmation:e}){const t=xe(g=>g.confirmPath),n=xe(g=>g.currentSession),r=xe(g=>g.switchDangerLevel),{title:s,description:a}=BH(e.reason),l=e.reason==="sensitive_file"||e.reason==="both",d=l?"border-red-500/50":"border-amber-500/50",f=l?"bg-red-500/10":"bg-amber-500/10",h=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return c.jsxs("div",{className:`border ${d} ${f} rounded p-3 my-2`,children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx(Lg,{}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:`text-sm font-medium ${l?"text-red-400":"text-amber-400"}`,children:s}),c.jsx("div",{className:"text-xs text-text-muted",children:a})]})]}),c.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[c.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),c.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:c.jsx("ul",{className:"space-y-0.5",children:e.paths.map((g,_)=>c.jsx("li",{className:`text-xs font-mono ${l?"text-red-300":"text-amber-300"} break-all`,children:g},_))})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),c.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),c.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${h?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function $H(e,t){if(e==="read_file"){const r=String(t.path??""),s=t.offset,a=t.limit,l=[];return s!==void 0&&s!==1&&l.push(`offset=${s}`),a!==void 0&&l.push(`limit=${a}`),l.length>0?`${r} [${l.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function gC(e,t,n){return $H(e,t)}function HH(e){return JSON.stringify(e,null,2)}const FH={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-red-400",animate:!1}},UH=C.memo(function({tool:t,args:n,status:r,variant:s="compact",forceCompact:a,result:l,error:d,durationMs:f,diagnostics:h,editContext:p,startedAt:g,streamingOutput:_,metadata:x,callId:v}){var W;const S=t==="edit_file"||t==="write_file",w=t==="run_command"&&r==="pending",k=t==="read_file",T=a?!1:S||w||t==="return_value",[A,P]=C.useState(T),R=FH[r],q=tn(z=>z.settings[Me.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",J=t==="edit_file"?(W=p==null?void 0:p.regions[0])==null?void 0:W.startLine:t==="read_file"?(()=>{const z=l==null?void 0:l.split(`
301
- `)[0],L=z==null?void 0:z.match(/^(\d+): /);return L?parseInt(L[1],10):void 0})():void 0,ne=xe(z=>z.pendingPathConfirmations),I=r==="pending"&&v?ne.find(z=>z.callId===v)??null:null;return s==="compact"?c.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary rounded px-2 py-1.5",children:[c.jsx(KN,{tool:t}),c.jsx("span",{className:"text-accent-primary font-medium",children:t}),c.jsx("span",{className:"text-text-muted truncate flex-1",children:gC(t,n)}),c.jsx("span",{className:`${R.color} ${R.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):c.jsxs("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0",children:[c.jsxs("button",{className:"w-full flex items-center gap-1.5 p-2 bg-secondary hover:bg-secondary/80 text-left",onClick:()=>P(!A),children:[c.jsx("span",{className:`${R.color} ${R.animate?"animate-pulse":""}`,children:R.icon}),c.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),c.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:gC(t,n)}),c.jsx("span",{className:"text-text-muted text-xs",children:A?"▼":"▶"})]}),I&&c.jsx(zH,{confirmation:I}),(A||k)&&c.jsxs("div",{className:"p-2 bg-primary border-t border-border space-y-2 min-w-0",children:[t==="run_command"&&c.jsx(PH,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:g,streamingOutput:_,status:r,result:l,error:d,durationMs:f}),t==="edit_file"&&r==="success"&&c.jsxs(c.Fragment,{children:[p&&p.regions.length>0?c.jsx(DH,{regions:p.regions,filePath:String(n.path??"")}):c.jsx(TH,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&c.jsx(pC,{diagnostics:h})]}),t==="write_file"&&r==="success"&&c.jsxs(c.Fragment,{children:[c.jsx(AH,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&c.jsx(pC,{diagnostics:h})]}),t==="read_file"&&r==="success"&&c.jsx(OH,{result:l,metadata:x,filePath:String(n.path??""),heightExpanded:A}),t==="return_value"&&(()=>{const z=(_==null?void 0:_.map(U=>U.content).join(""))??"",L=r==="pending"&&z?z:String(n.content??"");return c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),c.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:c.jsx(Ks,{content:L})})]})})(),t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),c.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto",children:HH(n)})]}),r==="success"&&l!==void 0&&c.jsxs("div",{children:[c.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",f!==void 0&&` (${f}ms)`,":"]}),c.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-32",children:l||"No output"})]})]}),r==="success"&&(t==="edit_file"||t==="write_file"||t==="read_file")&&f!==void 0&&c.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[c.jsxs("span",{children:["Completed in ",f,"ms"]}),q&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String(n.path??"")&&c.jsx("a",{href:`vscode://file/${String(n.path)}${J?`:${J}`:""}`,className:"text-accent-primary hover:underline ml-auto",children:"Open in VSCode"})]}),r==="error"&&d&&t!=="run_command"&&c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),c.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error",children:d})]})]})]})}),VH={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"},WH={criteria:"criteria",review_findings:"review findings",todos:"tasks"};function GH(e,t){const n=VH[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const s=JSON.parse(t).key;if(s){const a=WH[s]??s;return`${n} ${a}`}}catch{}return n}function qH(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 KH=C.memo(function({name:t,arguments:n}){let s=GH(t,n)+"...";if(t==="run_command"&&n){const a=qH(n);a&&(s=a)}return c.jsx("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0 animate-pulse",children:c.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-bg-tertiary",children:[c.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),c.jsx(KN,{tool:t}),c.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?c.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:s}):c.jsx("span",{className:"text-text-muted text-xs flex-1",children:s})]})})}),YH={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},XH=C.memo(function({todos:t}){return Array.isArray(t)?t.length===0?c.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):c.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[c.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:c.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),c.jsx("div",{children:t.map((n,r)=>{const s=YH[n.status];return c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[c.jsx("span",{className:`${(s==null?void 0:s.color)??"text-text-muted"} ${s!=null&&s.animate?"animate-pulse":""} text-sm leading-tight`,children:(s==null?void 0:s.icon)??"○"}),c.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):c.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})}),_C={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"}},XN=C.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(f=>[f.id,f]))??[]),s=t.find(f=>{var h,p;return f.arguments.action==="get"&&((h=f.result)==null?void 0:h.success)&&((p=f.result)==null?void 0:p.output)}),a=t.some(f=>f.name==="session_metadata"),l={criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"},d=(()=>{if(!a)return"Acceptance Criteria";const f=new Set(t.map(h=>h.arguments.key).filter(Boolean));if(f.size===1){const h=f.values().next().value;return h?l[h]??h:"Session Data"}return"Session Data"})();return c.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[c.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:c.jsx("span",{className:"text-xs font-medium text-text-muted",children:d})}),c.jsx("div",{className:"bg-primary",children:s?(()=>{const f=s.result.output;if(f==="No criteria defined yet.")return c.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[c.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),c.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(f).map((p,g)=>c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${g>0?"border-t border-border":""}`,children:[c.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),c.jsx("div",{className:"flex-1 min-w-0",children:c.jsx(Ks,{content:`[${p.id}] ${p.description}`})})]},p.id??g))}catch{return t.map((h,p)=>c.jsx(xC,{tc:h,index:p,criteriaMap:r},h.id??p))}})():t.map((f,h)=>c.jsx(xC,{tc:f,index:h,criteriaMap:r},f.id??h))})]})});function xC({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,s=e.arguments,a=e.name==="session_metadata",l=r==="remove",d=s.id,f=s.description,h=d?n.get(d):void 0,p=f??(h==null?void 0:h.description)??(l&&d?`[${d}]`:"Criterion updated"),g=s.reason,_=r==="fail";return c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[a?c.jsx(zh,{status:s.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const x=r&&_C[r]?_C[r]:{icon:"○",color:"text-text-muted"};return c.jsx("span",{className:`${x.color} text-sm leading-tight flex-shrink-0`,children:x.icon})})(),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:l?"line-through text-text-muted":"",children:c.jsx(Ks,{content:p})}),g&&c.jsxs("div",{className:`mt-1 text-sm ${_?"text-accent-error":"text-text-muted"}`,children:[c.jsx("span",{className:"text-text-muted",children:"└ "}),'"',g,'"']})]})]})}function QH(e){return e==="criterion"||e==="session_metadata"}function JH(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const s of e)s.type==="tool_call"&&QH(s.toolCall.name)?n.push(s.toolCall):(r(),t.push(s));return r(),t}function ZH(e,t){if(e.segments&&e.segments.length>0)return eF(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 eF(e,t,n,r,s){const a=[],l=new Map(t.map(d=>[d.id,d]));for(const d of e)switch(d.type){case"text":a.push({type:"text",content:d.content});break;case"thinking":d.content&&d.content.trim().length>0&&a.push({type:"thinking",content:d.content});break;case"tool_call":{const f=l.get(d.toolCallId);f&&a.push({type:"tool_call",toolCall:f});break}}for(const d of n)a.push({type:"preparing_tool_call",preparing:d});return s&&r&&a.push({type:"stats",stats:r}),a}const Jx=C.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:s=!0}){const a=xe(_=>{var x,v;return(v=(x=_.currentSession)==null?void 0:x.metadataEntries)==null?void 0:v.criteria}),l=mt(_=>_.defaults),d=mt(_=>_.userItems),f=[...l,...d],h=ZH(t,n),p=r?h:h.filter(_=>_.type!=="thinking"),g=JH(p);return g.length===0?null:c.jsx("div",{className:"feed-item",children:c.jsxs("div",{className:"min-w-0",children:[g.map((_,x)=>{var v,S;switch(_.type){case"thinking":return c.jsx(jH,{content:_.content},x);case"text":return c.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:c.jsx(Ks,{content:_.content})},x);case"preparing_tool_call":return c.jsx(KH,{name:_.preparing.name,arguments:_.preparing.arguments},`preparing-${_.preparing.index}`);case"tool_call":{const w=_.toolCall,k=w.result;if(w.name==="todo_write"){const A=w.arguments.todos,P=Array.isArray(A)?A:[];return c.jsx(XH,{todos:P},x)}const j=(v=k==null?void 0:k.output)==null?void 0:v.includes("[interrupted by user]"),T=k?j?"interrupted":k.success?"success":"error":"pending";return c.jsx(UH,{tool:w.name,args:w.arguments,status:T,variant:"expandable",forceCompact:!s,result:k==null?void 0:k.output,error:k==null?void 0:k.error,durationMs:k==null?void 0:k.durationMs,diagnostics:k==null?void 0:k.diagnostics,editContext:k==null?void 0:k.editContext,startedAt:w.startedAt,streamingOutput:w.streamingOutput,metadata:k==null?void 0:k.metadata,callId:w.id},x)}case"criteria_group":return c.jsx(XN,{toolCalls:_.toolCalls,criteria:a},x);case"stats":{const w=_.stats;if(!w||"error"in w)return null;const k=((S=w.model.split("/").pop())==null?void 0:S.split("-").slice(0,2).join("-"))??w.model,j=Ac(f,w.mode),T=P=>P>=1e3?`${(P/1e3).toFixed(1)}k`:P.toString(),A=P=>P>=1e3?`${(P/1e3).toFixed(1)}k`:P.toFixed(1);return c.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[c.jsx("span",{className:"flex-1 h-px bg-border"}),c.jsx("span",{className:"text-text-secondary",children:k}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsx("span",{style:{color:j},children:w.mode}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[w.totalTime.toFixed(1),"s"]}),w.toolTime>0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[w.toolTime.toFixed(1),"s tools"]})]}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[T(w.prefillTokens)," @ ",A(w.prefillSpeed)," pp"]}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[T(w.generationTokens)," @ ",A(w.generationSpeed)," tg"]}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const P=new CustomEvent("open-turn-stats",{detail:{stats:w}});window.dispatchEvent(P)},children:c.jsx(ek,{className:"w-3 h-3"})}),c.jsx("span",{className:"flex-1 h-px bg-border"})]},x)}}}),t.partial&&c.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[c.jsx(Lg,{}),c.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&c.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-amber-400/80 mt-1",children:[c.jsx(Lg,{}),c.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function Ch(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),s=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${s},${t})`}function tF(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),n=Math.round(e%60);return n>0?`${t}m ${n}s`:`${t}m`}function nF(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const rF=C.memo(function({data:t}){var l;const n=jt(d=>d.defaults),r=jt(d=>d.userItems),a=((l=[...n,...r].find(d=>d.id===t.workflowId))==null?void 0:l.color)??t.workflowColor??"#8b949e";return c.jsxs("div",{className:"feed-item rounded p-3 border",style:{borderColor:Ch(a,.3),backgroundColor:Ch(a,.08)},children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx(tL,{color:a}),c.jsx("span",{className:"text-sm font-medium",style:{color:a},children:t.workflowName??"Task Completed"})]}),c.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[c.jsx(cc,{label:"Iterations",value:String(t.iterations)}),c.jsx(cc,{label:"Total time",value:tF(t.totalTimeSeconds)}),c.jsx(cc,{label:"Tool calls",value:String(t.totalToolCalls)}),c.jsx(cc,{label:"Tokens",value:nF(t.totalTokensGenerated)}),c.jsx(cc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function cc({label:e,value:t}){return c.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[c.jsx("div",{className:"text-sm text-text-muted",children:e}),c.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const sF=C.memo(function({data:t}){var l;const n=jt(d=>d.defaults),r=jt(d=>d.userItems),a=((l=[...n,...r].find(d=>d.id===t.workflowId))==null?void 0:l.color)??t.workflowColor??"#6b7280";return c.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:Ch(a,.3),backgroundColor:Ch(a,.08)},children:[c.jsx(YD,{className:"w-3 h-3 shrink-0",color:a}),c.jsx("span",{className:"text-sm font-medium",style:{color:a},children:t.workflowName}),c.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function iF({attachments:e,messageId:t}){const[n,r]=C.useState(null),s=xe(p=>p.visionFallbackByMessage),a=xe(p=>p.messages),l=C.useMemo(()=>{const p=a.findIndex(g=>g.id===t);if(p===-1)return null;for(let g=p+1;g<a.length;g++){const _=a[g];if(_&&_.role==="assistant")return _.id}return null},[a,t]),d=p=>{r(p)},f=()=>{r(null)},h=p=>{const g=`${t}-${p}`;if(s[g])return s[g];if(l){const _=`${l}-${p}`;return s[_]}return null};return e.length===0?null:c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const g=h(p.id);return c.jsxs("div",{className:"relative inline-block",children:[c.jsxs("button",{onClick:()=>d(p.data),className:"group relative inline-block",title:p.filename,disabled:(g==null?void 0:g.type)==="start",children:[c.jsx("img",{src:p.data,alt:p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(g==null?void 0:g.type)==="start"&&c.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:c.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(g==null?void 0:g.type)==="done"&&g.description&&c.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[g.description.slice(0,200),g.description.length>200?"...":""]})]},p.id)})}),n&&c.jsx(YN,{src:n,alt:"Attached image",isOpen:!0,onClose:f})]})}function aF({isOpen:e,onClose:t,promptContext:n}){const[r,s]=C.useState({systemPrompt:!1,messages:!0,tools:!0,requestOptions:!0,injectedFiles:!0,userMessage:!0}),a=l=>{s(d=>({...d,[l]:!d[l]}))};return c.jsx(Et,{isOpen:e,onClose:t,title:"Prompt Inspector",size:"lg",children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(Lo,{title:"User Message",expanded:r.userMessage??!0,onToggle:()=>a("userMessage"),children:c.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-3 max-h-48 overflow-auto",children:n.userMessage||"(empty)"})}),n.messages.length>0&&c.jsx(Lo,{title:`Prompt Messages (${n.messages.length})`,expanded:r.messages??!0,onToggle:()=>a("messages"),children:c.jsx("div",{className:"space-y-2",children:n.messages.map((l,d)=>c.jsxs("div",{className:"border border-border rounded overflow-hidden",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-bg-tertiary/50 text-xs text-text-muted",children:[c.jsx("span",{className:"font-mono text-text-primary",children:l.role}),c.jsx("span",{className:"rounded bg-bg-tertiary px-1.5 py-0.5",children:l.source}),l.toolCallId&&c.jsx("span",{className:"font-mono",children:l.toolCallId}),l.attachments&&l.attachments.length>0&&c.jsxs("span",{className:"rounded bg-bg-tertiary px-1.5 py-0.5",children:[l.attachments.length," attachment",l.attachments.length===1?"":"s"]})]}),l.attachments&&l.attachments.length>0&&c.jsx("div",{className:"border-b border-border px-3 py-2 text-xs text-text-muted",children:l.attachments.map(f=>f.filename).join(", ")}),c.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded-b p-3 max-h-64 overflow-auto font-mono",children:l.content||"(empty)"})]},`${l.role}-${d}`))})}),c.jsx(Lo,{title:`Tools (${n.tools.length})`,expanded:r.tools??!0,onToggle:()=>a("tools"),children:c.jsxs("div",{className:"space-y-2",children:[n.tools.length===0&&c.jsx("div",{className:"text-sm text-text-muted",children:"No tools sent with this request."}),n.tools.map((l,d)=>c.jsxs("div",{className:"bg-bg-tertiary rounded p-3 space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("span",{className:"font-mono text-sm text-text-primary",children:l.name}),c.jsx("span",{className:"text-xs text-text-muted",children:"parameters"})]}),c.jsx("div",{className:"text-sm text-text-secondary",children:l.description}),c.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap max-h-48 overflow-auto font-mono",children:JSON.stringify(l.parameters,null,2)})]},`${l.name}-${d}`))]})}),c.jsx(Lo,{title:"Request Options",expanded:r.requestOptions??!0,onToggle:()=>a("requestOptions"),children:c.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-3 max-h-48 overflow-auto font-mono lowercase",children:JSON.stringify(n.requestOptions,null,2)})}),n.injectedFiles.length>0&&c.jsx(Lo,{title:`Injected Files (${n.injectedFiles.length})`,expanded:r.injectedFiles??!0,onToggle:()=>a("injectedFiles"),children:c.jsx("div",{className:"space-y-2",children:n.injectedFiles.map((l,d)=>c.jsx(oF,{file:l,expanded:r[`file-${d}`]??!1,onToggle:()=>a(`file-${d}`)},d))})}),c.jsx(Lo,{title:"System Prompt",expanded:r.systemPrompt??!1,onToggle:()=>a("systemPrompt"),badge:`${Math.round(n.systemPrompt.length/1e3)}K chars`,children:c.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-3 max-h-96 overflow-auto font-mono",children:n.systemPrompt})})]})})}function oF({file:e,expanded:t,onToggle:n}){return c.jsxs("div",{className:"bg-bg-tertiary rounded overflow-hidden",children:[c.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2 p-2 hover:bg-bg-primary/30 transition-colors",children:[c.jsx(Br,{className:`w-3 h-3 text-text-muted transition-transform ${t?"rotate-90":""}`}),c.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${e.source==="global"?"bg-purple-500/20 text-purple-400":e.source==="project"?"bg-blue-500/20 text-blue-400":"bg-green-500/20 text-green-400"}`,children:e.source}),c.jsx("span",{className:"text-sm text-text-primary font-mono truncate flex-1 text-left",children:e.path}),e.content&&c.jsxs("span",{className:"text-xs text-text-muted",children:[Math.round(e.content.length/1e3),"K chars"]})]}),t&&e.content&&c.jsx("div",{className:"border-t border-border/50 p-2",children:c.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap max-h-64 overflow-auto font-mono",children:e.content})})]})}function Lo({title:e,expanded:t,onToggle:n,badge:r,children:s}){return c.jsxs("div",{className:"border border-border rounded overflow-hidden",children:[c.jsx("button",{onClick:n,className:"w-full flex items-center justify-between p-3 bg-bg-tertiary/50 hover:bg-bg-tertiary transition-colors",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Br,{className:`w-4 h-4 text-text-muted transition-transform ${t?"rotate-90":""}`}),c.jsx("span",{className:"font-medium text-text-primary",children:e}),r&&c.jsx("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:r})]})}),t&&c.jsx("div",{className:"p-3 border-t border-border",children:s})]})}function lF({content:e,promptContext:t,align:n="right",messageIndex:r,sessionId:s}){const[a,l]=C.useState(!1),[d,f]=C.useState(!1),[h,p]=C.useState(!1),g=C.useRef(null),_=xe(w=>w.loadSession);C.useEffect(()=>{const w=k=>{g.current&&!g.current.contains(k.target)&&l(!1)};return a&&document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[a]);const x=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(e);else{const w=document.createElement("textarea");w.value=e,w.style.position="fixed",w.style.left="-999999px",document.body.appendChild(w),w.select(),document.execCommand("copy"),document.body.removeChild(w)}p(!0),l(!1),window.setTimeout(()=>p(!1),1500)}catch(w){console.error("Failed to copy:",w)}},v=async()=>{!s||r===void 0||(l(!1),await BA(s,r),_(s))},S=n==="right";return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:`flex items-start gap-1.5 ${S?"":"order-first"}`,children:[h&&c.jsx(gs,{className:"w-4 h-4 text-accent-success"}),c.jsxs("div",{ref:g,className:"relative",children:[c.jsx("button",{onClick:()=>l(!a),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",title:"Message options",children:c.jsx(Q_,{})}),a&&c.jsxs("div",{className:`absolute top-full mt-1 bg-bg-secondary border border-border rounded shadow-xl z-50 py-1 min-w-36 ${S?"right-0":"left-0"}`,children:[c.jsxs("button",{onClick:x,className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[c.jsx(X_,{className:"w-4 h-4"}),"Copy"]}),s&&r!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-t border-border my-1"}),c.jsxs("button",{onClick:v,className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[c.jsx(Z_,{className:"w-4 h-4"}),"Replay"]})]}),t&&c.jsxs("button",{onClick:()=>{f(!0),l(!1)},className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[c.jsx(Ec,{className:"w-4 h-4"}),"Inspect"]})]})]})]}),t&&c.jsx(aF,{isOpen:d,onClose:()=>f(!1),promptContext:t})]})}function cF({message:e}){const[t,n]=C.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,s=(r==null?void 0:r.color)??"#6b7280",a=(r==null?void 0:r.name)??"Agent",l=(r==null?void 0:r.type)??"agent",f={agent:"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions"}[l]??"injected",h=l==="workflow"||l==="subagent";return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[c.jsx("span",{className:"flex-1 h-px bg-border"}),c.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:s},onClick:()=>!h&&n(!0)}),c.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:s},onClick:()=>!h&&n(!0),children:a}),c.jsx("span",{children:"·"}),c.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:f}),c.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&c.jsx("div",{className:"flex justify-center feed-item mb-4",children:c.jsx("div",{className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${s}`},children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:e.content})})}),c.jsx(Et,{isOpen:t,onClose:()=>n(!1),title:`${a} Prompt`,size:"lg",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:s}}),c.jsx("span",{className:"text-sm text-text-primary font-medium",children:a}),c.jsxs("span",{className:"text-xs text-text-muted",children:["(",l,")"]})]}),c.jsx("div",{className:"h-full min-h-96",children:c.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-4 h-full min-h-96 overflow-auto font-mono",children:e.content})})]})})]})}function uF({message:e,promptContext:t,messageIndex:n,sessionId:r}){const s=e.messageKind==="auto-prompt",a=e.messageKind==="command",l=e.isSystemGenerated;return c.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",children:[!l&&c.jsx(lF,{content:e.content,promptContext:t,align:"right",messageIndex:n,sessionId:r}),c.jsxs("div",{className:`max-w-[75%] rounded p-2 ${l?a?"bg-teal-500/10 border border-teal-500/30":s?"bg-slate-500/10 border border-slate-500/30":"bg-amber-500/10 border border-amber-500/30":"bg-accent-primary/15 text-text-primary"}`,children:[l&&c.jsx("span",{className:`text-[10px] block mb-0.5 ${a?"text-teal-400":s?"text-slate-400":"text-amber-400"}`,children:a?"Command":s?"Auto":"System"}),c.jsx("div",{className:`whitespace-pre-wrap text-sm ${l?`${a?"text-teal-200":s?"text-slate-200":"text-amber-200 italic"}`:""}`,children:e.content}),e.attachments&&e.attachments.length>0&&c.jsx(iF,{attachments:e.attachments,messageId:e.id})]})]})}function dF({message:e}){const t=tn(r=>r.settings[Me.LLM_DISABLE_XML_PROTECTION])!=="true",n=async()=>{await tn.getState().setSetting(Me.LLM_DISABLE_XML_PROTECTION,t?"true":"false")};return c.jsx("div",{className:"flex justify-end feed-item",children:c.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-amber-500/10 border border-amber-500/30",children:[c.jsx("span",{className:"text-[10px] block mb-0.5 text-amber-400",children:"System"}),c.jsx("div",{className:"whitespace-pre-wrap text-sm text-amber-200 italic",children:e.content}),c.jsx("button",{onClick:n,className:"mt-2 text-xs text-amber-400 hover:text-amber-300 underline",children:t?"Disable XML protection":"Enable XML protection"})]})})}const QN=C.memo(function({message:t,isLastAssistantMessage:n=!1,promptContext:r,messageIndex:s,sessionId:a}){const l=t.role==="user",d=t.role==="assistant",f=t.role==="system",h=t.role==="tool";if(d)return c.jsx(Jx,{message:t,showStats:n});if(f&&t.isCompacted)return c.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[c.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),c.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
302
- `,"")})]});if(h)return c.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[c.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),c.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap overflow-x-auto max-h-32",children:[t.content.slice(0,500),t.content.length>500&&"..."]})]});if(t.messageKind==="workflow-started")try{const p=JSON.parse(t.content);return c.jsx(sF,{data:p})}catch{}if(t.messageKind==="task-completed")try{const p=JSON.parse(t.content);return c.jsx(rF,{data:p})}catch{}return t.messageKind==="context-reset"?c.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[c.jsx("div",{className:"flex-1 border-t border-border"}),c.jsx("span",{children:t.content}),c.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?c.jsx(cF,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?c.jsx(dF,{message:t}):l?c.jsx(uF,{message:t,promptContext:r,messageIndex:s,sessionId:a}):c.jsx("div",{className:"flex justify-start feed-item",children:c.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:c.jsx(Ks,{content:t.content})})})}),JN=(e,t)=>{const n=C.useRef(!0),r=C.useRef(null),[s,a]=C.useState(!0),l=()=>{const d=e.current;d&&(d.scrollTop=d.scrollHeight)};return C.useEffect(()=>{const d=e.current;if(!d)return;const f=x=>{if(x.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(()=>{d.scrollHeight-d.scrollTop-d.offsetHeight<100&&(n.current=!0,a(!0))}));return}n.current=!1,a(!1)},h=x=>{x.touches[0]&&(r.current=x.touches[0].clientY)},p=x=>{if(r.current===null)return;const v=x.touches[0];if(!v)return;if(v.clientY-r.current>0){n.current=!1,a(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>{d.scrollHeight-d.scrollTop-d.offsetHeight<100&&(n.current=!0,a(!0))}))},g=new MutationObserver(()=>{n.current&&requestAnimationFrame(l)}),_=setInterval(()=>{n.current&&l()},1e3);return d.addEventListener("wheel",f,{passive:!0}),d.addEventListener("touchstart",h,{passive:!0}),d.addEventListener("touchmove",p,{passive:!0}),g.observe(d,{childList:!0,subtree:!0,characterData:!0}),()=>{d.removeEventListener("wheel",f),d.removeEventListener("touchstart",h),d.removeEventListener("touchmove",p),g.disconnect(),clearInterval(_)}},[t==null?void 0:t.id]),{force_scroll_to_bottom:()=>{n.current=!0,a(!0),l()},isAutoScrollActive:s,setAutoScroll:d=>{n.current=d,a(d),d&&l()}}},hF={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function fF(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function yC(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function mF({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:s}=e,a=Math.round(t/n*100);return c.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[c.jsxs("span",{className:yC(a,s),children:[sh(t),"/",sh(n)]}),c.jsxs("span",{className:yC(a,s),children:["(",a,"%)"]}),c.jsx(v2,{percent:a,dangerZone:s,size:"sm"}),s&&c.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&c.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const pF=C.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:s}){const a=C.useRef(null),l=C.useRef(null),[d,f]=C.useState(!1),h=mt(q=>q.defaults),p=mt(q=>q.userItems),g=[...h,...p],_=xe(q=>q.subAgentContextStates[r]),{showThinking:x,showVerboseToolOutput:v}=Nh(),{isAutoScrollActive:S,setAutoScroll:w}=JN(l,null);C.useEffect(()=>{s||w(!0)},[s]);const k=C.useCallback(()=>{const q=!d;f(q),q&&setTimeout(()=>{var J;(J=a.current)==null||J.scrollIntoView({block:"start",behavior:"smooth"})},220)},[d]),j=g.find(q=>q.id===n),T=(j==null?void 0:j.name)??hF[n]??n,A=Ac(g,n),P=fF(A),R=t.filter(q=>q.role!=="tool");return c.jsxs("div",{ref:a,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[c.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:P,children:[c.jsx("span",{className:"text-xs font-medium",children:T}),c.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:_&&c.jsx(mF,{contextState:_})}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>w(!S),children:[c.jsx("span",{className:`w-1 h-1 rounded-full ${S?"bg-accent-success":"border border-text-muted"}`}),"live"]}),c.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:k,children:[d?"▼":"▶"," Expand"]})]})]}),c.jsx("div",{ref:l,className:`${d?"max-h-[calc(100vh-10rem)]":"max-h-80"} overflow-y-auto p-2 transition-[max-height] duration-200`,children:R.map(q=>q.role==="assistant"?c.jsx(Jx,{message:q,showStats:!0,showThinking:x,showVerboseToolOutput:v},q.id):c.jsx(QN,{message:q,isLastAssistantMessage:!1},q.id))})]})});function gF(e){const t={};let n=null;for(const r of e){if(r.role==="user"&&!r.isSystemGenerated){n=r.id;continue}r.role==="assistant"&&r.promptContext&&n&&t[n]===void 0&&(t[n]=r.promptContext)}return t}function ZN(e,t,n=!0){C.useEffect(()=>{if(!n)return;const r=s=>{var a;(a=e.current)!=null&&a.contains(s.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const _F=[],xF=C.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r}){const s=xe(W=>{var z,L;return((L=(z=W.currentSession)==null?void 0:z.metadataEntries)==null?void 0:L.criteria)??_F}),a=xe(W=>{var z;return(z=W.currentSession)==null?void 0:z.id}),l=xe(W=>{var z;return(z=W.currentSession)==null?void 0:z.mode}),d=xe(W=>{var z;return(z=W.currentSession)==null?void 0:z.phase}),f=xe(W=>W.messages),h=xe(W=>W.error),p=xe(W=>W.clearError),g=xe(W=>W.acceptAndBuild),_=Ah(),{showThinking:x,showVerboseToolOutput:v,showStats:S,showAgentDefinitions:w,showWorkflowBars:k}=Nh(),j=jt(W=>W.defaults),T=jt(W=>W.userItems),A=[...j,...T],P=C.useMemo(()=>gF(f),[f]),R=l==="planner",q=s.length>0,J=d==="done",ne=t.some(W=>W.type==="message"&&W.message.role==="assistant"),I=R&&q&&!_&&ne&&!J;return c.jsxs("div",{ref:n,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto relative bg-primary",children:[c.jsx("div",{className:"pt-4",children:t.map((W,z)=>{if(W.type==="context-divider")return c.jsxs("div",{"data-item-index":z,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[c.jsx("div",{className:"flex-1 border-t border-border"}),c.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),c.jsx("div",{className:"flex-1 border-t border-border"})]},z);if(W.type==="subagent"){const N=W.messages.some(F=>F.isStreaming);return c.jsx("div",{"data-item-index":z,className:"px-2 md:px-4",children:c.jsx(pF,{messages:W.messages,subAgentType:W.subAgentType,subAgentId:W.subAgentId,isStreaming:N})},z)}if(W.type==="criteria-batch")return c.jsx("div",{"data-item-index":z,className:"feed-item px-2 md:px-4",children:c.jsx(XN,{toolCalls:W.toolCalls,criteria:s})},z);const L=W.message;if(L.role==="assistant")return c.jsx("div",{"data-item-index":z,className:"px-2 md:px-4",children:c.jsx(Jx,{message:L,showStats:S,showThinking:x,showVerboseToolOutput:v})},z);const U=!w&&L.messageKind==="auto-prompt",D=!k&&(L.messageKind==="workflow-started"||L.messageKind==="task-completed");return U||D?null:c.jsx("div",{"data-item-index":z,className:"px-2 md:px-4",children:c.jsx("div",{"data-message-id":L.id,className:r===L.id?"rounded animate-highlight-fade":void 0,children:c.jsx(QN,{message:L,messageIndex:z,sessionId:a,isLastAssistantMessage:!1,promptContext:L.role==="user"?P[L.id]:void 0})})},z)})}),c.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[h&&c.jsx("div",{className:"feed-item bg-red-500/10 border border-red-500/50 rounded p-2",children:c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-red-400 text-sm font-medium",children:h.code}),c.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:h.message})]}),c.jsx(qc,{onClick:p,className:"text-red-400 hover:text-red-300 p-0.5",size:"sm"})]})}),I&&c.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:A.map(W=>{const z=W.color??"#3b82f6",L=parseInt(z.slice(1,3),16),U=parseInt(z.slice(3,5),16),D=parseInt(z.slice(5,7),16),N=`rgba(${L},${U},${D},0.12)`,F=`rgba(${L},${U},${D},0.22)`,H=`rgba(${L},${U},${D},0.25)`;return c.jsx(yF,{workflowName:W.name,color:z,bg:N,bgHover:F,border:H,subGroups:W.subGroups,onLaunch:se=>g(W.id,void 0,void 0,se)},W.id)})})]})]})});function yF({workflowName:e,color:t,bg:n,bgHover:r,border:s,subGroups:a,onLaunch:l}){const[d,f]=C.useState(!1),h=C.useRef(null);return ZN(h,()=>f(!1),d),c.jsxs("div",{className:"relative flex",children:[c.jsxs("button",{onClick:()=>l(),"data-testid":"workflow-run-button",className:"px-4 py-1.5 rounded-l text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${s}`,borderRight:"none"},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=r},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),a&&a.length>0&&c.jsxs("div",{ref:h,className:"relative",children:[c.jsx("button",{onClick:()=>f(!d),className:"px-1.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${s}`},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=r},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:"⋮"}),d&&c.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[c.jsx("button",{onClick:()=>{l(),f(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),c.jsx("div",{className:"border-t border-border/50"}),a.map(p=>c.jsx("button",{onClick:()=>{l(p),f(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:p},p))]})]})]})}function vF({question:e}){const t=xe(l=>l.answerQuestion),[n,r]=C.useState(""),s=()=>{t(e.callId,n)},a=l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),s())};return c.jsx(Et,{isOpen:!0,onClose:()=>{},size:"sm",closeOnBackdropClick:!1,closeOnEscape:!1,showCloseButton:!1,children:c.jsxs("div",{className:"space-y-4",children:[c.jsx("p",{className:"text-sm text-text-primary",children:e.question}),c.jsx("textarea",{value:n,onChange:l=>r(l.target.value),onKeyDown:a,placeholder:"Type your answer here...",className:"w-full min-h-[120px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:!0}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",size:"sm",onClick:()=>t(e.callId,""),children:"Skip"}),c.jsx(Ze,{variant:"primary",size:"sm",onClick:s,children:"Send Answer"})]})]})})}function bF(){const e=xe(r=>r.connectionStatus),t=xe(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return c.jsxs("div",{className:`
303
- flex items-center justify-between px-4 py-2
304
- text-sm font-medium
305
- ${n?"bg-amber-500/15 border-b border-amber-500/30 text-amber-300":"bg-red-500/15 border-b border-red-500/30 text-red-300"}
306
- `,children:[c.jsx("div",{className:"flex items-center gap-2",children:n?c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"flex gap-1",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),c.jsx("span",{children:"Reconnecting to server..."})]}):c.jsxs(c.Fragment,{children:[c.jsx(rL,{}),c.jsx("span",{children:"Connection lost"})]})}),c.jsx("button",{onClick:()=>t(),disabled:n,className:`
307
- px-3 py-1 rounded text-xs font-medium
308
- transition-colors
309
- ${n?"bg-amber-500/20 text-amber-400 cursor-not-allowed opacity-50":"bg-red-500/20 text-red-300 hover:bg-red-500/30 hover:text-red-200"}
310
- `,children:n?"Reconnecting...":"Reconnect"})]})}const mn=xr((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await rx("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await Ne(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const s=await zi("POST","/api/commands",{...n,destination:r});return s.success&&await t().fetchCommands(),s},updateCommand:async(n,r)=>{const s=await zi("PUT",`/api/commands/${n}`,r);return s.success&&await t().fetchCommands(),s},deleteCommand:async n=>{try{const r=await Ne(`/api/commands/${n}`,{method:"DELETE"}),s=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:s.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r)=>Th(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function SF(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function wF({onClick:e}){return c.jsx("button",{type:"button",onClick:e,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:c.jsx(Ec,{})})}function ej({isOpen:e,onClose:t,initialEditId:n}){const r=mn(ue=>ue.defaults),s=mn(ue=>ue.userItems),a=mn(ue=>ue.projectItems),l=mn(ue=>ue.loading),d=mn(ue=>ue.fetchCommands),f=mn(ue=>ue.fetchCommand),h=mn(ue=>ue.fetchDefaultContent),p=mn(ue=>ue.createCommand),g=mn(ue=>ue.updateCommand),_=mn(ue=>ue.deleteCommand),[x,v]=C.useState(null),[S,w]=C.useState(null),{view:k,editingId:j,formError:T,saving:A,formData:P,setView:R,setEditingId:q,setFormError:J,setFormData:ne,setSaving:I}=mk(),{requestDelete:W,clearConfirm:z,isConfirming:L}=sx(),U=C.useRef(!1),D=mt(ue=>ue.defaults),N=mt(ue=>ue.userItems),F=mt(ue=>ue.fetchAgents),se=[...D,...N].filter(ue=>!ue.subagent),B=C.useRef(d),V=C.useRef(F),K=C.useRef(f),O=C.useRef(h),Q=C.useRef(n),G=C.useRef(R),Z=C.useRef(q),te=C.useRef(J),Se=C.useRef(z);C.useEffect(()=>{B.current=d,V.current=F,K.current=f,O.current=h,Q.current=n,G.current=R,Z.current=q,te.current=J,Se.current=z}),C.useEffect(()=>{if(e)if(B.current(),V.current(),U.current||(Se.current(),U.current=!0),Q.current){const ue=r.some(Ee=>Ee.id===Q.current);G.current("edit"),Z.current(Q.current),te.current(""),ue?O.current(Q.current).then(Ee=>{Ee&&ne({name:Ee.metadata.name+" (copy)",id:`${Q.current}-copy-${Date.now()}`,prompt:Ee.prompt,agentMode:Ee.metadata.agentMode??"",isDefault:!0,destination:"user"})}):K.current(Q.current).then(Ee=>{Ee&&ne({name:Ee.metadata.name,id:Ee.metadata.id,prompt:Ee.prompt,agentMode:Ee.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else G.current("list"),Z.current(null);else U.current=!1},[e]);const le=async ue=>{v(ue);const Ee=await h(ue);w((Ee==null?void 0:Ee.prompt)??null)},Ce=async ue=>{if(r.some(_t=>_t.id===ue)){const _t=await h(ue);_t&&(q(null),ne({name:`${_t.metadata.name} (copy)`,id:`${ue}-copy-${Date.now()}`,prompt:_t.prompt,agentMode:_t.metadata.agentMode??"",isDefault:!0,destination:"user"}),J(""),R("edit"))}else{const _t=await f(ue);_t&&(q(null),ne({name:`${_t.metadata.name} (copy)`,id:`${ue}-copy-${Date.now()}`,prompt:_t.prompt,agentMode:_t.metadata.agentMode??"",isDefault:!1,destination:"user"}),J(""),R("edit"))}},Re=()=>{ne({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),q(null),R("edit")},Oe=async ue=>{const Ee=await f(ue);Ee&&(q(ue),ne({name:Ee.metadata.name,id:Ee.metadata.id,prompt:Ee.prompt,agentMode:Ee.metadata.agentMode??"",isDefault:!1,destination:"user"}),J(""),R("edit"))},De=async ue=>{await _(ue),z()},Ue=async()=>{const ue=j??P.id;if(!ue||!P.name||!P.prompt){J("Name and message are required.");return}I(!0),J("");const Ee={metadata:{id:ue,name:P.name,...P.agentMode?{agentMode:P.agentMode}:{}},prompt:P.prompt},_t=j?await g(j,Ee):await p(Ee,P.destination);if(I(!1),!_t.success){J(_t.error??"Failed to save command.");return}n?t():R("list")},st=()=>{n?t():(R("list"),v(null),w(null))},it=ue=>{ne(Ee=>({...Ee,name:ue})),(!j||P.isDefault)&&ne(Ee=>({...Ee,id:SF(ue)}))},ye=()=>{v(null),w(null),R("list")},ze=()=>{x&&(v(null),R("edit"),q(x),h(x).then(ue=>{ue&&ne({name:`${ue.metadata.name} (copy)`,id:`${x}-copy-${Date.now()}`,prompt:ue.prompt,agentMode:ue.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(x){const ue=r.find(Ee=>Ee.id===x);return c.jsx(Et,{isOpen:e,onClose:ye,title:`Default: ${(ue==null?void 0:ue.name)??x}`,size:"xl",children:c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"space-y-3 mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[c.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),c.jsx("span",{className:"font-mono",children:x})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),c.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:ue==null?void 0:ue.name})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),c.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(ue==null?void 0:ue.agentMode)||"None"})]})]}),c.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),c.jsx("textarea",{value:S??"",readOnly:!0,placeholder:"...",className:"flex-1 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none opacity-60"})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:ye,children:"Close"}),c.jsx(Ze,{variant:"primary",onClick:ze,children:"Duplicate & Customize"})]})]})})}if(k==="edit")return c.jsx(Et,{isOpen:e,onClose:st,title:j?"Edit Command":"New Command",size:"xl",children:c.jsxs("div",{className:"flex flex-col h-full",children:[T&&c.jsx(ox,{message:T}),c.jsxs("div",{className:"space-y-3 mb-3",children:[c.jsx(fk,{name:P.name,id:P.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!j&&!P.isDefault,onNameChange:it,onIdChange:ue=>ne(Ee=>({...Ee,id:ue}))}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",c.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),c.jsxs("select",{value:P.agentMode,onChange:ue=>ne(Ee=>({...Ee,agentMode:ue.target.value})),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[c.jsx("option",{value:"",children:"None (keep current mode)"}),se.map(ue=>c.jsx("option",{value:ue.id,children:ue.name},ue.id))]})]}),!j&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),c.jsxs("select",{value:P.destination,onChange:ue=>ne(Ee=>({...Ee,destination:ue.target.value})),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[c.jsx("option",{value:"user",children:"Global config"}),c.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})]}),c.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),c.jsx("textarea",{value:P.prompt,onChange:ue=>ne(Ee=>({...Ee,prompt:ue.target.value})),placeholder:"The message that will be sent when this command is triggered...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:st,children:"Cancel"}),c.jsx(Ze,{variant:"primary",onClick:Ue,disabled:A||!P.name||!P.prompt,children:A?"Saving...":"Save"})]})]})});const ve=ue=>ue.map(Ee=>c.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[c.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("span",{className:"text-text-primary text-sm font-medium",children:Ee.name})})}),c.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.jsx(Oi,{onClick:()=>Oe(Ee.id)}),c.jsx(Qd,{onClick:()=>Ce(Ee.id)}),L(Ee.id,"delete")?c.jsx(ix,{onConfirm:()=>De(Ee.id),onCancel:z}):c.jsx(ax,{onClick:()=>W(Ee.id)})]})]},Ee.id));return c.jsxs(Et,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[c.jsx(uk,{description:"Commands are pre-defined messages you can send with a single click.",onNew:Re}),c.jsxs(hk,{loading:l,hasItems:r.length>0||s.length>0||a.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),c.jsx("div",{className:"space-y-2",children:r.map(ue=>c.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[c.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c.jsx("span",{className:"text-text-primary text-sm font-medium",children:ue.name})}),c.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.jsx(wF,{onClick:()=>le(ue.id)}),c.jsx(Qd,{onClick:()=>Ce(ue.id)})]})]},ue.id))})]}),s.length>0&&c.jsx(ck,{children:ve(s)}),a.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),c.jsx("div",{className:"space-y-2",children:ve(a)})]})]})]})}const ua=150,Hs=54,Bd=80,Wr=30,Ro=70,vC=100,da=50,zd=50,bC=4,tj={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},nj=[{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)"}],CF=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}];function Zx(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.toolMode);return{name:(n==null?void 0:n.name)??(e.toolMode||"Agent"),color:(n==null?void 0:n.color)||"#3b82f6"}}if(e.type==="sub_agent"){const n=t.find(r=>r.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return{name:"Shell",color:"#22c55e"}}function kF(e,t,n,r){const s=zd+da+ua+vC+ua+da+zd,a=s/2,l=zd+da+ua/2,d=zd+da+ua+vC+ua/2,f=[],h=[],p=new Map,g=e.filter(D=>D.type==="agent"||D.type==="shell"),_=e.filter(D=>D.type==="sub_agent"),x=_.length>0,v=x?l:a,S=g.length>0?d:a,w=da+Wr/2;f.push({id:"$start",type:"terminal",label:"Start",cx:v,cy:w,w:Bd,h:Wr}),p.set("$start",{cx:v,cy:w,w:Bd,h:Wr});const k=D=>{f.push({id:"$done",type:"terminal",label:"Done",cx:v,cy:D,w:Bd,h:Wr}),p.set("$done",{cx:v,cy:D,w:Bd,h:Wr})};if(e.length===0){const D=w+Wr/2+Ro*2+Wr/2;return k(D),{nodes:f,edges:h,width:s,height:D+Wr/2+da,posMap:p}}const j=w+Wr/2+Ro,T=(D,N)=>{D.forEach((F,H)=>{const se=j+H*(Hs+Ro)+Hs/2,{name:B,color:V}=Zx(F,r);f.push({id:F.id,type:"step",label:B,color:V,cx:N,cy:se,w:ua,h:Hs}),p.set(F.id,{cx:N,cy:se,w:ua,h:Hs})})};T(g,v),T(_,S);const A=g.length>0?j+(g.length-1)*(Hs+Ro)+Hs/2:w,P=x?j+(_.length-1)*(Hs+Ro)+Hs/2:w,R=Math.max(A,P)+Hs/2+Ro+Wr/2;k(R);const q=[];t&&p.has(t)&&q.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let J=0;for(const D of e)D.transitions.forEach((N,F)=>{var O;if(!N.goto||!p.has(N.goto))return;const H=p.get(D.id),se=p.get(N.goto),B=N.when.type==="step_result"?`${N.when.result}`:N.when.type==="metadata_all_match"?`${N.when.key??"?"}=${N.when.value??"?"}`:N.when.type==="metadata_all_in"?`${N.when.key??"?"} in [${((O=N.when.values)==null?void 0:O.join(","))??"?"}]`:tj[N.when.type]??N.when.type,V=D.id===N.goto;let K;V?K="back":se.cy>H.cy+1?K="down":se.cy<H.cy-1?K="back":K="same",q.push({from:D.id,to:N.goto,label:B,edgeKey:`${D.id}:${F}`,direction:K,backEdgeIndex:K==="back"?J++:0})});const ne=new Map,I=new Map,W=new Map,z=new Map;for(const D of q)D.direction==="down"&&(ne.set(D.from,(ne.get(D.from)??0)+1),I.set(D.to,(I.get(D.to)??0)+1));const L=new Map,U=new Map;for(const D of q){if(D.direction!=="same")continue;const N=[D.from,D.to].sort().join("|");L.set(N,(L.get(N)??0)+1)}for(const D of q){if(D.direction==="back"||D.direction==="same"){let K=0;if(D.direction==="same"){const O=[D.from,D.to].sort().join("|");K=U.get(O)??0,U.set(O,K+1)}h.push({...D,fromPort:0,toPort:0,sameEdgeIndex:K});continue}const N=ne.get(D.from)??1,F=I.get(D.to)??1,H=W.get(D.from)??0,se=z.get(D.to)??0;W.set(D.from,H+1),z.set(D.to,se+1);const B=N===1?0:-.6+1.2*H/(N-1),V=F===1?0:-.6+1.2*se/(F-1);h.push({...D,fromPort:B,toPort:V,sameEdgeIndex:0})}return{nodes:f,edges:h,width:s,height:R+Wr/2+da,posMap:p}}function EF({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:s,agentTypes:a,isReadOnly:l,onSelectNode:d,onSelectEdge:f,onRemoveStep:h,onCreateTransition:p,onReconnectTo:g,onReconnectFrom:_,onDeleteTransition:x}){const v=C.useRef(null),S=C.useRef(!1),[w,k]=C.useState(null),[j,T]=C.useState(null),[A,P]=C.useState(null),{nodes:R,edges:q,width:J,height:ne,posMap:I}=C.useMemo(()=>kF(e,t,s,a),[e,t,s,a]),W=C.useCallback(G=>{var Ce;const Z=v.current;if(!Z)return{x:0,y:0};const te=Z.createSVGPoint();te.x=G.clientX,te.y=G.clientY;const Se=(Ce=Z.getScreenCTM())==null?void 0:Ce.inverse();if(!Se)return{x:0,y:0};const le=te.matrixTransform(Se);return{x:le.x,y:le.y}},[]),z=C.useCallback(G=>!G||!j||G==="$start"?!1:j.type==="reconnect-from"?G!=="$done":!0,[j]),L=C.useCallback((G,Z)=>{if(l)return;G.stopPropagation(),G.preventDefault();const te=W(G);T({type:"new",fromNodeId:Z,mouseX:te.x,mouseY:te.y})},[W,l]),U=C.useCallback((G,Z)=>{if(l)return;G.stopPropagation(),G.preventDefault();const te=W(G);T({type:"reconnect-to",fromNodeId:Z.from,edgeKey:Z.edgeKey,mouseX:te.x,mouseY:te.y})},[W,l]),D=C.useCallback((G,Z)=>{if(l)return;G.stopPropagation(),G.preventDefault();const te=W(G);T({type:"reconnect-from",fromNodeId:Z.from,fixedTargetId:Z.to,edgeKey:Z.edgeKey,mouseX:te.x,mouseY:te.y})},[W,l]),N=C.useCallback(G=>{if(!j)return;const Z=W(G);T(te=>te?{...te,mouseX:Z.x,mouseY:Z.y}:null)},[j,W]),F=C.useCallback(()=>{j&&(S.current=!0,A&&z(A)&&(j.type==="new"?p(j.fromNodeId,A):j.type==="reconnect-to"?g(j.edgeKey,A):j.type==="reconnect-from"&&_(j.edgeKey,A)),T(null),P(null))},[j,A,z,p,g,_]),H=C.useCallback(()=>{if(S.current){S.current=!1;return}d(null),f(null)},[d,f]);C.useEffect(()=>{if(l)return;const G=Z=>{Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement||(Z.key==="Delete"||Z.key==="Backspace")&&r&&r!=="start"&&(Z.preventDefault(),x(r),f(null))};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[l,r,x,f]);const se=G=>{const Z=I.get(G.from),te=I.get(G.to);if(!Z||!te)return null;let Se,le,Ce,Re="middle",Oe,De;if(G.direction==="down"){const Ue=Z.cx+G.fromPort*(Z.w/2-10),st=Z.cy+Z.h/2,it=te.cx+G.toPort*(te.w/2-10),ye=te.cy-te.h/2,ze=ye-st,ve=it-Ue;Se=`M ${Ue} ${st} C ${Ue} ${st+ze*.4}, ${it-ve*.2} ${ye-ze*.1}, ${it} ${ye}`,le=Ue+(it-Ue)*.5,Ce=st+ze*.6,Oe={x:Ue,y:st},De={x:it,y:ye}}else if(G.direction==="back"){const Ue=G.from===G.to,st=Z.cx>=J/2,it=G.backEdgeIndex*16,ye=st?J-20-it:20+it;if(Ue){const ze=Z.cx>=J/2,ve=30+G.backEdgeIndex*14,ue=Z.cy-Z.h/2,Ee=ze?Z.cx+Z.w/2:Z.cx-Z.w/2,_t=ze?Ee+ve:Ee-ve,Js=Z.cx+(ze?Z.w/4:-Z.w/4),Yt=ue-20-G.backEdgeIndex*10;Se=`M ${Ee} ${Z.cy} C ${_t} ${Z.cy}, ${_t} ${Yt}, ${Js} ${ue}`,le=_t+10,Ce=Yt+4,Re="middle",Oe={x:Ee,y:Z.cy},De={x:Js,y:ue}}else{const ze=st?Z.cx+Z.w/2:Z.cx-Z.w/2,ve=te.cx+(st?te.w/4:-te.w/4),ue=Math.min(Z.cy,te.cy)-te.h/2-18-G.backEdgeIndex*14;Se=`M ${ze} ${Z.cy} L ${ye} ${Z.cy} L ${ye} ${ue} L ${ve} ${ue} L ${ve} ${te.cy-te.h/2}`,le=ye,Ce=(Z.cy+ue)/2,Re=st?"start":"end",Oe={x:ze,y:Z.cy},De={x:ve,y:te.cy-te.h/2}}}else{const Ue=te.cx>Z.cx,st=G.sameEdgeIndex===0?-12:12,it=Ue?Z.cx+Z.w/2:Z.cx-Z.w/2,ye=Ue?te.cx-te.w/2:te.cx+te.w/2,ze=Z.cy+st,ve=te.cy+st,ue=(it+ye)/2;Se=`M ${it} ${ze} C ${ue} ${ze}, ${ue} ${ve}, ${ye} ${ve}`,le=ue,Ce=(ze+ve)/2-6,Oe={x:it,y:ze},De={x:ye,y:ve}}return{path:Se,labelX:le,labelY:Ce,labelAnchor:Re,fromPt:Oe,toPt:De}},B=(G,Z)=>{const te=se(G);if(!te)return null;const{path:Se,labelX:le,labelY:Ce,labelAnchor:Re}=te,Oe=r===G.edgeKey,De=G.label&&G.label!=="otherwise";return c.jsxs("g",{children:[c.jsx("path",{d:Se,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Ue=>{Ue.stopPropagation(),l||f(Oe?null:G.edgeKey)}}),c.jsx("path",{d:Se,fill:"none",stroke:Oe?"#58a6ff":"#484f58",strokeWidth:Oe?2.2:1.2,markerEnd:Oe?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),De&&c.jsx("text",{x:le+(Re==="start"?5:Re==="end"?-5:0),y:Ce+3,textAnchor:Re,className:"text-[8px]",fill:Oe?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:G.label})]},Z)},V=()=>{if(!r||j)return null;const G=q.find(Ce=>Ce.edgeKey===r);if(!G)return null;const Z=se(G);if(!Z)return null;const{fromPt:te,toPt:Se}=Z,le=6;return c.jsxs(c.Fragment,{children:[G.edgeKey!=="start"&&c.jsx("circle",{cx:te.x,cy:te.y,r:le,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:Ce=>D(Ce,G)}),c.jsx("circle",{cx:Se.x,cy:Se.y,r:le,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:Ce=>U(Ce,G)})]})},K=()=>{if(!j)return null;let G,Z,te,Se;if(j.type==="reconnect-from"){const Re=I.get(j.fixedTargetId);if(!Re)return null;G=j.mouseX,Z=j.mouseY,te=Re.cx,Se=Re.cy-Re.h/2}else{const Re=I.get(j.fromNodeId);if(!Re)return null;G=Re.cx,Z=Re.cy+Re.h/2,te=j.mouseX,Se=j.mouseY}const le=Se-Z,Ce=Math.abs(le)>10?`M ${G} ${Z} C ${G} ${Z+le*.4}, ${te} ${Se-le*.4}, ${te} ${Se}`:`M ${G} ${Z} L ${te} ${Se}`;return c.jsx("path",{d:Ce,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},O=G=>{const Z=G.cy+G.h/2,te=(j==null?void 0:j.fromNodeId)===G.id;return c.jsx("circle",{cx:G.cx,cy:Z,r:bC,fill:te?"#58a6ff":"#1c2128",stroke:te?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:te?1:.5,className:"cursor-crosshair",onMouseDown:Se=>L(Se,G.id)})},Q=G=>{const Z=G.cy-G.h/2,te=j&&A===G.id&&z(G.id);return c.jsx("circle",{cx:G.cx,cy:Z,r:bC,fill:te?"#3fb950":"#1c2128",stroke:te?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:te?1:.5})};return c.jsxs("svg",{ref:v,viewBox:`0 0 ${J} ${ne}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:N,onMouseUp:F,onClick:H,children:[c.jsxs("defs",{children:[c.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:c.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),c.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:c.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),q.map((G,Z)=>B(G,Z)),R.map(G=>{const Z=n===G.id,te=G.cx-G.w/2,Se=G.cy-G.h/2,le=w===G.id,Ce=j&&A===G.id&&z(G.id);if(G.type==="terminal"){const Oe=G.id==="$start",De=Oe?"#58a6ff":"#3fb950",Ue=Oe,st=!Oe;return c.jsxs("g",{onClick:it=>{it.stopPropagation(),Oe&&!l&&f("start")},className:Oe&&!l?"cursor-pointer":void 0,children:[Ce&&c.jsx("rect",{x:te-3,y:Se-3,width:G.w+6,height:G.h+6,rx:G.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),Oe&&r==="start"&&c.jsx("rect",{x:te-3,y:Se-3,width:G.w+6,height:G.h+6,rx:G.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),c.jsx("rect",{x:te,y:Se,width:G.w,height:G.h,rx:G.h/2,fill:De,fillOpacity:.08,stroke:De,strokeOpacity:.4,strokeWidth:1.5}),c.jsx("text",{x:G.cx,y:G.cy+4,textAnchor:"middle",fill:De,className:"text-[10px] font-medium",pointerEvents:"none",children:G.label}),Ue&&O(G),st&&Q(G)]},G.id)}const Re=G.color??"#6b7280";return c.jsxs("g",{onClick:Oe=>{Oe.stopPropagation(),l||d(Z?null:G.id)},onMouseEnter:()=>k(G.id),onMouseLeave:()=>k(null),className:l?void 0:"cursor-pointer",children:[Ce&&c.jsx("rect",{x:te-3,y:Se-3,width:G.w+6,height:G.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),Z&&c.jsx("rect",{x:te-3,y:Se-3,width:G.w+6,height:G.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),c.jsx("rect",{x:te,y:Se,width:G.w,height:G.h,rx:10,fill:Re,fillOpacity:.08,stroke:Re,strokeOpacity:.6,strokeWidth:Z?2:1.5}),c.jsx("text",{x:G.cx,y:G.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:G.label}),!l&&O(G),!l&&Q(G),le&&!j&&!l&&c.jsxs("g",{onClick:Oe=>{Oe.stopPropagation(),h(G.id)},className:"cursor-pointer",children:[c.jsx("circle",{cx:te+G.w-2,cy:Se+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),c.jsx("line",{x1:te+G.w-5,y1:Se-1,x2:te+G.w+1,y2:Se+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),c.jsx("line",{x1:te+G.w+1,y1:Se-1,x2:te+G.w-5,y2:Se+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},G.id)}),j&&R.map(G=>z(G.id)?c.jsx("rect",{x:G.cx-G.w/2-8,y:G.cy-G.h/2-8,width:G.w+16,height:G.h+16,fill:"transparent",rx:12,onMouseEnter:()=>P(G.id),onMouseLeave:()=>P(null),onMouseUp:Z=>{Z.stopPropagation(),F()}},`drop-${G.id}`):null),K(),V()]})}function NF({name:e,id:t,color:n,description:r,isBuiltIn:s,actions:a}){return c.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),c.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),c.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),s&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&c.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),c.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:a})]})}function SC({title:e,items:t,renderActions:n}){return t.length===0?null:c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),c.jsx("div",{className:"space-y-2",children:t.map(r=>c.jsx(NF,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const Mo="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Cg="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",Fs="block text-[11px] text-text-secondary mb-0.5";function kg({variables:e,onInsert:t}){return e.length===0?null:c.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>c.jsx("button",{type:"button",onClick:()=>t(n.name),title:n.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${n.name}}}`},n.name))})}function jF({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:s,onUpdate:a,onRemove:l,onSetEntry:d}){const{color:f,name:h}=Zx(e,n);return c.jsxs("div",{className:"space-y-3 text-sm",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:f+"20",color:f},children:h}),t&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[!t&&c.jsx("button",{onClick:d,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),c.jsx("button",{onClick:l,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Type"}),c.jsx("select",{value:e.type,onChange:p=>{const g=p.target.value,_=g==="sub_agent"?"verification":"build";if(g==="agent"){const x=n.find(v=>!v.subagent);a({...e,type:g,phase:_,toolMode:(x==null?void 0:x.id)??"builder",name:(x==null?void 0:x.name)??"Agent"})}else if(g==="sub_agent"){const x=n.find(v=>v.subagent);a({...e,type:g,phase:_,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else a({...e,type:g,phase:_,name:"Shell"})},className:Cg,children:CF.map(p=>c.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Agent Type"}),c.jsx("select",{value:e.toolMode??"builder",onChange:p=>{const g=n.find(_=>_.id===p.target.value);a({...e,toolMode:p.target.value,name:(g==null?void 0:g.name)??p.target.value})},className:Cg,children:n.filter(p=>!p.subagent).map(p=>c.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Sub-Agent Type"}),c.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const g=n.find(_=>_.id===p.target.value);a({...e,subAgentType:p.target.value,name:(g==null?void 0:g.name)??p.target.value})},className:Cg,children:[c.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>c.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Prompt"}),c.jsx("textarea",{value:e.prompt??"",onChange:p=>a({...e,prompt:p.target.value||void 0}),rows:6,className:`${Mo} resize-y text-xs`,placeholder:"Injected on first entry..."}),c.jsx(kg,{variables:s,onInsert:p=>a({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Nudge Prompt"}),c.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>a({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${Mo} resize-y text-xs`,placeholder:"Injected on re-entry..."}),c.jsx(kg,{variables:s,onInsert:p=>a({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Command"}),c.jsx("textarea",{value:e.command??"",onChange:p=>a({...e,command:p.target.value}),rows:3,className:`${Mo} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),c.jsx(kg,{variables:s,onInsert:p=>a({...e,command:(e.command??"")+`{{${p}}}`})})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Timeout (ms)"}),c.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>a({...e,timeout:Number(p.target.value)}),className:`${Mo} font-mono text-xs`})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Success Codes"}),c.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>a({...e,successExitCodes:p.target.value.split(",").map(g=>Number(g.trim())).filter(g=>!isNaN(g))}),className:`${Mo} font-mono text-xs`})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fs,children:"Sub-group"}),c.jsx("input",{value:e.subGroup??"",onChange:p=>a({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Mo})]}),c.jsx("div",{className:"pt-1 border-t border-border/50",children:c.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Oo="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",wC="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",ha="block text-[11px] text-text-secondary mb-0.5";function TF({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:s,agentTypes:a,transitionIndex:l,totalTransitions:d,onUpdateCondition:f,onUpdateSubGroup:h,onDelete:p,onMoveUp:g,onMoveDown:_}){var S;const x=s&&(s.type==="sub_agent"||s.type==="agent")?a.find(w=>w.id===(s.type==="sub_agent"?s.subAgentType:s.toolMode)):void 0,v=(x==null?void 0:x.results)&&x.results.length>0;return c.jsxs("div",{className:"space-y-3 text-sm",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",l+1]}),d>1&&c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx("button",{onClick:g,disabled:l===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:c.jsx(Br,{className:"w-3 h-3",rotate:180})}),c.jsx("button",{onClick:_,disabled:l===d-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:c.jsx(Br,{className:"w-3 h-3"})})]})]}),c.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[c.jsx("span",{className:"font-medium text-text-primary",children:e}),c.jsx(ZC,{}),c.jsx("span",{className:"font-medium text-text-primary",children:t})]}),c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Condition"}),c.jsx("select",{value:n.type,onChange:w=>{f(w.target.value==="step_result"?{type:"step_result",result:"success"}:{type:w.target.value})},className:wC,children:nj.map(w=>c.jsx("option",{value:w.value,children:w.label},w.value))})]}),n.type==="step_result"&&c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Result"}),v?c.jsx("select",{value:n.result??x.results[0],onChange:w=>{f({type:"step_result",result:w.target.value})},className:wC,children:x.results.map(w=>c.jsx("option",{value:w,children:w},w))}):c.jsx("input",{type:"text",value:n.result??"success",onChange:w=>f({type:"step_result",result:w.target.value}),placeholder:"e.g. success, passed, failed",className:Oo})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Metadata Key"}),c.jsx("input",{type:"text",value:n.key??"",onChange:w=>f({...n,key:w.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Oo})]}),c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Field"}),c.jsx("input",{type:"text",value:n.field??"",onChange:w=>f({...n,field:w.target.value}),placeholder:"e.g. status",className:Oo})]}),n.type==="metadata_all_match"?c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Value"}),c.jsx("input",{type:"text",value:n.value??"",onChange:w=>f({...n,value:w.target.value}),placeholder:"e.g. passed, resolved",className:Oo})]}):c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Values (comma-separated)"}),c.jsx("input",{type:"text",value:((S=n.values)==null?void 0:S.join(", "))??"",onChange:w=>f({...n,values:w.target.value.split(",").map(k=>k.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Oo})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Sub-group"}),c.jsx("input",{type:"text",value:r??"",onChange:w=>h(w.target.value||void 0),placeholder:"e.g. build, verify",className:Oo})]}),c.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function AF(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function DF(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Us="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",CC="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",Gr="block text-[11px] text-text-secondary mb-0.5",kC=[];function rj({isOpen:e,onClose:t,initialEditId:n}){var za,Zs;const r=jt(fe=>fe.defaults),s=jt(fe=>fe.userItems),a=jt(fe=>fe.loading),l=jt(fe=>fe.templateVariables),d=jt(fe=>fe.fetchWorkflows),f=jt(fe=>fe.fetchWorkflow),h=jt(fe=>fe.fetchDefaultContent),p=jt(fe=>fe.fetchTemplateVariables),g=jt(fe=>fe.createWorkflow),_=jt(fe=>fe.updateWorkflow),x=jt(fe=>fe.deleteWorkflow),{requestDelete:v,clearConfirm:S,isConfirming:w}=sx(),[k,j]=C.useState("list"),[T,A]=C.useState(null),[P,R]=C.useState(!1),[q,J]=C.useState(null),[ne,I]=C.useState(null),[W,z]=C.useState(""),[L,U]=C.useState(""),[D,N]=C.useState(""),[F,H]=C.useState("1.0.0"),[se,B]=C.useState("#3b82f6"),[V,K]=C.useState(""),[O,Q]=C.useState(50),[G,Z]=C.useState(kC),[te,Se]=C.useState({type:"always"}),[le,Ce]=C.useState(""),[Re,Oe]=C.useState(!1),De=mt(fe=>fe.defaults),Ue=mt(fe=>fe.userItems),st=mt(fe=>fe.projectItems),it=C.useMemo(()=>[...De,...Ue,...st],[De,Ue,st]),ye=mt(fe=>fe.fetchAgents),[ze]=C.useState(null);C.useEffect(()=>{e&&(d(),p(),ye(),J(null),I(null),n?r.some(he=>he.id===n)?h(n).then(he=>{he&&ve({...he,metadata:{...he.metadata,name:he.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):f(n).then(he=>{he&&ve(he,{editingId:n,isReadOnly:!1})}):(j("list"),A(null),R(!1)))},[e,d,f,h,p,n]);const ve=(fe,he)=>{z(fe.metadata.name),U(fe.metadata.id),N(fe.metadata.description),H(fe.metadata.version),B(fe.metadata.color??"#3b82f6"),K(fe.entryStep),Q(fe.settings.maxIterations),Z(fe.steps),Se(fe.startCondition??{type:"always"}),Ce(""),(he==null?void 0:he.editingId)!==void 0&&A(he.editingId),(he==null?void 0:he.isReadOnly)!==void 0&&R(he.isReadOnly),(he==null?void 0:he.selectedNodeKey)!==void 0&&J(null),(he==null?void 0:he.selectedEdgeKey)!==void 0&&I(null),j("edit")},ue=async fe=>{const he=await f(fe);he&&ve(he,{editingId:fe,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},Ee=async()=>{var Qe;const fe=T??L;if(!fe||!W)return Ce("Name is required."),!1;if(G.length===0)return Ce("Add at least one step."),!1;let he=V;if(!he||!G.some(We=>We.id===he)){if(he=((Qe=G.find(We=>We.id))==null?void 0:Qe.id)??"",!he)return Ce("All steps need an ID."),!1;K(he)}Oe(!0),Ce("");const Te={metadata:{id:fe,name:W,description:D,version:F||"1.0.0",color:se},entryStep:he,settings:{maxIterations:O},steps:G,startCondition:te},Pe=T?await _(T,Te):await g(Te);return Oe(!1),Pe.success?(T||A(fe),!0):(Ce(Pe.error??"Failed to save."),!1)},_t=async()=>{await Ee()},Js=async()=>{await Ee()&&(n?t():j("list"))},Yt=()=>{n?t():j("list")},tl=fe=>{z(fe),T||U(AF(fe))},me=async fe=>r.some(Te=>Te.id===fe)?await h(fe):await f(fe),ke=async fe=>{const he=await me(fe);he&&ve(he,{editingId:fe,isReadOnly:!0})},$e=async fe=>{const he=await me(fe);he&&ve({...he,metadata:{...he.metadata,name:he.metadata.name+" (copy)",id:`${fe}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Xe=()=>{A(null),z(""),U(""),N(""),H("1.0.0"),B("#3b82f6"),K(""),Q(50),Z(structuredClone(kC)),Se({type:"always"}),Ce(""),J(null),I(null),R(!1),j("edit")},ut=async fe=>{await x(fe),S()},un=C.useCallback(fe=>{J(fe),I(null)},[]),Kn=C.useCallback(fe=>{I(fe),J(null)},[]),zt=q!==null?Number(q):-1,pt=zt>=0?G[zt]??null:null,On=C.useCallback(fe=>{Z(he=>he.map((Te,Pe)=>Pe===zt?fe:Te))},[zt]),xt=te.type==="step_result"?`${te.result}`:te.type==="metadata_all_match"?`${te.key??"?"}=${te.value??"?"}`:te.type==="metadata_all_in"?`${te.key??"?"} in [${((za=te.values)==null?void 0:za.join(","))??"?"}]`:tj[te.type]??te.type,zr=()=>{const fe=G.length,he=DF(G),Te=it.find(Pe=>!Pe.subagent);Z([...G,{id:he,name:(Te==null?void 0:Te.name)??"Agent",type:"agent",phase:"build",toolMode:(Te==null?void 0:Te.id)??"builder",transitions:[]}]),V||K(he),un(String(fe))},ir=C.useCallback((fe,he)=>{fe==="$start"?(K(he),Kn("start")):Z(Te=>{const Pe=Te.find(We=>We.id===fe),Qe=Pe?Pe.transitions.length:0;return Kn(`${fe}:${Qe}`),Te.map(We=>We.id===fe?{...We,transitions:[...We.transitions,{when:{type:"always"},goto:he}]}:We)})},[Kn]),Oa=fe=>{if(fe==="start")return null;const he=fe.lastIndexOf(":"),Te=fe.slice(0,he),Pe=parseInt(fe.slice(he+1));return{stepId:Te,transIdx:Pe}},$r=C.useCallback((fe,he)=>{const Te=Oa(fe);Te&&Z(Pe=>Pe.map(Qe=>Qe.id===Te.stepId?{...Qe,transitions:Qe.transitions.map((We,dt)=>dt===Te.transIdx?he(We):We)}:Qe))},[]),Ia=C.useCallback((fe,he)=>{if(fe==="start"){K(he);return}$r(fe,Te=>({...Te,goto:he}))},[$r]),Pa=C.useCallback((fe,he)=>{const Te=Oa(fe);Te&&(Z(Pe=>{const Qe=Pe.find(dt=>dt.id===Te.stepId);if(!Qe)return Pe;const We=Qe.transitions[Te.transIdx];return We?Pe.map(dt=>dt.id===Te.stepId?{...dt,transitions:dt.transitions.filter((jn,It)=>It!==Te.transIdx)}:dt.id===he?{...dt,transitions:[...dt.transitions,We]}:dt):Pe}),I(null))},[]),Zr=C.useCallback(fe=>{if(fe==="start"){K(""),I(null);return}const he=Oa(fe);he&&(Z(Te=>Te.map(Pe=>Pe.id===he.stepId?{...Pe,transitions:Pe.transitions.filter((Qe,We)=>We!==he.transIdx)}:Pe)),I(null))},[]),Ba=C.useCallback((fe,he)=>{if(fe==="start"){Se(he);return}$r(fe,Te=>({...Te,when:he}))},[$r]),Fi=C.useCallback((fe,he)=>{fe!=="start"&&$r(fe,Te=>({...Te,subGroup:he||void 0}))},[$r]),nl=fe=>Zx(fe,it).name,tu=()=>{if(!ne)return null;if(ne==="start"){const jn=G.find(It=>It.id===V);return{type:"start",fromLabel:"Start",toLabel:jn?nl(jn):"(none)",condition:te}}const fe=ne.lastIndexOf(":"),he=ne.slice(0,fe),Te=parseInt(ne.slice(fe+1)),Pe=G.find(jn=>jn.id===he);if(!Pe)return null;const Qe=Pe.transitions[Te];if(!Qe)return null;const We=G.find(jn=>jn.id===Qe.goto),dt=Qe.goto==="$done"?"Done":We?nl(We):Qe.goto;return{type:"step",fromLabel:nl(Pe),toLabel:dt,condition:Qe.when,subGroup:Qe.subGroup}};if(k==="edit"){const fe=tu();return c.jsxs(Et,{isOpen:e,onClose:Yt,title:P?W:T?"Edit Workflow":"New Workflow",size:"full",children:[le&&c.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:le}),c.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[c.jsxs("div",{className:"min-w-[140px]",children:[c.jsx("label",{className:Gr,children:"Name"}),c.jsx("input",{value:W,onChange:he=>tl(he.target.value),placeholder:"Workflow name",className:`${Us} ${P?"opacity-50":""}`,readOnly:P})]}),c.jsxs("div",{className:"min-w-[100px]",children:[c.jsx("label",{className:Gr,children:"ID"}),c.jsx("input",{value:L,readOnly:!0,className:`${Us} font-mono opacity-50`})]}),c.jsxs("div",{className:"flex-1 min-w-[140px]",children:[c.jsx("label",{className:Gr,children:"Description"}),c.jsx("input",{value:D,onChange:he=>!P&&N(he.target.value),readOnly:P,placeholder:"What does this workflow do?",className:`${Us} ${P?"opacity-50":""}`})]}),c.jsxs("div",{className:"w-20",children:[c.jsx("label",{className:Gr,children:"Max Iter."}),c.jsx("input",{type:"number",value:O,onChange:he=>!P&&Q(Number(he.target.value)),readOnly:P,className:`${Us} font-mono ${P?"opacity-50":""}`})]}),c.jsxs("div",{children:[c.jsx("label",{className:Gr,children:"Color"}),c.jsx("input",{type:"color",value:se,onChange:he=>!P&&B(he.target.value),disabled:P,className:`w-8 h-8 rounded border border-border bg-transparent ${P?"opacity-50":"cursor-pointer"}`})]})]}),c.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[c.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[c.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!P&&c.jsx("button",{onClick:zr,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),c.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[c.jsx(EF,{steps:G,entryStep:V,selectedNodeId:(pt==null?void 0:pt.id)??null,selectedEdgeKey:ne,startConditionLabel:xt,agentTypes:it,isReadOnly:P,onSelectNode:he=>{if(he===null){un(null);return}const Te=G.findIndex(Pe=>Pe.id===he);un(Te>=0?String(Te):null)},onSelectEdge:Kn,onRemoveStep:he=>{var Pe;const Te=G.findIndex(Qe=>Qe.id===he);if(Z(Qe=>Qe.filter(We=>We.id!==he)),zt===Te&&un(null),V===he){const Qe=G.filter(We=>We.id!==he);K(((Pe=Qe[0])==null?void 0:Pe.id)??"")}},onCreateTransition:ir,onReconnectTo:Ia,onReconnectFrom:Pa,onDeleteTransition:Zr}),G.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[c.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),c.jsx("button",{onClick:zr,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),c.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[c.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:c.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),c.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:P&&(fe||pt)?c.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):fe?fe.type==="start"?c.jsxs("div",{className:"space-y-3 text-sm",children:[c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),V&&c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[c.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),c.jsx(ZC,{}),c.jsx("span",{className:"text-text-primary font-medium",children:fe.toLabel})]}),c.jsxs("div",{children:[c.jsx("label",{className:Gr,children:"Activation Condition"}),c.jsx("select",{value:te.type,onChange:he=>Se(he.target.value==="step_result"?{type:"step_result",result:"success"}:he.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:he.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:he.target.value}),className:CC,children:nj.map(he=>c.jsx("option",{value:he.value,children:he.label},he.value))})]}),te.type==="step_result"&&c.jsxs("div",{children:[c.jsx("label",{className:Gr,children:"Result"}),V&&(()=>{const he=G.find(We=>We.id===V),Te=he&&(he.type==="sub_agent"||he.type==="agent")?it.find(We=>We.id===(he.type==="sub_agent"?he.subAgentType:he.toolMode)):void 0,Pe=(Te==null?void 0:Te.results)&&Te.results.length>0,Qe=(Te==null?void 0:Te.results)??[];return Pe?c.jsx("select",{value:te.result??Qe[0],onChange:We=>Se({type:"step_result",result:We.target.value}),className:CC,children:Qe.map(We=>c.jsx("option",{value:We,children:We},We))}):c.jsx("input",{type:"text",value:te.result??"success",onChange:We=>Se({type:"step_result",result:We.target.value}),placeholder:"e.g. success, passed, failed",className:Us})})()]}),(te.type==="metadata_all_match"||te.type==="metadata_all_in")&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:Gr,children:"Metadata Key"}),c.jsx("input",{type:"text",value:te.key??"",onChange:he=>Se({...te,key:he.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Us})]}),c.jsxs("div",{children:[c.jsx("label",{className:Gr,children:"Field"}),c.jsx("input",{type:"text",value:te.field??"",onChange:he=>Se({...te,field:he.target.value}),placeholder:"e.g. status",className:Us})]}),te.type==="metadata_all_match"?c.jsxs("div",{children:[c.jsx("label",{className:Gr,children:"Value"}),c.jsx("input",{type:"text",value:te.value??"",onChange:he=>Se({...te,value:he.target.value}),placeholder:"e.g. passed, resolved",className:Us})]}):c.jsxs("div",{children:[c.jsx("label",{className:Gr,children:"Values (comma-separated)"}),c.jsx("input",{type:"text",value:((Zs=te.values)==null?void 0:Zs.join(", "))??"",onChange:he=>Se({...te,values:he.target.value.split(",").map(Te=>Te.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Us})]})]}),c.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):(()=>{const he=Oa(ne),Te=he==null?void 0:he.stepId,Pe=(he==null?void 0:he.transIdx)??0,Qe=Te?G.find(dt=>dt.id===Te):void 0,We=(Qe==null?void 0:Qe.transitions.length)??0;return c.jsx(TF,{fromLabel:fe.fromLabel,toLabel:fe.toLabel,condition:fe.condition,subGroup:"subGroup"in fe?fe.subGroup:void 0,fromStep:fe.type==="step"?G.find(dt=>dt.id===fe.fromLabel):void 0,agentTypes:it,transitionIndex:Pe,totalTransitions:We,onUpdateCondition:dt=>Ba(ne,dt),onUpdateSubGroup:dt=>Fi(ne,dt),onDelete:()=>Zr(ne),onMoveUp:()=>{Z(dt=>{const jn=dt.find(yt=>yt.id===Te);if(!jn||Pe===0)return dt;const It=[...jn.transitions];return[It[Pe-1],It[Pe]]=[It[Pe],It[Pe-1]],dt.map(yt=>yt.id===Te?{...yt,transitions:It}:yt)}),I(`${Te}:${Pe-1}`)},onMoveDown:()=>{Z(dt=>{const jn=dt.find(yt=>yt.id===Te);if(!jn||Pe===jn.transitions.length-1)return dt;const It=[...jn.transitions];return[It[Pe],It[Pe+1]]=[It[Pe+1],It[Pe]],dt.map(yt=>yt.id===Te?{...yt,transitions:It}:yt)}),I(`${Te}:${Pe+1}`)}})})():pt?c.jsx(jF,{step:pt,isEntry:pt.id===V,agentTypes:it,transitionCount:pt.transitions.length,templateVariables:l,onUpdate:On,onRemove:()=>{var he;if(pt&&(Z(G.filter((Te,Pe)=>Pe!==zt)),un(null),V===pt.id)){const Te=G.filter((Pe,Qe)=>Qe!==zt);K(((he=Te[0])==null?void 0:he.id)??"")}},onSetEntry:()=>K(pt.id)}):c.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",c.jsx("br",{}),"Drag from a port to connect."]})})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[c.jsx(Ze,{variant:"secondary",onClick:Yt,children:"Close"}),P?c.jsx(Ze,{variant:"primary",onClick:()=>{z(W+" (copy)"),U(`${T}-copy-${Date.now()}`),A(null),R(!1)},children:"Duplicate & Customize"}):c.jsxs(c.Fragment,{children:[c.jsx(Ze,{variant:"primary",onClick:_t,children:"Save"}),c.jsx(Ze,{variant:"primary",onClick:Js,children:"Save & Close"})]})]})]})}return c.jsx(Et,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:c.jsx(lk,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Xe,loading:a,hasItems:r.length>0||s.length>0,children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(SC,{title:"Built-in",items:r,renderActions:fe=>c.jsx(c.Fragment,{children:c.jsx(Oi,{onClick:()=>$e(fe.id),children:c.jsx(Ec,{})})})}),c.jsx(SC,{title:"Custom",items:s,renderActions:fe=>c.jsxs(c.Fragment,{children:[c.jsx(Oi,{onClick:()=>ke(fe.id),children:c.jsx(Ec,{})}),c.jsx(Oi,{onClick:()=>ue(fe.id),children:c.jsx("span",{className:"text-[10px]",children:"Edit"})}),c.jsx(Qd,{onClick:()=>$e(fe.id)}),w(fe.id,"delete")?c.jsx(ix,{onConfirm:()=>ut(fe.id),onCancel:S}):c.jsx(ax,{onClick:()=>v(fe.id)})]})})]})})})}function sj(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(s=>{for(const a of r){let l=0;for(let d=0;d<a.length&&l<s.length;d++)a[d]===s[l]&&l++;if(l===s.length)return!0}return!1})}function ij(e,t,n,r,s){switch(e.key){case"ArrowDown":e.preventDefault(),n(a=>Math.min(a+1,t));break;case"ArrowUp":e.preventDefault(),n(a=>Math.max(a-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),s();break}}function LF(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function RF({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:s,onCloseCompleteAction:a,textareaContent:l,onSearchMessages:d,onToggleAutoScroll:f,isAutoScrollActive:h}){const[,p]=Jr(),g=mn(Q=>Q.fetchCommands),_=jt(Q=>Q.fetchWorkflows),x=mt(Q=>Q.fetchAgents),v=mn(Q=>Q.defaults),S=mn(Q=>Q.userItems),w=mn(Q=>Q.projectItems),k=jt(Q=>Q.defaults),j=jt(Q=>Q.userItems),T=jt(Q=>Q.projectItems),A=mt(Q=>Q.defaults),P=mt(Q=>Q.userItems),R=mt(Q=>Q.projectItems),q=xe(Q=>{var G;return(G=Q.currentSession)==null?void 0:G.mode}),J=xe(Q=>{var G;return((G=Q.currentSession)==null?void 0:G.dangerLevel)??"normal"}),ne=xe(Q=>Q.switchMode),I=xe(Q=>Q.switchDangerLevel),W=xe(Q=>{var G;return(G=Q.currentSession)==null?void 0:G.projectId}),z=C.useRef(void 0),[L,U]=C.useState(""),[D,N]=C.useState(0),F=C.useRef(null),H=C.useRef(!1);C.useEffect(()=>{e&&(H.current=!0)},[e]),C.useEffect(()=>{if(e){g(),_(),x(),U(""),N(0);const Q=setTimeout(()=>{var G;return(G=F.current)==null?void 0:G.focus()},50);return()=>clearTimeout(Q)}},[e,g,_,x]),C.useEffect(()=>{var Q;!e&&H.current&&(n==null||n(),(Q=z.current)==null||Q.call(z),z.current=void 0)},[e,n]);const se=(Q,G)=>{const Z=new Set(G.map(te=>te.id));return[...Q.filter(te=>!Z.has(te.id)),...G]},V=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const Q=W??LF(window.location.pathname);Q&&p(`/p/${Q}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{z.current=a,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),d==null||d()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),f==null||f(!h)}},...se(se(A,P),R).filter(Q=>!Q.subagent&&Q.id!==q).map(Q=>({id:Q.id,name:Q.name,prefix:"Agent > Switch to",action:()=>ne(Q.id)})),...se(se(v,S),w).map(Q=>({id:Q.id,name:Q.name,prefix:"Command > Launch",action:()=>r(Q.id,l)})),...se(se(k,j),T).map(Q=>({id:Q.id,name:Q.name,prefix:"Workflow > Run",action:()=>s(Q.id)})),...["normal","dangerous"].filter(Q=>Q!==J).map(Q=>({id:Q,name:Q.charAt(0).toUpperCase()+Q.slice(1),prefix:"Mode > Switch to",action:()=>I(Q)}))].filter(Q=>sj(`${Q.prefix} ${Q.name}`,L)),K=V.length-1,O=Q=>{ij(Q,K,N,()=>{var G;(G=V[D])==null||G.action(),t()},t)};return e?La.createPortal(c.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),c.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[c.jsx("input",{ref:F,type:"text",value:L,onChange:Q=>{U(Q.target.value),N(0)},onKeyDown:O,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),c.jsx(nx,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),c.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:V.length===0?c.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:v.length+S.length+k.length+j.length>0?"No matches":"No agents, commands, or workflows yet"}):V.map((Q,G)=>c.jsxs("button",{type:"button",onClick:()=>{Q.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${G===D?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[c.jsxs("span",{className:"text-text-muted font-normal",children:[Q.prefix," "]}),c.jsx("span",{children:Q.name})]},Q.id))})]})]}),document.body):null}function MF(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 s=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),d=String(t.getHours()).padStart(2,"0"),f=String(t.getMinutes()).padStart(2,"0");return`${s}/${a}/${l} ${d}:${f}`}function OF(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 IF(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const s=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!s?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function PF(e){var n,r;if(e.type!=="message")return c.jsx(AS,{className:"w-3.5 h-3.5"});const t=e.message;return t.role==="assistant"?(n=t.thinkingContent)!=null&&n.trim()&&!((r=t.content)!=null&&r.trim())?c.jsx(iL,{className:"w-3.5 h-3.5"}):c.jsx(AS,{className:"w-3.5 h-3.5"}):c.jsx(sL,{className:"w-3.5 h-3.5"})}function EC(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",s=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 s?s.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const a=s.slice(0,200);return a.length<s.length?`${a}...`:a}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:e.type==="criteria-batch"?"Acceptance Criteria":""}function BF({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[s,a]=C.useState(""),[l,d]=C.useState(0),f=C.useRef(null),h=C.useRef(null),p=C.useMemo(()=>n.filter(w=>{var k,j;return!(w.type==="context-divider"||w.type==="message"&&w.message.role==="assistant"&&!((k=w.message.content)!=null&&k.trim())&&!((j=w.message.thinkingContent)!=null&&j.trim()))}),[n]),g=C.useMemo(()=>s?p.filter(w=>{const k=EC(w);return sj(k,s)}):p,[p,s]),_=g.length-1;C.useEffect(()=>{if(e){a(""),d(0);const w=setTimeout(()=>{var k;return(k=f.current)==null?void 0:k.focus()},50);return()=>clearTimeout(w)}},[e]),C.useEffect(()=>{e&&h.current&&(h.current.scrollTop=h.current.scrollHeight)},[e]);const x=w=>{ij(w,_,d,()=>{const k=g[l];if(k){const j=n.indexOf(k);j>=0&&r(j),t()}},t)},v=w=>{const k=n.indexOf(w);k>=0&&r(k),t()},S=w=>n.indexOf(w);return e?La.createPortal(c.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),c.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[c.jsx(ex,{}),c.jsx("input",{ref:f,type:"text",value:s,onChange:w=>{a(w.target.value),d(0)},onKeyDown:x,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),c.jsx("button",{type:"button",onClick:t,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Close",children:c.jsx(Hc,{className:"w-4 h-4"})})]}),c.jsx("div",{ref:h,className:"overflow-y-auto max-h-[60vh] p-2",children:g.length===0?c.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:p.length>0?"No matches":"No messages yet"}):g.map((w,k)=>{const j=S(w),T=PF(w),A=EC(w),P=IF(w),R=OF(w),q=w.type==="message"&&w.message.role==="user";return c.jsx("button",{type:"button",onClick:()=>v(w),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${k===l?"bg-accent-primary/20 text-text-primary":q?"bg-accent-primary/5 text-text-secondary hover:bg-accent-primary/10 hover:text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[c.jsx("span",{className:"flex-shrink-0",children:T}),c.jsx("span",{className:`truncate flex-1 ${P}`,children:A})]}),R&&c.jsx("span",{className:"text-text-muted text-xs shrink-0",children:MF(R)})]})},`${j}-${w.type}`)})})]})]}),document.body):null}function zF({attachment:e,onRemove:t}){const n=r=>r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`;return c.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[c.jsx(qc,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),c.jsx("img",{src:e.data,alt:e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}),c.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),c.jsx("div",{className:"text-[10px] text-text-muted",children:n(e.size)})]})}function $F({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:s}){const a=C.useRef(null),l=C.useRef(null);C.useEffect(()=>{l.current&&a.current&&l.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const d=h=>{switch(h.key){case"Enter":h.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":h.preventDefault(),r();break;case"ArrowUp":h.preventDefault(),s("up");break;case"ArrowDown":h.preventDefault(),s("down");break}},f=h=>{n(h)};return c.jsx("div",{ref:a,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg overflow-y-auto max-h-64",onKeyDown:d,children:e.map((h,p)=>c.jsxs("div",{ref:p===t?l:null,role:"listitem",onClick:()=>f(h.content),className:`
311
- p-2 rounded cursor-pointer transition-colors
312
- ${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
313
- `,children:[c.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&c.jsxs(c.Fragment,{children:[" | ",c.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),c.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function HF(){const e=LD(),t=e?"bg-amber-400":"bg-accent-primary";return c.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("span",{className:"flex gap-0.5",children:[c.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),c.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),c.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),c.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&c.jsx("span",{className:"text-text-muted",children:"esc to interrupt"})]})}const FF={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function UF(e,t={}){const n={...FF,...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 s=await e.arrayBuffer(),a=XF(s),l=`data:${e.type};base64,${a}`,d=await aj(l);return{dataUrl:l,mimeType:e.type,size:e.size,width:d.width,height:d.height}}return await VF(e,n)}async function VF(e,t){const n=await GF(e),r=await aj(n),{width:s,height:a}=WF(r.width,r.height,t.maxWidth,t.maxHeight),l=qF();l.width=s,l.height=a;const d=l.getContext("2d");if(!d)throw new Error("Failed to get canvas context");d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(r,0,0,s,a);let f=t.quality,h="";for(let g=0;g<10&&(h=l.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,f),!(NC(h)<=t.maxSizeBytes||f<=.3));g++)f-=.1;const p=NC(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:s,height:a}}function WF(e,t,n,r){const s=e/t;return e>t&&e>n?{width:n,height:Math.round(n/s)}:t>e&&t>r?{width:Math.round(r*s),height:r}:{width:e,height:t}}function GF(e){return new Promise((t,n)=>{const r=YF(),s=new r;s.onload=()=>t(s.result),s.onerror=()=>n(new Error("Failed to read file")),s.readAsDataURL(e)})}function aj(e){return new Promise((t,n)=>{const r=KF(),s=new r;s.onload=()=>t(s),s.onerror=()=>n(new Error("Failed to load image")),s.src=e})}function qF(){var t;const e=ey();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function KF(){const e=ey();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function YF(){const e=ey();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function ey(){return globalThis}function XF(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const s=t[r];s!==void 0&&(n+=String.fromCharCode(s))}return btoa(n)}function NC(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}function QF(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function JF(e,t=50*1024*1024){return e.size>t?{valid:!1,error:`Image file is too large (${jC(e.size)}). Maximum size is ${jC(t)}.`}:{valid:!0}}function jC(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function Eg(e,t,n,r={}){const{maxSizeBytes:s=50*1024*1024,filename:a}=r;if(!QF(e)){n(`Unsupported file type: ${e.type}. Only PNG, JPG, and GIF are supported.`);return}const l=JF(e,s);if(!l.valid){n(l.error??"Image file is too large");return}try{const d=await UF(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),f={id:GC(),filename:a??e.name,mimeType:d.mimeType,size:d.size,data:d.dataUrl};t(f)}catch(d){const f=d instanceof Error?d.message??"Failed to process image":"Failed to process image";n(f)}}function ZF({children:e}){return La.createPortal(e,document.body)}function eU(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 tU({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:s,onAttach:a,textareaContent:l,attachments:d}){const[f,h]=C.useState(!1),[p,g]=C.useState("commands"),[_,x]=C.useState(""),[v,S]=C.useState(0),[w,k]=C.useState(null),[j,T]=C.useState(null),A=C.useRef(null),P=C.useRef(null),R=mn(K=>K.defaults),q=mn(K=>K.userItems),J=mn(K=>K.fetchCommands),ne=jt(K=>K.defaults),I=jt(K=>K.userItems),W=jt(K=>K.fetchWorkflows),z=[...R,...q],L=[...ne,...I];C.useEffect(()=>{f&&(p==="commands"?J():p==="workflows"&&W())},[f,p,J,W]),C.useEffect(()=>{f&&(x(""),S(0),requestAnimationFrame(()=>{var K;return(K=A.current)==null?void 0:K.focus()}))},[f,p]),C.useEffect(()=>{if(!f)return;const K=O=>{var Q;(Q=P.current)!=null&&Q.contains(O.target)||h(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[f]);const U=K=>{switch(K.key){case"ArrowDown":K.preventDefault(),S(O=>{const G=(p==="commands"?z:L).filter(Z=>{const te=_.toLowerCase();return!te||Z.name.toLowerCase().includes(te)});return Math.min(O+1,G.length-1)});break;case"ArrowUp":K.preventDefault(),S(O=>Math.max(O-1,0));break;case"Enter":K.preventDefault();break;case"Escape":K.preventDefault(),h(!1);break}},D=K=>{x(K),S(0)},N=z.filter(K=>!_||K.name.toLowerCase().includes(_.toLowerCase())),F=L.filter(K=>!_||K.name.toLowerCase().includes(_.toLowerCase())),H=async K=>{const O=await mn.getState().fetchCommand(K);O&&e(O.prompt,O.metadata.agentMode,l,d),h(!1)},se=K=>{t(K),h(!1)},B=(K,O)=>{O.stopPropagation(),h(!1),k(K)},V=(K,O)=>{O.stopPropagation(),h(!1),T(K)};return c.jsxs("div",{ref:P,className:"relative",children:[c.jsx("button",{type:"button",onClick:()=>h(!f),className:"px-1.5 py-2 rounded-r bg-bg-secondary text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors border-l border-border/50",title:"More options",children:c.jsx(tk,{className:"w-4 h-4"})}),f&&c.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 bg-bg-secondary border border-border rounded-lg shadow-xl z-50",children:[c.jsxs("div",{className:"flex border-b border-border",children:[c.jsx("button",{type:"button",onClick:()=>{g("commands"),x(""),S(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),c.jsx("button",{type:"button",onClick:()=>{g("workflows"),x(""),S(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),c.jsx("button",{type:"button",onClick:()=>g("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&c.jsx("div",{className:"p-2 border-b border-border",children:c.jsx("input",{ref:A,value:_,onChange:K=>D(K.target.value),onKeyDown:U,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),c.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:p==="commands"?N.length===0?c.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:z.length===0?"No commands yet":"No matches"}):N.map((K,O)=>c.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${O===v?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[c.jsx("button",{type:"button",onClick:()=>H(K.id),className:"flex-1 text-left",children:c.jsx("div",{className:"text-sm text-text-primary font-medium",children:K.name})}),c.jsx(Oi,{className:"opacity-0 group-hover:opacity-100",onClick:Q=>B(K.id,Q)})]},K.id)):p==="workflows"?F.length===0?c.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:L.length===0?"No workflows yet":"No matches"}):F.map((K,O)=>{const Q=eU(K),G=K.color??"#3b82f6";return c.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${O===v?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[c.jsxs("button",{type:"button",onClick:()=>se(K.id),className:"flex-1 text-left flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:G}}),c.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:K.name}),Q!==null&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Q?"#22c55e":"#6b7280"},title:Q?"Entry condition met":"Entry condition not met"})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[K.subGroups&&K.subGroups.length>0&&c.jsx(nU,{subGroups:K.subGroups,onSelect:Z=>{h(!1),n(K.id,Z)}}),c.jsx(Oi,{className:"opacity-0 group-hover:opacity-100",onClick:Z=>V(K.id,Z)})]})]},K.id)}):c.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[c.jsxs("button",{type:"button",onClick:()=>{a(),h(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[c.jsx(zD,{className:"w-4 h-4"}),c.jsx("span",{className:"text-sm font-medium",children:"Attach image"})]}),c.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&c.jsx("div",{className:"border-t border-border p-1",children:c.jsx("button",{type:"button",onClick:()=>{h(!1),p==="commands"?r():s()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),c.jsx(ej,{isOpen:!!w,onClose:()=>k(null),initialEditId:w}),c.jsx(rj,{isOpen:!!j,onClose:()=>T(null),initialEditId:j})]})}function nU({subGroups:e,onSelect:t}){const[n,r]=C.useState(!1),[s,a]=C.useState({top:0,right:0}),l=C.useRef(null),d=C.useRef(null);ZN(d,()=>r(!1),n);const f=h=>{if(h.stopPropagation(),!n&&l.current){const p=l.current.getBoundingClientRect();a({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return c.jsxs(c.Fragment,{children:[c.jsx("button",{ref:l,type:"button",onClick:f,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&c.jsx(ZF,{children:c.jsx("div",{ref:d,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:s.top,right:s.right},children:e.map(h=>c.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(h)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:h},h))})})]})}function rU({messages:e,onCancel:t}){return e.length===0?null:c.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>c.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${n.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[c.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),c.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),c.jsx(qc,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function sU({agent:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:s,onDuplicate:a,onDelete:l}){return c.jsxs(dk,{isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:s,onDuplicate:a,onDelete:l,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),c.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),c.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),e.description&&c.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),c.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[e.allowedTools.slice(0,5).map(d=>c.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:d},d)),e.allowedTools.length>5&&c.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.allowedTools.length-5," more"]})]})]})}function TC({title:e,agents:t,subagents:n,isBuiltIn:r,onView:s,onDuplicate:a,onEdit:l,onDelete:d}){if(t.length===0&&n.length===0)return null;const f=h=>c.jsx(sU,{agent:h,isBuiltIn:r,isConfirmingDelete:!1,onView:()=>s(h.id),onEdit:r?void 0:()=>l==null?void 0:l(h.id),onDuplicate:()=>a(h.id),onDelete:r?void 0:()=>d==null?void 0:d(h.id)},h.id);return c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),c.jsxs("div",{className:"space-y-2",children:[t.map(f),n.length>0&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:"Sub-agents"}),c.jsx("div",{className:"space-y-2",children:n.map(f)})]})]})]})}function iU(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const s=n.slice(0,r),l=n.slice(r+1).split(",").filter(Boolean);t.set(s,new Set(l))}}return t}function Ng(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function aU({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:s,formColor:a,formPrompt:l,formError:d,saving:f,isReadOnly:h,availableTools:p,onNameChange:g,onIdChange:_,onDescriptionChange:x,onSubagentChange:v,onColorChange:S,onPromptChange:w,onSave:k,onCancel:j,onDuplicate:T}){const A=iU(s),P=(J,ne)=>{const I=new Map(A),W=I.get(J)||new Set,z=new Set(W);z.has(ne)?z.delete(ne):z.add(ne),z.size===0?I.set(J,new Set):I.set(J,z),q(Ng(I))},R=J=>{const ne=new Map(A);ne.has(J)?ne.delete(J):ne.set(J,new Set),q(Ng(ne))},q=J=>{};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"space-y-3",children:[d&&c.jsx(ox,{message:d}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),c.jsx(ka,{label:"ID",value:t,onChange:_,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:"Description",value:n,onChange:x,placeholder:"What this agent does",readOnly:h}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),c.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[c.jsx("button",{onClick:()=>!h&&v(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),c.jsx("button",{onClick:()=>!h&&v(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${h?"pointer-events-none opacity-60":""}`,children:"Top-level"}),c.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[c.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),c.jsx("input",{type:"color",value:a,onChange:J=>!h&&S(J.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),c.jsx("div",{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32 overflow-y-auto",children:p.map(J=>{const ne=A.has(J.name),I=J.actions.length>0,W=A.get(J.name)||new Set;return I?h?c.jsxs("button",{className:"px-1.5 py-0.5 rounded text-xs font-mono flex items-center gap-1 bg-bg-primary text-text-muted pointer-events-none opacity-60",children:[c.jsx("span",{children:J.name}),c.jsx("span",{className:"text-[10px]",children:"*"})]},J.name):c.jsx(Gc,{trigger:c.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${ne?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[c.jsx("span",{children:J.name}),I&&c.jsx("span",{className:`text-[10px] ${ne&&W.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...J.actions.map(z=>({label:c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${J.name}-${z}`,children:[c.jsx("input",{type:"checkbox",id:`${J.name}-${z}`,checked:W.has(z),onChange:()=>P(J.name,z),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),c.jsx("span",{children:z})]}),closeOnClick:!1})),{label:ne?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(ne)R(J.name);else{const z=new Map(A);z.set(J.name,new Set(J.actions)),q(Ng(z))}}}]},J.name):c.jsx("button",{onClick:()=>!h&&R(J.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${ne?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:c.jsx("span",{children:J.name})},J.name)})})]})]}),c.jsxs("div",{className:"flex-1 min-h-[150px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),c.jsx("textarea",{value:l,onChange:J=>!h&&w(J.target.value),readOnly:h,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"opacity-60":""}`})]}),c.jsx(gL,{onCancel:j,onSave:k,saving:f,saveDisabled:!e||!l||h}),h&&c.jsx("div",{className:"flex justify-end mt-2",children:c.jsx("button",{onClick:T,className:"px-3 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors",children:"Duplicate & Customize"})})]})}function oU(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function lU({isOpen:e,onClose:t,initialEditId:n}){const r=mt(ye=>ye.defaults),s=mt(ye=>ye.userItems),a=mt(ye=>ye.loading),l=mt(ye=>ye.fetchAgents),d=mt(ye=>ye.fetchAgent),f=mt(ye=>ye.fetchDefaultContent),h=mt(ye=>ye.createAgent),p=mt(ye=>ye.updateAgent),g=mt(ye=>ye.deleteAgent),[_,x]=C.useState("list"),[v,S]=C.useState(null),[w,k]=C.useState(!1),[j,T]=C.useState(""),[A,P]=C.useState(""),[R,q]=C.useState(""),[J,ne]=C.useState(!0),[I,W]=C.useState([]),[z,L]=C.useState("#6b7280"),[U,D]=C.useState(""),[N,F]=C.useState(""),[H,se]=C.useState(!1),[B,V]=C.useState([]),K=ye=>{T(ye.metadata.name),P(ye.metadata.id),q(ye.metadata.description),ne(ye.metadata.subagent),W(ye.metadata.allowedTools),L(ye.metadata.color??"#6b7280"),D(ye.prompt),F("")},O=(ye,ze,ve)=>{T(ye.metadata.name+" (copy)"),P(`${ze}-copy-${Date.now()}`),q(ye.metadata.description),ne(ye.metadata.subagent),W(ye.metadata.allowedTools),L(ye.metadata.color??"#6b7280"),D(ye.prompt),F(""),S(null),k(!1),x("edit")},Q=(ye,ze)=>{K(ye),S(ze),k(!0),x("edit")};C.useEffect(()=>{e&&(l(),Ne("/api/tools").then(ye=>ye.json()).then(ye=>V(ye.tools||[])).catch(()=>V([])),n?r.some(ze=>ze.id===n)?f(n).then(ze=>{ze&&O(ze,n)}):d(n).then(ze=>{ze&&(K(ze),S(n),k(!1),x("edit"))}):(x("list"),S(null),k(!1)))},[e,l,d,f,n]);const G=async ye=>{if(r.some(ve=>ve.id===ye)){const ve=await f(ye);if(!ve)return;Q(ve,ye)}else{const ve=await d(ye);if(!ve)return;Q(ve,ye)}},Z=async ye=>{const ze=await f(ye);ze&&O(ze,ye)},te=()=>{S(null),T(""),P(""),q(""),ne(!0),W(["read_file"]),L("#6b7280"),D(""),F(""),k(!1),x("edit")},Se=async ye=>{const ze=await d(ye);ze&&(K(ze),S(ye),k(!1),x("edit"))},le=async ye=>{await g(ye)},Ce=async()=>{const ye=v??A;if(!ye||!j||!U){F("Name and prompt are required.");return}se(!0),F("");const ze={metadata:{id:ye,name:j,description:R,subagent:J,allowedTools:I,color:z},prompt:U},ve=v?await p(v,ze):await h(ze);if(se(!1),!ve.success){F(ve.error??"Failed to save agent.");return}n?t():x("list")},Re=()=>{n?t():(x("list"),k(!1))},Oe=ye=>{T(ye),v||P(oU(ye))},De=r.filter(ye=>ye.subagent),Ue=r.filter(ye=>!ye.subagent),st=s.filter(ye=>ye.subagent),it=s.filter(ye=>!ye.subagent);return _==="edit"?c.jsx(Et,{isOpen:e,onClose:Re,title:w?`${j}`:v?"Edit Agent":"New Agent",size:"xl",children:c.jsx(aU,{formName:j,formId:A,formDescription:R,formSubagent:J,formTools:I,formColor:z,formPrompt:U,formError:N,saving:H,isReadOnly:w,availableTools:B,onNameChange:Oe,onIdChange:P,onDescriptionChange:q,onSubagentChange:ne,onColorChange:L,onPromptChange:D,onSave:Ce,onCancel:Re,onDuplicate:()=>{T(j+" (copy)"),P(`${v}-copy-${Date.now()}`),S(null),k(!1)}})}):c.jsx(Et,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:c.jsx(lk,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:te,loading:a,hasItems:r.length>0||s.length>0,children:c.jsxs("div",{className:"space-y-4",children:[r.length>0&&c.jsx(TC,{title:"Built-in",agents:Ue,subagents:De,isBuiltIn:!0,onView:G,onDuplicate:Z}),s.length>0&&c.jsx(TC,{title:"Custom",agents:it,subagents:st,isBuiltIn:!1,onView:G,onDuplicate:Z,onEdit:Se,onDelete:le})]})})})}function cU(){const e=xe(j=>{var T;return(T=j.currentSession)==null?void 0:T.mode}),t=xe(j=>j.switchMode),n=mt(j=>j.defaults),r=mt(j=>j.userItems),s=mt(j=>j.fetchAgents),a=[...n,...r],[l,d]=C.useState(!1),[f,h]=C.useState(!1),[p,g]=C.useState(null),_=C.useRef(null);C.useEffect(()=>{s()},[s]),C.useEffect(()=>{function j(T){_.current&&!_.current.contains(T.target)&&d(!1)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const x=tx();if(!e)return null;const v=a.filter(j=>!j.subagent),S=v.find(j=>j.id===e),w=(S==null?void 0:S.name)??e,k=Ac(a,e);return c.jsxs("div",{className:"relative",ref:_,children:[c.jsxs("button",{type:"button",onClick:()=>d(!l),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[c.jsx("span",{className:"text-sm font-medium",style:{color:k},children:w}),c.jsx(Br,{className:`w-3 h-3 text-text-muted transition-transform ${l?"rotate-180":""}`})]}),l&&v.length>0&&c.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[v.map((j,T)=>{const A=j.id===e,P=Ac(a,j.id),R=x.agentSwitching[T],q=R?sk(R):null;return c.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${A?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[c.jsxs("button",{type:"button",onClick:()=>{A||t(j.id),d(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[c.jsx("span",{className:"font-medium truncate",style:{color:P},children:j.name}),A&&c.jsx(gs,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),q&&c.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:q})]},j.id)}),c.jsx("div",{className:"border-t border-border p-1",children:c.jsx("button",{type:"button",onClick:()=>{d(!1),h(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),c.jsx(lU,{isOpen:f,onClose:()=>{h(!1),g(null)},initialEditId:p})]})}function uU(){const e=xe(r=>r.currentSession),t=xe(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return c.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[c.jsx("button",{type:"button",onClick:()=>t("normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),c.jsx("button",{type:"button",onClick:()=>t("dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})}function dU({content:e,children:t,position:n="top",delay:r=200}){const[s,a]=C.useState(!1),[l,d]=C.useState({top:0,left:0}),f=C.useRef(void 0),h=C.useRef(null);C.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const p=()=>{f.current=setTimeout(()=>{if(h.current){const x=h.current.getBoundingClientRect();d({top:x.top,left:x.left+x.width/2})}a(!0)},r)},g=()=>{f.current&&clearTimeout(f.current),a(!1)},_=(()=>{switch(n){case"top":return{top:l.top-8,left:l.left,tx:"-50%",ty:"-100%"};case"bottom":return{top:l.top+8,left:l.left,tx:"-50%",ty:"0%"};case"left":return{top:l.top,left:l.left-8,tx:"-100%",ty:"-50%"};case"right":return{top:l.top,left:l.left+8,tx:"0%",ty:"-50%"}}})();return c.jsxs(c.Fragment,{children:[c.jsx("span",{ref:h,className:"inline-flex",onMouseEnter:p,onMouseLeave:g,onFocus:p,onBlur:g,children:t}),s&&La.createPortal(c.jsx("div",{className:"fixed z-[9999] px-4 py-3 text-sm text-text-primary bg-bg-secondary border border-border rounded-lg shadow-xl max-w-sm break-words pointer-events-none",style:{top:_.top,left:_.left,transform:`translate(${_.tx}, ${_.ty})`},children:e}),document.body)]})}function jg(e){return{contextWindow:e.contextWindow,temperature:e.temperature??null,topP:e.topP??null,topK:e.topK??null,maxTokens:e.maxTokens??null,supportsVision:e.supportsVision??null}}function hU({label:e,children:t}){return c.jsxs("div",{className:"space-y-3",children:[c.jsx("h4",{className:"text-sm font-medium text-text-secondary border-b border-border/50 pb-1",children:e}),t]})}function uc({label:e,value:t,onChange:n,min:r,max:s,step:a=1,helpText:l,defaultValue:d,profileDefault:f,tooltip:h}){const[p,g]=C.useState((t==null?void 0:t.toString())??""),[_,x]=C.useState(t===null);C.useEffect(()=>{g((t==null?void 0:t.toString())??""),x(t===null)},[t]);const v=k=>{if(g(k),k==="")n(null);else{const j=parseFloat(k);isNaN(j)||n(j)}},S=()=>{_?(x(!1),d!==void 0&&(g(d.toString()),n(d))):(x(!0),n(null))},w=c.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary mb-1",children:[h&&c.jsx(dU,{content:h,children:c.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-xs text-text-muted hover:text-text-secondary cursor-help rounded-full border border-border/50",children:"?"})}),e,c.jsx("button",{type:"button",onClick:S,className:`text-xs px-1.5 py-0.5 rounded border ${_?"border-accent-primary/50 bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-secondary"}`,title:_?"Click to set a custom value":"Click to use default",children:_?"default":"custom"})]});return c.jsxs("div",{children:[w,c.jsx("input",{type:"number",min:r,max:s,step:a,value:p,readOnly:_,onChange:k=>v(k.target.value),onClick:()=>_&&S(),placeholder:_?`${f!==void 0?f:"Using default"} (click to edit)`:"",className:`w-full bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary focus:outline-none focus:border-accent-primary ${_?"opacity-50 cursor-pointer":""}`}),l&&c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.jsx("p",{className:"text-xs text-text-muted",children:l}),f!==void 0&&c.jsxs("span",{className:"text-xs text-text-muted/60",children:["(default: ",f,")"]})]}),!l&&f!==void 0&&c.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Profile default: ",f]})]})}function fU({isOpen:e,onClose:t,providerId:n,model:r}){const[s,a]=C.useState(()=>jg(r)),[l,d]=C.useState(!1),f=Ot(g=>g.updateModelSettings);C.useEffect(()=>{a(jg(r))},[r]);const h=async()=>{if(s.contextWindow<1024||s.contextWindow>1e7)return;d(!0);const g=s.temperature!==(r.temperature??null)||s.topP!==(r.topP??null)||s.topK!==(r.topK??null)||s.maxTokens!==(r.maxTokens??null)||s.supportsVision!==(r.supportsVision??null);await f(n,r.id,{contextWindow:s.contextWindow,...g&&{temperature:s.temperature,topP:s.topP,topK:s.topK,maxTokens:s.maxTokens,supportsVision:s.supportsVision??void 0}}),d(!1),t()},p=()=>{a(jg(r)),t()};return e?c.jsx(Et,{isOpen:e,onClose:t,title:"Model Properties",size:"lg",footer:c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",onClick:p,disabled:l,children:"Cancel"}),c.jsx(Ze,{variant:"primary",onClick:h,disabled:l||s.contextWindow<1024||s.contextWindow>1e7,children:l?"Saving...":"Save"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Model Name"}),c.jsx("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded font-mono text-sm break-all",children:r.id})]}),c.jsx(uc,{label:"Context Window",value:s.contextWindow,onChange:g=>g!==null&&a(_=>({..._,contextWindow:g})),min:1024,max:1e7,helpText:"Range: 1,024 - 10,000,000 tokens"}),c.jsxs(hU,{label:"Sampling Parameters",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(uc,{label:"Temperature",value:s.temperature,onChange:g=>a(_=>({..._,temperature:g})),min:0,max:2,step:.1,helpText:"0.0 - 2.0",defaultValue:1,profileDefault:r.defaultTemperature,tooltip:"How random the response is. Low (0.1-0.3) = precise and predictable. High (0.7-1.5) = creative and varied."}),c.jsx(uc,{label:"Top P",value:s.topP,onChange:g=>a(_=>({..._,topP:g})),min:0,max:1,step:.05,helpText:"0.0 - 1.0",defaultValue:1,profileDefault:r.defaultTopP,tooltip:"How to pick the next word. Low (0.5-0.8) = stick to obvious choices. High (0.95-1.0) = allow surprising words."})]}),c.jsx(uc,{label:"Top K",value:s.topK,onChange:g=>a(_=>({..._,topK:g})),min:1,max:200,helpText:"1 - 200 (leave as default if not supported)",profileDefault:r.defaultTopK,tooltip:"Restricts word choices to the top K most likely ones. Low (10-20) = focused. High (50-200) = diverse. Not all backends support this."})]}),c.jsx(uc,{label:"Max Tokens",value:s.maxTokens,onChange:g=>a(_=>({..._,maxTokens:g})),min:256,max:32e3,helpText:"Maximum tokens to generate per response",profileDefault:r.defaultMaxTokens,tooltip:"Longest response length. Higher values let the model write more, but use up your context window faster."}),c.jsxs("div",{children:[c.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary mb-1",children:[c.jsx("input",{type:"checkbox",checked:s.supportsVision??!1,onChange:g=>a(_=>({..._,supportsVision:g.target.checked})),className:"rounded border-border bg-bg-tertiary text-accent-primary focus:ring-accent-primary focus:ring-offset-0"}),"Vision Enabled"]}),c.jsx("p",{className:"text-xs text-text-muted",children:"Allow sending images directly to this model. Disable if the model doesn't support vision."})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Source"}),c.jsxs("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded text-sm",children:[r.source==="backend"&&"Auto-detected from backend",r.source==="user"&&"Manually set",r.source==="default"&&"Default value"]})]})]})}):null}function mU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function pU(){var F;const[,e]=Jr(),t=xe(H=>H.currentSession),n=xe(H=>H.setSessionProvider),[r,s]=C.useState(!1),[a,l]=C.useState([]),[d,f]=C.useState(null),h=C.useRef(null),[p,g]=C.useState(null),_=C.useRef(new Set),x=Ot(H=>H.providers),v=Ot(H=>H.activeProviderId),S=Ot(H=>H.defaultModelSelection);Ot(H=>H.backend);const w=Ot(H=>H.activating),k=Ot(H=>H.activateProvider),j=Ot(H=>H.refreshModel),T=Ot(H=>H.refreshProviderModels);C.useEffect(()=>{function H(se){h.current&&!h.current.contains(se.target)&&(s(!1),l([]),_.current=new Set)}return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[]),C.useEffect(()=>{if(r){const H=x.map(se=>se.id);l(H),H.forEach(se=>{_.current.has(se)||(_.current.add(se),ne(se))})}},[r,x]);const A=x.find(H=>H.id===v),P=(A==null?void 0:A.status)==="disconnected",R=S?S.split("/").pop()??null:null,q=R?((F=R.split("/").pop())==null?void 0:F.replace(/-/g," "))??R:"detecting...",J=(H,se)=>S?S===`${H}/${se}`:!1,ne=async H=>{f(H);try{await T(H)}catch{}finally{f(null)}},I=H=>{a.includes(H.id)?l(a.filter(se=>se!==H.id)):(l([...a,H.id]),ne(H.id))},W=async H=>{if(H.id===v){I(H);return}t?(n(H.id,void 0),Ot.getState().syncFromSession(H.id,""),s(!1),l([])):await k(H.id)&&(s(!1),l([]))},z=H=>{I(H)},L=async(H,se)=>{H.stopPropagation(),_.current.delete(se),await T(se),await ne(se)},U=(H,se)=>{g({providerId:H,model:se})},D=()=>{g(null)},N=async(H,se)=>{if(t){n(H,se),Ot.getState().syncFromSession(H,se),l([]),s(!1);return}f("activating");try{Ot.getState().syncFromSession(H,se),l([]),s(!1);const B=await Ne(`/api/providers/${H}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:se})});if(B.ok){const V=await B.json();Ot.getState().syncFromSession(V.activeProviderId,V.model)}}catch{}finally{f(null)}};return x.length===0?c.jsxs("button",{type:"button",onClick:()=>j(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:P?"LLM server is offline. Click to retry.":R??"Click to refresh model",children:[P?c.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):c.jsx("span",{className:"text-sm text-accent-primary",children:q}),c.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):c.jsxs("div",{className:"relative",ref:h,children:[c.jsxs("button",{type:"button",onClick:()=>s(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[P?c.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):c.jsx("span",{className:"text-sm text-accent-primary",children:q}),c.jsx(Br,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&c.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-lg z-50 overflow-hidden max-h-[80vh] overflow-y-auto",children:[c.jsx("div",{className:"py-1",children:x.map(H=>{var se;return c.jsxs("div",{children:[c.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${H.id===v?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${w?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[c.jsxs("div",{onClick:()=>!w&&W(H),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[c.jsx("span",{className:`text-sm font-medium truncate ${H.id===v?"text-accent-primary":"text-text-primary"}`,children:H.name}),c.jsx("span",{className:"text-xs text-text-muted truncate",children:H.backend!=="auto"&&Ag(H.backend)})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[H.id===v?c.jsx("span",{className:"text-accent-success",title:"Active",children:c.jsx(gs,{className:"w-4 h-4"})}):c.jsx("span",{className:"w-4"}),c.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),L(B,H.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:c.jsx(Z_,{className:`w-4 h-4 ${d===H.id?"animate-spin":""} ${H.id===v?"text-accent-primary":"text-text-muted"}`})}),c.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),z(H)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:c.jsx(Br,{className:`w-4 h-4 transition-transform ${a.includes(H.id)?"rotate-180":""} ${H.id===v?"text-accent-primary":"text-text-muted"}`})})]})]}),a.includes(H.id)&&c.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:d===H.id?c.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):(se=H.models)!=null&&se.length?H.models.map(B=>{var V;return c.jsxs("button",{type:"button",onClick:()=>N(H.id,B.id),disabled:d==="activating",className:`w-full px-4 py-1.5 text-left hover:bg-bg-tertiary transition-colors text-sm flex items-center justify-between group ${d==="activating"?"opacity-50 cursor-wait":""} ${J(H.id,B.id)?"text-accent-primary":"text-text-secondary"}`,children:[c.jsx("span",{className:"truncate flex-1",children:((V=B.id.split("/").pop())==null?void 0:V.replace(/-/g," "))??B.id}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx("span",{className:"text-xs text-text-muted",children:mU(B.contextWindow)}),c.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),U(H.id,B)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:c.jsx(UD,{className:"w-3 h-3 text-text-muted"})})]}),J(H.id,B.id)&&c.jsx("span",{className:"text-accent-success flex-shrink-0 ml-1",children:c.jsx(gs,{className:"w-3.5 h-3.5"})})]},B.id)}):c.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},H.id)})}),c.jsx("div",{className:"border-t border-border px-3 py-2",children:c.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),p&&c.jsx(fU,{isOpen:!0,onClose:D,providerId:p.providerId,model:p.model})]})}function gU({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:s,setDragOver:a,errorMessage:l,setErrorMessage:d,scrollContainerRef:f,sessionId:h,sessionMode:p,showHistory:g,history:_,selectedIndex:x,openHistory:v,closeHistory:S,navigateUp:w,navigateDown:k,selectCurrent:j,isAutoScrollActive:T,setAutoScroll:A,onOpenMessageSearch:P,onOpenCommandsModal:R,onOpenWorkflowsModal:q,onSelectWorkflow:J,onSelectWorkflowWithSubGroup:ne,clearInput:I}){const W=C.useRef(null),z=C.useRef(null),L=C.useRef(0),U=Ah(),D=xe(le=>le.sendMessage),N=xe(le=>le.stopGeneration),F=xe(le=>le.cancelQueued),H=xe(le=>le.queuedMessages),se=C.useCallback(()=>{const le=W.current;if(!le)return;const Ce=e.length>=L.current;L.current=e.length,Ce||(le.style.height="auto"),le.style.height=`${Math.min(200,le.scrollHeight)}px`},[e]);C.useEffect(()=>{if(!h)return;const le=`openfox:draft:${h}`,Ce=localStorage.getItem(le);Ce!==null&&t(Ce)},[h,t]),C.useEffect(()=>{var le;(le=W.current)==null||le.focus(),se()},[h,se]),C.useEffect(()=>{if(!h)return;const le=`openfox:draft:${h}`,Ce=setTimeout(()=>{e?localStorage.setItem(le,e):localStorage.removeItem(le)},500);return()=>clearTimeout(Ce)},[h,e]),C.useEffect(()=>{se()},[e,se]),C.useEffect(()=>{const le=W.current;if(!le)return;const Ce=async Re=>{var De;if(document.activeElement!==le)return;const Oe=(De=Re.clipboardData)==null?void 0:De.items;if(Oe){for(const Ue of Array.from(Oe))if(Ue.type.startsWith("image/")){Re.preventDefault();const st=Ue.getAsFile();if(!st)continue;await Eg(st,it=>r([...n,it]),d,{filename:"pasted-image"})}}};return le.addEventListener("paste",Ce),()=>le.removeEventListener("paste",Ce)},[n,r,d]);const B=le=>{le.preventDefault(),!(!e.trim()&&n.length===0)&&(D(e,n.length>0?n:void 0),I())},V=le=>{if(g)switch(le.key){case"Enter":{le.preventDefault();const Ce=j();Ce&&(t(Ce),S());return}case"Escape":le.preventDefault(),S(),U&&N();return;case"ArrowUp":le.preventDefault(),w();return;case"ArrowDown":le.preventDefault(),k();return}if(le.key==="ArrowUp"&&e.trim()===""&&!g){le.preventDefault(),v();return}le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),B(le))},K=C.useCallback(async le=>{const Ce=le.target.files;if(!(!Ce||Ce.length===0)){d(null);for(const Re of Array.from(Ce))await Eg(Re,Oe=>r([...n,Oe]),d);z.current&&(z.current.value="")}},[n,r,d]),O=C.useCallback(le=>{le.preventDefault(),le.stopPropagation(),a(!0)},[a]),Q=C.useCallback(le=>{le.preventDefault(),le.stopPropagation(),a(!1)},[a]),G=C.useCallback(async le=>{le.preventDefault(),le.stopPropagation(),a(!1),d(null);const Ce=le.dataTransfer.files;if(!(!Ce||Ce.length===0))for(const Re of Array.from(Ce))await Eg(Re,Oe=>r([...n,Oe]),d)},[n,r,a,d]),Z=C.useCallback(le=>{r(n.filter(Ce=>Ce.id!==le))},[n,r]),te=C.useCallback(()=>{var le;(le=z.current)==null||le.click()},[]),Se=()=>{var le;!e.trim()&&n.length===0||((le=f.current)==null||le.scrollTo({top:f.current.scrollHeight,behavior:"smooth"}),D(e,n),I())};return c.jsxs("form",{onSubmit:B,className:"relative p-2 md:p-4 bg-secondary",children:[U&&c.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:c.jsx(HF,{})}),c.jsxs("div",{className:"absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2",children:[c.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors",onClick:()=>A(!T),children:[T?c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):c.jsx(Br,{className:"w-3 h-3 text-text-muted"}),T?"live":"scroll to bottom"]}),c.jsxs("button",{type:"button",onClick:P,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[c.jsx(ex,{}),"Browse history"]})]}),c.jsx("input",{ref:z,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:K,className:"hidden",multiple:!0}),l&&c.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:l}),n.length>0&&c.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(le=>c.jsx(zF,{attachment:le,onRemove:Z},le.id))}),g&&c.jsx($F,{history:_,selectedIndex:x,onSelect:le=>{t(le),S()},onEscape:S,onNavigate:le=>{le==="up"?w():k()}}),c.jsx(rU,{messages:H,onCancel:F}),c.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${s?"bg-accent-primary/10":"bg-primary"}`,onDragOver:O,onDragLeave:Q,onDrop:G,children:[c.jsx("textarea",{id:i2,ref:W,value:e,onChange:le=>{t(le.target.value),g&&S()},onKeyDown:V,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"flex-1 bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),c.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[U&&c.jsxs("button",{type:"button",onClick:()=>N(),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[c.jsx(nk,{}),"Abort"]}),c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{type:"button",onClick:Se,disabled:!e.trim()&&n.length===0,"data-testid":"chat-send-button",className:"px-4 py-1.5 rounded-l bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"}),c.jsx(tU,{onSendCommand:(le,Ce,Re,Oe)=>{var Ue;Ce&&p!==Ce&&xe.getState().switchMode(Ce);const De=Re&&Re.trim()?`${Re.trim()}
314
-
315
- ${le}`:le;(Ue=f.current)==null||Ue.scrollTo({top:f.current.scrollHeight,behavior:"smooth"}),D(De,Oe!=null&&Oe.length?Oe:void 0,{messageKind:"command",isSystemGenerated:!0}),I()},onSelectWorkflow:J,onSelectWorkflowWithSubGroup:ne,onOpenCommandsManager:R,onOpenWorkflowsManager:q,onAttach:te,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),c.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(cU,{}),c.jsx(uU,{})]}),c.jsx(pU,{})]})]})}function _U(e){return e==="criterion"||e==="session_metadata"}function xU(e){var t,n;return e.role!=="assistant"||e.subAgentId||(t=e.content)!=null&&t.trim()||(n=e.thinkingContent)!=null&&n.trim()||!e.toolCalls||e.toolCalls.length===0?!1:e.toolCalls.every(r=>_U(r.name))}function yU(e,t=[]){const n=[];let r=null,s=[],a,l=1;const d=new Map,f=new Map,h=[];for(const x of t)x.type==="message"?d.set(x.message.id,x):x.type==="subagent"?f.set(x.subAgentId,x):x.type==="criteria-batch"&&h.push(x);let p=0;const g=()=>{if(s.length>0){const x=h[p];x&&x.type==="criteria-batch"&&x.toolCalls.length===s.length&&x.toolCalls.every((S,w)=>{var k;return S.id===((k=s[w])==null?void 0:k.id)})?n.push(x):n.push({type:"criteria-batch",toolCalls:[...s]}),p++,s=[]}},_=()=>{if(!r)return;const x=r,v=f.get(x.subAgentId);v&&v.type==="subagent"&&v.messages.length===x.messages.length&&v.messages.every((w,k)=>w===x.messages[k])?n.push(v):n.push({type:"subagent",subAgentId:x.subAgentId,subAgentType:x.subAgentType,messages:x.messages}),r=null};for(const x of e)if(x.role!=="tool"){if(x.contextWindowId&&a&&x.contextWindowId!==a&&(g(),_(),l++,n.push({type:"context-divider",windowSequence:l})),a=x.contextWindowId,xU(x)){_();for(const v of x.toolCalls)s.push(v);continue}if(g(),x.subAgentId&&x.subAgentType)r&&r.subAgentId===x.subAgentId?r.messages.push(x):(_(),r={subAgentId:x.subAgentId,subAgentType:x.subAgentType,messages:[x]});else{_();const v=d.get(x.id);v&&v.type==="message"&&v.message===x?n.push(v):n.push({type:"message",message:x})}}return g(),_(),n}function vU(e){const{year:t,month:n,day:r}=l2(e);return`${t}/${n}/${r} ${Ph(e)}`}function bU(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const SU=10,wU=150;function CU(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 kU(e){return[...e].sort((r,s)=>new Date(s.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,SU).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:vU(r.timestamp),trimmedContent:bU(r.content,wU),sessionId:r.sessionId,sessionName:r.sessionName}))}function EU(e,t,n){const r=[],s=e.filter(a=>a.role==="user"&&!a.isSystemGenerated&&a.messageKind!=="auto-prompt");for(const a of s)r.push({id:a.id,content:a.content,timestamp:a.timestamp,sessionId:n??"",sessionName:"This session"});for(const a of t)n&&a.id===n||r.push(...CU(a));return kU(r)}function NU(e,t=[],n=null){const[r,s]=C.useState(0),[a,l]=C.useState(!1),d=C.useMemo(()=>EU(e,t,n),[e,t,n]),f=C.useCallback(()=>{d.length>0&&(s(d.length-1),l(!0))},[d.length]),h=C.useCallback(()=>{l(!1),s(0)},[]),p=C.useCallback(()=>{s(x=>d.length===0?x:x===0?d.length-1:x-1)},[d.length]),g=C.useCallback(()=>{s(x=>d.length===0?x:x===d.length-1?0:x+1)},[d.length]),_=C.useCallback(()=>{if(d.length===0||!a)return null;const x=d[r];return(x==null?void 0:x.content)??null},[d,r,a]);return{history:d,selectedIndex:r,showHistory:a,openHistory:f,closeHistory:h,navigateUp:p,navigateDown:g,selectCurrent:_}}C.memo(function({item:t}){const[n,r]=C.useState(!1);return t.type==="start"?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[c.jsx("span",{className:"animate-pulse",children:"●"}),c.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&c.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):c.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[c.jsx("span",{className:"text-accent-success",children:"✓"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),c.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&c.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:c.jsx(Ks,{content:t.description})})]})]})});function jU({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t}={}){const n=e??!0,[r,s]=C.useState(""),[a,l]=C.useState([]),[d,f]=C.useState(!1),[h,p]=C.useState(null),[g,_]=C.useState(!1),[x,v]=C.useState(!1),[S,w]=C.useState(!1),[k,j]=C.useState(!1),[T,A]=C.useState(null),P=C.useRef(null),R=xe(ve=>ve.currentSession),q=xe(ve=>ve.messages),J=xe(ve=>ve.streamingMessage),ne=xe(ve=>ve.sessions),I=xe(ve=>ve.pendingQuestion),W=Ah(),z=xe(ve=>ve.sendMessage),L=xe(ve=>ve.acceptAndBuild),U=xe(ve=>ve.stopGeneration),D=xe(ve=>ve.launchRunner),N=mt(ve=>ve.defaults),F=mt(ve=>ve.userItems),H=[...N,...F].filter(ve=>!ve.subagent),{history:se,selectedIndex:B,showHistory:V,openHistory:K,closeHistory:O,navigateUp:Q,navigateDown:G,selectCurrent:Z}=NU(q,ne,R==null?void 0:R.id);C.useEffect(()=>{const ve=ue=>{A(ue.detail.stats)};return window.addEventListener("open-turn-stats",ve),()=>window.removeEventListener("open-turn-stats",ve)},[]),C.useEffect(()=>{jt.getState().fetchWorkflows()},[]);const te=C.useMemo(()=>J?q.map(ve=>ve.id===J.id?J:ve):q,[q,J]),Se=C.useRef([]),le=C.useMemo(()=>{const ve=yU(te,Se.current);return Se.current=ve,ve},[te]),{isAutoScrollActive:Ce,setAutoScroll:Re}=JN(P,R),Oe=C.useCallback(ve=>{var Ee;Re(!1);const ue=document.querySelector(`[data-item-index="${ve}"]`);ue&&(ue.scrollIntoView({behavior:"smooth",block:"start"}),(Ee=ue.closest('[data-testid="chat-scroll-container"]'))==null||Ee.scrollBy(0,-80))},[Re]);C.useEffect(()=>{const ve=ue=>{const Ee=S||g||x||k||T;ue.key==="Escape"&&W&&!Ee&&U(),ue.key==="ScrollLock"&&Re(!Ce)};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[W,U,Ce,S,g,x,k,T]);const De=tx();ok(De.quickAction,()=>{w(!0)}),uL(De.agentSwitching,H,ve=>{xe.getState().switchMode(ve)});const Ue=(R==null?void 0:R.mode)==="planner",st=(R==null?void 0:R.mode)==="builder",it=ve=>{const ue=r.trim()?r:void 0,Ee=a.length>0?a:void 0;Ue?L(ve,ue,Ee):st&&D(ue,Ee,ve),ze()},ye=(ve,ue)=>{const Ee=r.trim()?r:void 0,_t=a.length>0?a:void 0;Ue?L(ve,Ee,_t,ue):st&&D(Ee,_t,ve,ue),ze()},ze=()=>{s(""),l([]),R!=null&&R.id&&localStorage.removeItem(`openfox:draft:${R.id}`)};return c.jsxs(c.Fragment,{children:[c.jsxs(XM,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:t,messages:te,children:[I&&c.jsx(vF,{question:I}),c.jsx(ZM,{}),T&&c.jsx(eO,{stats:T,onClose:()=>A(null)}),c.jsx(bF,{}),c.jsx(xF,{displayItems:le,scrollContainerRef:P,highlightedMessageId:null}),c.jsx(gU,{input:r,setInput:s,attachments:a,setAttachments:l,dragOver:d,setDragOver:f,errorMessage:h,setErrorMessage:p,scrollContainerRef:P,sessionId:R==null?void 0:R.id,sessionMode:R==null?void 0:R.mode,showHistory:V,history:se,selectedIndex:B,openHistory:K,closeHistory:O,navigateUp:Q,navigateDown:G,selectCurrent:Z,isAutoScrollActive:Ce,setAutoScroll:Re,onOpenMessageSearch:()=>j(!0),onOpenCommandsModal:()=>_(!0),onOpenWorkflowsModal:()=>v(!0),onSelectWorkflow:it,onSelectWorkflowWithSubGroup:ye,clearInput:ze}),c.jsx(ej,{isOpen:g,onClose:()=>_(!1)}),c.jsx(rj,{isOpen:x,onClose:()=>v(!1)}),c.jsx(RF,{isOpen:S,onClose:()=>w(!1),onSearchMessages:()=>j(!0),isAutoScrollActive:Ce,onToggleAutoScroll:Re,textareaContent:r,onCloseComplete:a2,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(ve,ue)=>{const Ee=await mn.getState().fetchCommand(ve);if(Ee){const _t=ue!=null&&ue.trim()?`${ue.trim()}
316
-
317
- ${Ee.prompt}`:Ee.prompt;Ee.metadata.agentMode&&xe.getState().switchMode(Ee.metadata.agentMode),z(_t,a!=null&&a.length?a:void 0,{messageKind:"command",isSystemGenerated:!0}),ze()}},onSelectWorkflow:ve=>{const ue=r.trim()||void 0,Ee=a.length>0?a:void 0;(R==null?void 0:R.mode)==="planner"?xe.getState().acceptAndBuild(ve,ue,Ee):xe.getState().launchRunner(ue,Ee,ve),ze()}})]}),k&&c.jsx(BF,{isOpen:k,onClose:()=>j(!1),displayItems:le,onNavigate:Oe})]})}function AC({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[s,a]=C.useState(""),l=C.useRef(null);C.useEffect(()=>{e&&(a(""),setTimeout(()=>{var f;return(f=l.current)==null?void 0:f.focus()},100))},[e]);const d=f=>{f.preventDefault(),s.trim()&&n(s)};return c.jsx(Et,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:c.jsxs("form",{onSubmit:d,className:"space-y-4",children:[c.jsx("p",{className:"text-text-secondary text-sm",children:t?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),c.jsx(Bh,{ref:l,type:"password",value:s,onChange:f=>a(f.target.value),placeholder:"Enter password",autoFocus:!0}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),c.jsx(Ze,{type:"submit",disabled:!s.trim(),children:t?"Try Again":"Connect"})]})]})})}function TU({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return c.jsx("div",{className:"flex justify-center py-6",children:c.jsx("div",{className:"flex items-center",children:Array.from({length:t},(s,a)=>{const l=a+1,d=l<e,f=l===e;return c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{onClick:()=>r==null?void 0:r(l),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${d?"bg-accent-primary text-text-primary hover:opacity-80":f?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:d?"✓":l}),c.jsx("button",{onClick:()=>r==null?void 0:r(l),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${f?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[a]}),a<t-1&&c.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${d?"bg-accent-primary":"bg-border"}`})]},a)})})})}const AU=[8e3,11434,8080],DU=[{name:"OpenCode Go",url:"https://opencode.ai/zen/go/v1",backend:"opencode-go"}];function LU({onNext:e}){const[t,n]=C.useState([]),[r,s]=C.useState([]),[a,l]=C.useState(!1),[d,f]=C.useState(""),[h,p]=C.useState(""),[g,_]=C.useState(""),[x,v]=C.useState("auto"),[S,w]=C.useState(!1),[k,j]=C.useState(null),[T,A]=C.useState(null),[P,R]=C.useState(null),[q,J]=C.useState("");C.useEffect(()=>{ne()},[]);async function ne(){try{const D=await Ne("/api/providers");if(D.ok){const F=(await D.json()).providers.map(H=>({id:H.id,name:H.name,url:H.url,backend:H.backend,model:null,apiKey:H.apiKey}));n(F),s(F)}}catch{}}async function I(D){w(!0),j(null);const N=x!=="auto";try{const H=await(await Ne("/api/providers/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:D,skipBackendDetection:N})})).json();H.success?(N||v(H.backend??"auto"),j({success:!0,model:H.model??void 0})):j({success:!1,error:H.error??"Connection failed"})}catch(F){j({success:!1,error:F instanceof Error?F.message:"Connection failed"})}w(!1)}function W(){if(!h)return;const D=d||`Provider ${r.length+1}`,N={id:`temp-${Date.now()}`,name:D,url:h,backend:k!=null&&k.success?x:"auto",model:k!=null&&k.success?k.model??null:null,apiKey:g||void 0};s([...r,N]),f(""),p(""),_(""),j(null)}function z(D){A(D),t.some(F=>F.id===D)?Ne(`/api/providers/${D}`,{method:"DELETE"}).then(()=>{s(r.filter(F=>F.id!==D)),n(t.filter(F=>F.id!==D)),A(null)}).catch(()=>{A(null)}):(s(r.filter(F=>F.id!==D)),A(null))}async function L(){for(const N of r)(N.id.startsWith("temp-")||!t.some(F=>F.id===N.id))&&((await Ne("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N.name,url:N.url,backend:N.backend,model:N.model,apiKey:N.apiKey})})).ok||console.error("Failed to add provider",N));const D=r.filter(N=>!N.id.startsWith("temp-"));e({providers:D})}const U=r.length>0;return c.jsxs("div",{className:"max-w-xl mx-auto",children:[c.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),c.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),c.jsxs("div",{className:"space-y-4",children:[r.length>0?c.jsx("div",{className:"space-y-2",children:r.map(D=>c.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:Ag(D.backend)}),P===D.id?c.jsx("input",{type:"text",value:q,onChange:N=>J(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(s(r.map(F=>F.id===D.id?{...F,name:q}:F)),R(null)),N.key==="Escape"&&R(null)},onBlur:()=>{s(r.map(N=>N.id===D.id?{...N,name:q}:N)),R(null)},className:"px-2 py-0.5 bg-bg-primary border border-accent-primary rounded text-text-primary text-sm focus:outline-none",autoFocus:!0}):c.jsx("span",{className:"text-text-primary font-medium cursor-pointer hover:text-accent-primary",onClick:()=>{R(D.id),J(D.name)},title:"Click to edit",children:D.name})]}),c.jsx("p",{className:"text-text-muted text-sm mt-1",children:D.url}),D.model&&c.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",D.model]})]}),c.jsx("button",{onClick:()=>z(D.id),disabled:T===D.id,className:"p-2 text-text-muted hover:text-red-500 transition-colors disabled:opacity-50",title:"Remove provider",children:c.jsx($c,{})})]},D.id))}):c.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:c.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),a?c.jsxs("form",{onSubmit:D=>{D.preventDefault(),h&&W()},className:"space-y-4 p-4 bg-bg-tertiary rounded-lg",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Service Presets"}),c.jsx("div",{className:"grid grid-cols-2 gap-2",children:DU.map(D=>c.jsx("button",{type:"button",onClick:()=>{f(D.name),p(D.url),v(D.backend),j(null)},className:`p-2 rounded border text-center text-sm transition-colors ${h===D.url?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:D.name},D.name))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Local Presets"}),c.jsx("div",{className:"grid grid-cols-3 gap-2",children:AU.map(D=>c.jsxs("button",{type:"button",onClick:()=>{f(""),p(`http://localhost:${D}`),v("auto"),j(null)},className:`p-2 rounded border text-center text-sm transition-colors ${h===`http://localhost:${D}`?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:["localhost:",D]},D))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Or enter address manually"}),c.jsx("input",{type:"text",name:"url",value:h,onChange:D=>{p(D.target.value),j(null)},onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),I(h))},placeholder:"http://localhost:8000","data-testid":"onboarding-provider-url-input",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name (optional)"}),c.jsx("input",{type:"text",name:"name",value:d,onChange:D=>f(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),W())},placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),c.jsx("input",{type:"password",name:"apiKey",value:g,onChange:D=>_(D.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),k&&c.jsx("div",{className:`p-3 rounded-lg ${k.success?"bg-accent-primary/10":"bg-red-500/10"}`,children:k.success?c.jsxs("p",{className:"text-accent-primary font-medium",children:["✓ Connected to ",Ag(x),k.model&&` (${k.model})`]}):c.jsx("p",{className:"text-red-500",children:k.error})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",onClick:()=>I(h),disabled:!h||S,"data-testid":"onboarding-test-connection-button",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted disabled:opacity-50",children:S?c.jsx($i,{className:"w-4 h-4"}):"Test Connection"}),c.jsx("button",{type:"submit",disabled:!h,"data-testid":"onboarding-add-provider-submit-button",className:"flex-1 px-4 py-2 bg-accent-primary text-text-primary rounded-lg hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:k!=null&&k.success?"Add Provider ✓":"Add Provider"})]}),c.jsx("button",{type:"button",onClick:()=>{l(!1),f(""),p(""),j(null)},className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]}):c.jsxs("button",{onClick:()=>l(!0),"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[c.jsx($i,{className:"w-4 h-4"}),"Add Provider"]}),c.jsx("button",{onClick:L,disabled:!U,"data-testid":"onboarding-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function RU({onNext:e}){const[t,n]=C.useState(""),[r,s]=C.useState(!1);return C.useEffect(()=>{Ne("/api/config").then(a=>a.json()).then(a=>{a.workdir?n(a.workdir):fetch("/api/directories?path="+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})}).catch(()=>{fetch("/api/directories?path="+encodeURIComponent("/home")).then(a=>a.json()).then(a=>{a.current&&n(a.current)}).catch(()=>{})})},[]),c.jsxs("div",{className:"max-w-xl mx-auto",children:[c.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),c.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",value:t,onChange:a=>n(a.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),c.jsx("button",{onClick:()=>s(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&c.jsx(m2,{initialPath:t||void 0,onSelect:a=>{n(a),s(!1)},onClose:()=>s(!1)}),c.jsx("button",{onClick:()=>e({workdir:t}),disabled:!t,"data-testid":"onboarding-workdir-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function MU({onNext:e}){const[t,n]=C.useState(!1),[r,s]=C.useState("http://localhost:11434"),[a,l]=C.useState("qwen3.5:0.8b"),{copied:d,copy:f}=qN();C.useEffect(()=>{Ne("/api/config").then(p=>p.json()).then(p=>{p.visionFallback&&(n(p.visionFallback.enabled),s(p.visionFallback.url),l(p.visionFallback.model))}).catch(()=>{})},[]);function h(p){if(p){e({});return}e({visionFallback:{enabled:t,url:r,model:a,timeout:120}})}return c.jsxs("div",{className:"max-w-xl mx-auto",children:[c.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),c.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[c.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"To enable vision support, you need an Ollama server with a vision model:"}),c.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),c.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[c.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),c.jsx("button",{onClick:()=>f("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:d?c.jsx(gs,{className:"w-4 h-4 text-accent-primary"}):c.jsx(FD,{className:"w-4 h-4"})})]})]}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t,onChange:p=>n(p.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),c.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),t&&c.jsxs("div",{className:"space-y-4 pl-8",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),c.jsx("input",{type:"text",value:r,onChange:p=>s(p.target.value),placeholder:"http://localhost:11434",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),c.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"qwen3.5:0.8b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-4",children:[c.jsx("button",{onClick:()=>h(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),c.jsx("button",{onClick:()=>h(!1),className:"px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Finish Setup"})]})]})]})}function OU({onComplete:e}){const[t,n]=C.useState(1),[r,s]=C.useState(!1),[a,l]=C.useState({});async function d(g){l(_=>({..._,providers:g.providers})),n(2)}async function f(g){l(_=>({..._,...g})),n(3)}async function h(g){s(!0);try{if(!(await Ne("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:a.workdir,visionFallback:g.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(_){console.error("Failed to save onboarding data:",_),s(!1)}}const p=g=>{n(g)};return c.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[c.jsx(qc,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),c.jsx(TU,{currentStep:t,totalSteps:3,labels:["LLM Server","Projects Folder","Vision"],onStepClick:p}),c.jsx("div",{className:"max-w-xl mx-auto",children:r?c.jsxs("div",{className:"text-center",children:[c.jsx($i,{className:"w-6 h-6"}),c.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):c.jsxs(c.Fragment,{children:[t===1&&c.jsx(LU,{onNext:d}),t===2&&c.jsx(RU,{onNext:f}),t===3&&c.jsx(MU,{onNext:h})]})})]})}const DC="openfox_updated_to",LC="update_pending";function IU(){const[e,t]=C.useState(!1),n=localStorage.getItem(DC),r=localStorage.getItem(LC);C.useEffect(()=>{if(!n||!r)return;const a=setTimeout(()=>t(!0),3e4);return()=>clearTimeout(a)},[n,r]);const s=()=>{localStorage.removeItem(DC),localStorage.removeItem(LC),t(!0)};return e||r!=="true"||!n?null:c.jsxs("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 bg-bg-secondary border border-border rounded-lg shadow-xl animate-slide-down",role:"status","aria-live":"polite",children:[c.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:c.jsx(gs,{className:"w-3 h-3 text-accent-primary"})}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),c.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),c.jsx("button",{onClick:s,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:c.jsx(rk,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Gt.getState().loadUserPresets(),Gt.getState().applySavedTheme());function ty(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function oj(){return c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx(Kc,{})})}function PU({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Y_("/p/:projectId"),r=n==null?void 0:n.projectId,s=xe(f=>f.connectionStatus),a=Ut(f=>f.currentProject),l=ty();return ID({canLoad:s==="connected"||l,projectId:r,currentProjectId:a==null?void 0:a.id}),!a||a.id!==r?c.jsx(oj,{}):c.jsxs(c.Fragment,{children:[c.jsx(u2,{projectId:r,isOpen:e,onClose:t}),c.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:c.jsx(uM,{})})]})}function BU({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,s]=Y_("/p/:projectId/s/:sessionId"),a=s==null?void 0:s.projectId,l=s==null?void 0:s.sessionId,[,d]=Jr(),f=xe(S=>S.connectionStatus),h=xe(S=>S.currentSession),p=xe(S=>S.error),g=xe(S=>S.clearError),_=Ut(S=>S.currentProject),x=ty();return PD({canLoad:f==="connected"||x,projectId:a,sessionId:l,currentProjectId:_==null?void 0:_.id,currentSessionId:h==null?void 0:h.id}),C.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&a&&(g(),d(`/p/${a}`))},[p,a,g,d]),!_||_.id!==a?c.jsx(oj,{}):c.jsxs(c.Fragment,{children:[c.jsx(u2,{projectId:a,isOpen:e,onClose:t}),c.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:c.jsx(jU,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})})]})}function zU(){const e=Ot(n=>n.fetchConfig);function t(){e(),window.history.back()}return c.jsx("div",{className:"flex-1 overflow-y-auto",children:c.jsx(OU,{onComplete:t})})}function $U(){const{connectionStatus:e}=RD(),t=Ot(D=>D.fetchConfig),n=Ot(D=>D.refreshProviderModels),r=Ot(D=>D.providers),s=Ot(D=>D.activeProviderId),[,a]=Jr(),l=ty(),[d,f]=C.useState(!1);C.useEffect(()=>{(e==="connected"||l)&&t().then(()=>{f(!0),tn.getState().getSettings([...PC,Me.DISPLAY_THEME,Me.DISPLAY_USER_PRESETS])})},[e,l,t]),C.useEffect(()=>{d&&s&&n(s).then(()=>{const D=Ot.getState().defaultModelSelection;(D?D.split("/")[0]:null)!==s&&t()})},[d,s,n,t]);const h=tn(D=>D.settings);C.useEffect(()=>{d&&r.length===0&&a("/onboarding")},[d,r.length]),C.useEffect(()=>{const{applyPreset:D,applyTokens:N,setFollowSystemTheme:F,initSystemThemeListener:H}=Gt.getState(),se=h[Me.DISPLAY_THEME],B=h[Me.DISPLAY_USER_PRESETS],V=h[Me.DISPLAY_FOLLOW_SYSTEM_THEME];if(B&&localStorage.setItem("openfox:userPresets",B),se){localStorage.setItem("openfox:theme",se);try{const O=JSON.parse(se);O.preset&&O.tokens?(D(O.preset),Gt.setState({basePreset:O.preset}),N(O.tokens)):O.preset?D(O.preset):O.tokens&&N(O.tokens)}catch{D("dark")}}else D("dark");V!==void 0&&F(V==="true");const K=H();return()=>K()},[h[Me.DISPLAY_THEME],h[Me.DISPLAY_USER_PRESETS],h[Me.DISPLAY_FOLLOW_SYSTEM_THEME]]);const p=()=>{const D=localStorage.getItem("openfox:leftSidebar");return D!==null?D==="true":!0},g=()=>{const D=localStorage.getItem("openfox:rightSidebar");return D!==null?D==="true":!0},[_,x]=C.useState(p),[v,S]=C.useState(g),[w,k]=C.useState(!1),[j,T]=C.useState(!1),[A,P]=C.useState(!1),R=zA();C.useEffect(()=>{const D=()=>{P(window.innerWidth<768)};return D(),window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]);const q=A?w:_,J=A?j:v,ne=()=>{A?k(!w):x(!_)},I=()=>{A?T(!j):S(!v)};C.useEffect(()=>{A||localStorage.setItem("openfox:leftSidebar",String(_))},[_,A]),C.useEffect(()=>{A||localStorage.setItem("openfox:rightSidebar",String(v))},[v,A]),C.useEffect(()=>{(e==="connected"||l)&&t()},[e,t,l]);const W=xe(D=>D.showPasswordModal),z=xe(D=>D.passwordModalRetry),L=xe(D=>D.submitPassword),U=xe(D=>D.cancelPassword);return e!=="connected"&&!W&&!l?c.jsxs(c.Fragment,{children:[c.jsx(AC,{isOpen:!0,isRetry:z,onSubmit:L,onCancel:U}),c.jsx("div",{className:"h-screen flex items-center justify-center",children:c.jsx(aM,{text:"Connecting to server..."})})]}):c.jsxs(c.Fragment,{children:[c.jsx(AC,{isOpen:W,isRetry:z,onSubmit:L,onCancel:U}),c.jsxs("div",{className:"flex flex-col",style:{height:A?`calc(${R.offsetTop}px + ${R.height}px)`:"100vh"},children:[c.jsx(nM,{}),c.jsx(X3,{onMenuClick:ne,onCriteriaToggle:I}),c.jsx("div",{className:"flex-1 flex overflow-hidden",children:c.jsxs(oD,{children:[c.jsx(Kl,{path:"/onboarding",children:c.jsx(zU,{})}),c.jsx(Kl,{path:"/p/:projectId/s/:sessionId",children:c.jsx(BU,{sidebarOpen:q,onSidebarToggle:ne,rightSidebarOpen:J,onRightSidebarToggle:I})}),c.jsx(Kl,{path:"/p/:projectId/new",children:c.jsx(cM,{})}),c.jsx(Kl,{path:"/p/:projectId",children:c.jsx(PU,{sidebarOpen:q,onSidebarToggle:ne})}),c.jsx(Kl,{path:"/",children:c.jsx(lM,{})})]})})]}),c.jsx(IU,{})]})}MA.createRoot(document.getElementById("root")).render(c.jsx(Li.StrictMode,{children:c.jsx($U,{})}));