openfox 2.0.118 → 2.0.119

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 (55) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/CHANGELOG.md +26 -0
  3. package/dist/agent-defaults/code-reviewer.agent.md +8 -3
  4. package/dist/{auto-config-AAUO4PKW.js → auto-config-YXNCBYEY.js} +125 -11
  5. package/dist/{chat-handler-KNBP6WVI.js → chat-handler-M54IWF5Y.js} +11 -10
  6. package/dist/{chunk-HZSKKJHQ.js → chunk-5FAPM2GM.js} +28 -9
  7. package/dist/{chunk-CX7UJZA5.js → chunk-6DDB67FN.js} +4 -4
  8. package/dist/{chunk-5ZR5O5GC.js → chunk-AIFZNTUJ.js} +4 -4
  9. package/dist/{chunk-45OS4H3L.js → chunk-AVQCOSOF.js} +7 -7
  10. package/dist/chunk-EW25UQG3.js +7 -0
  11. package/dist/{chunk-MKWS7TQH.js → chunk-J6KFWVZ3.js} +21 -15
  12. package/dist/chunk-K2QKX4ZJ.js +31 -0
  13. package/dist/{chunk-TOKQ2UVG.js → chunk-MIPQOHWS.js} +20 -6
  14. package/dist/{chunk-NP2SV2CX.js → chunk-SE62ZBNX.js} +9 -3
  15. package/dist/{chunk-GZTMCTUS.js → chunk-U6JMRMBW.js} +17 -21
  16. package/dist/{chunk-5E5G3DLI.js → chunk-UNNCD7A3.js} +3 -3
  17. package/dist/{chunk-IDUXGSQV.js → chunk-V5XWUVF5.js} +13 -9
  18. package/dist/{chunk-MTFLMNLN.js → chunk-VFS7TFA7.js} +2 -2
  19. package/dist/{chunk-Y6WWEQPC.js → chunk-XB7IXMUI.js} +11 -11
  20. package/dist/{chunk-RXIDGWNV.js → chunk-XZ2WAI66.js} +56 -26
  21. package/dist/{chunk-CIYA6BNB.js → chunk-YHAE2SJI.js} +2 -2
  22. package/dist/cli/dev.js +1 -1
  23. package/dist/cli/index.js +1 -1
  24. package/dist/{client-KCNTDTIR.js → client-R4PI64IL.js} +3 -3
  25. package/dist/{client-pure-B5DHEKQJ.js → client-pure-QSY7TJGK.js} +2 -2
  26. package/dist/{compactor-5ATICQ2A.js → compactor-F6XMYVHL.js} +4 -4
  27. package/dist/{dynamic-context-4SKLIPJ4.js → dynamic-context-NXQ2TFAZ.js} +2 -2
  28. package/dist/{launch-Q6GUJ22H.js → launch-I5XBYRSJ.js} +11 -10
  29. package/dist/{orchestrator-DVCGWWNA.js → orchestrator-MNON5G7R.js} +10 -9
  30. package/dist/package.json +1 -1
  31. package/dist/{processor-G6UJGA2K.js → processor-OZSK7RUD.js} +10 -9
  32. package/dist/{protocol-DzJrspsl.d.ts → protocol-D5kJLGWy.d.ts} +1 -1
  33. package/dist/provider/index.d.ts +4 -4
  34. package/dist/{provider-Q7J4UFTS.js → provider-7YF42S7C.js} +5 -4
  35. package/dist/{provider-manager-TMBO4DFG.js → provider-manager-FJIPQJMX.js} +5 -4
  36. package/dist/{serve-23YIIMXH.js → serve-V34QG72C.js} +16 -15
  37. package/dist/server/index.d.ts +5 -3
  38. package/dist/server/index.js +15 -14
  39. package/dist/{server-IDXIAC5L.js → server-XZQLWIVD.js} +14 -13
  40. package/dist/{service-M7XJHAK4.js → service-ZKH465DA.js} +6 -5
  41. package/dist/session-status-6Q5B5PEN.js +35 -0
  42. package/dist/shared/index.d.ts +3 -3
  43. package/dist/{tasks-X5H5HM4J.js → tasks-I766NBPW.js} +8 -6
  44. package/dist/{tools-GOGLGTNV.js → tools-ZJXDZLRH.js} +8 -7
  45. package/dist/{types-CIVhQMvD.d.ts → types-B5CI_Ql3.d.ts} +3 -1
  46. package/dist/{types-Df7NM9b5.d.ts → types-CZlj7ufS.d.ts} +2 -0
  47. package/dist/{update-T3YMIWQO.js → update-C3YVPKCR.js} +2 -2
  48. package/dist/web/assets/index-BlYcAqzD.js +324 -0
  49. package/dist/web/assets/{index-XTp1QlHA.css → index-D9sfxcRH.css} +1 -1
  50. package/dist/web/index.html +2 -2
  51. package/dist/web/sw.js +1 -1
  52. package/dist/workflow-defaults/default.workflow.json +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunk-BSULZIPW.js +0 -7
  55. package/dist/web/assets/index-BgENxR9h.js +0 -324
@@ -0,0 +1,324 @@
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 fD=Object.defineProperty;var mD=Object.getPrototypeOf;var pD=Reflect.get;var Nw=e=>{throw TypeError(e)};var gD=(e,t,n)=>t in e?fD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Te=(e,t,n)=>gD(e,typeof t!="symbol"?t+"":t,n),Lg=(e,t,n)=>t.has(e)||Nw("Cannot "+n);var lr=(e,t,n)=>(Lg(e,t,"read from private field"),n?n.call(e):t.get(e)),Oa=(e,t,n)=>t.has(e)?Nw("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),cs=(e,t,n,r)=>(Lg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Rg=(e,t,n)=>(Lg(e,t,"access private method"),n);var Tw=(e,t,n)=>pD(mD(e),n,t);function xD(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const d of o.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Lf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Dg={exports:{}},Dc={};/**
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 Aw;function yD(){if(Aw)return Dc;Aw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var d=null;if(o!==void 0&&(d=""+o),a.key!==void 0&&(d=""+a.key),"key"in a){o={};for(var u in a)u!=="key"&&(o[u]=a[u])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:d,ref:a!==void 0?a:null,props:o}}return Dc.Fragment=t,Dc.jsx=n,Dc.jsxs=n,Dc}var Lw;function bD(){return Lw||(Lw=1,Dg.exports=yD()),Dg.exports}var s=bD(),Og={exports:{}},St={};/**
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 Rw;function vD(){if(Rw)return St;Rw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function x(M){return M===null||typeof M!="object"?null:(M=g&&M[g]||M["@@iterator"],typeof M=="function"?M:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,v={};function S(M,V,$){this.props=M,this.context=V,this.refs=v,this.updater=$||w}S.prototype.isReactComponent={},S.prototype.setState=function(M,V){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,V,"setState")},S.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function _(){}_.prototype=S.prototype;function b(M,V,$){this.props=M,this.context=V,this.refs=v,this.updater=$||w}var j=b.prototype=new _;j.constructor=b,C(j,S.prototype),j.isPureReactComponent=!0;var E=Array.isArray;function N(){}var L={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function D(M,V,$){var ee=$.ref;return{$$typeof:e,type:M,key:V,ref:ee!==void 0?ee:null,props:$}}function O(M,V){return D(M.type,V,M.props)}function F(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function P(M){var V={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function($){return V[$]})}var z=/\/+/g;function K(M,V){return typeof M=="object"&&M!==null&&M.key!=null?P(""+M.key):V.toString(36)}function q(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(N,N):(M.status="pending",M.then(function(V){M.status==="pending"&&(M.status="fulfilled",M.value=V)},function(V){M.status==="pending"&&(M.status="rejected",M.reason=V)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function W(M,V,$,ee,Y){var X=typeof M;(X==="undefined"||X==="boolean")&&(M=null);var U=!1;if(M===null)U=!0;else switch(X){case"bigint":case"string":case"number":U=!0;break;case"object":switch(M.$$typeof){case e:case t:U=!0;break;case m:return U=M._init,W(U(M._payload),V,$,ee,Y)}}if(U)return Y=Y(M),U=ee===""?"."+K(M,0):ee,E(Y)?($="",U!=null&&($=U.replace(z,"$&/")+"/"),W(Y,V,$,"",function(se){return se})):Y!=null&&(F(Y)&&(Y=O(Y,$+(Y.key==null||M&&M.key===Y.key?"":(""+Y.key).replace(z,"$&/")+"/")+U)),V.push(Y)),1;U=0;var B=ee===""?".":ee+":";if(E(M))for(var J=0;J<M.length;J++)ee=M[J],X=B+K(ee,J),U+=W(ee,V,$,X,Y);else if(J=x(M),typeof J=="function")for(M=J.call(M),J=0;!(ee=M.next()).done;)ee=ee.value,X=B+K(ee,J++),U+=W(ee,V,$,X,Y);else if(X==="object"){if(typeof M.then=="function")return W(q(M),V,$,ee,Y);throw V=String(M),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return U}function Z(M,V,$){if(M==null)return M;var ee=[],Y=0;return W(M,ee,"","",function(X){return V.call($,X,Y++)}),ee}function Q(M){if(M._status===-1){var V=M._result;V=V(),V.then(function($){(M._status===0||M._status===-1)&&(M._status=1,M._result=$)},function($){(M._status===0||M._status===-1)&&(M._status=2,M._result=$)}),M._status===-1&&(M._status=0,M._result=V)}if(M._status===1)return M._result.default;throw M._result}var H=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},I={map:Z,forEach:function(M,V,$){Z(M,function(){V.apply(this,arguments)},$)},count:function(M){var V=0;return Z(M,function(){V++}),V},toArray:function(M){return Z(M,function(V){return V})||[]},only:function(M){if(!F(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return St.Activity=f,St.Children=I,St.Component=S,St.Fragment=n,St.Profiler=a,St.PureComponent=b,St.StrictMode=r,St.Suspense=c,St.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,St.__COMPILER_RUNTIME={__proto__:null,c:function(M){return L.H.useMemoCache(M)}},St.cache=function(M){return function(){return M.apply(null,arguments)}},St.cacheSignal=function(){return null},St.cloneElement=function(M,V,$){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var ee=C({},M.props),Y=M.key;if(V!=null)for(X in V.key!==void 0&&(Y=""+V.key),V)!A.call(V,X)||X==="key"||X==="__self"||X==="__source"||X==="ref"&&V.ref===void 0||(ee[X]=V[X]);var X=arguments.length-2;if(X===1)ee.children=$;else if(1<X){for(var U=Array(X),B=0;B<X;B++)U[B]=arguments[B+2];ee.children=U}return D(M.type,Y,ee)},St.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:o,_context:M},M},St.createElement=function(M,V,$){var ee,Y={},X=null;if(V!=null)for(ee in V.key!==void 0&&(X=""+V.key),V)A.call(V,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(Y[ee]=V[ee]);var U=arguments.length-2;if(U===1)Y.children=$;else if(1<U){for(var B=Array(U),J=0;J<U;J++)B[J]=arguments[J+2];Y.children=B}if(M&&M.defaultProps)for(ee in U=M.defaultProps,U)Y[ee]===void 0&&(Y[ee]=U[ee]);return D(M,X,Y)},St.createRef=function(){return{current:null}},St.forwardRef=function(M){return{$$typeof:u,render:M}},St.isValidElement=F,St.lazy=function(M){return{$$typeof:m,_payload:{_status:-1,_result:M},_init:Q}},St.memo=function(M,V){return{$$typeof:h,type:M,compare:V===void 0?null:V}},St.startTransition=function(M){var V=L.T,$={};L.T=$;try{var ee=M(),Y=L.S;Y!==null&&Y($,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(N,H)}catch(X){H(X)}finally{V!==null&&$.types!==null&&(V.types=$.types),L.T=V}},St.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},St.use=function(M){return L.H.use(M)},St.useActionState=function(M,V,$){return L.H.useActionState(M,V,$)},St.useCallback=function(M,V){return L.H.useCallback(M,V)},St.useContext=function(M){return L.H.useContext(M)},St.useDebugValue=function(){},St.useDeferredValue=function(M,V){return L.H.useDeferredValue(M,V)},St.useEffect=function(M,V){return L.H.useEffect(M,V)},St.useEffectEvent=function(M){return L.H.useEffectEvent(M)},St.useId=function(){return L.H.useId()},St.useImperativeHandle=function(M,V,$){return L.H.useImperativeHandle(M,V,$)},St.useInsertionEffect=function(M,V){return L.H.useInsertionEffect(M,V)},St.useLayoutEffect=function(M,V){return L.H.useLayoutEffect(M,V)},St.useMemo=function(M,V){return L.H.useMemo(M,V)},St.useOptimistic=function(M,V){return L.H.useOptimistic(M,V)},St.useReducer=function(M,V,$){return L.H.useReducer(M,V,$)},St.useRef=function(M){return L.H.useRef(M)},St.useState=function(M){return L.H.useState(M)},St.useSyncExternalStore=function(M,V,$){return L.H.useSyncExternalStore(M,V,$)},St.useTransition=function(){return L.H.useTransition()},St.version="19.2.8",St}var Dw;function Rf(){return Dw||(Dw=1,Og.exports=vD()),Og.exports}var k=Rf();const ps=Lf(k),_D=xD({__proto__:null,default:ps},[k]);var Mg={exports:{}},Oc={},Ig={exports:{}},Pg={};/**
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 Ow;function SD(){return Ow||(Ow=1,(function(e){function t(W,Z){var Q=W.length;W.push(Z);e:for(;0<Q;){var H=Q-1>>>1,I=W[H];if(0<a(I,Z))W[H]=Z,W[Q]=I,Q=H;else break e}}function n(W){return W.length===0?null:W[0]}function r(W){if(W.length===0)return null;var Z=W[0],Q=W.pop();if(Q!==Z){W[0]=Q;e:for(var H=0,I=W.length,M=I>>>1;H<M;){var V=2*(H+1)-1,$=W[V],ee=V+1,Y=W[ee];if(0>a($,Q))ee<I&&0>a(Y,$)?(W[H]=Y,W[ee]=Q,H=ee):(W[H]=$,W[V]=Q,H=V);else if(ee<I&&0>a(Y,Q))W[H]=Y,W[ee]=Q,H=ee;else break e}}return Z}function a(W,Z){var Q=W.sortIndex-Z.sortIndex;return Q!==0?Q:W.id-Z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var c=[],h=[],m=1,f=null,g=3,x=!1,w=!1,C=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;function j(W){for(var Z=n(h);Z!==null;){if(Z.callback===null)r(h);else if(Z.startTime<=W)r(h),Z.sortIndex=Z.expirationTime,t(c,Z);else break;Z=n(h)}}function E(W){if(C=!1,j(W),!w)if(n(c)!==null)w=!0,N||(N=!0,P());else{var Z=n(h);Z!==null&&q(E,Z.startTime-W)}}var N=!1,L=-1,A=5,D=-1;function O(){return v?!0:!(e.unstable_now()-D<A)}function F(){if(v=!1,N){var W=e.unstable_now();D=W;var Z=!0;try{e:{w=!1,C&&(C=!1,_(L),L=-1),x=!0;var Q=g;try{t:{for(j(W),f=n(c);f!==null&&!(f.expirationTime>W&&O());){var H=f.callback;if(typeof H=="function"){f.callback=null,g=f.priorityLevel;var I=H(f.expirationTime<=W);if(W=e.unstable_now(),typeof I=="function"){f.callback=I,j(W),Z=!0;break t}f===n(c)&&r(c),j(W)}else r(c);f=n(c)}if(f!==null)Z=!0;else{var M=n(h);M!==null&&q(E,M.startTime-W),Z=!1}}break e}finally{f=null,g=Q,x=!1}Z=void 0}}finally{Z?P():N=!1}}}var P;if(typeof b=="function")P=function(){b(F)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,K=z.port2;z.port1.onmessage=F,P=function(){K.postMessage(null)}}else P=function(){S(F,0)};function q(W,Z){L=S(function(){W(e.unstable_now())},Z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(W){W.callback=null},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(W){switch(g){case 1:case 2:case 3:var Z=3;break;default:Z=g}var Q=g;g=Z;try{return W()}finally{g=Q}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(W,Z){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var Q=g;g=W;try{return Z()}finally{g=Q}},e.unstable_scheduleCallback=function(W,Z,Q){var H=e.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?H+Q:H):Q=H,W){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=Q+I,W={id:m++,callback:Z,priorityLevel:W,startTime:Q,expirationTime:I,sortIndex:-1},Q>H?(W.sortIndex=Q,t(h,W),n(c)===null&&W===n(h)&&(C?(_(L),L=-1):C=!0,q(E,Q-H))):(W.sortIndex=I,t(c,W),w||x||(w=!0,N||(N=!0,P()))),W},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(W){var Z=g;return function(){var Q=g;g=Z;try{return W.apply(this,arguments)}finally{g=Q}}}})(Pg)),Pg}var Mw;function wD(){return Mw||(Mw=1,Ig.exports=SD()),Ig.exports}var Bg={exports:{}},nr={};/**
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 Iw;function CD(){if(Iw)return nr;Iw=1;var e=Rf();function t(c){var h="https://react.dev/errors/"+c;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)h+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+c+"; 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},a=Symbol.for("react.portal");function o(c,h,m){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:f==null?null:""+f,children:c,containerInfo:h,implementation:m}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(c,h){if(c==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,nr.createPortal=function(c,h){var m=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 o(c,h,null,m)},nr.flushSync=function(c){var h=d.T,m=r.p;try{if(d.T=null,r.p=2,c)return c()}finally{d.T=h,r.p=m,r.d.f()}},nr.preconnect=function(c,h){typeof c=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(c,h))},nr.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},nr.preinit=function(c,h){if(typeof c=="string"&&h&&typeof h.as=="string"){var m=h.as,f=u(m,h.crossOrigin),g=typeof h.integrity=="string"?h.integrity:void 0,x=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;m==="style"?r.d.S(c,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:x}):m==="script"&&r.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:x,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},nr.preinitModule=function(c,h){if(typeof c=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var m=u(h.as,h.crossOrigin);r.d.M(c,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(c)},nr.preload=function(c,h){if(typeof c=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var m=h.as,f=u(m,h.crossOrigin);r.d.L(c,m,{crossOrigin:f,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})}},nr.preloadModule=function(c,h){if(typeof c=="string")if(h){var m=u(h.as,h.crossOrigin);r.d.m(c,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(c)},nr.requestFormReset=function(c){r.d.r(c)},nr.unstable_batchedUpdates=function(c,h){return c(h)},nr.useFormState=function(c,h,m){return d.H.useFormState(c,h,m)},nr.useFormStatus=function(){return d.H.useHostTransitionStatus()},nr.version="19.2.8",nr}var Pw;function bj(){if(Pw)return Bg.exports;Pw=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(),Bg.exports=CD(),Bg.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 Bw;function kD(){if(Bw)return Oc;Bw=1;var e=wD(),t=Rf(),n=bj();function r(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function o(i){var l=i,p=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(p=l.return),i=l.return;while(i)}return l.tag===3?p:null}function d(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function u(i){if(i.tag===31){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function c(i){if(o(i)!==i)throw Error(r(188))}function h(i){var l=i.alternate;if(!l){if(l=o(i),l===null)throw Error(r(188));return l!==i?null:i}for(var p=i,y=l;;){var T=p.return;if(T===null)break;var R=T.alternate;if(R===null){if(y=T.return,y!==null){p=y;continue}break}if(T.child===R.child){for(R=T.child;R;){if(R===p)return c(T),i;if(R===y)return c(T),l;R=R.sibling}throw Error(r(188))}if(p.return!==y.return)p=T,y=R;else{for(var G=!1,te=T.child;te;){if(te===p){G=!0,p=T,y=R;break}if(te===y){G=!0,y=T,p=R;break}te=te.sibling}if(!G){for(te=R.child;te;){if(te===p){G=!0,p=R,y=T;break}if(te===y){G=!0,y=R,p=T;break}te=te.sibling}if(!G)throw Error(r(189))}}if(p.alternate!==y)throw Error(r(190))}if(p.tag!==3)throw Error(r(188));return p.stateNode.current===p?i:l}function m(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=m(i),l!==null)return l;i=i.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),b=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function P(i){return i===null||typeof i!="object"?null:(i=F&&i[F]||i["@@iterator"],typeof i=="function"?i:null)}var z=Symbol.for("react.client.reference");function K(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===z?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case S:return"Profiler";case v:return"StrictMode";case E:return"Suspense";case N:return"SuspenseList";case D:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case b:return i.displayName||"Context";case _:return(i._context.displayName||"Context")+".Consumer";case j:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case L:return l=i.displayName||null,l!==null?l:K(i.type)||"Memo";case A:l=i._payload,i=i._init;try{return K(i(l))}catch{}}return null}var q=Array.isArray,W=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},H=[],I=-1;function M(i){return{current:i}}function V(i){0>I||(i.current=H[I],H[I]=null,I--)}function $(i,l){I++,H[I]=i.current,i.current=l}var ee=M(null),Y=M(null),X=M(null),U=M(null);function B(i,l){switch($(X,l),$(Y,i),$(ee,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?QS(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=QS(l),i=JS(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}V(ee),$(ee,i)}function J(){V(ee),V(Y),V(X)}function se(i){i.memoizedState!==null&&$(U,i);var l=ee.current,p=JS(l,i.type);l!==p&&($(Y,i),$(ee,p))}function ne(i){Y.current===i&&(V(ee),V(Y)),U.current===i&&(V(U),Tc._currentValue=Q)}var ie,de;function pe(i){if(ie===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);ie=l&&l[1]||"",de=-1<p.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+ie+i+de}var Oe=!1;function $e(i,l){if(!i||Oe)return"";Oe=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var y={DetermineComponentFrameRoot:function(){try{if(l){var ze=function(){throw Error()};if(Object.defineProperty(ze.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ze,[])}catch(Ce){var we=Ce}Reflect.construct(i,[],ze)}else{try{ze.call()}catch(Ce){we=Ce}i.call(ze.prototype)}}else{try{throw Error()}catch(Ce){we=Ce}(ze=i())&&typeof ze.catch=="function"&&ze.catch(function(){})}}catch(Ce){if(Ce&&we&&typeof Ce.stack=="string")return[Ce.stack,we.stack]}return[null,null]}};y.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var T=Object.getOwnPropertyDescriptor(y.DetermineComponentFrameRoot,"name");T&&T.configurable&&Object.defineProperty(y.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var R=y.DetermineComponentFrameRoot(),G=R[0],te=R[1];if(G&&te){var oe=G.split(`
45
+ `),xe=te.split(`
46
+ `);for(T=y=0;y<oe.length&&!oe[y].includes("DetermineComponentFrameRoot");)y++;for(;T<xe.length&&!xe[T].includes("DetermineComponentFrameRoot");)T++;if(y===oe.length||T===xe.length)for(y=oe.length-1,T=xe.length-1;1<=y&&0<=T&&oe[y]!==xe[T];)T--;for(;1<=y&&0<=T;y--,T--)if(oe[y]!==xe[T]){if(y!==1||T!==1)do if(y--,T--,0>T||oe[y]!==xe[T]){var Ie=`
47
+ `+oe[y].replace(" at new "," at ");return i.displayName&&Ie.includes("<anonymous>")&&(Ie=Ie.replace("<anonymous>",i.displayName)),Ie}while(1<=y&&0<=T);break}}}finally{Oe=!1,Error.prepareStackTrace=p}return(p=i?i.displayName||i.name:"")?pe(p):""}function Pe(i,l){switch(i.tag){case 26:case 27:case 5:return pe(i.type);case 16:return pe("Lazy");case 13:return i.child!==l&&l!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return $e(i.type,!1);case 11:return $e(i.type.render,!1);case 1:return $e(i.type,!0);case 31:return pe("Activity");default:return""}}function Ve(i){try{var l="",p=null;do l+=Pe(i,p),p=i,i=i.return;while(i);return l}catch(y){return`
48
+ Error generating stack: `+y.message+`
49
+ `+y.stack}}var Ye=Object.prototype.hasOwnProperty,ot=e.unstable_scheduleCallback,Ae=e.unstable_cancelCallback,me=e.unstable_shouldYield,re=e.unstable_requestPaint,_e=e.unstable_now,Me=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,Ne=e.unstable_UserBlockingPriority,Xe=e.unstable_NormalPriority,at=e.unstable_LowPriority,fe=e.unstable_IdlePriority,We=e.log,Ze=e.unstable_setDisableYieldValue,it=null,nt=null;function De(i){if(typeof We=="function"&&Ze(i),nt&&typeof nt.setStrictMode=="function")try{nt.setStrictMode(it,i)}catch{}}var Re=Math.clz32?Math.clz32:ve,Se=Math.log,Ue=Math.LN2;function ve(i){return i>>>=0,i===0?32:31-(Se(i)/Ue|0)|0}var tt=256,et=262144,dt=4194304;function Lt(i){var l=i&42;if(l!==0)return l;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 qt(i,l,p){var y=i.pendingLanes;if(y===0)return 0;var T=0,R=i.suspendedLanes,G=i.pingedLanes;i=i.warmLanes;var te=y&134217727;return te!==0?(y=te&~R,y!==0?T=Lt(y):(G&=te,G!==0?T=Lt(G):p||(p=te&~i,p!==0&&(T=Lt(p))))):(te=y&~R,te!==0?T=Lt(te):G!==0?T=Lt(G):p||(p=y&~i,p!==0&&(T=Lt(p)))),T===0?0:l!==0&&l!==T&&(l&R)===0&&(R=T&-T,p=l&-l,R>=p||R===32&&(p&4194048)!==0)?l:T}function vn(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function _n(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 xn(){var i=dt;return dt<<=1,(dt&62914560)===0&&(dt=4194304),i}function hr(i){for(var l=[],p=0;31>p;p++)l.push(i);return l}function be(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function rt(i,l,p,y,T,R){var G=i.pendingLanes;i.pendingLanes=p,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=p,i.entangledLanes&=p,i.errorRecoveryDisabledLanes&=p,i.shellSuspendCounter=0;var te=i.entanglements,oe=i.expirationTimes,xe=i.hiddenUpdates;for(p=G&~p;0<p;){var Ie=31-Re(p),ze=1<<Ie;te[Ie]=0,oe[Ie]=-1;var we=xe[Ie];if(we!==null)for(xe[Ie]=null,Ie=0;Ie<we.length;Ie++){var Ce=we[Ie];Ce!==null&&(Ce.lane&=-536870913)}p&=~ze}y!==0&&Qe(i,y,0),R!==0&&T===0&&i.tag!==0&&(i.suspendedLanes|=R&~(G&~l))}function Qe(i,l,p){i.pendingLanes|=l,i.suspendedLanes&=~l;var y=31-Re(l);i.entangledLanes|=l,i.entanglements[y]=i.entanglements[y]|1073741824|p&261930}function He(i,l){var p=i.entangledLanes|=l;for(i=i.entanglements;p;){var y=31-Re(p),T=1<<y;T&l|i[y]&l&&(i[y]|=l),p&=~T}}function le(i,l){var p=l&-l;return p=(p&42)!==0?1:Ke(p),(p&(i.suspendedLanes|l))!==0?0:p}function Ke(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 xt(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Mt(){var i=Z.p;return i!==0?i:(i=window.event,i===void 0?32:_w(i.type))}function ke(i,l){var p=Z.p;try{return Z.p=i,l()}finally{Z.p=p}}var Ee=Math.random().toString(36).slice(2),Fe="__reactFiber$"+Ee,Je="__reactProps$"+Ee,st="__reactContainer$"+Ee,bt="__reactEvents$"+Ee,jt="__reactListeners$"+Ee,In="__reactHandles$"+Ee,Cn="__reactResources$"+Ee,Tn="__reactMarker$"+Ee;function fo(i){delete i[Fe],delete i[Je],delete i[bt],delete i[jt],delete i[In]}function Ws(i){var l=i[Fe];if(l)return l;for(var p=i.parentNode;p;){if(l=p[st]||p[Fe]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(i=iw(i);i!==null;){if(p=i[Fe])return p;i=iw(i)}return l}i=p,p=i.parentNode}return null}function mo(i){if(i=i[Fe]||i[st]){var l=i.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return i}return null}function Wl(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i.stateNode;throw Error(r(33))}function po(i){var l=i[Cn];return l||(l=i[Cn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function Hn(i){i[Tn]=!0}var $v=new Set,Fv={};function xa(i,l){go(i,l),go(i+"Capture",l)}function go(i,l){for(Fv[i]=l,i=0;i<l.length;i++)$v.add(l[i])}var sL=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]*$"),zv={},Hv={};function iL(i){return Ye.call(Hv,i)?!0:Ye.call(zv,i)?!1:sL.test(i)?Hv[i]=!0:(zv[i]=!0,!1)}function Hu(i,l,p){if(iL(l))if(p===null)i.removeAttribute(l);else{switch(typeof p){case"undefined":case"function":case"symbol":i.removeAttribute(l);return;case"boolean":var y=l.toLowerCase().slice(0,5);if(y!=="data-"&&y!=="aria-"){i.removeAttribute(l);return}}i.setAttribute(l,""+p)}}function Uu(i,l,p){if(p===null)i.removeAttribute(l);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(l);return}i.setAttribute(l,""+p)}}function Gs(i,l,p,y){if(y===null)i.removeAttribute(p);else{switch(typeof y){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(p);return}i.setAttributeNS(l,p,""+y)}}function Hr(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Uv(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function aL(i,l,p){var y=Object.getOwnPropertyDescriptor(i.constructor.prototype,l);if(!i.hasOwnProperty(l)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var T=y.get,R=y.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return T.call(this)},set:function(G){p=""+G,R.call(this,G)}}),Object.defineProperty(i,l,{enumerable:y.enumerable}),{getValue:function(){return p},setValue:function(G){p=""+G},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function Cm(i){if(!i._valueTracker){var l=Uv(i)?"checked":"value";i._valueTracker=aL(i,l,""+i[l])}}function Vv(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var p=l.getValue(),y="";return i&&(y=Uv(i)?i.checked?"true":"false":i.value),i=y,i!==p?(l.setValue(i),!0):!1}function Vu(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 oL=/[\n"\\]/g;function Ur(i){return i.replace(oL,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function km(i,l,p,y,T,R,G,te){i.name="",G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"?i.type=G:i.removeAttribute("type"),l!=null?G==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+Hr(l)):i.value!==""+Hr(l)&&(i.value=""+Hr(l)):G!=="submit"&&G!=="reset"||i.removeAttribute("value"),l!=null?jm(i,G,Hr(l)):p!=null?jm(i,G,Hr(p)):y!=null&&i.removeAttribute("value"),T==null&&R!=null&&(i.defaultChecked=!!R),T!=null&&(i.checked=T&&typeof T!="function"&&typeof T!="symbol"),te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"?i.name=""+Hr(te):i.removeAttribute("name")}function Wv(i,l,p,y,T,R,G,te){if(R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(i.type=R),l!=null||p!=null){if(!(R!=="submit"&&R!=="reset"||l!=null)){Cm(i);return}p=p!=null?""+Hr(p):"",l=l!=null?""+Hr(l):p,te||l===i.value||(i.value=l),i.defaultValue=l}y=y??T,y=typeof y!="function"&&typeof y!="symbol"&&!!y,i.checked=te?i.checked:!!y,i.defaultChecked=!!y,G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"&&(i.name=G),Cm(i)}function jm(i,l,p){l==="number"&&Vu(i.ownerDocument)===i||i.defaultValue===""+p||(i.defaultValue=""+p)}function xo(i,l,p,y){if(i=i.options,l){l={};for(var T=0;T<p.length;T++)l["$"+p[T]]=!0;for(p=0;p<i.length;p++)T=l.hasOwnProperty("$"+i[p].value),i[p].selected!==T&&(i[p].selected=T),T&&y&&(i[p].defaultSelected=!0)}else{for(p=""+Hr(p),l=null,T=0;T<i.length;T++){if(i[T].value===p){i[T].selected=!0,y&&(i[T].defaultSelected=!0);return}l!==null||i[T].disabled||(l=i[T])}l!==null&&(l.selected=!0)}}function Gv(i,l,p){if(l!=null&&(l=""+Hr(l),l!==i.value&&(i.value=l),p==null)){i.defaultValue!==l&&(i.defaultValue=l);return}i.defaultValue=p!=null?""+Hr(p):""}function qv(i,l,p,y){if(l==null){if(y!=null){if(p!=null)throw Error(r(92));if(q(y)){if(1<y.length)throw Error(r(93));y=y[0]}p=y}p==null&&(p=""),l=p}p=Hr(l),i.defaultValue=p,y=i.textContent,y===p&&y!==""&&y!==null&&(i.value=y),Cm(i)}function yo(i,l){if(l){var p=i.firstChild;if(p&&p===i.lastChild&&p.nodeType===3){p.nodeValue=l;return}}i.textContent=l}var lL=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 Kv(i,l,p){var y=l.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?y?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="":y?i.setProperty(l,p):typeof p!="number"||p===0||lL.has(l)?l==="float"?i.cssFloat=p:i[l]=(""+p).trim():i[l]=p+"px"}function Yv(i,l,p){if(l!=null&&typeof l!="object")throw Error(r(62));if(i=i.style,p!=null){for(var y in p)!p.hasOwnProperty(y)||l!=null&&l.hasOwnProperty(y)||(y.indexOf("--")===0?i.setProperty(y,""):y==="float"?i.cssFloat="":i[y]="");for(var T in l)y=l[T],l.hasOwnProperty(T)&&p[T]!==y&&Kv(i,T,y)}else for(var R in l)l.hasOwnProperty(R)&&Kv(i,R,l[R])}function Em(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 cL=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"]]),uL=/^[\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 Wu(i){return uL.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function qs(){}var Nm=null;function Tm(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var bo=null,vo=null;function Xv(i){var l=mo(i);if(l&&(i=l.stateNode)){var p=i[Je]||null;e:switch(i=l.stateNode,l.type){case"input":if(km(i,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),l=p.name,p.type==="radio"&&l!=null){for(p=i;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+Ur(""+l)+'"][type="radio"]'),l=0;l<p.length;l++){var y=p[l];if(y!==i&&y.form===i.form){var T=y[Je]||null;if(!T)throw Error(r(90));km(y,T.value,T.defaultValue,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name)}}for(l=0;l<p.length;l++)y=p[l],y.form===i.form&&Vv(y)}break e;case"textarea":Gv(i,p.value,p.defaultValue);break e;case"select":l=p.value,l!=null&&xo(i,!!p.multiple,l,!1)}}}var Am=!1;function Qv(i,l,p){if(Am)return i(l,p);Am=!0;try{var y=i(l);return y}finally{if(Am=!1,(bo!==null||vo!==null)&&(Rd(),bo&&(l=bo,i=vo,vo=bo=null,Xv(l),i)))for(l=0;l<i.length;l++)Xv(i[l])}}function Gl(i,l){var p=i.stateNode;if(p===null)return null;var y=p[Je]||null;if(y===null)return null;p=y[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(i=i.type,y=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!y;break e;default:i=!1}if(i)return null;if(p&&typeof p!="function")throw Error(r(231,l,typeof p));return p}var Ks=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Lm=!1;if(Ks)try{var ql={};Object.defineProperty(ql,"passive",{get:function(){Lm=!0}}),window.addEventListener("test",ql,ql),window.removeEventListener("test",ql,ql)}catch{Lm=!1}var ji=null,Rm=null,Gu=null;function Jv(){if(Gu)return Gu;var i,l=Rm,p=l.length,y,T="value"in ji?ji.value:ji.textContent,R=T.length;for(i=0;i<p&&l[i]===T[i];i++);var G=p-i;for(y=1;y<=G&&l[p-y]===T[R-y];y++);return Gu=T.slice(i,1<y?1-y:void 0)}function qu(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function Ku(){return!0}function Zv(){return!1}function fr(i){function l(p,y,T,R,G){this._reactName=p,this._targetInst=T,this.type=y,this.nativeEvent=R,this.target=G,this.currentTarget=null;for(var te in i)i.hasOwnProperty(te)&&(p=i[te],this[te]=p?p(R):R[te]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?Ku:Zv,this.isPropagationStopped=Zv,this}return f(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Ku)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Ku)},persist:function(){},isPersistent:Ku}),l}var ya={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yu=fr(ya),Kl=f({},ya,{view:0,detail:0}),dL=fr(Kl),Dm,Om,Yl,Xu=f({},Kl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Im,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!==Yl&&(Yl&&i.type==="mousemove"?(Dm=i.screenX-Yl.screenX,Om=i.screenY-Yl.screenY):Om=Dm=0,Yl=i),Dm)},movementY:function(i){return"movementY"in i?i.movementY:Om}}),e_=fr(Xu),hL=f({},Xu,{dataTransfer:0}),fL=fr(hL),mL=f({},Kl,{relatedTarget:0}),Mm=fr(mL),pL=f({},ya,{animationName:0,elapsedTime:0,pseudoElement:0}),gL=fr(pL),xL=f({},ya,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),yL=fr(xL),bL=f({},ya,{data:0}),t_=fr(bL),vL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},_L={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"},SL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wL(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=SL[i])?!!l[i]:!1}function Im(){return wL}var CL=f({},Kl,{key:function(i){if(i.key){var l=vL[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=qu(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?_L[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Im,charCode:function(i){return i.type==="keypress"?qu(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?qu(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),kL=fr(CL),jL=f({},Xu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),n_=fr(jL),EL=f({},Kl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Im}),NL=fr(EL),TL=f({},ya,{propertyName:0,elapsedTime:0,pseudoElement:0}),AL=fr(TL),LL=f({},Xu,{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}),RL=fr(LL),DL=f({},ya,{newState:0,oldState:0}),OL=fr(DL),ML=[9,13,27,32],Pm=Ks&&"CompositionEvent"in window,Xl=null;Ks&&"documentMode"in document&&(Xl=document.documentMode);var IL=Ks&&"TextEvent"in window&&!Xl,r_=Ks&&(!Pm||Xl&&8<Xl&&11>=Xl),s_=" ",i_=!1;function a_(i,l){switch(i){case"keyup":return ML.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function o_(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var _o=!1;function PL(i,l){switch(i){case"compositionend":return o_(l);case"keypress":return l.which!==32?null:(i_=!0,s_);case"textInput":return i=l.data,i===s_&&i_?null:i;default:return null}}function BL(i,l){if(_o)return i==="compositionend"||!Pm&&a_(i,l)?(i=Jv(),Gu=Rm=ji=null,_o=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return r_&&l.locale!=="ko"?null:l.data;default:return null}}var $L={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 l_(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!$L[i.type]:l==="textarea"}function c_(i,l,p,y){bo?vo?vo.push(y):vo=[y]:bo=y,l=$d(l,"onChange"),0<l.length&&(p=new Yu("onChange","change",null,p,y),i.push({event:p,listeners:l}))}var Ql=null,Jl=null;function FL(i){WS(i,0)}function Qu(i){var l=Wl(i);if(Vv(l))return i}function u_(i,l){if(i==="change")return l}var d_=!1;if(Ks){var Bm;if(Ks){var $m="oninput"in document;if(!$m){var h_=document.createElement("div");h_.setAttribute("oninput","return;"),$m=typeof h_.oninput=="function"}Bm=$m}else Bm=!1;d_=Bm&&(!document.documentMode||9<document.documentMode)}function f_(){Ql&&(Ql.detachEvent("onpropertychange",m_),Jl=Ql=null)}function m_(i){if(i.propertyName==="value"&&Qu(Jl)){var l=[];c_(l,Jl,i,Tm(i)),Qv(FL,l)}}function zL(i,l,p){i==="focusin"?(f_(),Ql=l,Jl=p,Ql.attachEvent("onpropertychange",m_)):i==="focusout"&&f_()}function HL(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Qu(Jl)}function UL(i,l){if(i==="click")return Qu(l)}function VL(i,l){if(i==="input"||i==="change")return Qu(l)}function WL(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var Er=typeof Object.is=="function"?Object.is:WL;function Zl(i,l){if(Er(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var p=Object.keys(i),y=Object.keys(l);if(p.length!==y.length)return!1;for(y=0;y<p.length;y++){var T=p[y];if(!Ye.call(l,T)||!Er(i[T],l[T]))return!1}return!0}function p_(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function g_(i,l){var p=p_(i);i=0;for(var y;p;){if(p.nodeType===3){if(y=i+p.textContent.length,i<=l&&y>=l)return{node:p,offset:l-i};i=y}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=p_(p)}}function x_(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?x_(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function y_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=Vu(i.document);l instanceof i.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)i=l.contentWindow;else break;l=Vu(i.document)}return l}function Fm(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var GL=Ks&&"documentMode"in document&&11>=document.documentMode,So=null,zm=null,ec=null,Hm=!1;function b_(i,l,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Hm||So==null||So!==Vu(y)||(y=So,"selectionStart"in y&&Fm(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),ec&&Zl(ec,y)||(ec=y,y=$d(zm,"onSelect"),0<y.length&&(l=new Yu("onSelect","select",null,l,p),i.push({event:l,listeners:y}),l.target=So)))}function ba(i,l){var p={};return p[i.toLowerCase()]=l.toLowerCase(),p["Webkit"+i]="webkit"+l,p["Moz"+i]="moz"+l,p}var wo={animationend:ba("Animation","AnimationEnd"),animationiteration:ba("Animation","AnimationIteration"),animationstart:ba("Animation","AnimationStart"),transitionrun:ba("Transition","TransitionRun"),transitionstart:ba("Transition","TransitionStart"),transitioncancel:ba("Transition","TransitionCancel"),transitionend:ba("Transition","TransitionEnd")},Um={},v_={};Ks&&(v_=document.createElement("div").style,"AnimationEvent"in window||(delete wo.animationend.animation,delete wo.animationiteration.animation,delete wo.animationstart.animation),"TransitionEvent"in window||delete wo.transitionend.transition);function va(i){if(Um[i])return Um[i];if(!wo[i])return i;var l=wo[i],p;for(p in l)if(l.hasOwnProperty(p)&&p in v_)return Um[i]=l[p];return i}var __=va("animationend"),S_=va("animationiteration"),w_=va("animationstart"),qL=va("transitionrun"),KL=va("transitionstart"),YL=va("transitioncancel"),C_=va("transitionend"),k_=new Map,Vm="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(" ");Vm.push("scrollEnd");function as(i,l){k_.set(i,l),xa(l,[i])}var Ju=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=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(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Vr=[],Co=0,Wm=0;function Zu(){for(var i=Co,l=Wm=Co=0;l<i;){var p=Vr[l];Vr[l++]=null;var y=Vr[l];Vr[l++]=null;var T=Vr[l];Vr[l++]=null;var R=Vr[l];if(Vr[l++]=null,y!==null&&T!==null){var G=y.pending;G===null?T.next=T:(T.next=G.next,G.next=T),y.pending=T}R!==0&&j_(p,T,R)}}function ed(i,l,p,y){Vr[Co++]=i,Vr[Co++]=l,Vr[Co++]=p,Vr[Co++]=y,Wm|=y,i.lanes|=y,i=i.alternate,i!==null&&(i.lanes|=y)}function Gm(i,l,p,y){return ed(i,l,p,y),td(i)}function _a(i,l){return ed(i,null,null,l),td(i)}function j_(i,l,p){i.lanes|=p;var y=i.alternate;y!==null&&(y.lanes|=p);for(var T=!1,R=i.return;R!==null;)R.childLanes|=p,y=R.alternate,y!==null&&(y.childLanes|=p),R.tag===22&&(i=R.stateNode,i===null||i._visibility&1||(T=!0)),i=R,R=R.return;return i.tag===3?(R=i.stateNode,T&&l!==null&&(T=31-Re(p),i=R.hiddenUpdates,y=i[T],y===null?i[T]=[l]:y.push(l),l.lane=p|536870912),R):null}function td(i){if(50<Sc)throw Sc=0,tg=null,Error(r(185));for(var l=i.return;l!==null;)i=l,l=i.return;return i.tag===3?i.stateNode:null}var ko={};function XL(i,l,p,y){this.tag=i,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nr(i,l,p,y){return new XL(i,l,p,y)}function qm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ys(i,l){var p=i.alternate;return p===null?(p=Nr(i.tag,l,i.key,i.mode),p.elementType=i.elementType,p.type=i.type,p.stateNode=i.stateNode,p.alternate=i,i.alternate=p):(p.pendingProps=l,p.type=i.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=i.flags&65011712,p.childLanes=i.childLanes,p.lanes=i.lanes,p.child=i.child,p.memoizedProps=i.memoizedProps,p.memoizedState=i.memoizedState,p.updateQueue=i.updateQueue,l=i.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=i.sibling,p.index=i.index,p.ref=i.ref,p.refCleanup=i.refCleanup,p}function E_(i,l){i.flags&=65011714;var p=i.alternate;return p===null?(i.childLanes=0,i.lanes=l,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=p.childLanes,i.lanes=p.lanes,i.child=p.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=p.memoizedProps,i.memoizedState=p.memoizedState,i.updateQueue=p.updateQueue,i.type=p.type,l=p.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),i}function nd(i,l,p,y,T,R){var G=0;if(y=i,typeof i=="function")qm(i)&&(G=1);else if(typeof i=="string")G=tD(i,p,ee.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case D:return i=Nr(31,p,l,T),i.elementType=D,i.lanes=R,i;case C:return Sa(p.children,T,R,l);case v:G=8,T|=24;break;case S:return i=Nr(12,p,l,T|2),i.elementType=S,i.lanes=R,i;case E:return i=Nr(13,p,l,T),i.elementType=E,i.lanes=R,i;case N:return i=Nr(19,p,l,T),i.elementType=N,i.lanes=R,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case b:G=10;break e;case _:G=9;break e;case j:G=11;break e;case L:G=14;break e;case A:G=16,y=null;break e}G=29,p=Error(r(130,i===null?"null":typeof i,"")),y=null}return l=Nr(G,p,l,T),l.elementType=i,l.type=y,l.lanes=R,l}function Sa(i,l,p,y){return i=Nr(7,i,y,l),i.lanes=p,i}function Km(i,l,p){return i=Nr(6,i,null,l),i.lanes=p,i}function N_(i){var l=Nr(18,null,null,0);return l.stateNode=i,l}function Ym(i,l,p){return l=Nr(4,i.children!==null?i.children:[],i.key,l),l.lanes=p,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}var T_=new WeakMap;function Wr(i,l){if(typeof i=="object"&&i!==null){var p=T_.get(i);return p!==void 0?p:(l={value:i,source:l,stack:Ve(l)},T_.set(i,l),l)}return{value:i,source:l,stack:Ve(l)}}var jo=[],Eo=0,rd=null,tc=0,Gr=[],qr=0,Ei=null,ks=1,js="";function Xs(i,l){jo[Eo++]=tc,jo[Eo++]=rd,rd=i,tc=l}function A_(i,l,p){Gr[qr++]=ks,Gr[qr++]=js,Gr[qr++]=Ei,Ei=i;var y=ks;i=js;var T=32-Re(y)-1;y&=~(1<<T),p+=1;var R=32-Re(l)+T;if(30<R){var G=T-T%5;R=(y&(1<<G)-1).toString(32),y>>=G,T-=G,ks=1<<32-Re(l)+T|p<<T|y,js=R+i}else ks=1<<R|p<<T|y,js=i}function Xm(i){i.return!==null&&(Xs(i,1),A_(i,1,0))}function Qm(i){for(;i===rd;)rd=jo[--Eo],jo[Eo]=null,tc=jo[--Eo],jo[Eo]=null;for(;i===Ei;)Ei=Gr[--qr],Gr[qr]=null,js=Gr[--qr],Gr[qr]=null,ks=Gr[--qr],Gr[qr]=null}function L_(i,l){Gr[qr++]=ks,Gr[qr++]=js,Gr[qr++]=Ei,ks=l.id,js=l.overflow,Ei=i}var Kn=null,dn=null,Ot=!1,Ni=null,Kr=!1,Jm=Error(r(519));function Ti(i){var l=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw nc(Wr(l,i)),Jm}function R_(i){var l=i.stateNode,p=i.type,y=i.memoizedProps;switch(l[Fe]=i,l[Je]=y,p){case"dialog":Tt("cancel",l),Tt("close",l);break;case"iframe":case"object":case"embed":Tt("load",l);break;case"video":case"audio":for(p=0;p<Cc.length;p++)Tt(Cc[p],l);break;case"source":Tt("error",l);break;case"img":case"image":case"link":Tt("error",l),Tt("load",l);break;case"details":Tt("toggle",l);break;case"input":Tt("invalid",l),Wv(l,y.value,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name,!0);break;case"select":Tt("invalid",l);break;case"textarea":Tt("invalid",l),qv(l,y.value,y.defaultValue,y.children)}p=y.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||l.textContent===""+p||y.suppressHydrationWarning===!0||YS(l.textContent,p)?(y.popover!=null&&(Tt("beforetoggle",l),Tt("toggle",l)),y.onScroll!=null&&Tt("scroll",l),y.onScrollEnd!=null&&Tt("scrollend",l),y.onClick!=null&&(l.onclick=qs),l=!0):l=!1,l||Ti(i,!0)}function D_(i){for(Kn=i.return;Kn;)switch(Kn.tag){case 5:case 31:case 13:Kr=!1;return;case 27:case 3:Kr=!0;return;default:Kn=Kn.return}}function No(i){if(i!==Kn)return!1;if(!Ot)return D_(i),Ot=!0,!1;var l=i.tag,p;if((p=l!==3&&l!==27)&&((p=l===5)&&(p=i.type,p=!(p!=="form"&&p!=="button")||gg(i.type,i.memoizedProps)),p=!p),p&&dn&&Ti(i),D_(i),l===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));dn=sw(i)}else if(l===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));dn=sw(i)}else l===27?(l=dn,Ui(i.type)?(i=_g,_g=null,dn=i):dn=l):dn=Kn?Xr(i.stateNode.nextSibling):null;return!0}function wa(){dn=Kn=null,Ot=!1}function Zm(){var i=Ni;return i!==null&&(xr===null?xr=i:xr.push.apply(xr,i),Ni=null),i}function nc(i){Ni===null?Ni=[i]:Ni.push(i)}var ep=M(null),Ca=null,Qs=null;function Ai(i,l,p){$(ep,l._currentValue),l._currentValue=p}function Js(i){i._currentValue=ep.current,V(ep)}function tp(i,l,p){for(;i!==null;){var y=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,y!==null&&(y.childLanes|=l)):y!==null&&(y.childLanes&l)!==l&&(y.childLanes|=l),i===p)break;i=i.return}}function np(i,l,p,y){var T=i.child;for(T!==null&&(T.return=i);T!==null;){var R=T.dependencies;if(R!==null){var G=T.child;R=R.firstContext;e:for(;R!==null;){var te=R;R=T;for(var oe=0;oe<l.length;oe++)if(te.context===l[oe]){R.lanes|=p,te=R.alternate,te!==null&&(te.lanes|=p),tp(R.return,p,i),y||(G=null);break e}R=te.next}}else if(T.tag===18){if(G=T.return,G===null)throw Error(r(341));G.lanes|=p,R=G.alternate,R!==null&&(R.lanes|=p),tp(G,p,i),G=null}else G=T.child;if(G!==null)G.return=T;else for(G=T;G!==null;){if(G===i){G=null;break}if(T=G.sibling,T!==null){T.return=G.return,G=T;break}G=G.return}T=G}}function To(i,l,p,y){i=null;for(var T=l,R=!1;T!==null;){if(!R){if((T.flags&524288)!==0)R=!0;else if((T.flags&262144)!==0)break}if(T.tag===10){var G=T.alternate;if(G===null)throw Error(r(387));if(G=G.memoizedProps,G!==null){var te=T.type;Er(T.pendingProps.value,G.value)||(i!==null?i.push(te):i=[te])}}else if(T===U.current){if(G=T.alternate,G===null)throw Error(r(387));G.memoizedState.memoizedState!==T.memoizedState.memoizedState&&(i!==null?i.push(Tc):i=[Tc])}T=T.return}i!==null&&np(l,i,p,y),l.flags|=262144}function sd(i){for(i=i.firstContext;i!==null;){if(!Er(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function ka(i){Ca=i,Qs=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Yn(i){return O_(Ca,i)}function id(i,l){return Ca===null&&ka(i),O_(i,l)}function O_(i,l){var p=l._currentValue;if(l={context:l,memoizedValue:p,next:null},Qs===null){if(i===null)throw Error(r(308));Qs=l,i.dependencies={lanes:0,firstContext:l},i.flags|=524288}else Qs=Qs.next=l;return p}var QL=typeof AbortController<"u"?AbortController:function(){var i=[],l=this.signal={aborted:!1,addEventListener:function(p,y){i.push(y)}};this.abort=function(){l.aborted=!0,i.forEach(function(p){return p()})}},JL=e.unstable_scheduleCallback,ZL=e.unstable_NormalPriority,An={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function rp(){return{controller:new QL,data:new Map,refCount:0}}function rc(i){i.refCount--,i.refCount===0&&JL(ZL,function(){i.controller.abort()})}var sc=null,sp=0,Ao=0,Lo=null;function eR(i,l){if(sc===null){var p=sc=[];sp=0,Ao=og(),Lo={status:"pending",value:void 0,then:function(y){p.push(y)}}}return sp++,l.then(M_,M_),l}function M_(){if(--sp===0&&sc!==null){Lo!==null&&(Lo.status="fulfilled");var i=sc;sc=null,Ao=0,Lo=null;for(var l=0;l<i.length;l++)(0,i[l])()}}function tR(i,l){var p=[],y={status:"pending",value:null,reason:null,then:function(T){p.push(T)}};return i.then(function(){y.status="fulfilled",y.value=l;for(var T=0;T<p.length;T++)(0,p[T])(l)},function(T){for(y.status="rejected",y.reason=T,T=0;T<p.length;T++)(0,p[T])(void 0)}),y}var I_=W.S;W.S=function(i,l){bS=_e(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&eR(i,l),I_!==null&&I_(i,l)};var ja=M(null);function ip(){var i=ja.current;return i!==null?i:nn.pooledCache}function ad(i,l){l===null?$(ja,ja.current):$(ja,l.pool)}function P_(){var i=ip();return i===null?null:{parent:An._currentValue,pool:i}}var Ro=Error(r(460)),ap=Error(r(474)),od=Error(r(542)),ld={then:function(){}};function B_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function $_(i,l,p){switch(p=i[p],p===void 0?i.push(l):p!==l&&(l.then(qs,qs),l=p),l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,z_(i),i;default:if(typeof l.status=="string")l.then(qs,qs);else{if(i=nn,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=l,i.status="pending",i.then(function(y){if(l.status==="pending"){var T=l;T.status="fulfilled",T.value=y}},function(y){if(l.status==="pending"){var T=l;T.status="rejected",T.reason=y}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,z_(i),i}throw Na=l,Ro}}function Ea(i){try{var l=i._init;return l(i._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(Na=p,Ro):p}}var Na=null;function F_(){if(Na===null)throw Error(r(459));var i=Na;return Na=null,i}function z_(i){if(i===Ro||i===od)throw Error(r(483))}var Do=null,ic=0;function cd(i){var l=ic;return ic+=1,Do===null&&(Do=[]),$_(Do,i,l)}function ac(i,l){l=l.props.ref,i.ref=l!==void 0?l:null}function ud(i,l){throw l.$$typeof===g?Error(r(525)):(i=Object.prototype.toString.call(l),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i)))}function H_(i){function l(he,ue){if(i){var ge=he.deletions;ge===null?(he.deletions=[ue],he.flags|=16):ge.push(ue)}}function p(he,ue){if(!i)return null;for(;ue!==null;)l(he,ue),ue=ue.sibling;return null}function y(he){for(var ue=new Map;he!==null;)he.key!==null?ue.set(he.key,he):ue.set(he.index,he),he=he.sibling;return ue}function T(he,ue){return he=Ys(he,ue),he.index=0,he.sibling=null,he}function R(he,ue,ge){return he.index=ge,i?(ge=he.alternate,ge!==null?(ge=ge.index,ge<ue?(he.flags|=67108866,ue):ge):(he.flags|=67108866,ue)):(he.flags|=1048576,ue)}function G(he){return i&&he.alternate===null&&(he.flags|=67108866),he}function te(he,ue,ge,Be){return ue===null||ue.tag!==6?(ue=Km(ge,he.mode,Be),ue.return=he,ue):(ue=T(ue,ge),ue.return=he,ue)}function oe(he,ue,ge,Be){var ht=ge.type;return ht===C?Ie(he,ue,ge.props.children,Be,ge.key):ue!==null&&(ue.elementType===ht||typeof ht=="object"&&ht!==null&&ht.$$typeof===A&&Ea(ht)===ue.type)?(ue=T(ue,ge.props),ac(ue,ge),ue.return=he,ue):(ue=nd(ge.type,ge.key,ge.props,null,he.mode,Be),ac(ue,ge),ue.return=he,ue)}function xe(he,ue,ge,Be){return ue===null||ue.tag!==4||ue.stateNode.containerInfo!==ge.containerInfo||ue.stateNode.implementation!==ge.implementation?(ue=Ym(ge,he.mode,Be),ue.return=he,ue):(ue=T(ue,ge.children||[]),ue.return=he,ue)}function Ie(he,ue,ge,Be,ht){return ue===null||ue.tag!==7?(ue=Sa(ge,he.mode,Be,ht),ue.return=he,ue):(ue=T(ue,ge),ue.return=he,ue)}function ze(he,ue,ge){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return ue=Km(""+ue,he.mode,ge),ue.return=he,ue;if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case x:return ge=nd(ue.type,ue.key,ue.props,null,he.mode,ge),ac(ge,ue),ge.return=he,ge;case w:return ue=Ym(ue,he.mode,ge),ue.return=he,ue;case A:return ue=Ea(ue),ze(he,ue,ge)}if(q(ue)||P(ue))return ue=Sa(ue,he.mode,ge,null),ue.return=he,ue;if(typeof ue.then=="function")return ze(he,cd(ue),ge);if(ue.$$typeof===b)return ze(he,id(he,ue),ge);ud(he,ue)}return null}function we(he,ue,ge,Be){var ht=ue!==null?ue.key:null;if(typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint")return ht!==null?null:te(he,ue,""+ge,Be);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case x:return ge.key===ht?oe(he,ue,ge,Be):null;case w:return ge.key===ht?xe(he,ue,ge,Be):null;case A:return ge=Ea(ge),we(he,ue,ge,Be)}if(q(ge)||P(ge))return ht!==null?null:Ie(he,ue,ge,Be,null);if(typeof ge.then=="function")return we(he,ue,cd(ge),Be);if(ge.$$typeof===b)return we(he,ue,id(he,ge),Be);ud(he,ge)}return null}function Ce(he,ue,ge,Be,ht){if(typeof Be=="string"&&Be!==""||typeof Be=="number"||typeof Be=="bigint")return he=he.get(ge)||null,te(ue,he,""+Be,ht);if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case x:return he=he.get(Be.key===null?ge:Be.key)||null,oe(ue,he,Be,ht);case w:return he=he.get(Be.key===null?ge:Be.key)||null,xe(ue,he,Be,ht);case A:return Be=Ea(Be),Ce(he,ue,ge,Be,ht)}if(q(Be)||P(Be))return he=he.get(ge)||null,Ie(ue,he,Be,ht,null);if(typeof Be.then=="function")return Ce(he,ue,ge,cd(Be),ht);if(Be.$$typeof===b)return Ce(he,ue,ge,id(ue,Be),ht);ud(ue,Be)}return null}function lt(he,ue,ge,Be){for(var ht=null,$t=null,ut=ue,kt=ue=0,Dt=null;ut!==null&&kt<ge.length;kt++){ut.index>kt?(Dt=ut,ut=null):Dt=ut.sibling;var Ft=we(he,ut,ge[kt],Be);if(Ft===null){ut===null&&(ut=Dt);break}i&&ut&&Ft.alternate===null&&l(he,ut),ue=R(Ft,ue,kt),$t===null?ht=Ft:$t.sibling=Ft,$t=Ft,ut=Dt}if(kt===ge.length)return p(he,ut),Ot&&Xs(he,kt),ht;if(ut===null){for(;kt<ge.length;kt++)ut=ze(he,ge[kt],Be),ut!==null&&(ue=R(ut,ue,kt),$t===null?ht=ut:$t.sibling=ut,$t=ut);return Ot&&Xs(he,kt),ht}for(ut=y(ut);kt<ge.length;kt++)Dt=Ce(ut,he,kt,ge[kt],Be),Dt!==null&&(i&&Dt.alternate!==null&&ut.delete(Dt.key===null?kt:Dt.key),ue=R(Dt,ue,kt),$t===null?ht=Dt:$t.sibling=Dt,$t=Dt);return i&&ut.forEach(function(Ki){return l(he,Ki)}),Ot&&Xs(he,kt),ht}function gt(he,ue,ge,Be){if(ge==null)throw Error(r(151));for(var ht=null,$t=null,ut=ue,kt=ue=0,Dt=null,Ft=ge.next();ut!==null&&!Ft.done;kt++,Ft=ge.next()){ut.index>kt?(Dt=ut,ut=null):Dt=ut.sibling;var Ki=we(he,ut,Ft.value,Be);if(Ki===null){ut===null&&(ut=Dt);break}i&&ut&&Ki.alternate===null&&l(he,ut),ue=R(Ki,ue,kt),$t===null?ht=Ki:$t.sibling=Ki,$t=Ki,ut=Dt}if(Ft.done)return p(he,ut),Ot&&Xs(he,kt),ht;if(ut===null){for(;!Ft.done;kt++,Ft=ge.next())Ft=ze(he,Ft.value,Be),Ft!==null&&(ue=R(Ft,ue,kt),$t===null?ht=Ft:$t.sibling=Ft,$t=Ft);return Ot&&Xs(he,kt),ht}for(ut=y(ut);!Ft.done;kt++,Ft=ge.next())Ft=Ce(ut,he,kt,Ft.value,Be),Ft!==null&&(i&&Ft.alternate!==null&&ut.delete(Ft.key===null?kt:Ft.key),ue=R(Ft,ue,kt),$t===null?ht=Ft:$t.sibling=Ft,$t=Ft);return i&&ut.forEach(function(hD){return l(he,hD)}),Ot&&Xs(he,kt),ht}function Jt(he,ue,ge,Be){if(typeof ge=="object"&&ge!==null&&ge.type===C&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case x:e:{for(var ht=ge.key;ue!==null;){if(ue.key===ht){if(ht=ge.type,ht===C){if(ue.tag===7){p(he,ue.sibling),Be=T(ue,ge.props.children),Be.return=he,he=Be;break e}}else if(ue.elementType===ht||typeof ht=="object"&&ht!==null&&ht.$$typeof===A&&Ea(ht)===ue.type){p(he,ue.sibling),Be=T(ue,ge.props),ac(Be,ge),Be.return=he,he=Be;break e}p(he,ue);break}else l(he,ue);ue=ue.sibling}ge.type===C?(Be=Sa(ge.props.children,he.mode,Be,ge.key),Be.return=he,he=Be):(Be=nd(ge.type,ge.key,ge.props,null,he.mode,Be),ac(Be,ge),Be.return=he,he=Be)}return G(he);case w:e:{for(ht=ge.key;ue!==null;){if(ue.key===ht)if(ue.tag===4&&ue.stateNode.containerInfo===ge.containerInfo&&ue.stateNode.implementation===ge.implementation){p(he,ue.sibling),Be=T(ue,ge.children||[]),Be.return=he,he=Be;break e}else{p(he,ue);break}else l(he,ue);ue=ue.sibling}Be=Ym(ge,he.mode,Be),Be.return=he,he=Be}return G(he);case A:return ge=Ea(ge),Jt(he,ue,ge,Be)}if(q(ge))return lt(he,ue,ge,Be);if(P(ge)){if(ht=P(ge),typeof ht!="function")throw Error(r(150));return ge=ht.call(ge),gt(he,ue,ge,Be)}if(typeof ge.then=="function")return Jt(he,ue,cd(ge),Be);if(ge.$$typeof===b)return Jt(he,ue,id(he,ge),Be);ud(he,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint"?(ge=""+ge,ue!==null&&ue.tag===6?(p(he,ue.sibling),Be=T(ue,ge),Be.return=he,he=Be):(p(he,ue),Be=Km(ge,he.mode,Be),Be.return=he,he=Be),G(he)):p(he,ue)}return function(he,ue,ge,Be){try{ic=0;var ht=Jt(he,ue,ge,Be);return Do=null,ht}catch(ut){if(ut===Ro||ut===od)throw ut;var $t=Nr(29,ut,null,he.mode);return $t.lanes=Be,$t.return=he,$t}finally{}}}var Ta=H_(!0),U_=H_(!1),Li=!1;function op(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Ri(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Di(i,l,p){var y=i.updateQueue;if(y===null)return null;if(y=y.shared,(Vt&2)!==0){var T=y.pending;return T===null?l.next=l:(l.next=T.next,T.next=l),y.pending=l,l=td(i),j_(i,null,p),l}return ed(i,y,l,p),td(i)}function oc(i,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194048)!==0)){var y=l.lanes;y&=i.pendingLanes,p|=y,l.lanes=p,He(i,p)}}function cp(i,l){var p=i.updateQueue,y=i.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var T=null,R=null;if(p=p.firstBaseUpdate,p!==null){do{var G={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};R===null?T=R=G:R=R.next=G,p=p.next}while(p!==null);R===null?T=R=l:R=R.next=l}else T=R=l;p={baseState:y.baseState,firstBaseUpdate:T,lastBaseUpdate:R,shared:y.shared,callbacks:y.callbacks},i.updateQueue=p;return}i=p.lastBaseUpdate,i===null?p.firstBaseUpdate=l:i.next=l,p.lastBaseUpdate=l}var up=!1;function lc(){if(up){var i=Lo;if(i!==null)throw i}}function cc(i,l,p,y){up=!1;var T=i.updateQueue;Li=!1;var R=T.firstBaseUpdate,G=T.lastBaseUpdate,te=T.shared.pending;if(te!==null){T.shared.pending=null;var oe=te,xe=oe.next;oe.next=null,G===null?R=xe:G.next=xe,G=oe;var Ie=i.alternate;Ie!==null&&(Ie=Ie.updateQueue,te=Ie.lastBaseUpdate,te!==G&&(te===null?Ie.firstBaseUpdate=xe:te.next=xe,Ie.lastBaseUpdate=oe))}if(R!==null){var ze=T.baseState;G=0,Ie=xe=oe=null,te=R;do{var we=te.lane&-536870913,Ce=we!==te.lane;if(Ce?(Rt&we)===we:(y&we)===we){we!==0&&we===Ao&&(up=!0),Ie!==null&&(Ie=Ie.next={lane:0,tag:te.tag,payload:te.payload,callback:null,next:null});e:{var lt=i,gt=te;we=l;var Jt=p;switch(gt.tag){case 1:if(lt=gt.payload,typeof lt=="function"){ze=lt.call(Jt,ze,we);break e}ze=lt;break e;case 3:lt.flags=lt.flags&-65537|128;case 0:if(lt=gt.payload,we=typeof lt=="function"?lt.call(Jt,ze,we):lt,we==null)break e;ze=f({},ze,we);break e;case 2:Li=!0}}we=te.callback,we!==null&&(i.flags|=64,Ce&&(i.flags|=8192),Ce=T.callbacks,Ce===null?T.callbacks=[we]:Ce.push(we))}else Ce={lane:we,tag:te.tag,payload:te.payload,callback:te.callback,next:null},Ie===null?(xe=Ie=Ce,oe=ze):Ie=Ie.next=Ce,G|=we;if(te=te.next,te===null){if(te=T.shared.pending,te===null)break;Ce=te,te=Ce.next,Ce.next=null,T.lastBaseUpdate=Ce,T.shared.pending=null}}while(!0);Ie===null&&(oe=ze),T.baseState=oe,T.firstBaseUpdate=xe,T.lastBaseUpdate=Ie,R===null&&(T.shared.lanes=0),Bi|=G,i.lanes=G,i.memoizedState=ze}}function V_(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function W_(i,l){var p=i.callbacks;if(p!==null)for(i.callbacks=null,i=0;i<p.length;i++)V_(p[i],l)}var Oo=M(null),dd=M(0);function G_(i,l){i=oi,$(dd,i),$(Oo,l),oi=i|l.baseLanes}function dp(){$(dd,oi),$(Oo,Oo.current)}function hp(){oi=dd.current,V(Oo),V(dd)}var Tr=M(null),Yr=null;function Oi(i){var l=i.alternate;$(kn,kn.current&1),$(Tr,i),Yr===null&&(l===null||Oo.current!==null||l.memoizedState!==null)&&(Yr=i)}function fp(i){$(kn,kn.current),$(Tr,i),Yr===null&&(Yr=i)}function q_(i){i.tag===22?($(kn,kn.current),$(Tr,i),Yr===null&&(Yr=i)):Mi()}function Mi(){$(kn,kn.current),$(Tr,Tr.current)}function Ar(i){V(Tr),Yr===i&&(Yr=null),V(kn)}var kn=M(0);function hd(i){for(var l=i;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||bg(p)||vg(p)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Zs=0,Ct=null,Xt=null,Ln=null,fd=!1,Mo=!1,Aa=!1,md=0,uc=0,Io=null,nR=0;function Sn(){throw Error(r(321))}function mp(i,l){if(l===null)return!1;for(var p=0;p<l.length&&p<i.length;p++)if(!Er(i[p],l[p]))return!1;return!0}function pp(i,l,p,y,T,R){return Zs=R,Ct=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,W.H=i===null||i.memoizedState===null?A0:Ap,Aa=!1,R=p(y,T),Aa=!1,Mo&&(R=Y_(l,p,y,T)),K_(i),R}function K_(i){W.H=fc;var l=Xt!==null&&Xt.next!==null;if(Zs=0,Ln=Xt=Ct=null,fd=!1,uc=0,Io=null,l)throw Error(r(300));i===null||Rn||(i=i.dependencies,i!==null&&sd(i)&&(Rn=!0))}function Y_(i,l,p,y){Ct=i;var T=0;do{if(Mo&&(Io=null),uc=0,Mo=!1,25<=T)throw Error(r(301));if(T+=1,Ln=Xt=null,i.updateQueue!=null){var R=i.updateQueue;R.lastEffect=null,R.events=null,R.stores=null,R.memoCache!=null&&(R.memoCache.index=0)}W.H=L0,R=l(p,y)}while(Mo);return R}function rR(){var i=W.H,l=i.useState()[0];return l=typeof l.then=="function"?dc(l):l,i=i.useState()[0],(Xt!==null?Xt.memoizedState:null)!==i&&(Ct.flags|=1024),l}function gp(){var i=md!==0;return md=0,i}function xp(i,l,p){l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~p}function yp(i){if(fd){for(i=i.memoizedState;i!==null;){var l=i.queue;l!==null&&(l.pending=null),i=i.next}fd=!1}Zs=0,Ln=Xt=Ct=null,Mo=!1,uc=md=0,Io=null}function or(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ln===null?Ct.memoizedState=Ln=i:Ln=Ln.next=i,Ln}function jn(){if(Xt===null){var i=Ct.alternate;i=i!==null?i.memoizedState:null}else i=Xt.next;var l=Ln===null?Ct.memoizedState:Ln.next;if(l!==null)Ln=l,Xt=i;else{if(i===null)throw Ct.alternate===null?Error(r(467)):Error(r(310));Xt=i,i={memoizedState:Xt.memoizedState,baseState:Xt.baseState,baseQueue:Xt.baseQueue,queue:Xt.queue,next:null},Ln===null?Ct.memoizedState=Ln=i:Ln=Ln.next=i}return Ln}function pd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function dc(i){var l=uc;return uc+=1,Io===null&&(Io=[]),i=$_(Io,i,l),l=Ct,(Ln===null?l.memoizedState:Ln.next)===null&&(l=l.alternate,W.H=l===null||l.memoizedState===null?A0:Ap),i}function gd(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return dc(i);if(i.$$typeof===b)return Yn(i)}throw Error(r(438,String(i)))}function bp(i){var l=null,p=Ct.updateQueue;if(p!==null&&(l=p.memoCache),l==null){var y=Ct.alternate;y!==null&&(y=y.updateQueue,y!==null&&(y=y.memoCache,y!=null&&(l={data:y.data.map(function(T){return T.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),p===null&&(p=pd(),Ct.updateQueue=p),p.memoCache=l,p=l.data[l.index],p===void 0)for(p=l.data[l.index]=Array(i),y=0;y<i;y++)p[y]=O;return l.index++,p}function ei(i,l){return typeof l=="function"?l(i):l}function xd(i){var l=jn();return vp(l,Xt,i)}function vp(i,l,p){var y=i.queue;if(y===null)throw Error(r(311));y.lastRenderedReducer=p;var T=i.baseQueue,R=y.pending;if(R!==null){if(T!==null){var G=T.next;T.next=R.next,R.next=G}l.baseQueue=T=R,y.pending=null}if(R=i.baseState,T===null)i.memoizedState=R;else{l=T.next;var te=G=null,oe=null,xe=l,Ie=!1;do{var ze=xe.lane&-536870913;if(ze!==xe.lane?(Rt&ze)===ze:(Zs&ze)===ze){var we=xe.revertLane;if(we===0)oe!==null&&(oe=oe.next={lane:0,revertLane:0,gesture:null,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null}),ze===Ao&&(Ie=!0);else if((Zs&we)===we){xe=xe.next,we===Ao&&(Ie=!0);continue}else ze={lane:0,revertLane:xe.revertLane,gesture:null,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null},oe===null?(te=oe=ze,G=R):oe=oe.next=ze,Ct.lanes|=we,Bi|=we;ze=xe.action,Aa&&p(R,ze),R=xe.hasEagerState?xe.eagerState:p(R,ze)}else we={lane:ze,revertLane:xe.revertLane,gesture:xe.gesture,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null},oe===null?(te=oe=we,G=R):oe=oe.next=we,Ct.lanes|=ze,Bi|=ze;xe=xe.next}while(xe!==null&&xe!==l);if(oe===null?G=R:oe.next=te,!Er(R,i.memoizedState)&&(Rn=!0,Ie&&(p=Lo,p!==null)))throw p;i.memoizedState=R,i.baseState=G,i.baseQueue=oe,y.lastRenderedState=R}return T===null&&(y.lanes=0),[i.memoizedState,y.dispatch]}function _p(i){var l=jn(),p=l.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=i;var y=p.dispatch,T=p.pending,R=l.memoizedState;if(T!==null){p.pending=null;var G=T=T.next;do R=i(R,G.action),G=G.next;while(G!==T);Er(R,l.memoizedState)||(Rn=!0),l.memoizedState=R,l.baseQueue===null&&(l.baseState=R),p.lastRenderedState=R}return[R,y]}function X_(i,l,p){var y=Ct,T=jn(),R=Ot;if(R){if(p===void 0)throw Error(r(407));p=p()}else p=l();var G=!Er((Xt||T).memoizedState,p);if(G&&(T.memoizedState=p,Rn=!0),T=T.queue,Cp(Z_.bind(null,y,T,i),[i]),T.getSnapshot!==l||G||Ln!==null&&Ln.memoizedState.tag&1){if(y.flags|=2048,Po(9,{destroy:void 0},J_.bind(null,y,T,p,l),null),nn===null)throw Error(r(349));R||(Zs&127)!==0||Q_(y,l,p)}return p}function Q_(i,l,p){i.flags|=16384,i={getSnapshot:l,value:p},l=Ct.updateQueue,l===null?(l=pd(),Ct.updateQueue=l,l.stores=[i]):(p=l.stores,p===null?l.stores=[i]:p.push(i))}function J_(i,l,p,y){l.value=p,l.getSnapshot=y,e0(l)&&t0(i)}function Z_(i,l,p){return p(function(){e0(l)&&t0(i)})}function e0(i){var l=i.getSnapshot;i=i.value;try{var p=l();return!Er(i,p)}catch{return!0}}function t0(i){var l=_a(i,2);l!==null&&yr(l,i,2)}function Sp(i){var l=or();if(typeof i=="function"){var p=i;if(i=p(),Aa){De(!0);try{p()}finally{De(!1)}}}return l.memoizedState=l.baseState=i,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ei,lastRenderedState:i},l}function n0(i,l,p,y){return i.baseState=p,vp(i,Xt,typeof y=="function"?y:ei)}function sR(i,l,p,y,T){if(vd(i))throw Error(r(485));if(i=l.action,i!==null){var R={payload:T,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(G){R.listeners.push(G)}};W.T!==null?p(!0):R.isTransition=!1,y(R),p=l.pending,p===null?(R.next=l.pending=R,r0(l,R)):(R.next=p.next,l.pending=p.next=R)}}function r0(i,l){var p=l.action,y=l.payload,T=i.state;if(l.isTransition){var R=W.T,G={};W.T=G;try{var te=p(T,y),oe=W.S;oe!==null&&oe(G,te),s0(i,l,te)}catch(xe){wp(i,l,xe)}finally{R!==null&&G.types!==null&&(R.types=G.types),W.T=R}}else try{R=p(T,y),s0(i,l,R)}catch(xe){wp(i,l,xe)}}function s0(i,l,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(y){i0(i,l,y)},function(y){return wp(i,l,y)}):i0(i,l,p)}function i0(i,l,p){l.status="fulfilled",l.value=p,a0(l),i.state=p,l=i.pending,l!==null&&(p=l.next,p===l?i.pending=null:(p=p.next,l.next=p,r0(i,p)))}function wp(i,l,p){var y=i.pending;if(i.pending=null,y!==null){y=y.next;do l.status="rejected",l.reason=p,a0(l),l=l.next;while(l!==y)}i.action=null}function a0(i){i=i.listeners;for(var l=0;l<i.length;l++)(0,i[l])()}function o0(i,l){return l}function l0(i,l){if(Ot){var p=nn.formState;if(p!==null){e:{var y=Ct;if(Ot){if(dn){t:{for(var T=dn,R=Kr;T.nodeType!==8;){if(!R){T=null;break t}if(T=Xr(T.nextSibling),T===null){T=null;break t}}R=T.data,T=R==="F!"||R==="F"?T:null}if(T){dn=Xr(T.nextSibling),y=T.data==="F!";break e}}Ti(y)}y=!1}y&&(l=p[0])}}return p=or(),p.memoizedState=p.baseState=l,y={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o0,lastRenderedState:l},p.queue=y,p=E0.bind(null,Ct,y),y.dispatch=p,y=Sp(!1),R=Tp.bind(null,Ct,!1,y.queue),y=or(),T={state:l,dispatch:null,action:i,pending:null},y.queue=T,p=sR.bind(null,Ct,T,R,p),T.dispatch=p,y.memoizedState=i,[l,p,!1]}function c0(i){var l=jn();return u0(l,Xt,i)}function u0(i,l,p){if(l=vp(i,l,o0)[0],i=xd(ei)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var y=dc(l)}catch(G){throw G===Ro?od:G}else y=l;l=jn();var T=l.queue,R=T.dispatch;return p!==l.memoizedState&&(Ct.flags|=2048,Po(9,{destroy:void 0},iR.bind(null,T,p),null)),[y,R,i]}function iR(i,l){i.action=l}function d0(i){var l=jn(),p=Xt;if(p!==null)return u0(l,p,i);jn(),l=l.memoizedState,p=jn();var y=p.queue.dispatch;return p.memoizedState=i,[l,y,!1]}function Po(i,l,p,y){return i={tag:i,create:p,deps:y,inst:l,next:null},l=Ct.updateQueue,l===null&&(l=pd(),Ct.updateQueue=l),p=l.lastEffect,p===null?l.lastEffect=i.next=i:(y=p.next,p.next=i,i.next=y,l.lastEffect=i),i}function h0(){return jn().memoizedState}function yd(i,l,p,y){var T=or();Ct.flags|=i,T.memoizedState=Po(1|l,{destroy:void 0},p,y===void 0?null:y)}function bd(i,l,p,y){var T=jn();y=y===void 0?null:y;var R=T.memoizedState.inst;Xt!==null&&y!==null&&mp(y,Xt.memoizedState.deps)?T.memoizedState=Po(l,R,p,y):(Ct.flags|=i,T.memoizedState=Po(1|l,R,p,y))}function f0(i,l){yd(8390656,8,i,l)}function Cp(i,l){bd(2048,8,i,l)}function aR(i){Ct.flags|=4;var l=Ct.updateQueue;if(l===null)l=pd(),Ct.updateQueue=l,l.events=[i];else{var p=l.events;p===null?l.events=[i]:p.push(i)}}function m0(i){var l=jn().memoizedState;return aR({ref:l,nextImpl:i}),function(){if((Vt&2)!==0)throw Error(r(440));return l.impl.apply(void 0,arguments)}}function p0(i,l){return bd(4,2,i,l)}function g0(i,l){return bd(4,4,i,l)}function x0(i,l){if(typeof l=="function"){i=i();var p=l(i);return function(){typeof p=="function"?p():l(null)}}if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function y0(i,l,p){p=p!=null?p.concat([i]):null,bd(4,4,x0.bind(null,l,i),p)}function kp(){}function b0(i,l){var p=jn();l=l===void 0?null:l;var y=p.memoizedState;return l!==null&&mp(l,y[1])?y[0]:(p.memoizedState=[i,l],i)}function v0(i,l){var p=jn();l=l===void 0?null:l;var y=p.memoizedState;if(l!==null&&mp(l,y[1]))return y[0];if(y=i(),Aa){De(!0);try{i()}finally{De(!1)}}return p.memoizedState=[y,l],y}function jp(i,l,p){return p===void 0||(Zs&1073741824)!==0&&(Rt&261930)===0?i.memoizedState=l:(i.memoizedState=p,i=_S(),Ct.lanes|=i,Bi|=i,p)}function _0(i,l,p,y){return Er(p,l)?p:Oo.current!==null?(i=jp(i,p,y),Er(i,l)||(Rn=!0),i):(Zs&42)===0||(Zs&1073741824)!==0&&(Rt&261930)===0?(Rn=!0,i.memoizedState=p):(i=_S(),Ct.lanes|=i,Bi|=i,l)}function S0(i,l,p,y,T){var R=Z.p;Z.p=R!==0&&8>R?R:8;var G=W.T,te={};W.T=te,Tp(i,!1,l,p);try{var oe=T(),xe=W.S;if(xe!==null&&xe(te,oe),oe!==null&&typeof oe=="object"&&typeof oe.then=="function"){var Ie=tR(oe,y);hc(i,l,Ie,Dr(i))}else hc(i,l,y,Dr(i))}catch(ze){hc(i,l,{then:function(){},status:"rejected",reason:ze},Dr())}finally{Z.p=R,G!==null&&te.types!==null&&(G.types=te.types),W.T=G}}function oR(){}function Ep(i,l,p,y){if(i.tag!==5)throw Error(r(476));var T=w0(i).queue;S0(i,T,l,Q,p===null?oR:function(){return C0(i),p(y)})}function w0(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ei,lastRenderedState:Q},next:null};var p={};return l.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ei,lastRenderedState:p},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function C0(i){var l=w0(i);l.next===null&&(l=i.alternate.memoizedState),hc(i,l.next.queue,{},Dr())}function Np(){return Yn(Tc)}function k0(){return jn().memoizedState}function j0(){return jn().memoizedState}function lR(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var p=Dr();i=Ri(p);var y=Di(l,i,p);y!==null&&(yr(y,l,p),oc(y,l,p)),l={cache:rp()},i.payload=l;return}l=l.return}}function cR(i,l,p){var y=Dr();p={lane:y,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},vd(i)?N0(l,p):(p=Gm(i,l,p,y),p!==null&&(yr(p,i,y),T0(p,l,y)))}function E0(i,l,p){var y=Dr();hc(i,l,p,y)}function hc(i,l,p,y){var T={lane:y,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(vd(i))N0(l,T);else{var R=i.alternate;if(i.lanes===0&&(R===null||R.lanes===0)&&(R=l.lastRenderedReducer,R!==null))try{var G=l.lastRenderedState,te=R(G,p);if(T.hasEagerState=!0,T.eagerState=te,Er(te,G))return ed(i,l,T,0),nn===null&&Zu(),!1}catch{}finally{}if(p=Gm(i,l,T,y),p!==null)return yr(p,i,y),T0(p,l,y),!0}return!1}function Tp(i,l,p,y){if(y={lane:2,revertLane:og(),gesture:null,action:y,hasEagerState:!1,eagerState:null,next:null},vd(i)){if(l)throw Error(r(479))}else l=Gm(i,p,y,2),l!==null&&yr(l,i,2)}function vd(i){var l=i.alternate;return i===Ct||l!==null&&l===Ct}function N0(i,l){Mo=fd=!0;var p=i.pending;p===null?l.next=l:(l.next=p.next,p.next=l),i.pending=l}function T0(i,l,p){if((p&4194048)!==0){var y=l.lanes;y&=i.pendingLanes,p|=y,l.lanes=p,He(i,p)}}var fc={readContext:Yn,use:gd,useCallback:Sn,useContext:Sn,useEffect:Sn,useImperativeHandle:Sn,useLayoutEffect:Sn,useInsertionEffect:Sn,useMemo:Sn,useReducer:Sn,useRef:Sn,useState:Sn,useDebugValue:Sn,useDeferredValue:Sn,useTransition:Sn,useSyncExternalStore:Sn,useId:Sn,useHostTransitionStatus:Sn,useFormState:Sn,useActionState:Sn,useOptimistic:Sn,useMemoCache:Sn,useCacheRefresh:Sn};fc.useEffectEvent=Sn;var A0={readContext:Yn,use:gd,useCallback:function(i,l){return or().memoizedState=[i,l===void 0?null:l],i},useContext:Yn,useEffect:f0,useImperativeHandle:function(i,l,p){p=p!=null?p.concat([i]):null,yd(4194308,4,x0.bind(null,l,i),p)},useLayoutEffect:function(i,l){return yd(4194308,4,i,l)},useInsertionEffect:function(i,l){yd(4,2,i,l)},useMemo:function(i,l){var p=or();l=l===void 0?null:l;var y=i();if(Aa){De(!0);try{i()}finally{De(!1)}}return p.memoizedState=[y,l],y},useReducer:function(i,l,p){var y=or();if(p!==void 0){var T=p(l);if(Aa){De(!0);try{p(l)}finally{De(!1)}}}else T=l;return y.memoizedState=y.baseState=T,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:T},y.queue=i,i=i.dispatch=cR.bind(null,Ct,i),[y.memoizedState,i]},useRef:function(i){var l=or();return i={current:i},l.memoizedState=i},useState:function(i){i=Sp(i);var l=i.queue,p=E0.bind(null,Ct,l);return l.dispatch=p,[i.memoizedState,p]},useDebugValue:kp,useDeferredValue:function(i,l){var p=or();return jp(p,i,l)},useTransition:function(){var i=Sp(!1);return i=S0.bind(null,Ct,i.queue,!0,!1),or().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,p){var y=Ct,T=or();if(Ot){if(p===void 0)throw Error(r(407));p=p()}else{if(p=l(),nn===null)throw Error(r(349));(Rt&127)!==0||Q_(y,l,p)}T.memoizedState=p;var R={value:p,getSnapshot:l};return T.queue=R,f0(Z_.bind(null,y,R,i),[i]),y.flags|=2048,Po(9,{destroy:void 0},J_.bind(null,y,R,p,l),null),p},useId:function(){var i=or(),l=nn.identifierPrefix;if(Ot){var p=js,y=ks;p=(y&~(1<<32-Re(y)-1)).toString(32)+p,l="_"+l+"R_"+p,p=md++,0<p&&(l+="H"+p.toString(32)),l+="_"}else p=nR++,l="_"+l+"r_"+p.toString(32)+"_";return i.memoizedState=l},useHostTransitionStatus:Np,useFormState:l0,useActionState:l0,useOptimistic:function(i){var l=or();l.memoizedState=l.baseState=i;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=p,l=Tp.bind(null,Ct,!0,p),p.dispatch=l,[i,l]},useMemoCache:bp,useCacheRefresh:function(){return or().memoizedState=lR.bind(null,Ct)},useEffectEvent:function(i){var l=or(),p={impl:i};return l.memoizedState=p,function(){if((Vt&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}},Ap={readContext:Yn,use:gd,useCallback:b0,useContext:Yn,useEffect:Cp,useImperativeHandle:y0,useInsertionEffect:p0,useLayoutEffect:g0,useMemo:v0,useReducer:xd,useRef:h0,useState:function(){return xd(ei)},useDebugValue:kp,useDeferredValue:function(i,l){var p=jn();return _0(p,Xt.memoizedState,i,l)},useTransition:function(){var i=xd(ei)[0],l=jn().memoizedState;return[typeof i=="boolean"?i:dc(i),l]},useSyncExternalStore:X_,useId:k0,useHostTransitionStatus:Np,useFormState:c0,useActionState:c0,useOptimistic:function(i,l){var p=jn();return n0(p,Xt,i,l)},useMemoCache:bp,useCacheRefresh:j0};Ap.useEffectEvent=m0;var L0={readContext:Yn,use:gd,useCallback:b0,useContext:Yn,useEffect:Cp,useImperativeHandle:y0,useInsertionEffect:p0,useLayoutEffect:g0,useMemo:v0,useReducer:_p,useRef:h0,useState:function(){return _p(ei)},useDebugValue:kp,useDeferredValue:function(i,l){var p=jn();return Xt===null?jp(p,i,l):_0(p,Xt.memoizedState,i,l)},useTransition:function(){var i=_p(ei)[0],l=jn().memoizedState;return[typeof i=="boolean"?i:dc(i),l]},useSyncExternalStore:X_,useId:k0,useHostTransitionStatus:Np,useFormState:d0,useActionState:d0,useOptimistic:function(i,l){var p=jn();return Xt!==null?n0(p,Xt,i,l):(p.baseState=i,[i,p.queue.dispatch])},useMemoCache:bp,useCacheRefresh:j0};L0.useEffectEvent=m0;function Lp(i,l,p,y){l=i.memoizedState,p=p(y,l),p=p==null?l:f({},l,p),i.memoizedState=p,i.lanes===0&&(i.updateQueue.baseState=p)}var Rp={enqueueSetState:function(i,l,p){i=i._reactInternals;var y=Dr(),T=Ri(y);T.payload=l,p!=null&&(T.callback=p),l=Di(i,T,y),l!==null&&(yr(l,i,y),oc(l,i,y))},enqueueReplaceState:function(i,l,p){i=i._reactInternals;var y=Dr(),T=Ri(y);T.tag=1,T.payload=l,p!=null&&(T.callback=p),l=Di(i,T,y),l!==null&&(yr(l,i,y),oc(l,i,y))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var p=Dr(),y=Ri(p);y.tag=2,l!=null&&(y.callback=l),l=Di(i,y,p),l!==null&&(yr(l,i,p),oc(l,i,p))}};function R0(i,l,p,y,T,R,G){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(y,R,G):l.prototype&&l.prototype.isPureReactComponent?!Zl(p,y)||!Zl(T,R):!0}function D0(i,l,p,y){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,y),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,y),l.state!==i&&Rp.enqueueReplaceState(l,l.state,null)}function La(i,l){var p=l;if("ref"in l){p={};for(var y in l)y!=="ref"&&(p[y]=l[y])}if(i=i.defaultProps){p===l&&(p=f({},p));for(var T in i)p[T]===void 0&&(p[T]=i[T])}return p}function O0(i){Ju(i)}function M0(i){console.error(i)}function I0(i){Ju(i)}function _d(i,l){try{var p=i.onUncaughtError;p(l.value,{componentStack:l.stack})}catch(y){setTimeout(function(){throw y})}}function P0(i,l,p){try{var y=i.onCaughtError;y(p.value,{componentStack:p.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function Dp(i,l,p){return p=Ri(p),p.tag=3,p.payload={element:null},p.callback=function(){_d(i,l)},p}function B0(i){return i=Ri(i),i.tag=3,i}function $0(i,l,p,y){var T=p.type.getDerivedStateFromError;if(typeof T=="function"){var R=y.value;i.payload=function(){return T(R)},i.callback=function(){P0(l,p,y)}}var G=p.stateNode;G!==null&&typeof G.componentDidCatch=="function"&&(i.callback=function(){P0(l,p,y),typeof T!="function"&&($i===null?$i=new Set([this]):$i.add(this));var te=y.stack;this.componentDidCatch(y.value,{componentStack:te!==null?te:""})})}function uR(i,l,p,y,T){if(p.flags|=32768,y!==null&&typeof y=="object"&&typeof y.then=="function"){if(l=p.alternate,l!==null&&To(l,p,T,!0),p=Tr.current,p!==null){switch(p.tag){case 31:case 13:return Yr===null?Dd():p.alternate===null&&wn===0&&(wn=3),p.flags&=-257,p.flags|=65536,p.lanes=T,y===ld?p.flags|=16384:(l=p.updateQueue,l===null?p.updateQueue=new Set([y]):l.add(y),sg(i,y,T)),!1;case 22:return p.flags|=65536,y===ld?p.flags|=16384:(l=p.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([y])},p.updateQueue=l):(p=l.retryQueue,p===null?l.retryQueue=new Set([y]):p.add(y)),sg(i,y,T)),!1}throw Error(r(435,p.tag))}return sg(i,y,T),Dd(),!1}if(Ot)return l=Tr.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=T,y!==Jm&&(i=Error(r(422),{cause:y}),nc(Wr(i,p)))):(y!==Jm&&(l=Error(r(423),{cause:y}),nc(Wr(l,p))),i=i.current.alternate,i.flags|=65536,T&=-T,i.lanes|=T,y=Wr(y,p),T=Dp(i.stateNode,y,T),cp(i,T),wn!==4&&(wn=2)),!1;var R=Error(r(520),{cause:y});if(R=Wr(R,p),_c===null?_c=[R]:_c.push(R),wn!==4&&(wn=2),l===null)return!0;y=Wr(y,p),p=l;do{switch(p.tag){case 3:return p.flags|=65536,i=T&-T,p.lanes|=i,i=Dp(p.stateNode,y,i),cp(p,i),!1;case 1:if(l=p.type,R=p.stateNode,(p.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&($i===null||!$i.has(R))))return p.flags|=65536,T&=-T,p.lanes|=T,T=B0(T),$0(T,i,p,y),cp(p,T),!1}p=p.return}while(p!==null);return!1}var Op=Error(r(461)),Rn=!1;function Xn(i,l,p,y){l.child=i===null?U_(l,null,p,y):Ta(l,i.child,p,y)}function F0(i,l,p,y,T){p=p.render;var R=l.ref;if("ref"in y){var G={};for(var te in y)te!=="ref"&&(G[te]=y[te])}else G=y;return ka(l),y=pp(i,l,p,G,R,T),te=gp(),i!==null&&!Rn?(xp(i,l,T),ti(i,l,T)):(Ot&&te&&Xm(l),l.flags|=1,Xn(i,l,y,T),l.child)}function z0(i,l,p,y,T){if(i===null){var R=p.type;return typeof R=="function"&&!qm(R)&&R.defaultProps===void 0&&p.compare===null?(l.tag=15,l.type=R,H0(i,l,R,y,T)):(i=nd(p.type,null,y,l,l.mode,T),i.ref=l.ref,i.return=l,l.child=i)}if(R=i.child,!Hp(i,T)){var G=R.memoizedProps;if(p=p.compare,p=p!==null?p:Zl,p(G,y)&&i.ref===l.ref)return ti(i,l,T)}return l.flags|=1,i=Ys(R,y),i.ref=l.ref,i.return=l,l.child=i}function H0(i,l,p,y,T){if(i!==null){var R=i.memoizedProps;if(Zl(R,y)&&i.ref===l.ref)if(Rn=!1,l.pendingProps=y=R,Hp(i,T))(i.flags&131072)!==0&&(Rn=!0);else return l.lanes=i.lanes,ti(i,l,T)}return Mp(i,l,p,y,T)}function U0(i,l,p,y){var T=y.children,R=i!==null?i.memoizedState:null;if(i===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),y.mode==="hidden"){if((l.flags&128)!==0){if(R=R!==null?R.baseLanes|p:p,i!==null){for(y=l.child=i.child,T=0;y!==null;)T=T|y.lanes|y.childLanes,y=y.sibling;y=T&~R}else y=0,l.child=null;return V0(i,l,R,p,y)}if((p&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},i!==null&&ad(l,R!==null?R.cachePool:null),R!==null?G_(l,R):dp(),q_(l);else return y=l.lanes=536870912,V0(i,l,R!==null?R.baseLanes|p:p,p,y)}else R!==null?(ad(l,R.cachePool),G_(l,R),Mi(),l.memoizedState=null):(i!==null&&ad(l,null),dp(),Mi());return Xn(i,l,T,p),l.child}function mc(i,l){return i!==null&&i.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function V0(i,l,p,y,T){var R=ip();return R=R===null?null:{parent:An._currentValue,pool:R},l.memoizedState={baseLanes:p,cachePool:R},i!==null&&ad(l,null),dp(),q_(l),i!==null&&To(i,l,y,!0),l.childLanes=T,null}function Sd(i,l){return l=Cd({mode:l.mode,children:l.children},i.mode),l.ref=i.ref,i.child=l,l.return=i,l}function W0(i,l,p){return Ta(l,i.child,null,p),i=Sd(l,l.pendingProps),i.flags|=2,Ar(l),l.memoizedState=null,i}function dR(i,l,p){var y=l.pendingProps,T=(l.flags&128)!==0;if(l.flags&=-129,i===null){if(Ot){if(y.mode==="hidden")return i=Sd(l,y),l.lanes=536870912,mc(null,i);if(fp(l),(i=dn)?(i=rw(i,Kr),i=i!==null&&i.data==="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:Ei!==null?{id:ks,overflow:js}:null,retryLane:536870912,hydrationErrors:null},p=N_(i),p.return=l,l.child=p,Kn=l,dn=null)):i=null,i===null)throw Ti(l);return l.lanes=536870912,null}return Sd(l,y)}var R=i.memoizedState;if(R!==null){var G=R.dehydrated;if(fp(l),T)if(l.flags&256)l.flags&=-257,l=W0(i,l,p);else if(l.memoizedState!==null)l.child=i.child,l.flags|=128,l=null;else throw Error(r(558));else if(Rn||To(i,l,p,!1),T=(p&i.childLanes)!==0,Rn||T){if(y=nn,y!==null&&(G=le(y,p),G!==0&&G!==R.retryLane))throw R.retryLane=G,_a(i,G),yr(y,i,G),Op;Dd(),l=W0(i,l,p)}else i=R.treeContext,dn=Xr(G.nextSibling),Kn=l,Ot=!0,Ni=null,Kr=!1,i!==null&&L_(l,i),l=Sd(l,y),l.flags|=4096;return l}return i=Ys(i.child,{mode:y.mode,children:y.children}),i.ref=l.ref,l.child=i,i.return=l,i}function wd(i,l){var p=l.ref;if(p===null)i!==null&&i.ref!==null&&(l.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(r(284));(i===null||i.ref!==p)&&(l.flags|=4194816)}}function Mp(i,l,p,y,T){return ka(l),p=pp(i,l,p,y,void 0,T),y=gp(),i!==null&&!Rn?(xp(i,l,T),ti(i,l,T)):(Ot&&y&&Xm(l),l.flags|=1,Xn(i,l,p,T),l.child)}function G0(i,l,p,y,T,R){return ka(l),l.updateQueue=null,p=Y_(l,y,p,T),K_(i),y=gp(),i!==null&&!Rn?(xp(i,l,R),ti(i,l,R)):(Ot&&y&&Xm(l),l.flags|=1,Xn(i,l,p,R),l.child)}function q0(i,l,p,y,T){if(ka(l),l.stateNode===null){var R=ko,G=p.contextType;typeof G=="object"&&G!==null&&(R=Yn(G)),R=new p(y,R),l.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,R.updater=Rp,l.stateNode=R,R._reactInternals=l,R=l.stateNode,R.props=y,R.state=l.memoizedState,R.refs={},op(l),G=p.contextType,R.context=typeof G=="object"&&G!==null?Yn(G):ko,R.state=l.memoizedState,G=p.getDerivedStateFromProps,typeof G=="function"&&(Lp(l,p,G,y),R.state=l.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(G=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),G!==R.state&&Rp.enqueueReplaceState(R,R.state,null),cc(l,y,R,T),lc(),R.state=l.memoizedState),typeof R.componentDidMount=="function"&&(l.flags|=4194308),y=!0}else if(i===null){R=l.stateNode;var te=l.memoizedProps,oe=La(p,te);R.props=oe;var xe=R.context,Ie=p.contextType;G=ko,typeof Ie=="object"&&Ie!==null&&(G=Yn(Ie));var ze=p.getDerivedStateFromProps;Ie=typeof ze=="function"||typeof R.getSnapshotBeforeUpdate=="function",te=l.pendingProps!==te,Ie||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(te||xe!==G)&&D0(l,R,y,G),Li=!1;var we=l.memoizedState;R.state=we,cc(l,y,R,T),lc(),xe=l.memoizedState,te||we!==xe||Li?(typeof ze=="function"&&(Lp(l,p,ze,y),xe=l.memoizedState),(oe=Li||R0(l,p,oe,y,we,xe,G))?(Ie||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(l.flags|=4194308)):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=y,l.memoizedState=xe),R.props=y,R.state=xe,R.context=G,y=oe):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),y=!1)}else{R=l.stateNode,lp(i,l),G=l.memoizedProps,Ie=La(p,G),R.props=Ie,ze=l.pendingProps,we=R.context,xe=p.contextType,oe=ko,typeof xe=="object"&&xe!==null&&(oe=Yn(xe)),te=p.getDerivedStateFromProps,(xe=typeof te=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(G!==ze||we!==oe)&&D0(l,R,y,oe),Li=!1,we=l.memoizedState,R.state=we,cc(l,y,R,T),lc();var Ce=l.memoizedState;G!==ze||we!==Ce||Li||i!==null&&i.dependencies!==null&&sd(i.dependencies)?(typeof te=="function"&&(Lp(l,p,te,y),Ce=l.memoizedState),(Ie=Li||R0(l,p,Ie,y,we,Ce,oe)||i!==null&&i.dependencies!==null&&sd(i.dependencies))?(xe||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(y,Ce,oe),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(y,Ce,oe)),typeof R.componentDidUpdate=="function"&&(l.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof R.componentDidUpdate!="function"||G===i.memoizedProps&&we===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&we===i.memoizedState||(l.flags|=1024),l.memoizedProps=y,l.memoizedState=Ce),R.props=y,R.state=Ce,R.context=oe,y=Ie):(typeof R.componentDidUpdate!="function"||G===i.memoizedProps&&we===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&we===i.memoizedState||(l.flags|=1024),y=!1)}return R=y,wd(i,l),y=(l.flags&128)!==0,R||y?(R=l.stateNode,p=y&&typeof p.getDerivedStateFromError!="function"?null:R.render(),l.flags|=1,i!==null&&y?(l.child=Ta(l,i.child,null,T),l.child=Ta(l,null,p,T)):Xn(i,l,p,T),l.memoizedState=R.state,i=l.child):i=ti(i,l,T),i}function K0(i,l,p,y){return wa(),l.flags|=256,Xn(i,l,p,y),l.child}var Ip={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Pp(i){return{baseLanes:i,cachePool:P_()}}function Bp(i,l,p){return i=i!==null?i.childLanes&~p:0,l&&(i|=Rr),i}function Y0(i,l,p){var y=l.pendingProps,T=!1,R=(l.flags&128)!==0,G;if((G=R)||(G=i!==null&&i.memoizedState===null?!1:(kn.current&2)!==0),G&&(T=!0,l.flags&=-129),G=(l.flags&32)!==0,l.flags&=-33,i===null){if(Ot){if(T?Oi(l):Mi(),(i=dn)?(i=rw(i,Kr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:Ei!==null?{id:ks,overflow:js}:null,retryLane:536870912,hydrationErrors:null},p=N_(i),p.return=l,l.child=p,Kn=l,dn=null)):i=null,i===null)throw Ti(l);return vg(i)?l.lanes=32:l.lanes=536870912,null}var te=y.children;return y=y.fallback,T?(Mi(),T=l.mode,te=Cd({mode:"hidden",children:te},T),y=Sa(y,T,p,null),te.return=l,y.return=l,te.sibling=y,l.child=te,y=l.child,y.memoizedState=Pp(p),y.childLanes=Bp(i,G,p),l.memoizedState=Ip,mc(null,y)):(Oi(l),$p(l,te))}var oe=i.memoizedState;if(oe!==null&&(te=oe.dehydrated,te!==null)){if(R)l.flags&256?(Oi(l),l.flags&=-257,l=Fp(i,l,p)):l.memoizedState!==null?(Mi(),l.child=i.child,l.flags|=128,l=null):(Mi(),te=y.fallback,T=l.mode,y=Cd({mode:"visible",children:y.children},T),te=Sa(te,T,p,null),te.flags|=2,y.return=l,te.return=l,y.sibling=te,l.child=y,Ta(l,i.child,null,p),y=l.child,y.memoizedState=Pp(p),y.childLanes=Bp(i,G,p),l.memoizedState=Ip,l=mc(null,y));else if(Oi(l),vg(te)){if(G=te.nextSibling&&te.nextSibling.dataset,G)var xe=G.dgst;G=xe,y=Error(r(419)),y.stack="",y.digest=G,nc({value:y,source:null,stack:null}),l=Fp(i,l,p)}else if(Rn||To(i,l,p,!1),G=(p&i.childLanes)!==0,Rn||G){if(G=nn,G!==null&&(y=le(G,p),y!==0&&y!==oe.retryLane))throw oe.retryLane=y,_a(i,y),yr(G,i,y),Op;bg(te)||Dd(),l=Fp(i,l,p)}else bg(te)?(l.flags|=192,l.child=i.child,l=null):(i=oe.treeContext,dn=Xr(te.nextSibling),Kn=l,Ot=!0,Ni=null,Kr=!1,i!==null&&L_(l,i),l=$p(l,y.children),l.flags|=4096);return l}return T?(Mi(),te=y.fallback,T=l.mode,oe=i.child,xe=oe.sibling,y=Ys(oe,{mode:"hidden",children:y.children}),y.subtreeFlags=oe.subtreeFlags&65011712,xe!==null?te=Ys(xe,te):(te=Sa(te,T,p,null),te.flags|=2),te.return=l,y.return=l,y.sibling=te,l.child=y,mc(null,y),y=l.child,te=i.child.memoizedState,te===null?te=Pp(p):(T=te.cachePool,T!==null?(oe=An._currentValue,T=T.parent!==oe?{parent:oe,pool:oe}:T):T=P_(),te={baseLanes:te.baseLanes|p,cachePool:T}),y.memoizedState=te,y.childLanes=Bp(i,G,p),l.memoizedState=Ip,mc(i.child,y)):(Oi(l),p=i.child,i=p.sibling,p=Ys(p,{mode:"visible",children:y.children}),p.return=l,p.sibling=null,i!==null&&(G=l.deletions,G===null?(l.deletions=[i],l.flags|=16):G.push(i)),l.child=p,l.memoizedState=null,p)}function $p(i,l){return l=Cd({mode:"visible",children:l},i.mode),l.return=i,i.child=l}function Cd(i,l){return i=Nr(22,i,null,l),i.lanes=0,i}function Fp(i,l,p){return Ta(l,i.child,null,p),i=$p(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function X0(i,l,p){i.lanes|=l;var y=i.alternate;y!==null&&(y.lanes|=l),tp(i.return,l,p)}function zp(i,l,p,y,T,R){var G=i.memoizedState;G===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:T,treeForkCount:R}:(G.isBackwards=l,G.rendering=null,G.renderingStartTime=0,G.last=y,G.tail=p,G.tailMode=T,G.treeForkCount=R)}function Q0(i,l,p){var y=l.pendingProps,T=y.revealOrder,R=y.tail;y=y.children;var G=kn.current,te=(G&2)!==0;if(te?(G=G&1|2,l.flags|=128):G&=1,$(kn,G),Xn(i,l,y,p),y=Ot?tc:0,!te&&i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&X0(i,p,l);else if(i.tag===19)X0(i,p,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(T){case"forwards":for(p=l.child,T=null;p!==null;)i=p.alternate,i!==null&&hd(i)===null&&(T=p),p=p.sibling;p=T,p===null?(T=l.child,l.child=null):(T=p.sibling,p.sibling=null),zp(l,!1,T,p,R,y);break;case"backwards":case"unstable_legacy-backwards":for(p=null,T=l.child,l.child=null;T!==null;){if(i=T.alternate,i!==null&&hd(i)===null){l.child=T;break}i=T.sibling,T.sibling=p,p=T,T=i}zp(l,!0,p,null,R,y);break;case"together":zp(l,!1,null,null,void 0,y);break;default:l.memoizedState=null}return l.child}function ti(i,l,p){if(i!==null&&(l.dependencies=i.dependencies),Bi|=l.lanes,(p&l.childLanes)===0)if(i!==null){if(To(i,l,p,!1),(p&l.childLanes)===0)return null}else return null;if(i!==null&&l.child!==i.child)throw Error(r(153));if(l.child!==null){for(i=l.child,p=Ys(i,i.pendingProps),l.child=p,p.return=l;i.sibling!==null;)i=i.sibling,p=p.sibling=Ys(i,i.pendingProps),p.return=l;p.sibling=null}return l.child}function Hp(i,l){return(i.lanes&l)!==0?!0:(i=i.dependencies,!!(i!==null&&sd(i)))}function hR(i,l,p){switch(l.tag){case 3:B(l,l.stateNode.containerInfo),Ai(l,An,i.memoizedState.cache),wa();break;case 27:case 5:se(l);break;case 4:B(l,l.stateNode.containerInfo);break;case 10:Ai(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,fp(l),null;break;case 13:var y=l.memoizedState;if(y!==null)return y.dehydrated!==null?(Oi(l),l.flags|=128,null):(p&l.child.childLanes)!==0?Y0(i,l,p):(Oi(l),i=ti(i,l,p),i!==null?i.sibling:null);Oi(l);break;case 19:var T=(i.flags&128)!==0;if(y=(p&l.childLanes)!==0,y||(To(i,l,p,!1),y=(p&l.childLanes)!==0),T){if(y)return Q0(i,l,p);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),$(kn,kn.current),y)break;return null;case 22:return l.lanes=0,U0(i,l,p,l.pendingProps);case 24:Ai(l,An,i.memoizedState.cache)}return ti(i,l,p)}function J0(i,l,p){if(i!==null)if(i.memoizedProps!==l.pendingProps)Rn=!0;else{if(!Hp(i,p)&&(l.flags&128)===0)return Rn=!1,hR(i,l,p);Rn=(i.flags&131072)!==0}else Rn=!1,Ot&&(l.flags&1048576)!==0&&A_(l,tc,l.index);switch(l.lanes=0,l.tag){case 16:e:{var y=l.pendingProps;if(i=Ea(l.elementType),l.type=i,typeof i=="function")qm(i)?(y=La(i,y),l.tag=1,l=q0(null,l,i,y,p)):(l.tag=0,l=Mp(null,l,i,y,p));else{if(i!=null){var T=i.$$typeof;if(T===j){l.tag=11,l=F0(null,l,i,y,p);break e}else if(T===L){l.tag=14,l=z0(null,l,i,y,p);break e}}throw l=K(i)||i,Error(r(306,l,""))}}return l;case 0:return Mp(i,l,l.type,l.pendingProps,p);case 1:return y=l.type,T=La(y,l.pendingProps),q0(i,l,y,T,p);case 3:e:{if(B(l,l.stateNode.containerInfo),i===null)throw Error(r(387));y=l.pendingProps;var R=l.memoizedState;T=R.element,lp(i,l),cc(l,y,null,p);var G=l.memoizedState;if(y=G.cache,Ai(l,An,y),y!==R.cache&&np(l,[An],p,!0),lc(),y=G.element,R.isDehydrated)if(R={element:y,isDehydrated:!1,cache:G.cache},l.updateQueue.baseState=R,l.memoizedState=R,l.flags&256){l=K0(i,l,y,p);break e}else if(y!==T){T=Wr(Error(r(424)),l),nc(T),l=K0(i,l,y,p);break e}else{switch(i=l.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(dn=Xr(i.firstChild),Kn=l,Ot=!0,Ni=null,Kr=!0,p=U_(l,null,y,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(wa(),y===T){l=ti(i,l,p);break e}Xn(i,l,y,p)}l=l.child}return l;case 26:return wd(i,l),i===null?(p=cw(l.type,null,l.pendingProps,null))?l.memoizedState=p:Ot||(p=l.type,i=l.pendingProps,y=Fd(X.current).createElement(p),y[Fe]=l,y[Je]=i,Qn(y,p,i),Hn(y),l.stateNode=y):l.memoizedState=cw(l.type,i.memoizedProps,l.pendingProps,i.memoizedState),null;case 27:return se(l),i===null&&Ot&&(y=l.stateNode=aw(l.type,l.pendingProps,X.current),Kn=l,Kr=!0,T=dn,Ui(l.type)?(_g=T,dn=Xr(y.firstChild)):dn=T),Xn(i,l,l.pendingProps.children,p),wd(i,l),i===null&&(l.flags|=4194304),l.child;case 5:return i===null&&Ot&&((T=y=dn)&&(y=HR(y,l.type,l.pendingProps,Kr),y!==null?(l.stateNode=y,Kn=l,dn=Xr(y.firstChild),Kr=!1,T=!0):T=!1),T||Ti(l)),se(l),T=l.type,R=l.pendingProps,G=i!==null?i.memoizedProps:null,y=R.children,gg(T,R)?y=null:G!==null&&gg(T,G)&&(l.flags|=32),l.memoizedState!==null&&(T=pp(i,l,rR,null,null,p),Tc._currentValue=T),wd(i,l),Xn(i,l,y,p),l.child;case 6:return i===null&&Ot&&((i=p=dn)&&(p=UR(p,l.pendingProps,Kr),p!==null?(l.stateNode=p,Kn=l,dn=null,i=!0):i=!1),i||Ti(l)),null;case 13:return Y0(i,l,p);case 4:return B(l,l.stateNode.containerInfo),y=l.pendingProps,i===null?l.child=Ta(l,null,y,p):Xn(i,l,y,p),l.child;case 11:return F0(i,l,l.type,l.pendingProps,p);case 7:return Xn(i,l,l.pendingProps,p),l.child;case 8:return Xn(i,l,l.pendingProps.children,p),l.child;case 12:return Xn(i,l,l.pendingProps.children,p),l.child;case 10:return y=l.pendingProps,Ai(l,l.type,y.value),Xn(i,l,y.children,p),l.child;case 9:return T=l.type._context,y=l.pendingProps.children,ka(l),T=Yn(T),y=y(T),l.flags|=1,Xn(i,l,y,p),l.child;case 14:return z0(i,l,l.type,l.pendingProps,p);case 15:return H0(i,l,l.type,l.pendingProps,p);case 19:return Q0(i,l,p);case 31:return dR(i,l,p);case 22:return U0(i,l,p,l.pendingProps);case 24:return ka(l),y=Yn(An),i===null?(T=ip(),T===null&&(T=nn,R=rp(),T.pooledCache=R,R.refCount++,R!==null&&(T.pooledCacheLanes|=p),T=R),l.memoizedState={parent:y,cache:T},op(l),Ai(l,An,T)):((i.lanes&p)!==0&&(lp(i,l),cc(l,null,null,p),lc()),T=i.memoizedState,R=l.memoizedState,T.parent!==y?(T={parent:y,cache:y},l.memoizedState=T,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=T),Ai(l,An,y)):(y=R.cache,Ai(l,An,y),y!==T.cache&&np(l,[An],p,!0))),Xn(i,l,l.pendingProps.children,p),l.child;case 29:throw l.pendingProps}throw Error(r(156,l.tag))}function ni(i){i.flags|=4}function Up(i,l,p,y,T){if((l=(i.mode&32)!==0)&&(l=!1),l){if(i.flags|=16777216,(T&335544128)===T)if(i.stateNode.complete)i.flags|=8192;else if(kS())i.flags|=8192;else throw Na=ld,ap}else i.flags&=-16777217}function Z0(i,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!mw(l))if(kS())i.flags|=8192;else throw Na=ld,ap}function kd(i,l){l!==null&&(i.flags|=4),i.flags&16384&&(l=i.tag!==22?xn():536870912,i.lanes|=l,zo|=l)}function pc(i,l){if(!Ot)switch(i.tailMode){case"hidden":l=i.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?i.tail=null:p.sibling=null;break;case"collapsed":p=i.tail;for(var y=null;p!==null;)p.alternate!==null&&(y=p),p=p.sibling;y===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:y.sibling=null}}function hn(i){var l=i.alternate!==null&&i.alternate.child===i.child,p=0,y=0;if(l)for(var T=i.child;T!==null;)p|=T.lanes|T.childLanes,y|=T.subtreeFlags&65011712,y|=T.flags&65011712,T.return=i,T=T.sibling;else for(T=i.child;T!==null;)p|=T.lanes|T.childLanes,y|=T.subtreeFlags,y|=T.flags,T.return=i,T=T.sibling;return i.subtreeFlags|=y,i.childLanes=p,l}function fR(i,l,p){var y=l.pendingProps;switch(Qm(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return hn(l),null;case 1:return hn(l),null;case 3:return p=l.stateNode,y=null,i!==null&&(y=i.memoizedState.cache),l.memoizedState.cache!==y&&(l.flags|=2048),Js(An),J(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(i===null||i.child===null)&&(No(l)?ni(l):i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Zm())),hn(l),null;case 26:var T=l.type,R=l.memoizedState;return i===null?(ni(l),R!==null?(hn(l),Z0(l,R)):(hn(l),Up(l,T,null,y,p))):R?R!==i.memoizedState?(ni(l),hn(l),Z0(l,R)):(hn(l),l.flags&=-16777217):(i=i.memoizedProps,i!==y&&ni(l),hn(l),Up(l,T,i,y,p)),null;case 27:if(ne(l),p=X.current,T=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&ni(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return hn(l),null}i=ee.current,No(l)?R_(l):(i=aw(T,y,p),l.stateNode=i,ni(l))}return hn(l),null;case 5:if(ne(l),T=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&ni(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return hn(l),null}if(R=ee.current,No(l))R_(l);else{var G=Fd(X.current);switch(R){case 1:R=G.createElementNS("http://www.w3.org/2000/svg",T);break;case 2:R=G.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;default:switch(T){case"svg":R=G.createElementNS("http://www.w3.org/2000/svg",T);break;case"math":R=G.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;case"script":R=G.createElement("div"),R.innerHTML="<script><\/script>",R=R.removeChild(R.firstChild);break;case"select":R=typeof y.is=="string"?G.createElement("select",{is:y.is}):G.createElement("select"),y.multiple?R.multiple=!0:y.size&&(R.size=y.size);break;default:R=typeof y.is=="string"?G.createElement(T,{is:y.is}):G.createElement(T)}}R[Fe]=l,R[Je]=y;e:for(G=l.child;G!==null;){if(G.tag===5||G.tag===6)R.appendChild(G.stateNode);else if(G.tag!==4&&G.tag!==27&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===l)break e;for(;G.sibling===null;){if(G.return===null||G.return===l)break e;G=G.return}G.sibling.return=G.return,G=G.sibling}l.stateNode=R;e:switch(Qn(R,T,y),T){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}y&&ni(l)}}return hn(l),Up(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,p),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==y&&ni(l);else{if(typeof y!="string"&&l.stateNode===null)throw Error(r(166));if(i=X.current,No(l)){if(i=l.stateNode,p=l.memoizedProps,y=null,T=Kn,T!==null)switch(T.tag){case 27:case 5:y=T.memoizedProps}i[Fe]=l,i=!!(i.nodeValue===p||y!==null&&y.suppressHydrationWarning===!0||YS(i.nodeValue,p)),i||Ti(l,!0)}else i=Fd(i).createTextNode(y),i[Fe]=l,l.stateNode=i}return hn(l),null;case 31:if(p=l.memoizedState,i===null||i.memoizedState!==null){if(y=No(l),p!==null){if(i===null){if(!y)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Fe]=l}else wa(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;hn(l),i=!1}else p=Zm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=p),i=!0;if(!i)return l.flags&256?(Ar(l),l):(Ar(l),null);if((l.flags&128)!==0)throw Error(r(558))}return hn(l),null;case 13:if(y=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(T=No(l),y!==null&&y.dehydrated!==null){if(i===null){if(!T)throw Error(r(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(r(317));T[Fe]=l}else wa(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;hn(l),T=!1}else T=Zm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=T),T=!0;if(!T)return l.flags&256?(Ar(l),l):(Ar(l),null)}return Ar(l),(l.flags&128)!==0?(l.lanes=p,l):(p=y!==null,i=i!==null&&i.memoizedState!==null,p&&(y=l.child,T=null,y.alternate!==null&&y.alternate.memoizedState!==null&&y.alternate.memoizedState.cachePool!==null&&(T=y.alternate.memoizedState.cachePool.pool),R=null,y.memoizedState!==null&&y.memoizedState.cachePool!==null&&(R=y.memoizedState.cachePool.pool),R!==T&&(y.flags|=2048)),p!==i&&p&&(l.child.flags|=8192),kd(l,l.updateQueue),hn(l),null);case 4:return J(),i===null&&dg(l.stateNode.containerInfo),hn(l),null;case 10:return Js(l.type),hn(l),null;case 19:if(V(kn),y=l.memoizedState,y===null)return hn(l),null;if(T=(l.flags&128)!==0,R=y.rendering,R===null)if(T)pc(y,!1);else{if(wn!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(R=hd(i),R!==null){for(l.flags|=128,pc(y,!1),i=R.updateQueue,l.updateQueue=i,kd(l,i),l.subtreeFlags=0,i=p,p=l.child;p!==null;)E_(p,i),p=p.sibling;return $(kn,kn.current&1|2),Ot&&Xs(l,y.treeForkCount),l.child}i=i.sibling}y.tail!==null&&_e()>Ad&&(l.flags|=128,T=!0,pc(y,!1),l.lanes=4194304)}else{if(!T)if(i=hd(R),i!==null){if(l.flags|=128,T=!0,i=i.updateQueue,l.updateQueue=i,kd(l,i),pc(y,!0),y.tail===null&&y.tailMode==="hidden"&&!R.alternate&&!Ot)return hn(l),null}else 2*_e()-y.renderingStartTime>Ad&&p!==536870912&&(l.flags|=128,T=!0,pc(y,!1),l.lanes=4194304);y.isBackwards?(R.sibling=l.child,l.child=R):(i=y.last,i!==null?i.sibling=R:l.child=R,y.last=R)}return y.tail!==null?(i=y.tail,y.rendering=i,y.tail=i.sibling,y.renderingStartTime=_e(),i.sibling=null,p=kn.current,$(kn,T?p&1|2:p&1),Ot&&Xs(l,y.treeForkCount),i):(hn(l),null);case 22:case 23:return Ar(l),hp(),y=l.memoizedState!==null,i!==null?i.memoizedState!==null!==y&&(l.flags|=8192):y&&(l.flags|=8192),y?(p&536870912)!==0&&(l.flags&128)===0&&(hn(l),l.subtreeFlags&6&&(l.flags|=8192)):hn(l),p=l.updateQueue,p!==null&&kd(l,p.retryQueue),p=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(p=i.memoizedState.cachePool.pool),y=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(y=l.memoizedState.cachePool.pool),y!==p&&(l.flags|=2048),i!==null&&V(ja),null;case 24:return p=null,i!==null&&(p=i.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),Js(An),hn(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function mR(i,l){switch(Qm(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return Js(An),J(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ne(l),null;case 31:if(l.memoizedState!==null){if(Ar(l),l.alternate===null)throw Error(r(340));wa()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(Ar(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));wa()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return V(kn),null;case 4:return J(),null;case 10:return Js(l.type),null;case 22:case 23:return Ar(l),hp(),i!==null&&V(ja),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return Js(An),null;case 25:return null;default:return null}}function eS(i,l){switch(Qm(l),l.tag){case 3:Js(An),J();break;case 26:case 27:case 5:ne(l);break;case 4:J();break;case 31:l.memoizedState!==null&&Ar(l);break;case 13:Ar(l);break;case 19:V(kn);break;case 10:Js(l.type);break;case 22:case 23:Ar(l),hp(),i!==null&&V(ja);break;case 24:Js(An)}}function gc(i,l){try{var p=l.updateQueue,y=p!==null?p.lastEffect:null;if(y!==null){var T=y.next;p=T;do{if((p.tag&i)===i){y=void 0;var R=p.create,G=p.inst;y=R(),G.destroy=y}p=p.next}while(p!==T)}}catch(te){Yt(l,l.return,te)}}function Ii(i,l,p){try{var y=l.updateQueue,T=y!==null?y.lastEffect:null;if(T!==null){var R=T.next;y=R;do{if((y.tag&i)===i){var G=y.inst,te=G.destroy;if(te!==void 0){G.destroy=void 0,T=l;var oe=p,xe=te;try{xe()}catch(Ie){Yt(T,oe,Ie)}}}y=y.next}while(y!==R)}}catch(Ie){Yt(l,l.return,Ie)}}function tS(i){var l=i.updateQueue;if(l!==null){var p=i.stateNode;try{W_(l,p)}catch(y){Yt(i,i.return,y)}}}function nS(i,l,p){p.props=La(i.type,i.memoizedProps),p.state=i.memoizedState;try{p.componentWillUnmount()}catch(y){Yt(i,l,y)}}function xc(i,l){try{var p=i.ref;if(p!==null){switch(i.tag){case 26:case 27:case 5:var y=i.stateNode;break;case 30:y=i.stateNode;break;default:y=i.stateNode}typeof p=="function"?i.refCleanup=p(y):p.current=y}}catch(T){Yt(i,l,T)}}function Es(i,l){var p=i.ref,y=i.refCleanup;if(p!==null)if(typeof y=="function")try{y()}catch(T){Yt(i,l,T)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(T){Yt(i,l,T)}else p.current=null}function rS(i){var l=i.type,p=i.memoizedProps,y=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":p.autoFocus&&y.focus();break e;case"img":p.src?y.src=p.src:p.srcSet&&(y.srcset=p.srcSet)}}catch(T){Yt(i,i.return,T)}}function Vp(i,l,p){try{var y=i.stateNode;IR(y,i.type,p,l),y[Je]=l}catch(T){Yt(i,i.return,T)}}function sS(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ui(i.type)||i.tag===4}function Wp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||sS(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&&Ui(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 Gp(i,l,p){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(i,l):(l=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,l.appendChild(i),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=qs));else if(y!==4&&(y===27&&Ui(i.type)&&(p=i.stateNode,l=null),i=i.child,i!==null))for(Gp(i,l,p),i=i.sibling;i!==null;)Gp(i,l,p),i=i.sibling}function jd(i,l,p){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?p.insertBefore(i,l):p.appendChild(i);else if(y!==4&&(y===27&&Ui(i.type)&&(p=i.stateNode),i=i.child,i!==null))for(jd(i,l,p),i=i.sibling;i!==null;)jd(i,l,p),i=i.sibling}function iS(i){var l=i.stateNode,p=i.memoizedProps;try{for(var y=i.type,T=l.attributes;T.length;)l.removeAttributeNode(T[0]);Qn(l,y,p),l[Fe]=i,l[Je]=p}catch(R){Yt(i,i.return,R)}}var ri=!1,Dn=!1,qp=!1,aS=typeof WeakSet=="function"?WeakSet:Set,Un=null;function pR(i,l){if(i=i.containerInfo,mg=qd,i=y_(i),Fm(i)){if("selectionStart"in i)var p={start:i.selectionStart,end:i.selectionEnd};else e:{p=(p=i.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var T=y.anchorOffset,R=y.focusNode;y=y.focusOffset;try{p.nodeType,R.nodeType}catch{p=null;break e}var G=0,te=-1,oe=-1,xe=0,Ie=0,ze=i,we=null;t:for(;;){for(var Ce;ze!==p||T!==0&&ze.nodeType!==3||(te=G+T),ze!==R||y!==0&&ze.nodeType!==3||(oe=G+y),ze.nodeType===3&&(G+=ze.nodeValue.length),(Ce=ze.firstChild)!==null;)we=ze,ze=Ce;for(;;){if(ze===i)break t;if(we===p&&++xe===T&&(te=G),we===R&&++Ie===y&&(oe=G),(Ce=ze.nextSibling)!==null)break;ze=we,we=ze.parentNode}ze=Ce}p=te===-1||oe===-1?null:{start:te,end:oe}}else p=null}p=p||{start:0,end:0}}else p=null;for(pg={focusedElem:i,selectionRange:p},qd=!1,Un=l;Un!==null;)if(l=Un,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,Un=i;else for(;Un!==null;){switch(l=Un,R=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(p=0;p<i.length;p++)T=i[p],T.ref.impl=T.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&R!==null){i=void 0,p=l,T=R.memoizedProps,R=R.memoizedState,y=p.stateNode;try{var lt=La(p.type,T);i=y.getSnapshotBeforeUpdate(lt,R),y.__reactInternalSnapshotBeforeUpdate=i}catch(gt){Yt(p,p.return,gt)}}break;case 3:if((i&1024)!==0){if(i=l.stateNode.containerInfo,p=i.nodeType,p===9)yg(i);else if(p===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":yg(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=l.sibling,i!==null){i.return=l.return,Un=i;break}Un=l.return}}function oS(i,l,p){var y=p.flags;switch(p.tag){case 0:case 11:case 15:ii(i,p),y&4&&gc(5,p);break;case 1:if(ii(i,p),y&4)if(i=p.stateNode,l===null)try{i.componentDidMount()}catch(G){Yt(p,p.return,G)}else{var T=La(p.type,l.memoizedProps);l=l.memoizedState;try{i.componentDidUpdate(T,l,i.__reactInternalSnapshotBeforeUpdate)}catch(G){Yt(p,p.return,G)}}y&64&&tS(p),y&512&&xc(p,p.return);break;case 3:if(ii(i,p),y&64&&(i=p.updateQueue,i!==null)){if(l=null,p.child!==null)switch(p.child.tag){case 27:case 5:l=p.child.stateNode;break;case 1:l=p.child.stateNode}try{W_(i,l)}catch(G){Yt(p,p.return,G)}}break;case 27:l===null&&y&4&&iS(p);case 26:case 5:ii(i,p),l===null&&y&4&&rS(p),y&512&&xc(p,p.return);break;case 12:ii(i,p);break;case 31:ii(i,p),y&4&&uS(i,p);break;case 13:ii(i,p),y&4&&dS(i,p),y&64&&(i=p.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(p=CR.bind(null,p),VR(i,p))));break;case 22:if(y=p.memoizedState!==null||ri,!y){l=l!==null&&l.memoizedState!==null||Dn,T=ri;var R=Dn;ri=y,(Dn=l)&&!R?ai(i,p,(p.subtreeFlags&8772)!==0):ii(i,p),ri=T,Dn=R}break;case 30:break;default:ii(i,p)}}function lS(i){var l=i.alternate;l!==null&&(i.alternate=null,lS(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&fo(l)),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 pn=null,mr=!1;function si(i,l,p){for(p=p.child;p!==null;)cS(i,l,p),p=p.sibling}function cS(i,l,p){if(nt&&typeof nt.onCommitFiberUnmount=="function")try{nt.onCommitFiberUnmount(it,p)}catch{}switch(p.tag){case 26:Dn||Es(p,l),si(i,l,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:Dn||Es(p,l);var y=pn,T=mr;Ui(p.type)&&(pn=p.stateNode,mr=!1),si(i,l,p),jc(p.stateNode),pn=y,mr=T;break;case 5:Dn||Es(p,l);case 6:if(y=pn,T=mr,pn=null,si(i,l,p),pn=y,mr=T,pn!==null)if(mr)try{(pn.nodeType===9?pn.body:pn.nodeName==="HTML"?pn.ownerDocument.body:pn).removeChild(p.stateNode)}catch(R){Yt(p,l,R)}else try{pn.removeChild(p.stateNode)}catch(R){Yt(p,l,R)}break;case 18:pn!==null&&(mr?(i=pn,tw(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,p.stateNode),Yo(i)):tw(pn,p.stateNode));break;case 4:y=pn,T=mr,pn=p.stateNode.containerInfo,mr=!0,si(i,l,p),pn=y,mr=T;break;case 0:case 11:case 14:case 15:Ii(2,p,l),Dn||Ii(4,p,l),si(i,l,p);break;case 1:Dn||(Es(p,l),y=p.stateNode,typeof y.componentWillUnmount=="function"&&nS(p,l,y)),si(i,l,p);break;case 21:si(i,l,p);break;case 22:Dn=(y=Dn)||p.memoizedState!==null,si(i,l,p),Dn=y;break;default:si(i,l,p)}}function uS(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Yo(i)}catch(p){Yt(l,l.return,p)}}}function dS(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Yo(i)}catch(p){Yt(l,l.return,p)}}function gR(i){switch(i.tag){case 31:case 13:case 19:var l=i.stateNode;return l===null&&(l=i.stateNode=new aS),l;case 22:return i=i.stateNode,l=i._retryCache,l===null&&(l=i._retryCache=new aS),l;default:throw Error(r(435,i.tag))}}function Ed(i,l){var p=gR(i);l.forEach(function(y){if(!p.has(y)){p.add(y);var T=kR.bind(null,i,y);y.then(T,T)}})}function pr(i,l){var p=l.deletions;if(p!==null)for(var y=0;y<p.length;y++){var T=p[y],R=i,G=l,te=G;e:for(;te!==null;){switch(te.tag){case 27:if(Ui(te.type)){pn=te.stateNode,mr=!1;break e}break;case 5:pn=te.stateNode,mr=!1;break e;case 3:case 4:pn=te.stateNode.containerInfo,mr=!0;break e}te=te.return}if(pn===null)throw Error(r(160));cS(R,G,T),pn=null,mr=!1,R=T.alternate,R!==null&&(R.return=null),T.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)hS(l,i),l=l.sibling}var os=null;function hS(i,l){var p=i.alternate,y=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:pr(l,i),gr(i),y&4&&(Ii(3,i,i.return),gc(3,i),Ii(5,i,i.return));break;case 1:pr(l,i),gr(i),y&512&&(Dn||p===null||Es(p,p.return)),y&64&&ri&&(i=i.updateQueue,i!==null&&(y=i.callbacks,y!==null&&(p=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=p===null?y:p.concat(y))));break;case 26:var T=os;if(pr(l,i),gr(i),y&512&&(Dn||p===null||Es(p,p.return)),y&4){var R=p!==null?p.memoizedState:null;if(y=i.memoizedState,p===null)if(y===null)if(i.stateNode===null){e:{y=i.type,p=i.memoizedProps,T=T.ownerDocument||T;t:switch(y){case"title":R=T.getElementsByTagName("title")[0],(!R||R[Tn]||R[Fe]||R.namespaceURI==="http://www.w3.org/2000/svg"||R.hasAttribute("itemprop"))&&(R=T.createElement(y),T.head.insertBefore(R,T.querySelector("head > title"))),Qn(R,y,p),R[Fe]=i,Hn(R),y=R;break e;case"link":var G=hw("link","href",T).get(y+(p.href||""));if(G){for(var te=0;te<G.length;te++)if(R=G[te],R.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&R.getAttribute("rel")===(p.rel==null?null:p.rel)&&R.getAttribute("title")===(p.title==null?null:p.title)&&R.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){G.splice(te,1);break t}}R=T.createElement(y),Qn(R,y,p),T.head.appendChild(R);break;case"meta":if(G=hw("meta","content",T).get(y+(p.content||""))){for(te=0;te<G.length;te++)if(R=G[te],R.getAttribute("content")===(p.content==null?null:""+p.content)&&R.getAttribute("name")===(p.name==null?null:p.name)&&R.getAttribute("property")===(p.property==null?null:p.property)&&R.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&R.getAttribute("charset")===(p.charSet==null?null:p.charSet)){G.splice(te,1);break t}}R=T.createElement(y),Qn(R,y,p),T.head.appendChild(R);break;default:throw Error(r(468,y))}R[Fe]=i,Hn(R),y=R}i.stateNode=y}else fw(T,i.type,i.stateNode);else i.stateNode=dw(T,y,i.memoizedProps);else R!==y?(R===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):R.count--,y===null?fw(T,i.type,i.stateNode):dw(T,y,i.memoizedProps)):y===null&&i.stateNode!==null&&Vp(i,i.memoizedProps,p.memoizedProps)}break;case 27:pr(l,i),gr(i),y&512&&(Dn||p===null||Es(p,p.return)),p!==null&&y&4&&Vp(i,i.memoizedProps,p.memoizedProps);break;case 5:if(pr(l,i),gr(i),y&512&&(Dn||p===null||Es(p,p.return)),i.flags&32){T=i.stateNode;try{yo(T,"")}catch(lt){Yt(i,i.return,lt)}}y&4&&i.stateNode!=null&&(T=i.memoizedProps,Vp(i,T,p!==null?p.memoizedProps:T)),y&1024&&(qp=!0);break;case 6:if(pr(l,i),gr(i),y&4){if(i.stateNode===null)throw Error(r(162));y=i.memoizedProps,p=i.stateNode;try{p.nodeValue=y}catch(lt){Yt(i,i.return,lt)}}break;case 3:if(Ud=null,T=os,os=zd(l.containerInfo),pr(l,i),os=T,gr(i),y&4&&p!==null&&p.memoizedState.isDehydrated)try{Yo(l.containerInfo)}catch(lt){Yt(i,i.return,lt)}qp&&(qp=!1,fS(i));break;case 4:y=os,os=zd(i.stateNode.containerInfo),pr(l,i),gr(i),os=y;break;case 12:pr(l,i),gr(i);break;case 31:pr(l,i),gr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,Ed(i,y)));break;case 13:pr(l,i),gr(i),i.child.flags&8192&&i.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Td=_e()),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,Ed(i,y)));break;case 22:T=i.memoizedState!==null;var oe=p!==null&&p.memoizedState!==null,xe=ri,Ie=Dn;if(ri=xe||T,Dn=Ie||oe,pr(l,i),Dn=Ie,ri=xe,gr(i),y&8192)e:for(l=i.stateNode,l._visibility=T?l._visibility&-2:l._visibility|1,T&&(p===null||oe||ri||Dn||Ra(i)),p=null,l=i;;){if(l.tag===5||l.tag===26){if(p===null){oe=p=l;try{if(R=oe.stateNode,T)G=R.style,typeof G.setProperty=="function"?G.setProperty("display","none","important"):G.display="none";else{te=oe.stateNode;var ze=oe.memoizedProps.style,we=ze!=null&&ze.hasOwnProperty("display")?ze.display:null;te.style.display=we==null||typeof we=="boolean"?"":(""+we).trim()}}catch(lt){Yt(oe,oe.return,lt)}}}else if(l.tag===6){if(p===null){oe=l;try{oe.stateNode.nodeValue=T?"":oe.memoizedProps}catch(lt){Yt(oe,oe.return,lt)}}}else if(l.tag===18){if(p===null){oe=l;try{var Ce=oe.stateNode;T?nw(Ce,!0):nw(oe.stateNode,!1)}catch(lt){Yt(oe,oe.return,lt)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===i)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break e;for(;l.sibling===null;){if(l.return===null||l.return===i)break e;p===l&&(p=null),l=l.return}p===l&&(p=null),l.sibling.return=l.return,l=l.sibling}y&4&&(y=i.updateQueue,y!==null&&(p=y.retryQueue,p!==null&&(y.retryQueue=null,Ed(i,p))));break;case 19:pr(l,i),gr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,Ed(i,y)));break;case 30:break;case 21:break;default:pr(l,i),gr(i)}}function gr(i){var l=i.flags;if(l&2){try{for(var p,y=i.return;y!==null;){if(sS(y)){p=y;break}y=y.return}if(p==null)throw Error(r(160));switch(p.tag){case 27:var T=p.stateNode,R=Wp(i);jd(i,R,T);break;case 5:var G=p.stateNode;p.flags&32&&(yo(G,""),p.flags&=-33);var te=Wp(i);jd(i,te,G);break;case 3:case 4:var oe=p.stateNode.containerInfo,xe=Wp(i);Gp(i,xe,oe);break;default:throw Error(r(161))}}catch(Ie){Yt(i,i.return,Ie)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function fS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var l=i;fS(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),i=i.sibling}}function ii(i,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)oS(i,l.alternate,l),l=l.sibling}function Ra(i){for(i=i.child;i!==null;){var l=i;switch(l.tag){case 0:case 11:case 14:case 15:Ii(4,l,l.return),Ra(l);break;case 1:Es(l,l.return);var p=l.stateNode;typeof p.componentWillUnmount=="function"&&nS(l,l.return,p),Ra(l);break;case 27:jc(l.stateNode);case 26:case 5:Es(l,l.return),Ra(l);break;case 22:l.memoizedState===null&&Ra(l);break;case 30:Ra(l);break;default:Ra(l)}i=i.sibling}}function ai(i,l,p){for(p=p&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var y=l.alternate,T=i,R=l,G=R.flags;switch(R.tag){case 0:case 11:case 15:ai(T,R,p),gc(4,R);break;case 1:if(ai(T,R,p),y=R,T=y.stateNode,typeof T.componentDidMount=="function")try{T.componentDidMount()}catch(xe){Yt(y,y.return,xe)}if(y=R,T=y.updateQueue,T!==null){var te=y.stateNode;try{var oe=T.shared.hiddenCallbacks;if(oe!==null)for(T.shared.hiddenCallbacks=null,T=0;T<oe.length;T++)V_(oe[T],te)}catch(xe){Yt(y,y.return,xe)}}p&&G&64&&tS(R),xc(R,R.return);break;case 27:iS(R);case 26:case 5:ai(T,R,p),p&&y===null&&G&4&&rS(R),xc(R,R.return);break;case 12:ai(T,R,p);break;case 31:ai(T,R,p),p&&G&4&&uS(T,R);break;case 13:ai(T,R,p),p&&G&4&&dS(T,R);break;case 22:R.memoizedState===null&&ai(T,R,p),xc(R,R.return);break;case 30:break;default:ai(T,R,p)}l=l.sibling}}function Kp(i,l){var p=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(p=i.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==p&&(i!=null&&i.refCount++,p!=null&&rc(p))}function Yp(i,l){i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&rc(i))}function ls(i,l,p,y){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)mS(i,l,p,y),l=l.sibling}function mS(i,l,p,y){var T=l.flags;switch(l.tag){case 0:case 11:case 15:ls(i,l,p,y),T&2048&&gc(9,l);break;case 1:ls(i,l,p,y);break;case 3:ls(i,l,p,y),T&2048&&(i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&rc(i)));break;case 12:if(T&2048){ls(i,l,p,y),i=l.stateNode;try{var R=l.memoizedProps,G=R.id,te=R.onPostCommit;typeof te=="function"&&te(G,l.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(oe){Yt(l,l.return,oe)}}else ls(i,l,p,y);break;case 31:ls(i,l,p,y);break;case 13:ls(i,l,p,y);break;case 23:break;case 22:R=l.stateNode,G=l.alternate,l.memoizedState!==null?R._visibility&2?ls(i,l,p,y):yc(i,l):R._visibility&2?ls(i,l,p,y):(R._visibility|=2,Bo(i,l,p,y,(l.subtreeFlags&10256)!==0||!1)),T&2048&&Kp(G,l);break;case 24:ls(i,l,p,y),T&2048&&Yp(l.alternate,l);break;default:ls(i,l,p,y)}}function Bo(i,l,p,y,T){for(T=T&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var R=i,G=l,te=p,oe=y,xe=G.flags;switch(G.tag){case 0:case 11:case 15:Bo(R,G,te,oe,T),gc(8,G);break;case 23:break;case 22:var Ie=G.stateNode;G.memoizedState!==null?Ie._visibility&2?Bo(R,G,te,oe,T):yc(R,G):(Ie._visibility|=2,Bo(R,G,te,oe,T)),T&&xe&2048&&Kp(G.alternate,G);break;case 24:Bo(R,G,te,oe,T),T&&xe&2048&&Yp(G.alternate,G);break;default:Bo(R,G,te,oe,T)}l=l.sibling}}function yc(i,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var p=i,y=l,T=y.flags;switch(y.tag){case 22:yc(p,y),T&2048&&Kp(y.alternate,y);break;case 24:yc(p,y),T&2048&&Yp(y.alternate,y);break;default:yc(p,y)}l=l.sibling}}var bc=8192;function $o(i,l,p){if(i.subtreeFlags&bc)for(i=i.child;i!==null;)pS(i,l,p),i=i.sibling}function pS(i,l,p){switch(i.tag){case 26:$o(i,l,p),i.flags&bc&&i.memoizedState!==null&&nD(p,os,i.memoizedState,i.memoizedProps);break;case 5:$o(i,l,p);break;case 3:case 4:var y=os;os=zd(i.stateNode.containerInfo),$o(i,l,p),os=y;break;case 22:i.memoizedState===null&&(y=i.alternate,y!==null&&y.memoizedState!==null?(y=bc,bc=16777216,$o(i,l,p),bc=y):$o(i,l,p));break;default:$o(i,l,p)}}function gS(i){var l=i.alternate;if(l!==null&&(i=l.child,i!==null)){l.child=null;do l=i.sibling,i.sibling=null,i=l;while(i!==null)}}function vc(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var p=0;p<l.length;p++){var y=l[p];Un=y,yS(y,i)}gS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)xS(i),i=i.sibling}function xS(i){switch(i.tag){case 0:case 11:case 15:vc(i),i.flags&2048&&Ii(9,i,i.return);break;case 3:vc(i);break;case 12:vc(i);break;case 22:var l=i.stateNode;i.memoizedState!==null&&l._visibility&2&&(i.return===null||i.return.tag!==13)?(l._visibility&=-3,Nd(i)):vc(i);break;default:vc(i)}}function Nd(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var p=0;p<l.length;p++){var y=l[p];Un=y,yS(y,i)}gS(i)}for(i=i.child;i!==null;){switch(l=i,l.tag){case 0:case 11:case 15:Ii(8,l,l.return),Nd(l);break;case 22:p=l.stateNode,p._visibility&2&&(p._visibility&=-3,Nd(l));break;default:Nd(l)}i=i.sibling}}function yS(i,l){for(;Un!==null;){var p=Un;switch(p.tag){case 0:case 11:case 15:Ii(8,p,l);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var y=p.memoizedState.cachePool.pool;y!=null&&y.refCount++}break;case 24:rc(p.memoizedState.cache)}if(y=p.child,y!==null)y.return=p,Un=y;else e:for(p=i;Un!==null;){y=Un;var T=y.sibling,R=y.return;if(lS(y),y===p){Un=null;break e}if(T!==null){T.return=R,Un=T;break e}Un=R}}}var xR={getCacheForType:function(i){var l=Yn(An),p=l.data.get(i);return p===void 0&&(p=i(),l.data.set(i,p)),p},cacheSignal:function(){return Yn(An).controller.signal}},yR=typeof WeakMap=="function"?WeakMap:Map,Vt=0,nn=null,Nt=null,Rt=0,Kt=0,Lr=null,Pi=!1,Fo=!1,Xp=!1,oi=0,wn=0,Bi=0,Da=0,Qp=0,Rr=0,zo=0,_c=null,xr=null,Jp=!1,Td=0,bS=0,Ad=1/0,Ld=null,$i=null,Pn=0,Fi=null,Ho=null,li=0,Zp=0,eg=null,vS=null,Sc=0,tg=null;function Dr(){return(Vt&2)!==0&&Rt!==0?Rt&-Rt:W.T!==null?og():Mt()}function _S(){if(Rr===0)if((Rt&536870912)===0||Ot){var i=et;et<<=1,(et&3932160)===0&&(et=262144),Rr=i}else Rr=536870912;return i=Tr.current,i!==null&&(i.flags|=32),Rr}function yr(i,l,p){(i===nn&&(Kt===2||Kt===9)||i.cancelPendingCommit!==null)&&(Uo(i,0),zi(i,Rt,Rr,!1)),be(i,p),((Vt&2)===0||i!==nn)&&(i===nn&&((Vt&2)===0&&(Da|=p),wn===4&&zi(i,Rt,Rr,!1)),Ns(i))}function SS(i,l,p){if((Vt&6)!==0)throw Error(r(327));var y=!p&&(l&127)===0&&(l&i.expiredLanes)===0||vn(i,l),T=y?_R(i,l):rg(i,l,!0),R=y;do{if(T===0){Fo&&!y&&zi(i,l,0,!1);break}else{if(p=i.current.alternate,R&&!bR(p)){T=rg(i,l,!1),R=!1;continue}if(T===2){if(R=l,i.errorRecoveryDisabledLanes&R)var G=0;else G=i.pendingLanes&-536870913,G=G!==0?G:G&536870912?536870912:0;if(G!==0){l=G;e:{var te=i;T=_c;var oe=te.current.memoizedState.isDehydrated;if(oe&&(Uo(te,G).flags|=256),G=rg(te,G,!1),G!==2){if(Xp&&!oe){te.errorRecoveryDisabledLanes|=R,Da|=R,T=4;break e}R=xr,xr=T,R!==null&&(xr===null?xr=R:xr.push.apply(xr,R))}T=G}if(R=!1,T!==2)continue}}if(T===1){Uo(i,0),zi(i,l,0,!0);break}e:{switch(y=i,R=T,R){case 0:case 1:throw Error(r(345));case 4:if((l&4194048)!==l)break;case 6:zi(y,l,Rr,!Pi);break e;case 2:xr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((l&62914560)===l&&(T=Td+300-_e(),10<T)){if(zi(y,l,Rr,!Pi),qt(y,0,!0)!==0)break e;li=l,y.timeoutHandle=ZS(wS.bind(null,y,p,xr,Ld,Jp,l,Rr,Da,zo,Pi,R,"Throttled",-0,0),T);break e}wS(y,p,xr,Ld,Jp,l,Rr,Da,zo,Pi,R,null,-0,0)}}break}while(!0);Ns(i)}function wS(i,l,p,y,T,R,G,te,oe,xe,Ie,ze,we,Ce){if(i.timeoutHandle=-1,ze=l.subtreeFlags,ze&8192||(ze&16785408)===16785408){ze={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qs},pS(l,R,ze);var lt=(R&62914560)===R?Td-_e():(R&4194048)===R?bS-_e():0;if(lt=rD(ze,lt),lt!==null){li=R,i.cancelPendingCommit=lt(LS.bind(null,i,l,R,p,y,T,G,te,oe,Ie,ze,null,we,Ce)),zi(i,R,G,!xe);return}}LS(i,l,R,p,y,T,G,te,oe)}function bR(i){for(var l=i;;){var p=l.tag;if((p===0||p===11||p===15)&&l.flags&16384&&(p=l.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var y=0;y<p.length;y++){var T=p[y],R=T.getSnapshot;T=T.value;try{if(!Er(R(),T))return!1}catch{return!1}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function zi(i,l,p,y){l&=~Qp,l&=~Da,i.suspendedLanes|=l,i.pingedLanes&=~l,y&&(i.warmLanes|=l),y=i.expirationTimes;for(var T=l;0<T;){var R=31-Re(T),G=1<<R;y[R]=-1,T&=~G}p!==0&&Qe(i,p,l)}function Rd(){return(Vt&6)===0?(wc(0),!1):!0}function ng(){if(Nt!==null){if(Kt===0)var i=Nt.return;else i=Nt,Qs=Ca=null,yp(i),Do=null,ic=0,i=Nt;for(;i!==null;)eS(i.alternate,i),i=i.return;Nt=null}}function Uo(i,l){var p=i.timeoutHandle;p!==-1&&(i.timeoutHandle=-1,$R(p)),p=i.cancelPendingCommit,p!==null&&(i.cancelPendingCommit=null,p()),li=0,ng(),nn=i,Nt=p=Ys(i.current,null),Rt=l,Kt=0,Lr=null,Pi=!1,Fo=vn(i,l),Xp=!1,zo=Rr=Qp=Da=Bi=wn=0,xr=_c=null,Jp=!1,(l&8)!==0&&(l|=l&32);var y=i.entangledLanes;if(y!==0)for(i=i.entanglements,y&=l;0<y;){var T=31-Re(y),R=1<<T;l|=i[T],y&=~R}return oi=l,Zu(),p}function CS(i,l){Ct=null,W.H=fc,l===Ro||l===od?(l=F_(),Kt=3):l===ap?(l=F_(),Kt=4):Kt=l===Op?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,Lr=l,Nt===null&&(wn=1,_d(i,Wr(l,i.current)))}function kS(){var i=Tr.current;return i===null?!0:(Rt&4194048)===Rt?Yr===null:(Rt&62914560)===Rt||(Rt&536870912)!==0?i===Yr:!1}function jS(){var i=W.H;return W.H=fc,i===null?fc:i}function ES(){var i=W.A;return W.A=xR,i}function Dd(){wn=4,Pi||(Rt&4194048)!==Rt&&Tr.current!==null||(Fo=!0),(Bi&134217727)===0&&(Da&134217727)===0||nn===null||zi(nn,Rt,Rr,!1)}function rg(i,l,p){var y=Vt;Vt|=2;var T=jS(),R=ES();(nn!==i||Rt!==l)&&(Ld=null,Uo(i,l)),l=!1;var G=wn;e:do try{if(Kt!==0&&Nt!==null){var te=Nt,oe=Lr;switch(Kt){case 8:ng(),G=6;break e;case 3:case 2:case 9:case 6:Tr.current===null&&(l=!0);var xe=Kt;if(Kt=0,Lr=null,Vo(i,te,oe,xe),p&&Fo){G=0;break e}break;default:xe=Kt,Kt=0,Lr=null,Vo(i,te,oe,xe)}}vR(),G=wn;break}catch(Ie){CS(i,Ie)}while(!0);return l&&i.shellSuspendCounter++,Qs=Ca=null,Vt=y,W.H=T,W.A=R,Nt===null&&(nn=null,Rt=0,Zu()),G}function vR(){for(;Nt!==null;)NS(Nt)}function _R(i,l){var p=Vt;Vt|=2;var y=jS(),T=ES();nn!==i||Rt!==l?(Ld=null,Ad=_e()+500,Uo(i,l)):Fo=vn(i,l);e:do try{if(Kt!==0&&Nt!==null){l=Nt;var R=Lr;t:switch(Kt){case 1:Kt=0,Lr=null,Vo(i,l,R,1);break;case 2:case 9:if(B_(R)){Kt=0,Lr=null,TS(l);break}l=function(){Kt!==2&&Kt!==9||nn!==i||(Kt=7),Ns(i)},R.then(l,l);break e;case 3:Kt=7;break e;case 4:Kt=5;break e;case 7:B_(R)?(Kt=0,Lr=null,TS(l)):(Kt=0,Lr=null,Vo(i,l,R,7));break;case 5:var G=null;switch(Nt.tag){case 26:G=Nt.memoizedState;case 5:case 27:var te=Nt;if(G?mw(G):te.stateNode.complete){Kt=0,Lr=null;var oe=te.sibling;if(oe!==null)Nt=oe;else{var xe=te.return;xe!==null?(Nt=xe,Od(xe)):Nt=null}break t}}Kt=0,Lr=null,Vo(i,l,R,5);break;case 6:Kt=0,Lr=null,Vo(i,l,R,6);break;case 8:ng(),wn=6;break e;default:throw Error(r(462))}}SR();break}catch(Ie){CS(i,Ie)}while(!0);return Qs=Ca=null,W.H=y,W.A=T,Vt=p,Nt!==null?0:(nn=null,Rt=0,Zu(),wn)}function SR(){for(;Nt!==null&&!me();)NS(Nt)}function NS(i){var l=J0(i.alternate,i,oi);i.memoizedProps=i.pendingProps,l===null?Od(i):Nt=l}function TS(i){var l=i,p=l.alternate;switch(l.tag){case 15:case 0:l=G0(p,l,l.pendingProps,l.type,void 0,Rt);break;case 11:l=G0(p,l,l.pendingProps,l.type.render,l.ref,Rt);break;case 5:yp(l);default:eS(p,l),l=Nt=E_(l,oi),l=J0(p,l,oi)}i.memoizedProps=i.pendingProps,l===null?Od(i):Nt=l}function Vo(i,l,p,y){Qs=Ca=null,yp(l),Do=null,ic=0;var T=l.return;try{if(uR(i,T,l,p,Rt)){wn=1,_d(i,Wr(p,i.current)),Nt=null;return}}catch(R){if(T!==null)throw Nt=T,R;wn=1,_d(i,Wr(p,i.current)),Nt=null;return}l.flags&32768?(Ot||y===1?i=!0:Fo||(Rt&536870912)!==0?i=!1:(Pi=i=!0,(y===2||y===9||y===3||y===6)&&(y=Tr.current,y!==null&&y.tag===13&&(y.flags|=16384))),AS(l,i)):Od(l)}function Od(i){var l=i;do{if((l.flags&32768)!==0){AS(l,Pi);return}i=l.return;var p=fR(l.alternate,l,oi);if(p!==null){Nt=p;return}if(l=l.sibling,l!==null){Nt=l;return}Nt=l=i}while(l!==null);wn===0&&(wn=5)}function AS(i,l){do{var p=mR(i.alternate,i);if(p!==null){p.flags&=32767,Nt=p;return}if(p=i.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!l&&(i=i.sibling,i!==null)){Nt=i;return}Nt=i=p}while(i!==null);wn=6,Nt=null}function LS(i,l,p,y,T,R,G,te,oe){i.cancelPendingCommit=null;do Md();while(Pn!==0);if((Vt&6)!==0)throw Error(r(327));if(l!==null){if(l===i.current)throw Error(r(177));if(R=l.lanes|l.childLanes,R|=Wm,rt(i,p,R,G,te,oe),i===nn&&(Nt=nn=null,Rt=0),Ho=l,Fi=i,li=p,Zp=R,eg=T,vS=y,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,jR(Xe,function(){return IS(),null})):(i.callbackNode=null,i.callbackPriority=0),y=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||y){y=W.T,W.T=null,T=Z.p,Z.p=2,G=Vt,Vt|=4;try{pR(i,l,p)}finally{Vt=G,Z.p=T,W.T=y}}Pn=1,RS(),DS(),OS()}}function RS(){if(Pn===1){Pn=0;var i=Fi,l=Ho,p=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||p){p=W.T,W.T=null;var y=Z.p;Z.p=2;var T=Vt;Vt|=4;try{hS(l,i);var R=pg,G=y_(i.containerInfo),te=R.focusedElem,oe=R.selectionRange;if(G!==te&&te&&te.ownerDocument&&x_(te.ownerDocument.documentElement,te)){if(oe!==null&&Fm(te)){var xe=oe.start,Ie=oe.end;if(Ie===void 0&&(Ie=xe),"selectionStart"in te)te.selectionStart=xe,te.selectionEnd=Math.min(Ie,te.value.length);else{var ze=te.ownerDocument||document,we=ze&&ze.defaultView||window;if(we.getSelection){var Ce=we.getSelection(),lt=te.textContent.length,gt=Math.min(oe.start,lt),Jt=oe.end===void 0?gt:Math.min(oe.end,lt);!Ce.extend&&gt>Jt&&(G=Jt,Jt=gt,gt=G);var he=g_(te,gt),ue=g_(te,Jt);if(he&&ue&&(Ce.rangeCount!==1||Ce.anchorNode!==he.node||Ce.anchorOffset!==he.offset||Ce.focusNode!==ue.node||Ce.focusOffset!==ue.offset)){var ge=ze.createRange();ge.setStart(he.node,he.offset),Ce.removeAllRanges(),gt>Jt?(Ce.addRange(ge),Ce.extend(ue.node,ue.offset)):(ge.setEnd(ue.node,ue.offset),Ce.addRange(ge))}}}}for(ze=[],Ce=te;Ce=Ce.parentNode;)Ce.nodeType===1&&ze.push({element:Ce,left:Ce.scrollLeft,top:Ce.scrollTop});for(typeof te.focus=="function"&&te.focus(),te=0;te<ze.length;te++){var Be=ze[te];Be.element.scrollLeft=Be.left,Be.element.scrollTop=Be.top}}qd=!!mg,pg=mg=null}finally{Vt=T,Z.p=y,W.T=p}}i.current=l,Pn=2}}function DS(){if(Pn===2){Pn=0;var i=Fi,l=Ho,p=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||p){p=W.T,W.T=null;var y=Z.p;Z.p=2;var T=Vt;Vt|=4;try{oS(i,l.alternate,l)}finally{Vt=T,Z.p=y,W.T=p}}Pn=3}}function OS(){if(Pn===4||Pn===3){Pn=0,re();var i=Fi,l=Ho,p=li,y=vS;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Pn=5:(Pn=0,Ho=Fi=null,MS(i,i.pendingLanes));var T=i.pendingLanes;if(T===0&&($i=null),xt(p),l=l.stateNode,nt&&typeof nt.onCommitFiberRoot=="function")try{nt.onCommitFiberRoot(it,l,void 0,(l.current.flags&128)===128)}catch{}if(y!==null){l=W.T,T=Z.p,Z.p=2,W.T=null;try{for(var R=i.onRecoverableError,G=0;G<y.length;G++){var te=y[G];R(te.value,{componentStack:te.stack})}}finally{W.T=l,Z.p=T}}(li&3)!==0&&Md(),Ns(i),T=i.pendingLanes,(p&261930)!==0&&(T&42)!==0?i===tg?Sc++:(Sc=0,tg=i):Sc=0,wc(0)}}function MS(i,l){(i.pooledCacheLanes&=l)===0&&(l=i.pooledCache,l!=null&&(i.pooledCache=null,rc(l)))}function Md(){return RS(),DS(),OS(),IS()}function IS(){if(Pn!==5)return!1;var i=Fi,l=Zp;Zp=0;var p=xt(li),y=W.T,T=Z.p;try{Z.p=32>p?32:p,W.T=null,p=eg,eg=null;var R=Fi,G=li;if(Pn=0,Ho=Fi=null,li=0,(Vt&6)!==0)throw Error(r(331));var te=Vt;if(Vt|=4,xS(R.current),mS(R,R.current,G,p),Vt=te,wc(0,!1),nt&&typeof nt.onPostCommitFiberRoot=="function")try{nt.onPostCommitFiberRoot(it,R)}catch{}return!0}finally{Z.p=T,W.T=y,MS(i,l)}}function PS(i,l,p){l=Wr(p,l),l=Dp(i.stateNode,l,2),i=Di(i,l,2),i!==null&&(be(i,2),Ns(i))}function Yt(i,l,p){if(i.tag===3)PS(i,i,p);else for(;l!==null;){if(l.tag===3){PS(l,i,p);break}else if(l.tag===1){var y=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&($i===null||!$i.has(y))){i=Wr(p,i),p=B0(2),y=Di(l,p,2),y!==null&&($0(p,y,l,i),be(y,2),Ns(y));break}}l=l.return}}function sg(i,l,p){var y=i.pingCache;if(y===null){y=i.pingCache=new yR;var T=new Set;y.set(l,T)}else T=y.get(l),T===void 0&&(T=new Set,y.set(l,T));T.has(p)||(Xp=!0,T.add(p),i=wR.bind(null,i,l,p),l.then(i,i))}function wR(i,l,p){var y=i.pingCache;y!==null&&y.delete(l),i.pingedLanes|=i.suspendedLanes&p,i.warmLanes&=~p,nn===i&&(Rt&p)===p&&(wn===4||wn===3&&(Rt&62914560)===Rt&&300>_e()-Td?(Vt&2)===0&&Uo(i,0):Qp|=p,zo===Rt&&(zo=0)),Ns(i)}function BS(i,l){l===0&&(l=xn()),i=_a(i,l),i!==null&&(be(i,l),Ns(i))}function CR(i){var l=i.memoizedState,p=0;l!==null&&(p=l.retryLane),BS(i,p)}function kR(i,l){var p=0;switch(i.tag){case 31:case 13:var y=i.stateNode,T=i.memoizedState;T!==null&&(p=T.retryLane);break;case 19:y=i.stateNode;break;case 22:y=i.stateNode._retryCache;break;default:throw Error(r(314))}y!==null&&y.delete(l),BS(i,p)}function jR(i,l){return ot(i,l)}var Id=null,Wo=null,ig=!1,Pd=!1,ag=!1,Hi=0;function Ns(i){i!==Wo&&i.next===null&&(Wo===null?Id=Wo=i:Wo=Wo.next=i),Pd=!0,ig||(ig=!0,NR())}function wc(i,l){if(!ag&&Pd){ag=!0;do for(var p=!1,y=Id;y!==null;){if(i!==0){var T=y.pendingLanes;if(T===0)var R=0;else{var G=y.suspendedLanes,te=y.pingedLanes;R=(1<<31-Re(42|i)+1)-1,R&=T&~(G&~te),R=R&201326741?R&201326741|1:R?R|2:0}R!==0&&(p=!0,HS(y,R))}else R=Rt,R=qt(y,y===nn?R:0,y.cancelPendingCommit!==null||y.timeoutHandle!==-1),(R&3)===0||vn(y,R)||(p=!0,HS(y,R));y=y.next}while(p);ag=!1}}function ER(){$S()}function $S(){Pd=ig=!1;var i=0;Hi!==0&&BR()&&(i=Hi);for(var l=_e(),p=null,y=Id;y!==null;){var T=y.next,R=FS(y,l);R===0?(y.next=null,p===null?Id=T:p.next=T,T===null&&(Wo=p)):(p=y,(i!==0||(R&3)!==0)&&(Pd=!0)),y=T}Pn!==0&&Pn!==5||wc(i),Hi!==0&&(Hi=0)}function FS(i,l){for(var p=i.suspendedLanes,y=i.pingedLanes,T=i.expirationTimes,R=i.pendingLanes&-62914561;0<R;){var G=31-Re(R),te=1<<G,oe=T[G];oe===-1?((te&p)===0||(te&y)!==0)&&(T[G]=_n(te,l)):oe<=l&&(i.expiredLanes|=te),R&=~te}if(l=nn,p=Rt,p=qt(i,i===l?p:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y=i.callbackNode,p===0||i===l&&(Kt===2||Kt===9)||i.cancelPendingCommit!==null)return y!==null&&y!==null&&Ae(y),i.callbackNode=null,i.callbackPriority=0;if((p&3)===0||vn(i,p)){if(l=p&-p,l===i.callbackPriority)return l;switch(y!==null&&Ae(y),xt(p)){case 2:case 8:p=Ne;break;case 32:p=Xe;break;case 268435456:p=fe;break;default:p=Xe}return y=zS.bind(null,i),p=ot(p,y),i.callbackPriority=l,i.callbackNode=p,l}return y!==null&&y!==null&&Ae(y),i.callbackPriority=2,i.callbackNode=null,2}function zS(i,l){if(Pn!==0&&Pn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var p=i.callbackNode;if(Md()&&i.callbackNode!==p)return null;var y=Rt;return y=qt(i,i===nn?y:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y===0?null:(SS(i,y,l),FS(i,_e()),i.callbackNode!=null&&i.callbackNode===p?zS.bind(null,i):null)}function HS(i,l){if(Md())return null;SS(i,l,!0)}function NR(){FR(function(){(Vt&6)!==0?ot(ce,ER):$S()})}function og(){if(Hi===0){var i=Ao;i===0&&(i=tt,tt<<=1,(tt&261888)===0&&(tt=256)),Hi=i}return Hi}function US(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Wu(""+i)}function VS(i,l){var p=l.ownerDocument.createElement("input");return p.name=l.name,p.value=l.value,i.id&&p.setAttribute("form",i.id),l.parentNode.insertBefore(p,l),i=new FormData(i),p.parentNode.removeChild(p),i}function TR(i,l,p,y,T){if(l==="submit"&&p&&p.stateNode===T){var R=US((T[Je]||null).action),G=y.submitter;G&&(l=(l=G[Je]||null)?US(l.formAction):G.getAttribute("formAction"),l!==null&&(R=l,G=null));var te=new Yu("action","action",null,y,T);i.push({event:te,listeners:[{instance:null,listener:function(){if(y.defaultPrevented){if(Hi!==0){var oe=G?VS(T,G):new FormData(T);Ep(p,{pending:!0,data:oe,method:T.method,action:R},null,oe)}}else typeof R=="function"&&(te.preventDefault(),oe=G?VS(T,G):new FormData(T),Ep(p,{pending:!0,data:oe,method:T.method,action:R},R,oe))},currentTarget:T}]})}}for(var lg=0;lg<Vm.length;lg++){var cg=Vm[lg],AR=cg.toLowerCase(),LR=cg[0].toUpperCase()+cg.slice(1);as(AR,"on"+LR)}as(__,"onAnimationEnd"),as(S_,"onAnimationIteration"),as(w_,"onAnimationStart"),as("dblclick","onDoubleClick"),as("focusin","onFocus"),as("focusout","onBlur"),as(qL,"onTransitionRun"),as(KL,"onTransitionStart"),as(YL,"onTransitionCancel"),as(C_,"onTransitionEnd"),go("onMouseEnter",["mouseout","mouseover"]),go("onMouseLeave",["mouseout","mouseover"]),go("onPointerEnter",["pointerout","pointerover"]),go("onPointerLeave",["pointerout","pointerover"]),xa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),xa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),xa("onBeforeInput",["compositionend","keypress","textInput","paste"]),xa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),xa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),xa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Cc="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(" "),RR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Cc));function WS(i,l){l=(l&4)!==0;for(var p=0;p<i.length;p++){var y=i[p],T=y.event;y=y.listeners;e:{var R=void 0;if(l)for(var G=y.length-1;0<=G;G--){var te=y[G],oe=te.instance,xe=te.currentTarget;if(te=te.listener,oe!==R&&T.isPropagationStopped())break e;R=te,T.currentTarget=xe;try{R(T)}catch(Ie){Ju(Ie)}T.currentTarget=null,R=oe}else for(G=0;G<y.length;G++){if(te=y[G],oe=te.instance,xe=te.currentTarget,te=te.listener,oe!==R&&T.isPropagationStopped())break e;R=te,T.currentTarget=xe;try{R(T)}catch(Ie){Ju(Ie)}T.currentTarget=null,R=oe}}}}function Tt(i,l){var p=l[bt];p===void 0&&(p=l[bt]=new Set);var y=i+"__bubble";p.has(y)||(GS(l,i,2,!1),p.add(y))}function ug(i,l,p){var y=0;l&&(y|=4),GS(p,i,y,l)}var Bd="_reactListening"+Math.random().toString(36).slice(2);function dg(i){if(!i[Bd]){i[Bd]=!0,$v.forEach(function(p){p!=="selectionchange"&&(RR.has(p)||ug(p,!1,i),ug(p,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[Bd]||(l[Bd]=!0,ug("selectionchange",!1,l))}}function GS(i,l,p,y){switch(_w(l)){case 2:var T=aD;break;case 8:T=oD;break;default:T=jg}p=T.bind(null,l,p,i),T=void 0,!Lm||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(T=!0),y?T!==void 0?i.addEventListener(l,p,{capture:!0,passive:T}):i.addEventListener(l,p,!0):T!==void 0?i.addEventListener(l,p,{passive:T}):i.addEventListener(l,p,!1)}function hg(i,l,p,y,T){var R=y;if((l&1)===0&&(l&2)===0&&y!==null)e:for(;;){if(y===null)return;var G=y.tag;if(G===3||G===4){var te=y.stateNode.containerInfo;if(te===T)break;if(G===4)for(G=y.return;G!==null;){var oe=G.tag;if((oe===3||oe===4)&&G.stateNode.containerInfo===T)return;G=G.return}for(;te!==null;){if(G=Ws(te),G===null)return;if(oe=G.tag,oe===5||oe===6||oe===26||oe===27){y=R=G;continue e}te=te.parentNode}}y=y.return}Qv(function(){var xe=R,Ie=Tm(p),ze=[];e:{var we=k_.get(i);if(we!==void 0){var Ce=Yu,lt=i;switch(i){case"keypress":if(qu(p)===0)break e;case"keydown":case"keyup":Ce=kL;break;case"focusin":lt="focus",Ce=Mm;break;case"focusout":lt="blur",Ce=Mm;break;case"beforeblur":case"afterblur":Ce=Mm;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ce=e_;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ce=fL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ce=NL;break;case __:case S_:case w_:Ce=gL;break;case C_:Ce=AL;break;case"scroll":case"scrollend":Ce=dL;break;case"wheel":Ce=RL;break;case"copy":case"cut":case"paste":Ce=yL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ce=n_;break;case"toggle":case"beforetoggle":Ce=OL}var gt=(l&4)!==0,Jt=!gt&&(i==="scroll"||i==="scrollend"),he=gt?we!==null?we+"Capture":null:we;gt=[];for(var ue=xe,ge;ue!==null;){var Be=ue;if(ge=Be.stateNode,Be=Be.tag,Be!==5&&Be!==26&&Be!==27||ge===null||he===null||(Be=Gl(ue,he),Be!=null&&gt.push(kc(ue,Be,ge))),Jt)break;ue=ue.return}0<gt.length&&(we=new Ce(we,lt,null,p,Ie),ze.push({event:we,listeners:gt}))}}if((l&7)===0){e:{if(we=i==="mouseover"||i==="pointerover",Ce=i==="mouseout"||i==="pointerout",we&&p!==Nm&&(lt=p.relatedTarget||p.fromElement)&&(Ws(lt)||lt[st]))break e;if((Ce||we)&&(we=Ie.window===Ie?Ie:(we=Ie.ownerDocument)?we.defaultView||we.parentWindow:window,Ce?(lt=p.relatedTarget||p.toElement,Ce=xe,lt=lt?Ws(lt):null,lt!==null&&(Jt=o(lt),gt=lt.tag,lt!==Jt||gt!==5&&gt!==27&&gt!==6)&&(lt=null)):(Ce=null,lt=xe),Ce!==lt)){if(gt=e_,Be="onMouseLeave",he="onMouseEnter",ue="mouse",(i==="pointerout"||i==="pointerover")&&(gt=n_,Be="onPointerLeave",he="onPointerEnter",ue="pointer"),Jt=Ce==null?we:Wl(Ce),ge=lt==null?we:Wl(lt),we=new gt(Be,ue+"leave",Ce,p,Ie),we.target=Jt,we.relatedTarget=ge,Be=null,Ws(Ie)===xe&&(gt=new gt(he,ue+"enter",lt,p,Ie),gt.target=ge,gt.relatedTarget=Jt,Be=gt),Jt=Be,Ce&&lt)t:{for(gt=DR,he=Ce,ue=lt,ge=0,Be=he;Be;Be=gt(Be))ge++;Be=0;for(var ht=ue;ht;ht=gt(ht))Be++;for(;0<ge-Be;)he=gt(he),ge--;for(;0<Be-ge;)ue=gt(ue),Be--;for(;ge--;){if(he===ue||ue!==null&&he===ue.alternate){gt=he;break t}he=gt(he),ue=gt(ue)}gt=null}else gt=null;Ce!==null&&qS(ze,we,Ce,gt,!1),lt!==null&&Jt!==null&&qS(ze,Jt,lt,gt,!0)}}e:{if(we=xe?Wl(xe):window,Ce=we.nodeName&&we.nodeName.toLowerCase(),Ce==="select"||Ce==="input"&&we.type==="file")var $t=u_;else if(l_(we))if(d_)$t=VL;else{$t=HL;var ut=zL}else Ce=we.nodeName,!Ce||Ce.toLowerCase()!=="input"||we.type!=="checkbox"&&we.type!=="radio"?xe&&Em(xe.elementType)&&($t=u_):$t=UL;if($t&&($t=$t(i,xe))){c_(ze,$t,p,Ie);break e}ut&&ut(i,we,xe),i==="focusout"&&xe&&we.type==="number"&&xe.memoizedProps.value!=null&&jm(we,"number",we.value)}switch(ut=xe?Wl(xe):window,i){case"focusin":(l_(ut)||ut.contentEditable==="true")&&(So=ut,zm=xe,ec=null);break;case"focusout":ec=zm=So=null;break;case"mousedown":Hm=!0;break;case"contextmenu":case"mouseup":case"dragend":Hm=!1,b_(ze,p,Ie);break;case"selectionchange":if(GL)break;case"keydown":case"keyup":b_(ze,p,Ie)}var kt;if(Pm)e:{switch(i){case"compositionstart":var Dt="onCompositionStart";break e;case"compositionend":Dt="onCompositionEnd";break e;case"compositionupdate":Dt="onCompositionUpdate";break e}Dt=void 0}else _o?a_(i,p)&&(Dt="onCompositionEnd"):i==="keydown"&&p.keyCode===229&&(Dt="onCompositionStart");Dt&&(r_&&p.locale!=="ko"&&(_o||Dt!=="onCompositionStart"?Dt==="onCompositionEnd"&&_o&&(kt=Jv()):(ji=Ie,Rm="value"in ji?ji.value:ji.textContent,_o=!0)),ut=$d(xe,Dt),0<ut.length&&(Dt=new t_(Dt,i,null,p,Ie),ze.push({event:Dt,listeners:ut}),kt?Dt.data=kt:(kt=o_(p),kt!==null&&(Dt.data=kt)))),(kt=IL?PL(i,p):BL(i,p))&&(Dt=$d(xe,"onBeforeInput"),0<Dt.length&&(ut=new t_("onBeforeInput","beforeinput",null,p,Ie),ze.push({event:ut,listeners:Dt}),ut.data=kt)),TR(ze,i,xe,p,Ie)}WS(ze,l)})}function kc(i,l,p){return{instance:i,listener:l,currentTarget:p}}function $d(i,l){for(var p=l+"Capture",y=[];i!==null;){var T=i,R=T.stateNode;if(T=T.tag,T!==5&&T!==26&&T!==27||R===null||(T=Gl(i,p),T!=null&&y.unshift(kc(i,T,R)),T=Gl(i,l),T!=null&&y.push(kc(i,T,R))),i.tag===3)return y;i=i.return}return[]}function DR(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function qS(i,l,p,y,T){for(var R=l._reactName,G=[];p!==null&&p!==y;){var te=p,oe=te.alternate,xe=te.stateNode;if(te=te.tag,oe!==null&&oe===y)break;te!==5&&te!==26&&te!==27||xe===null||(oe=xe,T?(xe=Gl(p,R),xe!=null&&G.unshift(kc(p,xe,oe))):T||(xe=Gl(p,R),xe!=null&&G.push(kc(p,xe,oe)))),p=p.return}G.length!==0&&i.push({event:l,listeners:G})}var OR=/\r\n?/g,MR=/\u0000|\uFFFD/g;function KS(i){return(typeof i=="string"?i:""+i).replace(OR,`
50
+ `).replace(MR,"")}function YS(i,l){return l=KS(l),KS(i)===l}function Qt(i,l,p,y,T,R){switch(p){case"children":typeof y=="string"?l==="body"||l==="textarea"&&y===""||yo(i,y):(typeof y=="number"||typeof y=="bigint")&&l!=="body"&&yo(i,""+y);break;case"className":Uu(i,"class",y);break;case"tabIndex":Uu(i,"tabindex",y);break;case"dir":case"role":case"viewBox":case"width":case"height":Uu(i,p,y);break;case"style":Yv(i,y,R);break;case"data":if(l!=="object"){Uu(i,"data",y);break}case"src":case"href":if(y===""&&(l!=="a"||p!=="href")){i.removeAttribute(p);break}if(y==null||typeof y=="function"||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(p);break}y=Wu(""+y),i.setAttribute(p,y);break;case"action":case"formAction":if(typeof y=="function"){i.setAttribute(p,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof R=="function"&&(p==="formAction"?(l!=="input"&&Qt(i,l,"name",T.name,T,null),Qt(i,l,"formEncType",T.formEncType,T,null),Qt(i,l,"formMethod",T.formMethod,T,null),Qt(i,l,"formTarget",T.formTarget,T,null)):(Qt(i,l,"encType",T.encType,T,null),Qt(i,l,"method",T.method,T,null),Qt(i,l,"target",T.target,T,null)));if(y==null||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(p);break}y=Wu(""+y),i.setAttribute(p,y);break;case"onClick":y!=null&&(i.onclick=qs);break;case"onScroll":y!=null&&Tt("scroll",i);break;case"onScrollEnd":y!=null&&Tt("scrollend",i);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(p=y.__html,p!=null){if(T.children!=null)throw Error(r(60));i.innerHTML=p}}break;case"multiple":i.multiple=y&&typeof y!="function"&&typeof y!="symbol";break;case"muted":i.muted=y&&typeof y!="function"&&typeof y!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(y==null||typeof y=="function"||typeof y=="boolean"||typeof y=="symbol"){i.removeAttribute("xlink:href");break}p=Wu(""+y),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,""+y):i.removeAttribute(p);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":y&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,""):i.removeAttribute(p);break;case"capture":case"download":y===!0?i.setAttribute(p,""):y!==!1&&y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,y):i.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":y!=null&&typeof y!="function"&&typeof y!="symbol"&&!isNaN(y)&&1<=y?i.setAttribute(p,y):i.removeAttribute(p);break;case"rowSpan":case"start":y==null||typeof y=="function"||typeof y=="symbol"||isNaN(y)?i.removeAttribute(p):i.setAttribute(p,y);break;case"popover":Tt("beforetoggle",i),Tt("toggle",i),Hu(i,"popover",y);break;case"xlinkActuate":Gs(i,"http://www.w3.org/1999/xlink","xlink:actuate",y);break;case"xlinkArcrole":Gs(i,"http://www.w3.org/1999/xlink","xlink:arcrole",y);break;case"xlinkRole":Gs(i,"http://www.w3.org/1999/xlink","xlink:role",y);break;case"xlinkShow":Gs(i,"http://www.w3.org/1999/xlink","xlink:show",y);break;case"xlinkTitle":Gs(i,"http://www.w3.org/1999/xlink","xlink:title",y);break;case"xlinkType":Gs(i,"http://www.w3.org/1999/xlink","xlink:type",y);break;case"xmlBase":Gs(i,"http://www.w3.org/XML/1998/namespace","xml:base",y);break;case"xmlLang":Gs(i,"http://www.w3.org/XML/1998/namespace","xml:lang",y);break;case"xmlSpace":Gs(i,"http://www.w3.org/XML/1998/namespace","xml:space",y);break;case"is":Hu(i,"is",y);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=cL.get(p)||p,Hu(i,p,y))}}function fg(i,l,p,y,T,R){switch(p){case"style":Yv(i,y,R);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(p=y.__html,p!=null){if(T.children!=null)throw Error(r(60));i.innerHTML=p}}break;case"children":typeof y=="string"?yo(i,y):(typeof y=="number"||typeof y=="bigint")&&yo(i,""+y);break;case"onScroll":y!=null&&Tt("scroll",i);break;case"onScrollEnd":y!=null&&Tt("scrollend",i);break;case"onClick":y!=null&&(i.onclick=qs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Fv.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(T=p.endsWith("Capture"),l=p.slice(2,T?p.length-7:void 0),R=i[Je]||null,R=R!=null?R[p]:null,typeof R=="function"&&i.removeEventListener(l,R,T),typeof y=="function")){typeof R!="function"&&R!==null&&(p in i?i[p]=null:i.hasAttribute(p)&&i.removeAttribute(p)),i.addEventListener(l,y,T);break e}p in i?i[p]=y:y===!0?i.setAttribute(p,""):Hu(i,p,y)}}}function Qn(i,l,p){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Tt("error",i),Tt("load",i);var y=!1,T=!1,R;for(R in p)if(p.hasOwnProperty(R)){var G=p[R];if(G!=null)switch(R){case"src":y=!0;break;case"srcSet":T=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Qt(i,l,R,G,p,null)}}T&&Qt(i,l,"srcSet",p.srcSet,p,null),y&&Qt(i,l,"src",p.src,p,null);return;case"input":Tt("invalid",i);var te=R=G=T=null,oe=null,xe=null;for(y in p)if(p.hasOwnProperty(y)){var Ie=p[y];if(Ie!=null)switch(y){case"name":T=Ie;break;case"type":G=Ie;break;case"checked":oe=Ie;break;case"defaultChecked":xe=Ie;break;case"value":R=Ie;break;case"defaultValue":te=Ie;break;case"children":case"dangerouslySetInnerHTML":if(Ie!=null)throw Error(r(137,l));break;default:Qt(i,l,y,Ie,p,null)}}Wv(i,R,te,oe,xe,G,T,!1);return;case"select":Tt("invalid",i),y=G=R=null;for(T in p)if(p.hasOwnProperty(T)&&(te=p[T],te!=null))switch(T){case"value":R=te;break;case"defaultValue":G=te;break;case"multiple":y=te;default:Qt(i,l,T,te,p,null)}l=R,p=G,i.multiple=!!y,l!=null?xo(i,!!y,l,!1):p!=null&&xo(i,!!y,p,!0);return;case"textarea":Tt("invalid",i),R=T=y=null;for(G in p)if(p.hasOwnProperty(G)&&(te=p[G],te!=null))switch(G){case"value":y=te;break;case"defaultValue":T=te;break;case"children":R=te;break;case"dangerouslySetInnerHTML":if(te!=null)throw Error(r(91));break;default:Qt(i,l,G,te,p,null)}qv(i,y,T,R);return;case"option":for(oe in p)if(p.hasOwnProperty(oe)&&(y=p[oe],y!=null))switch(oe){case"selected":i.selected=y&&typeof y!="function"&&typeof y!="symbol";break;default:Qt(i,l,oe,y,p,null)}return;case"dialog":Tt("beforetoggle",i),Tt("toggle",i),Tt("cancel",i),Tt("close",i);break;case"iframe":case"object":Tt("load",i);break;case"video":case"audio":for(y=0;y<Cc.length;y++)Tt(Cc[y],i);break;case"image":Tt("error",i),Tt("load",i);break;case"details":Tt("toggle",i);break;case"embed":case"source":case"link":Tt("error",i),Tt("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(xe in p)if(p.hasOwnProperty(xe)&&(y=p[xe],y!=null))switch(xe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Qt(i,l,xe,y,p,null)}return;default:if(Em(l)){for(Ie in p)p.hasOwnProperty(Ie)&&(y=p[Ie],y!==void 0&&fg(i,l,Ie,y,p,void 0));return}}for(te in p)p.hasOwnProperty(te)&&(y=p[te],y!=null&&Qt(i,l,te,y,p,null))}function IR(i,l,p,y){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var T=null,R=null,G=null,te=null,oe=null,xe=null,Ie=null;for(Ce in p){var ze=p[Ce];if(p.hasOwnProperty(Ce)&&ze!=null)switch(Ce){case"checked":break;case"value":break;case"defaultValue":oe=ze;default:y.hasOwnProperty(Ce)||Qt(i,l,Ce,null,y,ze)}}for(var we in y){var Ce=y[we];if(ze=p[we],y.hasOwnProperty(we)&&(Ce!=null||ze!=null))switch(we){case"type":R=Ce;break;case"name":T=Ce;break;case"checked":xe=Ce;break;case"defaultChecked":Ie=Ce;break;case"value":G=Ce;break;case"defaultValue":te=Ce;break;case"children":case"dangerouslySetInnerHTML":if(Ce!=null)throw Error(r(137,l));break;default:Ce!==ze&&Qt(i,l,we,Ce,y,ze)}}km(i,G,te,oe,xe,Ie,R,T);return;case"select":Ce=G=te=we=null;for(R in p)if(oe=p[R],p.hasOwnProperty(R)&&oe!=null)switch(R){case"value":break;case"multiple":Ce=oe;default:y.hasOwnProperty(R)||Qt(i,l,R,null,y,oe)}for(T in y)if(R=y[T],oe=p[T],y.hasOwnProperty(T)&&(R!=null||oe!=null))switch(T){case"value":we=R;break;case"defaultValue":te=R;break;case"multiple":G=R;default:R!==oe&&Qt(i,l,T,R,y,oe)}l=te,p=G,y=Ce,we!=null?xo(i,!!p,we,!1):!!y!=!!p&&(l!=null?xo(i,!!p,l,!0):xo(i,!!p,p?[]:"",!1));return;case"textarea":Ce=we=null;for(te in p)if(T=p[te],p.hasOwnProperty(te)&&T!=null&&!y.hasOwnProperty(te))switch(te){case"value":break;case"children":break;default:Qt(i,l,te,null,y,T)}for(G in y)if(T=y[G],R=p[G],y.hasOwnProperty(G)&&(T!=null||R!=null))switch(G){case"value":we=T;break;case"defaultValue":Ce=T;break;case"children":break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:T!==R&&Qt(i,l,G,T,y,R)}Gv(i,we,Ce);return;case"option":for(var lt in p)if(we=p[lt],p.hasOwnProperty(lt)&&we!=null&&!y.hasOwnProperty(lt))switch(lt){case"selected":i.selected=!1;break;default:Qt(i,l,lt,null,y,we)}for(oe in y)if(we=y[oe],Ce=p[oe],y.hasOwnProperty(oe)&&we!==Ce&&(we!=null||Ce!=null))switch(oe){case"selected":i.selected=we&&typeof we!="function"&&typeof we!="symbol";break;default:Qt(i,l,oe,we,y,Ce)}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 gt in p)we=p[gt],p.hasOwnProperty(gt)&&we!=null&&!y.hasOwnProperty(gt)&&Qt(i,l,gt,null,y,we);for(xe in y)if(we=y[xe],Ce=p[xe],y.hasOwnProperty(xe)&&we!==Ce&&(we!=null||Ce!=null))switch(xe){case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(r(137,l));break;default:Qt(i,l,xe,we,y,Ce)}return;default:if(Em(l)){for(var Jt in p)we=p[Jt],p.hasOwnProperty(Jt)&&we!==void 0&&!y.hasOwnProperty(Jt)&&fg(i,l,Jt,void 0,y,we);for(Ie in y)we=y[Ie],Ce=p[Ie],!y.hasOwnProperty(Ie)||we===Ce||we===void 0&&Ce===void 0||fg(i,l,Ie,we,y,Ce);return}}for(var he in p)we=p[he],p.hasOwnProperty(he)&&we!=null&&!y.hasOwnProperty(he)&&Qt(i,l,he,null,y,we);for(ze in y)we=y[ze],Ce=p[ze],!y.hasOwnProperty(ze)||we===Ce||we==null&&Ce==null||Qt(i,l,ze,we,y,Ce)}function XS(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function PR(){if(typeof performance.getEntriesByType=="function"){for(var i=0,l=0,p=performance.getEntriesByType("resource"),y=0;y<p.length;y++){var T=p[y],R=T.transferSize,G=T.initiatorType,te=T.duration;if(R&&te&&XS(G)){for(G=0,te=T.responseEnd,y+=1;y<p.length;y++){var oe=p[y],xe=oe.startTime;if(xe>te)break;var Ie=oe.transferSize,ze=oe.initiatorType;Ie&&XS(ze)&&(oe=oe.responseEnd,G+=Ie*(oe<te?1:(te-xe)/(oe-xe)))}if(--y,l+=8*(R+G)/(T.duration/1e3),i++,10<i)break}}if(0<i)return l/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var mg=null,pg=null;function Fd(i){return i.nodeType===9?i:i.ownerDocument}function QS(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 JS(i,l){if(i===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&l==="foreignObject"?0:i}function gg(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var xg=null;function BR(){var i=window.event;return i&&i.type==="popstate"?i===xg?!1:(xg=i,!0):(xg=null,!1)}var ZS=typeof setTimeout=="function"?setTimeout:void 0,$R=typeof clearTimeout=="function"?clearTimeout:void 0,ew=typeof Promise=="function"?Promise:void 0,FR=typeof queueMicrotask=="function"?queueMicrotask:typeof ew<"u"?function(i){return ew.resolve(null).then(i).catch(zR)}:ZS;function zR(i){setTimeout(function(){throw i})}function Ui(i){return i==="head"}function tw(i,l){var p=l,y=0;do{var T=p.nextSibling;if(i.removeChild(p),T&&T.nodeType===8)if(p=T.data,p==="/$"||p==="/&"){if(y===0){i.removeChild(T),Yo(l);return}y--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")y++;else if(p==="html")jc(i.ownerDocument.documentElement);else if(p==="head"){p=i.ownerDocument.head,jc(p);for(var R=p.firstChild;R;){var G=R.nextSibling,te=R.nodeName;R[Tn]||te==="SCRIPT"||te==="STYLE"||te==="LINK"&&R.rel.toLowerCase()==="stylesheet"||p.removeChild(R),R=G}}else p==="body"&&jc(i.ownerDocument.body);p=T}while(p);Yo(l)}function nw(i,l){var p=i;i=0;do{var y=p.nextSibling;if(p.nodeType===1?l?(p._stashedDisplay=p.style.display,p.style.display="none"):(p.style.display=p._stashedDisplay||"",p.getAttribute("style")===""&&p.removeAttribute("style")):p.nodeType===3&&(l?(p._stashedText=p.nodeValue,p.nodeValue=""):p.nodeValue=p._stashedText||""),y&&y.nodeType===8)if(p=y.data,p==="/$"){if(i===0)break;i--}else p!=="$"&&p!=="$?"&&p!=="$~"&&p!=="$!"||i++;p=y}while(p)}function yg(i){var l=i.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var p=l;switch(l=l.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":yg(p),fo(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}i.removeChild(p)}}function HR(i,l,p,y){for(;i.nodeType===1;){var T=p;if(i.nodeName.toLowerCase()!==l.toLowerCase()){if(!y&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(y){if(!i[Tn])switch(l){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(R=i.getAttribute("rel"),R==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(R!==T.rel||i.getAttribute("href")!==(T.href==null||T.href===""?null:T.href)||i.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin)||i.getAttribute("title")!==(T.title==null?null:T.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(R=i.getAttribute("src"),(R!==(T.src==null?null:T.src)||i.getAttribute("type")!==(T.type==null?null:T.type)||i.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin))&&R&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(l==="input"&&i.type==="hidden"){var R=T.name==null?null:""+T.name;if(T.type==="hidden"&&i.getAttribute("name")===R)return i}else return i;if(i=Xr(i.nextSibling),i===null)break}return null}function UR(i,l,p){if(l==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!p||(i=Xr(i.nextSibling),i===null))return null;return i}function rw(i,l){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!l||(i=Xr(i.nextSibling),i===null))return null;return i}function bg(i){return i.data==="$?"||i.data==="$~"}function vg(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function VR(i,l){var p=i.ownerDocument;if(i.data==="$~")i._reactRetry=l;else if(i.data!=="$?"||p.readyState!=="loading")l();else{var y=function(){l(),p.removeEventListener("DOMContentLoaded",y)};p.addEventListener("DOMContentLoaded",y),i._reactRetry=y}}function Xr(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return i}var _g=null;function sw(i){i=i.nextSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="/$"||p==="/&"){if(l===0)return Xr(i.nextSibling);l--}else p!=="$"&&p!=="$!"&&p!=="$?"&&p!=="$~"&&p!=="&"||l++}i=i.nextSibling}return null}function iw(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"){if(l===0)return i;l--}else p!=="/$"&&p!=="/&"||l++}i=i.previousSibling}return null}function aw(i,l,p){switch(l=Fd(p),i){case"html":if(i=l.documentElement,!i)throw Error(r(452));return i;case"head":if(i=l.head,!i)throw Error(r(453));return i;case"body":if(i=l.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function jc(i){for(var l=i.attributes;l.length;)i.removeAttributeNode(l[0]);fo(i)}var Qr=new Map,ow=new Set;function zd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var ci=Z.d;Z.d={f:WR,r:GR,D:qR,C:KR,L:YR,m:XR,X:JR,S:QR,M:ZR};function WR(){var i=ci.f(),l=Rd();return i||l}function GR(i){var l=mo(i);l!==null&&l.tag===5&&l.type==="form"?C0(l):ci.r(i)}var Go=typeof document>"u"?null:document;function lw(i,l,p){var y=Go;if(y&&typeof l=="string"&&l){var T=Ur(l);T='link[rel="'+i+'"][href="'+T+'"]',typeof p=="string"&&(T+='[crossorigin="'+p+'"]'),ow.has(T)||(ow.add(T),i={rel:i,crossOrigin:p,href:l},y.querySelector(T)===null&&(l=y.createElement("link"),Qn(l,"link",i),Hn(l),y.head.appendChild(l)))}}function qR(i){ci.D(i),lw("dns-prefetch",i,null)}function KR(i,l){ci.C(i,l),lw("preconnect",i,l)}function YR(i,l,p){ci.L(i,l,p);var y=Go;if(y&&i&&l){var T='link[rel="preload"][as="'+Ur(l)+'"]';l==="image"&&p&&p.imageSrcSet?(T+='[imagesrcset="'+Ur(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(T+='[imagesizes="'+Ur(p.imageSizes)+'"]')):T+='[href="'+Ur(i)+'"]';var R=T;switch(l){case"style":R=qo(i);break;case"script":R=Ko(i)}Qr.has(R)||(i=f({rel:"preload",href:l==="image"&&p&&p.imageSrcSet?void 0:i,as:l},p),Qr.set(R,i),y.querySelector(T)!==null||l==="style"&&y.querySelector(Ec(R))||l==="script"&&y.querySelector(Nc(R))||(l=y.createElement("link"),Qn(l,"link",i),Hn(l),y.head.appendChild(l)))}}function XR(i,l){ci.m(i,l);var p=Go;if(p&&i){var y=l&&typeof l.as=="string"?l.as:"script",T='link[rel="modulepreload"][as="'+Ur(y)+'"][href="'+Ur(i)+'"]',R=T;switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":R=Ko(i)}if(!Qr.has(R)&&(i=f({rel:"modulepreload",href:i},l),Qr.set(R,i),p.querySelector(T)===null)){switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(Nc(R)))return}y=p.createElement("link"),Qn(y,"link",i),Hn(y),p.head.appendChild(y)}}}function QR(i,l,p){ci.S(i,l,p);var y=Go;if(y&&i){var T=po(y).hoistableStyles,R=qo(i);l=l||"default";var G=T.get(R);if(!G){var te={loading:0,preload:null};if(G=y.querySelector(Ec(R)))te.loading=5;else{i=f({rel:"stylesheet",href:i,"data-precedence":l},p),(p=Qr.get(R))&&Sg(i,p);var oe=G=y.createElement("link");Hn(oe),Qn(oe,"link",i),oe._p=new Promise(function(xe,Ie){oe.onload=xe,oe.onerror=Ie}),oe.addEventListener("load",function(){te.loading|=1}),oe.addEventListener("error",function(){te.loading|=2}),te.loading|=4,Hd(G,l,y)}G={type:"stylesheet",instance:G,count:1,state:te},T.set(R,G)}}}function JR(i,l){ci.X(i,l);var p=Go;if(p&&i){var y=po(p).hoistableScripts,T=Ko(i),R=y.get(T);R||(R=p.querySelector(Nc(T)),R||(i=f({src:i,async:!0},l),(l=Qr.get(T))&&wg(i,l),R=p.createElement("script"),Hn(R),Qn(R,"link",i),p.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},y.set(T,R))}}function ZR(i,l){ci.M(i,l);var p=Go;if(p&&i){var y=po(p).hoistableScripts,T=Ko(i),R=y.get(T);R||(R=p.querySelector(Nc(T)),R||(i=f({src:i,async:!0,type:"module"},l),(l=Qr.get(T))&&wg(i,l),R=p.createElement("script"),Hn(R),Qn(R,"link",i),p.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},y.set(T,R))}}function cw(i,l,p,y){var T=(T=X.current)?zd(T):null;if(!T)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(l=qo(p.href),p=po(T).hoistableStyles,y=p.get(l),y||(y={type:"style",instance:null,count:0,state:null},p.set(l,y)),y):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){i=qo(p.href);var R=po(T).hoistableStyles,G=R.get(i);if(G||(T=T.ownerDocument||T,G={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},R.set(i,G),(R=T.querySelector(Ec(i)))&&!R._p&&(G.instance=R,G.state.loading=5),Qr.has(i)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Qr.set(i,p),R||eD(T,i,p,G.state))),l&&y===null)throw Error(r(528,""));return G}if(l&&y!==null)throw Error(r(529,""));return null;case"script":return l=p.async,p=p.src,typeof p=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=Ko(p),p=po(T).hoistableScripts,y=p.get(l),y||(y={type:"script",instance:null,count:0,state:null},p.set(l,y)),y):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function qo(i){return'href="'+Ur(i)+'"'}function Ec(i){return'link[rel="stylesheet"]['+i+"]"}function uw(i){return f({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,p,y){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?y.loading=1:(l=i.createElement("link"),y.preload=l,l.addEventListener("load",function(){return y.loading|=1}),l.addEventListener("error",function(){return y.loading|=2}),Qn(l,"link",p),Hn(l),i.head.appendChild(l))}function Ko(i){return'[src="'+Ur(i)+'"]'}function Nc(i){return"script[async]"+i}function dw(i,l,p){if(l.count++,l.instance===null)switch(l.type){case"style":var y=i.querySelector('style[data-href~="'+Ur(p.href)+'"]');if(y)return l.instance=y,Hn(y),y;var T=f({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return y=(i.ownerDocument||i).createElement("style"),Hn(y),Qn(y,"style",T),Hd(y,p.precedence,i),l.instance=y;case"stylesheet":T=qo(p.href);var R=i.querySelector(Ec(T));if(R)return l.state.loading|=4,l.instance=R,Hn(R),R;y=uw(p),(T=Qr.get(T))&&Sg(y,T),R=(i.ownerDocument||i).createElement("link"),Hn(R);var G=R;return G._p=new Promise(function(te,oe){G.onload=te,G.onerror=oe}),Qn(R,"link",y),l.state.loading|=4,Hd(R,p.precedence,i),l.instance=R;case"script":return R=Ko(p.src),(T=i.querySelector(Nc(R)))?(l.instance=T,Hn(T),T):(y=p,(T=Qr.get(R))&&(y=f({},p),wg(y,T)),i=i.ownerDocument||i,T=i.createElement("script"),Hn(T),Qn(T,"link",y),i.head.appendChild(T),l.instance=T);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(y=l.instance,l.state.loading|=4,Hd(y,p.precedence,i));return l.instance}function Hd(i,l,p){for(var y=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),T=y.length?y[y.length-1]:null,R=T,G=0;G<y.length;G++){var te=y[G];if(te.dataset.precedence===l)R=te;else if(R!==T)break}R?R.parentNode.insertBefore(i,R.nextSibling):(l=p.nodeType===9?p.head:p,l.insertBefore(i,l.firstChild))}function Sg(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.title==null&&(i.title=l.title)}function wg(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.integrity==null&&(i.integrity=l.integrity)}var Ud=null;function hw(i,l,p){if(Ud===null){var y=new Map,T=Ud=new Map;T.set(p,y)}else T=Ud,y=T.get(p),y||(y=new Map,T.set(p,y));if(y.has(i))return y;for(y.set(i,null),p=p.getElementsByTagName(i),T=0;T<p.length;T++){var R=p[T];if(!(R[Tn]||R[Fe]||i==="link"&&R.getAttribute("rel")==="stylesheet")&&R.namespaceURI!=="http://www.w3.org/2000/svg"){var G=R.getAttribute(l)||"";G=i+G;var te=y.get(G);te?te.push(R):y.set(G,[R])}}return y}function fw(i,l,p){i=i.ownerDocument||i,i.head.insertBefore(p,l==="title"?i.querySelector("head > title"):null)}function tD(i,l,p){if(p===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return i=l.disabled,typeof l.precedence=="string"&&i==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function mw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,p,y){if(p.type==="stylesheet"&&(typeof y.media!="string"||matchMedia(y.media).matches!==!1)&&(p.state.loading&4)===0){if(p.instance===null){var T=qo(y.href),R=l.querySelector(Ec(T));if(R){l=R._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=Vd.bind(i),l.then(i,i)),p.state.loading|=4,p.instance=R,Hn(R);return}R=l.ownerDocument||l,y=uw(y),(T=Qr.get(T))&&Sg(y,T),R=R.createElement("link"),Hn(R);var G=R;G._p=new Promise(function(te,oe){G.onload=te,G.onerror=oe}),Qn(R,"link",y),p.instance=R}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(p,l),(l=p.state.preload)&&(p.state.loading&3)===0&&(i.count++,p=Vd.bind(i),l.addEventListener("load",p),l.addEventListener("error",p))}}var Cg=0;function rD(i,l){return i.stylesheets&&i.count===0&&Gd(i,i.stylesheets),0<i.count||0<i.imgCount?function(p){var y=setTimeout(function(){if(i.stylesheets&&Gd(i,i.stylesheets),i.unsuspend){var R=i.unsuspend;i.unsuspend=null,R()}},6e4+l);0<i.imgBytes&&Cg===0&&(Cg=62500*PR());var T=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Gd(i,i.stylesheets),i.unsuspend)){var R=i.unsuspend;i.unsuspend=null,R()}},(i.imgBytes>Cg?50:800)+l);return i.unsuspend=p,function(){i.unsuspend=null,clearTimeout(y),clearTimeout(T)}}:null}function Vd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Gd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Wd=null;function Gd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Wd=new Map,l.forEach(sD,i),Wd=null,Vd.call(i))}function sD(i,l){if(!(l.state.loading&4)){var p=Wd.get(i);if(p)var y=p.get(null);else{p=new Map,Wd.set(i,p);for(var T=i.querySelectorAll("link[data-precedence],style[data-precedence]"),R=0;R<T.length;R++){var G=T[R];(G.nodeName==="LINK"||G.getAttribute("media")!=="not all")&&(p.set(G.dataset.precedence,G),y=G)}y&&p.set(null,y)}T=l.instance,G=T.getAttribute("data-precedence"),R=p.get(G)||y,R===y&&p.set(null,T),p.set(G,T),this.count++,y=Vd.bind(this),T.addEventListener("load",y),T.addEventListener("error",y),R?R.parentNode.insertBefore(T,R.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(T,i.firstChild)),l.state.loading|=4}}var Tc={$$typeof:b,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function iD(i,l,p,y,T,R,G,te,oe){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=hr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hr(0),this.hiddenUpdates=hr(null),this.identifierPrefix=y,this.onUncaughtError=T,this.onCaughtError=R,this.onRecoverableError=G,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=oe,this.incompleteTransitions=new Map}function pw(i,l,p,y,T,R,G,te,oe,xe,Ie,ze){return i=new iD(i,l,p,G,oe,xe,Ie,ze,te),l=1,R===!0&&(l|=24),R=Nr(3,null,null,l),i.current=R,R.stateNode=i,l=rp(),l.refCount++,i.pooledCache=l,l.refCount++,R.memoizedState={element:y,isDehydrated:p,cache:l},op(R),i}function gw(i){return i?(i=ko,i):ko}function xw(i,l,p,y,T,R){T=gw(T),y.context===null?y.context=T:y.pendingContext=T,y=Ri(l),y.payload={element:p},R=R===void 0?null:R,R!==null&&(y.callback=R),p=Di(i,y,l),p!==null&&(yr(p,i,l),oc(p,i,l))}function yw(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var p=i.retryLane;i.retryLane=p!==0&&p<l?p:l}}function kg(i,l){yw(i,l),(i=i.alternate)&&yw(i,l)}function bw(i){if(i.tag===13||i.tag===31){var l=_a(i,67108864);l!==null&&yr(l,i,67108864),kg(i,67108864)}}function vw(i){if(i.tag===13||i.tag===31){var l=Dr();l=Ke(l);var p=_a(i,l);p!==null&&yr(p,i,l),kg(i,l)}}var qd=!0;function aD(i,l,p,y){var T=W.T;W.T=null;var R=Z.p;try{Z.p=2,jg(i,l,p,y)}finally{Z.p=R,W.T=T}}function oD(i,l,p,y){var T=W.T;W.T=null;var R=Z.p;try{Z.p=8,jg(i,l,p,y)}finally{Z.p=R,W.T=T}}function jg(i,l,p,y){if(qd){var T=Eg(y);if(T===null)hg(i,l,y,Kd,p),Sw(i,y);else if(cD(T,i,l,p,y))y.stopPropagation();else if(Sw(i,y),l&4&&-1<lD.indexOf(i)){for(;T!==null;){var R=mo(T);if(R!==null)switch(R.tag){case 3:if(R=R.stateNode,R.current.memoizedState.isDehydrated){var G=Lt(R.pendingLanes);if(G!==0){var te=R;for(te.pendingLanes|=2,te.entangledLanes|=2;G;){var oe=1<<31-Re(G);te.entanglements[1]|=oe,G&=~oe}Ns(R),(Vt&6)===0&&(Ad=_e()+500,wc(0))}}break;case 31:case 13:te=_a(R,2),te!==null&&yr(te,R,2),Rd(),kg(R,2)}if(R=Eg(y),R===null&&hg(i,l,y,Kd,p),R===T)break;T=R}T!==null&&y.stopPropagation()}else hg(i,l,y,null,p)}}function Eg(i){return i=Tm(i),Ng(i)}var Kd=null;function Ng(i){if(Kd=null,i=Ws(i),i!==null){var l=o(i);if(l===null)i=null;else{var p=l.tag;if(p===13){if(i=d(l),i!==null)return i;i=null}else if(p===31){if(i=u(l),i!==null)return i;i=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null)}}return Kd=i,null}function _w(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(Me()){case ce:return 2;case Ne:return 8;case Xe:case at:return 32;case fe:return 268435456;default:return 32}default:return 32}}var Tg=!1,Vi=null,Wi=null,Gi=null,Ac=new Map,Lc=new Map,qi=[],lD="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 Sw(i,l){switch(i){case"focusin":case"focusout":Vi=null;break;case"dragenter":case"dragleave":Wi=null;break;case"mouseover":case"mouseout":Gi=null;break;case"pointerover":case"pointerout":Ac.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Lc.delete(l.pointerId)}}function Rc(i,l,p,y,T,R){return i===null||i.nativeEvent!==R?(i={blockedOn:l,domEventName:p,eventSystemFlags:y,nativeEvent:R,targetContainers:[T]},l!==null&&(l=mo(l),l!==null&&bw(l)),i):(i.eventSystemFlags|=y,l=i.targetContainers,T!==null&&l.indexOf(T)===-1&&l.push(T),i)}function cD(i,l,p,y,T){switch(l){case"focusin":return Vi=Rc(Vi,i,l,p,y,T),!0;case"dragenter":return Wi=Rc(Wi,i,l,p,y,T),!0;case"mouseover":return Gi=Rc(Gi,i,l,p,y,T),!0;case"pointerover":var R=T.pointerId;return Ac.set(R,Rc(Ac.get(R)||null,i,l,p,y,T)),!0;case"gotpointercapture":return R=T.pointerId,Lc.set(R,Rc(Lc.get(R)||null,i,l,p,y,T)),!0}return!1}function ww(i){var l=Ws(i.target);if(l!==null){var p=o(l);if(p!==null){if(l=p.tag,l===13){if(l=d(p),l!==null){i.blockedOn=l,ke(i.priority,function(){vw(p)});return}}else if(l===31){if(l=u(p),l!==null){i.blockedOn=l,ke(i.priority,function(){vw(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){i.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Yd(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var p=Eg(i.nativeEvent);if(p===null){p=i.nativeEvent;var y=new p.constructor(p.type,p);Nm=y,p.target.dispatchEvent(y),Nm=null}else return l=mo(p),l!==null&&bw(l),i.blockedOn=p,!1;l.shift()}return!0}function Cw(i,l,p){Yd(i)&&p.delete(l)}function uD(){Tg=!1,Vi!==null&&Yd(Vi)&&(Vi=null),Wi!==null&&Yd(Wi)&&(Wi=null),Gi!==null&&Yd(Gi)&&(Gi=null),Ac.forEach(Cw),Lc.forEach(Cw)}function Xd(i,l){i.blockedOn===l&&(i.blockedOn=null,Tg||(Tg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,uD)))}var Qd=null;function kw(i){Qd!==i&&(Qd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Qd===i&&(Qd=null);for(var l=0;l<i.length;l+=3){var p=i[l],y=i[l+1],T=i[l+2];if(typeof y!="function"){if(Ng(y||p)===null)continue;break}var R=mo(p);R!==null&&(i.splice(l,3),l-=3,Ep(R,{pending:!0,data:T,method:p.method,action:y},y,T))}}))}function Yo(i){function l(oe){return Xd(oe,i)}Vi!==null&&Xd(Vi,i),Wi!==null&&Xd(Wi,i),Gi!==null&&Xd(Gi,i),Ac.forEach(l),Lc.forEach(l);for(var p=0;p<qi.length;p++){var y=qi[p];y.blockedOn===i&&(y.blockedOn=null)}for(;0<qi.length&&(p=qi[0],p.blockedOn===null);)ww(p),p.blockedOn===null&&qi.shift();if(p=(i.ownerDocument||i).$$reactFormReplay,p!=null)for(y=0;y<p.length;y+=3){var T=p[y],R=p[y+1],G=T[Je]||null;if(typeof R=="function")G||kw(p);else if(G){var te=null;if(R&&R.hasAttribute("formAction")){if(T=R,G=R[Je]||null)te=G.formAction;else if(Ng(T)!==null)continue}else te=G.action;typeof te=="function"?p[y+1]=te:(p.splice(y,3),y-=3),kw(p)}}}function jw(){function i(R){R.canIntercept&&R.info==="react-transition"&&R.intercept({handler:function(){return new Promise(function(G){return T=G})},focusReset:"manual",scroll:"manual"})}function l(){T!==null&&(T(),T=null),y||setTimeout(p,20)}function p(){if(!y&&!navigation.transition){var R=navigation.currentEntry;R&&R.url!=null&&navigation.navigate(R.url,{state:R.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var y=!1,T=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(p,100),function(){y=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),T!==null&&(T(),T=null)}}}function Ag(i){this._internalRoot=i}Jd.prototype.render=Ag.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(r(409));var p=l.current,y=Dr();xw(p,y,i,l,null,null)},Jd.prototype.unmount=Ag.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;xw(i.current,2,null,i,null,null),Rd(),l[st]=null}};function Jd(i){this._internalRoot=i}Jd.prototype.unstable_scheduleHydration=function(i){if(i){var l=Mt();i={blockedOn:null,target:i,priority:l};for(var p=0;p<qi.length&&l!==0&&l<qi[p].priority;p++);qi.splice(p,0,i),p===0&&ww(i)}};var Ew=t.version;if(Ew!=="19.2.8")throw Error(r(527,Ew,"19.2.8"));Z.findDOMNode=function(i){var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=h(l),i=i!==null?m(i):null,i=i===null?null:i.stateNode,i};var dD={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:W,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Zd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Zd.isDisabled&&Zd.supportsFiber)try{it=Zd.inject(dD),nt=Zd}catch{}}return Oc.createRoot=function(i,l){if(!a(i))throw Error(r(299));var p=!1,y="",T=O0,R=M0,G=I0;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(y=l.identifierPrefix),l.onUncaughtError!==void 0&&(T=l.onUncaughtError),l.onCaughtError!==void 0&&(R=l.onCaughtError),l.onRecoverableError!==void 0&&(G=l.onRecoverableError)),l=pw(i,1,!1,null,null,p,y,null,T,R,G,jw),i[st]=l.current,dg(i),new Ag(l)},Oc.hydrateRoot=function(i,l,p){if(!a(i))throw Error(r(299));var y=!1,T="",R=O0,G=M0,te=I0,oe=null;return p!=null&&(p.unstable_strictMode===!0&&(y=!0),p.identifierPrefix!==void 0&&(T=p.identifierPrefix),p.onUncaughtError!==void 0&&(R=p.onUncaughtError),p.onCaughtError!==void 0&&(G=p.onCaughtError),p.onRecoverableError!==void 0&&(te=p.onRecoverableError),p.formState!==void 0&&(oe=p.formState)),l=pw(i,1,!0,l,p??null,y,T,oe,R,G,te,jw),l.context=gw(null),p=l.current,y=Dr(),y=Ke(y),T=Ri(y),T.callback=null,Di(p,T,y),p=y,l.current.lanes=p,be(l,p),Ns(l),i[st]=l.current,dg(i),new Jd(l)},Oc.version="19.2.8",Oc}var $w;function jD(){if($w)return Mg.exports;$w=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(),Mg.exports=kD(),Mg.exports}var ED=jD();const ND=Lf(ED);function TD(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,o,d=[],u="",c=e.split("/");for(c[0]||c.shift();a=c.shift();)n=a[0],n==="*"?(d.push(n),u+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=a.indexOf("?",1),o=a.indexOf(".",1),d.push(a.substring(1,~r?r:~o?o:a.length)),u+=~r&&!~o?"(?:/([^/]+?))?":"/([^/]+?)",~o&&(u+=(~r?"?":"")+"\\"+a.substring(o))):u+="/"+a;return{keys:d,pattern:new RegExp("^"+u+(t?"(?=$|/)":"/?$"),"i")}}var $g={exports:{}},Fg={};/**
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 Fw;function AD(){if(Fw)return Fg;Fw=1;var e=Rf();function t(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,o=e.useLayoutEffect,d=e.useDebugValue;function u(f,g){var x=g(),w=r({inst:{value:x,getSnapshot:g}}),C=w[0].inst,v=w[1];return o(function(){C.value=x,C.getSnapshot=g,c(C)&&v({inst:C})},[f,x,g]),a(function(){return c(C)&&v({inst:C}),f(function(){c(C)&&v({inst:C})})},[f]),d(x),x}function c(f){var g=f.getSnapshot;f=f.value;try{var x=g();return!n(f,x)}catch{return!0}}function h(f,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return Fg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Fg}var zw;function LD(){return zw||(zw=1,$g.exports=AD()),$g.exports}var RD=LD();const DD=_D.useInsertionEffect,OD=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",MD=OD?k.useLayoutEffect:k.useEffect,ID=DD||MD,vj=e=>{const t=k.useRef([e,(...n)=>t[0](...n)]).current;return ID(()=>{t[0]=e}),t[1]},PD="popstate",eb="pushState",tb="replaceState",BD="hashchange",Hw=[PD,eb,tb,BD],$D=e=>{for(const t of Hw)addEventListener(t,e);return()=>{for(const t of Hw)removeEventListener(t,e)}},_j=(e,t)=>RD.useSyncExternalStore($D,e,t),Uw=()=>location.search,FD=({ssrSearch:e}={})=>_j(Uw,e!=null?()=>e:Uw),Vw=()=>location.pathname,zD=({ssrPath:e}={})=>_j(Vw,e!=null?()=>e:Vw),HD=(e,{replace:t=!1,state:n=null}={})=>history[t?tb:eb](n,"",e),UD=(e={})=>[zD(e),HD],Ww=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[Ww]>"u"){for(const e of[eb,tb]){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,Ww,{value:!0})}const VD=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",Sj=(e="")=>e==="/"?"":e,WD=(e,t)=>e[0]==="~"?e.slice(1):Sj(t)+e,GD=(e="",t)=>VD(Gw(Sj(e)),Gw(t)),Gw=e=>{try{return decodeURI(e)}catch{return e}},wj={hook:UD,searchHook:FD,parser:TD,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},Cj=k.createContext(wj),Dl=()=>k.useContext(Cj),kj={},jj=k.createContext(kj),qD=()=>k.useContext(jj),Df=e=>{const[t,n]=e.hook(e);return[GD(e.base,t),vj((r,a)=>e.aroundNav(n,WD(r,e.base),a))]},Fn=()=>Df(Dl()),nb=(e,t,n,r)=>{const{pattern:a,keys:o}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),d=a.exec(n)||[],[u,...c]=d;return u!==void 0?[!0,(()=>{const h=o!==!1?Object.fromEntries(o.map((f,g)=>[f,c[g]])):d.groups;let m={...c};return h&&Object.assign(m,h),m})(),...r?[u]:[]]:[!1,null]},Ol=e=>nb(Dl().parser,e,Fn()[0]),Ej=({children:e,...t})=>{var m,f,g;const n=Dl(),r=t.hook?wj:n;let a=r;const[o,d=t.ssrSearch??""]=((m=t.ssrPath)==null?void 0:m.split("?"))??[];o&&(t.ssrSearch=d,t.ssrPath=o),t.hrefs=t.hrefs??((f=t.hook)==null?void 0:f.hrefs),t.searchHook=t.searchHook??((g=t.hook)==null?void 0:g.searchHook);let u=k.useRef({}),c=u.current,h=c;for(let x in r){const w=x==="base"?r[x]+(t[x]??""):t[x]??r[x];c===h&&w!==h[x]&&(u.current=h={...h}),h[x]=w,(w!==r[x]||w!==a[x])&&(a=h)}return k.createElement(Cj.Provider,{value:a,children:e})},qw=({children:e,component:t},n)=>t?k.createElement(t,{params:n}):typeof e=="function"?e(n):e,KD=e=>{let t=k.useRef(kj);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,a])=>a!==n[r])?e:n},Xo=({path:e,nest:t,match:n,...r})=>{const a=Dl(),[o]=Df(a),[d,u,c]=n??nb(a.parser,e,o,t),h=KD({...qD(),...u});if(!d)return null;const m=c?k.createElement(Ej,{base:c},qw(r,h)):qw(r,h);return k.createElement(jj.Provider,{value:h,children:m})},er=k.forwardRef((e,t)=>{const n=Dl(),[r,a]=Df(n),{to:o="",href:d=o,onClick:u,asChild:c,children:h,className:m,replace:f,state:g,transition:x,...w}=e,C=vj(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(u==null||u(S),S.defaultPrevented||(S.preventDefault(),a(d,e)))}),v=n.hrefs(d[0]==="~"?d.slice(1):n.base+d,n);return c&&k.isValidElement(h)?k.cloneElement(h,{onClick:C,href:v}):k.createElement("a",{...w,onClick:C,href:v,className:m!=null&&m.call?m(r===d):m,children:h,ref:t})}),Nj=e=>Array.isArray(e)?e.flatMap(t=>Nj(t&&t.type===k.Fragment?t.props.children:t)):[e],YD=({children:e,location:t})=>{const n=Dl(),[r]=Df(n);for(const a of Nj(e)){let o=0;if(k.isValidElement(a)&&(o=nb(n.parser,a.props.path,t||r,a.props.nest))[0])return k.cloneElement(a,{match:o})}return null};/*!
59
+ * OverlayScrollbars
60
+ * Version: 2.16.0
61
+ *
62
+ * Copyright (c) Rene Haas | KingSora.
63
+ * https://github.com/KingSora
64
+ *
65
+ * Released under the MIT license.
66
+ */const Ir=(e,t)=>{const{o:n,i:r,u:a}=e;let o=n,d;const u=(m,f)=>{const g=o,x=m,w=f||(r?!r(g,x):g!==x);return(w||a)&&(o=x,d=g),[o,w,d]};return[t?m=>u(t(o,d),m):u,m=>[o,!!m,d]]},XD=typeof window<"u"&&typeof HTMLElement<"u"&&!!window.document,Sr=XD?window:{},Tj=Math.max,QD=Math.min,Xx=Math.round,sa=Math.abs,Kw=Math.sign,Aj=Sr.cancelAnimationFrame,rb=Sr.requestAnimationFrame,sb=Sr.setTimeout,Lj=Sr.clearTimeout,Of=e=>typeof Sr[e]<"u"?Sr[e]:void 0,JD=Of("MutationObserver"),Yw=Of("IntersectionObserver"),hl=Of("ResizeObserver"),Jc=Of("ScrollTimeline"),ib=e=>e===void 0,Mf=e=>e===null,la=e=>typeof e=="number",Ml=e=>typeof e=="string",If=e=>typeof e=="boolean",Ss=e=>typeof e=="function",is=e=>Array.isArray(e),Kh=e=>typeof e=="object"&&!is(e)&&!Mf(e),ab=e=>{const t=!!e&&e.length,n=la(t)&&t>-1&&t%1==0;return is(e)||!Ss(e)&&n?t>0&&Kh(e)?t-1 in e:!0:!1},cu=e=>!!e&&e.constructor===Object,Yh=e=>e instanceof HTMLElement,Pf=e=>e instanceof Element;function tn(e,t){if(ab(e))for(let n=0;n<e.length&&t(e[n],n,e)!==!1;n++);else e&&tn(Object.keys(e),(n=>t(e[n],n,e)));return e}const Rj=(e,t)=>e.indexOf(t)>=0,wl=(e,t)=>e.concat(t),bn=(e,t,n)=>(!Ml(t)&&ab(t)?Array.prototype.push.apply(e,t):e.push(t),e),fa=e=>Array.from(e||[]),ob=e=>is(e)?e:!Ml(e)&&ab(e)?fa(e):[e],Xh=e=>!!e&&!e.length,Qh=e=>fa(new Set(e)),Br=(e,t,n)=>{tn(e,a=>a?a.apply(void 0,t||[]):!0),n||(e.length=0)},Dj="paddingTop",Oj="paddingRight",Mj="paddingLeft",Ij="paddingBottom",Pj="marginLeft",Bj="marginRight",$j="marginBottom",lb="overflowX",cb="overflowY",Bf="width",$f="height",xi="visible",hs="hidden",Ja="scroll",ZD=e=>{const t=String(e||"");return t?t[0].toUpperCase()+t.slice(1):""},Ff=(e,t,n,r)=>{if(e&&t){let a=!0;return tn(n,(o=>{const d=e[o],u=t[o];d!==u&&(a=!1)})),a}return!1},Fj=(e,t)=>Ff(e,t,["w","h"]),Ih=(e,t)=>Ff(e,t,["x","y"]),e5=(e,t)=>Ff(e,t,["t","r","b","l"]),yt=(e,...t)=>e.bind(0,...t),fl=e=>{let t;const n=e?sb:rb,r=e?Lj:Aj;return[a=>{r(t),t=n((()=>a()),Ss(e)?e():e)},()=>r(t)]},Xw=e=>{const t=Ss(e)?e():e;if(la(t)){const n=t?sb:rb,r=t?Lj:Aj;return a=>{const o=n((()=>a()),t);return()=>{r(o)}}}return t&&t._},zj=(e,t)=>{const{p:n,v:r,S:a,m:o}=t||{};let d,u,c,h;const m=function(C){u&&u(),d&&d(),h=u=d=c=void 0,e.apply(this,C)},f=w=>o&&c?o(c,w):w,g=()=>{u&&c&&m(f(c)||c)},x=function(){const C=fa(arguments),v=Xw(n);if(v){const S=typeof a=="function"?a():a,_=Xw(r),j=f(C)||C,E=m.bind(0,j);u&&u(),S&&!h?(E(),h=!0,u=v((()=>h=void 0))):(u=v(E),_&&!d&&(d=_(g))),c=j}else m(C)};return x.O=g,x},Hj=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),vr=e=>e?Object.keys(e):[],Ut=(e,t,n,r,a,o,d)=>{const u=[t,n,r,a,o,d];return(typeof e!="object"||Mf(e))&&!Ss(e)&&(e={}),tn(u,(c=>{tn(c,((h,m)=>{const f=c[m];if(e===f)return!0;const g=is(f);if(f&&cu(f)){const x=e[m];let w=x;g&&!is(x)?w=[]:!g&&!cu(x)&&(w={}),e[m]=Ut(w,f)}else e[m]=g?f.slice():f}))})),e},Uj=(e,t)=>tn(Ut({},e),((n,r,a)=>{n===void 0?delete a[r]:n&&cu(n)&&(a[r]=Uj(n))})),ub=e=>!vr(e).length,uu=()=>{},Vj=(e,t,n)=>Tj(e,QD(t,n)),Za=e=>Qh((is(e)?e:(e||"").split(" ")).filter((t=>t))),db=(e,t)=>e&&e.getAttribute(t),Qw=(e,t)=>e&&e.hasAttribute(t),mi=(e,t,n)=>{tn(Za(t),(r=>{e&&e.setAttribute(r,String(n||""))}))},Ls=(e,t)=>{tn(Za(t),(n=>e&&e.removeAttribute(n)))},zf=(e,t)=>{const n=Za(db(e,t)),r=yt(mi,e,t),a=(o,d)=>{const u=new Set(n);return tn(Za(o),(c=>{u[d](c)})),fa(u).join(" ")};return{C:o=>r(a(o,"delete")),$:o=>r(a(o,"add")),H:o=>{const d=Za(o);return d.reduce(((u,c)=>u&&n.includes(c)),d.length>0)}}},Wj=(e,t,n)=>(zf(e,t).C(n),yt(hb,e,t,n)),hb=(e,t,n)=>(zf(e,t).$(n),yt(Wj,e,t,n)),Jh=(e,t,n,r)=>(r?hb:Wj)(e,t,n),fb=(e,t,n)=>zf(e,t).H(n),Gj=e=>zf(e,"class"),qj=(e,t)=>{Gj(e).C(t)},mb=(e,t)=>(Gj(e).$(t),yt(qj,e,t)),Kj=(e,t)=>{const n=t?Pf(t)&&t:document;return n?fa(n.querySelectorAll(e)):[]},t5=(e,t)=>{const n=t?Pf(t)&&t:document;return n&&n.querySelector(e)},Qx=(e,t)=>Pf(e)&&e.matches(t),Yj=e=>Qx(e,"body"),Jx=e=>e?fa(e.childNodes):[],du=e=>e&&e.parentElement,ml=(e,t)=>Pf(e)&&e.closest(t),Zx=e=>document.activeElement,n5=(e,t,n)=>{const r=ml(e,t),a=e&&t5(n,r),o=ml(a,t)===r;return r&&a?r===e||a===e||o&&ml(ml(e,n),t)!==r:!1},Cl=e=>{tn(ob(e),(t=>{const n=du(t);t&&n&&n.removeChild(t)}))},_r=(e,t)=>yt(Cl,e&&t&&tn(ob(t),(n=>{n&&e.appendChild(n)})));let Xj;const r5=()=>Xj,s5=e=>{Xj=e},xl=e=>{const t=document.createElement("div");return mi(t,"class",e),t},Qj=e=>{const t=xl(),n=r5(),r=e.trim();return t.innerHTML=n?n.createHTML(r):r,tn(Jx(t),(a=>Cl(a)))},Jw=(e,t)=>e.getPropertyValue(t)||e[t]||"",Jj=e=>{const t=e||0;return isFinite(t)?t:0},eh=e=>Jj(parseFloat(e||"")),ey=e=>Math.round(e*1e4)/1e4,Zj=e=>`${ey(Jj(e))}px`;function hu(e,t){e&&t&&tn(t,((n,r)=>{try{const a=e.style,o=Mf(n)||If(n)?"":la(n)?Zj(n):n;r.indexOf("--")===0?a.setProperty(r,o):a[r]=o}catch{}}))}function $s(e,t,n){const r=Ml(t);let a=r?"":{};if(e){const o=Sr.getComputedStyle(e,n)||e.style;a=r?Jw(o,t):fa(t).reduce(((d,u)=>(d[u]=Jw(o,u),d)),a)}return a}const Zw=(e,t,n)=>{const r=t?`${t}-`:"",a=n?`-${n}`:"",o=`${r}top${a}`,d=`${r}right${a}`,u=`${r}bottom${a}`,c=`${r}left${a}`,h=$s(e,[o,d,u,c]);return{t:eh(h[o]),r:eh(h[d]),b:eh(h[u]),l:eh(h[c])}},zg=(e,t)=>`translate${Kh(e)?`(${e.x},${e.y})`:`${t?"X":"Y"}(${e})`}`,i5=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length),a5={w:0,h:0},Hf=(e,t)=>t?{w:t[`${e}Width`],h:t[`${e}Height`]}:a5,o5=e=>Hf("inner",e||Sr),yl=yt(Hf,"offset"),eE=yt(Hf,"client"),Zh=yt(Hf,"scroll"),pb=e=>{const t=parseFloat($s(e,Bf))||0,n=parseFloat($s(e,$f))||0;return{w:t-Xx(t),h:n-Xx(n)}},Hg=e=>e.getBoundingClientRect(),l5=e=>!!e&&i5(e),ty=e=>!!(e&&(e[$f]||e[Bf])),tE=(e,t)=>{const n=ty(e);return!ty(t)&&n},e1=(e,t,n,r)=>{tn(Za(t),(a=>{e&&e.removeEventListener(a,n,r)}))},fn=(e,t,n,r)=>{var a;const o=(a=r&&r.D)!=null?a:!0,d=r&&r.I||!1,u=r&&r.A||!1,c={passive:o,capture:d};return yt(Br,Za(t).map((h=>{const m=u?f=>{e1(e,h,m,d),n&&n(f)}:n;return e&&e.addEventListener(h,m,c),yt(e1,e,h,m,d)})))},nE=e=>e.stopPropagation(),ny=e=>e.preventDefault(),rE=e=>nE(e)||ny(e),Is=(e,t)=>{const{x:n,y:r}=la(t)?{x:t,y:t}:t||{};la(n)&&(e.scrollLeft=n),la(r)&&(e.scrollTop=r)},Pr=e=>({x:e.scrollLeft,y:e.scrollTop}),sE=()=>({T:{x:0,y:0},k:{x:0,y:0}}),c5=(e,t)=>{const{T:n,k:r}=e,{w:a,h:o}=t,d=(f,g,x)=>{let w=Kw(f)*x,C=Kw(g)*x;if(w===C){const v=sa(f),S=sa(g);C=v>S?0:C,w=v<S?0:w}return w=w===C?0:w,[w+0,C+0]},[u,c]=d(n.x,r.x,a),[h,m]=d(n.y,r.y,o);return{T:{x:u,y:h},k:{x:c,y:m}}},Ug=({T:e,k:t})=>{const n=(r,a)=>r===0&&r<=a;return{x:n(e.x,t.x),y:n(e.y,t.y)}},t1=({T:e,k:t},n)=>{const r=(a,o,d)=>Vj(0,1,(a-d)/(a-o)||0);return{x:r(e.x,t.x,n.x),y:r(e.y,t.y,n.y)}},ry=e=>{e&&e.focus&&e.focus({preventScroll:!0,focusVisible:!1})},n1=(e,t)=>{tn(ob(t),e)},sy=e=>{const t=new Map,n=(o,d)=>{if(o){const u=t.get(o);n1((c=>{u&&u[c?"delete":"clear"](c)}),d)}else t.forEach((u=>{u.clear()})),t.clear()},r=(o,d)=>{if(Ml(o)){const h=t.get(o)||new Set;return t.set(o,h),n1((m=>{Ss(m)&&h.add(m)}),d),yt(n,o,d)}If(d)&&d&&n();const u=vr(o),c=[];return tn(u,(h=>{const m=o[h];m&&bn(c,r(h,m))})),yt(Br,c)},a=(o,d)=>{tn(fa(t.get(o)),(u=>{d&&!Xh(d)?u.apply(0,d):u()}))};return r(e||{}),[r,n,a]},iE={},aE={},u5=e=>{tn(e,(t=>tn(t,((n,r)=>{iE[r]=t[r]}))))},oE=(e,t,n)=>vr(e).map((r=>{const{static:a,instance:o}=e[r],[d,u,c]=n||[],h=n?o:a;if(h){const m=n?h(d,u,t):h(t);return(c||aE)[r]=m}})),d5=(e,t)=>e[t],Il=e=>d5(aE,e),h5="__osOptionsValidationPlugin",Pl="data-overlayscrollbars",Ph="os-environment",th=`${Ph}-scrollbar-hidden`,Vg=`${Pl}-initialize`,Bh="noClipping",r1=`${Pl}-body`,ca=Pl,f5="host",pi=`${Pl}-viewport`,m5=lb,p5=cb,g5="arrange",lE="measuring",x5="scrolling",cE="scrollbarHidden",y5="noContent",iy=`${Pl}-padding`,s1=`${Pl}-content`,gb="os-size-observer",b5=`${gb}-appear`,v5=`${gb}-listener`,_5="os-trinsic-observer",S5="os-theme-none",zr="os-scrollbar",w5=`${zr}-rtl`,C5=`${zr}-horizontal`,k5=`${zr}-vertical`,uE=`${zr}-track`,xb=`${zr}-handle`,j5=`${zr}-visible`,E5=`${zr}-cornerless`,i1=`${zr}-interaction`,a1=`${zr}-unusable`,ay=`${zr}-auto-hide`,N5=`${ay}-hidden`,o1=`${zr}-wheel`,T5=`${uE}-interactive`,A5=`${xb}-interactive`,L5="__osSizeObserverPlugin",R5=(e,t)=>{const{M:n}=t,[r,a]=e("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,a]},pl=e=>e.indexOf(xi)===0,D5=e=>e.replace(`${xi}-`,""),oy=(e,t)=>{if(e==="auto")return t?Ja:hs;const n=e||hs;return[hs,Ja,xi].includes(n)?n:hs},O5=(e,t)=>{const{overflowX:n,overflowY:r}=$s(e,[lb,cb]);return{x:oy(n,t.x),y:oy(r,t.y)}},yb="__osScrollbarsHidingPlugin",M5="__osClickScrollPlugin",l1=e=>JSON.stringify(e,((t,n)=>{if(Ss(n))throw 0;return n})),c1=(e,t)=>e?`${t}`.split(".").reduce(((n,r)=>n&&Hj(n,r)?n[r]:void 0),e):void 0,I5=[0,33],dE=[33,99],hE=[222,666,!0],P5={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:{mutation:I5,resize:null,event:dE,env:hE},attributes:null,ignoreMutation:null,flowDirectionStyles:null},overflow:{x:"scroll",y:"scroll"},scrollbars:{theme:"os-theme-dark",visibility:"auto",autoHide:"never",autoHideDelay:1300,autoHideSuspend:!1,dragScroll:!0,clickScroll:!1,pointers:["mouse","touch","pen"]}},fE=(e,t)=>{const n={},r=wl(vr(t),vr(e));return tn(r,(a=>{const o=e[a],d=t[a];if(Kh(o)&&Kh(d))Ut(n[a]={},fE(o,d)),ub(n[a])&&delete n[a];else if(Hj(t,a)&&d!==o){let u=!0;if(is(o)||is(d))try{l1(o)===l1(d)&&(u=!1)}catch{}u&&(n[a]=d)}})),n},Wg=(e,t,n)=>r=>[c1(e,r),n||c1(t,r)!==void 0];let mE;const B5=()=>mE,$5=e=>{mE=e};let Gg;const F5=()=>{const e=(j,E,N)=>{_r(document.body,j),_r(document.body,j);const L=eE(j),A=yl(j),D=pb(E);return N&&Cl(j),{x:A.h-L.h+D.h,y:A.w-L.w+D.w}},t=j=>{let E=!1;const N=mb(j,th);try{E=$s(j,"scrollbar-width")==="none"||$s(j,"display","::-webkit-scrollbar")==="none"}catch{}return N(),E},n=`.${Ph}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${Ph} div{width:200%;height:200%;margin:10px 0}.${th}{scrollbar-width:none!important}.${th}::-webkit-scrollbar,.${th}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`,a=Qj(`<div class="${Ph}"><div></div><style>${n}</style></div>`)[0],o=a.firstChild,d=a.lastChild,u=B5();u&&(d.nonce=u);const[c,,h]=sy(),[m,f]=Ir({o:e(a,o),i:Ih},yt(e,a,o,!0)),[g]=f(),x=t(a),w={x:g.x===0,y:g.y===0},C={elements:{host:null,padding:!x,viewport:j=>x&&Yj(j)&&j,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},v=Ut({},P5),S=yt(Ut,{},v),_=yt(Ut,{},C),b={U:g,M:w,P:x,J:!!Jc,G:yt(c,"r"),K:_,Z:j=>Ut(C,j)&&_(),tt:S,nt:j=>Ut(v,j)&&S(),ot:Ut({},C),st:Ut({},v)};if(Ls(a,"style"),Cl(a),fn(Sr,"resize",(()=>{h("r",[])})),Ss(Sr.matchMedia)&&!x&&(!w.x||!w.y)){const j=E=>{const N=Sr.matchMedia(`(resolution: ${Sr.devicePixelRatio}dppx)`);fn(N,"change",(()=>{E(),j(E)}),{A:!0})};j((()=>{const[E,N]=m();Ut(b.U,E),h("r",[N])}))}return b},zs=()=>(Gg||(Gg=F5()),Gg),z5=(e,t,n)=>{let r=!1;const a=n?new WeakMap:!1,o=()=>{r=!0},d=u=>{if(a&&n){const c=n.map((h=>{const[m,f]=h||[];return[f&&m?(u||Kj)(m,e):[],f]}));tn(c,(h=>tn(h[0],(m=>{const f=h[1],g=a.get(m)||[];if(e.contains(m)&&f){const w=fn(m,f,(C=>{r?(w(),a.delete(m)):t(C)}));a.set(m,bn(g,w))}else Br(g),a.delete(m)}))))}};return d(),[o,d]},u1=(e,t,n,r)=>{let a=!1;const{et:o,ct:d,rt:u,it:c,lt:h,ut:m}=r||{},[f,g]=z5(e,(()=>a&&n(!0)),u),x=o||[],w=d||[],C=wl(x,w),v=(_,b)=>{if(!Xh(b)){const j=h||uu,E=m||uu,N=[],L=[];let A=!1,D=!1;if(tn(b,(O=>{const{attributeName:F,target:P,type:z,oldValue:K,addedNodes:q,removedNodes:W}=O,Z=z==="attributes",Q=z==="childList",H=e===P,I=Z&&F,M=I&&db(P,F||""),V=Ml(M)?M:null,$=I&&K!==V,ee=Rj(w,F)&&$;if(t&&(Q||!H)){const Y=Z&&$,X=Y&&c&&Qx(P,c),B=(X?!j(P,F,K,V):!Z||Y)&&!E(O,!!X,e,r);tn(q,(J=>bn(N,J))),tn(W,(J=>bn(N,J))),D=D||B}!t&&H&&$&&!j(P,F,K,V)&&(bn(L,F),A=A||ee)})),g((O=>Qh(N).reduce(((F,P)=>(bn(F,Kj(O,P)),Qx(P,O)?bn(F,P):F)),[]))),t)return!_&&D&&n(!1),[!1];if(!Xh(L)||A){const O=[Qh(L),A];return _||n.apply(0,O),O}}},S=new JD(yt(v,!1));return[()=>(S.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:C,subtree:t,childList:t,characterData:t}),a=!0,()=>{a&&(f(),S.disconnect(),a=!1)}),()=>{if(a)return v(!0,S.takeRecords())}]};let Ma=null;const pE=(e,t,n)=>{const{ft:r}=n||{},a=Il(L5),[o]=Ir({o:!1,u:!0});return()=>{const d=[],c=Qj(`<div class="${gb}"><div class="${v5}"></div></div>`)[0],h=c.firstChild,m=f=>{const g=is(f)&&!Xh(f);let x=!1,w=!1;if(g){const C=f[0],[v,,S]=o(C.contentRect),_=ty(v);w=tE(v,S),x=!w&&!_}else w=f===!0;x||t({_t:!0,ft:w})};if(hl){if(!If(Ma)){const w=new hl(uu);w.observe(e,{get box(){Ma=!0}}),Ma=Ma||!1,w.disconnect()}const f=zj(m,{p:0,v:0}),g=w=>f(w),x=new hl(g);if(x.observe(Ma?e:h),bn(d,[()=>{x.disconnect()},!Ma&&_r(e,c)]),Ma){const w=new hl(g);w.observe(e,{box:"border-box"}),bn(d,(()=>w.disconnect()))}}else if(a){const[f,g]=a(h,m,r);bn(d,wl([mb(c,b5),fn(c,"animationstart",f),_r(e,c)],g))}else return uu;return yt(Br,d)}},H5=(e,t)=>{let n;const r=c=>c.h===0||c.isIntersecting||c.intersectionRatio>0,a=xl(_5),[o]=Ir({o:!1}),d=(c,h)=>{if(c){const m=o(r(c)),[,f]=m;return f&&!h&&t(m)&&[m]}},u=(c,h)=>d(h.pop(),c);return[()=>{const c=[];if(Yw)n=new Yw(yt(u,!1),{root:e}),n.observe(a),bn(c,(()=>{n.disconnect()}));else{const h=()=>{const m=yl(a);d(m)};bn(c,pE(a,h)()),h()}return yt(Br,bn(c,_r(e,a)))},()=>n&&u(!0,n.takeRecords())]},U5=(e,t,n,r)=>{let a,o,d,u,c,h,m,f;const g=`[${ca}]`,x=`[${pi}]`,w=["id","class","style","open","wrap","cols","rows"],{dt:C,vt:v,L:S,gt:_,ht:b,V:j,bt:E,yt:N,wt:L,St:A}=e,D=U=>$s(U,"direction")==="rtl",O=()=>{let U,B,J;const se=zj(r,{p:()=>U,v:()=>B,S:()=>J,m(ie,de){const[pe]=ie,[Oe]=de;return[wl(vr(pe),vr(Oe)).reduce((($e,Pe)=>($e[Pe]=pe[Pe]||Oe[Pe],$e)),{})]}}),ne=(ie,de)=>{if(is(de)){const[pe,Oe,$e]=de;U=pe,B=Oe,J=$e}else la(de)?(U=de,B=!1,J=!1):(U=!1,B=!1,J=!1);se(ie)};return ne.O=se.O,ne},F={Ot:!1,B:D(C)},P=zs(),z=Il(yb),[K]=Ir({i:Fj,o:{w:0,h:0}},(()=>{const U=z&&z.R(e,t,F,P,n).Y,J=!(E&&j)&&fb(v,ca,Bh),se=!j&&N(g5),ne=se&&Pr(_),ie=ne&&A(),de=L(lE,J),pe=se&&U&&U(),Oe=Zh(S),$e=pb(S);return pe&&pe(),Is(_,ne),ie&&ie(),J&&de(),{w:Oe.w+$e.w,h:Oe.h+$e.h}})),q=O(),W=U=>{const B=D(C);Ut(U,{Ct:f!==B}),Ut(F,{B}),f=B},Z=(U,B)=>{const[J,se]=U,ne={$t:se};return Ut(F,{Ot:J}),B||r(ne),ne},Q=({_t:U,ft:B})=>{const J=B?r:q,se={_t:U||B,ft:B};W(se),J(se,o)},H=(U,B)=>{const[,J]=K(),se={xt:J};return W(se),J&&!B&&q(se,U?d:a),se},I=(U,B,J)=>{const se={Ht:B};return W(se),B&&!J&&q(se,a),se},[M,V]=b?H5(v,Z):[],$=!j&&pE(v,Q,{ft:!0}),[ee,Y]=u1(v,!1,I,{ct:w,et:w}),X=j&&hl&&new hl((U=>{const B=U[U.length-1].contentRect;Q({_t:!0,ft:tE(B,m)}),m=B}));return[()=>{X&&X.observe(v);const U=$&&$(),B=M&&M(),J=ee(),se=P.G((ne=>{const[,ie]=K();q({Et:ne,xt:ie,_t:E},u)}));return()=>{X&&X.disconnect(),U&&U(),B&&B(),h&&h(),J(),se()}},({Dt:U,zt:B,It:J})=>{const se={},[ne]=U("update.ignoreMutation"),[ie,de]=U("update.attributes"),[pe,Oe]=U("update.elementEvents"),[$e,Pe]=U("update.debounce"),Ve=Oe||de,Ye=B||J,ot=Ae=>Ss(ne)&&!!ne(Ae);if(Ve){c&&c(),h&&h();const[Ae,me]=u1(b||S,!0,H,{et:wl(w,ie||[]),rt:pe,it:g,ut:(re,_e)=>{const{target:Me,attributeName:ce}=re;return(!_e&&ce&&!j?n5(Me,g,x):!1)||!!ml(Me,`.${zr}`)||ot(re)}});h=Ae(),c=me}if(Pe&&(q.O(),is($e)||la($e)?(a=$e,o=!1,d=dE,u=hE):cu($e)?(a=$e.mutation,o=$e.resize,d=$e.event,u=$e.env):(a=!1,o=!1,d=!1,u=!1)),Ye){const Ae=Y(),me=V&&V(),re=c&&c();Ae&&Ut(se,I(Ae[0],Ae[1],Ye)),me&&Ut(se,Z(me[0],Ye)),re&&Ut(se,H(re[0],Ye))}return W(se),se},F]},gE=(e,t)=>Ss(t)?t.apply(0,e):t,V5=(e,t,n,r)=>{const a=ib(r)?n:r;return gE(e,a)||t.apply(0,e)},xE=(e,t,n,r)=>{const a=ib(r)?n:r,o=gE(e,a);return!!o&&(Yh(o)?o:t.apply(0,e))},W5=(e,t)=>{const{nativeScrollbarsOverlaid:n,body:r}=t||{},{M:a,P:o,K:d}=zs(),{nativeScrollbarsOverlaid:u,body:c}=d().cancel,h=n??u,m=ib(r)?c:r,f=(a.x||a.y)&&h,g=e&&(Mf(m)?!o:m);return!!f||!!g},G5=(e,t,n,r)=>{const a="--os-viewport-percent",o="--os-scroll-percent",d="--os-scroll-direction",{K:u}=zs(),{scrollbars:c}=u(),{slot:h}=c,{dt:m,vt:f,L:g,At:x,gt:w,bt:C,V:v}=t,{scrollbars:S}=x?{}:e,{slot:_}=S||{},b=[],j=[],E=[],N=xE([m,f,g],(()=>v&&C?m:f),h,_),L=M=>{if(Jc){let V=null,$=[];const ee=new Jc({source:w,axis:M}),Y=()=>{V&&V.cancel(),V=null};return{Mt:U=>{const{Tt:B}=n,J=Ug(B)[M],se=M==="x",ne=[zg(0,se),zg(`calc(-100% + 100cq${se?"w":"h"})`,se)],ie=J?ne:ne.reverse();return $[0]===ie[0]&&$[1]===ie[1]||($=ie,Y(),V=U.kt.animate({clear:["left"],transform:ie},{timeline:ee})),Y}}}},A={x:L("x"),y:L("y")},D=()=>{const{Rt:M,Vt:V}=n,$=(ee,Y)=>Vj(0,1,ee/(ee+Y)||0);return{x:$(V.x,M.x),y:$(V.y,M.y)}},O=(M,V,$)=>{const ee=$?mb:qj;tn(M,(Y=>{ee(Y.Lt,V)}))},F=(M,V)=>{tn(M,($=>{const[ee,Y]=V($);hu(ee,Y)}))},P=(M,V,$)=>{const ee=If($),Y=ee?$:!0,X=ee?!$:!0;Y&&O(j,M,V),X&&O(E,M,V)},z=()=>{const M=D(),V=$=>ee=>[ee.Lt,{[a]:ey($)+""}];F(j,V(M.x)),F(E,V(M.y))},K=()=>{if(!Jc){const{Tt:M}=n,V=t1(M,Pr(w)),$=ee=>Y=>[Y.Lt,{[o]:ey(ee)+""}];F(j,$(V.x)),F(E,$(V.y))}},q=()=>{const{Tt:M}=n,V=Ug(M),$=ee=>Y=>[Y.Lt,{[d]:ee?"0":"1"}];F(j,$(V.x)),F(E,$(V.y)),Jc&&(j.forEach(A.x.Mt),E.forEach(A.y.Mt))},W=()=>{if(v&&!C){const{Rt:M,Tt:V}=n,$=Ug(V),ee=t1(V,Pr(w)),Y=X=>{const{Lt:U}=X,B=du(U)===g&&U,J=(se,ne,ie)=>{const de=ne*se;return Zj(ie?de:-de)};return[B,B&&{transform:zg({x:J(ee.x,M.x,$.x),y:J(ee.y,M.y,$.y)})}]};F(j,Y),F(E,Y)}},Z=M=>{const V=M?"x":"y",ee=xl(`${zr} ${M?C5:k5}`),Y=xl(uE),X=xl(xb),U={Lt:ee,Pt:Y,kt:X},B=A[V];return bn(M?j:E,U),bn(b,[_r(ee,Y),_r(Y,X),yt(Cl,ee),B&&B.Mt(U),r(U,P,M)]),U},Q=yt(Z,!0),H=yt(Z,!1),I=()=>(_r(N,j[0].Lt),_r(N,E[0].Lt),yt(Br,b));return Q(),H(),[{Ut:z,Nt:K,qt:q,Bt:W,Ft:P,jt:{Xt:j,Yt:Q,Wt:yt(F,j)},Jt:{Xt:E,Yt:H,Wt:yt(F,E)}},I]},q5=(e,t,n,r,a)=>(o,d,u)=>{const{vt:c,L:h,V:m,gt:f,Gt:g,St:x}=t,{Lt:w,Pt:C,kt:v}=o,[S,_]=fl(333),[b,j]=fl(444),E=A=>{Ss(f.scrollBy)&&f.scrollBy({behavior:"smooth",left:A.x,top:A.y})},N=()=>{const A="pointerup pointercancel lostpointercapture",D=`client${u?"X":"Y"}`,O=u?Bf:$f,F=u?"left":"top",P=u?"w":"h",z=u?"x":"y",K=[];return fn(C,"pointerdown",r((q=>{const W=ml(q.target,`.${xb}`)===v,Z=W?v:C,Q=e.scrollbars,H=Q[W?"dragScroll":"clickScroll"],{button:I,isPrimary:M,pointerType:V}=q,{pointers:$}=Q;if(I===0&&M&&H&&($||[]).includes(V)){Br(K),j();const Y=!W&&(q.shiftKey||H==="instant"),X=yt(Hg,v),U=yt(Hg,C),B=(Me,ce)=>(Me||X())[F]-(ce||U())[F],J=Xx(Hg(f)[O])/yl(f)[P]||1,se=Pr(f)[z],ne=Me=>{Is(f,{[z]:se+Me})},ie=Me=>{const{Rt:ce}=n,Ne=yl(C)[P]-yl(v)[P],Xe=1/J*Me/Ne;ne(Xe*ce[z])},de=q[D],pe=X(),Oe=U(),$e=pe[O],Pe=B(pe,Oe)+$e/2,Ye=de-Oe[F]-Pe,ot=W?0:Ye,Ae=Me=>{Br(_e),Z.releasePointerCapture(Me.pointerId)},me=W||Y,re=x(),_e=[fn(g,A,Ae),fn(g,"selectstart",(Me=>ny(Me)),{D:!1}),fn(C,A,Ae),me&&fn(C,"pointermove",(Me=>ie(ot+Me[D]-de))),me&&(()=>{const Me=Pr(f);re();const ce=Pr(f),Ne={x:ce.x-Me.x,y:ce.y-Me.y};(sa(Ne.x)>3||sa(Ne.y)>3)&&(x(),Is(f,Me),E(Ne),b(re))})];if(Z.setPointerCapture(q.pointerId),Y)ie(Ye);else if(!W){const Me=Il(M5);if(Me){const{Vt:ce}=n,Ne=Me(ne,ie,yt(B),Ye,ce[z],H,!!u,(Xe=>{Xe?re():bn(_e,re)}));bn(_e,Ne),bn(K,yt(Ne,!0))}}}})))};let L=!0;return yt(Br,[fn(v,"pointermove pointerleave",r(a)),fn(w,"pointerenter",r((()=>{d(i1,!0)}))),fn(w,"pointerleave pointercancel",r((()=>{d(i1,!1)}))),fn(w,"wheel",r((A=>{const{deltaX:D,deltaY:O,deltaMode:F}=A;L&&F===0&&du(w)===c&&E({x:D,y:O}),L=!1,d(o1,!0),S((()=>{L=!0,d(o1)})),ny(A)})),{D:!1,I:!0}),!m&&fn(w,"mousedown",r((()=>{const A=Zx();(Qw(A,pi)||Qw(A,ca)||A===document.body)&&sb(yt(ry,h),25)}))),fn(w,"pointerdown",(()=>{const A=fn(g,"click",(O=>{D(),rE(O)}),{A:!0,I:!0,D:!1}),D=fn(g,"pointerup pointercancel",(()=>{D(),setTimeout(A,150)}),{I:!0,D:!0})}),{I:!0,D:!0}),N(),_,j])},K5=(e,t,n,r,a,o,d)=>{let u,c,h,m,f,g=uu,x=0;const w=["mouse","pen"],C=X=>U=>{n.Kt||X(U)},v=X=>w.includes(X.pointerType),[S,_]=fl(),[b,j]=fl(100),[E,N]=fl(50),[L,A]=fl((()=>x)),[D,O]=G5(e,o,a,q5(t,o,a,C,(X=>v(X)&&I()))),{vt:F,Qt:P,bt:z}=o,{Ft:K,Ut:q,Nt:W,qt:Z,Bt:Q}=D,H=(X,U)=>{A();const B=J=>{n.Kt||K(N5,J)};if(X)B();else{const J=h?!u:!0;x>0&&!U?L(yt(B,J)):B(J)}},I=()=>{(h?!u:!m)&&(H(!0),b((()=>{H(!1)})))},M=X=>{v(X)&&(u=!0,!n.Kt&&h&&H(!0))},V=X=>{v(X)&&(u=!1,!n.Kt&&h&&H(!1))},$=X=>{K(ay,X,!0),K(ay,X,!1)},ee=[A,j,N,_,()=>g(),fn(F,"pointerover",M,{A:!0}),fn(F,"pointerenter",M),fn(F,"pointerleave",V),fn(F,"pointermove",C((X=>{v(X)&&c&&I()}))),fn(P,"scroll",C((X=>{S((()=>{W(),I()})),d(X),Q()})))],Y=Il(yb);return[()=>yt(Br,bn(ee,O())),({Dt:X,It:U,Zt:B,tn:J})=>{const{nn:se,sn:ne,en:ie,cn:de}=J||{},{Ct:pe,ft:Oe}=B||{},{B:$e}=r,{M:Pe,P:Ve}=zs(),{rn:Ye,j:ot}=a,[Ae,me]=X("showNativeOverlaidScrollbars"),[re,_e]=X("scrollbars.theme"),[Me,ce]=X("scrollbars.visibility"),[Ne,Xe]=X("scrollbars.autoHide"),[at,fe]=X("scrollbars.autoHideSuspend"),[We]=X("scrollbars.autoHideDelay"),[Ze,it]=X("scrollbars.dragScroll"),[nt,De]=X("scrollbars.clickScroll"),[Re,Se]=X("overflow"),Ue=Oe&&!U,ve=se||ne||de||pe||U,tt=ie||ce||Se,et=Ae&&Pe.x&&Pe.y,dt=!Ve&&!Y,Lt=et||dt,qt=(vn,_n,xn)=>{const hr=vn.includes(Ja)&&(Me===xi||Me==="auto"&&_n===Ja);return K(j5,hr,xn),hr};if(x=We,(me||dt)&&K(S5,Lt),_e&&(K(f),K(re,!0),f=re),(fe||Ue)&&($(!at),Ue&&at&&(ot.x||ot.y?(g(),E((()=>{g=fn(P,Ja,C(yt($,!0)),{A:!0})}))):$(!0))),Xe&&(c=Ne==="move",h=Ne==="leave",m=Ne==="never",H(m,!0)),it&&K(A5,Ze),De&&K(T5,!!nt),tt){const vn=qt(Re.x,Ye.x,!0),_n=qt(Re.y,Ye.y,!1);K(E5,!(vn&&_n))}ve&&(W(),q(),Q(),de&&Z(),K(a1,!ot.x,!0),K(a1,!ot.y,!1),K(w5,$e&&!z))},{},D]},Y5=e=>{const t=zs(),{K:n,P:r}=t,{elements:a}=n(),{padding:o,viewport:d,content:u}=a,c=Yh(e),h=c?{}:e,{elements:m}=h,{padding:f,viewport:g,content:x}=m||{},w=c?e:h.target,C=Yj(w),v=w.ownerDocument,S=v.documentElement,_=()=>v.defaultView||Sr,b=yt(V5,[w]),j=yt(xE,[w]),E=yt(xl,""),N=yt(b,E,d),L=yt(j,E,u),A=pe=>{const Oe=yl(pe),$e=Zh(pe),Pe=$s(pe,lb),Ve=$s(pe,cb);return $e.w-Oe.w>0&&!pl(Pe)||$e.h-Oe.h>0&&!pl(Ve)},D=N(g),O=D===w,F=O&&C,P=!O&&L(x),z=!O&&D===P,K=F?S:D,q=F?K:w,W=!O&&j(E,o,f),Z=!z&&P,Q=[Z,K,W,q].map((pe=>Yh(pe)&&!du(pe)&&pe)),H=pe=>pe&&Rj(Q,pe),I=!H(K)&&A(K)?K:w,M=F?S:K,$={dt:w,vt:q,L:K,ln:W,ht:Z,gt:M,Qt:F?v:K,an:C?S:I,Gt:v,bt:C,At:c,V:O,un:_,yt:pe=>fb(K,pi,pe),wt:(pe,Oe)=>Jh(K,pi,pe,Oe),St:()=>Jh(M,pi,x5,!0)},{dt:ee,vt:Y,ln:X,L:U,ht:B}=$,J=[()=>{Ls(Y,[ca,Vg]),Ls(ee,Vg),C&&Ls(S,[Vg,ca])}];let se=Jx([B,U,X,Y,ee].find((pe=>pe&&!H(pe))));const ne=F?ee:B||U,ie=yt(Br,J);return[$,()=>{const pe=_(),Oe=Zx(),$e=Ae=>{_r(du(Ae),Jx(Ae)),Cl(Ae)},Pe=Ae=>fn(Ae,"focusin focusout focus blur",rE,{I:!0,D:!1}),Ve="tabindex",Ye=db(U,Ve),ot=Pe(Oe);return mi(Y,ca,O?"":f5),mi(X,iy,""),mi(U,pi,""),mi(B,s1,""),O||(mi(U,Ve,Ye||"-1"),C&&mi(S,r1,"")),_r(ne,se),_r(Y,X),_r(X||Y,!O&&U),_r(U,B),bn(J,[ot,()=>{const Ae=Zx(),me=H(U),re=me&&Ae===U?ee:Ae,_e=Pe(re);Ls(X,iy),Ls(B,s1),Ls(U,pi),C&&Ls(S,r1),Ye?mi(U,Ve,Ye):Ls(U,Ve),H(B)&&$e(B),me&&$e(U),H(X)&&$e(X),ry(re),_e()}]),r&&!O&&(hb(U,pi,cE),bn(J,yt(Ls,U,pi))),ry(!O&&C&&Oe===ee&&pe.top===pe?U:Oe),ot(),se=0,ie},ie]},X5=({ht:e})=>({Zt:t,fn:n,It:r})=>{const{$t:a}=t||{},{Ot:o}=n;e&&(a||r)&&hu(e,{[$f]:o&&"100%"})},Q5=({vt:e,ln:t,L:n,V:r},a)=>{const[o,d]=Ir({i:e5,o:Zw()},yt(Zw,e,"padding",""));return({Dt:u,Zt:c,fn:h,It:m})=>{let[f,g]=d(m);const{P:x}=zs(),{_t:w,xt:C,Ct:v}=c||{},{B:S}=h,[_,b]=u("paddingAbsolute");(w||g||(m||C))&&([f,g]=o(m));const E=!r&&(b||v||g);if(E){const N=!_||!t&&!x,L=f.r+f.l,A=f.t+f.b,D={[Bj]:N&&!S?-L:0,[$j]:N?-A:0,[Pj]:N&&S?-L:0,top:N?-f.t:0,right:N?S?-f.r:"auto":0,left:N?S?"auto":-f.l:0,[Bf]:N&&`calc(100% + ${L}px)`},O={[Dj]:N?f.t:0,[Oj]:N?f.r:0,[Ij]:N?f.b:0,[Mj]:N?f.l:0};hu(t||n,D),hu(n,O),Ut(a,{ln:f,_n:!N,F:t?O:Ut({},D,O)})}return{dn:E}}},J5=(e,t)=>{const n=zs(),{vt:r,ln:a,L:o,V:d,Qt:u,gt:c,bt:h,wt:m,un:f}=e,{P:g}=n,x=h&&d,w=yt(Tj,0),C={display:()=>!1,direction:ee=>ee!=="ltr",flexDirection:ee=>ee.endsWith("-reverse"),writingMode:ee=>ee!=="horizontal-tb"},v=vr(C),S={i:Fj,o:{w:0,h:0}},_={i:Ih,o:{}},b=ee=>{m(lE,!x&&ee)},j=()=>$s(o,v),E=(ee,Y)=>{const X=!vr(ee).length,U=Y?!0:v.some((Ve=>{const Ye=ee[Ve];return Ml(Ye)&&C[Ve](Ye)}));if(X||!U||!l5(o))return{T:{x:0,y:0},k:{x:1,y:1}};b(!0);const B=Pr(c),J=fn(u,Ja,(Ve=>{const Ye=Pr(c);Ve.isTrusted&&Ye.x===B.x&&Ye.y===B.y&&nE(Ve)}),{I:!0,A:!0}),se=m(y5,!0);Is(c,{x:0,y:0}),se();const ne=Pr(c),ie=Zh(c);Is(c,{x:ie.w,y:ie.h});const de=Pr(c),pe={x:de.x-ne.x,y:de.y-ne.y};Is(c,{x:-ie.w,y:-ie.h});const Oe=Pr(c),$e={x:Oe.x-ne.x,y:Oe.y-ne.y},Pe={x:sa(pe.x)>=sa($e.x)?de.x:Oe.x,y:sa(pe.y)>=sa($e.y)?de.y:Oe.y};return Is(c,B),rb((()=>J())),{T:ne,k:Pe}},N=(ee,Y)=>{const X=Sr.devicePixelRatio%1!==0?1:0,U={w:w(ee.w-Y.w),h:w(ee.h-Y.h)};return{w:U.w>X?U.w:0,h:U.h>X?U.h:0}},L=(ee,Y)=>{const X=(U,B,J,se)=>{const ne=U===xi?hs:D5(U),ie=pl(U),de=pl(J);return!B&&!se?hs:ie&&de?xi:ie?B&&se?ne:B?xi:hs:B?ne:de&&se?xi:hs};return{x:X(Y.x,ee.x,Y.y,ee.y),y:X(Y.y,ee.y,Y.x,ee.x)}},A=ee=>{const Y=U=>[xi,hs,Ja].map((B=>$(oy(B),U))),X=Y(!0).concat(Y()).join(" ");m(X),m(vr(ee).map((U=>$(ee[U],U==="x"))).join(" "),!0)},[D,O]=Ir(S,yt(pb,o)),[F,P]=Ir(S,yt(Zh,o)),[z,K]=Ir(S),[q]=Ir(_),[W,Z]=Ir(S),[Q]=Ir(_),[H]=Ir({i:(ee,Y)=>Ff(ee,Y,Qh(wl(vr(ee),vr(Y)))),o:{}}),[I,M]=Ir({i:(ee,Y)=>Ih(ee.T,Y.T)&&Ih(ee.k,Y.k),o:sE()}),V=Il(yb),$=(ee,Y)=>`${Y?m5:p5}${ZD(ee)}`;return({Dt:ee,Zt:Y,fn:X,It:U},{dn:B})=>{const{_t:J,Ht:se,xt:ne,Ct:ie,ft:de,Et:pe}=Y||{},Oe=V&&V.R(e,t,X,n,ee),{X:$e,Y:Pe,W:Ve}=Oe||{},[Ye,ot]=R5(ee,n),[Ae,me]=ee("overflow"),re=pl(Ae.x),_e=pl(Ae.y),Me=J||B||ne||ie||pe||ot;let ce=O(U),Ne=P(U),Xe=K(U),at=Z(U);if(ot&&g&&m(cE,!Ye),Me){fb(r,ca,Bh)&&b(!0);const rt=Pe&&Pe(),[Qe]=ce=D(U),[He]=Ne=F(U),le=eE(o),Ke=x&&o5(f()),xt={w:w(He.w+Qe.w),h:w(He.h+Qe.h)},Mt={w:w((Ke?Ke.w:le.w+w(le.w-He.w))+Qe.w),h:w((Ke?Ke.h:le.h+w(le.h-He.h))+Qe.h)};rt&&rt(),at=W(Mt),Xe=z(N(xt,Mt),U)}const[fe,We]=at,[Ze,it]=Xe,[nt,De]=Ne,[Re,Se]=ce,[Ue]=q({x:Ze.w>0,y:Ze.h>0}),ve=re&&_e&&(Ue.x||Ue.y)||re&&Ue.x&&!Ue.y||_e&&Ue.y&&!Ue.x,tt=B||ie||pe||Se||De||We||it||me||ot||Me||se&&x,[et]=ee("update.flowDirectionStyles"),[dt,Lt]=H(et?et(o)||{}:j(),U),qt=ie||de||Lt||U,[vn,_n]=qt?I(E(dt,!!et),U):M();let xn=L(Ue,Ae);b(!1),tt&&(A(xn),xn=O5(o,Ue),Ve&&$e&&($e(xn,nt,Re),hu(o,Ve(xn))));const[hr,be]=Q(xn);return Jh(r,ca,Bh,ve),Jh(a,iy,Bh,ve),Ut(t,{rn:hr,Vt:{x:fe.w,y:fe.h},Rt:{x:Ze.w,y:Ze.h},j:Ue,Tt:c5(vn,Ze)}),{en:be,nn:We,sn:it,cn:_n||it}}},Z5=e=>{const[t,n,r]=Y5(e),a={ln:{t:0,r:0,b:0,l:0},_n:!1,F:{[Bj]:0,[$j]:0,[Pj]:0,[Dj]:0,[Oj]:0,[Ij]:0,[Mj]:0},Vt:{x:0,y:0},Rt:{x:0,y:0},rn:{x:hs,y:hs},j:{x:!1,y:!1},Tt:sE()},{dt:o,gt:d,V:u,St:c}=t,{P:h,M:m}=zs(),f=!h&&(m.x||m.y),g=[X5(t),Q5(t,a),J5(t,a)];return[n,x=>{const w={},v=f&&Pr(d),S=v&&c();return tn(g,(_=>{Ut(w,_(x,w)||{})})),Is(d,v),S&&S(),u||Is(o,0),w},a,t,r]},e3=(e,t,n,r)=>{let a=!1;const o={Kt:!1,pn:!1},d=Wg(t,{}),[u,c,h,m,f]=Z5(e),[g,x,w]=U5(m,h,d,(j=>{b({},j)})),[C,v,,S]=K5(e,t,o,w,h,m,r),_=j=>vr(j).some((E=>!!j[E])),b=(j,E)=>{const{Kt:N,pn:L}=o;if(L||N&&a)return!1;const{vn:A,It:D,zt:O}=j,F=A||{},P=!!D||!a,z={Dt:Wg(t,F,P),vn:F,It:P},K=E||x(Ut({},z,{zt:O})),q=c(Ut({},z,{fn:w,Zt:K}));v(Ut({},z,{Zt:K,tn:q}));const W=_(K),Z=_(q),Q=W||Z||!ub(F)||P;return a=!0,Q&&n(j,{Zt:K,tn:q}),Q};return[()=>{const{an:j,gt:E,St:N}=m,L=Pr(j),A=[g(),u(),C(),()=>{o.pn=!0}],D=N();return Is(E,L),D(),yt(Br,A)},b,j=>{const E=o.Kt;o.Kt=j,!j&&E!==j&&b({It:!0,zt:!0})},()=>{v({Dt:Wg(t,{},!1),vn:{},It:!1})},()=>({gn:o,hn:w,bn:h}),{yn:m,wn:S},f]},bb=new WeakMap,t3=(e,t)=>{bb.set(e,t)},n3=e=>{bb.delete(e)},yE=e=>bb.get(e),gs=(e,t,n)=>{const{tt:r}=zs(),a=Yh(e),o=a?e:e.target,d=yE(o);if(t&&!d){const u=[],c={},h=P=>{const z=Uj(P),K=Il(h5);return K?K(z,!0):z},m=Ut({},r(),h(t)),[f,g,x]=sy(),[w,C,v]=sy(n),S=(P,z)=>{v(P,z),x(P,z)},[_,b,j,E,N,L,A]=e3(e,m,(({vn:P,It:z},{Zt:K,tn:q})=>{const{_t:W,Ct:Z,$t:Q,xt:H,Ht:I,ft:M}=K,{nn:V,sn:$,en:ee,cn:Y}=q;S("updated",[F,{updateHints:{sizeChanged:!!W,directionChanged:!!Z,heightIntrinsicChanged:!!Q,overflowEdgeChanged:!!V,overflowAmountChanged:!!$,overflowStyleChanged:!!ee,scrollCoordinatesChanged:!!Y,contentMutation:!!H,hostMutation:!!I,appear:!!M},changedOptions:P||{},force:!!z}])}),(P=>S("scroll",[F,P]))),D=P=>{const{gn:z}=N(),{pn:K}=z;K||(n3(o),Br(u),S("destroyed",[F,P]),g(),C())},F={options(P,z){if(P){const K=z?r():{},q=fE(m,Ut(K,h(P)));ub(q)||(Ut(m,q),b({vn:q}))}return Ut({},m)},on:w,off:(P,z)=>{P&&z&&C(P,z)},state(){const{gn:P,hn:z,bn:K}=N(),{pn:q,Kt:W}=P,{B:Z}=z,{Vt:Q,Rt:H,rn:I,j:M,ln:V,_n:$,Tt:ee}=K;return Ut({},{overflowEdge:Q,overflowAmount:H,overflowStyle:I,hasOverflow:M,scrollCoordinates:{start:ee.T,end:ee.k},padding:V,paddingAbsolute:$,directionRTL:Z,sleeping:W,destroyed:q})},elements(){const{dt:P,vt:z,ln:K,L:q,ht:W,gt:Z,Qt:Q}=L.yn,{jt:H,Jt:I}=L.wn,M=$=>{const{kt:ee,Pt:Y,Lt:X}=$;return{scrollbar:X,track:Y,handle:ee}},V=$=>{const{Xt:ee,Yt:Y}=$,X=M(ee[0]);return Ut({},X,{clone:()=>{const U=M(Y());return E(),U}})};return Ut({},{target:P,host:z,padding:K||q,viewport:q,content:W||q,scrollOffsetElement:Z,scrollEventElement:Q,scrollbarHorizontal:V(H),scrollbarVertical:V(I)})},update:P=>b({It:P,zt:!0}),destroy:yt(D,!1),sleep:j,plugin:P=>c[vr(P)[0]]};return bn(u,[A]),t3(o,F),oE(iE,gs,[F,f,c]),W5(L.yn.bt,!a&&e.cancel)?(D(!0),F):(bn(u,_()),S("initialized",[F]),F.update(),F)}return d};gs.plugin=e=>{const t=is(e),n=t?e:[e],r=n.map((a=>oE(a,gs)[0]));return u5(n),t?r:r[0]};gs.valid=e=>{const t=e&&e.elements,n=Ss(t)&&t();return cu(n)&&!!yE(n.target)};gs.env=()=>{const{U:e,M:t,P:n,J:r,ot:a,st:o,K:d,Z:u,tt:c,nt:h}=zs();return Ut({},{scrollbarsSize:e,scrollbarsOverlaid:t,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:a,staticDefaultOptions:o,getDefaultInitialization:d,setDefaultInitialization:u,getDefaultOptions:c,setDefaultOptions:h})};gs.nonce=$5;gs.trustedTypePolicy=s5;const r3=()=>{if(typeof window>"u"){const h=()=>{};return[h,h]}let e,t;const n=window,r=typeof n.requestIdleCallback=="function",a=n.requestAnimationFrame,o=n.cancelAnimationFrame,d=r?n.requestIdleCallback:a,u=r?n.cancelIdleCallback:o,c=()=>{u(e),o(t)};return[(h,m)=>{c(),e=d(r?()=>{c(),t=a(h)}:h,typeof m=="object"?m:{timeout:2233})},c]},s3=e=>{const{options:t,events:n,defer:r}=e||{},[a,o]=k.useMemo(r3,[]),d=k.useRef(null),u=k.useRef(r),c=k.useRef(t),h=k.useRef(n);return k.useEffect(()=>{u.current=r},[r]),k.useEffect(()=>{const{current:m}=d;c.current=t,gs.valid(m)&&m.options(t||{},!0)},[t]),k.useEffect(()=>{const{current:m}=d;h.current=n,gs.valid(m)&&m.on(n||{},!0)},[n]),k.useEffect(()=>()=>{var m;o(),(m=d.current)==null||m.destroy()},[]),k.useMemo(()=>[m=>{const f=d.current;if(gs.valid(f))return;const g=u.current,x=c.current||{},w=h.current||{},C=()=>d.current=gs(m,x,w);g?a(C,g):C()},()=>d.current],[])},i3=(e,t)=>{const{element:n="div",options:r,events:a,defer:o,children:d,...u}=e,c=n,h=k.useRef(null),m=k.useRef(null),[f,g]=s3({options:r,events:a,defer:o});return k.useEffect(()=>{const{current:x}=h,{current:w}=m;if(!x)return;const C=x;return f(n==="body"?{target:C,cancel:{body:null}}:{target:C,elements:{viewport:w,content:w}}),()=>{var v;return(v=g())==null?void 0:v.destroy()}},[f,n]),k.useImperativeHandle(t,()=>({osInstance:g,getElement:()=>h.current}),[]),ps.createElement(c,{"data-overlayscrollbars-initialize":"",ref:h,...u},n==="body"?d:ps.createElement("div",{"data-overlayscrollbars-contents":"",ref:m},d))},a3=k.forwardRef(i3),mt=k.forwardRef(({options:e,horizontal:t,both:n,onScrollbarGesture:r,...a},o)=>{const d=t||n,u=k.useRef(r);u.current=r;const c=k.useRef(null),h=k.useMemo(()=>({initialized:f=>{var _;(_=c.current)==null||_.call(c);const g=f.elements().scrollbarVertical,x=()=>{const b=g.handle.getBoundingClientRect(),j=g.track.getBoundingClientRect();return b.height===0||j.height===0?null:Math.max(0,j.bottom-b.bottom)};let w=null;const C=()=>{var b;(b=u.current)==null||b.call(u,"up",x()),w==null||w()},v=b=>{var j;if(b.buttons===0){C();return}(j=u.current)==null||j.call(u,"move",x())},S=()=>{var b;(b=u.current)==null||b.call(u,"down",x()),w==null||w(),window.addEventListener("pointermove",v),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),w=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C),w=null}};g.track.addEventListener("pointerdown",S),c.current=()=>{g.track.removeEventListener("pointerdown",S),w==null||w()}}}),[]);return k.useEffect(()=>()=>{var m;return(m=c.current)==null?void 0:m.call(c)},[]),s.jsx(a3,{ref:o,events:h,options:{overflow:{x:d?"scroll":"hidden",y:n?"scroll":t?"hidden":"scroll"},scrollbars:{autoHide:d?"leave":"move",autoHideDelay:d?1500:600,clickScroll:"instant"},update:{elementEvents:[[":scope","mouseenter"]]},...e},...a})});mt.displayName="ScrollArea";const d1=e=>{let t;const n=new Set,r=(h,m)=>{const f=typeof h=="function"?h(t):h;if(!Object.is(f,t)){const g=t;t=m??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(x=>x(t,g))}},a=()=>t,u={setState:r,getState:a,getInitialState:()=>c,subscribe:h=>(n.add(h),()=>n.delete(h))},c=t=e(r,a,u);return u},o3=(e=>e?d1(e):d1),l3=e=>e;function c3(e,t=l3){const n=ps.useSyncExternalStore(e.subscribe,ps.useCallback(()=>t(e.getState()),[e,t]),ps.useCallback(()=>t(e.getInitialState()),[e,t]));return ps.useDebugValue(n),n}const h1=e=>{const t=o3(e),n=r=>c3(t,r);return Object.assign(n,t),n},tr=(e=>e?h1(e):h1);function u3(){if(typeof document>"u")return"";const e=Array.from(document.scripts).find(a=>{const o=new URL(a.src,window.location.href).pathname;return o.includes("/assets/")||o.endsWith("/src/main.tsx")});if(!e)return"";const t=new URL(e.src,window.location.href).pathname,n=t.includes("/assets/")?"/assets/":"/src/",r=t.indexOf(n);return r>0?t.slice(0,r):""}const bE=u3();function _s(e){return e.startsWith("/")?`${bE}${e}`||"/":e}async function ye(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(_s(e),{...t,headers:r})}async function f1(e,t,n,r){try{return(await ye(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{content:n}:{},...r!==void 0?{attachments:r}:{}})})).ok}catch{return!1}}async function vE(e,t,n){try{const r=await ye(`/api/sessions/${e}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{title:n}:{}})});return r.ok?await r.json():null}catch{return null}}const je={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SYSTEM_THEME_PREFS:"display.systemThemePrefs",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",DISPLAY_SHOW_CHANGELOG_ON_UPDATE:"display.showChangelogOnUpdate",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",DISPLAY_CUSTOM_CSS:"display.customCss",DISPLAY_TERMINAL_FONT:"display.terminalFont",DISPLAY_USE_NATIVE_SCROLLBARS:"display.useNativeScrollbars",DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS:"display.useNativeScrollbarsCodeBlocks",DISPLAY_COLLAPSE_LARGE_TOOL_CALLS:"display.collapseLargeToolCalls",DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING:"display.deferCodeHighlightWhileStreaming",DISPLAY_FEED_VIRTUALIZATION:"display.feedVirtualization",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey",TOOLS_USE_RTK:"tools.useRtk",TOOLS_SHELL:"tools.shell",CONFIRM_ON_WORKSPACE_ACTIONS:"tools.confirmOnWorkspaceActions",FEATURES_PER_SESSION_MCP:"features.perSessionMcp",PROXY_URL:"network.proxyUrl",DEFAULT_AGENT:"agent.defaultAgent"};function nh(e,t){return n=>({loading:{...n.loading,[e]:t}})}function m1(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const vb=[je.DISPLAY_SHOW_THINKING,je.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,je.DISPLAY_SHOW_STATS,je.DISPLAY_SHOW_AGENT_DEFINITIONS,je.DISPLAY_SHOW_WORKFLOW_BARS,je.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,je.DISPLAY_FOLLOW_SYSTEM_THEME,je.DISPLAY_SHOW_OPEN_IN_EDITOR,je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,je.DISPLAY_MAX_VISIBLE_ITEMS,je.DISPLAY_TERMINAL_FONT,je.DISPLAY_USE_NATIVE_SCROLLBARS,je.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,je.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,je.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,je.DISPLAY_FEED_VIRTUALIZATION];function Hs(){return{showThinking:Bt(e=>e.settings[je.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Bt(e=>e.settings[je.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Bt(e=>e.settings[je.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Bt(e=>e.settings[je.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Bt(e=>e.settings[je.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Bt(e=>e.settings[je.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Bt(e=>e.settings[je.DISPLAY_MAX_VISIBLE_ITEMS]??"300")),useNativeScrollbars:Bt(e=>e.settings[je.DISPLAY_USE_NATIVE_SCROLLBARS]??"false")==="true",useNativeScrollbarsCodeBlocks:Bt(e=>e.settings[je.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS]??"false")==="true",collapseLargeToolCalls:Bt(e=>e.settings[je.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS]??"false")==="true",deferCodeHighlightWhileStreaming:Bt(e=>e.settings[je.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING]??"false")==="true",feedVirtualization:Bt(e=>e.settings[je.DISPLAY_FEED_VIRTUALIZATION]??"false")==="true"}}const Bt=tr(e=>({settings:{},loading:{},getSetting:async t=>{e(nh(t,!0));try{const r=await(await ye(`/api/settings/${t}`)).json();return e(m1(t,r.value??"")),r.value}catch{return e(nh(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await ye(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(a=>[a,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(nh(t,!0));try{const a=await(await ye(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(m1(t,a.value??""))}catch{e(nh(t,!1))}}})),Mc=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:vb,SETTINGS_KEYS:je,useDisplaySettings:Hs,useSettingsStore:Bt},Symbol.toStringTag,{value:"Module"}));function d3(){const[e,t]=k.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=k.useRef(window.innerHeight);return k.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const o=r.offsetTop,d=r.height,u=n.current-d>100;t({offsetTop:o,height:d,keyboardVisible:u})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}const p1=1e4,kl=new Map;function h3(){const e=Date.now();for(const[t,n]of kl)n.expiresAt<e&&kl.delete(t)}function f3(e){if(kl.has(e))return;const t=localStorage.getItem("openfox_token"),n=fetch(_s(`/api/sessions/${e}`),{headers:t?{"x-session-token":t}:void 0}).then(async r=>r.ok?{ok:!0,data:await r.json()}:{ok:!1}).catch(()=>({ok:!1}));kl.set(e,{promise:n,expiresAt:Date.now()+p1}),setTimeout(h3,p1)}function m3(e){const t=kl.get(e);if(t&&(kl.delete(e),!(t.expiresAt<Date.now())))return t.promise}function p3(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function $h(){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 g3{constructor(t){Te(this,"ws",null);Te(this,"handlers",new Set);Te(this,"statusHandler",null);Te(this,"baseUrl");Te(this,"isReconnecting",!1);Te(this,"connectingPromise",null);Te(this,"lastCloseCode",0);Te(this,"reconnectAttempts",0);Te(this,"manualReconnectScheduled",!1);Te(this,"pwaRecoveryAttempted",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,r;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,o)=>{try{const d=this.getUrl();this.ws=new WebSocket(d);const u=setTimeout(()=>{var c;((c=this.ws)==null?void 0:c.readyState)===WebSocket.CONNECTING&&(this.ws.close(),o(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var c;clearTimeout(u),this.isReconnecting=!1,this.reconnectAttempts=0,this.connectingPromise=null,(c=this.statusHandler)==null||c.call(this,"connected"),a()},this.ws.onclose=c=>{var h,m,f;clearTimeout(u),this.lastCloseCode=c.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),o(new Error(`Connection closed: ${c.code}`))):(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=c=>{clearTimeout(u),console.error("WebSocket error:",c),this.connectingPromise=null,o(c)},this.ws.onmessage=c=>{try{const h=JSON.parse(c.data);p3(h)&&this.handlers.forEach(m=>m(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(d){this.connectingPromise=null,o(d)}}),this.connectingPromise)))}async recoverPwaStuckConnection(){if(this.pwaRecoveryAttempted||!window.matchMedia("(display-mode: standalone)").matches||!("serviceWorker"in navigator))return;this.pwaRecoveryAttempted=!0;const n=await navigator.serviceWorker.getRegistrations();n.length!==0&&(console.warn("[WS] PWA mode detected with stale service worker — unregistering and reloading"),await Promise.all(n.map(r=>r.unregister())),window.location.reload())}attemptReconnect(){var r;if(this.lastCloseCode===4e3&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(r=this.statusHandler)==null||r.call(this,"reconnecting");const n=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{this.reconnectAttempts>=3&&this.recoverPwaStuckConnection()})},n)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{this.recoverPwaStuckConnection()})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const r=$h(),a={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(a)),r}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const x3=window.location.protocol==="https:"?"wss:":"ws:";let ly=window.location.port;ly||(ly=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const y3=`${x3}//${window.location.hostname}:${ly}${_s("/ws")}`,zt=new g3(y3),b3=3e4;function _E(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}let Ic=null;const an=tr((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,platform:null,workdir:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>Ic||(e({loading:!0,error:null}),Ic=(async()=>{try{const n=await ye("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json(),a=r.platform&&typeof r.platform=="object"?{isWSL:!!r.platform.isWSL,wslDistro:String(r.platform.wslDistro??"")}:null;e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,platform:a,workdir:r.workdir??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}finally{Ic=null}})(),Ic),refreshModel:async()=>{try{const n=await ye("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json();e({model:r.model,llmStatus:r.llmStatus,backend:r.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:r,providers:a}=t();if(n===r)return!0;e({activating:!0,error:null});try{const o=await ye(`/api/providers/${n}/activate`,{method:"POST"});if(!o.ok){const u=await o.json();throw new Error(u.error??"Failed to activate provider")}const d=await o.json();return e({activeProviderId:d.activeProviderId,model:d.model,backend:d.backend,providers:a.map(u=>({...u,isActive:u.id===d.activeProviderId})),activating:!1}),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,r)=>{const{providers:a}=t();try{const o=await ye("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!o.ok)return!1;const d=await o.json();return e({activeProviderId:n,model:r,defaultModelSelection:d.defaultModelSelection,providers:a.map(u=>({...u,isActive:u.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await ye(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const d=await r.json();throw new Error(d.error??"Failed to refresh models")}const a=await r.json(),{providers:o}=t();return e({providers:o.map(d=>d.id===n?{...d,models:a.models,status:a.status}:d),activating:!1}),!0}catch(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const a=setInterval(()=>{r()},b3);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(a=>a.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:a}=t(),o=r.find(u=>u.id===a);if(!o)return 2e5;const d=o.models.find(u=>u.id===n);return(d==null?void 0:d.contextWindow)??2e5}})),Pt=tr((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await ye("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const a=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!a.ok){const d=await a.json().catch(()=>({}));return{error:{code:d.code||"UNKNOWN",path:d.path,message:d.error}}}const o=await a.json();return await t().listProjects(),o.project}catch{return null}},loadProject:async n=>{try{const r=await ye(`/api/projects/${n}`);if(!r.ok)return null;const a=await r.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,r)=>{var a;try{const o=await ye(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)return null;const d=await o.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:d.project}),await t().listProjects(),d.project}catch{return null}},deleteProject:async n=>{var r;try{return(await ye(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var a;try{const o=await ye(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!o.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const d=await o.json();e({currentProject:d.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),ha=async(e,t,n)=>{try{const r=await ye(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"}}},Uf=async(e,t,n)=>{try{const r=await ye(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function SE(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let rh=[];const nu=tr()((e,t)=>{function n(){if(rh.length===0)return;const a=rh;rh=[],e(o=>{const d={...o.logs};for(const u of a){const c=d[u.processId]??[];d[u.processId]=[...c,{offset:c.length,content:u.content,timestamp:Date.now(),stream:u.stream}]}return{logs:d}})}const r=SE(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(o=>({processes:[...o.processes,a]})),updateProcess:(a,o)=>e(d=>({processes:d.processes.map(u=>u.id===a?{...u,...o}:u)})),removeProcess:a=>e(o=>({processes:o.processes.filter(d=>d.id!==a),logs:Object.fromEntries(Object.entries(o.logs).filter(([d])=>d!==a))})),stopProcess:async(a,o)=>{try{(await ye(`/api/sessions/${o}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,o,d)=>{rh.push({processId:a,stream:o,content:d}),r()},setLogs:(a,o)=>e(d=>({logs:{...d.logs,[a]:o}})),clearLogs:a=>e(o=>({logs:{...o.logs,[a]:[]}})),handleMessage:(a,o)=>{switch(a){case"backgroundProcess.started":{const{processId:d,name:u,command:c,cwd:h,pid:m,status:f}=o;e(g=>({processes:[...g.processes,{id:d,sessionId:"",name:u,command:c,cwd:h,pid:m,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const d=o.processId,u=o.stream,c=o.content;t().appendLog(d,u,c);break}case"backgroundProcess.exited":{const d=o.processId,u=o.exitCode;e(c=>({processes:c.processes.map(h=>h.id===d?{...h,status:"exited",exitCode:u}:h)}));break}case"backgroundProcess.removed":{const d=o.processId;t().removeProcess(d);break}}}}}),wE="/split-view",cy="openfox:split",CE="openfox:split:layout";function v3(){return typeof window>"u"?!1:window.location.pathname===wE}function kE(){const[e]=Fn();return e===wE}function _3(){return typeof localStorage>"u"?"columns":localStorage.getItem(CE)==="grid"?"grid":"columns"}function S3(e){typeof localStorage>"u"||localStorage.setItem(CE,e)}function w3(){if(typeof localStorage>"u")return null;const e=localStorage.getItem(cy);if(!e)return null;try{const t=JSON.parse(e);if(!Array.isArray(t.openSessionIds))return null;const n=t.openSessionIds.filter(Boolean),r=typeof t.focusedSessionId=="string"?t.focusedSessionId:null;return{openSessionIds:n,focusedSessionId:r}}catch{return null}}function C3(e){if(!(typeof localStorage>"u")){if(!e||e.openSessionIds.length===0){localStorage.removeItem(cy);return}localStorage.setItem(cy,JSON.stringify(e))}}const Vf="__default__",ef=new Map,fu=new Set;let eo=null,bi=null,bl=null,_b=0;const g1=16;function k3(e){eo=e}function ol(e=Vf){let t=ef.get(e);return t||(t={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]},ef.set(e,t)),t}function j3(e=Vf){ef.delete(e),fu.delete(e)}function E3(){bi!==null&&(bl==="raf"?cancelAnimationFrame(bi):clearTimeout(bi),bi=null,bl=null)}function qg(){bi=null,bl=null,_b=Date.now();for(const e of fu)eo==null||eo(e);fu.clear()}function Kg(e=Vf){if(fu.add(e),bi!==null)return;const t=Date.now()-_b;t>=g1?typeof document<"u"&&document.hidden?(bi=setTimeout(qg,0),bl="timeout"):(bi=requestAnimationFrame(qg),bl="raf"):(bi=setTimeout(qg,g1-t),bl="timeout")}function ia(e=Vf){_b=0,E3(),fu.delete(e),eo==null||eo(e);const t=ef.get(e);t&&(t.deltaContent.length>0||t.thinkingContent.length>0||t.toolOutput.length>0||(t.messageId=null,t.deltaContent="",t.thinkingContent="",t.toolOutput=[]))}const x1=2e3,N3=e=>e.length>x1?e.slice(-x1):e,jE={status:null,logs:[],config:null};let sh=[];const Yg=(e,t,n)=>({...e,[t]:n(e[t]??jE)}),ds=tr()((e,t)=>{function n(){if(sh.length===0)return;const c=sh;sh=[],e(h=>{let m=h.byWorkdir;const f=new Map;for(const g of c){const x=f.get(g.workdir)??[];x.push({stream:g.stream,content:g.content}),f.set(g.workdir,x)}for(const[g,x]of f)m=Yg(m,g,w=>({...w,logs:N3([...w.logs,...x])}));return{byWorkdir:m}})}const r=SE(n),a=(c,h)=>`/api/dev-server/${h}?workdir=${encodeURIComponent(c)}`,o=async(c,h,m,f)=>{if(c)try{const x=await(await ye(h,m)).json();e(w=>({byWorkdir:Yg(w.byWorkdir,c,f(x))}))}catch{}},d=c=>h=>({...h,status:c}),u=c=>h=>({...h,status:c,logs:[]});return{byWorkdir:{},fetchStatus:c=>o(c,a(c,""),void 0,d),fetchConfig:c=>o(c,a(c,"config"),void 0,h=>m=>({...m,config:h.config??null})),fetchLogs:c=>o(c,a(c,"logs"),void 0,h=>m=>({...m,logs:h.logs.map(f=>({stream:f.stream,content:f.content,...f.type?{type:f.type}:{}}))})),clearLogs:c=>o(c,a(c,"clear-logs"),{method:"POST"},()=>h=>({...h,logs:[]})),insertMarker:async c=>{if(c)try{await ye(a(c,"insert-marker"),{method:"POST"}),t().fetchLogs(c)}catch{}},start:c=>o(c,a(c,"start"),{method:"POST"},u),stop:c=>o(c,a(c,"stop"),{method:"POST"},d),restart:c=>o(c,a(c,"restart"),{method:"POST"},u),saveConfig:(c,h)=>c?o(c,a(c,"config"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},m=>f=>({...f,config:m.config??h})).then(()=>t().fetchStatus(c)):Promise.resolve(),handleMessage:c=>{switch(c.type){case"devServer.output":{const h=c.payload;sh.push({workdir:h.workdir,stream:h.stream,content:h.content}),r();break}case"devServer.state":{const h=c.payload;e(m=>({byWorkdir:Yg(m.byWorkdir,h.workdir,f=>{const g=f.status?{...f.status,state:h.state,errorMessage:h.errorMessage,...h.url!==void 0?{url:h.url}:{},...h.inspectProxyPort!==void 0?{inspectProxyPort:h.inspectProxyPort}:{}}:{state:h.state,url:h.url??null,hotReload:!1,config:null,errorMessage:h.errorMessage,inspectProxyPort:h.inspectProxyPort??null};return{...f,status:g}})}));break}}}}});function Sb(e){return ds(t=>(e?t.byWorkdir[e]:void 0)??jE)}const y1={open:0,todo:0,inProgress:0,running:0,queued:0,done:0};function T3(e,t,n){e(r=>({...n.tasks?{tasks:n.tasks}:{},...n.settings?{settings:n.settings}:{},...n.counts?{counts:n.counts}:{},...n.gates?{gates:n.gates}:{},activeProjectId:t,lastError:null}))}const Ht=tr((e,t)=>({tasks:[],settings:{slotLimit:1,queuePaused:!1},counts:y1,gates:[],summaries:{},loading:!1,activeProjectId:null,lastError:null,lastAutoLaunch:null,loadBoard:async n=>{e({loading:!0});try{const r=await ye(`/api/projects/${n}/tasks`);if(!r.ok){e({loading:!1});return}const a=await r.json();T3(e,n,a),e({loading:!1})}catch{e({loading:!1})}},loadCounts:async n=>{try{const r=await ye(`/api/projects/${n}/tasks/count`);if(!r.ok)return;const a=await r.json();e(o=>({counts:a.counts??o.counts,activeProjectId:n}))}catch{}},loadGates:async n=>{try{const r=await ye(`/api/projects/${n}/tasks/gates`);if(!r.ok)return;const a=await r.json();e({gates:a.gates??[]})}catch{}},loadSummaries:async n=>{await Promise.all(n.map(async r=>{try{const a=await ye(`/api/projects/${r}/tasks/count`);if(!a.ok)return;const o=await a.json(),d=o==null?void 0:o.counts;if(!d)return;const u=t().summaries[r];if(u&&Object.keys(d).every(c=>u[c]===d[c]))return;e(c=>({summaries:{...c.summaries,[r]:d}}))}catch{}}))},createTask:async(n,r)=>{try{const a=await ye(`/api/projects/${n}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),o=await a.json();return a.ok?(await t().loadBoard(n),o.task):(e({lastError:o.error??"Failed to create task"}),null)}catch{return e({lastError:"Failed to create task"}),null}},updateTask:async(n,r,a)=>{try{const o=await ye(`/api/projects/${n}/tasks/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),d=await o.json();return o.ok?(await t().loadBoard(n),d.task):(e({lastError:d.error??"Failed to update task"}),null)}catch{return e({lastError:"Failed to update task"}),null}},deleteTask:async(n,r)=>{try{return(await ye(`/api/projects/${n}/tasks/${r}`,{method:"DELETE"})).ok?(await t().loadBoard(n),!0):!1}catch{return!1}},duplicateTask:async(n,r)=>{try{const a=await ye(`/api/projects/${n}/tasks/${r}/duplicate`,{method:"POST"}),o=await a.json();return a.ok?(await t().loadBoard(n),o.task):null}catch{return null}},moveTask:async(n,r,a,o)=>{try{const d=await ye(`/api/projects/${n}/tasks/${r}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({to:a,...o!=null&&o.reason?{reason:o.reason}:{},...o!=null&&o.sessionId?{sessionId:o.sessionId}:{}})}),u=await d.json();return d.ok?(e({lastError:null}),u.autoLaunched&&e({lastAutoLaunch:u.autoLaunched}),await t().loadBoard(n),u):(e({lastError:u.error??"Failed to move task"}),null)}catch{return e({lastError:"Failed to move task"}),null}},setGateValue:async(n,r,a,o)=>{try{const d=await ye(`/api/projects/${n}/tasks/${r}/gate-values/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:o})}),u=await d.json();return d.ok?(await t().loadBoard(n),u.task):(e({lastError:u.error??"Failed to set gate value"}),null)}catch{return e({lastError:"Failed to set gate value"}),null}},setGateConfig:async(n,r)=>{try{return(await ye(`/api/projects/${n}/tasks/gates`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({gates:r})})).ok?(e({gates:r}),!0):!1}catch{return!1}},setSettings:async(n,r)=>{e(a=>a.activeProjectId===n?{settings:{...a.settings,...r}}:{});try{return!!(await ye(`/api/projects/${n}/tasks/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).ok}catch{return!1}},reorderTask:async(n,r,a,o)=>{try{return!!(await ye(`/api/projects/${n}/tasks/${r}/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:a,index:o})})).ok}catch{return!1}},clearBoard:()=>{e({tasks:[],gates:[],settings:{slotLimit:1,queuePaused:!1},counts:y1,activeProjectId:null})},clearAutoLaunch:()=>e({lastAutoLaunch:null}),handleTasksUpdate:n=>{n.counts&&e(r=>({summaries:{...r.summaries,[n.projectId]:n.counts}})),n.projectId===t().activeProjectId&&e(r=>({tasks:n.tasks??r.tasks,settings:n.settings??r.settings,counts:n.counts??r.counts,...n.gates?{gates:n.gates}:{},...n.autoLaunched?{lastAutoLaunch:n.autoLaunched}:{}}))}})),A3=[{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"}],L3=[{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"}],EE={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"},aa={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},NE={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},uy={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...aa},waiting_for_user:{...aa},phase_done:{...aa},phase_blocked:{...aa},new_message:{...NE}},agentOverrides:{}};function TE(e,t,n){var o;const r=e.events[t];if(!n)return r;const a=(o=e.agentOverrides[n])==null?void 0:o[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const Wa=tr((e,t)=>({settings:uy,loaded:!1,load:()=>{Bt.getState().getSetting(je.NOTIFICATION_SETTINGS);const r=Bt.subscribe(o=>{const d=o.settings[je.NOTIFICATION_SETTINGS];if(d!==void 0)try{const u=JSON.parse(d);e({settings:b1(u),loaded:!0})}catch{e({loaded:!0})}}),a=Bt.getState().settings[je.NOTIFICATION_SETTINGS];if(a)try{const o=JSON.parse(a);e({settings:b1(o),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Xg(n)},updateEvent:(n,r)=>{const a=t().settings,o={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:o}),Xg(o)},updateAgentOverride:(n,r,a)=>{var c;const o=t().settings,d={...o.agentOverrides};if(a===null){if(d[n]){const h={...d[n]};delete h[r],Object.keys(h).length===0?delete d[n]:d[n]=h}}else d[n]={...d[n],[r]:{...((c=d[n])==null?void 0:c[r])??{},...a}};const u={...o,agentOverrides:d};e({settings:u}),Xg(u)}}));function Xg(e){Bt.getState().setSetting(je.NOTIFICATION_SETTINGS,JSON.stringify(e))}function b1(e){var t,n,r,a,o;return{soundEnabled:e.soundEnabled??uy.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??uy.browserNotificationEnabled,events:{complete:{...aa,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...aa,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...aa,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...aa,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...NE,...(o=e.events)==null?void 0:o.new_message}},agentOverrides:e.agentOverrides??{}}}const v1=new Map;function R3(e){let t=v1.get(e);return t||(t=new Audio(_s(e)),t.volume=.5,v1.set(e,t)),t}let AE=typeof Notification<"u"?Notification.permission:"denied";function D3(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(AE=e,e))}const O3={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},M3={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 I3(e){typeof Notification>"u"||AE==="granted"&&(document.hasFocus()||new Notification(O3[e],{body:M3[e],icon:_s("/fox.svg"),tag:`openfox-${e}`}))}function Nu(e,t){const{settings:n}=Wa.getState(),r=TE(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??EE[e],o=R3(a);o.currentTime=0,o.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&I3(e)}const P3=e=>Nu("complete",e),B3=e=>Nu("phase_done",e),$3=e=>Nu("phase_blocked",e),Qg=e=>Nu("waiting_for_user",e),F3=e=>Nu("new_message",e),_1=new Map;function ll(e,t){var o;const n=t===((o=e.currentSession)==null?void 0:o.id)?e.currentSession:null,r=e.sessions.find(d=>d.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function z3(e,t){if(e.type==="chat.done"){const n=e.payload,r=ll(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&P3(a),n.reason==="waiting_for_user"&&Qg(a);return}if(e.type==="chat.path_confirmation"){const n=ll(t,e.sessionId);Qg(n);return}if(e.type==="session.confirmation_pending"){const n=ll(t,e.sessionId);Qg(n);return}if(e.type==="task.completed"){const n=ll(t,e.sessionId);B3(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=_1.get(e.sessionId)??null;if(_1.set(e.sessionId,n.phase),r===n.phase)return;const a=ll(t,e.sessionId);n.phase==="blocked"&&$3(a)}}const mu=tr(e=>({servers:[],setServers:t=>e({servers:t}),fetchServers:async()=>{try{const t=await ye("/api/mcp/servers");if(!t.ok)return;const r=((await t.json()).servers??[]).sort((a,o)=>a.name.localeCompare(o.name));e({servers:r})}catch{}}}));function pu(){return{session:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},queuedMessages:[],abortInProgress:!1,restoredInput:null,activeWorkflowExecution:null,gitStatus:null,error:null,llmRetry:null}}function ta(e){return{session:e.currentSession,messages:e.messages,hiddenCount:e.hiddenCount,currentTodos:e.currentTodos,contextState:e.contextState,subAgentContextStates:e.subAgentContextStates,pendingPathConfirmations:e.pendingPathConfirmations,pendingQuestions:e.pendingQuestions,visionFallbackByMessage:e.visionFallbackByMessage,queuedMessages:e.queuedMessages,abortInProgress:e.abortInProgress,restoredInput:e.restoredInput,activeWorkflowExecution:e.activeWorkflowExecution,gitStatus:e.gitStatus,error:e.error,llmRetry:e.llmRetry}}function vi(e){return{currentSession:e.session,messages:e.messages,hiddenCount:e.hiddenCount,currentTodos:e.currentTodos,contextState:e.contextState,subAgentContextStates:e.subAgentContextStates,pendingPathConfirmations:e.pendingPathConfirmations,pendingQuestions:e.pendingQuestions,visionFallbackByMessage:e.visionFallbackByMessage,queuedMessages:e.queuedMessages,abortInProgress:e.abortInProgress,restoredInput:e.restoredInput,activeWorkflowExecution:e.activeWorkflowExecution,gitStatus:e.gitStatus,error:e.error,llmRetry:e.llmRetry}}function Ps(e){var t;return e.focusedSessionId??((t=e.currentSession)==null?void 0:t.id)??null}function cr(e,t){return t?Ps(e)===t||e.panes[t]!==void 0:!1}function en(e,t,n){const r=e.panes[t],a=Ps(e)===t;if(!r){if(!a)return e;const u=n(ta(e));return{...e,panes:{...e.panes,[t]:u},...vi(u)}}const o=n(r),d={...e,panes:{...e.panes,[t]:o}};return a?{...d,...vi(o)}:d}function Fh(e,t,n){const r=Ps(e)===t,a={...e,panes:{...e.panes,[t]:n}};return r?{...a,...vi(n)}:a}function dy(e,t,n){return en(e,t,r=>r.session?{...r,session:n(r.session)}:r)}function S1(e,t){if(e.panes[t]===void 0&&e.openSessionIds.includes(t)===!1)return e;const n={...e.panes};delete n[t];const r=e.openSessionIds.filter(d=>d!==t);let a=e.focusedSessionId,o={};return e.focusedSessionId===t&&(a=r.length>0?r[r.length-1]:null,o=vi(a?n[a]??pu():pu())),{...e,panes:n,openSessionIds:r,focusedSessionId:a,...o}}const Jg=new Set;function H3(e,t){return e.includes(t)?e:[...e,t]}function w1(e,t){return e.filter(n=>n!==t)}function yn(e,t){const n=t.sessionId;n&&e(r=>({unreadSessionIds:H3(r.unreadSessionIds,n)}))}function U3(e,t){const n=e.find(o=>o.id===t.id),r=t.messageCount??0,a=n?{...n,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning,isFavorite:!1,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length,messageCount:r};return n?e.map(o=>o.id===t.id?a:o):[a,...e]}function ih(e,t){const n=e.findIndex(r=>r.callId===t.callId);if(n>=0){const r=[...e];return r[n]=t,r}return[...e,t]}function V3(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,o=t.find(d=>d.id===r.id);return{...r,title:r.title??(o==null?void 0:o.title),mode:(a==null?void 0:a.mode)??(o==null?void 0:o.mode)??r.mode,phase:(a==null?void 0:a.phase)??(o==null?void 0:o.phase)??r.phase,isRunning:r.isRunning&&(o==null?void 0:o.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function C1(e,t,n,r){const a=e.sessionId;if(!a)return;const o=n(),d=cr(o,a);t(u=>{let c={...u,sessions:u.sessions.map(h=>h.id===a?r(h):h)};return d&&(c=dy(c,a,h=>{const m=r(h);return{...h,...m}})),c})}function En(e,t,n,r){if(!n)return!1;const a=t();return cr(a,n)?(e(o=>en(o,n,r)),!0):!1}function Pc(e,t,n){var a,o;if(!n)return;const r=(a=t().panes)==null?void 0:a[n];((o=r==null?void 0:r.llmRetry)==null?void 0:o.status)==="retrying"&&En(e,t,n,d=>({...d,llmRetry:null}))}function k1(e,t,n){var o,d,u;const r=n();z3(e,r);const a=r.focusedSessionId??((o=r.currentSession)==null?void 0:o.id)??null;switch(e.type){case"session.state":{const c=e.payload,h=e.sessionId,m=n();if(!(e.id!==void 0||cr(m,h)||m.pendingSessionCreate===!0&&h!==void 0))break;const g=ol(h??"").messageId;ia(h??"");const x=n().pendingSessionCreate===!0,w=c.pendingConfirmations??[],C=c.session.id,v={...n().crossSessionConfirmations};delete v[C],t(S=>{const _=S.panes[C]??(Ps(S)===C?ta(S):pu()),b=c.messages.map(N=>{const L=_.messages.find(z=>z.id===N.id);if(N.id===g&&L)return L;if(!L)return N;const A=L.content??"",D=N.content??"",O=L.thinkingContent??"",F=N.thinkingContent??"";if(A.length<=D.length&&O.length<=F.length)return N;const P={...N};return A.length>D.length&&(P.content=A),O.length>F.length&&(P.thinkingContent=O),P}),j={..._,session:c.session,messages:b,hiddenCount:c.hiddenCount??0,currentTodos:[],pendingPathConfirmations:w,pendingQuestions:c.pendingQuestions??[],activeWorkflowExecution:c.activeWorkflowExecution??null,queuedMessages:_.queuedMessages,llmRetry:null},E=Fh(S,C,j);return{...E,sessions:U3(E.sessions,c.session),unreadSessionIds:w1(E.unreadSessionIds,C),crossSessionConfirmations:v,sessionsWithPendingConfirmations:Object.keys(v),...x?{pendingSessionCreate:C}:{}}});break}case"session.list":{const c=e.payload;t(h=>({sessions:V3(c.sessions,h.sessions,h.currentSession)}));break}case"session.created":{const c=e.payload;t(h=>({sessions:h.sessions.some(m=>m.id===c.session.id)?h.sessions.map(m=>m.id===c.session.id?{...m,...c.session}:m):[c.session,...h.sessions],searchSessions:null}));break}case"session.deleted":{const c=e.payload;t(h=>{const m={...h.panes};return delete m[c.sessionId],{panes:m,openSessionIds:h.openSessionIds.filter(f=>f!==c.sessionId),unreadSessionIds:w1(h.unreadSessionIds,c.sessionId),searchSessions:null}}),n().listSessions();break}case"session.deletedAll":{t({searchSessions:null}),n().listSessions();break}case"session.running":{const c=e.payload;C1(e,t,n,m=>({...m,isRunning:c.isRunning}));const h=e.sessionId;if(!h||!cr(n(),h))break;c.isRunning||t(m=>en(m,h,f=>({...f,abortInProgress:!1,queuedMessages:[]}))),c.isRunning&&t(m=>en(m,h,f=>({...f,restoredInput:null})));break}case"chat.message":{En(t,n,e.sessionId,c=>{const h=e.payload;if(c.messages.some(f=>f.id===h.message.id))return c;const m=h.message.role==="user";return{...c,messages:[...c.messages,h.message],session:c.session&&m?{...c.session,messageCount:(c.session.messageCount??0)+1}:c.session}})||(e.payload.message.role==="user"&&t(h=>({sessions:h.sessions.map(m=>m.id===e.sessionId?{...m,messageCount:m.messageCount+1}:m)})),yn(t,e));break}case"chat.message_updated":{const c=e.payload,h=e.sessionId,m=n().panes[h??""],f=(m==null?void 0:m.messages.find(x=>x.id===c.messageId))??(((d=n().currentSession)==null?void 0:d.id)===h?n().messages.find(x=>x.id===c.messageId):void 0);c.updates.isStreaming===!1&&(f==null?void 0:f.isStreaming)===!0&&ia(h??""),En(t,n,h,x=>({...x,messages:x.messages.map(w=>{if(w.id!==c.messageId)return w;const C={...w,...c.updates},v=C.content??"",S=w.content??"";return S.length>v.length&&(C.content=S),C})}))||yn(t,e);break}case"chat.delta":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>{if(c===a&&!Jg.has(h.messageId)){Jg.add(h.messageId);const g=h.subAgentType?"sub-agent":ll(n(),c);F3(g)}const f=ol(c??"");return f.messageId=h.messageId,f.deltaContent+=h.content,Kg(c??""),m})||yn(t,e),Pc(t,n,c);break}case"chat.thinking":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>{const f=ol(c??"");return f.messageId=h.messageId,f.thinkingContent+=h.content,Kg(c??""),m})||yn(t,e),Pc(t,n,c);break}case"chat.tool_preparing":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>{var v;const f=m.messages.find(S=>S.id===h.messageId);if(!f||((v=f.toolCalls)==null?void 0:v.find((S,_)=>_===h.index)))return m;const x=f.preparingToolCalls??[],w=x.findIndex(S=>S.index===h.index);let C;return w>=0?C=x.map((S,_)=>_===w?{...S,arguments:h.arguments}:S):C=[...x,{index:h.index,name:h.name,...h.arguments?{arguments:h.arguments}:{}}],{...m,messages:m.messages.map(S=>S.id===h.messageId?{...S,preparingToolCalls:C}:S)}})||yn(t,e),Pc(t,n,c);break}case"chat.tool_call":{const c=e.sessionId,h=e.payload,m=f=>{var v;const g=(f.toolCalls??[]).length,x=(v=f.preparingToolCalls)==null?void 0:v.filter(S=>S.index!==g),w=ol(c??""),C=w.toolOutput.filter(S=>S.callId===h.callId);return C.length>0&&(w.toolOutput=w.toolOutput.filter(S=>S.callId!==h.callId)),{...f,toolCalls:[...f.toolCalls??[],{id:h.callId,name:h.tool,arguments:h.args,startedAt:Date.now(),...C.length>0?{streamingOutput:C.map(S=>({stream:S.stream,content:S.content,timestamp:Date.now()}))}:{}}],...x&&x.length>0?{preparingToolCalls:x}:{preparingToolCalls:void 0}}};En(t,n,c,f=>({...f,messages:f.messages.map(g=>g.id===h.messageId?m(g):g)}))||yn(t,e),Pc(t,n,c);break}case"chat.tool_output":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>{const f=ol(c??"");return f.messageId=h.messageId,f.toolOutput.push({messageId:h.messageId,callId:h.callId,stream:h.stream,content:h.output}),Kg(c??""),m})||yn(t,e),Pc(t,n,c);break}case"chat.tool_result":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>({...m,messages:m.messages.map(f=>{var g;return f.id===h.messageId?{...f,toolCalls:(g=f.toolCalls)==null?void 0:g.map(x=>x.id===h.callId?{...x,result:h.result}:x)}:f})}))||yn(t,e);break}case"chat.vision_fallback":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>{const f=`${h.messageId}-${h.attachmentId}`,g={...m.visionFallbackByMessage};return g[f]={type:h.type,attachmentId:h.attachmentId,filename:h.filename,description:h.description},{...m,visionFallbackByMessage:g}})||yn(t,e);break}case"chat.todo":{const c=e.payload;En(t,n,e.sessionId,h=>({...h,currentTodos:c.todos}))||yn(t,e);break}case"chat.progress":{cr(n(),e.sessionId)||yn(t,e);break}case"chat.format_retry":{cr(n(),e.sessionId)||yn(t,e);break}case"chat.done":{const c=e.sessionId,h=e.payload;if(!cr(n(),c)){yn(t,e);break}ia(c??""),Jg.delete(h.messageId);const m=h.stats;t(f=>en(f,c??"",g=>({...g,messages:g.messages.map(x=>x.id===h.messageId?{...x,isStreaming:!1,stats:m??x.stats,completeReason:h.reason,preparingToolCalls:void 0}:x),visionFallbackByMessage:{},...h.reason!=="error"?{llmRetry:null}:{}})));break}case"chat.llm_retry":{const c=e.sessionId,h=e.payload;if(!cr(n(),c)){yn(t,e);break}En(t,n,c,m=>({...m,error:null,llmRetry:{status:"retrying",attempt:h.attempt,retryInMs:h.retryInMs}}));break}case"chat.llm_retry_failed":{const c=e.sessionId,h=e.payload;if(!cr(n(),c)){yn(t,e);break}En(t,n,c,m=>({...m,error:null,llmRetry:{status:"failed",error:h.error}}));break}case"chat.error":{const c=e.sessionId,h=e.payload;if(!cr(n(),c)){yn(t,e);break}ia(c??""),console.error("Chat error:",h.error,"recoverable:",h.recoverable),t(m=>en(m,c??"",f=>({...f,error:{code:"CHAT_ERROR",message:h.error}})));break}case"chat.path_confirmation":{const c=e.sessionId,h=e.payload,m={callId:h.callId,tool:h.tool,paths:h.paths,workdir:h.workdir,reason:h.reason};En(t,n,c,f=>({...f,pendingPathConfirmations:ih(f.pendingPathConfirmations,m)}))||(yn(t,e),c&&t(f=>({crossSessionConfirmations:{...f.crossSessionConfirmations,[c]:ih(f.crossSessionConfirmations[c]??[],m)},sessionsWithPendingConfirmations:f.sessionsWithPendingConfirmations.includes(c)?f.sessionsWithPendingConfirmations:[...f.sessionsWithPendingConfirmations,c]})));break}case"session.confirmation_pending":{const c=e.sessionId,h=e.payload,m={callId:h.callId,tool:h.tool,paths:h.paths,workdir:h.workdir,reason:h.reason};!En(t,n,c,f=>({...f,pendingPathConfirmations:ih(f.pendingPathConfirmations,m)}))&&c&&t(f=>({crossSessionConfirmations:{...f.crossSessionConfirmations,[c]:ih(f.crossSessionConfirmations[c]??[],m)},sessionsWithPendingConfirmations:f.sessionsWithPendingConfirmations.includes(c)?f.sessionsWithPendingConfirmations:[...f.sessionsWithPendingConfirmations,c]}));break}case"session.confirmation_resolved":{const c=e.sessionId,h=e.payload;c&&(t(m=>{const g=(m.crossSessionConfirmations[c]??[]).filter(w=>w.callId!==h.callId),x={...m.crossSessionConfirmations};return g.length===0?delete x[c]:x[c]=g,{crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x)}}),En(t,n,c,m=>({...m,pendingPathConfirmations:m.pendingPathConfirmations.filter(f=>f.callId!==h.callId)})));break}case"chat.ask_user":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>{const f={callId:h.callId,question:h.question,type:h.type??"text",options:h.options??void 0};return{...m,pendingQuestions:[...m.pendingQuestions.filter(g=>g.callId!==h.callId),f]}})||yn(t,e);break}case"mode.changed":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>m.session?{...m,session:{...m.session,mode:h.mode}}:m)||yn(t,e);break}case"phase.changed":{const c=e.payload;C1(e,t,n,h=>({...h,phase:c.phase}));break}case"workflow.execution_changed":{const c=e.sessionId,h=e.payload,m={...h.currentStepId?{currentStepId:h.currentStepId}:{},...h.currentStepName?{currentStepName:h.currentStepName}:{},...h.pendingChoices?{pendingChoices:h.pendingChoices}:{}};En(t,n,c,f=>{const g=f.activeWorkflowExecution;return g?{...f,activeWorkflowExecution:{...g,status:h.status,...m}}:{...f,activeWorkflowExecution:{id:h.executionId,sessionId:e.sessionId??"",workflowId:h.workflowId,workflowName:h.workflowName,...h.workflowColor?{workflowColor:h.workflowColor}:{},status:h.status,...m,stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}})||yn(t,e);break}case"criteria.updated":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>m.session?{...m,session:{...m.session,criteria:h.criteria}}:m)||yn(t,e);break}case"metadata.updated":{const c=e.sessionId,h=e.payload;En(t,n,c,m=>m.session?{...m,session:{...m.session,metadataEntries:{...m.session.metadataEntries,[h.key]:h.entries}}}:m)||yn(t,e);break}case"context.state":{const c=e.payload,h=e.sessionId,m=cr(n(),h);c.subAgentId?m&&h&&t(f=>en(f,h,g=>({...g,subAgentContextStates:{...g.subAgentContextStates,[c.subAgentId]:c.context}}))):m&&h?t(f=>en(f,h,g=>({...g,contextState:c.context}))):yn(t,e);break}case"session.name_generated":{const c=e.payload,h=e.sessionId,m=n().focusedSessionId??((u=n().currentSession)==null?void 0:u.id);t(f=>{var x;const g=h&&((x=f.panes[h])!=null&&x.session)?en(f,h,w=>({...w,session:{...w.session,metadata:{...w.session.metadata,title:c.name}}})):f;return{...g,sessions:g.sessions.map(w=>w.id===h?{...w,title:c.name}:w),currentSession:m===h&&g.currentSession?{...g.currentSession,metadata:{...g.currentSession.metadata,title:c.name}}:g.currentSession}});break}case"queue.state":{const c=e.payload,h=e.sessionId??Ps(n());h&&cr(n(),h)?t(m=>en(m,h,f=>({...f,queuedMessages:c.messages??[]}))):t({queuedMessages:c.messages??[]});break}case"mcp.servers.changed":{const c=e.payload;if(c!=null&&c.servers){const h=[...c.servers].sort((m,f)=>m.name.localeCompare(f.name));mu.getState().setServers(h)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const c=e.payload,h=e.sessionId??Ps(n());h&&cr(n(),h)?t(m=>en(m,h,f=>({...f,gitStatus:{branch:c.branch,diff:c.diff}}))):t({gitStatus:{branch:c.branch,diff:c.diff}});break}case"devServer.output":case"devServer.state":{ds.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{nu.getState().handleMessage(e.type,e.payload);break}case"tasks.update":{Ht.getState().handleTasksUpdate(e.payload);break}case"error":{const c=e.payload;console.error("Server error:",c);const h=e.sessionId??Ps(n());t(m=>h&&cr(m,h)?en(m,h,f=>({...f,error:{code:c.code,message:c.message}})):{error:{code:c.code,message:c.message}});break}}}let Bc=!1,Ts=null;const Zg=new Set,Qo=new Set,ah=new Map;let $c=null;function W3(e,t,n){return e==null?void 0:e.map(r=>{const a=t.filter(o=>o.callId===r.id);return a.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...a.map(o=>({stream:o.stream,content:o.content,timestamp:Date.now()}))]})})}function j1(e,t){return e.includes(t)?e:[...e,t]}async function E1(e,t,n,r,a){try{const d=await(await ye(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();d.queueState&&a(u=>en(u,e,c=>({...c,queuedMessages:d.queueState})))}catch(o){console.error("Error queueing message:",o)}}function N1(e,t){return e.map(n=>{const r=t.sessions.find(d=>d.id===n.id),a=t.panes[n.id],o=a==null?void 0:a.session;return{...n,title:n.title??(r==null?void 0:r.title),mode:(o==null?void 0:o.id)===n.id?o.mode:(r==null?void 0:r.mode)??n.mode,phase:(o==null?void 0:o.id)===n.id?o.phase:(r==null?void 0:r.phase)??n.phase,isRunning:n.isRunning&&(r==null?void 0:r.isRunning)!==!1,messageCount:n.messageCount,...n.recentUserPrompts!==void 0&&{recentUserPrompts:n.recentUserPrompts}}})}function Jn(e,t){var r;const n=e.panes[t];return n||(((r=e.currentSession)==null?void 0:r.id)===t?ta(e):null)}const Le=tr((e,t)=>{const n=()=>{const o=t();C3({openSessionIds:o.openSessionIds,focusedSessionId:o.focusedSessionId})};k3(o=>{const d=ol(o);if(!d.messageId)return;const u=d.deltaContent.length>0,c=d.thinkingContent.length>0,h=d.toolOutput.length>0;!u&&!c&&!h||e(m=>cr(m,o)?en(m,o,f=>{const g=f.messages.find(C=>C.id===d.messageId);if(!g)return f;const x={...g};let w=!1;if(u&&(x.content=x.content+d.deltaContent,d.deltaContent="",w=!0),c&&(x.thinkingContent=(x.thinkingContent??"")+d.thinkingContent,d.thinkingContent="",w=!0),h){const C=new Set;x.toolCalls=W3(x.toolCalls,d.toolOutput,C);const v=d.toolOutput.filter(S=>!C.has(S.callId));d.toolOutput=v,w=!0}return w?{...f,messages:f.messages.map(C=>C.id===d.messageId?x:C)}:f}):m)});function r(o,d,u,c,h,m){return{sessionId:d,workflowId:o.workflowId,resumeFrom:o.currentStepId,stepOutput:o.stepOutput,...o.params&&Object.keys(o.params).length>0?{params:o.params}:{},...o.subGroup?{subGroup:o.subGroup}:{},...m?{userChoice:m}:{},...u!=null&&u.trim()?{content:u}:{},...c&&c.length>0?{attachments:c}:{},...h?{messageKind:h}:{}}}async function a(o,d,u=!1){var c,h;if(!(!u&&Zg.has(o))){if(!u&&Qo.has(o)){d&&e(m=>{var g;const f=m.panes[o]??(((g=m.currentSession)==null?void 0:g.id)===o?ta(m):null);return f?{focusedSessionId:o,...vi(f),unreadSessionIds:m.unreadSessionIds.filter(x=>x!==o)}:m});return}Zg.add(o);try{const m=t(),f=Ps(m),g=f!==null&&f!==o,x={...m.crossSessionConfirmations};if(g&&f){const j=((c=m.panes[f])==null?void 0:c.pendingPathConfirmations)??m.pendingPathConfirmations;j.length>0&&(x[f]=[...x[f]??[],...j])}e(j=>{const E=j.panes[o],N=E??(Ps(j)===o?ta(j):pu()),L=d&&g&&!E;return{focusedSessionId:d?o:j.focusedSessionId,panes:{...j.panes,[o]:N},...d?vi(L?pu():N):{},unreadSessionIds:j.unreadSessionIds.filter(A=>A!==o),crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x),llmRetry:null,pendingSessionCreate:!1}}),g&&f&&ia(f);const w=m3(o),C=w?w.then(async j=>{if(j.ok)return j.data;const E=await ye(`/api/sessions/${o}`);return E.ok?await E.json():null}):ye(`/api/sessions/${o}`).then(async j=>j.ok?await j.json():null),v=ye(`/api/sessions/${o}/background-processes`),S=await C;if(!S){((h=t().panes[o])==null?void 0:h.session)==null&&(e(j=>S1(j,o)),n());return}const _=S.messages??[],b={...t().crossSessionConfirmations};delete b[o],e(j=>{const N={...j.panes[o]??ta(j),session:S.session,messages:_,hiddenCount:S.hiddenCount??0,contextState:S.contextState??null,queuedMessages:S.queueState??[],pendingPathConfirmations:S.pendingConfirmations??[],pendingQuestions:S.pendingQuestions??[],activeWorkflowExecution:S.activeWorkflowExecution??null,llmRetry:null};return{...Fh(j,o,N),crossSessionConfirmations:b,sessionsWithPendingConfirmations:Object.keys(b)}}),zt.send("session.load",{sessionId:o});try{const j=await v;if(j.ok){const E=await j.json();nu.getState().setProcesses(E.processes??[])}}catch{}Qo.add(o)}catch{}finally{Zg.delete(o)}}}return{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],searchSessions:null,currentSession:null,unreadSessionIds:[],messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],crossSessionConfirmations:{},sessionsWithPendingConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,activeWorkflowExecution:null,llmRetry:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,pendingUpdate:null,panes:{},openSessionIds:[],focusedSessionId:null,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let d=!1;try{d=(await(await ye("/api/auth")).json()).requiresAuth}catch{}if(d&&!zt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}zt.onStatusChange(u=>{var c,h;if(e({connectionStatus:u}),u==="connected"){if(v3())t().listHomeSessions();else{const f=(c=t().currentSession)==null?void 0:c.projectId;f&&t().listSessions(f)}Pt.getState().listProjects();const m=t().focusedSessionId??((h=t().currentSession)==null?void 0:h.id);m&&t().loadSession(m)}else(u==="disconnected"||u==="reconnecting")&&Qo.clear()});try{await zt.connect(),Bc||(Bc=!0,Ts=zt.subscribe(u=>{k1(u,e,t)}))}catch(u){console.error("Failed to connect:",u);const c=zt.getLastCloseCode();if(!zt.hasToken()&&(c===1006||c===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Ts&&(Ts(),Ts=null),Bc=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{zt.disconnect(),Ts&&(Ts(),Ts=null),Bc=!1,Qo.clear(),e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{zt.disconnect(),Ts&&(Ts(),Ts=null),Bc=!1,Qo.clear(),e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async o=>{try{const d=await fetch(_s("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:o})});if(!d.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:u}=await d.json();zt.setToken(u),e({showPasswordModal:!1}),t().connect();const{listProjects:c}=Pt.getState(),{fetchConfig:h}=an.getState();c(),h(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{zt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(o,d)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const c=await ye("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:o,title:d})});if(!c.ok)return e({pendingSessionCreate:!1}),null;const h=await c.json();e({searchSessions:null});try{zt.send("session.load",{sessionId:h.session.id})}catch{}return h.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async(o,d=!1)=>{await a(o,!0,d)},openPane:async(o,d={})=>{const u=d.focus??!1;e(c=>({openSessionIds:j1(c.openSessionIds,o)})),await a(o,u),u&&t().focusPane(o),n()},closePane:o=>{ia(o),j3(o),e(d=>S1(d,o)),n()},focusPane:o=>{e(d=>{var c;if(Ps(d)===o)return d;const u=d.panes[o]??(((c=d.currentSession)==null?void 0:c.id)===o?ta(d):null);return u?{...d,focusedSessionId:o,openSessionIds:j1(d.openSessionIds,o),...vi(u)}:d}),n()},reorderPane:(o,d)=>{e(u=>{const c=u.openSessionIds.indexOf(o);if(c===-1)return u;const h=c+d;if(h<0||h>=u.openSessionIds.length)return u;const m=[...u.openSessionIds],[f,g]=[m[c],m[h]];return m[c]=g,m[h]=f,{...u,openSessionIds:m}}),n()},isPaneOpen:o=>{const d=t();return d.openSessionIds.includes(o)||d.panes[o]!==void 0},enterSplitView:async(o,d)=>{const u=o.filter(Boolean);if(u.length===0)return;t().listHomeSessions();const c=u.filter(m=>!t().panes[m]);await Promise.all(c.map(m=>t().openPane(m,{focus:!1})));const h=d&&u.includes(d)?d:u[0];e(m=>{const f=[...new Set([...m.openSessionIds,...u])],g=m.panes[h]??null;return{openSessionIds:f,focusedSessionId:h,...g?vi(g):{},unreadSessionIds:m.unreadSessionIds.filter(x=>x!==h)}}),n()},exitSplitView:()=>{n()},listSessions:async(o,d=20)=>{const u=o??"global";if(ah.has(u))return ah.get(u);const c=(async()=>{var h;try{const m=new URLSearchParams;m.set("limit",String(d)),o&&m.set("projectId",o);const g=await(await ye(`/api/sessions?${m.toString()}`)).json(),x=g.sessions??[];e(C=>({sessions:N1(x,C),sessionsHasMore:o?g.hasMore??!1:!0}));const w=g.pendingConfirmationsBySession;if(w){const C=t().focusedSessionId??((h=t().currentSession)==null?void 0:h.id),v={};for(const[S,_]of Object.entries(w))S!==C&&(v[S]=_);e({crossSessionConfirmations:v,sessionsWithPendingConfirmations:Object.keys(v)})}}catch{}finally{ah.delete(u)}})();return ah.set(u,c),c},listHomeSessions:async()=>{try{const o=await ye("/api/sessions/home");if(!o.ok)return;const d=await o.json();e(u=>({sessions:N1(d.sessions,u),sessionsHasMore:!1}))}catch{}},ensureFullSessionList:async()=>{if(!t().searchSessions)return $c||($c=(async()=>{try{const u=(await(await ye("/api/sessions")).json()).sessions??[];e({searchSessions:u})}catch{}finally{$c=null}})(),$c)},loadMoreSessions:async o=>{const d=t();if(!(d.sessionsPaginationLoading||!d.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const u=new URLSearchParams;u.set("limit","20"),u.set("offset",String(d.sessions.length)),u.set("projectId",o);const h=await(await ye(`/api/sessions?${u.toString()}`)).json(),m=h.sessions??[];e(f=>({sessions:[...f.sessions,...m.map(g=>{const x=f.sessions.find(w=>w.id===g.id);return(x==null?void 0:x.isRunning)===!1?{...g,isRunning:!1}:g})],sessionsHasMore:h.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async o=>{var d;try{return(await ye(`/api/sessions/${o}`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),(t().focusedSessionId===o||((d=t().currentSession)==null?void 0:d.id)===o)&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(o,d)=>{try{return(await ye(`/api/sessions/${o}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:d})})).ok?(e({searchSessions:null}),await t().listSessions(),e(c=>{const h=c.panes[o];if(!h)return{};const m=h.session?{...h.session,metadata:{...h.session.metadata,title:d}}:h.session;return{...Fh(c,o,{...h,session:m})}}),!0):!1}catch{return!1}},toggleFavorite:async(o,d)=>{e(u=>({sessions:u.sessions.map(c=>c.id===o?{...c,isFavorite:d}:c)}));try{const u=await ye(`/api/sessions/${o}/favorite`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isFavorite:d})});return u.ok?(await t().listSessions(),!0):(console.warn("Failed to toggle favorite",{sessionId:o,isFavorite:d,status:u.status}),e(c=>({sessions:c.sessions.map(h=>h.id===o?{...h,isFavorite:!d}:h)})),!1)}catch(u){return console.error("Error toggling favorite:",u),e(c=>({sessions:c.sessions.map(h=>h.id===o?{...h,isFavorite:!d}:h)})),!1}},deleteAllSessions:async o=>{try{return(await ye(`/api/projects/${o}/sessions`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{var d;const o=t().focusedSessionId??((d=t().currentSession)==null?void 0:d.id);o&&ia(o),Qo.clear(),e(u=>{const c={...u.panes};return o&&delete c[o],{currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,focusedSessionId:null,panes:c,openSessionIds:u.openSessionIds.filter(h=>h!==o),unreadSessionIds:o?u.unreadSessionIds.filter(h=>h!==o):u.unreadSessionIds}})},sendMessage:async(o,d,u,c)=>{const h=Jn(t(),o);if(!(h!=null&&h.session))return;e(f=>en(f,o,g=>({...g,error:null})));const m=h.activeWorkflowExecution;if(m&&m.status==="running"){zt.send("runner.launch",r(m,o,d,u,c==null?void 0:c.messageKind));return}try{const f=d==null?void 0:d.trim(),g=u&&u.length>0,x={};f&&(x.content=d),g&&(x.attachments=u),c!=null&&c.messageKind&&(x.messageKind=c.messageKind);const C=await(await ye(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)})).json();C.queueState&&e(v=>en(v,o,S=>({...S,queuedMessages:C.queueState})))}catch(f){console.error("Error sending message:",f)}},stopGeneration:async o=>{var d,u;if((d=Jn(t(),o))!=null&&d.session&&!((u=t().panes[o])!=null&&u.abortInProgress)){ia(o),e(c=>en(c,o,h=>({...h,abortInProgress:!0})));try{const h=await(await ye(`/api/sessions/${o}/stop`,{method:"POST"})).json();if(h.queuedMessages&&h.queuedMessages.length>0){const m=h.queuedMessages.map(f=>f.content).join(`
67
+ `);e(f=>en(f,o,g=>({...g,restoredInput:m})))}}catch(c){console.error("Error stopping generation:",c)}}},continueGeneration:async o=>{var d;if((d=Jn(t(),o))!=null&&d.session)try{await ye(`/api/sessions/${o}/continue`,{method:"POST"})}catch(u){console.error("Error continuing generation:",u)}},launchWorkflow:(o,d,u,c,h,m,f)=>{var x;if(!((x=Jn(t(),o))!=null&&x.session))return;const g={sessionId:o};d!=null&&d.trim()&&(g.content=d),u&&u.length>0&&(g.attachments=u),c&&(g.workflowId=c),h&&(g.subGroup=h),m&&(g.params=m),g.scope=f??"auto",zt.send("runner.launch",g)},continueWorkflow:(o,d)=>{const u=Jn(t(),o),c=u==null?void 0:u.activeWorkflowExecution;!c||c.status!=="waiting"||zt.send("runner.launch",r(c,o,void 0,void 0,void 0,d))},retryLLMNow:o=>{zt.send("chat.llm_retry_now",{sessionId:o}),e(d=>en(d,o,u=>({...u,llmRetry:null})))},retryLLM:o=>{var c;const d=Jn(t(),o);e(h=>en(h,o,m=>({...m,llmRetry:null,error:null})));const u=d==null?void 0:d.activeWorkflowExecution;if(u&&u.status==="blocked"&&u.currentStepId&&!((c=d==null?void 0:d.session)!=null&&c.isRunning)){zt.send("runner.launch",r(u,o,void 0,void 0,void 0));return}zt.send("chat.retry",{sessionId:o})},exitWorkflow:o=>{var d;(d=Jn(t(),o))!=null&&d.session&&zt.send("workflow.exit",{sessionId:o})},switchMode:async(o,d)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const c=await ye(`/api/sessions/${o}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:d})});if(!c.ok){console.error("Failed to switch mode:",await c.json());return}const h=await c.json();h.session&&e(m=>dy(m,o,()=>h.session)),h.messages&&e(m=>en(m,o,f=>({...f,messages:h.messages,hiddenCount:h.hiddenCount??0})))}catch(c){console.error("Error switching mode:",c)}},switchDangerLevel:async(o,d)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const c=await ye(`/api/sessions/${o}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:d})});if(!c.ok){console.error("Failed to switch danger level:",await c.json());return}const h=await c.json();h.session&&e(m=>dy(m,o,()=>h.session))}catch(c){console.error("Error switching danger level:",c)}},editCriteria:async(o,d)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const c=await ye(`/api/sessions/${o}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:d})});c.ok||console.error("Failed to update criteria:",await c.json())}catch(c){console.error("Error updating criteria:",c)}},compactContext:o=>{var d;(d=Jn(t(),o))!=null&&d.session&&zt.send("context.compact",{sessionId:o})},setSessionProvider:async(o,d,u)=>{var c;try{if(!((c=Jn(t(),o))!=null&&c.session))return null;const h=await ye(`/api/sessions/${o}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:d,...u?{model:u}:{}})});if(!h.ok)return null;const m=await h.json();return e(f=>{const g=f.panes[o]??ta(f),x={...g,session:m.session,messages:m.messages??g.messages,hiddenCount:m.hiddenCount??g.hiddenCount,contextState:m.contextState??g.contextState};return Fh(f,o,x)}),m.session}catch{return null}},updateContextState:o=>{var u;const d=t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);d&&e(c=>en(c,d,h=>({...h,contextState:o})))},updateSubAgentContextState:(o,d)=>{var c;const u=t().focusedSessionId??((c=t().currentSession)==null?void 0:c.id);u&&e(h=>en(h,u,m=>({...m,subAgentContextStates:{...m.subAgentContextStates,[o]:d}})))},clearSubAgentContextState:o=>{var u;const d=t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);d&&e(c=>en(c,d,h=>{const m={...h.subAgentContextStates};return delete m[o],{...h,subAgentContextStates:m}}))},confirmPath:async(o,d,u,c=!1)=>{var h;if((h=Jn(t(),o))!=null&&h.session)try{const m=await ye(`/api/sessions/${o}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:d,approved:u,alwaysAllow:c})});if(!m.ok){const f=await m.json().catch(()=>({}));console.error("Error confirming path:",f.error??`HTTP ${m.status}`)}}catch(m){console.error("Error confirming path:",m)}},answerQuestion:async(o,d,u,c)=>{var h;if((h=Jn(t(),o))!=null&&h.session){try{await ye(`/api/sessions/${o}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:d,answer:u,skip:c})})}catch(m){console.error("Error answering question:",m)}e(m=>en(m,o,f=>({...f,pendingQuestions:f.pendingQuestions.filter(g=>g.callId!==d)})))}},queueAsap:async(o,d,u,c)=>{var h;(h=Jn(t(),o))!=null&&h.session&&await E1(o,d,u,c,e)},queueCompletion:async(o,d,u,c)=>{var h;(h=Jn(t(),o))!=null&&h.session&&await E1(o,d,u,c,e)},cancelQueued:async(o,d)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const h=await(await ye(`/api/sessions/${o}/queue/${d}`,{method:"DELETE"})).json();h.queueState&&e(m=>en(m,o,f=>({...f,queuedMessages:h.queueState})))}catch(c){console.error("Error canceling queued message:",c)}},clearError:()=>{var d;const o=t().focusedSessionId??((d=t().currentSession)==null?void 0:d.id);o&&e(u=>en(u,o,c=>({...c,error:null})))},clearRestoredInput:o=>{var u;const d=o??t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);d&&e(c=>en(c,d,h=>({...h,restoredInput:null})))},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:o=>{e({pendingUpdate:o})},triggerPendingUpdate:()=>{const o=t().pendingUpdate;o&&(e({pendingUpdate:null}),zt.send("context.applyDynamic",{sessionId:o}))},handleServerMessage:o=>{k1(o,e,t)}}}),oh=[],lh=[];function Wf(e){return Le(t=>{var n,r,a,o,d,u;return e?(n=t.panes)!=null&&n[e]?((o=(a=(r=t.panes)==null?void 0:r[e])==null?void 0:a.session)==null?void 0:o.isRunning)??!1:((d=t.currentSession)==null?void 0:d.id)===e?t.currentSession.isRunning??!1:!1:((u=t.currentSession)==null?void 0:u.isRunning)??!1})}function G3(e){return Le(t=>{var n,r;if(e){const a=(n=t.panes)==null?void 0:n[e];return a?a.queuedMessages??oh:((r=t.currentSession)==null?void 0:r.id)===e?t.queuedMessages??oh:oh}return t.queuedMessages??oh})}function q3(e){return Le(t=>{var n,r;if(e){const a=(n=t.panes)==null?void 0:n[e];return a?a.pendingQuestions??lh:((r=t.currentSession)==null?void 0:r.id)===e?t.pendingQuestions??lh:lh}return t.pendingQuestions??lh})}function K3(){const e=Le(a=>a.connect),t=Le(a=>a.connectionStatus),n=Wa(a=>a.load),r=Ol("/p/:projectId/s/:sessionId/readonly")[0];return k.useEffect(()=>{r||e()},[e,r]),k.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const Y3="modulepreload",X3=function(e){return"/"+e},T1={},ae=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),c=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=d(n.map(h=>{if(h=X3(h),h in T1)return;T1[h]=!0;const m=h.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${f}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":Y3,m||(g.as="script"),g.crossOrigin="",g.href=h,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((x,w)=>{g.addEventListener("load",x),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(d){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=d,window.dispatchEvent(u),!u.defaultPrevented)throw d}return a.then(d=>{for(const u of d||[])u.status==="rejected"&&o(u.reason);return t().catch(o)})},Q3=[{key:"color-bg-primary",category:"background",label:"Primary Background",defaultValue:"13 17 23"},{key:"color-bg-secondary",category:"background",label:"Secondary Background",defaultValue:"22 27 34"},{key:"color-bg-tertiary",category:"background",label:"Tertiary Background",defaultValue:"33 38 45"},{key:"color-primary",category:"surface",label:"Primary Surface",defaultValue:"10 10 10"},{key:"color-secondary",category:"surface",label:"Secondary Surface",defaultValue:"20 20 20"},{key:"color-text-primary",category:"text",label:"Primary Text",defaultValue:"139 148 158"},{key:"color-text-secondary",category:"text",label:"Secondary Text",defaultValue:"139 148 158"},{key:"color-text-muted",category:"text",label:"Muted Text",defaultValue:"72 79 88"},{key:"color-accent-primary",category:"accent",label:"Primary Accent",defaultValue:"88 166 255"},{key:"color-accent-success",category:"accent",label:"Success Accent",defaultValue:"63 185 80"},{key:"color-accent-warning",category:"accent",label:"Warning Accent",defaultValue:"210 153 34"},{key:"color-accent-error",category:"accent",label:"Error Accent",defaultValue:"248 81 73"},{key:"color-border",category:"border",label:"Border",defaultValue:"48 53 60"},{key:"color-text-heading",category:"text",label:"Heading Text",defaultValue:"56 189 248"},{key:"color-text-bold",category:"text",label:"Bold Text",defaultValue:"251 191 36"},{key:"color-text-code",category:"text",label:"Inline Code Text",defaultValue:"88 166 255"},{key:"color-text-link",category:"text",label:"Link Text",defaultValue:"88 166 255"},{key:"color-bg-system",category:"background",label:"System Message Background",defaultValue:"40 35 28"},{key:"color-border-system",category:"border",label:"System Message Border",defaultValue:"65 55 25"},{key:"color-text-system",category:"text",label:"System Message Text",defaultValue:"253 230 138"},{key:"color-text-thinking",category:"text",label:"Thinking Label",defaultValue:"192 132 252"},{key:"color-text-truncated",category:"text",label:"Truncation Warning",defaultValue:"251 191 36"},{key:"color-text-tool-error",category:"text",label:"Tool Error Text",defaultValue:"248 81 73"}],J3=JSON.parse('[{"id":"system","name":"System","tokens":{}},{"id":"dark","name":"Dark","tokens":{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"255 255 255","color-text-link":"88 166 255","color-bg-system":"40 35 28","color-border-system":"65 55 25","color-text-system":"253 230 138","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"light","name":"Light","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225","color-text-heading":"2 132 199","color-text-bold":"217 119 6","color-text-code":"37 99 235","color-text-link":"37 99 235","color-bg-system":"254 243 199","color-border-system":"252 211 77","color-text-system":"146 100 30","color-text-thinking":"147 51 234","color-text-truncated":"217 119 6","color-text-tool-error":"220 38 38"},"mode":"light"},{"id":"monokai","name":"Monokai","tokens":{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"248 248 242","color-text-link":"102 217 239","color-bg-system":"62 57 40","color-border-system":"85 75 40","color-text-system":"230 219 116","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"dracula","name":"Dracula","tokens":{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90","color-text-heading":"189 147 249","color-text-bold":"255 184 108","color-text-code":"189 147 249","color-text-link":"189 147 249","color-bg-system":"68 64 50","color-border-system":"90 80 60","color-text-system":"255 184 108","color-text-thinking":"255 121 198","color-text-truncated":"255 184 108","color-text-tool-error":"255 85 85"},"mode":"dark"},{"id":"nord","name":"Nord","tokens":{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"121 133 160","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"121 133 160","color-text-heading":"129 161 193","color-text-bold":"235 203 139","color-text-code":"129 161 193","color-text-link":"129 161 193","color-bg-system":"67 62 50","color-border-system":"85 80 60","color-text-system":"235 203 139","color-text-thinking":"184 142 173","color-text-truncated":"235 203 139","color-text-tool-error":"191 97 106"},"mode":"dark"},{"id":"rose-pine-dawn","name":"Rose Pine Dawn","tokens":{"color-bg-primary":"250 244 237","color-bg-secondary":"244 237 228","color-bg-tertiary":"235 226 216","color-primary":"250 244 237","color-secondary":"244 237 228","color-text-primary":"87 82 95","color-text-secondary":"111 105 120","color-text-muted":"175 170 180","color-accent-primary":"215 130 126","color-accent-success":"104 157 153","color-accent-warning":"234 157 84","color-accent-error":"215 85 112","color-border":"230 218 206","color-text-heading":"215 130 126","color-text-bold":"234 157 84","color-text-code":"145 117 186","color-text-link":"215 130 126","color-bg-system":"244 237 228","color-border-system":"230 218 206","color-text-system":"162 137 123","color-text-thinking":"145 117 186","color-text-truncated":"234 157 84","color-text-tool-error":"215 85 112"},"mode":"light"},{"id":"everforest-light","name":"Everforest Light","tokens":{"color-bg-primary":"255 248 235","color-bg-secondary":"245 238 220","color-bg-tertiary":"237 228 208","color-primary":"255 248 235","color-secondary":"245 238 220","color-text-primary":"91 105 86","color-text-secondary":"127 139 116","color-text-muted":"179 181 158","color-accent-primary":"100 153 117","color-accent-success":"141 169 73","color-accent-warning":"224 146 66","color-accent-error":"203 97 80","color-border":"230 216 194","color-text-heading":"100 153 117","color-text-bold":"224 146 66","color-text-code":"146 131 176","color-text-link":"100 153 117","color-bg-system":"245 238 220","color-border-system":"230 216 194","color-text-system":"163 147 121","color-text-thinking":"146 131 176","color-text-truncated":"224 146 66","color-text-tool-error":"203 97 80"},"mode":"light"},{"id":"synthwave-84","name":"Synthwave-84","tokens":{"color-bg-primary":"13 15 26","color-bg-secondary":"20 24 41","color-bg-tertiary":"26 31 51","color-primary":"10 12 20","color-secondary":"20 24 41","color-text-primary":"212 230 255","color-text-secondary":"136 153 187","color-text-muted":"68 85 119","color-accent-primary":"0 229 255","color-accent-success":"0 255 65","color-accent-warning":"255 106 0","color-accent-error":"255 0 60","color-border":"26 51 102","color-text-heading":"0 229 255","color-text-bold":"255 140 0","color-text-code":"0 255 170","color-text-link":"0 229 255","color-bg-system":"26 20 10","color-border-system":"51 40 20","color-text-system":"255 170 80","color-text-thinking":"191 0 255","color-text-truncated":"255 140 0","color-text-tool-error":"255 0 60"},"mode":"dark"},{"id":"one-dark-pro","name":"One Dark Pro","tokens":{"color-bg-primary":"40 44 52","color-bg-secondary":"33 37 43","color-bg-tertiary":"47 52 62","color-primary":"28 31 37","color-secondary":"33 37 43","color-text-primary":"171 178 191","color-text-secondary":"150 155 168","color-text-muted":"92 99 112","color-accent-primary":"97 175 239","color-accent-success":"152 195 121","color-accent-warning":"209 154 102","color-accent-error":"224 108 117","color-border":"57 62 72","color-text-heading":"97 175 239","color-text-bold":"209 154 102","color-text-code":"198 120 221","color-text-link":"97 175 239","color-bg-system":"47 42 32","color-border-system":"68 60 46","color-text-system":"224 190 79","color-text-thinking":"198 120 221","color-text-truncated":"209 154 102","color-text-tool-error":"224 108 117"},"mode":"dark"},{"id":"night-owl","name":"Night Owl","tokens":{"color-bg-primary":"1 22 39","color-bg-secondary":"0 30 55","color-bg-tertiary":"11 41 66","color-primary":"1 20 33","color-secondary":"0 30 55","color-text-primary":"214 222 235","color-text-secondary":"162 176 196","color-text-muted":"82 98 126","color-accent-primary":"130 170 255","color-accent-success":"34 218 110","color-accent-warning":"247 140 108","color-accent-error":"239 83 80","color-border":"30 56 85","color-text-heading":"130 170 255","color-text-bold":"247 140 108","color-text-code":"199 146 234","color-text-link":"130 170 255","color-bg-system":"30 25 20","color-border-system":"60 50 40","color-text-system":"247 199 120","color-text-thinking":"199 146 234","color-text-truncated":"247 140 108","color-text-tool-error":"239 83 80"},"mode":"dark"},{"id":"catppuccin-mocha","name":"Catppuccin Mocha","tokens":{"color-bg-primary":"30 30 46","color-bg-secondary":"24 24 37","color-bg-tertiary":"49 50 68","color-primary":"17 17 27","color-secondary":"24 24 37","color-text-primary":"205 214 244","color-text-secondary":"186 194 222","color-text-muted":"108 112 134","color-accent-primary":"137 180 250","color-accent-success":"166 227 161","color-accent-warning":"249 226 175","color-accent-error":"243 139 168","color-border":"69 71 90","color-text-heading":"137 180 250","color-text-bold":"249 226 175","color-text-code":"203 166 247","color-text-link":"137 180 250","color-bg-system":"37 37 54","color-border-system":"69 71 90","color-text-system":"250 179 135","color-text-thinking":"203 166 247","color-text-truncated":"249 226 175","color-text-tool-error":"243 139 168"},"mode":"dark"},{"id":"rose-pine","name":"Rose Pine","tokens":{"color-bg-primary":"25 23 36","color-bg-secondary":"31 29 46","color-bg-tertiary":"38 35 58","color-primary":"20 18 30","color-secondary":"31 29 46","color-text-primary":"224 222 244","color-text-secondary":"196 194 220","color-text-muted":"110 106 134","color-accent-primary":"235 188 186","color-accent-success":"156 207 216","color-accent-warning":"246 193 119","color-accent-error":"235 111 146","color-border":"44 40 67","color-text-heading":"235 188 186","color-text-bold":"246 193 119","color-text-code":"196 167 231","color-text-link":"235 188 186","color-bg-system":"44 38 36","color-border-system":"60 52 50","color-text-system":"246 193 119","color-text-thinking":"196 167 231","color-text-truncated":"246 193 119","color-text-tool-error":"235 111 146"},"mode":"dark"},{"id":"kanagawa-wave","name":"Kanagawa Wave","tokens":{"color-bg-primary":"31 34 44","color-bg-secondary":"25 28 36","color-bg-tertiary":"42 47 58","color-primary":"25 28 36","color-secondary":"25 28 36","color-text-primary":"220 224 206","color-text-secondary":"188 193 178","color-text-muted":"108 112 99","color-accent-primary":"133 189 168","color-accent-success":"157 198 113","color-accent-warning":"226 190 107","color-accent-error":"227 116 102","color-border":"51 59 72","color-text-heading":"133 189 168","color-text-bold":"226 190 107","color-text-code":"194 160 191","color-text-link":"133 189 168","color-bg-system":"42 38 30","color-border-system":"60 54 44","color-text-system":"226 190 107","color-text-thinking":"194 160 191","color-text-truncated":"226 190 107","color-text-tool-error":"227 116 102"},"mode":"dark"},{"id":"light-plus","name":"Light Plus","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"243 244 245","color-bg-tertiary":"233 235 238","color-primary":"255 255 255","color-secondary":"243 244 245","color-text-primary":"0 0 0","color-text-secondary":"80 80 80","color-text-muted":"140 140 140","color-accent-primary":"0 92 197","color-accent-success":"0 128 0","color-accent-warning":"178 110 0","color-accent-error":"204 0 0","color-border":"217 217 217","color-text-heading":"0 0 0","color-text-bold":"0 0 0","color-text-code":"204 0 0","color-text-link":"0 92 197","color-bg-system":"255 243 207","color-border-system":"255 220 150","color-text-system":"130 80 0","color-text-thinking":"130 50 180","color-text-truncated":"178 110 0","color-text-tool-error":"204 0 0"},"mode":"light"}]'),LE={tokens:Q3,presets:J3},RE=LE.tokens,ur=LE.presets;function A1(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function Z3(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Zt=tr((e,t)=>{const n=Z3();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:A1(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:o}=t(),d=r();if(d)try{const u=JSON.parse(d);u.preset&&u.tokens?(a(u.preset),e({basePreset:u.preset}),o(u.tokens)):u.preset?a(u.preset):u.tokens&&o(u.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(ur.find(o=>o.id===r))if(r==="system"){const o=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:d,systemLightPreset:u,userPresets:c}=t(),h=o.matches?d:u,m=c.find(f=>f.id===h);e(m?{basePreset:"system",currentPreset:m.basePreset,customTokens:{...m.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:m.id}:{basePreset:"system",currentPreset:h,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0,activeUserPresetId:null}),t().applyTheme()}else e({currentPreset:r,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1,activeUserPresetId:null}),t().applyTheme()},startCustomizing:()=>{var o;const{currentPreset:r}=t(),a=((o=ur.find(d=>d.id===r))==null?void 0:o.tokens)??{};e({basePreset:r,customTokens:{...a},isCustom:!0,isCustomizing:!0})},setCustomToken:(r,a)=>{e(o=>({customTokens:{...o.customTokens,[r]:a}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:r}=t();t().saveTheme(JSON.stringify({tokens:r})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:r=>{e({customTokens:r,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var u,c;const{basePreset:r,customTokens:a,isCustom:o}=t();if(o&&r)return{...((u=ur.find(m=>m.id===r))==null?void 0:u.tokens)??{},...a};if(o)return{...RE.reduce((h,m)=>({...h,[m.key]:m.defaultValue}),{}),...a};const d=ur.find(h=>h.id===t().currentPreset);return(d==null?void 0:d.tokens)??((c=ur[0])==null?void 0:c.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([o,d])=>{a.style.setProperty(`--${o}`,d)})},getSavedTheme:()=>{try{const r=localStorage.getItem("openfox:theme");if(!r)return null;if(r[0]!=="{")return JSON.stringify({preset:r});const a=JSON.parse(r);if(a.preset)return JSON.stringify({preset:a.preset});if(a.tokens)return JSON.stringify({tokens:a.tokens})}catch{return null}return null},saveTheme:async r=>{localStorage.setItem("openfox:theme",r);const{useSettingsStore:a}=await ae(async()=>{const{useSettingsStore:o}=await Promise.resolve().then(()=>Mc);return{useSettingsStore:o}},void 0);await a.getState().setSetting(je.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),ae(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Mc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_FOLLOW_SYSTEM_THEME,String(r))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const r=window.matchMedia("(prefers-color-scheme: dark)"),a=d=>{const{followSystemTheme:u,systemDarkPreset:c,systemLightPreset:h}=t();if(!u)return;const m=d?c:h;t().applyPreset(m),t().saveTheme(JSON.stringify({preset:m}))},o=d=>a(d.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0,systemDarkPreset:"dark",systemLightPreset:"light",activeUserPresetId:null})},addUserPreset:r=>{const{basePreset:a,customTokens:o,currentPreset:d}=t(),u=a||d,c=ur.find(f=>f.id===u),h={id:"custom-"+Date.now(),name:r,basePreset:u,mode:c==null?void 0:c.mode,tokens:{...o}},m=[...t().userPresets,h];e({userPresets:m}),t().saveUserPresets()},applyUserPreset:r=>{const a=t().userPresets[r];a&&(e({currentPreset:a.basePreset,basePreset:a.basePreset,customTokens:{...a.tokens},isCustom:!0,isCustomizing:!1,activeUserPresetId:a.id}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:a.basePreset,tokens:a.tokens})).catch(()=>{}))},deleteUserPreset:r=>{const a=t().userPresets.filter((o,d)=>d!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:A1()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),ae(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>Mc);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(je.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),ae(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Mc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset}))}),t().isSystem&&t().applyPreset("system")},setSystemLightPreset:r=>{e({systemLightPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r})),ae(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Mc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r}))}),t().isSystem&&t().applyPreset("system")}}});function eO({canLoad:e,projectId:t,currentProjectId:n}){const r=Pt(d=>d.loadProject),a=Le(d=>d.listSessions),o=Le(d=>d.clearSession);k.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),o())},[e,t,n,r,a,o])}function tO({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const o=Le(h=>h.loadSession),d=Pt(h=>h.loadProject),u=Le(h=>h.listSessions),c=Le(h=>h.pendingSessionCreate);k.useEffect(()=>{e&&t&&r!==t&&d(t)},[e,t,r,d]),k.useEffect(()=>{e&&n&&a!==n&&o(n),e&&t&&u(t)},[e,n,a,o,u,c,t])}function nO({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Gf({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function DE({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 rO({className:e="w-3 h-3 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 to({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.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 Us({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function gu({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"3.5",y:"4",width:"7",height:"16",rx:"1.5",strokeWidth:1.8}),s.jsx("rect",{x:"13.5",y:"4",width:"7",height:"16",rx:"1.5",strokeWidth:1.8})]})}function wb({className:e="w-3 h-3 text-text-muted",rotate:t,direction:n="down"}){return s.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:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:n==="up"?"M5 15l7-7 7 7":n==="right"?"M9 18l6-6-6-6":"M19 9l-7 7-7-7"})})}function gn(e){return s.jsx(wb,{direction:"down",...e})}function Cb(e){return s.jsx(wb,{direction:"up",...e})}function sO(e){return s.jsx(wb,{direction:"right",...e})}function iO({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function jl({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 kb({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 jb({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"}),s.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Eb({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 wr({className:e="w-5 h-5 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.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 aO({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 oO({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 OE({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.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 qf({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 lO({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 hy({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function ME({className:e="w-[18px] h-[18px]"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Nb({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.jsx("path",{d:"M9.5 2h4.5v4.5"}),s.jsx("path",{d:"M14 2L7.5 8.5"})]})}function Kf({className:e="w-3 h-3",color:t}){return s.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M8 5v14l11-7z"})})}function Fr({className:e="w-3 h-3 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function cO({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 Yf({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 IE({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.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"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function uO({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return s.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[s.jsx("title",{children:"Running"}),s.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),s.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function El({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.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 Xf({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 Tb({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function dO({className:e="w-3.5 h-3.5 shrink-0",color:t}){return s.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:s.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 Qf({className:e="w-5 h-5"}){return s.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"4.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"3",y:"10.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"3",y:"16.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 6.75h11"}),s.jsx("path",{d:"M10 12.75h8"}),s.jsx("path",{d:"M10 18.75h9"})]})}function PE({className:e="w-4 h-4",color:t}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:t??"currentColor",children:[s.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),s.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})}function hO({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Ci({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 Fs({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 fO({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 fy({className:e="w-2.5 h-2.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 ws({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 Ab({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.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 mO({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 pO({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 L1({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 my(){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 R1(e,t){const n=zt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:my(),type:e,payload:t}))}const fs=tr((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 ye(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const o=zt.ws;if(o&&o.readyState===WebSocket.OPEN)for(const d of a)o.send(JSON.stringify({id:my(),type:"terminal.subscribe",payload:{sessionId:d.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await ye("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(a.ok){const o=await a.json();e(u=>({sessions:[...u.sessions,o]}));const d=zt.ws;d&&d.readyState===WebSocket.OPEN&&d.send(JSON.stringify({id:my(),type:"terminal.subscribe",payload:{sessionId:o.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{R1("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{R1("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await ye(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(o=>o.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(a=>{const o=a.sessions.filter(d=>d.id!==r);return o.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:o}});break}}}}));zt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&fs.getState().handleMessage(e)});const Si=tr((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(_s(`/api/auto-update/check${n?"?force=true":""}`));if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();e({status:a.isUpdateAvailable?"available":"upToDate",current:a.current,latest:a.latest})}catch{e({status:"error"})}}}})),Ms={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},modelSelector:{type:"chord",key:"m",modifiers:["ctrl"]},sessionSearch:{type:"chord",key:"s",modifiers:["ctrl"]},criteriaSidebar:{type:"chord",key:"d",modifiers:["ctrl"]},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function py(e){if(!e)return structuredClone(Ms);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(Ms[r]):t[r];return{terminalToggle:n("terminalToggle"),quickAction:n("quickAction"),modelSelector:n("modelSelector"),sessionSearch:n("sessionSearch"),criteriaSidebar:n("criteriaSidebar"),agentSwitching:n("agentSwitching")}}catch{return structuredClone(Ms)}}function D1(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Lb(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 gO(e){return e.type==="double-press"}function BE(e){return e.type==="chord"}function xO(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.key.toLowerCase()===t.toLowerCase():t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function $E(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),o=t.modifiers.includes("shift");return xO(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===o}function Tu(){const e=Bt(t=>t.settings[je.KEYBINDINGS]);return py(e)}function yO(e,t,n){const r=k.useRef(0),a=k.useRef(t);a.current=t,k.useEffect(()=>{if(!e)return;const o=e.threshold??300,d=u=>{if(u.key!==e.key)return;const c=e.key==="Control",h=e.key==="Shift",m=e.key==="Alt",f=e.key==="Meta";if(!c&&u.ctrlKey||!h&&u.shiftKey||!m&&u.altKey||!f&&u.metaKey)return;const g=Date.now();g-r.current<o?(u.preventDefault(),u.stopPropagation(),a.current(),r.current=0):r.current=g};return window.addEventListener("keydown",d,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",d,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function bO(e,t){const n=k.useRef(t);n.current=t,k.useEffect(()=>{if(!e)return;const r=a=>{$E(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function xu(e,t,n){yO(e&&gO(e)?e:void 0,t,n),bO(e&&BE(e)?e:void 0,t)}function vO(e,t,n){const r=k.useRef(n);r.current=n,k.useEffect(()=>{const a=o=>{for(let d=0;d<e.length;d++){const u=e[d];if(!u)continue;const c=t[d];if(c&&BE(u)&&$E(o,u)){o.preventDefault(),r.current(c.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var Cs=bj();const Jf=k.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>s.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Jf.displayName="IconButton";const _O="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",wi=k.forwardRef((e,t)=>s.jsx(Jf,{ref:t,icon:_O,title:"Edit",...e}));wi.displayName="EditButton";const SO="M6 18L18 6M6 6l12 12",Rb=k.forwardRef((e,t)=>s.jsx(Jf,{ref:t,icon:SO,...e}));Rb.displayName="CloseButton";const wO={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,headerRight:n,size:r="md",minHeight:a,children:o,footer:d,className:u,onClose:c,isOpen:h,closeOnBackdropClick:m=!0,closeOnEscape:f=!0,showCloseButton:g=!0,scrollable:x=!0}){const[w,C]=k.useState(!1),v=h!==void 0,S=v?h:w,_=k.useCallback(()=>{v||C(!0)},[v]),b=k.useCallback(()=>{v||C(!1),c==null||c()},[v,c]);k.useEffect(()=>{if(!S||!f)return;const E=N=>{if(N.key==="Escape"){const L=document.activeElement;if(L&&(L.tagName==="INPUT"||L.tagName==="TEXTAREA"))return;N.stopPropagation(),b()}};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[S,b,f]);const j=e&&(typeof e=="string"?s.jsx("button",{type:"button",onClick:_,className:u,children:e}):s.jsx("span",{onClick:_,className:u,style:{cursor:"pointer"},children:e}));return s.jsxs(s.Fragment,{children:[j,S&&(typeof document<"u"?Cs.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:m?b:void 0}),s.jsxs("div",{role:"dialog",className:`relative w-full ${wO[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||g)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 border-b border-border",children:[t&&s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),s.jsxs("div",{className:"flex items-center gap-2 ml-auto w-full sm:w-auto min-w-0",children:[n,g&&s.jsx(Rb,{onClick:b,"aria-label":"Close"})]})]}),x?s.jsx(mt,{className:"p-4 flex-1 min-h-0",style:a?{minHeight:a}:void 0,children:o}):s.jsx("div",{className:"p-4 flex-1 min-h-0 overflow-hidden flex flex-col",style:a?{minHeight:a}:void 0,children:o}),d&&s.jsx("div",{className:"px-4 py-3 border-t border-border",children:d})]})]}),document.body):null)]})}function CO({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a,disabled:n,onChange:o=>{const d=o.target.value;r(d===t?null:d)},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:L3.map(({url:o,label:d})=>s.jsx("option",{value:o,title:d,children:d.split(" ")[0]},o))}),s.jsx(gn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const O1=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function kO(){const e=Wa(c=>c.settings),t=Wa(c=>c.update),n=Wa(c=>c.updateEvent),r=Wa(c=>c.updateAgentOverride),a=Wa(c=>c.load);k.useEffect(()=>{a()},[a]);const o=async()=>{await D3()==="granted"&&t({...e,browserNotificationEnabled:!0})},d=(c,h,m,f)=>{c==="general"?n(h,{[m]:f}):r(c,h,{[m]:f})},u=(c,h,m)=>{c==="general"?n(h,{customSoundUrl:m}):r(c,h,{customSoundUrl:m})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),s.jsx(M1,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:c=>t({...e,soundEnabled:c})}),s.jsx(M1,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:c=>{c&&typeof Notification<"u"&&Notification.permission!=="granted"?o():t({...e,browserNotificationEnabled:c})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&s.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),s.jsx("div",{className:"border border-border rounded overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),O1.map(c=>s.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:c.label},c.key))]})}),s.jsx("tbody",{children:A3.map(c=>s.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[s.jsx("td",{className:"px-3 py-2",children:s.jsx("div",{className:"text-text-primary text-xs",children:c.label})}),O1.map(h=>{const m=TE(e,c.key,h.key==="general"?void 0:h.key),f=EE[c.key];return s.jsx("td",{className:"px-2 py-2 align-top",children:s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:m.soundEnabled,onChange:g=>d(h.key,c.key,"soundEnabled",g.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:m.browserNotification,onChange:g=>d(h.key,c.key,"browserNotification",g.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),m.soundEnabled&&e.soundEnabled&&s.jsx(CO,{value:m.customSoundUrl,defaultUrl:f,disabled:!e.soundEnabled,onChange:g=>u(h.key,c.key,g)})]})},h.key)})]},c.key))})]})})]})]})}function M1({label:e,description:t,checked:n,onChange:r}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),r(!n)},children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})})]})}const ct=k.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},o)=>{const d="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",u={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"},c={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return s.jsx("button",{ref:o,className:`${d} ${u[e]} ${c[t]} ${n}`,...a,children:r})});ct.displayName="Button";async function I1(e,t,n){try{const r=await ye(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}function Ia(e,t){return t?`${e}?workdir=${encodeURIComponent(t)}`:e}const Vn=tr((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,workdir:null,setWorkdir:n=>{e({workdir:n})},fetchSkills:async n=>{const r=n??t().workdir;e({loading:!0});try{const o=await(await ye(Ia("/api/skills",r))).json();e({defaults:o.defaults??[],userItems:o.userItems??[],projectItems:o.projectItems??[],items:o.items??[],selectedDirectory:o.selectedDirectory??null,diagnostics:o.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await ye(Ia(`/api/skills/${n}/toggle`,t().workdir),{method:"POST"})).json();e(o=>({defaults:o.defaults.map(d=>d.id===n?{...d,enabled:a.enabled}:d),userItems:o.userItems.map(d=>d.id===n?{...d,enabled:a.enabled}:d),projectItems:o.projectItems.map(d=>d.id===n?{...d,enabled:a.enabled}:d),items:o.items.map(d=>d.id===n?{...d,enabled:a.enabled}:d)}))}catch{}},fetchSkill:async n=>{try{const r=await ye(Ia(`/api/skills/${n}`,t().workdir));return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ye(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await ha("POST",Ia("/api/skills",t().workdir),{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await ha("PUT",Ia(`/api/skills/${n}`,t().workdir),r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await ye(Ia(`/api/skills/${n}`,t().workdir),{method:"DELETE"}),a=await r.json();return r.ok?(e(o=>({userItems:o.userItems.filter(d=>d.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>Uf(Ia(`/api/skills/${n}/duplicate`,t().workdir),()=>t().fetchSkills(),r),selectDirectory:async n=>I1("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await ye("/api/skills/library",{method:"DELETE"}),await t().fetchSkills()},installSkill:async n=>{const r=new FormData;r.append("packageName",n.packageName),r.append("paths",JSON.stringify(n.files.map(a=>a.path)));for(const a of n.files)r.append("files",a.file,a.file.name);return I1("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function Au(){const[e,t]=k.useState({id:null,type:null}),n=k.useCallback(o=>t({id:o,type:"delete"}),[]),r=k.useCallback(()=>t({id:null,type:null}),[]),a=k.useCallback((o,d)=>e.id===o&&e.type===d,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function tf({onConfirm:e,onCancel:t}){return s.jsxs("div",{className:"flex items-center gap-1",children:[s.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"}),s.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 nf({onClick:e}){return s.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:s.jsx(Ci,{})})}function yu({onClick:e}){return s.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:s.jsx(jl,{})})}function rs({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:o,mono:d}){return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,o&&s.jsx("span",{className:"text-text-muted ml-1",children:o})]}),s.jsx("input",{value:t,onChange:u=>n(u.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${d?"font-mono":""} ${a?"opacity-60":""}`})]})}function FE({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(ct,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(ct,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function vl({message:e}){return s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function Zf({value:e,onChange:t}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),s.jsxs("select",{value:e,onChange:n=>t(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:[s.jsx("option",{value:"user",children:"Global config"}),s.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})}function zE({description:e,onNew:t,loading:n,hasItems:r,children:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(ct,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?s.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?a:s.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function HE({label:e="Custom",children:t}){return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t})]})}function UE({description:e,onNew:t,newLabel:n="+ New"}){return s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(ct,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function Db({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?s.jsx("div",{className:"text-text-muted text-sm",children:n}):t?s.jsx("div",{className:"space-y-4",children:a}):r?s.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function VE({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:o="my-item",nameHint:d,readOnlyId:u=!1,readOnlyHint:c="(read-only)",onNameChange:h,onIdChange:m}){return s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(rs,{label:n,value:e,onChange:h,placeholder:a,hint:d}),s.jsx(rs,{label:r,value:t,onChange:m,readOnly:u,placeholder:o,hint:u?c:void 0,mono:!0})]})}function WE(e={}){const{initialData:t={}}=e,[n,r]=k.useState("list"),[a,o]=k.useState(null),[d,u]=k.useState(""),[c,h]=k.useState(!1),[m,f]=k.useState(t),g=k.useCallback(()=>{f(t),u(""),o(null)},[t]),x=k.useCallback(S=>{r(S),S==="list"&&g()},[g]),w=k.useCallback(S=>{f(_=>typeof S=="function"?S(_):S)},[]),C=k.useCallback((S,_={})=>{o(S),r("edit"),f({..._}),u("")},[]),v=k.useCallback(()=>{o(null),r("edit"),f(t),u("")},[t]);return{view:n,editingId:a,formError:d,saving:c,formData:m,setView:x,setEditingId:o,setFormError:u,setFormData:w,setSaving:h,resetForm:g,startEditing:C,startNew:v}}function Nl({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:o="Confirm",confirmVariant:d="primary",disabled:u=!1}){return s.jsx(Et,{isOpen:e,onClose:t,title:r,size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"text-text-secondary",children:a}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ct,{variant:"secondary",onClick:t,disabled:u,children:"Cancel"}),s.jsx(ct,{variant:d,onClick:n,disabled:u,autoFocus:!0,children:o})]})]})})}const jO={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function ma({size:e="md",className:t=""}){return s.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${jO[e]} ${t}`})}function EO({text:e,...t}){return s.jsxs("div",{className:"text-center",children:[s.jsx(ma,{...t,className:"mx-auto mb-4"}),e&&s.jsx("div",{className:"text-text-secondary",children:e})]})}function Lu(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function NO(e){const t=e.includes("\\")?"\\":"/";return e.split(/[\\/]/).filter(Boolean).map((n,r,a)=>({name:n,path:t==="/"?"/"+a.slice(0,r+1).join("/"):a.slice(0,r+1).join("\\")+(r===0?"\\":"")}))}function Ob(e,t=28){if(e.length<=t)return e;const n=e.includes("\\")?"\\":"/",r=e.split(/[\\/]/).filter(Boolean);if(r.length<=2)return e;const a=r[0],o=r[r.length-1],d=r.slice(1,-1).join(n),u=t-a.length-o.length-3;if(u<0)return e;const c=d.slice(0,Math.floor(u/2)),h=d.slice(-Math.ceil(u/2));return`${e.startsWith(n)?n:""}${a}${n}${c}...${h}${n}${o}`}function Wt(){return typeof window>"u"||typeof window.matchMedia!="function"?!0:!window.matchMedia("(hover: none) and (pointer: coarse)").matches}const xs=k.forwardRef(({className:e="",...t},n)=>s.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}));xs.displayName="Input";function em({onSelect:e,onClose:t,initialPath:n}){const[r,a]=k.useState(null),[o,d]=k.useState(!0),[u,c]=k.useState(""),[h,m]=k.useState(-1),f=k.useRef(null),g=k.useRef(null),x=k.useCallback(async b=>{d(!0),c(""),m(-1);try{const j=b?`/api/directories?path=${encodeURIComponent(b)}`:"/api/directories",N=await(await ye(j)).json();a(N)}catch(j){console.error("Failed to load directories:",j)}finally{d(!1)}},[]);k.useEffect(()=>{x(n)},[n,x]);const w=NO((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(b=>u===""||b.name.toLowerCase().includes(u.toLowerCase())))??[],v=[...!u&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(b=>({type:"dir",path:b.path,name:b.name}))];k.useEffect(()=>{m(u?0:-1)},[u,C.length]),k.useEffect(()=>{if(h>=0&&g.current){const b=g.current.querySelector(`[data-index="${h}"]`);b==null||b.scrollIntoView({block:"nearest"})}},[h]);const S=b=>{var j;if(b.key==="ArrowDown")b.preventDefault(),m(E=>Math.min(E+1,v.length-1));else if(b.key==="ArrowUp")b.preventDefault(),m(E=>Math.max(E-1,0));else if(b.key==="Enter"){if(h<0||!v[h]||b.target instanceof HTMLElement&&b.target.dataset.select==="true")return;b.preventDefault(),b.shiftKey?x(v[h].path):e(v[h].path)}else b.key==="Escape"&&(c(""),Wt()&&((j=f.current)==null||j.focus()))},_=s.jsx("div",{className:"flex flex-col gap-2",children:s.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return s.jsx(Et,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:_,scrollable:!1,children:s.jsxs("div",{ref:g,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[s.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&s.jsx("div",{className:"px-3 pt-3 pb-1",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((b,j)=>s.jsxs("span",{className:"flex items-center shrink-0",children:[s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx("button",{onClick:()=>x(b.path),className:`px-1 ${j===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:b.name})]},b.path)),w.length===0&&s.jsx("button",{onClick:()=>x("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&s.jsx("button",{onClick:()=>e(r.current),className:"ml-auto shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90",children:"Select"})]})}),s.jsx("div",{className:"px-4 py-2",children:s.jsxs("div",{className:"relative",children:[s.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:s.jsx(Fs,{})}),s.jsx(xs,{autoFocus:Wt(),ref:f,value:u,onChange:b=>c(b.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),s.jsx(mt,{className:"flex-1",children:o?s.jsx("div",{className:"p-8 text-center",children:s.jsx(ma,{size:"sm"})}):v.length===0?s.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:u?"No matching directories":"No subdirectories"}):s.jsx("div",{className:"divide-y divide-border",children:v.map((b,j)=>s.jsxs("div",{"data-index":j,className:`group flex items-center ${j===h?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[s.jsxs("button",{onClick:()=>{x(b.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[b.type==="parent"?s.jsx(nO,{className:"w-5 h-5 text-text-muted shrink-0"}):s.jsx(wr,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"truncate",children:b.name}),b.type==="dir"&&s.jsx(gn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${j===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),b.type==="dir"&&s.jsx("button",{"data-select":"true",tabIndex:j===h?0:-1,onClick:E=>{E.stopPropagation(),e(b.path)},className:`mr-2 shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90 ${j===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${b.name}`,children:"Select"})]},b.path))})})]})})}function GE(e,t){if(!e||!t.some(n=>n.path==="SKILL.md"))throw new Error("Drop one folder containing SKILL.md.");return{packageName:e,files:t}}function TO(e){const t=[...e];if(!t.length)throw new Error("Choose one skill folder.");const n=new Set(t.map(a=>a.webkitRelativePath.split("/")[0]).filter(Boolean));if(n.size!==1)throw new Error("Choose exactly one skill folder.");const r=[...n][0];return GE(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function AO(e){return new Promise((t,n)=>e.file(t,n))}async function qE(e,t=""){const n=e.createReader(),r=[];for(;;){const o=await new Promise((d,u)=>n.readEntries(d,u));if(!o.length)break;r.push(...o)}return(await Promise.all(r.map(async o=>{const d=t?`${t}/${o.name}`:o.name;return o.isDirectory?qE(o,d):[{path:d,file:await AO(o)}]}))).flat()}async function LO(e){const t=[...e.items].filter(r=>r.kind==="file").map(r=>{var a;return((a=r.webkitGetAsEntry)==null?void 0:a.call(r))??null}).filter(r=>!!r);if(t.length!==1||!t[0].isDirectory)throw new Error("Drop exactly one skill folder.");const n=t[0];return GE(n.name,await qE(n))}function RO({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[o,d]=k.useState(!1),[u,c]=k.useState(!1),[h,m]=k.useState(""),[f,g]=k.useState(null),[x,w]=k.useState(!1),C=k.useRef(null);k.useEffect(()=>{var j;(j=C.current)==null||j.setAttribute("webkitdirectory","")},[]);const v=j=>{g(j)},S=async()=>{if(!f||x)return;w(!0);const j=await t(f);if(j&&!j.success){m(j.error??"Cannot use selected folder."),w(!1);return}g(null),d(!1),w(!1)},_=async j=>{c(!0),m("");const E=await a(j);c(!1),E.success||m(E.error??"Failed to install skill package.")},b=async j=>{if(j.preventDefault(),!(!(e!=null&&e.available)||u))try{await _(await LO(j.dataTransfer))}catch(E){m(E instanceof Error?E.message:"Invalid skill folder.")}};return s.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),s.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(ct,{variant:"secondary",onClick:()=>d(!0),children:"Change folder"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&s.jsx(ct,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),s.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||u,onClick:()=>{var j;return(j=C.current)==null?void 0:j.click()},onDragOver:j=>j.preventDefault(),onDrop:b,className:"mt-3 w-full rounded border border-dashed border-border px-4 py-5 text-center text-xs text-text-secondary disabled:cursor-not-allowed disabled:opacity-50",children:e!=null&&e.available?u?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),s.jsx("input",{ref:C,hidden:!0,type:"file",multiple:!0,onChange:j=>{var E;if((E=j.target.files)!=null&&E.length)try{_(TO(j.target.files))}catch(N){m(N instanceof Error?N.message:"Invalid skill folder.")}finally{j.target.value=""}}}),h&&s.jsx("p",{className:"mt-2 text-xs text-error",children:h}),o&&s.jsx(em,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:v,onClose:()=>d(!1)}),s.jsx(Nl,{isOpen:f!==null,onClose:()=>g(null),onConfirm:S,title:"Trust this folder?",message:"Skills may contain instructions and scripts. Select this folder for discovery without executing package content?",confirmLabel:"Trust folder",disabled:x})]})}function ys({enabled:e,onClick:t,label:n,disabled:r}){return s.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:r?void 0:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"} ${r?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function KE({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:o,onCancelDelete:d,actions:u,children:c}){return s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&r&&s.jsx(wi,{onClick:r}),e&&!r&&n&&s.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:s.jsx(Eb,{})}),s.jsx(yu,{onClick:a}),!e&&r&&s.jsx(wi,{onClick:r}),!e&&o&&(t?s.jsx(tf,{onConfirm:()=>{o==null||o()},onCancel:()=>d==null?void 0:d()}):s.jsx(nf,{onClick:()=>o==null?void 0:o()})),u]})]})}function DO({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:d,onDuplicate:u,onDelete:c,onCancelDelete:h,actions:m}){return s.jsxs(KE,{isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:d,onDuplicate:u,onDelete:c,onCancelDelete:h,actions:m,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&s.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function P1({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:d,onToggle:u,readOnly:c=!1}){return s.jsx(DO,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:c?void 0:a,onDuplicate:o,onDelete:c?void 0:d,actions:s.jsx(ys,{enabled:e.enabled,onClick:u,label:`Activation for ${e.name}`})})}function OO({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return s.jsxs(Et,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ct,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),s.jsx(ct,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[s.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),s.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&s.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&s.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function MO({isOpen:e}){const t=Vn(ne=>ne.defaults),n=Vn(ne=>ne.userItems),r=Vn(ne=>ne.projectItems),a=Vn(ne=>ne.items),o=Vn(ne=>ne.selectedDirectory),d=Vn(ne=>ne.diagnostics),u=Vn(ne=>ne.loading),c=Vn(ne=>ne.fetchSkills),h=Vn(ne=>ne.setWorkdir),m=Vn(ne=>ne.fetchSkill),f=Vn(ne=>ne.fetchDefaultContent),g=Vn(ne=>ne.createSkill),x=Vn(ne=>ne.updateSkill),w=Vn(ne=>ne.deleteSkill),C=Vn(ne=>ne.selectDirectory),v=Vn(ne=>ne.removeDirectory),S=Vn(ne=>ne.installSkill),_=Vn(ne=>ne.toggleSkill),b=Le(ne=>ne.currentSession),[j,E]=k.useState(null),[N,L]=k.useState(!1),[A,D]=k.useState(""),{view:O,editingId:F,formError:P,saving:z,formData:K,setView:q,setEditingId:W,setFormError:Z,setFormData:Q,setSaving:H}=WE(),{clearConfirm:I}=Au();k.useEffect(()=>{if(e){const ne=(b==null?void 0:b.workdir)??null;h(ne),c(ne),q("list"),W(null),I()}},[e,c,h,I,b==null?void 0:b.workdir]);const M=(ne,ie,de,pe)=>{Q({name:pe??ne.metadata.name,id:de??ne.metadata.id,description:ne.metadata.description??"",version:ne.metadata.version??"1.0.0",prompt:ne.prompt,isReadOnly:ie,destination:"user"})},V=async ne=>{if(t.some(de=>de.id===ne)){const de=await f(ne);if(!de)return;M(de,!0),W(ne),Z(""),q("edit")}else{const de=await m(ne);if(!de)return;M(de,!0),W(ne),Z(""),q("edit")}},$=async ne=>{const de=t.some(Oe=>Oe.id===ne)?await f(ne):await m(ne);if(!de)return;const pe=`${ne}-copy-${Date.now()}`;M(de,!1,pe,`${de.metadata.name} (copy)`),W(null),Z(""),q("edit")},ee=()=>{Q({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),q("edit")},Y=async ne=>{const ie=await m(ne);ie&&(M(ie,!1),W(ne),Z(""),q("edit"))},X=async()=>{if(!j)return;L(!0),D("");const ne=await w(j.id);if(L(!1),!ne.success){D(ne.error??"Failed to delete skill.");return}await c(),E(null),I()},U=async()=>{const ne=F??K.id;if(!ne||!K.name||!K.prompt){Z("Name, ID, and prompt are required.");return}H(!0),Z("");const ie={metadata:{id:ne,name:K.name,description:K.description,version:K.version},prompt:K.prompt},de=F?await x(F,ie):await g(ie,K.destination);if(H(!1),!de.success){Z(de.error??"Failed to save skill.");return}q("list")},B=ne=>{Q(ie=>({...ie,name:ne})),F||Q(ie=>({...ie,id:ne.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},J=K.isReadOnly;if(O==="edit")return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:J?K.name:F?"Edit Skill":"New Skill"}),s.jsx("button",{onClick:()=>q("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),P&&s.jsx(vl,{message:P}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(VE,{name:K.name,id:K.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:B,onIdChange:()=>{}}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(rs,{label:"Description",value:K.description,onChange:ne=>Q(ie=>({...ie,description:ne})),placeholder:"What this skill does...",readOnly:J}),s.jsx(rs,{label:"Version",value:K.version,onChange:ne=>Q(ie=>({...ie,version:ne})),placeholder:"1.0.0",readOnly:J})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:K.prompt,onChange:ne=>Q(ie=>({...ie,prompt:ne.target.value})),readOnly:J,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"})]}),!F&&s.jsx(Zf,{value:K.destination,onChange:ne=>Q(ie=>({...ie,destination:ne}))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[s.jsx(ct,{variant:"secondary",onClick:()=>q("list"),children:"Cancel"}),J?s.jsx(ct,{variant:"primary",onClick:()=>{Q(ne=>({...ne,name:ne.name+" (copy)",id:`${F}-copy-${Date.now()}`,isReadOnly:!1})),W(null)},children:"Duplicate & Customize"}):s.jsx(ct,{variant:"primary",onClick:U,disabled:z||!K.name||!K.id||!K.prompt,children:z?"Saving...":"Save"})]})]});function se({items:ne}){return ne.map(ie=>s.jsx(P1,{skill:ie,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>V(ie.id),onEdit:()=>Y(ie.id),onDuplicate:()=>$(ie.id),onDelete:()=>{D(""),E(ie)},onToggle:()=>_(ie.id),readOnly:ie.readOnly},ie.id))}return s.jsxs("div",{children:[s.jsx(OO,{skill:j,deleting:N,error:A,onClose:()=>{N||E(null)},onConfirm:X}),s.jsx(RO,{selectedDirectory:o,onSelect:C,onRemove:v,onRefresh:c,onInstall:S}),d.length>0&&s.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:d.map((ne,ie)=>s.jsx("p",{children:ne},`${ne}-${ie}`))}),s.jsx(UE,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:ee}),s.jsxs(Db,{loading:u,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:t.map(ne=>s.jsx(P1,{skill:ne,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>V(ne.id),onDuplicate:()=>$(ne.id),onToggle:()=>_(ne.id)},ne.id))})]}),n.length>0&&s.jsx(HE,{children:s.jsx(se,{items:n})}),a.some(ne=>["global-shared","selected","project-shared"].includes(ne.source))&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),s.jsx("div",{className:"space-y-2",children:s.jsx(se,{items:a.filter(ne=>["global-shared","selected","project-shared"].includes(ne.source))})})]}),r.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:s.jsx(se,{items:r})})]})]})]})}function pa(){const e=Bt(a=>a.settings),t=Bt(a=>a.loading),n=Bt(a=>a.getSetting),r=Bt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function IO({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=pa(),o=t[je.GLOBAL_INSTRUCTIONS]??"",d=n[je.GLOBAL_INSTRUCTIONS]??!1,[u,c]=k.useState(o),[h,m]=k.useState(!1),[f,g]=k.useState(!1);k.useEffect(()=>{e&&r(je.GLOBAL_INSTRUCTIONS)},[e,r]),k.useEffect(()=>{c(o),m(!1)},[o]);const x=async()=>{g(!0),await a(je.GLOBAL_INSTRUCTIONS,u),g(!1),m(!1)},w=()=>{c(o),m(!1)},C=d||f;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),s.jsx("textarea",{value:u,onChange:v=>{c(v.target.value),m(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ct,{variant:"secondary",onClick:w,disabled:!h,children:"Discard"}),s.jsx(ct,{variant:"primary",onClick:x,disabled:!h||C,children:f?"Saving...":"Save"})]})]})}function PO(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),r=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${r} ${a}`}return e}function zh(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 BO({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:o,onClose:d,onSave:u}){const[c,h]=k.useState(o),[m,f]=k.useState(r),[g,x]=k.useState(a);k.useEffect(()=>{h(o),f(r)},[o,r]);const w=(b,j)=>{const E=j.startsWith("#")?PO(j):j;h(N=>({...N,[b]:E}))},C=()=>{u(m.trim()||"Untitled",{...c},g)},v=RE.reduce((b,j)=>{const E=j.category;return b[E]||(b[E]=[]),b[E].push(j),b},{}),S={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},_=ur.find(b=>b.id===n);return s.jsx(Et,{isOpen:e,onClose:d,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{type:"button",onClick:d,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:C,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.jsx("input",{type:"text",value:m,onChange:b=>f(b.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Mode"}),s.jsxs("div",{className:"flex rounded overflow-hidden border border-border",children:[s.jsx("button",{type:"button",onClick:()=>x("dark"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="dark"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Dark"}),s.jsx("button",{type:"button",onClick:()=>x("light"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="light"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Light"})]})]})]}),!t&&s.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",s.jsx("span",{className:"text-text-primary",children:_==null?void 0:_.name})]}),Object.entries(v).map(([b,j])=>s.jsxs("div",{className:"space-y-3",children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:S[b]??b}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:j.map(E=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("label",{htmlFor:E.key,className:"text-xs text-text-muted",children:E.label}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"color",id:E.key,value:zh(c[E.key]??E.defaultValue),onChange:N=>w(E.key,N.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),s.jsx("input",{type:"text",value:c[E.key]??E.defaultValue,onChange:N=>w(E.key,N.target.value),className:"flex-1 min-w-0 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},E.key))})]},b))]})})}function B1({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:o,onDelete:d}){return s.jsxs("div",{className:"relative group",children:[s.jsxs("button",{type:"button",onClick:r,className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${t?"border-accent-primary bg-bg-tertiary text-text-primary":n?"border-dashed border-accent-primary/50 bg-bg-tertiary/50 text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[s.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:e.id==="system"?"transparent":zh(e.tokens["color-bg-primary"]??"#000"),borderColor:zh(e.tokens["color-border"]??"#000")},children:e.id==="system"?s.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:zh(e.tokens["color-text-primary"]??"#fff")}})}),s.jsx("span",{className:"text-xs",children:e.name})]}),a&&s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),a()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:s.jsx("span",{className:"text-xs",children:"✎"})}),o&&s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),o()},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:s.jsx("span",{className:"text-xs",children:"✎"})}),d&&s.jsx("button",{type:"button",onClick:u=>d(u),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:s.jsx(ws,{className:"w-3 h-3"})})]})}function $O(){const[e,t]=k.useState(null),n=Zt(P=>P.currentPreset),r=Zt(P=>P.isCustom),a=Zt(P=>P.basePreset),o=Zt(P=>P.isSystem),d=Zt(P=>P.systemDarkPreset),u=Zt(P=>P.systemLightPreset),c=Zt(P=>P.applyPreset),h=Zt(P=>P.applyUserPreset),m=Zt(P=>P.deleteUserPreset),f=Zt(P=>P.saveTheme),g=Zt(P=>P.setSystemDarkPreset),x=Zt(P=>P.setSystemLightPreset),w=Zt(P=>P.activeUserPresetId),C=Zt(P=>P.userPresets),v=ur.filter(P=>P.mode==="dark"),S=ur.filter(P=>P.mode==="light"),_=P=>{var z;if(o){const K=C[P];if(!K)return;const q=K.mode??((z=ur.find(W=>W.id===K.basePreset))==null?void 0:z.mode);q==="dark"?g(K.id):q==="light"&&x(K.id)}else h(P)},b=P=>{const z=ur.find(K=>K.id===P);z&&t({type:"new",presetIndex:C.length,basePresetId:P,presetName:z.name+" Copy",mode:z.mode??"dark",tokens:{...z.tokens}})},j=P=>{const z=C[P];if(!z)return;const K=ur.find(W=>W.id===z.basePreset),q=K?{...K.tokens,...z.tokens}:z.tokens;t({type:"edit",presetIndex:P,basePresetId:z.basePreset,presetName:z.name,mode:z.mode??"dark",tokens:q})},E=(P,z,K)=>{if(!e)return;const q=[...C];if(e.type==="new"){const W={id:"custom-"+Date.now(),name:P,basePreset:e.basePresetId,mode:K,tokens:z};q.push(W);const Z=q.length-1;Zt.setState({userPresets:q}),Zt.getState().saveUserPresets(),Zt.getState().applyUserPreset(Z)}else{const W=q[e.presetIndex];W&&(q[e.presetIndex]={...W,name:P,mode:K,tokens:z}),Zt.setState({userPresets:q}),Zt.getState().saveUserPresets(),Zt.getState().applyUserPreset(e.presetIndex)}t(null)},N=()=>{t(null)},L=(P,z)=>{P.stopPropagation(),m(z)},A=o?"system":r?a:n,D=()=>{o?(c(n),f(JSON.stringify({preset:n})).catch(()=>{})):(c("system"),f(JSON.stringify({preset:"system"})).catch(()=>{}))},O=P=>{if(o){const z=ur.find(K=>K.id===P);(z==null?void 0:z.mode)==="dark"?g(P):(z==null?void 0:z.mode)==="light"&&x(P)}else c(P),f(JSON.stringify({preset:P})).catch(()=>{})},F=P=>{const z=ur.find(K=>K.id===P.basePreset);return z?{...z.tokens,...P.tokens}:P.tokens};return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),s.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[s.jsx("span",{className:"text-sm text-text-primary font-medium",children:"Follow system theme"}),s.jsx("button",{type:"button",onClick:D,className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${o?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${o?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:P,mode:z})=>{const K=z==="dark"?v:S,q=C.filter(W=>{var Q;return(W.mode??((Q=ur.find(H=>H.id===W.basePreset))==null?void 0:Q.mode))===z});return s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:P}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[K.map(W=>s.jsx(B1,{preset:W,isActive:W.id===A&&!r,isUnderlying:o&&(W.id===d||W.id===u),onClick:()=>O(W.id),onNewFrom:()=>b(W.id)},W.id)),q.map(W=>{const Z=C.indexOf(W),Q=F(W);return s.jsx(B1,{preset:{id:W.id,name:W.name,tokens:Q},isActive:w===W.id,isUnderlying:o&&(W.id===d||W.id===u),onClick:()=>_(Z),onEdit:()=>j(Z),onDelete:H=>L(H,Z)},W.id)})]})]},P)}),e&&s.jsx(BO,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,mode:e.mode,initialTokens:e.tokens,onClose:N,onSave:E})]})}const FO=["monospace","serif","sans-serif"],YE=["JetBrains Mono","Cascadia Mono","Menlo","Consolas","DejaVu Sans Mono","Liberation Mono"],Hh=`${YE.map(e=>`"${e}"`).join(", ")}, monospace`,zO=["Andale Mono","Anonymous Pro","Cascadia Code","Cascadia Mono","Consolas","Courier New","DejaVu Sans Mono","Fira Code","Fira Mono","Geist Mono","Hack","IBM Plex Mono","Inconsolata","Iosevka","JetBrains Mono","Liberation Mono","Menlo","Monaco","Noto Sans Mono","Roboto Mono","SF Mono","Source Code Pro","Space Mono","Ubuntu Mono","Victor Mono","CaskaydiaCove Nerd Font","CaskaydiaCove Nerd Font Mono","DejaVuSansMono Nerd Font","FiraCode Nerd Font","FiraCode Nerd Font Mono","Hack Nerd Font","Hack Nerd Font Mono","Iosevka Nerd Font","JetBrainsMono Nerd Font","JetBrainsMono Nerd Font Mono","MesloLGS NF","MesloLGS Nerd Font","SauceCodePro Nerd Font","SauceCodePro Nerd Font Mono","UbuntuMono Nerd Font"],HO="mmmmmmmmmmlliWWWW@0Oo",UO="72px";let Fc;function VO(){if(Fc!==void 0)return Fc;try{Fc=document.createElement("canvas").getContext("2d")}catch{Fc=null}return Fc}function Mb(e){const t=VO();if(!t)throw new Error("Canvas 2D context unavailable");return t.font=`${UO} ${e}`,t.measureText(HO).width}function XE(e,t=Mb){const n=e.trim();if(!n)return!1;try{return FO.some(r=>{const a=t(r);return t(`"${n}", ${r}`)!==a})}catch{return!1}}function WO(e=zO,t=Mb){const n=new Set;for(const r of e)XE(r,t)&&n.add(r);return[...n].sort((r,a)=>r.localeCompare(a))}function GO(e=YE,t=Mb){return e.find(n=>XE(n,t))??""}function qO(e){const t=e.trim();return t?`"${t}", monospace`:""}function KO(e){var n;return(((n=e.split(",")[0])==null?void 0:n.trim())??"").replace(/^['"]|['"]$/g,"")}function YO(){return s.jsx($O,{})}function XO(){const{settings:e,loading:t,getSetting:n,setSetting:r}=pa(),a=t[je.DISPLAY_SHOW_THINKING]??!1,o=e[je.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[d,u]=k.useState(o);k.useEffect(()=>{n(je.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),k.useEffect(()=>{u(o)},[o]);const c=()=>{const _=parseInt(d,10),b=isNaN(_)||_<0?0:Math.min(_,9999);u(String(b)),r(je.DISPLAY_MAX_VISIBLE_ITEMS,String(b))},h=[{key:je.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:je.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:je.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:je.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:je.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],m=[{key:je.DISPLAY_USE_NATIVE_SCROLLBARS,label:"Use native scrollbars in tool calls",description:"Swap custom styled scrollbars for native ones in tool call views (file previews, arguments, results). Faster, but native scrollbars look different on some platforms.",defaultValue:"false"},{key:je.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,label:"Use native scrollbars in code blocks",description:"Swap custom styled scrollbars for native ones in markdown code blocks and tables.",defaultValue:"false"},{key:je.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,label:"Collapse large tool calls automatically",description:"Start finished tool calls with large outputs collapsed; click to expand. Speeds up loading long sessions.",defaultValue:"false"},{key:je.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,label:"Defer code highlighting while streaming",description:"While a code block is streaming, wait until it closes to highlight it. Smoother streaming, but code stays plain until the end.",defaultValue:"false"},{key:je.DISPLAY_FEED_VIRTUALIZATION,label:"Virtualize long feeds",description:"Mount only the most recent items and reveal older ones as you scroll up. Faster on very long sessions, but older history loading is experimental.",defaultValue:"false"},{key:je.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews",defaultValue:"true"}],f=[...h,...m],g=Object.fromEntries(h.map(_=>[_.key,e[_.key]??"true"])),x=Object.fromEntries(m.map(_=>[_.key,e[_.key]??_.defaultValue])),w={...g,...x},[C,v]=k.useState(()=>Object.fromEntries(f.map(_=>[_.key,w[_.key]==="true"])));k.useEffect(()=>{f.forEach(_=>n(_.key))},[n]),k.useEffect(()=>{v(Object.fromEntries(f.map(_=>[_.key,w[_.key]==="true"])))},[JSON.stringify(w)]);const S=async _=>{const b=String(!C[_]);v(j=>({...j,[_]:!j[_]})),await r(_,b)};return a?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(YO,{}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Custom CSS"}),s.jsx("p",{className:"text-xs text-text-muted mb-3",children:"Add global CSS overrides for any element."}),s.jsx(ZO,{})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),s.jsx($1,{toggles:h,local:C,onToggle:S})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Performance"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx($1,{toggles:m,local:C,onToggle:S}),s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Keep only the last N items in the feed. Set to 0 to show all."})]}),s.jsx("input",{type:"number",min:0,max:9999,value:d,onChange:_=>{const b=_.target.value.replace(/[^0-9]/g,"");u(b)},onBlur:c,onKeyDown:_=>{_.key==="Enter"&&c()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})]})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Terminal"}),s.jsx(JO,{})]})]})}const QO="~/project  git status ✓ ✗ → 0123 iIlL1 |─┤";function $1({toggles:e,local:t,onToggle:n}){return s.jsx("div",{className:"space-y-4",children:e.map(({key:r,label:a,description:o})=>s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:a}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:o})]}),s.jsx("button",{type:"button",onClick:()=>n(r),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${t[r]?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t[r]?"translate-x-6":"translate-x-1"}`})})]},r))})}function JO(){const{settings:e,getSetting:t,setSetting:n}=pa(),r=e[je.DISPLAY_TERMINAL_FONT]??Hh,[a,o]=k.useState(r),d=k.useMemo(()=>WO(),[]),u=k.useMemo(()=>GO(),[]);k.useEffect(()=>{t(je.DISPLAY_TERMINAL_FONT)},[t]),k.useEffect(()=>{o(r)},[r]);const h=r===Hh?u:KO(r),m=h!==""&&!d.includes(h),f=x=>{const w=x.target.value;w&&n(je.DISPLAY_TERMINAL_FONT,qO(w))},g=()=>{n(je.DISPLAY_TERMINAL_FONT,a.trim()||Hh)};return s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Only monospace fonts detected on this machine are listed. If your shell theme uses icons or powerline glyphs, pick a Nerd Font."}),s.jsxs("select",{value:m?"":h,onChange:f,className:"w-full px-2 py-1.5 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",children:[m&&s.jsx("option",{value:"",children:`Custom: ${h}`}),d.length===0&&s.jsx("option",{value:"",children:"No monospace font detected"}),d.map(x=>s.jsx("option",{value:x,style:{fontFamily:`"${x}", monospace`},children:x},x))]}),s.jsx(mt,{horizontal:!0,className:"px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded whitespace-nowrap",style:{fontFamily:r},children:QO}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-text-muted mb-1",children:'Not listed? Enter a CSS font-family manually (e.g. "My Font", monospace)'}),s.jsx("input",{type:"text",value:a,onChange:x=>o(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&g()},className:"w-full px-2 py-1 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})]})]})}function ZO(){const{settings:e,getSetting:t,setSetting:n}=pa(),r=e[je.DISPLAY_CUSTOM_CSS]??"",[a,o]=k.useState(r);k.useEffect(()=>{t(je.DISPLAY_CUSTOM_CSS)},[t]),k.useEffect(()=>{o(r)},[r]);const d=()=>{n(je.DISPLAY_CUSTOM_CSS,a)};return s.jsx("div",{className:"space-y-2",children:s.jsx("textarea",{value:a,onChange:u=>o(u.target.value),onBlur:d,placeholder:"/* Paste your custom CSS here */",className:"w-full h-32 px-3 py-2 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded resize-y focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})})}function gy(){const[e,t]=k.useState("Test"),[n,r]=k.useState(""),[a,o]=k.useState(!1),d=k.useCallback(async u=>{t("Testing..."),r(""),o(!1);try{const c=await u();c.success?(t("Success"),o(!0),setTimeout(()=>{t("Test"),o(!1)},3e3)):(r(c.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,a,d]}function eM(e){try{return new RegExp(e),!0}catch{return!1}}function tM({value:e,onChange:t}){const[n,r]=k.useState({}),a=(c,h)=>{const m=e.patterns.map((f,g)=>g===c?{...f,...h}:f);t({...e,patterns:m})},o=c=>{const h=e.patterns.filter((m,f)=>f!==c);t({...e,patterns:h})},d=()=>{const c={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,c]})},u=(c,h)=>{r(m=>({...m,[c]:h.length>0&&!eM(h)})),a(c,{pattern:h})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),s.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:c=>{const h=parseInt(c.target.value,10),m=isNaN(h)?10:Math.max(1,Math.min(100,h));t({...e,maxRetriesPerTurn:m})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?s.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[s.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),s.jsx("th",{className:"pb-2 pr-2",children:"Field"}),s.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),s.jsx("th",{className:"pb-2 pr-2",children:"Action"}),s.jsx("th",{className:"pb-2 w-8"})]})}),s.jsx("tbody",{children:e.patterns.map((c,h)=>s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("td",{className:"py-2 pr-2",children:s.jsx("input",{type:"checkbox",checked:c.active,onChange:()=>a(h,{active:!c.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${h+1}`})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("select",{value:c.field,onChange:m=>a(h,{field:m.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[s.jsx("option",{value:"content",children:"content"}),s.jsx("option",{value:"thinking",children:"thinking"}),s.jsx("option",{value:"both",children:"both"})]})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"text",value:c.pattern,onChange:m=>u(h,m.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),c.pattern.length>0&&s.jsx("span",{className:`text-sm ${n[h]?"text-red-500":"text-green-500"}`,children:n[h]?"✗":"✓"})]})}),s.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),s.jsx("td",{className:"py-2",children:s.jsx("button",{onClick:()=>o(h),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},h))})]}),s.jsx(ct,{variant:"secondary",onClick:d,children:"Add Pattern"})]})}const QE="openfox_last_version",JE="openfox_previous_version";function Ib(){return localStorage.getItem(QE)}function nM(){return localStorage.getItem(JE)}function ZE(e){e&&localStorage.setItem(JE,e)}function rM(e){if(!e)return;const t=Ib();t&&t!==e&&ZE(t),localStorage.setItem(QE,e)}function sM(e,t){if(!e||!t)return!1;const n=e.split(".").map(Number),r=t.split(".").map(Number);if(n.length!==3||r.length!==3||n.some(a=>!Number.isInteger(a))||r.some(a=>!Number.isInteger(a)))return!1;for(let a=0;a<3;a++){const o=n[a],d=r[a];if(o!==d)return o>d}return!1}const F1=1e3,iM=3e4;function z1({message:e,command:t,hint:n}){return s.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[s.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:[s.jsx("span",{children:"⚠️"}),s.jsx("p",{className:"text-text-secondary",children:e})]}),s.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:t}),s.jsx("p",{className:"text-xs text-text-muted",children:n})]})}function eN({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=k.useState("ready"),[o,d]=k.useState(""),[u,c]=k.useState(n),[h,m]=k.useState(null),[f,g]=k.useState(null),[x,w]=k.useState(!1),[C,v]=k.useState(!1),[S,_]=k.useState(!1),b=k.useRef(!1),j=k.useRef(null),E=k.useRef(null),N=k.useRef(!0),L=k.useRef(n);L.current=n,k.useEffect(()=>{if(!e)return;let Q=!1;return(async()=>{try{const I=await(await fetch(_s("/api/auto-update/check"))).json();if(Q)return;v(!!I.isService),!L.current&&I.current&&I.latest&&c({current:I.current,latest:I.latest})}catch{Q||v(!1)}})(),()=>{Q=!0}},[e]),k.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const Q=setInterval(()=>{d(H=>H.length>=3?"":H+".")},400);return()=>clearInterval(Q)},[e,r]);const A=k.useCallback(()=>{j.current!==null&&(clearTimeout(j.current),j.current=null),E.current=null},[]),D=k.useCallback(Q=>{g(Q),a("restartFailed")},[]),O=k.useCallback(Q=>{b.current=Q,_(Q)},[]),F=k.useCallback(Q=>{var I;const H=Ib()??((I=L.current)==null?void 0:I.current)??null;H&&H!==Q&&ZE(H),localStorage.setItem("openfox_updated_to",Q),localStorage.setItem("update_pending","true")},[]),P=k.useCallback(async Q=>{a("restarting"),g(null),A();try{await ye("/api/auto-update/restart",{method:"POST"})}catch{}if(!N.current)return;E.current=Date.now();const H=async()=>{if(!N.current){A();return}const I=E.current;if(I!==null&&Date.now()-I>=iM){A(),D("OpenFox could not be reached after restart within 30 seconds. Please restart OpenFox manually.");return}try{const M=await fetch(_s("/api/auto-update/check?force=true"));if(!M.ok)throw new Error(`HTTP ${M.status}`);if((await M.json()).current===Q){A(),F(Q),window.location.reload();return}}catch{}if(!N.current){A();return}j.current=setTimeout(()=>{H()},F1)};j.current=setTimeout(()=>{H()},F1)},[A,D,F]),z=k.useCallback(async()=>{a("updating"),g(null);try{const H=await(await ye("/api/auto-update",{method:"POST"})).json();if(H.success){const I=H.version??"unknown";m(I),w(!!H.isService),b.current&&H.isService?P(I):a("complete")}else g(H.error??"Update failed"),a("failed")}catch(Q){g(Q instanceof Error?Q.message:"Update request failed"),a("failed")}},[P]),K=k.useCallback(()=>{const Q=h??(u==null?void 0:u.latest)??null;if(!Q){D("Installed version unknown; cannot verify restart.");return}P(Q)},[h,u,D,P]);k.useEffect(()=>(N.current=!0,()=>{N.current=!1,A()}),[A]),k.useEffect(()=>{e&&(d(""),A(),a("ready"),m(null),g(null),w(!1),v(!1),O(!1))},[e,A,O]);const q=r!=="updating"&&r!=="restarting",W=Q=>Q,Z=r==="failed"?"Update Failed":r==="restarting"?"Restarting…":r==="complete"?"Update Complete":r==="restartFailed"?"Restart Not Confirmed":"New OpenFox version available";return s.jsxs(Et,{isOpen:e,onClose:q?t:void 0,title:Z,size:"md",closeOnBackdropClick:q,showCloseButton:q,children:[s.jsxs("div",{className:"flex flex-col gap-4",children:[u&&s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-text-muted",children:"Current version"}),s.jsx("span",{className:"text-text-primary font-mono",children:W(u.current)})]}),u&&s.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[s.jsx("span",{className:"text-text-muted",children:"Latest version"}),s.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:u.latest})]}),(r==="updating"||r==="restarting")&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),s.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",o]})]}),r==="complete"&&s.jsx("div",{className:"flex flex-col gap-3 mt-2",children:s.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h??(u==null?void 0:u.latest),".",x?' Click "Restart OpenFox now" to apply the update.':" Please restart OpenFox to use the new version."]})}),r==="failed"&&s.jsx(z1,{message:f,command:"openfox update",hint:"Run this command in your terminal to complete the update."}),r==="restartFailed"&&s.jsx(z1,{message:f,command:"openfox service restart",hint:"Run this command in your terminal to restart OpenFox."})]}),r==="ready"&&s.jsx("button",{onClick:z,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="ready"||r==="updating")&&C&&s.jsxs("label",{className:"flex items-center justify-center gap-2 text-xs text-text-muted cursor-pointer select-none mt-2",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:Q=>O(Q.target.checked)}),"Auto-restart once update is done"]}),r==="complete"&&x&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("button",{onClick:K,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Restart OpenFox now"}),s.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",children:"Later"})]}),r==="complete"&&!x&&s.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==="failed"||r==="restartFailed")&&s.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"})]})}function mn({children:e,className:t="",horizontal:n=!1,style:r,scope:a="toolCalls"}){const{useNativeScrollbars:o,useNativeScrollbarsCodeBlocks:d}=Hs();if(a==="codeBlocks"?d:o){const c=n?"overflow-x-auto":"overflow-y-auto";return s.jsx("div",{className:`${c} ${t}`.trim(),style:r,children:e})}return s.jsx(mt,{horizontal:n,className:t,style:r,children:e})}function aM(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const oM=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lM=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cM={};function H1(e,t){return(cM.jsx?lM:oM).test(e)}const uM=/[ \t\n\f\r]/g;function dM(e){return typeof e=="object"?e.type==="text"?U1(e.value):!1:U1(e)}function U1(e){return e.replace(uM,"")===""}let Ru=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Ru.prototype.normal={};Ru.prototype.property={};Ru.prototype.space=void 0;function tN(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ru(n,r,t)}function xy(e){return e.toLowerCase()}let Cr=class{constructor(t,n){this.attribute=n,this.property=t}};Cr.prototype.attribute="";Cr.prototype.booleanish=!1;Cr.prototype.boolean=!1;Cr.prototype.commaOrSpaceSeparated=!1;Cr.prototype.commaSeparated=!1;Cr.prototype.defined=!1;Cr.prototype.mustUseProperty=!1;Cr.prototype.number=!1;Cr.prototype.overloadedBoolean=!1;Cr.prototype.property="";Cr.prototype.spaceSeparated=!1;Cr.prototype.space=void 0;let hM=0;const vt=co(),On=co(),yy=co(),Ge=co(),rn=co(),no=co(),Or=co();function co(){return 2**++hM}const by=Object.freeze(Object.defineProperty({__proto__:null,boolean:vt,booleanish:On,commaOrSpaceSeparated:Or,commaSeparated:no,number:Ge,overloadedBoolean:yy,spaceSeparated:rn},Symbol.toStringTag,{value:"Module"})),ex=Object.keys(by);let Pb=class extends Cr{constructor(t,n,r,a){let o=-1;if(super(t,n),V1(this,"space",a),typeof r=="number")for(;++o<ex.length;){const d=ex[o];V1(this,ex[o],(r&by[d])===by[d])}}};Pb.prototype.defined=!0;function V1(e,t,n){n&&(e[t]=n)}function Bl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new Pb(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[xy(r)]=r,n[xy(o.attribute)]=r}return new Ru(t,n,e.space)}const nN=Bl({properties:{ariaActiveDescendant:null,ariaAtomic:On,ariaAutoComplete:null,ariaBusy:On,ariaChecked:On,ariaColCount:Ge,ariaColIndex:Ge,ariaColSpan:Ge,ariaControls:rn,ariaCurrent:null,ariaDescribedBy:rn,ariaDetails:null,ariaDisabled:On,ariaDropEffect:rn,ariaErrorMessage:null,ariaExpanded:On,ariaFlowTo:rn,ariaGrabbed:On,ariaHasPopup:null,ariaHidden:On,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:rn,ariaLevel:Ge,ariaLive:null,ariaModal:On,ariaMultiLine:On,ariaMultiSelectable:On,ariaOrientation:null,ariaOwns:rn,ariaPlaceholder:null,ariaPosInSet:Ge,ariaPressed:On,ariaReadOnly:On,ariaRelevant:null,ariaRequired:On,ariaRoleDescription:rn,ariaRowCount:Ge,ariaRowIndex:Ge,ariaRowSpan:Ge,ariaSelected:On,ariaSetSize:Ge,ariaSort:null,ariaValueMax:Ge,ariaValueMin:Ge,ariaValueNow:Ge,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function rN(e,t){return t in e?e[t]:t}function sN(e,t){return rN(e,t.toLowerCase())}const fM=Bl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:no,acceptCharset:rn,accessKey:rn,action:null,allow:null,allowFullScreen:vt,allowPaymentRequest:vt,allowUserMedia:vt,alpha:vt,alt:null,as:null,async:vt,autoCapitalize:null,autoComplete:rn,autoFocus:vt,autoPlay:vt,blocking:rn,capture:null,charSet:null,checked:vt,cite:null,className:rn,closedBy:null,colorSpace:null,cols:Ge,colSpan:Ge,command:null,commandFor:null,content:null,contentEditable:On,controls:vt,controlsList:rn,coords:Ge|no,crossOrigin:null,data:null,dateTime:null,decoding:null,default:vt,defer:vt,dir:null,dirName:null,disabled:vt,download:yy,draggable:On,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:vt,formTarget:null,headers:rn,height:Ge,hidden:yy,high:Ge,href:null,hrefLang:null,htmlFor:rn,httpEquiv:rn,id:null,imageSizes:null,imageSrcSet:null,inert:vt,inputMode:null,integrity:null,is:null,isMap:vt,itemId:null,itemProp:rn,itemRef:rn,itemScope:vt,itemType:rn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:vt,low:Ge,manifest:null,max:null,maxLength:Ge,media:null,method:null,min:null,minLength:Ge,multiple:vt,muted:vt,name:null,nonce:null,noModule:vt,noValidate:vt,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:vt,optimum:Ge,pattern:null,ping:rn,placeholder:null,playsInline:vt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:vt,referrerPolicy:null,rel:rn,required:vt,reversed:vt,rows:Ge,rowSpan:Ge,sandbox:rn,scope:null,scoped:vt,seamless:vt,selected:vt,shadowRootClonable:vt,shadowRootCustomElementRegistry:vt,shadowRootDelegatesFocus:vt,shadowRootMode:null,shadowRootSerializable:vt,shape:null,size:Ge,sizes:null,slot:null,span:Ge,spellCheck:On,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ge,step:null,style:null,tabIndex:Ge,target:null,title:null,translate:null,type:null,typeMustMatch:vt,useMap:null,value:On,width:Ge,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:rn,axis:null,background:null,bgColor:null,border:Ge,borderColor:null,bottomMargin:Ge,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:vt,declare:vt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ge,leftMargin:Ge,link:null,longDesc:null,lowSrc:null,marginHeight:Ge,marginWidth:Ge,noResize:vt,noHref:vt,noShade:vt,noWrap:vt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ge,rules:null,scheme:null,scrolling:On,standby:null,summary:null,text:null,topMargin:Ge,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ge,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:vt,disablePictureInPicture:vt,disableRemotePlayback:vt,exportParts:no,part:rn,prefix:null,property:null,results:Ge,security:null,unselectable:null},space:"html",transform:sN}),mM=Bl({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",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Or,accentHeight:Ge,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ge,amplitude:Ge,arabicForm:null,ascent:Ge,attributeName:null,attributeType:null,azimuth:Ge,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ge,by:null,calcMode:null,capHeight:Ge,className:rn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ge,diffuseConstant:Ge,direction:null,display:null,dur:null,divisor:Ge,dominantBaseline:null,download:vt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ge,enableBackground:null,end:null,event:null,exponent:Ge,externalResourcesRequired:null,fill:null,fillOpacity:Ge,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:no,g2:no,glyphName:no,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ge,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ge,horizOriginX:Ge,horizOriginY:Ge,id:null,ideographic:Ge,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ge,k:Ge,k1:Ge,k2:Ge,k3:Ge,k4:Ge,kernelMatrix:Or,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ge,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ge,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:Ge,overlineThickness:Ge,paintOrder:null,panose1:null,path:null,pathLength:Ge,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:rn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ge,pointsAtY:Ge,pointsAtZ:Ge,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Or,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Or,rev:Or,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Or,requiredFeatures:Or,requiredFonts:Or,requiredFormats:Or,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ge,specularExponent:Ge,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ge,strikethroughThickness:Ge,string:null,stroke:null,strokeDashArray:Or,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ge,strokeOpacity:Ge,strokeWidth:null,style:null,surfaceScale:Ge,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Or,tabIndex:Ge,tableValues:null,target:null,targetX:Ge,targetY:Ge,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Or,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ge,underlineThickness:Ge,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ge,values:null,vAlphabetic:Ge,vMathematical:Ge,vectorEffect:null,vHanging:Ge,vIdeographic:Ge,version:null,vertAdvY:Ge,vertOriginX:Ge,vertOriginY:Ge,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ge,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:rN}),iN=Bl({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()}}),aN=Bl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:sN}),oN=Bl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),pM={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"},gM=/[A-Z]/g,W1=/-[a-z]/g,xM=/^data[-\w.:]+$/i;function yM(e,t){const n=xy(t);let r=t,a=Cr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&xM.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(W1,vM);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!W1.test(o)){let d=o.replace(gM,bM);d.charAt(0)!=="-"&&(d="-"+d),t="data"+d}}a=Pb}return new a(r,t)}function bM(e){return"-"+e.toLowerCase()}function vM(e){return e.charAt(1).toUpperCase()}const _M=tN([nN,fM,iN,aN,oN],"html"),Bb=tN([nN,mM,iN,aN,oN],"svg");function SM(e){return e.join(" ").trim()}var Jo={},tx,G1;function wM(){if(G1)return tx;G1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,u=/^\s+|\s+$/g,c=`
68
+ `,h="/",m="*",f="",g="comment",x="declaration";function w(v,S){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];S=S||{};var _=1,b=1;function j(K){var q=K.match(t);q&&(_+=q.length);var W=K.lastIndexOf(c);b=~W?K.length-W:b+K.length}function E(){var K={line:_,column:b};return function(q){return q.position=new N(K),D(),q}}function N(K){this.start=K,this.end={line:_,column:b},this.source=S.source}N.prototype.content=v;function L(K){var q=new Error(S.source+":"+_+":"+b+": "+K);if(q.reason=K,q.filename=S.source,q.line=_,q.column=b,q.source=v,!S.silent)throw q}function A(K){var q=K.exec(v);if(q){var W=q[0];return j(W),v=v.slice(W.length),q}}function D(){A(n)}function O(K){var q;for(K=K||[];q=F();)q!==!1&&K.push(q);return K}function F(){var K=E();if(!(h!=v.charAt(0)||m!=v.charAt(1))){for(var q=2;f!=v.charAt(q)&&(m!=v.charAt(q)||h!=v.charAt(q+1));)++q;if(q+=2,f===v.charAt(q-1))return L("End of comment missing");var W=v.slice(2,q-2);return b+=2,j(W),v=v.slice(q),b+=2,K({type:g,comment:W})}}function P(){var K=E(),q=A(r);if(q){if(F(),!A(a))return L("property missing ':'");var W=A(o),Z=K({type:x,property:C(q[0].replace(e,f)),value:W?C(W[0].replace(e,f)):f});return A(d),Z}}function z(){var K=[];O(K);for(var q;q=P();)q!==!1&&(K.push(q),O(K));return K}return D(),z()}function C(v){return v?v.replace(u,f):f}return tx=w,tx}var q1;function CM(){if(q1)return Jo;q1=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(wM());function n(r,a){let o=null;if(!r||typeof r!="string")return o;const d=(0,t.default)(r),u=typeof a=="function";return d.forEach(c=>{if(c.type!=="declaration")return;const{property:h,value:m}=c;u?a(h,m,c):m&&(o=o||{},o[h]=m)}),o}return Jo}var zc={},K1;function kM(){if(K1)return zc;K1=1,Object.defineProperty(zc,"__esModule",{value:!0}),zc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},d=function(h,m){return m.toUpperCase()},u=function(h,m){return"".concat(m,"-")},c=function(h,m){return m===void 0&&(m={}),o(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(a,u):h=h.replace(r,u),h.replace(t,d))};return zc.camelCase=c,zc}var Hc,Y1;function jM(){if(Y1)return Hc;Y1=1;var e=Hc&&Hc.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(CM()),n=kM();function r(a,o){var d={};return!a||typeof a!="string"||(0,t.default)(a,function(u,c){u&&c&&(d[(0,n.camelCase)(u,o)]=c)}),d}return r.default=r,Hc=r,Hc}var EM=jM();const NM=Lf(EM),lN=cN("end"),$b=cN("start");function cN(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 TM(e){const t=$b(e),n=lN(e);if(t&&n)return{start:t,end:n}}function ru(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?X1(e.position):"start"in e||"end"in e?X1(e):"line"in e||"column"in e?vy(e):""}function vy(e){return Q1(e&&e.line)+":"+Q1(e&&e.column)}function X1(e){return vy(e&&e.start)+"-"+vy(e&&e.end)}function Q1(e){return e&&typeof e=="number"?e:1}class ar extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",o={},d=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(d=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=u?u.line:void 0,this.name=ru(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=d&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ar.prototype.file="";ar.prototype.name="";ar.prototype.reason="";ar.prototype.message="";ar.prototype.stack="";ar.prototype.column=void 0;ar.prototype.line=void 0;ar.prototype.ancestors=void 0;ar.prototype.cause=void 0;ar.prototype.fatal=void 0;ar.prototype.place=void 0;ar.prototype.ruleId=void 0;ar.prototype.source=void 0;const Fb={}.hasOwnProperty,AM=new Map,LM=/[A-Z]/g,RM=new Set(["table","tbody","thead","tfoot","tr"]),DM=new Set(["td","th"]),uN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function OM(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=HM(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=zM(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Bb:_M,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=dN(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function dN(e,t,n){if(t.type==="element")return MM(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return IM(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return BM(e,t,n);if(t.type==="mdxjsEsm")return PM(e,t);if(t.type==="root")return $M(e,t,n);if(t.type==="text")return FM(e,t)}function MM(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=Bb,e.schema=a),e.ancestors.push(t);const o=fN(e,t.tagName,!1),d=UM(e,t);let u=Hb(e,t);return RM.has(t.tagName)&&(u=u.filter(function(c){return typeof c=="string"?!dM(c):!0})),hN(e,d,o,t),zb(d,u),e.ancestors.pop(),e.schema=r,e.create(t,o,d,n)}function IM(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)}bu(e,t.position)}function PM(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);bu(e,t.position)}function BM(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=Bb,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:fN(e,t.name,!0),d=VM(e,t),u=Hb(e,t);return hN(e,d,o,t),zb(d,u),e.ancestors.pop(),e.schema=r,e.create(t,o,d,n)}function $M(e,t,n){const r={};return zb(r,Hb(e,t)),e.create(t,e.Fragment,r,n)}function FM(e,t){return t.value}function hN(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function zb(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function zM(e,t,n){return r;function r(a,o,d,u){const h=Array.isArray(d.children)?n:t;return u?h(o,d,u):h(o,d)}}function HM(e,t){return n;function n(r,a,o,d){const u=Array.isArray(o.children),c=$b(r);return t(a,o,d,u,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function UM(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&Fb.call(t.properties,a)){const o=WM(e,a,t.properties[a]);if(o){const[d,u]=o;e.tableCellAlignToStyle&&d==="align"&&typeof u=="string"&&DM.has(t.tagName)?r=u:n[d]=u}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function VM(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const d=o.expression;d.type;const u=d.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else bu(e,t.position);else{const a=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const u=r.value.data.estree.body[0];u.type,o=e.evaluater.evaluateExpression(u.expression)}else bu(e,t.position);else o=r.value===null?!0:r.value;n[a]=o}return n}function Hb(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:AM;for(;++r<t.children.length;){const o=t.children[r];let d;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const h=a.get(c)||0;d=c+"-"+h,a.set(c,h+1)}}const u=dN(e,o,d);u!==void 0&&n.push(u)}return n}function WM(e,t,n){const r=yM(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?aM(n):SM(n)),r.property==="style"){let a=typeof n=="object"?n:GM(e,String(n));return e.stylePropertyNameCase==="css"&&(a=qM(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?pM[r.property]||r.property:r.attribute,n]}}function GM(e,t){try{return NM(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new ar("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=uN+"#cannot-parse-style-attribute",a}}function fN(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,d;for(;++o<a.length;){const u=H1(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};d=d?{type:"MemberExpression",object:d,property:u,computed:!!(o&&u.type==="Literal"),optional:!1}:u}r=d}else r=H1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return Fb.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);bu(e)}function bu(e,t){const n=new ar("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=uN+"#cannot-handle-mdx-estrees-without-createevaluater",n}function qM(e){const t={};let n;for(n in e)Fb.call(e,n)&&(t[KM(n)]=e[n]);return t}function KM(e){let t=e.replace(LM,YM);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function YM(e){return"-"+e.toLowerCase()}const nx={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"]},XM={};function Ub(e,t){const n=XM,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return mN(e,r,a)}function mN(e,t,n){if(QM(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 J1(e.children,t,n)}return Array.isArray(e)?J1(e,t,n):""}function J1(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=mN(e[a],t,n);return r.join("")}function QM(e){return!!(e&&typeof e=="object")}const Z1=document.createElement("i");function Vb(e){const t="&"+e+";";Z1.innerHTML=t;const n=Z1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $r(e,t,n,r){const a=e.length;let o=0,d;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)d=Array.from(r),d.unshift(t,n),e.splice(...d);else for(n&&e.splice(t,n);o<r.length;)d=r.slice(o,o+1e4),d.unshift(t,0),e.splice(...d),o+=1e4,t+=1e4}function Zr(e,t){return e.length>0?($r(e,e.length,0,t),e):t}const eC={}.hasOwnProperty;function pN(e){const t={};let n=-1;for(;++n<e.length;)JM(t,e[n]);return t}function JM(e,t){let n;for(n in t){const a=(eC.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let d;if(o)for(d in o){eC.call(a,d)||(a[d]=[]);const u=o[d];ZM(a[d],Array.isArray(u)?u:u?[u]:[])}}}function ZM(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 gN(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 bs(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dr=ga(/[A-Za-z]/),ir=ga(/[\dA-Za-z]/),eI=ga(/[#-'*+\--9=?A-Z^-~]/);function rf(e){return e!==null&&(e<32||e===127)}const _y=ga(/\d/),tI=ga(/[\dA-Fa-f]/),nI=ga(/[!-/:-@[-`{-~]/);function pt(e){return e!==null&&e<-2}function ln(e){return e!==null&&(e<0||e===32)}function At(e){return e===-2||e===-1||e===32}const tm=ga(new RegExp("\\p{P}|\\p{S}","u")),ao=ga(/\s/);function ga(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function $l(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const o=e.charCodeAt(n);let d="";if(o===37&&ir(e.charCodeAt(n+1))&&ir(e.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(d=String.fromCharCode(o));else if(o>55295&&o<57344){const u=e.charCodeAt(n+1);o<56320&&u>56319&&u<57344?(d=String.fromCharCode(o,u),a=1):d="�"}else d=String.fromCharCode(o);d&&(t.push(e.slice(r,n),encodeURIComponent(d)),r=n+a+1,d=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function It(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let o=0;return d;function d(c){return At(c)?(e.enter(n),u(c)):t(c)}function u(c){return At(c)&&o++<a?(e.consume(c),u):(e.exit(n),t(c))}}const rI={tokenize:sI};function sI(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),It(e,t,"linePrefix")}function a(u){return e.enter("paragraph"),o(u)}function o(u){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,d(u)}function d(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return pt(u)?(e.consume(u),e.exit("chunkText"),o):(e.consume(u),d)}}const iI={tokenize:aI},tC={tokenize:oI};function aI(e){const t=this,n=[];let r=0,a,o,d;return u;function u(b){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,c,h)(b)}return h(b)}function c(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&_();const j=t.events.length;let E=j,N;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){N=t.events[E][1].end;break}S(r);let L=j;for(;L<t.events.length;)t.events[L][1].end={...N},L++;return $r(t.events,E+1,0,t.events.slice(j)),t.events.length=L,h(b)}return u(b)}function h(b){if(r===n.length){if(!a)return g(b);if(a.currentConstruct&&a.currentConstruct.concrete)return w(b);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(tC,m,f)(b)}function m(b){return a&&_(),S(r),g(b)}function f(b){return t.parser.lazy[t.now().line]=r!==n.length,d=t.now().offset,w(b)}function g(b){return t.containerState={},e.attempt(tC,x,w)(b)}function x(b){return r++,n.push([t.currentConstruct,t.containerState]),g(b)}function w(b){if(b===null){a&&_(),S(0),e.consume(b);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),C(b)}function C(b){if(b===null){v(e.exit("chunkFlow"),!0),S(0),e.consume(b);return}return pt(b)?(e.consume(b),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,u):(e.consume(b),C)}function v(b,j){const E=t.sliceStream(b);if(j&&E.push(null),b.previous=o,o&&(o.next=b),o=b,a.defineSkip(b.start),a.write(E),t.parser.lazy[b.start.line]){let N=a.events.length;for(;N--;)if(a.events[N][1].start.offset<d&&(!a.events[N][1].end||a.events[N][1].end.offset>d))return;const L=t.events.length;let A=L,D,O;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(D){O=t.events[A][1].end;break}D=!0}for(S(r),N=L;N<t.events.length;)t.events[N][1].end={...O},N++;$r(t.events,A+1,0,t.events.slice(L)),t.events.length=N}}function S(b){let j=n.length;for(;j-- >b;){const E=n[j];t.containerState=E[1],E[0].exit.call(t,e)}n.length=b}function _(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function oI(e,t,n){return It(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Tl(e){if(e===null||ln(e)||ao(e))return 1;if(tm(e))return 2}function nm(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Sy={name:"attention",resolveAll:lI,tokenize:cI};function lI(e,t){let n=-1,r,a,o,d,u,c,h,m;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=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 f={...e[r][1].end},g={...e[n][1].start};nC(f,-c),nC(g,c),d={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},u={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:c>1?"strong":"emphasis",start:{...d.start},end:{...u.end}},e[r][1].end={...d.start},e[n][1].start={...u.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=Zr(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=Zr(h,[["enter",a,t],["enter",d,t],["exit",d,t],["enter",o,t]]),h=Zr(h,nm(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=Zr(h,[["exit",o,t],["enter",u,t],["exit",u,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,h=Zr(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,$r(e,r-1,n-r+3,h),n=r+h.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function cI(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Tl(r);let o;return d;function d(c){return o=c,e.enter("attentionSequence"),u(c)}function u(c){if(c===o)return e.consume(c),u;const h=e.exit("attentionSequence"),m=Tl(c),f=!m||m===2&&a||n.includes(c),g=!a||a===2&&m||n.includes(r);return h._open=!!(o===42?f:f&&(a||!g)),h._close=!!(o===42?g:g&&(m||!f)),t(c)}}function nC(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const uI={name:"autolink",tokenize:dI};function dI(e,t,n){let r=0;return a;function a(x){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(x){return dr(x)?(e.consume(x),d):x===64?n(x):h(x)}function d(x){return x===43||x===45||x===46||ir(x)?(r=1,u(x)):h(x)}function u(x){return x===58?(e.consume(x),r=0,c):(x===43||x===45||x===46||ir(x))&&r++<32?(e.consume(x),u):(r=0,h(x))}function c(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||rf(x)?n(x):(e.consume(x),c)}function h(x){return x===64?(e.consume(x),m):eI(x)?(e.consume(x),h):n(x)}function m(x){return ir(x)?f(x):n(x)}function f(x){return x===46?(e.consume(x),r=0,m):x===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):g(x)}function g(x){if((x===45||ir(x))&&r++<63){const w=x===45?g:f;return e.consume(x),w}return n(x)}}const Du={partial:!0,tokenize:hI};function hI(e,t,n){return r;function r(o){return At(o)?It(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||pt(o)?t(o):n(o)}}const xN={continuation:{tokenize:mI},exit:pI,name:"blockQuote",tokenize:fI};function fI(e,t,n){const r=this;return a;function a(d){if(d===62){const u=r.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),o}return n(d)}function o(d){return At(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(d))}}function mI(e,t,n){const r=this;return a;function a(d){return At(d)?It(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):o(d)}function o(d){return e.attempt(xN,t,n)(d)}}function pI(e){e.exit("blockQuote")}const yN={name:"characterEscape",tokenize:gI};function gI(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return nI(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const bN={name:"characterReference",tokenize:xI};function xI(e,t,n){const r=this;let a=0,o,d;return u;function u(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),o=31,d=ir,m(f))}function h(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,d=tI,m):(e.enter("characterReferenceValue"),o=7,d=_y,m(f))}function m(f){if(f===59&&a){const g=e.exit("characterReferenceValue");return d===ir&&!Vb(r.sliceSerialize(g))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return d(f)&&a++<o?(e.consume(f),m):n(f)}}const rC={partial:!0,tokenize:bI},sC={concrete:!0,name:"codeFenced",tokenize:yI};function yI(e,t,n){const r=this,a={partial:!0,tokenize:E};let o=0,d=0,u;return c;function c(N){return h(N)}function h(N){const L=r.events[r.events.length-1];return o=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,u=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(N)}function m(N){return N===u?(d++,e.consume(N),m):d<3?n(N):(e.exit("codeFencedFenceSequence"),At(N)?It(e,f,"whitespace")(N):f(N))}function f(N){return N===null||pt(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(rC,C,j)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(N))}function g(N){return N===null||pt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(N)):At(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),It(e,x,"whitespace")(N)):N===96&&N===u?n(N):(e.consume(N),g)}function x(N){return N===null||pt(N)?f(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(N))}function w(N){return N===null||pt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(N)):N===96&&N===u?n(N):(e.consume(N),w)}function C(N){return e.attempt(a,j,v)(N)}function v(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),S}function S(N){return o>0&&At(N)?It(e,_,"linePrefix",o+1)(N):_(N)}function _(N){return N===null||pt(N)?e.check(rC,C,j)(N):(e.enter("codeFlowValue"),b(N))}function b(N){return N===null||pt(N)?(e.exit("codeFlowValue"),_(N)):(e.consume(N),b)}function j(N){return e.exit("codeFenced"),t(N)}function E(N,L,A){let D=0;return O;function O(q){return N.enter("lineEnding"),N.consume(q),N.exit("lineEnding"),F}function F(q){return N.enter("codeFencedFence"),At(q)?It(N,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):P(q)}function P(q){return q===u?(N.enter("codeFencedFenceSequence"),z(q)):A(q)}function z(q){return q===u?(D++,N.consume(q),z):D>=d?(N.exit("codeFencedFenceSequence"),At(q)?It(N,K,"whitespace")(q):K(q)):A(q)}function K(q){return q===null||pt(q)?(N.exit("codeFencedFence"),L(q)):A(q)}}}function bI(e,t,n){const r=this;return a;function a(d){return d===null?n(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o)}function o(d){return r.parser.lazy[r.now().line]?n(d):t(d)}}const rx={name:"codeIndented",tokenize:_I},vI={partial:!0,tokenize:SI};function _I(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),It(e,o,"linePrefix",5)(h)}function o(h){const m=r.events[r.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?d(h):n(h)}function d(h){return h===null?c(h):pt(h)?e.attempt(vI,d,c)(h):(e.enter("codeFlowValue"),u(h))}function u(h){return h===null||pt(h)?(e.exit("codeFlowValue"),d(h)):(e.consume(h),u)}function c(h){return e.exit("codeIndented"),t(h)}}function SI(e,t,n){const r=this;return a;function a(d){return r.parser.lazy[r.now().line]?n(d):pt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),a):It(e,o,"linePrefix",5)(d)}function o(d){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(d):pt(d)?a(d):n(d)}}const wI={name:"codeText",previous:kI,resolve:CI,tokenize:jI};function CI(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function kI(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function jI(e,t,n){let r=0,a,o;return d;function d(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),r++,u):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(o=e.enter("codeTextSequence"),a=0,m(f)):pt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),h(f))}function h(f){return f===null||f===32||f===96||pt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),h)}function m(f){return f===96?(e.consume(f),a++,m):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",h(f))}}class EI{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&Uc(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Uc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Uc(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);Uc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Uc(this.left,n.reverse())}}}function Uc(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 vN(e){const t={};let n=-1,r,a,o,d,u,c,h;const m=new EI(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(r=m.get(n),n&&r[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,NI(m,n)),n=t[n],h=!0);else if(r[1]._container){for(o=n,a=void 0;o--;)if(d=m.get(o),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(a&&(m.get(a)[1].type="lineEndingBlank"),d[1].type="lineEnding",a=o);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;a&&(r[1].end={...m.get(a)[1].start},u=m.slice(a,n),u.unshift(r),m.splice(a,n-a+1,u))}}return $r(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!h}function NI(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const o=[];let d=n._tokenizer;d||(d=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const u=d.events,c=[],h={};let m,f,g=-1,x=n,w=0,C=0;const v=[C];for(;x;){for(;e.get(++a)[1]!==x;);o.push(a),x._tokenizer||(m=r.sliceStream(x),x.next||m.push(null),f&&d.defineSkip(x.start),x._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(m),x._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),f=x,x=x.next}for(x=n;++g<u.length;)u[g][0]==="exit"&&u[g-1][0]==="enter"&&u[g][1].type===u[g-1][1].type&&u[g][1].start.line!==u[g][1].end.line&&(C=g+1,v.push(C),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(d.events=[],x?(x._tokenizer=void 0,x.previous=void 0):v.pop(),g=v.length;g--;){const S=u.slice(v[g],v[g+1]),_=o.pop();c.push([_,_+S.length-1]),e.splice(_,2,S)}for(c.reverse(),g=-1;++g<c.length;)h[w+c[g][0]]=w+c[g][1],w+=c[g][1]-c[g][0]-1;return h}const TI={resolve:LI,tokenize:RI},AI={partial:!0,tokenize:DI};function LI(e){return vN(e),e}function RI(e,t){let n;return r;function r(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(u)}function a(u){return u===null?o(u):pt(u)?e.check(AI,d,o)(u):(e.consume(u),a)}function o(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function d(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function DI(e,t,n){const r=this;return a;function a(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),It(e,o,"linePrefix")}function o(d){if(d===null||pt(d))return n(d);const u=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(d):e.interrupt(r.parser.constructs.flow,n,t)(d)}}function _N(e,t,n,r,a,o,d,u,c){const h=c||Number.POSITIVE_INFINITY;let m=0;return f;function f(S){return S===60?(e.enter(r),e.enter(a),e.enter(o),e.consume(S),e.exit(o),g):S===null||S===32||S===41||rf(S)?n(S):(e.enter(r),e.enter(d),e.enter(u),e.enter("chunkString",{contentType:"string"}),C(S))}function g(S){return S===62?(e.enter(o),e.consume(S),e.exit(o),e.exit(a),e.exit(r),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),x(S))}function x(S){return S===62?(e.exit("chunkString"),e.exit(u),g(S)):S===null||S===60||pt(S)?n(S):(e.consume(S),S===92?w:x)}function w(S){return S===60||S===62||S===92?(e.consume(S),x):x(S)}function C(S){return!m&&(S===null||S===41||ln(S))?(e.exit("chunkString"),e.exit(u),e.exit(d),e.exit(r),t(S)):m<h&&S===40?(e.consume(S),m++,C):S===41?(e.consume(S),m--,C):S===null||S===32||S===40||rf(S)?n(S):(e.consume(S),S===92?v:C)}function v(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function SN(e,t,n,r,a,o){const d=this;let u=0,c;return h;function h(x){return e.enter(r),e.enter(a),e.consume(x),e.exit(a),e.enter(o),m}function m(x){return u>999||x===null||x===91||x===93&&!c||x===94&&!u&&"_hiddenFootnoteSupport"in d.parser.constructs?n(x):x===93?(e.exit(o),e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):pt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),f(x))}function f(x){return x===null||x===91||x===93||pt(x)||u++>999?(e.exit("chunkString"),m(x)):(e.consume(x),c||(c=!At(x)),x===92?g:f)}function g(x){return x===91||x===92||x===93?(e.consume(x),u++,f):f(x)}}function wN(e,t,n,r,a,o){let d;return u;function u(g){return g===34||g===39||g===40?(e.enter(r),e.enter(a),e.consume(g),e.exit(a),d=g===40?41:g,c):n(g)}function c(g){return g===d?(e.enter(a),e.consume(g),e.exit(a),e.exit(r),t):(e.enter(o),h(g))}function h(g){return g===d?(e.exit(o),c(d)):g===null?n(g):pt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),It(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===d||g===null||pt(g)?(e.exit("chunkString"),h(g)):(e.consume(g),g===92?f:m)}function f(g){return g===d||g===92?(e.consume(g),m):m(g)}}function su(e,t){let n;return r;function r(a){return pt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):At(a)?It(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const OI={name:"definition",tokenize:II},MI={partial:!0,tokenize:PI};function II(e,t,n){const r=this;let a;return o;function o(x){return e.enter("definition"),d(x)}function d(x){return SN.call(r,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function u(x){return a=bs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),c):n(x)}function c(x){return ln(x)?su(e,h)(x):h(x)}function h(x){return _N(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function m(x){return e.attempt(MI,f,f)(x)}function f(x){return At(x)?It(e,g,"whitespace")(x):g(x)}function g(x){return x===null||pt(x)?(e.exit("definition"),r.parser.defined.push(a),t(x)):n(x)}}function PI(e,t,n){return r;function r(u){return ln(u)?su(e,a)(u):n(u)}function a(u){return wN(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return At(u)?It(e,d,"whitespace")(u):d(u)}function d(u){return u===null||pt(u)?t(u):n(u)}}const BI={name:"hardBreakEscape",tokenize:$I};function $I(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return pt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const FI={name:"headingAtx",resolve:zI,tokenize:HI};function zI(e,t){let n=e.length-2,r=3,a,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$r(e,r,n-r+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function HI(e,t,n){let r=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),d(m)}function d(m){return m===35&&r++<6?(e.consume(m),d):m===null||ln(m)?(e.exit("atxHeadingSequence"),u(m)):n(m)}function u(m){return m===35?(e.enter("atxHeadingSequence"),c(m)):m===null||pt(m)?(e.exit("atxHeading"),t(m)):At(m)?It(e,u,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function c(m){return m===35?(e.consume(m),c):(e.exit("atxHeadingSequence"),u(m))}function h(m){return m===null||m===35||ln(m)?(e.exit("atxHeadingText"),u(m)):(e.consume(m),h)}}const UI=["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"],iC=["pre","script","style","textarea"],VI={concrete:!0,name:"htmlFlow",resolveTo:qI,tokenize:KI},WI={partial:!0,tokenize:XI},GI={partial:!0,tokenize:YI};function qI(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 KI(e,t,n){const r=this;let a,o,d,u,c;return h;function h($){return m($)}function m($){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume($),f}function f($){return $===33?(e.consume($),g):$===47?(e.consume($),o=!0,C):$===63?(e.consume($),a=3,r.interrupt?t:I):dr($)?(e.consume($),d=String.fromCharCode($),v):n($)}function g($){return $===45?(e.consume($),a=2,x):$===91?(e.consume($),a=5,u=0,w):dr($)?(e.consume($),a=4,r.interrupt?t:I):n($)}function x($){return $===45?(e.consume($),r.interrupt?t:I):n($)}function w($){const ee="CDATA[";return $===ee.charCodeAt(u++)?(e.consume($),u===ee.length?r.interrupt?t:P:w):n($)}function C($){return dr($)?(e.consume($),d=String.fromCharCode($),v):n($)}function v($){if($===null||$===47||$===62||ln($)){const ee=$===47,Y=d.toLowerCase();return!ee&&!o&&iC.includes(Y)?(a=1,r.interrupt?t($):P($)):UI.includes(d.toLowerCase())?(a=6,ee?(e.consume($),S):r.interrupt?t($):P($)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n($):o?_($):b($))}return $===45||ir($)?(e.consume($),d+=String.fromCharCode($),v):n($)}function S($){return $===62?(e.consume($),r.interrupt?t:P):n($)}function _($){return At($)?(e.consume($),_):O($)}function b($){return $===47?(e.consume($),O):$===58||$===95||dr($)?(e.consume($),j):At($)?(e.consume($),b):O($)}function j($){return $===45||$===46||$===58||$===95||ir($)?(e.consume($),j):E($)}function E($){return $===61?(e.consume($),N):At($)?(e.consume($),E):b($)}function N($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),c=$,L):At($)?(e.consume($),N):A($)}function L($){return $===c?(e.consume($),c=null,D):$===null||pt($)?n($):(e.consume($),L)}function A($){return $===null||$===34||$===39||$===47||$===60||$===61||$===62||$===96||ln($)?E($):(e.consume($),A)}function D($){return $===47||$===62||At($)?b($):n($)}function O($){return $===62?(e.consume($),F):n($)}function F($){return $===null||pt($)?P($):At($)?(e.consume($),F):n($)}function P($){return $===45&&a===2?(e.consume($),W):$===60&&a===1?(e.consume($),Z):$===62&&a===4?(e.consume($),M):$===63&&a===3?(e.consume($),I):$===93&&a===5?(e.consume($),H):pt($)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(WI,V,z)($)):$===null||pt($)?(e.exit("htmlFlowData"),z($)):(e.consume($),P)}function z($){return e.check(GI,K,V)($)}function K($){return e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),q}function q($){return $===null||pt($)?z($):(e.enter("htmlFlowData"),P($))}function W($){return $===45?(e.consume($),I):P($)}function Z($){return $===47?(e.consume($),d="",Q):P($)}function Q($){if($===62){const ee=d.toLowerCase();return iC.includes(ee)?(e.consume($),M):P($)}return dr($)&&d.length<8?(e.consume($),d+=String.fromCharCode($),Q):P($)}function H($){return $===93?(e.consume($),I):P($)}function I($){return $===62?(e.consume($),M):$===45&&a===2?(e.consume($),I):P($)}function M($){return $===null||pt($)?(e.exit("htmlFlowData"),V($)):(e.consume($),M)}function V($){return e.exit("htmlFlow"),t($)}}function YI(e,t,n){const r=this;return a;function a(d){return pt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):n(d)}function o(d){return r.parser.lazy[r.now().line]?n(d):t(d)}}function XI(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Du,t,n)}}const QI={name:"htmlText",tokenize:JI};function JI(e,t,n){const r=this;let a,o,d;return u;function u(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),c}function c(I){return I===33?(e.consume(I),h):I===47?(e.consume(I),E):I===63?(e.consume(I),b):dr(I)?(e.consume(I),A):n(I)}function h(I){return I===45?(e.consume(I),m):I===91?(e.consume(I),o=0,w):dr(I)?(e.consume(I),_):n(I)}function m(I){return I===45?(e.consume(I),x):n(I)}function f(I){return I===null?n(I):I===45?(e.consume(I),g):pt(I)?(d=f,Z(I)):(e.consume(I),f)}function g(I){return I===45?(e.consume(I),x):f(I)}function x(I){return I===62?W(I):I===45?g(I):f(I)}function w(I){const M="CDATA[";return I===M.charCodeAt(o++)?(e.consume(I),o===M.length?C:w):n(I)}function C(I){return I===null?n(I):I===93?(e.consume(I),v):pt(I)?(d=C,Z(I)):(e.consume(I),C)}function v(I){return I===93?(e.consume(I),S):C(I)}function S(I){return I===62?W(I):I===93?(e.consume(I),S):C(I)}function _(I){return I===null||I===62?W(I):pt(I)?(d=_,Z(I)):(e.consume(I),_)}function b(I){return I===null?n(I):I===63?(e.consume(I),j):pt(I)?(d=b,Z(I)):(e.consume(I),b)}function j(I){return I===62?W(I):b(I)}function E(I){return dr(I)?(e.consume(I),N):n(I)}function N(I){return I===45||ir(I)?(e.consume(I),N):L(I)}function L(I){return pt(I)?(d=L,Z(I)):At(I)?(e.consume(I),L):W(I)}function A(I){return I===45||ir(I)?(e.consume(I),A):I===47||I===62||ln(I)?D(I):n(I)}function D(I){return I===47?(e.consume(I),W):I===58||I===95||dr(I)?(e.consume(I),O):pt(I)?(d=D,Z(I)):At(I)?(e.consume(I),D):W(I)}function O(I){return I===45||I===46||I===58||I===95||ir(I)?(e.consume(I),O):F(I)}function F(I){return I===61?(e.consume(I),P):pt(I)?(d=F,Z(I)):At(I)?(e.consume(I),F):D(I)}function P(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),a=I,z):pt(I)?(d=P,Z(I)):At(I)?(e.consume(I),P):(e.consume(I),K)}function z(I){return I===a?(e.consume(I),a=void 0,q):I===null?n(I):pt(I)?(d=z,Z(I)):(e.consume(I),z)}function K(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||ln(I)?D(I):(e.consume(I),K)}function q(I){return I===47||I===62||ln(I)?D(I):n(I)}function W(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function Z(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),Q}function Q(I){return At(I)?It(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):H(I)}function H(I){return e.enter("htmlTextData"),d(I)}}const Wb={name:"labelEnd",resolveAll:n4,resolveTo:r4,tokenize:s4},ZI={tokenize:i4},e4={tokenize:a4},t4={tokenize:o4};function n4(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&$r(e,0,e.length,n),e}function r4(e,t){let n=e.length,r=0,a,o,d,u;for(;n--;)if(a=e[n][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(d){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(d=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[o][1].start},end:{...e[d][1].end}},m={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[d-2][1].start}};return u=[["enter",c,t],["enter",h,t]],u=Zr(u,e.slice(o+1,o+r+3)),u=Zr(u,[["enter",m,t]]),u=Zr(u,nm(t.parser.constructs.insideSpan.null,e.slice(o+r+4,d-3),t)),u=Zr(u,[["exit",m,t],e[d-2],e[d-1],["exit",h,t]]),u=Zr(u,e.slice(d+1)),u=Zr(u,[["exit",c,t]]),$r(e,o,e.length,u),e}function s4(e,t,n){const r=this;let a=r.events.length,o,d;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){o=r.events[a][1];break}return u;function u(g){return o?o._inactive?f(g):(d=r.parser.defined.includes(bs(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),c):n(g)}function c(g){return g===40?e.attempt(ZI,m,d?m:f)(g):g===91?e.attempt(e4,m,d?h:f)(g):d?m(g):f(g)}function h(g){return e.attempt(t4,m,f)(g)}function m(g){return t(g)}function f(g){return o._balanced=!0,n(g)}}function i4(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),a}function a(f){return ln(f)?su(e,o)(f):o(f)}function o(f){return f===41?m(f):_N(e,d,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function d(f){return ln(f)?su(e,c)(f):m(f)}function u(f){return n(f)}function c(f){return f===34||f===39||f===40?wN(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):m(f)}function h(f){return ln(f)?su(e,m)(f):m(f)}function m(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function a4(e,t,n){const r=this;return a;function a(u){return SN.call(r,e,o,d,"reference","referenceMarker","referenceString")(u)}function o(u){return r.parser.defined.includes(bs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function d(u){return n(u)}}function o4(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),a}function a(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const l4={name:"labelStartImage",resolveAll:Wb.resolveAll,tokenize:c4};function c4(e,t,n){const r=this;return a;function a(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),o}function o(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),d):n(u)}function d(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const u4={name:"labelStartLink",resolveAll:Wb.resolveAll,tokenize:d4};function d4(e,t,n){const r=this;return a;function a(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),o}function o(d){return d===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(d):t(d)}}const sx={name:"lineEnding",tokenize:h4};function h4(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),It(e,t,"linePrefix")}}const Uh={name:"thematicBreak",tokenize:f4};function f4(e,t,n){let r=0,a;return o;function o(h){return e.enter("thematicBreak"),d(h)}function d(h){return a=h,u(h)}function u(h){return h===a?(e.enter("thematicBreakSequence"),c(h)):r>=3&&(h===null||pt(h))?(e.exit("thematicBreak"),t(h)):n(h)}function c(h){return h===a?(e.consume(h),r++,c):(e.exit("thematicBreakSequence"),At(h)?It(e,u,"whitespace")(h):u(h))}}const br={continuation:{tokenize:x4},exit:b4,name:"list",tokenize:g4},m4={partial:!0,tokenize:v4},p4={partial:!0,tokenize:y4};function g4(e,t,n){const r=this,a=r.events[r.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,d=0;return u;function u(x){const w=r.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||x===r.containerState.marker:_y(x)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),x===42||x===45?e.check(Uh,n,h)(x):h(x);if(!r.interrupt||x===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(x)}return n(x)}function c(x){return _y(x)&&++d<10?(e.consume(x),c):(!r.interrupt||d<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(Du,r.interrupt?n:m,e.attempt(m4,g,f))}function m(x){return r.containerState.initialBlankLine=!0,o++,g(x)}function f(x){return At(x)?(e.enter("listItemPrefixWhitespace"),e.consume(x),e.exit("listItemPrefixWhitespace"),g):n(x)}function g(x){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(x)}}function x4(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Du,a,o);function a(u){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,It(e,t,"listItemIndent",r.containerState.size+1)(u)}function o(u){return r.containerState.furtherBlankLines||!At(u)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,d(u)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(p4,t,d)(u))}function d(u){return r.containerState._closeFlow=!0,r.interrupt=void 0,It(e,e.attempt(br,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function y4(e,t,n){const r=this;return It(e,a,"listItemIndent",r.containerState.size+1);function a(o){const d=r.events[r.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===r.containerState.size?t(o):n(o)}}function b4(e){e.exit(this.containerState.type)}function v4(e,t,n){const r=this;return It(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const d=r.events[r.events.length-1];return!At(o)&&d&&d[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const aC={name:"setextUnderline",resolveTo:_4,tokenize:S4};function _4(e,t){let n=e.length,r,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const d={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",d,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=d,e.push(["exit",d,t]),e}function S4(e,t,n){const r=this;let a;return o;function o(h){let m=r.events.length,f;for(;m--;)if(r.events[m][1].type!=="lineEnding"&&r.events[m][1].type!=="linePrefix"&&r.events[m][1].type!=="content"){f=r.events[m][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),a=h,d(h)):n(h)}function d(h){return e.enter("setextHeadingLineSequence"),u(h)}function u(h){return h===a?(e.consume(h),u):(e.exit("setextHeadingLineSequence"),At(h)?It(e,c,"lineSuffix")(h):c(h))}function c(h){return h===null||pt(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const w4={tokenize:C4};function C4(e){const t=this,n=e.attempt(Du,r,e.attempt(this.parser.constructs.flowInitial,a,It(e,e.attempt(this.parser.constructs.flow,a,e.attempt(TI,a)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k4={resolveAll:kN()},j4=CN("string"),E4=CN("text");function CN(e){return{resolveAll:kN(e==="text"?N4:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],o=n.attempt(a,d,u);return d;function d(m){return h(m)?o(m):u(m)}function u(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),c}function c(m){return h(m)?(n.exit("data"),o(m)):(n.consume(m),c)}function h(m){if(m===null)return!0;const f=a[m];let g=-1;if(f)for(;++g<f.length;){const x=f[g];if(!x.previous||x.previous.call(r,r.previous))return!0}return!1}}}function kN(e){return t;function t(n,r){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,r):n}}function N4(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let o=a.length,d=-1,u=0,c;for(;o--;){const h=a[o];if(typeof h=="string"){for(d=h.length;h.charCodeAt(d-1)===32;)u++,d--;if(d)break;d=-1}else if(h===-2)c=!0,u++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const h={type:n===e.length||c||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?d:r.start._bufferIndex+d,_index:r.start._index+o,line:r.end.line,column:r.end.column-u,offset:r.end.offset-u},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 T4={42:br,43:br,45:br,48:br,49:br,50:br,51:br,52:br,53:br,54:br,55:br,56:br,57:br,62:xN},A4={91:OI},L4={[-2]:rx,[-1]:rx,32:rx},R4={35:FI,42:Uh,45:[aC,Uh],60:VI,61:aC,95:Uh,96:sC,126:sC},D4={38:bN,92:yN},O4={[-5]:sx,[-4]:sx,[-3]:sx,33:l4,38:bN,42:Sy,60:[uI,QI],91:u4,92:[BI,yN],93:Wb,95:Sy,96:wI},M4={null:[Sy,k4]},I4={null:[42,95]},P4={null:[]},B4=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:I4,contentInitial:A4,disable:P4,document:T4,flow:R4,flowInitial:L4,insideSpan:M4,string:D4,text:O4},Symbol.toStringTag,{value:"Module"}));function $4(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let d=[],u=[];const c={attempt:L(E),check:L(N),consume:_,enter:b,exit:j,interrupt:L(N,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:x,write:f};let m=t.tokenize.call(h,c);return t.resolveAll&&o.push(t),h;function f(F){return d=Zr(d,F),v(),d[d.length-1]!==null?[]:(A(t,0),h.events=nm(o,h.events,h),h.events)}function g(F,P){return z4(x(F),P)}function x(F){return F4(d,F)}function w(){const{_bufferIndex:F,_index:P,line:z,column:K,offset:q}=r;return{_bufferIndex:F,_index:P,line:z,column:K,offset:q}}function C(F){a[F.line]=F.column,O()}function v(){let F;for(;r._index<d.length;){const P=d[r._index];if(typeof P=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<P.length;)S(P.charCodeAt(r._bufferIndex));else S(P)}}function S(F){m=m(F)}function _(F){pt(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,O()):F!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===d[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=F}function b(F,P){const z=P||{};return z.type=F,z.start=w(),h.events.push(["enter",z,h]),u.push(z),z}function j(F){const P=u.pop();return P.end=w(),h.events.push(["exit",P,h]),P}function E(F,P){A(F,P.from)}function N(F,P){P.restore()}function L(F,P){return z;function z(K,q,W){let Z,Q,H,I;return Array.isArray(K)?V(K):"tokenize"in K?V([K]):M(K);function M(X){return U;function U(B){const J=B!==null&&X[B],se=B!==null&&X.null,ne=[...Array.isArray(J)?J:J?[J]:[],...Array.isArray(se)?se:se?[se]:[]];return V(ne)(B)}}function V(X){return Z=X,Q=0,X.length===0?W:$(X[Q])}function $(X){return U;function U(B){return I=D(),H=X,X.partial||(h.currentConstruct=X),X.name&&h.parser.constructs.disable.null.includes(X.name)?Y():X.tokenize.call(P?Object.assign(Object.create(h),P):h,c,ee,Y)(B)}}function ee(X){return F(H,I),q}function Y(X){return I.restore(),++Q<Z.length?$(Z[Q]):W}}}function A(F,P){F.resolveAll&&!o.includes(F)&&o.push(F),F.resolve&&$r(h.events,P,h.events.length-P,F.resolve(h.events.slice(P),h)),F.resolveTo&&(h.events=F.resolveTo(h.events,h))}function D(){const F=w(),P=h.previous,z=h.currentConstruct,K=h.events.length,q=Array.from(u);return{from:K,restore:W};function W(){r=F,h.previous=P,h.currentConstruct=z,h.events.length=K,u=q,O()}}function O(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function F4(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let d;if(n===a)d=[e[n].slice(r,o)];else{if(d=e.slice(n,a),r>-1){const u=d[0];typeof u=="string"?d[0]=u.slice(r):d.shift()}o>0&&d.push(e[a].slice(0,o))}return d}function z4(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const o=e[n];let d;if(typeof o=="string")d=o;else switch(o){case-5:{d="\r";break}case-4:{d=`
69
+ `;break}case-3:{d=`\r
70
+ `;break}case-2:{d=t?" ":" ";break}case-1:{if(!t&&a)continue;d=" ";break}default:d=String.fromCharCode(o)}a=o===-2,r.push(d)}return r.join("")}function H4(e){const r={constructs:pN([B4,...(e||{}).extensions||[]]),content:a(rI),defined:[],document:a(iI),flow:a(w4),lazy:{},string:a(j4),text:a(E4)};return r;function a(o){return d;function d(u){return $4(r,o,u)}}}function U4(e){for(;!vN(e););return e}const oC=/[\0\t\n\r]/g;function V4(){let e=1,t="",n=!0,r;return a;function a(o,d,u){const c=[];let h,m,f,g,x;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(d||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(oC.lastIndex=f,h=oC.exec(o),g=h&&h.index!==void 0?h.index:o.length,x=o.charCodeAt(g),!h){t=o.slice(f);break}if(x===10&&f===g&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<g&&(c.push(o.slice(f,g)),e+=g-f),x){case 0:{c.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,c.push(-2);e++<m;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=g+1}return u&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const W4=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function G4(e){return e.replace(W4,q4)}function q4(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),o=a===120||a===88;return gN(n.slice(o?2:1),o?16:10)}return Vb(n)||e}const jN={}.hasOwnProperty;function K4(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Y4(n)(U4(H4(n).document().write(V4()(e,t,!0))))}function Y4(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ye),autolinkProtocol:D,autolinkEmail:D,atxHeading:o(Oe),blockQuote:o(se),characterEscape:D,characterReference:D,codeFenced:o(ne),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:o(ne,d),codeText:o(ie,d),codeTextData:D,data:D,codeFlowValue:D,definition:o(de),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:o(pe),hardBreakEscape:o($e),hardBreakTrailing:o($e),htmlFlow:o(Pe,d),htmlFlowData:D,htmlText:o(Pe,d),htmlTextData:D,image:o(Ve),label:d,link:o(Ye),listItem:o(Ae),listItemValue:g,listOrdered:o(ot,f),listUnordered:o(ot),paragraph:o(me),reference:$,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:o(Oe),strong:o(re),thematicBreak:o(Me)},exit:{atxHeading:c(),atxHeadingSequence:E,autolink:c(),autolinkEmail:J,autolinkProtocol:B,blockQuote:c(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:Y,characterReferenceMarkerNumeric:Y,characterReferenceValue:X,characterReference:U,codeFenced:c(v),codeFencedFence:C,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:O,codeIndented:c(S),codeText:c(q),codeTextData:O,data:O,definition:c(),definitionDestinationString:j,definitionLabelString:_,definitionTitleString:b,emphasis:c(),hardBreakEscape:c(P),hardBreakTrailing:c(P),htmlFlow:c(z),htmlFlowData:O,htmlText:c(K),htmlTextData:O,image:c(Z),label:H,labelText:Q,lineEnding:F,link:c(W),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ee,resourceDestinationString:I,resourceTitleString:M,resource:V,setextHeading:c(A),setextHeadingLineSequence:L,setextHeadingText:N,strong:c(),thematicBreak:c()}};EN(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ce){let Ne={type:"root",children:[]};const Xe={stack:[Ne],tokenStack:[],config:t,enter:u,exit:h,buffer:d,resume:m,data:n},at=[];let fe=-1;for(;++fe<ce.length;)if(ce[fe][1].type==="listOrdered"||ce[fe][1].type==="listUnordered")if(ce[fe][0]==="enter")at.push(fe);else{const We=at.pop();fe=a(ce,We,fe)}for(fe=-1;++fe<ce.length;){const We=t[ce[fe][0]];jN.call(We,ce[fe][1].type)&&We[ce[fe][1].type].call(Object.assign({sliceSerialize:ce[fe][2].sliceSerialize},Xe),ce[fe][1])}if(Xe.tokenStack.length>0){const We=Xe.tokenStack[Xe.tokenStack.length-1];(We[1]||lC).call(Xe,void 0,We[0])}for(Ne.position={start:Yi(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:Yi(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},fe=-1;++fe<t.transforms.length;)Ne=t.transforms[fe](Ne)||Ne;return Ne}function a(ce,Ne,Xe){let at=Ne-1,fe=-1,We=!1,Ze,it,nt,De;for(;++at<=Xe;){const Re=ce[at];switch(Re[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Re[0]==="enter"?fe++:fe--,De=void 0;break}case"lineEndingBlank":{Re[0]==="enter"&&(Ze&&!De&&!fe&&!nt&&(nt=at),De=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:De=void 0}if(!fe&&Re[0]==="enter"&&Re[1].type==="listItemPrefix"||fe===-1&&Re[0]==="exit"&&(Re[1].type==="listUnordered"||Re[1].type==="listOrdered")){if(Ze){let Se=at;for(it=void 0;Se--;){const Ue=ce[Se];if(Ue[1].type==="lineEnding"||Ue[1].type==="lineEndingBlank"){if(Ue[0]==="exit")continue;it&&(ce[it][1].type="lineEndingBlank",We=!0),Ue[1].type="lineEnding",it=Se}else if(!(Ue[1].type==="linePrefix"||Ue[1].type==="blockQuotePrefix"||Ue[1].type==="blockQuotePrefixWhitespace"||Ue[1].type==="blockQuoteMarker"||Ue[1].type==="listItemIndent"))break}nt&&(!it||nt<it)&&(Ze._spread=!0),Ze.end=Object.assign({},it?ce[it][1].start:Re[1].end),ce.splice(it||at,0,["exit",Ze,Re[2]]),at++,Xe++}if(Re[1].type==="listItemPrefix"){const Se={type:"listItem",_spread:!1,start:Object.assign({},Re[1].start),end:void 0};Ze=Se,ce.splice(at,0,["enter",Se,Re[2]]),at++,Xe++,nt=void 0,De=!0}}}return ce[Ne][1]._spread=We,Xe}function o(ce,Ne){return Xe;function Xe(at){u.call(this,ce(at),at),Ne&&Ne.call(this,at)}}function d(){this.stack.push({type:"fragment",children:[]})}function u(ce,Ne,Xe){this.stack[this.stack.length-1].children.push(ce),this.stack.push(ce),this.tokenStack.push([Ne,Xe||void 0]),ce.position={start:Yi(Ne.start),end:void 0}}function c(ce){return Ne;function Ne(Xe){ce&&ce.call(this,Xe),h.call(this,Xe)}}function h(ce,Ne){const Xe=this.stack.pop(),at=this.tokenStack.pop();if(at)at[0].type!==ce.type&&(Ne?Ne.call(this,ce,at[0]):(at[1]||lC).call(this,ce,at[0]));else throw new Error("Cannot close `"+ce.type+"` ("+ru({start:ce.start,end:ce.end})+"): it’s not open");Xe.position.end=Yi(ce.end)}function m(){return Ub(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function g(ce){if(this.data.expectingFirstListItemValue){const Ne=this.stack[this.stack.length-2];Ne.start=Number.parseInt(this.sliceSerialize(ce),10),this.data.expectingFirstListItemValue=void 0}}function x(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.lang=ce}function w(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.meta=ce}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.value=ce.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.value=ce.replace(/(\r?\n|\r)$/g,"")}function _(ce){const Ne=this.resume(),Xe=this.stack[this.stack.length-1];Xe.label=Ne,Xe.identifier=bs(this.sliceSerialize(ce)).toLowerCase()}function b(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.title=ce}function j(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.url=ce}function E(ce){const Ne=this.stack[this.stack.length-1];if(!Ne.depth){const Xe=this.sliceSerialize(ce).length;Ne.depth=Xe}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function L(ce){const Ne=this.stack[this.stack.length-1];Ne.depth=this.sliceSerialize(ce).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function D(ce){const Xe=this.stack[this.stack.length-1].children;let at=Xe[Xe.length-1];(!at||at.type!=="text")&&(at=_e(),at.position={start:Yi(ce.start),end:void 0},Xe.push(at)),this.stack.push(at)}function O(ce){const Ne=this.stack.pop();Ne.value+=this.sliceSerialize(ce),Ne.position.end=Yi(ce.end)}function F(ce){const Ne=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Xe=Ne.children[Ne.children.length-1];Xe.position.end=Yi(ce.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ne.type)&&(D.call(this,ce),O.call(this,ce))}function P(){this.data.atHardBreak=!0}function z(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.value=ce}function K(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.value=ce}function q(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.value=ce}function W(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const Ne=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=Ne,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function Z(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const Ne=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=Ne,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function Q(ce){const Ne=this.sliceSerialize(ce),Xe=this.stack[this.stack.length-2];Xe.label=G4(Ne),Xe.identifier=bs(Ne).toLowerCase()}function H(){const ce=this.stack[this.stack.length-1],Ne=this.resume(),Xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Xe.type==="link"){const at=ce.children;Xe.children=at}else Xe.alt=Ne}function I(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.url=ce}function M(){const ce=this.resume(),Ne=this.stack[this.stack.length-1];Ne.title=ce}function V(){this.data.inReference=void 0}function $(){this.data.referenceType="collapsed"}function ee(ce){const Ne=this.resume(),Xe=this.stack[this.stack.length-1];Xe.label=Ne,Xe.identifier=bs(this.sliceSerialize(ce)).toLowerCase(),this.data.referenceType="full"}function Y(ce){this.data.characterReferenceType=ce.type}function X(ce){const Ne=this.sliceSerialize(ce),Xe=this.data.characterReferenceType;let at;Xe?(at=gN(Ne,Xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):at=Vb(Ne);const fe=this.stack[this.stack.length-1];fe.value+=at}function U(ce){const Ne=this.stack.pop();Ne.position.end=Yi(ce.end)}function B(ce){O.call(this,ce);const Ne=this.stack[this.stack.length-1];Ne.url=this.sliceSerialize(ce)}function J(ce){O.call(this,ce);const Ne=this.stack[this.stack.length-1];Ne.url="mailto:"+this.sliceSerialize(ce)}function se(){return{type:"blockquote",children:[]}}function ne(){return{type:"code",lang:null,meta:null,value:""}}function ie(){return{type:"inlineCode",value:""}}function de(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function pe(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function $e(){return{type:"break"}}function Pe(){return{type:"html",value:""}}function Ve(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function ot(ce){return{type:"list",ordered:ce.type==="listOrdered",start:null,spread:ce._spread,children:[]}}function Ae(ce){return{type:"listItem",spread:ce._spread,checked:null,children:[]}}function me(){return{type:"paragraph",children:[]}}function re(){return{type:"strong",children:[]}}function _e(){return{type:"text",value:""}}function Me(){return{type:"thematicBreak"}}}function Yi(e){return{line:e.line,column:e.column,offset:e.offset}}function EN(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?EN(e,r):X4(e,r)}}function X4(e,t){let n;for(n in t)if(jN.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 lC(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ru({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ru({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ru({start:t.start,end:t.end})+") is still open")}function Q4(e){const t=this;t.parser=n;function n(r){return K4(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function J4(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 Z4(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
71
+ `}]}function eP(e,t){const n=t.value?t.value+`
72
+ `:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function tP(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nP(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function rP(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=$l(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let d,u=e.footnoteCounts.get(r);u===void 0?(u=0,e.footnoteOrder.push(r),d=e.footnoteOrder.length):d=o+1,u+=1,e.footnoteCounts.set(r,u);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(t,c);const h={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,h),e.applyData(t,h)}function sP(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 iP(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function NN(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const d=a[a.length-1];return d&&d.type==="text"?d.value+=r:a.push({type:"text",value:r}),a}function aP(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return NN(e,t);const a={src:$l(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function oP(e,t){const n={src:$l(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 lP(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 cP(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return NN(e,t);const a={href:$l(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function uP(e,t){const n={href:$l(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 dP(e,t,n){const r=e.all(t),a=n?hP(n):TN(t),o={},d=[];if(typeof t.checked=="boolean"){const m=r[0];let f;m&&m.type==="element"&&m.tagName==="p"?f=m:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const m=r[u];(a||u!==0||m.type!=="element"||m.tagName!=="p")&&d.push({type:"text",value:`
73
+ `}),m.type==="element"&&m.tagName==="p"&&!a?d.push(...m.children):d.push(m)}const c=r[r.length-1];c&&(a||c.type!=="element"||c.tagName!=="p")&&d.push({type:"text",value:`
74
+ `});const h={type:"element",tagName:"li",properties:o,children:d};return e.patch(t,h),e.applyData(t,h)}function hP(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=TN(n[r])}return t}function TN(e){const t=e.spread;return t??e.children.length>1}function fP(e,t){const n={},r=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<r.length;){const d=r[a];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function mP(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pP(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function gP(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xP(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],d),a.push(d)}if(n.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},u=$b(t.children[1]),c=lN(t.children[t.children.length-1]);u&&c&&(d.position={start:u,end:c}),a.push(d)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function yP(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",d=n&&n.type==="table"?n.align:void 0,u=d?d.length:t.children.length;let c=-1;const h=[];for(;++c<u;){const f=t.children[c],g={},x=d?d[c]:void 0;x&&(g.align=x);let w={type:"element",tagName:o,properties:g,children:[]};f&&(w.children=e.all(f),e.patch(f,w),w=e.applyData(f,w)),h.push(w)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,m),e.applyData(t,m)}function bP(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const cC=9,uC=32;function vP(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const o=[];for(;r;)o.push(dC(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return o.push(dC(t.slice(a),a>0,!1)),o.join("")}function dC(e,t,n){let r=0,a=e.length;if(t){let o=e.codePointAt(r);for(;o===cC||o===uC;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(a-1);for(;o===cC||o===uC;)a--,o=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function _P(e,t){const n={type:"text",value:vP(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function SP(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wP={blockquote:J4,break:Z4,code:eP,delete:tP,emphasis:nP,footnoteReference:rP,heading:sP,html:iP,imageReference:aP,image:oP,inlineCode:lP,linkReference:cP,link:uP,listItem:dP,list:fP,paragraph:mP,root:pP,strong:gP,table:xP,tableCell:bP,tableRow:yP,text:_P,thematicBreak:SP,toml:ch,yaml:ch,definition:ch,footnoteDefinition:ch};function ch(){}const AN=-1,rm=0,iu=1,sf=2,Gb=3,qb=4,Kb=5,Yb=6,LN=7,RN=8,DN=typeof self=="object"?self:globalThis,hC=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new DN[e](t)},CP=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),r=a=>{if(e.has(a))return e.get(a);const[o,d]=t[a];switch(o){case rm:case AN:return n(d,a);case iu:{const u=n([],a);for(const c of d)u.push(r(c));return u}case sf:{const u=n({},a);for(const[c,h]of d)u[r(c)]=r(h);return u}case Gb:return n(new Date(d),a);case qb:{const{source:u,flags:c}=d;return n(new RegExp(u,c),a)}case Kb:{const u=n(new Map,a);for(const[c,h]of d)u.set(r(c),r(h));return u}case Yb:{const u=n(new Set,a);for(const c of d)u.add(r(c));return u}case LN:{const{name:u,message:c}=d;return n(typeof DN[u]=="function"?hC(u,c):new Error(c),a)}case RN:return n(BigInt(d),a);case"BigInt":return n(Object(BigInt(d)),a);case"ArrayBuffer":return n(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:u}=new Uint8Array(d);return n(new DataView(u),d)}}return n(hC(o,d),a)};return r},fC=e=>CP(new Map,e)(0),Va="",{toString:kP}={},{keys:jP}=Object,Vc=e=>{const t=typeof e;if(t!=="object"||!e)return[rm,t];const n=kP.call(e).slice(8,-1);switch(n){case"Array":return[iu,Va];case"Object":return[sf,Va];case"Date":return[Gb,Va];case"RegExp":return[qb,Va];case"Map":return[Kb,Va];case"Set":return[Yb,Va];case"DataView":return[iu,n]}return n.includes("Array")?[iu,n]:e instanceof Error?[LN,e.name||"Error"]:[sf,n]},uh=([e,t])=>e===rm&&(t==="function"||t==="symbol"),EP=(e,t,n,r)=>{const a=(d,u)=>{const c=r.push(d)-1;return n.set(u,c),c},o=d=>{if(n.has(d))return n.get(d);let[u,c]=Vc(d);switch(u){case rm:{let m=d;switch(c){case"bigint":u=RN,m=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);m=null;break;case"undefined":return a([AN],d)}return a([u,m],d)}case iu:{if(c){let g=d;return c==="DataView"?g=new Uint8Array(d.buffer):c==="ArrayBuffer"&&(g=new Uint8Array(d)),a([c,[...g]],d)}const m=[],f=a([u,m],d);for(const g of d)m.push(o(g));return f}case sf:{if(c)switch(c){case"BigInt":return a([c,d.toString()],d);case"Boolean":case"Number":case"String":return a([c,d.valueOf()],d)}if(t&&"toJSON"in d)return o(d.toJSON());const m=[],f=a([u,m],d);for(const g of jP(d))(e||!uh(Vc(d[g])))&&m.push([o(g),o(d[g])]);return f}case Gb:return a([u,isNaN(d.getTime())?Va:d.toISOString()],d);case qb:{const{source:m,flags:f}=d;return a([u,{source:m,flags:f}],d)}case Kb:{const m=[],f=a([u,m],d);for(const[g,x]of d)(e||!(uh(Vc(g))||uh(Vc(x))))&&m.push([o(g),o(x)]);return f}case Yb:{const m=[],f=a([u,m],d);for(const g of d)(e||!uh(Vc(g)))&&m.push(o(g));return f}}const{message:h}=d;return a([u,{name:c,message:h}],d)};return o},mC=(e,{json:t,lossy:n}={})=>{const r=[];return EP(!(t||n),!!t,new Map,r)(e),r},af=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?fC(mC(e,t)):structuredClone(e):(e,t)=>fC(mC(e,t));function NP(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 TP(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function AP(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||NP,r=e.options.footnoteBackLabel||TP,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let c=-1;for(;++c<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[c]);if(!h)continue;const m=e.all(h),f=String(h.identifier).toUpperCase(),g=$l(f.toLowerCase());let x=0;const w=[],C=e.footnoteCounts.get(f);for(;C!==void 0&&++x<=C;){w.length>0&&w.push({type:"text",value:" "});let _=typeof n=="string"?n:n(c,x);typeof _=="string"&&(_={type:"text",value:_}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,x),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const v=m[m.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const _=v.children[v.children.length-1];_&&_.type==="text"?_.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...w)}else m.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(m,!0)};e.patch(h,S),u.push(S)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...af(d),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
75
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
76
+ `}]}}const sm=(function(e){if(e==null)return OP;if(typeof e=="function")return im(e);if(typeof e=="object")return Array.isArray(e)?LP(e):RP(e);if(typeof e=="string")return DP(e);throw new Error("Expected function, string, or object as test")});function LP(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=sm(e[n]);return im(r);function r(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function RP(e){const t=e;return im(n);function n(r){const a=r;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function DP(e){return im(t);function t(n){return n&&n.type===e}}function im(e){return t;function t(n,r,a){return!!(MP(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function OP(){return!0}function MP(e){return e!==null&&typeof e=="object"&&"type"in e}const ON=[],IP=!0,wy=!1,PP="skip";function MN(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const o=sm(a),d=r?-1:1;u(e,void 0,[])();function u(c,h,m){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const x=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(c.type+(x?"<"+x+">":""))+")"})}return g;function g(){let x=ON,w,C,v;if((!t||o(c,h,m[m.length-1]||void 0))&&(x=BP(n(c,m)),x[0]===wy))return x;if("children"in c&&c.children){const S=c;if(S.children&&x[0]!==PP)for(C=(r?S.children.length:-1)+d,v=m.concat(S);C>-1&&C<S.children.length;){const _=S.children[C];if(w=u(_,C,v)(),w[0]===wy)return w;C=typeof w[1]=="number"?w[1]:C+d}}return x}}}function BP(e){return Array.isArray(e)?e:typeof e=="number"?[IP,e]:e==null?ON:[e]}function Xb(e,t,n,r){let a,o,d;typeof t=="function"&&typeof n!="function"?(o=void 0,d=t,a=n):(o=t,d=n,a=r),MN(e,o,u,a);function u(c,h){const m=h[h.length-1],f=m?m.children.indexOf(c):void 0;return d(c,f,m)}}const Cy={}.hasOwnProperty,$P={};function FP(e,t){const n=t||$P,r=new Map,a=new Map,o=new Map,d={...wP,...n.handlers},u={all:h,applyData:HP,definitionById:r,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:d,one:c,options:n,patch:zP,wrap:VP};return Xb(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const f=m.type==="definition"?r:a,g=String(m.identifier).toUpperCase();f.has(g)||f.set(g,m)}}),u;function c(m,f){const g=m.type,x=u.handlers[g];if(Cy.call(u.handlers,g)&&x)return x(u,m,f);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in m){const{children:C,...v}=m,S=af(v);return S.children=u.all(m),S}return af(m)}return(u.options.unknownHandler||UP)(u,m,f)}function h(m){const f=[];if("children"in m){const g=m.children;let x=-1;for(;++x<g.length;){const w=u.one(g[x],m);if(w){if(x&&g[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=pC(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=pC(C.value))}Array.isArray(w)?f.push(...w):f.push(w)}}}return f}}function zP(e,t){e.position&&(t.position=TM(e))}function HP(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const d="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:d}}n.type==="element"&&o&&Object.assign(n.properties,af(o)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function UP(e,t){const n=t.data||{},r="value"in t&&!(Cy.call(n,"hProperties")||Cy.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 VP(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
77
+ `});++r<e.length;)r&&n.push({type:"text",value:`
78
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
79
+ `}),n}function pC(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function gC(e,t){const n=FP(e,t),r=n.one(e,void 0),a=AP(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
80
+ `},a),o}function WP(e,t){return e&&"run"in e?async function(n,r){const a=gC(n,{file:r,...t});await e.run(a,r)}:function(n,r){return gC(n,{file:r,...e||t})}}function xC(e){if(e)throw e}var ix,yC;function GP(){if(yC)return ix;yC=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),f=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!f)return!1;var g;for(g in h);return typeof g>"u"||e.call(h,g)},d=function(h,m){n&&m.name==="__proto__"?n(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},u=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(r)return r(h,m).value}else return;return h[m]};return ix=function c(){var h,m,f,g,x,w,C=arguments[0],v=1,S=arguments.length,_=!1;for(typeof C=="boolean"&&(_=C,C=arguments[1]||{},v=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});v<S;++v)if(h=arguments[v],h!=null)for(m in h)f=u(C,m),g=u(h,m),C!==g&&(_&&g&&(o(g)||(x=a(g)))?(x?(x=!1,w=f&&a(f)?f:[]):w=f&&o(f)?f:{},d(C,{name:m,newValue:c(_,w,g)})):typeof g<"u"&&d(C,{name:m,newValue:g}));return C},ix}var qP=GP();const ax=Lf(qP);function ky(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 KP(){const e=[],t={run:n,use:r};return t;function n(...a){let o=-1;const d=a.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);u(null,...a);function u(c,...h){const m=e[++o];let f=-1;if(c){d(c);return}for(;++f<a.length;)(h[f]===null||h[f]===void 0)&&(h[f]=a[f]);a=h,m?YP(m,u)(...h):d(null,...h)}}function r(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function YP(e,t){let n;return r;function r(...d){const u=e.length>d.length;let c;u&&d.push(a);try{c=e.apply(this,d)}catch(h){const m=h;if(u&&n)throw m;return a(m)}u||(c&&c.then&&typeof c.then=="function"?c.then(o,a):c instanceof Error?a(c):o(c))}function a(d,...u){n||(n=!0,t(d,...u))}function o(d){a(null,d)}}const Os={basename:XP,dirname:QP,extname:JP,join:ZP,sep:"/"};function XP(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ou(e);let n=0,r=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else r<0&&(o=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let d=-1,u=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else d<0&&(o=!0,d=a+1),u>-1&&(e.codePointAt(a)===t.codePointAt(u--)?u<0&&(r=a):(u=-1,r=d));return n===r?r=d:r<0&&(r=e.length),e.slice(n,r)}function QP(e){if(Ou(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 JP(e){Ou(e);let t=e.length,n=-1,r=0,a=-1,o=0,d;for(;t--;){const u=e.codePointAt(t);if(u===47){if(d){r=t+1;break}continue}n<0&&(d=!0,n=t+1),u===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function ZP(...e){let t=-1,n;for(;++t<e.length;)Ou(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":e6(n)}function e6(e){Ou(e);const t=e.codePointAt(0)===47;let n=t6(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t6(e,t){let n="",r=0,a=-1,o=0,d=-1,u,c;for(;++d<=e.length;){if(d<e.length)u=e.codePointAt(d);else{if(u===47)break;u=47}if(u===47){if(!(a===d-1||o===1))if(a!==d-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),a=d,o=0;continue}}else if(n.length>0){n="",r=0,a=d,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,d):n=e.slice(a+1,d),r=d-a-1;a=d,o=0}else u===46&&o>-1?o++:o=-1}return n}function Ou(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const n6={cwd:r6};function r6(){return"/"}function jy(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function s6(e){if(typeof e=="string")e=new URL(e);else if(!jy(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 i6(e)}function i6(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const ox=["history","path","basename","stem","extname","dirname"];class IN{constructor(t){let n;t?jy(t)?n={path:t}:typeof t=="string"||a6(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":n6.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ox.length;){const o=ox[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let a;for(a in n)ox.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Os.basename(this.path):void 0}set basename(t){cx(t,"basename"),lx(t,"basename"),this.path=Os.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Os.dirname(this.path):void 0}set dirname(t){bC(this.basename,"dirname"),this.path=Os.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Os.extname(this.path):void 0}set extname(t){if(lx(t,"extname"),bC(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=Os.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){jy(t)&&(t=s6(t)),cx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Os.basename(this.path,this.extname):void 0}set stem(t){cx(t,"stem"),lx(t,"stem"),this.path=Os.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const a=this.message(t,n,r);throw a.fatal=!0,a}info(t,n,r){const a=this.message(t,n,r);return a.fatal=void 0,a}message(t,n,r){const a=new ar(t,n,r);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function lx(e,t){if(e&&e.includes(Os.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Os.sep+"`")}function cx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function bC(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function a6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const o6=(function(e){const r=this.constructor.prototype,a=r[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),l6={}.hasOwnProperty;class Qb extends o6{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=KP()}copy(){const t=new Qb;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ax(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(hx("data",this.frozen),this.namespace[t]=n,this):l6.call(this.namespace,t)&&this.namespace[t]||void 0:t?(hx("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const a=n.call(t,...r);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=dh(t),r=this.parser||this.Parser;return ux("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ux("process",this.parser||this.Parser),dx("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,d){const u=dh(t),c=r.parse(u);r.run(c,u,function(m,f,g){if(m||!f||!g)return h(m);const x=f,w=r.stringify(x,g);d6(w)?g.value=w:g.result=w,h(m,g)});function h(m,f){m||!f?d(m):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),ux("processSync",this.parser||this.Parser),dx("processSync",this.compiler||this.Compiler),this.process(t,a),_C("processSync","process",n),r;function a(o,d){n=!0,xC(o),r=d}}run(t,n,r){vC(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(d,u){const c=dh(n);a.run(t,c,h);function h(m,f,g){const x=f||t;m?u(m):d?d(x):r(void 0,x,g)}}}runSync(t,n){let r=!1,a;return this.run(t,n,o),_C("runSync","run",r),a;function o(d,u){xC(d),a=u,r=!0}}stringify(t,n){this.freeze();const r=dh(n),a=this.compiler||this.Compiler;return dx("stringify",a),vC(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(hx("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?u(t):d(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(h){if(typeof h=="function")c(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...f]=h;c(m,f)}else d(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function d(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");u(h.plugins),h.settings&&(a.settings=ax(!0,a.settings,h.settings))}function u(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const f=h[m];o(f)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function c(h,m){let f=-1,g=-1;for(;++f<r.length;)if(r[f][0]===h){g=f;break}if(g===-1)r.push([h,...m]);else if(m.length>0){let[x,...w]=m;const C=r[g][1];ky(C)&&ky(x)&&(x=ax(!0,C,x)),r[g]=[h,x,...w]}}}}const c6=new Qb().freeze();function ux(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function dx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function hx(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 vC(e){if(!ky(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function _C(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function dh(e){return u6(e)?e:new IN(e)}function u6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function d6(e){return typeof e=="string"||h6(e)}function h6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const f6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",SC=[],wC={allowDangerousHtml:!0},m6=/^(https?|ircs?|mailto|xmpp)$/i,p6=[{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 g6(e){const t=x6(e),n=y6(e);return b6(t.runSync(t.parse(n),n),e)}function x6(e){const t=e.rehypePlugins||SC,n=e.remarkPlugins||SC,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...wC}:wC;return c6().use(Q4).use(n).use(WP,r).use(t)}function y6(e){const t=e.children||"",n=new IN;return typeof t=="string"&&(n.value=t),n}function b6(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,o=t.disallowedElements,d=t.skipHtml,u=t.unwrapDisallowed,c=t.urlTransform||v6;for(const m of p6)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+f6+m.id,void 0);return Xb(e,h),OM(e,{Fragment:s.Fragment,components:a,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function h(m,f,g){if(m.type==="raw"&&g&&typeof f=="number")return d?g.children.splice(f,1):g.children[f]={type:"text",value:m.value},f;if(m.type==="element"){let x;for(x in nx)if(Object.hasOwn(nx,x)&&Object.hasOwn(m.properties,x)){const w=m.properties[x],C=nx[x];(C===null||C.includes(m.tagName))&&(m.properties[x]=c(String(w||""),x,m))}}if(m.type==="element"){let x=n?!n.includes(m.tagName):o?o.includes(m.tagName):!1;if(!x&&r&&typeof f=="number"&&(x=!r(m,f,g)),x&&g&&typeof f=="number")return u&&m.children?g.children.splice(f,1,...m.children):g.children.splice(f,1),f}}}function v6(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||r!==-1&&t>r||m6.test(e.slice(0,t))?e:""}function CC(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function _6(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function S6(e,t,n){const a=sm((n||{}).ignore||[]),o=w6(t);let d=-1;for(;++d<o.length;)MN(e,"text",u);function u(h,m){let f=-1,g;for(;++f<m.length;){const x=m[f],w=g?g.children:void 0;if(a(x,w?w.indexOf(x):void 0,g))return;g=x}if(g)return c(h,m)}function c(h,m){const f=m[m.length-1],g=o[d][0],x=o[d][1];let w=0;const v=f.children.indexOf(h);let S=!1,_=[];g.lastIndex=0;let b=g.exec(h.value);for(;b;){const j=b.index,E={index:b.index,input:b.input,stack:[...m,h]};let N=x(...b,E);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?g.lastIndex=j+1:(w!==j&&_.push({type:"text",value:h.value.slice(w,j)}),Array.isArray(N)?_.push(...N):N&&_.push(N),w=j+b[0].length,S=!0),!g.global)break;b=g.exec(h.value)}return S?(w<h.value.length&&_.push({type:"text",value:h.value.slice(w)}),f.children.splice(v,1,..._)):_=[h],v+_.length}}function w6(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const a=n[r];t.push([C6(a[0]),k6(a[1])])}return t}function C6(e){return typeof e=="string"?new RegExp(_6(e),"g"):e}function k6(e){return typeof e=="function"?e:function(){return e}}const fx="phrasing",mx=["autolink","link","image","label"];function j6(){return{transforms:[D6],enter:{literalAutolink:N6,literalAutolinkEmail:px,literalAutolinkHttp:px,literalAutolinkWww:px},exit:{literalAutolink:R6,literalAutolinkEmail:L6,literalAutolinkHttp:T6,literalAutolinkWww:A6}}}function E6(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:fx,notInConstruct:mx},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:fx,notInConstruct:mx},{character:":",before:"[ps]",after:"\\/",inConstruct:fx,notInConstruct:mx}]}}function N6(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function px(e){this.config.enter.autolinkProtocol.call(this,e)}function T6(e){this.config.exit.autolinkProtocol.call(this,e)}function A6(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 L6(e){this.config.exit.autolinkEmail.call(this,e)}function R6(e){this.exit(e)}function D6(e){S6(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,O6],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),M6]],{ignore:["link","linkReference"]})}function O6(e,t,n,r,a){let o="";if(!PN(a)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!I6(n)))return!1;const d=P6(n+r);if(!d[0])return!1;const u={type:"link",title:null,url:o+t+d[0],children:[{type:"text",value:t+d[0]}]};return d[1]?[u,{type:"text",value:d[1]}]:u}function M6(e,t,n,r){return!PN(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function I6(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 P6(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=CC(e,"(");let o=CC(e,")");for(;r!==-1&&a>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function PN(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||ao(n)||tm(n))&&(!t||n!==47)}BN.peek=G6;function B6(){this.buffer()}function $6(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F6(){this.buffer()}function z6(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function H6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=bs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function U6(e){this.exit(e)}function V6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=bs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function W6(e){this.exit(e)}function G6(){return"["}function BN(e,t,n,r){const a=n.createTracker(r);let o=a.move("[^");const d=n.enter("footnoteReference"),u=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),u(),d(),o+=a.move("]"),o}function q6(){return{enter:{gfmFootnoteCallString:B6,gfmFootnoteCall:$6,gfmFootnoteDefinitionLabelString:F6,gfmFootnoteDefinition:z6},exit:{gfmFootnoteCallString:H6,gfmFootnoteCall:U6,gfmFootnoteDefinitionLabelString:V6,gfmFootnoteDefinition:W6}}}function K6(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:BN},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,o,d){const u=o.createTracker(d);let c=u.move("[^");const h=o.enter("footnoteDefinition"),m=o.enter("label");return c+=u.move(o.safe(o.associationId(r),{before:c,after:"]"})),m(),c+=u.move("]:"),r.children&&r.children.length>0&&(u.shift(4),c+=u.move((t?`
81
+ `:" ")+o.indentLines(o.containerFlow(r,u.current()),t?$N:Y6))),h(),c}}function Y6(e,t,n){return t===0?e:$N(e,t,n)}function $N(e,t,n){return(n?"":" ")+e}const X6=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];FN.peek=tB;function Q6(){return{canContainEols:["delete"],enter:{strikethrough:Z6},exit:{strikethrough:eB}}}function J6(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:X6}],handlers:{delete:FN}}}function Z6(e){this.enter({type:"delete",children:[]},e)}function eB(e){this.exit(e)}function FN(e,t,n,r){const a=n.createTracker(r),o=n.enter("strikethrough");let d=a.move("~~");return d+=n.containerPhrasing(e,{...a.current(),before:d,after:"~"}),d+=a.move("~~"),o(),d}function tB(){return"~"}function nB(e){return e.length}function rB(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||nB,o=[],d=[],u=[],c=[];let h=0,m=-1;for(;++m<e.length;){const C=[],v=[];let S=-1;for(e[m].length>h&&(h=e[m].length);++S<e[m].length;){const _=sB(e[m][S]);if(n.alignDelimiters!==!1){const b=a(_);v[S]=b,(c[S]===void 0||b>c[S])&&(c[S]=b)}C.push(_)}d[m]=C,u[m]=v}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<h;)o[f]=kC(r[f]);else{const C=kC(r);for(;++f<h;)o[f]=C}f=-1;const g=[],x=[];for(;++f<h;){const C=o[f];let v="",S="";C===99?(v=":",S=":"):C===108?v=":":C===114&&(S=":");let _=n.alignDelimiters===!1?1:Math.max(1,c[f]-v.length-S.length);const b=v+"-".repeat(_)+S;n.alignDelimiters!==!1&&(_=v.length+_+S.length,_>c[f]&&(c[f]=_),x[f]=_),g[f]=b}d.splice(1,0,g),u.splice(1,0,x),m=-1;const w=[];for(;++m<d.length;){const C=d[m],v=u[m];f=-1;const S=[];for(;++f<h;){const _=C[f]||"";let b="",j="";if(n.alignDelimiters!==!1){const E=c[f]-(v[f]||0),N=o[f];N===114?b=" ".repeat(E):N===99?E%2?(b=" ".repeat(E/2+.5),j=" ".repeat(E/2-.5)):(b=" ".repeat(E/2),j=b):j=" ".repeat(E)}n.delimiterStart!==!1&&!f&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||f)&&S.push(" "),n.alignDelimiters!==!1&&S.push(b),S.push(_),n.alignDelimiters!==!1&&S.push(j),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||f!==h-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
82
+ `)}function sB(e){return e==null?"":String(e)}function kC(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function iB(e,t,n,r){const a=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const d=n.indentLines(n.containerFlow(e,o.current()),aB);return a(),d}function aB(e,t,n){return">"+(n?"":" ")+e}function oB(e,t){return jC(e,t.inConstruct,!0)&&!jC(e,t.notInConstruct,!1)}function jC(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 EC(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
83
+ `&&oB(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
84
+ `}function lB(e,t){const n=String(e);let r=n.indexOf(t),a=r,o=0,d=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++o>d&&(d=o):o=1,a=r+t.length,r=n.indexOf(t,a);return d}function cB(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 uB(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 dB(e,t,n,r){const a=uB(n),o=e.value||"",d=a==="`"?"GraveAccent":"Tilde";if(cB(e,n)){const f=n.enter("codeIndented"),g=n.indentLines(o,hB);return f(),g}const u=n.createTracker(r),c=a.repeat(Math.max(lB(o,a)+1,3)),h=n.enter("codeFenced");let m=u.move(c);if(e.lang){const f=n.enter(`codeFencedLang${d}`);m+=u.move(n.safe(e.lang,{before:m,after:" ",encode:["`"],...u.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${d}`);m+=u.move(" "),m+=u.move(n.safe(e.meta,{before:m,after:`
85
+ `,encode:["`"],...u.current()})),f()}return m+=u.move(`
86
+ `),o&&(m+=u.move(o+`
87
+ `)),m+=u.move(c),h(),m}function hB(e,t,n){return(n?"":" ")+e}function Jb(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 fB(e,t,n,r){const a=Jb(n),o=a==='"'?"Quote":"Apostrophe",d=n.enter("definition");let u=n.enter("label");const c=n.createTracker(r);let h=c.move("[");return h+=c.move(n.safe(n.associationId(e),{before:h,after:"]",...c.current()})),h+=c.move("]: "),u(),!e.url||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(u=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":`
88
+ `,...c.current()}))),u(),e.title&&(u=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),u()),d(),h}function mB(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 vu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function of(e,t,n){const r=Tl(e),a=Tl(t);return r===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}zN.peek=pB;function zN(e,t,n,r){const a=mB(n),o=n.enter("emphasis"),d=n.createTracker(r),u=d.move(a);let c=d.move(n.containerPhrasing(e,{after:a,before:u,...d.current()}));const h=c.charCodeAt(0),m=of(r.before.charCodeAt(r.before.length-1),h,a);m.inside&&(c=vu(h)+c.slice(1));const f=c.charCodeAt(c.length-1),g=of(r.after.charCodeAt(0),f,a);g.inside&&(c=c.slice(0,-1)+vu(f));const x=d.move(a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},u+c+x}function pB(e,t,n){return n.options.emphasis||"*"}function gB(e,t){let n=!1;return Xb(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,wy}),!!((!e.depth||e.depth<3)&&Ub(e)&&(t.options.setext||n))}function xB(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(gB(e,n)){const m=n.enter("headingSetext"),f=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:`
89
+ `,after:`
90
+ `});return f(),m(),g+`
91
+ `+(a===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
92
+ `))+1))}const d="#".repeat(a),u=n.enter("headingAtx"),c=n.enter("phrasing");o.move(d+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
93
+ `,...o.current()});return/^[\t ]/.test(h)&&(h=vu(h.charCodeAt(0))+h.slice(1)),h=h?d+" "+h:d,n.options.closeAtx&&(h+=" "+d),c(),u(),h}HN.peek=yB;function HN(e){return e.value||""}function yB(){return"<"}UN.peek=bB;function UN(e,t,n,r){const a=Jb(n),o=a==='"'?"Quote":"Apostrophe",d=n.enter("image");let u=n.enter("label");const c=n.createTracker(r);let h=c.move("![");return h+=c.move(n.safe(e.alt,{before:h,after:"]",...c.current()})),h+=c.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(u=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),u(),e.title&&(u=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),u()),h+=c.move(")"),d(),h}function bB(){return"!"}VN.peek=vB;function VN(e,t,n,r){const a=e.referenceType,o=n.enter("imageReference");let d=n.enter("label");const u=n.createTracker(r);let c=u.move("![");const h=n.safe(e.alt,{before:c,after:"]",...u.current()});c+=u.move(h+"]["),d();const m=n.stack;n.stack=[],d=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...u.current()});return d(),n.stack=m,o(),a==="full"||!h||h!==f?c+=u.move(f+"]"):a==="shortcut"?c=c.slice(0,-1):c+=u.move("]"),c}function vB(){return"!"}WN.peek=_B;function WN(e,t,n){let r=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const d=n.unsafe[o],u=n.compilePattern(d);let c;if(d.atBreak)for(;c=u.exec(r);){let h=c.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(c.index+1)}}return a+r+a}function _B(){return"`"}function GN(e,t){const n=Ub(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))}qN.peek=SB;function qN(e,t,n,r){const a=Jb(n),o=a==='"'?"Quote":"Apostrophe",d=n.createTracker(r);let u,c;if(GN(e,n)){const m=n.stack;n.stack=[],u=n.enter("autolink");let f=d.move("<");return f+=d.move(n.containerPhrasing(e,{before:f,after:">",...d.current()})),f+=d.move(">"),u(),n.stack=m,f}u=n.enter("link"),c=n.enter("label");let h=d.move("[");return h+=d.move(n.containerPhrasing(e,{before:h,after:"](",...d.current()})),h+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=n.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),h+=d.move(")"),u(),h}function SB(e,t,n){return GN(e,n)?"<":"["}KN.peek=wB;function KN(e,t,n,r){const a=e.referenceType,o=n.enter("linkReference");let d=n.enter("label");const u=n.createTracker(r);let c=u.move("[");const h=n.containerPhrasing(e,{before:c,after:"]",...u.current()});c+=u.move(h+"]["),d();const m=n.stack;n.stack=[],d=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...u.current()});return d(),n.stack=m,o(),a==="full"||!h||h!==f?c+=u.move(f+"]"):a==="shortcut"?c=c.slice(0,-1):c+=u.move("]"),c}function wB(){return"["}function Zb(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 CB(e){const t=Zb(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 kB(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 YN(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 jB(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let d=e.ordered?kB(n):Zb(n);const u=e.ordered?d==="."?")":".":CB(n);let c=t&&n.bulletLastUsed?d===n.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&m&&(!m.children||!m.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),YN(n)===d&&m){let f=-1;for(;++f<e.children.length;){const g=e.children[f];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(d=u),n.bulletCurrent=d;const h=n.containerFlow(e,r);return n.bulletLastUsed=d,n.bulletCurrent=o,a(),h}function EB(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 NB(e,t,n,r){const a=EB(n);let o=n.bulletCurrent||Zb(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let d=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(d=Math.ceil(d/4)*4);const u=n.createTracker(r);u.move(o+" ".repeat(d-o.length)),u.shift(d);const c=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,u.current()),m);return c(),h;function m(f,g,x){return g?(x?"":" ".repeat(d))+f:(x?o:o+" ".repeat(d-o.length))+f}}function TB(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),d=n.containerPhrasing(e,r);return o(),a(),d}const AB=sm(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function LB(e,t,n,r){return(e.children.some(function(d){return AB(d)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function RB(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}XN.peek=DB;function XN(e,t,n,r){const a=RB(n),o=n.enter("strong"),d=n.createTracker(r),u=d.move(a+a);let c=d.move(n.containerPhrasing(e,{after:a,before:u,...d.current()}));const h=c.charCodeAt(0),m=of(r.before.charCodeAt(r.before.length-1),h,a);m.inside&&(c=vu(h)+c.slice(1));const f=c.charCodeAt(c.length-1),g=of(r.after.charCodeAt(0),f,a);g.inside&&(c=c.slice(0,-1)+vu(f));const x=d.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},u+c+x}function DB(e,t,n){return n.options.strong||"*"}function OB(e,t,n,r){return n.safe(e.value,r)}function MB(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 IB(e,t,n){const r=(YN(n)+(n.options.ruleSpaces?" ":"")).repeat(MB(n));return n.options.ruleSpaces?r.slice(0,-1):r}const QN={blockquote:iB,break:EC,code:dB,definition:fB,emphasis:zN,hardBreak:EC,heading:xB,html:HN,image:UN,imageReference:VN,inlineCode:WN,link:qN,linkReference:KN,list:jB,listItem:NB,paragraph:TB,root:LB,strong:XN,text:OB,thematicBreak:IB};function PB(){return{enter:{table:BB,tableData:NC,tableHeader:NC,tableRow:FB},exit:{codeText:zB,table:$B,tableData:gx,tableHeader:gx,tableRow:gx}}}function BB(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 $B(e){this.exit(e),this.data.inTable=void 0}function FB(e){this.enter({type:"tableRow",children:[]},e)}function gx(e){this.exit(e)}function NC(e){this.enter({type:"tableCell",children:[]},e)}function zB(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,HB));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function HB(e,t){return t==="|"?t:e}function UB(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
94
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:d,tableCell:c,tableRow:u}};function d(x,w,C,v){return h(m(x,C,v),x.align)}function u(x,w,C,v){const S=f(x,C,v),_=h([S]);return _.slice(0,_.indexOf(`
95
+ `))}function c(x,w,C,v){const S=C.enter("tableCell"),_=C.enter("phrasing"),b=C.containerPhrasing(x,{...v,before:o,after:o});return _(),S(),b}function h(x,w){return rB(x,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function m(x,w,C){const v=x.children;let S=-1;const _=[],b=w.enter("table");for(;++S<v.length;)_[S]=f(v[S],w,C);return b(),_}function f(x,w,C){const v=x.children;let S=-1;const _=[],b=w.enter("tableRow");for(;++S<v.length;)_[S]=c(v[S],x,w,C);return b(),_}function g(x,w,C){let v=QN.inlineCode(x,w,C);return C.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function VB(){return{exit:{taskListCheckValueChecked:TC,taskListCheckValueUnchecked:TC,paragraph:GB}}}function WB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:qB}}}function TC(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function GB(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let o=-1,d;for(;++o<a.length;){const u=a[o];if(u.type==="paragraph"){d=u;break}}d===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 qB(e,t,n,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);o&&u.move(d);let c=QN.listItem(e,t,n,{...r,...u.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),c;function h(m){return m+d}}function KB(){return[j6(),q6(),Q6(),PB(),VB()]}function YB(e){return{extensions:[E6(),K6(e),J6(),UB(e),WB()]}}const XB={tokenize:n8,partial:!0},JN={tokenize:r8,partial:!0},ZN={tokenize:s8,partial:!0},e2={tokenize:i8,partial:!0},QB={tokenize:a8,partial:!0},t2={name:"wwwAutolink",tokenize:e8,previous:r2},n2={name:"protocolAutolink",tokenize:t8,previous:s2},ki={name:"emailAutolink",tokenize:ZB,previous:i2},Vs={};function JB(){return{text:Vs}}let Pa=48;for(;Pa<123;)Vs[Pa]=ki,Pa++,Pa===58?Pa=65:Pa===91&&(Pa=97);Vs[43]=ki;Vs[45]=ki;Vs[46]=ki;Vs[95]=ki;Vs[72]=[ki,n2];Vs[104]=[ki,n2];Vs[87]=[ki,t2];Vs[119]=[ki,t2];function ZB(e,t,n){const r=this;let a,o;return d;function d(f){return!Ey(f)||!i2.call(r,r.previous)||ev(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(f))}function u(f){return Ey(f)?(e.consume(f),u):f===64?(e.consume(f),c):n(f)}function c(f){return f===46?e.check(QB,m,h)(f):f===45||f===95||ir(f)?(o=!0,e.consume(f),c):m(f)}function h(f){return e.consume(f),a=!0,c}function m(f){return o&&a&&dr(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function e8(e,t,n){const r=this;return a;function a(d){return d!==87&&d!==119||!r2.call(r,r.previous)||ev(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(XB,e.attempt(JN,e.attempt(ZN,o),n),n)(d))}function o(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(d)}}function t8(e,t,n){const r=this;let a="",o=!1;return d;function d(f){return(f===72||f===104)&&s2.call(r,r.previous)&&!ev(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(f),e.consume(f),u):n(f)}function u(f){if(dr(f)&&a.length<5)return a+=String.fromCodePoint(f),e.consume(f),u;if(f===58){const g=a.toLowerCase();if(g==="http"||g==="https")return e.consume(f),c}return n(f)}function c(f){return f===47?(e.consume(f),o?h:(o=!0,c)):n(f)}function h(f){return f===null||rf(f)||ln(f)||ao(f)||tm(f)?n(f):e.attempt(JN,e.attempt(ZN,m),n)(f)}function m(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function n8(e,t,n){let r=0;return a;function a(d){return(d===87||d===119)&&r<3?(r++,e.consume(d),a):d===46&&r===3?(e.consume(d),o):n(d)}function o(d){return d===null?n(d):t(d)}}function r8(e,t,n){let r,a,o;return d;function d(h){return h===46||h===95?e.check(e2,c,u)(h):h===null||ln(h)||ao(h)||h!==45&&tm(h)?c(h):(o=!0,e.consume(h),d)}function u(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),d}function c(h){return a||r||!o?n(h):t(h)}}function s8(e,t){let n=0,r=0;return a;function a(d){return d===40?(n++,e.consume(d),a):d===41&&r<n?o(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(e2,t,o)(d):d===null||ln(d)||ao(d)?t(d):(e.consume(d),a)}function o(d){return d===41&&r++,e.consume(d),a}}function i8(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),o):u===93?(e.consume(u),a):u===60||u===null||ln(u)||ao(u)?t(u):n(u)}function a(u){return u===null||u===40||u===91||ln(u)||ao(u)?t(u):r(u)}function o(u){return dr(u)?d(u):n(u)}function d(u){return u===59?(e.consume(u),r):dr(u)?(e.consume(u),d):n(u)}}function a8(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return ir(o)?n(o):t(o)}}function r2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ln(e)}function s2(e){return!dr(e)}function i2(e){return!(e===47||Ey(e))}function Ey(e){return e===43||e===45||e===46||e===95||ir(e)}function ev(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 o8={tokenize:p8,partial:!0};function l8(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:h8,continuation:{tokenize:f8},exit:m8}},text:{91:{name:"gfmFootnoteCall",tokenize:d8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:c8,resolveTo:u8}}}}function c8(e,t,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let d;for(;a--;){const c=r.events[a][1];if(c.type==="labelImage"){d=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return u;function u(c){if(!d||!d._balanced)return n(c);const h=bs(r.sliceSerialize({start:d.end,end:r.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function u8(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",d,t],["exit",d,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...u),e}function d8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,d;return u;function u(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(f){if(o>999||f===93&&!d||f===null||f===91||ln(f))return n(f);if(f===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(bs(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return ln(f)||(d=!0),o++,e.consume(f),f===92?m:h}function m(f){return f===91||f===92||f===93?(e.consume(f),o++,h):h(f)}}function h8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,d=0,u;return c;function c(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):n(w)}function m(w){if(d>999||w===93&&!u||w===null||w===91||ln(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return o=bs(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return ln(w)||(u=!0),d++,e.consume(w),w===92?f:m}function f(w){return w===91||w===92||w===93?(e.consume(w),d++,m):m(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),It(e,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return t(w)}}function f8(e,t,n){return e.check(Du,t,e.attempt(o8,t,n))}function m8(e){e.exit("gfmFootnoteDefinition")}function p8(e,t,n){const r=this;return It(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const d=r.events[r.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?t(o):n(o)}}function g8(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(d,u){let c=-1;for(;++c<d.length;)if(d[c][0]==="enter"&&d[c][1].type==="strikethroughSequenceTemporary"&&d[c][1]._close){let h=c;for(;h--;)if(d[h][0]==="exit"&&d[h][1].type==="strikethroughSequenceTemporary"&&d[h][1]._open&&d[c][1].end.offset-d[c][1].start.offset===d[h][1].end.offset-d[h][1].start.offset){d[c][1].type="strikethroughSequence",d[h][1].type="strikethroughSequence";const m={type:"strikethrough",start:Object.assign({},d[h][1].start),end:Object.assign({},d[c][1].end)},f={type:"strikethroughText",start:Object.assign({},d[h][1].end),end:Object.assign({},d[c][1].start)},g=[["enter",m,u],["enter",d[h][1],u],["exit",d[h][1],u],["enter",f,u]],x=u.parser.constructs.insideSpan.null;x&&$r(g,g.length,0,nm(x,d.slice(h+1,c),u)),$r(g,g.length,0,[["exit",f,u],["enter",d[c][1],u],["exit",d[c][1],u],["exit",m,u]]),$r(d,h-1,c-h+3,g),c=h+g.length-2;break}}for(c=-1;++c<d.length;)d[c][1].type==="strikethroughSequenceTemporary"&&(d[c][1].type="data");return d}function o(d,u,c){const h=this.previous,m=this.events;let f=0;return g;function g(w){return h===126&&m[m.length-1][1].type!=="characterEscape"?c(w):(d.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const C=Tl(h);if(w===126)return f>1?c(w):(d.consume(w),f++,x);if(f<2&&!n)return c(w);const v=d.exit("strikethroughSequenceTemporary"),S=Tl(w);return v._open=!S||S===2&&!!C,v._close=!C||C===2&&!!S,u(w)}}}class x8{constructor(){this.map=[]}add(t,n,r){y8(this,t,n,r)}consume(t){if(this.map.sort(function(o,d){return o[0]-d[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const o of a)t.push(o);a=r.pop()}this.map.length=0}}function y8(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function b8(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function v8(){return{flow:{null:{name:"table",tokenize:_8,resolveAll:S8}}}}function _8(e,t,n){const r=this;let a=0,o=0,d;return u;function u(O){let F=r.events.length-1;for(;F>-1;){const K=r.events[F][1].type;if(K==="lineEnding"||K==="linePrefix")F--;else break}const P=F>-1?r.events[F][1].type:null,z=P==="tableHead"||P==="tableRow"?N:c;return z===N&&r.parser.lazy[r.now().line]?n(O):z(O)}function c(O){return e.enter("tableHead"),e.enter("tableRow"),h(O)}function h(O){return O===124||(d=!0,o+=1),m(O)}function m(O){return O===null?n(O):pt(O)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),x):n(O):At(O)?It(e,m,"whitespace")(O):(o+=1,d&&(d=!1,a+=1),O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),d=!0,m):(e.enter("data"),f(O)))}function f(O){return O===null||O===124||ln(O)?(e.exit("data"),m(O)):(e.consume(O),O===92?g:f)}function g(O){return O===92||O===124?(e.consume(O),f):f(O)}function x(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(e.enter("tableDelimiterRow"),d=!1,At(O)?It(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):w(O))}function w(O){return O===45||O===58?v(O):O===124?(d=!0,e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),C):E(O)}function C(O){return At(O)?It(e,v,"whitespace")(O):v(O)}function v(O){return O===58?(o+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),S):O===45?(o+=1,S(O)):O===null||pt(O)?j(O):E(O)}function S(O){return O===45?(e.enter("tableDelimiterFiller"),_(O)):E(O)}function _(O){return O===45?(e.consume(O),_):O===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(O))}function b(O){return At(O)?It(e,j,"whitespace")(O):j(O)}function j(O){return O===124?w(O):O===null||pt(O)?!d||a!==o?E(O):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(O)):E(O)}function E(O){return n(O)}function N(O){return e.enter("tableRow"),L(O)}function L(O){return O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),L):O===null||pt(O)?(e.exit("tableRow"),t(O)):At(O)?It(e,L,"whitespace")(O):(e.enter("data"),A(O))}function A(O){return O===null||O===124||ln(O)?(e.exit("data"),L(O)):(e.consume(O),O===92?D:A)}function D(O){return O===92||O===124?(e.consume(O),A):A(O)}}function S8(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],d=[0,0,0,0],u=!1,c=0,h,m,f;const g=new x8;for(;++n<e.length;){const x=e[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(u=!1,c!==0&&(AC(g,t,c,h,m),m=void 0,c=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",h,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,f=void 0,o=[0,0,0,0],d=[0,n+1,0,0],u&&(u=!1,m={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",m,t]])),a=w.type==="tableDelimiterRow"?2:m?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,d[2]===0&&(o[1]!==0&&(d[0]=d[1],f=hh(g,t,o,a,void 0,f),o=[0,0,0,0]),d[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(d[0]=d[1],f=hh(g,t,o,a,void 0,f)),o=d,d=[o[1],n,0,0])):w.type==="tableHead"?(u=!0,c=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(c=n,o[1]!==0?(d[0]=d[1],f=hh(g,t,o,a,n,f)):d[1]!==0&&(f=hh(g,t,d,a,n,f)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(d[3]=n)}for(c!==0&&AC(g,t,c,h,m),g.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=b8(t.events,n))}return e}function hh(e,t,n,r,a,o){const d=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(o.end=Object.assign({},cl(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const c=cl(t.events,n[1]);if(o={type:d,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const h=cl(t.events,n[2]),m=cl(t.events,n[3]),f={type:u,start:Object.assign({},h),end:Object.assign({},m)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const g=t.events[n[2]],x=t.events[n[3]];if(g[1].end=Object.assign({},x[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return a!==void 0&&(o.end=Object.assign({},cl(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function AC(e,t,n,r,a){const o=[],d=cl(t.events,n);a&&(a.end=Object.assign({},d),o.push(["exit",a,t])),r.end=Object.assign({},d),o.push(["exit",r,t]),e.add(n+1,0,o)}function cl(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const w8={name:"tasklistCheck",tokenize:k8};function C8(){return{text:{91:w8}}}function k8(e,t,n){const r=this;return a;function a(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return ln(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),d):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),d):n(c)}function d(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),u):n(c)}function u(c){return pt(c)?t(c):At(c)?e.check({tokenize:j8},t,n)(c):n(c)}}function j8(e,t,n){return It(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function E8(e){return pN([JB(),l8(),g8(e),v8(),C8()])}const N8={};function T8(e){const t=this,n=e||N8,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),d=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(E8(n)),o.push(KB()),d.push(YB(n))}var Ny=Object.defineProperty,A8=Object.getOwnPropertyDescriptor,L8=Object.getOwnPropertyNames,R8=Object.prototype.hasOwnProperty,tv=(e,t)=>{let n={};for(var r in e)Ny(n,r,{get:e[r],enumerable:!0});return Ny(n,Symbol.toStringTag,{value:"Module"}),n},D8=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=L8(t),o=0,d=a.length,u;o<d;o++)u=a[o],!R8.call(e,u)&&u!==n&&Ny(e,u,{get:(c=>t[c]).bind(null,u),enumerable:!(r=A8(t,u))||r.enumerable});return e},a2=(e,t,n)=>(D8(e,t,"default"),n);const am=[{id:"abap",name:"ABAP",import:(()=>ae(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>ae(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>ae(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>ae(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>ae(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>ae(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>ae(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>ae(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>ae(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>ae(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>ae(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>ae(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>ae(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>ae(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>ae(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>ae(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>ae(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>ae(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>ae(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>ae(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>ae(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>ae(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>ae(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>ae(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>ae(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>ae(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>ae(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>ae(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>ae(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>ae(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>ae(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>ae(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>ae(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>ae(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>ae(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>ae(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>ae(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>ae(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>ae(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>ae(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>ae(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>ae(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>ae(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>ae(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>ae(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>ae(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>ae(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>ae(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>ae(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>ae(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>ae(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>ae(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>ae(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>ae(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>ae(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>ae(()=>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:(()=>ae(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>ae(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>ae(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>ae(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>ae(()=>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:(()=>ae(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>ae(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>ae(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>ae(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>ae(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>ae(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>ae(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>ae(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>ae(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>ae(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>ae(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>ae(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>ae(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>ae(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>ae(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>ae(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>ae(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>ae(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>ae(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>ae(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>ae(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>ae(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>ae(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>ae(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>ae(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>ae(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>ae(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>ae(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>ae(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>ae(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>ae(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>ae(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>ae(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>ae(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>ae(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>ae(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>ae(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>ae(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>ae(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>ae(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>ae(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>ae(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>ae(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>ae(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>ae(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>ae(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>ae(()=>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:(()=>ae(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>ae(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>ae(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>ae(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>ae(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>ae(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>ae(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>ae(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>ae(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>ae(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>ae(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>ae(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>ae(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>ae(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>ae(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>ae(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>ae(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>ae(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>ae(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>ae(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>ae(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>ae(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>ae(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>ae(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>ae(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>ae(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>ae(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>ae(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>ae(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>ae(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>ae(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>ae(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>ae(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>ae(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>ae(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>ae(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>ae(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>ae(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>ae(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>ae(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>ae(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>ae(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>ae(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>ae(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>ae(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>ae(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>ae(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>ae(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>ae(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>ae(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>ae(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>ae(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>ae(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>ae(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>ae(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>ae(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>ae(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>ae(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>ae(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>ae(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>ae(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>ae(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>ae(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>ae(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>ae(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>ae(()=>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:(()=>ae(()=>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:(()=>ae(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>ae(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>ae(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>ae(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>ae(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>ae(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>ae(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>ae(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>ae(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>ae(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>ae(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>ae(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>ae(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>ae(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>ae(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>ae(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>ae(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>ae(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>ae(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>ae(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>ae(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>ae(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>ae(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>ae(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>ae(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>ae(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>ae(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>ae(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>ae(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>ae(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>ae(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>ae(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>ae(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>ae(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>ae(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>ae(()=>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:(()=>ae(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>ae(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>ae(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>ae(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>ae(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>ae(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>ae(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>ae(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>ae(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>ae(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>ae(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>ae(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>ae(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>ae(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>ae(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>ae(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>ae(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>ae(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>ae(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>ae(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>ae(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>ae(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>ae(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>ae(()=>import("./zig-VOosw3JB.js"),[]))}],nv=Object.fromEntries(am.map(e=>[e.id,e.import])),rv=Object.fromEntries(am.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),om={...nv,...rv},sv=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>ae(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>ae(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>ae(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>ae(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>ae(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>ae(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>ae(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>ae(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>ae(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>ae(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>ae(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>ae(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>ae(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>ae(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>ae(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>ae(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>ae(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>ae(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>ae(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>ae(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>ae(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>ae(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>ae(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>ae(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>ae(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>ae(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>ae(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>ae(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>ae(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>ae(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>ae(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>ae(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>ae(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>ae(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>ae(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>ae(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>ae(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>ae(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>ae(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>ae(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>ae(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>ae(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>ae(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>ae(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>ae(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>ae(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>ae(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>ae(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>ae(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>ae(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>ae(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>ae(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>ae(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>ae(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>ae(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>ae(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>ae(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>ae(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>ae(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>ae(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>ae(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>ae(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>ae(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>ae(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>ae(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],iv=Object.fromEntries(sv.map(e=>[e.id,e.import]));var av=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function O8(){return 2147483648}function M8(){return typeof performance<"u"?performance.now():Date.now()}const I8=(e,t)=>e+(t-e%t)%t;async function P8(e){let t,n;const r={};function a(x){n=x,r.HEAPU8=new Uint8Array(x),r.HEAPU32=new Uint32Array(x)}function o(x,w,C){r.HEAPU8.copyWithin(x,w,w+C)}function d(x){try{return t.grow(x-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function u(x){const w=r.HEAPU8.length;x=x>>>0;const C=O8();if(x>C)return!1;for(let v=1;v<=4;v*=2){let S=w*(1+.2/v);S=Math.min(S,x+100663296);const _=Math.min(C,I8(Math.max(x,S),65536));if(d(_))return!0}return!1}const c=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(x,w,C=1024){const v=w+C;let S=w;for(;x[S]&&!(S>=v);)++S;if(S-w>16&&x.buffer&&c)return c.decode(x.subarray(w,S));let _="";for(;w<S;){let b=x[w++];if(!(b&128)){_+=String.fromCharCode(b);continue}const j=x[w++]&63;if((b&224)===192){_+=String.fromCharCode((b&31)<<6|j);continue}const E=x[w++]&63;if((b&240)===224?b=(b&15)<<12|j<<6|E:b=(b&7)<<18|j<<12|E<<6|x[w++]&63,b<65536)_+=String.fromCharCode(b);else{const N=b-65536;_+=String.fromCharCode(55296|N>>10,56320|N&1023)}}return _}function m(x,w){return x?h(r.HEAPU8,x,w):""}const f={emscripten_get_now:M8,emscripten_memcpy_big:o,emscripten_resize_heap:u,fd_write:()=>0};async function g(){const w=await e({env:f,wasi_snapshot_preview1:f});t=w.memory,a(t.buffer),Object.assign(r,w),r.UTF8ToString=m}return await g(),r}var B8=Object.defineProperty,$8=(e,t,n)=>t in e?B8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bn=(e,t,n)=>$8(e,typeof t!="symbol"?t+"":t,n);let Wn=null;function F8(e){throw new av(e.UTF8ToString(e.getLastOnigError()))}class lm{constructor(t){Bn(this,"utf16Length"),Bn(this,"utf8Length"),Bn(this,"utf16Value"),Bn(this,"utf8Value"),Bn(this,"utf16OffsetToUtf8"),Bn(this,"utf8OffsetToUtf16");const n=t.length,r=lm._utf8ByteLength(t),a=r!==n,o=a?new Uint32Array(n+1):null;a&&(o[n]=r);const d=a?new Uint32Array(r+1):null;a&&(d[r]=n);const u=new Uint8Array(r);let c=0;for(let h=0;h<n;h++){const m=t.charCodeAt(h);let f=m,g=!1;if(m>=55296&&m<=56319&&h+1<n){const x=t.charCodeAt(h+1);x>=56320&&x<=57343&&(f=(m-55296<<10)+65536|x-56320,g=!0)}a&&(o[h]=c,g&&(o[h+1]=c),f<=127?d[c+0]=h:f<=2047?(d[c+0]=h,d[c+1]=h):f<=65535?(d[c+0]=h,d[c+1]=h,d[c+2]=h):(d[c+0]=h,d[c+1]=h,d[c+2]=h,d[c+3]=h)),f<=127?u[c++]=f:f<=2047?(u[c++]=192|(f&1984)>>>6,u[c++]=128|(f&63)>>>0):f<=65535?(u[c++]=224|(f&61440)>>>12,u[c++]=128|(f&4032)>>>6,u[c++]=128|(f&63)>>>0):(u[c++]=240|(f&1835008)>>>18,u[c++]=128|(f&258048)>>>12,u[c++]=128|(f&4032)>>>6,u[c++]=128|(f&63)>>>0),g&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=u,this.utf16OffsetToUtf8=o,this.utf8OffsetToUtf16=d}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const o=t.charCodeAt(r);let d=o,u=!1;if(o>=55296&&o<=56319&&r+1<a){const c=t.charCodeAt(r+1);c>=56320&&c<=57343&&(d=(o-55296<<10)+65536|c-56320,u=!0)}d<=127?n+=1:d<=2047?n+=2:d<=65535?n+=3:n+=4,u&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const cm=class Rs{constructor(t){if(Bn(this,"id",++Rs.LAST_ID),Bn(this,"_onigBinding"),Bn(this,"content"),Bn(this,"utf16Length"),Bn(this,"utf8Length"),Bn(this,"utf16OffsetToUtf8"),Bn(this,"utf8OffsetToUtf16"),Bn(this,"ptr"),!Wn)throw new av("Must invoke loadWasm first.");this._onigBinding=Wn,this.content=t;const n=new lm(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Rs._sharedPtrInUse?(Rs._sharedPtr||(Rs._sharedPtr=Wn.omalloc(1e4)),Rs._sharedPtrInUse=!0,Wn.HEAPU8.set(n.utf8Value,Rs._sharedPtr),this.ptr=Rs._sharedPtr):this.ptr=n.createString(Wn)}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===Rs._sharedPtr?Rs._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Bn(cm,"LAST_ID",0);Bn(cm,"_sharedPtr",0);Bn(cm,"_sharedPtrInUse",!1);let o2=cm;class z8{constructor(t){if(Bn(this,"_onigBinding"),Bn(this,"_ptr"),!Wn)throw new av("Must invoke loadWasm first.");const n=[],r=[];for(let u=0,c=t.length;u<c;u++){const h=new lm(t[u]);n[u]=h.createString(Wn),r[u]=h.utf8Length}const a=Wn.omalloc(4*t.length);Wn.HEAPU32.set(n,a/4);const o=Wn.omalloc(4*t.length);Wn.HEAPU32.set(r,o/4);const d=Wn.createOnigScanner(a,o,t.length);for(let u=0,c=t.length;u<c;u++)Wn.ofree(n[u]);Wn.ofree(o),Wn.ofree(a),d===0&&F8(Wn),this._onigBinding=Wn,this._ptr=d}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let a=0;if(typeof r=="number"&&(a=r),typeof t=="string"){t=new o2(t);const o=this._findNextMatchSync(t,n,!1,a);return t.dispose(),o}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,r,a){const o=this._onigBinding,d=o.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(d===0)return null;const u=o.HEAPU32;let c=d/4;const h=u[c++],m=u[c++],f=[];for(let g=0;g<m;g++){const x=t.convertUtf8OffsetToUtf16(u[c++]),w=t.convertUtf8OffsetToUtf16(u[c++]);f[g]={start:x,end:w,length:w-x}}return{index:h,captureIndices:f}}}function H8(e){return typeof e.instantiator=="function"}function U8(e){return typeof e.default=="function"}function V8(e){return typeof e.data<"u"}function W8(e){return typeof Response<"u"&&e instanceof Response}function G8(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 fh;function ov(e){if(fh)return fh;async function t(){Wn=await P8(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),H8(r)?r=await r.instantiator(n):U8(r)?r=await r.default(n):(V8(r)&&(r=r.data),W8(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await q8(r)(n):r=await K8(r)(n):G8(r)?r=await xx(r)(n):r instanceof WebAssembly.Module?r=await xx(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await xx(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return fh=t(),fh}function xx(e){return t=>WebAssembly.instantiate(e,t)}function q8(e){return t=>WebAssembly.instantiateStreaming(e,t)}function K8(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let l2;function Y8(e){l2=e}function X8(){return l2}async function c2(e){return e&&await ov(e),{createScanner(t){return new z8(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new o2(t)}}}const Q8=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:c2,getDefaultWasmLoader:X8,loadWasm:ov,setDefaultWasmLoader:Y8},Symbol.toStringTag,{value:"Module"}));var u2=tv({});a2(u2,Q8);var un=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function J8(e){return lv(e)}function lv(e){return Array.isArray(e)?Z8(e):e instanceof RegExp?e:typeof e=="object"?e$(e):e}function Z8(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=lv(e[n]);return t}function e$(e){let t={};for(let n in e)t[n]=lv(e[n]);return t}function d2(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function h2(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?h2(e.substring(0,e.length-1)):e.substr(~t+1)}var yx=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,mh=class{static hasCaptures(e){return e===null?!1:(yx.lastIndex=0,yx.test(e))}static replaceCaptures(e,t,n){return e.replace(yx,(r,a,o,d)=>{let u=n[parseInt(a||o,10)];if(u){let c=t.substring(u.start,u.end);for(;c[0]===".";)c=c.substring(1);switch(d){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function f2(e,t){return e<t?-1:e>t?1:0}function m2(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let a=0;a<n;a++){let o=f2(e[a],t[a]);if(o!==0)return o}return 0}return n-r}function LC(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 p2(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var g2=class{constructor(e){Te(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}},lf=class{constructor(e,t,n){Te(this,"_cachedMatchRoot",new g2(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(r$(e),t)}static createFromParsedTheme(e,t){return i$(e,t)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(a=>t$(e.parent,a.parentScopes));return r?new x2(r.fontStyle,r.foreground,r.background):null}},bx=class Vh{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Vh(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Vh(n,t[r]);return n}push(t){return new Vh(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 t$(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],a=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],a=!0}for(;e&&!n$(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function n$(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var x2=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function r$(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let a=0,o=t.length;a<o;a++){let d=t[a];if(!d.settings)continue;let u;if(typeof d.scope=="string"){let f=d.scope;f=f.replace(/^[,]+/,""),f=f.replace(/[,]+$/,""),u=f.split(",")}else Array.isArray(d.scope)?u=d.scope:u=[""];let c=-1;if(typeof d.settings.fontStyle=="string"){c=0;let f=d.settings.fontStyle.split(" ");for(let g=0,x=f.length;g<x;g++)switch(f[g]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let h=null;typeof d.settings.foreground=="string"&&LC(d.settings.foreground)&&(h=d.settings.foreground);let m=null;typeof d.settings.background=="string"&&LC(d.settings.background)&&(m=d.settings.background);for(let f=0,g=u.length;f<g;f++){let w=u[f].trim().split(" "),C=w[w.length-1],v=null;w.length>1&&(v=w.slice(0,w.length-1),v.reverse()),n[r++]=new s$(C,v,a,c,h,m)}}return n}var s$=class{constructor(e,t,n,r,a,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=a,this.background=o}},sr=(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))(sr||{});function i$(e,t){e.sort((c,h)=>{let m=f2(c.scope,h.scope);return m!==0||(m=m2(c.parentScopes,h.parentScopes),m!==0)?m:c.index-h.index});let n=0,r="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let c=e.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(a=c.background)}let o=new a$(t),d=new x2(n,o.getId(r),o.getId(a)),u=new l$(new Ty(0,null,-1,0,0),[]);for(let c=0,h=e.length;c<h;c++){let m=e[c];u.insert(0,m.scope,m.parentScopes,m.fontStyle,o.getId(m.foreground),o.getId(m.background))}return new lf(o,d,u)}var a$=class{constructor(e){Te(this,"_isFrozen");Te(this,"_lastColorId");Te(this,"_id2color");Te(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)}},o$=Object.freeze([]),Ty=class y2{constructor(t,n,r,a,o){Te(this,"scopeDepth");Te(this,"parentScopes");Te(this,"fontStyle");Te(this,"foreground");Te(this,"background");this.scopeDepth=t,this.parentScopes=n||o$,this.fontStyle=r,this.foreground=a,this.background=o}clone(){return new y2(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,a=t.length;r<a;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,a){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),a!==0&&(this.background=a)}},l$=class Ay{constructor(t,n=[],r={}){Te(this,"_rulesWithParentScopes");this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,a=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[a]===">"&&a++,!(r>=t.parentScopes.length||a>=n.parentScopes.length);){const o=n.parentScopes[a].length-t.parentScopes[r].length;if(o!==0)return o;r++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),a,o;if(r===-1?(a=t,o=""):(a=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(a))return this._children[a].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Ay._cmpBySpecificity),n}insert(t,n,r,a,o,d){if(n===""){this._doInsertHere(t,r,a,o,d);return}let u=n.indexOf("."),c,h;u===-1?(c=n,h=""):(c=n.substring(0,u),h=n.substring(u+1));let m;this._children.hasOwnProperty(c)?m=this._children[c]:(m=new Ay(this._mainRule.clone(),Ty.cloneArr(this._rulesWithParentScopes)),this._children[c]=m),m.insert(t+1,h,r,a,o,d)}_doInsertHere(t,n,r,a,o){if(n===null){this._mainRule.acceptOverwrite(t,r,a,o);return}for(let d=0,u=this._rulesWithParentScopes.length;d<u;d++){let c=this._rulesWithParentScopes[d];if(m2(c.parentScopes,n)===0){c.acceptOverwrite(t,r,a,o);return}}r===-1&&(r=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Ty(t,n,r,a,o))}},ro=class Jr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Jr.getLanguageId(t),r=Jr.getTokenType(t),a=Jr.getFontStyle(t),o=Jr.getForeground(t),d=Jr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:a,foreground:o,background:d})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,a,o,d,u){let c=Jr.getLanguageId(t),h=Jr.getTokenType(t),m=Jr.containsBalancedBrackets(t)?1:0,f=Jr.getFontStyle(t),g=Jr.getForeground(t),x=Jr.getBackground(t);return n!==0&&(c=n),r!==8&&(h=r),a!==null&&(m=a?1:0),o!==-1&&(f=o),d!==0&&(g=d),u!==0&&(x=u),(c<<0|h<<8|m<<10|f<<11|g<<15|x<<24)>>>0}};function cf(e,t){const n=[],r=c$(e);let a=r.next();for(;a!==null;){let c=0;if(a.length===2&&a.charAt(1)===":"){switch(a.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${a} in scope selector`)}a=r.next()}let h=d();if(n.push({matcher:h,priority:c}),a!==",")break;a=r.next()}return n;function o(){if(a==="-"){a=r.next();const c=o();return h=>!!c&&!c(h)}if(a==="("){a=r.next();const c=u();return a===")"&&(a=r.next()),c}if(RC(a)){const c=[];do c.push(a),a=r.next();while(RC(a));return h=>t(c,h)}return null}function d(){const c=[];let h=o();for(;h;)c.push(h),h=o();return m=>c.every(f=>f(m))}function u(){const c=[];let h=d();for(;h&&(c.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=d()}return m=>c.some(f=>f(m))}}function RC(e){return!!e&&!!e.match(/[\w\.:]+/)}function c$(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 b2(e){typeof e.dispose=="function"&&e.dispose()}var _u=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},u$=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},d$=class{constructor(){Te(this,"_references",[]);Te(this,"_seenReferenceKeys",new Set);Te(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))}},h$=class{constructor(e,t){Te(this,"seenFullScopeRequests",new Set);Te(this,"seenPartialScopeRequests",new Set);Te(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new _u(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new d$;for(const n of e)f$(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof _u){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 f$(e,t,n,r){const a=n.lookup(e.scopeName);if(!a){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const o=n.lookup(t);e instanceof _u?Wh({baseGrammar:o,selfGrammar:a},r):Ly(e.ruleName,{baseGrammar:o,selfGrammar:a,repository:a.repository},r);const d=n.injections(e.scopeName);if(d)for(const u of d)r.add(new _u(u))}function Ly(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];uf([r],t,n)}}function Wh(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&uf(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&uf(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function uf(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?d2({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&uf(r.patterns,{...t,repository:a},n);const o=r.include;if(!o)continue;const d=v2(o);switch(d.kind){case 0:Wh({...t,selfGrammar:t.baseGrammar},n);break;case 1:Wh(t,n);break;case 2:Ly(d.ruleName,{...t,repository:a},n);break;case 3:case 4:const u=d.scopeName===t.selfGrammar.scopeName?t.selfGrammar:d.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(u){const c={baseGrammar:t.baseGrammar,selfGrammar:u,repository:a};d.kind===4?Ly(d.ruleName,c,n):Wh(c,n)}else d.kind===4?n.add(new u$(d.scopeName,d.ruleName)):n.add(new _u(d.scopeName));break}}}var m$=class{constructor(){Te(this,"kind",0)}},p$=class{constructor(){Te(this,"kind",1)}},g$=class{constructor(e){Te(this,"kind",2);this.ruleName=e}},x$=class{constructor(e){Te(this,"kind",3);this.scopeName=e}},y$=class{constructor(e,t){Te(this,"kind",4);this.scopeName=e,this.ruleName=t}};function v2(e){if(e==="$base")return new m$;if(e==="$self")return new p$;const t=e.indexOf("#");if(t===-1)return new x$(e);if(t===0)return new g$(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new y$(n,r)}}var b$=/\\(\d+)/,DC=/\\(\d+)/g,v$=-1,_2=-2;var Mu=class{constructor(e,t,n,r){Te(this,"$location");Te(this,"id");Te(this,"_nameIsCapturing");Te(this,"_name");Te(this,"_contentNameIsCapturing");Te(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=mh.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=mh.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${h2(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:mh.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:mh.replaceCaptures(this._contentName,e,t)}},_$=class extends Mu{constructor(t,n,r,a,o){super(t,n,r,a);Te(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,a){throw new Error("Not supported!")}},S$=class extends Mu{constructor(t,n,r,a,o){super(t,n,r,null);Te(this,"_match");Te(this,"captures");Te(this,"_cachedCompiledPatterns");this._match=new Su(a,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new wu,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},OC=class extends Mu{constructor(t,n,r,a,o){super(t,n,r,a);Te(this,"hasMissingPatterns");Te(this,"patterns");Te(this,"_cachedCompiledPatterns");this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new wu,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ry=class extends Mu{constructor(t,n,r,a,o,d,u,c,h,m){super(t,n,r,a);Te(this,"_begin");Te(this,"beginCaptures");Te(this,"_end");Te(this,"endHasBackReferences");Te(this,"endCaptures");Te(this,"applyEndPatternLast");Te(this,"hasMissingPatterns");Te(this,"patterns");Te(this,"_cachedCompiledPatterns");this._begin=new Su(o,this.id),this.beginCaptures=d,this._end=new Su(u||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=c,this.applyEndPatternLast=h||!1,this.patterns=m.patterns,this.hasMissingPatterns=m.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new wu;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}},df=class extends Mu{constructor(t,n,r,a,o,d,u,c,h){super(t,n,r,a);Te(this,"_begin");Te(this,"beginCaptures");Te(this,"whileCaptures");Te(this,"_while");Te(this,"whileHasBackReferences");Te(this,"hasMissingPatterns");Te(this,"patterns");Te(this,"_cachedCompiledPatterns");Te(this,"_cachedCompiledWhilePatterns");this._begin=new Su(o,this.id),this.beginCaptures=d,this.whileCaptures=c,this._while=new Su(u,_2),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,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new wu;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,n){return this._getCachedCompiledWhilePatterns(t,n).compile(t)}compileWhileAG(t,n,r,a){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,a)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new wu,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},S2=class rr{static createCaptureRule(t,n,r,a,o){return t.registerRule(d=>new _$(n,d,r,a,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new S$(t.$vscodeTextmateLocation,t.id,t.name,t.match,rr._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=d2({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new OC(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,rr._compilePatterns(o,n,r))}return t.while?new df(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,rr._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,rr._compileCaptures(t.whileCaptures||t.captures,n,r),rr._compilePatterns(t.patterns,n,r)):new Ry(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,rr._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,rr._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,rr._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let a=[];if(t){let o=0;for(const d in t){if(d==="$vscodeTextmateLocation")continue;const u=parseInt(d,10);u>o&&(o=u)}for(let d=0;d<=o;d++)a[d]=null;for(const d in t){if(d==="$vscodeTextmateLocation")continue;const u=parseInt(d,10);let c=0;t[d].patterns&&(c=rr.getCompiledRuleId(t[d],n,r)),a[u]=rr.createCaptureRule(n,t[d].$vscodeTextmateLocation,t[d].name,t[d].contentName,c)}}return a}static _compilePatterns(t,n,r){let a=[];if(t)for(let o=0,d=t.length;o<d;o++){const u=t[o];let c=-1;if(u.include){const h=v2(u.include);switch(h.kind){case 0:case 1:c=rr.getCompiledRuleId(r[u.include],n,r);break;case 2:let m=r[h.ruleName];m&&(c=rr.getCompiledRuleId(m,n,r));break;case 3:case 4:const f=h.scopeName,g=h.kind===4?h.ruleName:null,x=n.getExternalGrammar(f,r);if(x)if(g){let w=x.repository[g];w&&(c=rr.getCompiledRuleId(w,n,x.repository))}else c=rr.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else c=rr.getCompiledRuleId(u,n,r);if(c!==-1){const h=n.getRule(c);let m=!1;if((h instanceof OC||h instanceof Ry||h instanceof df)&&h.hasMissingPatterns&&h.patterns.length===0&&(m=!0),m)continue;a.push(c)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},Su=class w2{constructor(t,n){Te(this,"source");Te(this,"ruleId");Te(this,"hasAnchor");Te(this,"hasBackReferences");Te(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,o=[],d=!1;for(let u=0;u<r;u++)if(t.charAt(u)==="\\"&&u+1<r){const h=t.charAt(u+1);h==="z"?(o.push(t.substring(a,u)),o.push("$(?!\\n)(?<!\\n)"),a=u+2):(h==="A"||h==="G")&&(d=!0),u++}this.hasAnchor=d,a===0?this.source=t:(o.push(t.substring(a,r)),this.source=o.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=b$.test(this.source):this.hasBackReferences=!1}clone(){return new w2(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(a=>t.substring(a.start,a.end));return DC.lastIndex=0,this.source.replace(DC,(a,o)=>p2(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],a=[],o,d,u,c;for(o=0,d=this.source.length;o<d;o++)u=this.source.charAt(o),t[o]=u,n[o]=u,r[o]=u,a[o]=u,u==="\\"&&o+1<d&&(c=this.source.charAt(o+1),c==="A"?(t[o+1]="￿",n[o+1]="￿",r[o+1]="A",a[o+1]="A"):c==="G"?(t[o+1]="￿",n[o+1]="G",r[o+1]="￿",a[o+1]="G"):(t[o+1]=c,n[o+1]=c,r[o+1]=c,a[o+1]=c),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:a.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},wu=class{constructor(){Te(this,"_items");Te(this,"_hasAnchors");Te(this,"_cached");Te(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 MC(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(a=>a.resolveAnchors(t,n));return new MC(e,r,this._items.map(a=>a.ruleId))}},MC=class{constructor(e,t,n){Te(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(`
96
+ `)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},vx=class{constructor(e,t){this.languageId=e,this.tokenType=t}},yi,w$=(yi=class{constructor(t,n){Te(this,"_defaultAttributes");Te(this,"_embeddedLanguagesMatcher");Te(this,"_getBasicScopeAttributes",new g2(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new vx(n,r)}));this._defaultAttributes=new vx(t,8),this._embeddedLanguagesMatcher=new C$(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?yi._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(yi.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!")}},Te(yi,"_NULL_SCOPE_METADATA",new vx(0,0)),Te(yi,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),yi),C$=class{constructor(e){Te(this,"values");Te(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>p2(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])}},IC=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function C2(e,t,n,r,a,o,d,u){const c=t.content.length;let h=!1,m=-1;if(d){const x=k$(e,t,n,r,a,o);a=x.stack,r=x.linePos,n=x.isFirstLine,m=x.anchorPosition}const f=Date.now();for(;!h;){if(u!==0&&Date.now()-f>u)return new IC(a,!0);g()}return new IC(a,!1);function g(){const x=j$(e,t,n,r,a,m);if(!x){o.produce(a,c),h=!0;return}const w=x.captureIndices,C=x.matchedRuleId,v=w&&w.length>0?w[0].end>r:!1;if(C===v$){const S=a.getRule(e);o.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),Zc(e,t,n,a,o,S.endCaptures,w),o.produce(a,w[0].end);const _=a;if(a=a.parent,m=_.getAnchorPos(),!v&&_.getEnterPos()===r){a=_,o.produce(a,c),h=!0;return}}else{const S=e.getRule(C);o.produce(a,w[0].start);const _=a,b=S.getName(t.content,w),j=a.contentNameScopesList.pushAttributed(b,e);if(a=a.push(C,r,m,w[0].end===c,null,j,j),S instanceof Ry){const E=S;Zc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),m=w[0].end;const N=E.getContentName(t.content,w),L=j.pushAttributed(N,e);if(a=a.withContentNameScopesList(L),E.endHasBackReferences&&(a=a.withEndRule(E.getEndWithResolvedBackReferences(t.content,w))),!v&&_.hasSameRuleAs(a)){a=a.pop(),o.produce(a,c),h=!0;return}}else if(S instanceof df){const E=S;Zc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),m=w[0].end;const N=E.getContentName(t.content,w),L=j.pushAttributed(N,e);if(a=a.withContentNameScopesList(L),E.whileHasBackReferences&&(a=a.withEndRule(E.getWhileWithResolvedBackReferences(t.content,w))),!v&&_.hasSameRuleAs(a)){a=a.pop(),o.produce(a,c),h=!0;return}}else if(Zc(e,t,n,a,o,S.captures,w),o.produce(a,w[0].end),a=a.pop(),!v){a=a.safePop(),o.produce(a,c),h=!0;return}}w[0].end>r&&(r=w[0].end,n=!1)}}function k$(e,t,n,r,a,o){let d=a.beginRuleCapturedEOL?0:-1;const u=[];for(let c=a;c;c=c.pop()){const h=c.getRule(e);h instanceof df&&u.push({rule:h,stack:c})}for(let c=u.pop();c;c=u.pop()){const{ruleScanner:h,findOptions:m}=T$(c.rule,e,c.stack.endRule,n,r===d),f=h.findNextMatchSync(t,r,m);if(f){if(f.ruleId!==_2){a=c.stack.pop();break}f.captureIndices&&f.captureIndices.length&&(o.produce(c.stack,f.captureIndices[0].start),Zc(e,t,n,c.stack,o,c.rule.whileCaptures,f.captureIndices),o.produce(c.stack,f.captureIndices[0].end),d=f.captureIndices[0].end,f.captureIndices[0].end>r&&(r=f.captureIndices[0].end,n=!1))}else{a=c.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:d,isFirstLine:n}}function j$(e,t,n,r,a,o){const d=E$(e,t,n,r,a,o),u=e.getInjections();if(u.length===0)return d;const c=N$(u,e,t,n,r,a,o);if(!c)return d;if(!d)return c;const h=d.captureIndices[0].start,m=c.captureIndices[0].start;return m<h||c.priorityMatch&&m===h?c:d}function E$(e,t,n,r,a,o){const d=a.getRule(e),{ruleScanner:u,findOptions:c}=k2(d,e,a.endRule,n,r===o),h=u.findNextMatchSync(t,r,c);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function N$(e,t,n,r,a,o,d){let u=Number.MAX_VALUE,c=null,h,m=0;const f=o.contentNameScopesList.getScopeNames();for(let g=0,x=e.length;g<x;g++){const w=e[g];if(!w.matcher(f))continue;const C=t.getRule(w.ruleId),{ruleScanner:v,findOptions:S}=k2(C,t,null,r,a===d),_=v.findNextMatchSync(n,a,S);if(!_)continue;const b=_.captureIndices[0].start;if(!(b>=u)&&(u=b,c=_.captureIndices,h=_.ruleId,m=w.priority,u===a))break}return c?{priorityMatch:m===-1,captureIndices:c,matchedRuleId:h}:null}function k2(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function T$(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function Zc(e,t,n,r,a,o,d){if(o.length===0)return;const u=t.content,c=Math.min(o.length,d.length),h=[],m=d[0].end;for(let f=0;f<c;f++){const g=o[f];if(g===null)continue;const x=d[f];if(x.length===0)continue;if(x.start>m)break;for(;h.length>0&&h[h.length-1].endPos<=x.start;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?a.produceFromScopes(h[h.length-1].scopes,x.start):a.produce(r,x.start),g.retokenizeCapturedWithRuleId){const C=g.getName(u,d),v=r.contentNameScopesList.pushAttributed(C,e),S=g.getContentName(u,d),_=v.pushAttributed(S,e),b=r.push(g.retokenizeCapturedWithRuleId,x.start,-1,!1,null,v,_),j=e.createOnigString(u.substring(0,x.end));C2(e,j,n&&x.start===0,x.start,b,a,!1,0),b2(j);continue}const w=g.getName(u,d);if(w!==null){const v=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);h.push(new A$(v,x.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var A$=class{constructor(e,t){Te(this,"scopes");Te(this,"endPos");this.scopes=e,this.endPos=t}};function L$(e,t,n,r,a,o,d,u){return new D$(e,t,n,r,a,o,d,u)}function PC(e,t,n,r,a){const o=cf(t,hf),d=S2.getCompiledRuleId(n,r,a.repository);for(const u of o)e.push({debugSelector:t,matcher:u.matcher,ruleId:d,grammar:a,priority:u.priority})}function hf(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let a=n;a<t.length;a++)if(R$(t[a],r))return n=a+1,!0;return!1})}function R$(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 D$=class{constructor(e,t,n,r,a,o,d,u){Te(this,"_rootId");Te(this,"_lastRuleId");Te(this,"_ruleId2desc");Te(this,"_includedGrammars");Te(this,"_grammarRepository");Te(this,"_grammar");Te(this,"_injections");Te(this,"_basicScopeAttributesProvider");Te(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=u,this._basicScopeAttributesProvider=new w$(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=d,this._grammar=BC(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const c of Object.keys(a)){const h=cf(c,hf);for(const m of h)this._tokenTypeMatchers.push({matcher:m.matcher,type:a[c]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const a=r.injections;if(a)for(let d in a)PC(t,d,a[d],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(d=>{const u=this.getExternalGrammar(d);if(u){const c=u.injectionSelector;c&&PC(t,c,u,this,u)}})}return t.sort((a,o)=>a.priority-o.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]=BC(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=S2.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===Dy.NULL){a=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),m=this.themeProvider.getDefaults(),f=ro.set(0,h.languageId,h.tokenType,null,m.fontStyle,m.foregroundId,m.backgroundId),g=this.getRule(this._rootId).getName(null,null);let x;g?x=au.createRootAndLookUpScopeName(g,f,this):x=au.createRoot("unknown",f),t=new Dy(null,this._rootId,-1,-1,!1,null,x,x)}else a=!1,t.reset();e=e+`
97
+ `;const o=this.createOnigString(e),d=o.content.length,u=new M$(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=C2(this,o,a,0,t,u,!0,r);return b2(o),{lineLength:d,lineTokens:u,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function BC(e,t){return e=J8(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 au=class Ds{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,a=(t==null?void 0:t.scopePath)??null;for(const o of n)a=bx.push(a,o.scopeNames),r=new Ds(r,a,o.encodedTokenAttributes);return r}static createRoot(t,n){return new Ds(null,new bx(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),o=new bx(null,t),d=r.themeProvider.themeMatch(o),u=Ds.mergeAttributes(n,a,d);return new Ds(null,o,u)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ds.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let a=-1,o=0,d=0;return r!==null&&(a=r.fontStyle,o=r.foregroundId,d=r.backgroundId),ro.set(t,n.languageId,n.tokenType,null,a,o,d)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Ds._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const o of r)a=Ds._pushAttributed(a,o,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),o=t.scopePath.push(n),d=r.themeProvider.themeMatch(o),u=Ds.mergeAttributes(t.tokenAttributes,a,d);return new Ds(t,o,u)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((a=r.parent)==null?void 0:a.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},ts,Dy=(ts=class{constructor(t,n,r,a,o,d,u,c){Te(this,"_stackElementBrand");Te(this,"_enterPos");Te(this,"_anchorPos");Te(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=d,this.nameScopesList=u,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=a}equals(t){return t===null?!1:ts._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?au.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(){ts._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,o,d,u){return new ts(this,t,n,r,a,o,d,u)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var r,a;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(a=this.contentNameScopesList)==null?void 0:a.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new ts(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=au.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new ts(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,au.fromExtension(r,n.contentNameScopesList))}},Te(ts,"NULL",new ts(null,0,0,0,!1,null,null,null)),ts),O$=class{constructor(e,t){Te(this,"balancedBracketScopes");Te(this,"unbalancedBracketScopes");Te(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):cf(n,hf).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>cf(n,hf).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}},M$=class{constructor(e,t,n,r){Te(this,"_emitBinaryTokens");Te(this,"_lineText");Te(this,"_tokens");Te(this,"_binaryTokens");Te(this,"_lastTokenEndIndex");Te(this,"_tokenTypeOverrides");this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var r;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let a=(e==null?void 0:e.tokenAttributes)??0,o=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const d=(e==null?void 0:e.getScopeNames())??[];for(const u of this._tokenTypeOverrides)u.matcher(d)&&(a=ro.set(a,0,u.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(d))}if(o&&(a=ro.set(a,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===a){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(a),this._lastTokenEndIndex=t;return}const n=(e==null?void 0:e.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,a=this._binaryTokens.length;r<a;r++)n[r]=this._binaryTokens[r];return n}},I$=class{constructor(e,t){Te(this,"_grammars",new Map);Te(this,"_rawGrammars",new Map);Te(this,"_injectionGrammars",new Map);Te(this,"_theme");this._onigLib=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,a){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,L$(e,o,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},P$=class{constructor(t){Te(this,"_options");Te(this,"_syncRegistry");Te(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new I$(lf.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(lf.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 O$(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,o){const d=new h$(this._syncRegistry,t);for(;d.Q.length>0;)d.Q.map(u=>this._loadSingleGrammar(u.scopeName)),d.processQueue();return this._grammarForScopeName(t,n,r,a,o)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,a=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,a)}_grammarForScopeName(t,n=0,r=null,a=null,o=null){return this._syncRegistry.grammarForScopeName(t,n,r,a,o)}},Oy=Dy.NULL;function ff(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[a,o]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof o=="string"?n[a]=o:a===r&&Object.assign(n,o);return n}function ua(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function B$(e){return Array.isArray(e)?e:[e]}async function j2(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function um(e){return!e||["plaintext","txt","text","plain"].includes(e)}function E2(e){return e==="ansi"||um(e)}function dm(e){return e==="none"}function N2(e){return dm(e)}const $$=/(\r?\n)/g;function hm(e,t=!1){var o;if(e.length===0)return[["",0]];const n=e.split($$);let r=0;const a=[];for(let d=0;d<n.length;d+=2){const u=t?n[d]+(n[d+1]||""):n[d];a.push([u,r]),r+=n[d].length,r+=((o=n[d+1])==null?void 0:o.length)||0}return a}const $C={light:"#333333",dark:"#bbbbbb"},FC={light:"#fffffe",dark:"#1e1e1e"},zC="__shiki_resolved";function cv(e){var u,c,h,m,f;if(e!=null&&e[zC])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 g=t.settings?t.settings.find(x=>!x.name&&!x.scope):void 0;(u=g==null?void 0:g.settings)!=null&&u.foreground&&(r=g.settings.foreground),(c=g==null?void 0:g.settings)!=null&&c.background&&(n=g.settings.background),!r&&((h=t==null?void 0:t.colors)!=null&&h["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((m=t==null?void 0:t.colors)!=null&&m["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?$C.light:$C.dark),n||(n=t.type==="light"?FC.light:FC.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let a=0;const o=new Map;function d(g){var w;if(o.has(g))return o.get(g);a+=1;const x=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${x}`]?d(g):(o.set(g,x),x)}t.settings=t.settings.map(g=>{var v,S;const x=((v=g.settings)==null?void 0:v.foreground)&&!g.settings.foreground.startsWith("#"),w=((S=g.settings)==null?void 0:S.background)&&!g.settings.background.startsWith("#");if(!x&&!w)return g;const C={...g,settings:{...g.settings}};if(x){const _=d(g.settings.foreground);t.colorReplacements[_]=g.settings.foreground,C.settings.foreground=_}if(w){const _=d(g.settings.background);t.colorReplacements[_]=g.settings.background,C.settings.background=_}return C});for(const g of Object.keys(t.colors||{}))if((g==="editor.foreground"||g==="editor.background"||g.startsWith("terminal.ansi"))&&!((f=t.colors[g])!=null&&f.startsWith("#"))){const x=d(t.colors[g]);t.colorReplacements[x]=t.colors[g],t.colors[g]=x}return Object.defineProperty(t,zC,{enumerable:!1,writable:!1,value:!0}),t}async function T2(e){return[...new Set((await Promise.all(e.filter(t=>!E2(t)).map(async t=>await j2(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function A2(e){return(await Promise.all(e.map(async t=>N2(t)?null:cv(await j2(t))))).filter(t=>!!t)}function L2(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 un(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var F$=class extends P${constructor(t,n,r,a={}){super(t);Te(this,"_resolver");Te(this,"_themes");Te(this,"_langs");Te(this,"_alias");Te(this,"_resolvedThemes",new Map);Te(this,"_resolvedGrammars",new Map);Te(this,"_langMap",new Map);Te(this,"_langGraph",new Map);Te(this,"_textmateThemeCache",new WeakMap);Te(this,"_loadedThemesCache",null);Te(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=a,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=cv(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=lf.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=L2(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var o,d,u,c;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(h=>{var m;return(m=h.embeddedLangsLazy)==null?void 0:m.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(d=(o=this._syncRegistry)==null?void 0:o._injectionGrammars)==null||d.delete(h.scopeName),(c=(u=this._syncRegistry)==null?void 0:u._grammars)==null||c.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 a of t)this.resolveEmbeddedLanguages(a);const n=[...this._langGraph.entries()],r=n.filter(([a,o])=>!o);if(r.length){const a=n.filter(([o,d])=>{var u;return d?(u=d.embeddedLanguages||d.embeddedLangs)==null?void 0:u.some(c=>r.map(([h])=>h).includes(c)):!1}).filter(o=>!r.includes(o));throw new un(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${a.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[a,o]of n)this._resolver.addLanguage(o);for(const[a,o]of n)this.loadLanguage(o)}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))}},z$=class{constructor(e,t){Te(this,"_langs",new Map);Te(this,"_scopeToLang",new Map);Te(this,"_injections",new Map);Te(this,"_onigLib");this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const a=t.slice(0,r).join(".");n=[...n,...this._injections.get(a)||[]]}return n}};let Wc=0;function H$(e){Wc+=1,e.warnings!==!1&&Wc>=10&&Wc%10===0&&console.warn(`[Shiki] ${Wc} 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 un("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(cv),a=new F$(new z$(e.engine,n),r,n,e.langAlias);let o;function d(_){return L2(_,e.langAlias)}function u(_){v();const b=a.getGrammar(typeof _=="string"?_:_.name);if(!b)throw new un(`Language \`${_}\` not found, you may need to load it first`);return b}function c(_){if(_==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};v();const b=a.getTheme(_);if(!b)throw new un(`Theme \`${_}\` not found, you may need to load it first`);return b}function h(_){v();const b=c(_);return o!==_&&(a.setTheme(b),o=_),{theme:b,colorMap:a.getColorMap()}}function m(){return v(),a.getLoadedThemes()}function f(){return v(),a.getLoadedLanguages()}function g(..._){v(),a.loadLanguages(_.flat(1))}async function x(..._){return g(await T2(_))}function w(..._){v();for(const b of _.flat(1))a.loadTheme(b)}async function C(..._){return v(),w(await A2(_))}function v(){if(t)throw new un("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),Wc-=1)}return{setTheme:h,getTheme:c,getLanguage:u,getLoadedThemes:m,getLoadedLanguages:f,resolveLangAlias:d,loadLanguage:x,loadLanguageSync:g,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function U$(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([A2(e.themes||[]),T2(e.langs||[]),e.engine]);return H$({...e,themes:t,langs:n,engine:r})}const R2=new WeakMap;function fm(e,t){R2.set(e,t)}function Cu(e){return R2.get(e)}var mm=class D2{constructor(...t){Te(this,"_stacks",{});Te(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,a]=t;this.lang=r,this._stacks={[a]:n}}}get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new D2(Object.fromEntries(B$(n).map(r=>[r,Oy])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return V$(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function V$(e){const t=[],n=new Set;function r(a){var d;if(n.has(a))return;n.add(a);const o=(d=a==null?void 0:a.nameScopesList)==null?void 0:d.scopeName;o&&t.push(o),a.parent&&r(a.parent)}return r(e),t}function W$(e,t){if(!(e instanceof mm))throw new un("Invalid grammar state");return e.getInternalStack(t)}const G$=/,/,q$=/ /;function O2(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(um(e.resolveLangAlias(n.lang||"text"))||dm(r))return hm(t).map(u=>[{content:u[0],offset:u[1]}]);const{theme:a,colorMap:o}=e.setTheme(r),d=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==d.name)throw new un(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${d.name}"`);if(!n.grammarState.themes.includes(a.name))throw new un(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return Y$(t,d,a,o,n)}function K$(...e){if(e.length===2)return Cu(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:o=t.getLoadedThemes()[0]}=r;if(um(a)||dm(o))throw new un("Plain language does not have grammar state");if(a==="ansi")throw new un("ANSI language does not have grammar state");const{theme:d,colorMap:u}=t.setTheme(o),c=t.getLanguage(a);return new mm(uv(n,c,d,u,r).stateStack,c.name,d.name)}function Y$(e,t,n,r,a){const o=uv(e,t,n,r,a),d=new mm(o.stateStack,t.name,n.name);return fm(o.tokens,d),o.tokens}function uv(e,t,n,r,a){const o=ff(n,a),{tokenizeMaxLineLength:d=0,tokenizeTimeLimit:u=500,includeExplanation:c=!1}=a,h=hm(e);let m=a.grammarState?W$(a.grammarState,n.name)??Oy:a.grammarContextCode!=null?uv(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:Oy,f=[];const g=[];for(let x=0,w=h.length;x<w;x++){const[C,v]=h[x];if(C===""){f=[],g.push([]);continue}if(d>0&&C.length>=d){f=[],g.push([{content:C,offset:v,color:"",fontStyle:0}]);continue}let S,_,b;c&&c!=="tokenType"&&(S=t.tokenizeLine(C,m,u),_=S.tokens,b=0);const j=t.tokenizeLine2(C,m,u),E=j.tokens.length/2;for(let N=0;N<E;N++){const L=j.tokens[2*N],A=N+1<E?j.tokens[2*N+2]:C.length;if(L===A)continue;const D=j.tokens[2*N+1],O=ua(r[ro.getForeground(D)],o),F=ro.getFontStyle(D),P={content:C.substring(L,A),offset:v+L,color:O,fontStyle:F};if(c==="tokenType")P.type=ro.getTokenType(D);else if(c){const z=[];if(c!=="scopeName")for(const q of n.settings){let W;switch(typeof q.scope){case"string":W=q.scope.split(G$).map(Z=>Z.trim());break;case"object":W=q.scope;break;default:continue}z.push({settings:q,selectors:W.map(Z=>Z.split(q$))})}P.explanation=[];let K=0;for(;L+K<A;){const q=_[b],W=C.substring(q.startIndex,q.endIndex);K+=W.length,P.explanation.push({content:W,scopes:c==="scopeName"?X$(q.scopes):Q$(z,q.scopes)}),b+=1}}f.push(P)}g.push(f),f=[],m=j.ruleStack}return{tokens:g,stateStack:m}}function X$(e){return e.map(t=>({scopeName:t}))}function Q$(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const o=t[r];n[r]={scopeName:o,themeMatches:Z$(e,o,t.slice(0,r))}}return n}function HC(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function J$(e,t,n){if(!HC(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)HC(e[r],n[a])&&(r-=1),a-=1;return r===-1}function Z$(e,t,n){const r=[];for(const{selectors:a,settings:o}of e)for(const d of a)if(J$(d,t,n)){r.push(o);break}return r}function M2(e,t,n,r=O2){const a=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),o=a.map(h=>{const m=r(e,t,{...n,theme:h.theme});return{tokens:m,state:Cu(m),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),d=eF(...o.map(h=>h.tokens)),u=d[0].map((h,m)=>h.map((f,g)=>{const x={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=f.explanation),d.forEach((w,C)=>{const{content:v,explanation:S,offset:_,...b}=w[m][g];x.variants[a[C].color]=b}),x})),c=o[0].state?new mm(Object.fromEntries(o.map(h=>{var m;return[h.theme,(m=h.state)==null?void 0:m.getInternalStack(h.theme)]})),o[0].state.lang):void 0;return c&&fm(u,c),u}function eF(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const a=e.map(c=>c[r]),o=t.map(()=>[]);t.forEach((c,h)=>c.push(o[h]));const d=a.map(()=>0),u=a.map(c=>c[0]);for(;u.every(c=>c);){const c=Math.min(...u.map(h=>h.content.length));for(let h=0;h<n;h++){const m=u[h];m.content.length===c?(o[h].push(m),d[h]+=1,u[h]=a[h][d[h]]):(o[h].push({...m,content:m.content.slice(0,c)}),u[h]={...m,content:m.content.slice(c),offset:m.offset+c})}}}return t}const tF=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Iu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Iu.prototype.normal={};Iu.prototype.property={};Iu.prototype.space=void 0;function I2(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Iu(n,r,t)}function My(e){return e.toLowerCase()}class kr{constructor(t,n){this.attribute=n,this.property=t}}kr.prototype.attribute="";kr.prototype.booleanish=!1;kr.prototype.boolean=!1;kr.prototype.commaOrSpaceSeparated=!1;kr.prototype.commaSeparated=!1;kr.prototype.defined=!1;kr.prototype.mustUseProperty=!1;kr.prototype.number=!1;kr.prototype.overloadedBoolean=!1;kr.prototype.property="";kr.prototype.spaceSeparated=!1;kr.prototype.space=void 0;let nF=0;const _t=uo(),Mn=uo(),Iy=uo(),qe=uo(),sn=uo(),so=uo(),Mr=uo();function uo(){return 2**++nF}const Py=Object.freeze(Object.defineProperty({__proto__:null,boolean:_t,booleanish:Mn,commaOrSpaceSeparated:Mr,commaSeparated:so,number:qe,overloadedBoolean:Iy,spaceSeparated:sn},Symbol.toStringTag,{value:"Module"})),_x=Object.keys(Py);class dv extends kr{constructor(t,n,r,a){let o=-1;if(super(t,n),UC(this,"space",a),typeof r=="number")for(;++o<_x.length;){const d=_x[o];UC(this,_x[o],(r&Py[d])===Py[d])}}}dv.prototype.defined=!0;function UC(e,t,n){n&&(e[t]=n)}function Fl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new dv(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[My(r)]=r,n[My(o.attribute)]=r}return new Iu(t,n,e.space)}const P2=Fl({properties:{ariaActiveDescendant:null,ariaAtomic:Mn,ariaAutoComplete:null,ariaBusy:Mn,ariaChecked:Mn,ariaColCount:qe,ariaColIndex:qe,ariaColSpan:qe,ariaControls:sn,ariaCurrent:null,ariaDescribedBy:sn,ariaDetails:null,ariaDisabled:Mn,ariaDropEffect:sn,ariaErrorMessage:null,ariaExpanded:Mn,ariaFlowTo:sn,ariaGrabbed:Mn,ariaHasPopup:null,ariaHidden:Mn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:sn,ariaLevel:qe,ariaLive:null,ariaModal:Mn,ariaMultiLine:Mn,ariaMultiSelectable:Mn,ariaOrientation:null,ariaOwns:sn,ariaPlaceholder:null,ariaPosInSet:qe,ariaPressed:Mn,ariaReadOnly:Mn,ariaRelevant:null,ariaRequired:Mn,ariaRoleDescription:sn,ariaRowCount:qe,ariaRowIndex:qe,ariaRowSpan:qe,ariaSelected:Mn,ariaSetSize:qe,ariaSort:null,ariaValueMax:qe,ariaValueMin:qe,ariaValueNow:qe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function B2(e,t){return t in e?e[t]:t}function $2(e,t){return B2(e,t.toLowerCase())}const rF=Fl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:so,acceptCharset:sn,accessKey:sn,action:null,allow:null,allowFullScreen:_t,allowPaymentRequest:_t,allowUserMedia:_t,alpha:_t,alt:null,as:null,async:_t,autoCapitalize:null,autoComplete:sn,autoFocus:_t,autoPlay:_t,blocking:sn,capture:null,charSet:null,checked:_t,cite:null,className:sn,closedBy:null,colorSpace:null,cols:qe,colSpan:qe,command:null,commandFor:null,content:null,contentEditable:Mn,controls:_t,controlsList:sn,coords:qe|so,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_t,defer:_t,dir:null,dirName:null,disabled:_t,download:Iy,draggable:Mn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_t,formTarget:null,headers:sn,height:qe,hidden:Iy,high:qe,href:null,hrefLang:null,htmlFor:sn,httpEquiv:sn,id:null,imageSizes:null,imageSrcSet:null,inert:_t,inputMode:null,integrity:null,is:null,isMap:_t,itemId:null,itemProp:sn,itemRef:sn,itemScope:_t,itemType:sn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_t,low:qe,manifest:null,max:null,maxLength:qe,media:null,method:null,min:null,minLength:qe,multiple:_t,muted:_t,name:null,nonce:null,noModule:_t,noValidate:_t,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:_t,optimum:qe,pattern:null,ping:sn,placeholder:null,playsInline:_t,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_t,referrerPolicy:null,rel:sn,required:_t,reversed:_t,rows:qe,rowSpan:qe,sandbox:sn,scope:null,scoped:_t,seamless:_t,selected:_t,shadowRootClonable:_t,shadowRootCustomElementRegistry:_t,shadowRootDelegatesFocus:_t,shadowRootMode:null,shadowRootSerializable:_t,shape:null,size:qe,sizes:null,slot:null,span:qe,spellCheck:Mn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:qe,step:null,style:null,tabIndex:qe,target:null,title:null,translate:null,type:null,typeMustMatch:_t,useMap:null,value:Mn,width:qe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:sn,axis:null,background:null,bgColor:null,border:qe,borderColor:null,bottomMargin:qe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_t,declare:_t,event:null,face:null,frame:null,frameBorder:null,hSpace:qe,leftMargin:qe,link:null,longDesc:null,lowSrc:null,marginHeight:qe,marginWidth:qe,noResize:_t,noHref:_t,noShade:_t,noWrap:_t,object:null,profile:null,prompt:null,rev:null,rightMargin:qe,rules:null,scheme:null,scrolling:Mn,standby:null,summary:null,text:null,topMargin:qe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:qe,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:_t,disablePictureInPicture:_t,disableRemotePlayback:_t,exportParts:so,part:sn,prefix:null,property:null,results:qe,security:null,unselectable:null},space:"html",transform:$2}),sF=Fl({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",maskType:"mask-type",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:Mr,accentHeight:qe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:qe,amplitude:qe,arabicForm:null,ascent:qe,attributeName:null,attributeType:null,azimuth:qe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:qe,by:null,calcMode:null,capHeight:qe,className:sn,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:qe,diffuseConstant:qe,direction:null,display:null,dur:null,divisor:qe,dominantBaseline:null,download:_t,dx:null,dy:null,edgeMode:null,editable:null,elevation:qe,enableBackground:null,end:null,event:null,exponent:qe,externalResourcesRequired:null,fill:null,fillOpacity:qe,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:so,g2:so,glyphName:so,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:qe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:qe,horizOriginX:qe,horizOriginY:qe,id:null,ideographic:qe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:qe,k:qe,k1:qe,k2:qe,k3:qe,k4:qe,kernelMatrix:Mr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:qe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:qe,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:qe,overlineThickness:qe,paintOrder:null,panose1:null,path:null,pathLength:qe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:sn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:qe,pointsAtY:qe,pointsAtZ:qe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mr,rev:Mr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mr,requiredFeatures:Mr,requiredFonts:Mr,requiredFormats:Mr,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:qe,specularExponent:qe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:qe,strikethroughThickness:qe,string:null,stroke:null,strokeDashArray:Mr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:qe,strokeOpacity:qe,strokeWidth:null,style:null,surfaceScale:qe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mr,tabIndex:qe,tableValues:null,target:null,targetX:qe,targetY:qe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Mr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:qe,underlineThickness:qe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:qe,values:null,vAlphabetic:qe,vMathematical:qe,vectorEffect:null,vHanging:qe,vIdeographic:qe,version:null,vertAdvY:qe,vertOriginX:qe,vertOriginY:qe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:qe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:B2}),F2=Fl({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()}}),z2=Fl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:$2}),H2=Fl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),iF=/[A-Z]/g,VC=/-[a-z]/g,aF=/^data[-\w.:]+$/i;function oF(e,t){const n=My(t);let r=t,a=kr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&aF.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(VC,cF);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!VC.test(o)){let d=o.replace(iF,lF);d.charAt(0)!=="-"&&(d="-"+d),t="data"+d}}a=dv}return new a(r,t)}function lF(e){return"-"+e.toLowerCase()}function cF(e){return e.charAt(1).toUpperCase()}const uF=I2([P2,rF,F2,z2,H2],"html"),U2=I2([P2,sF,F2,z2,H2],"svg"),WC={}.hasOwnProperty;function dF(e,t){const n=t||{};function r(a,...o){let d=r.invalid;const u=r.handlers;if(a&&WC.call(a,e)){const c=String(a[e]);d=WC.call(u,c)?u[c]:r.unknown}if(d)return d.call(this,a,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const hF=/["&'<>`]/g,fF=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,mF=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,pF=/[|\\{}()[\]^$+*?.]/g,GC=new WeakMap;function gF(e,t){if(e=e.replace(t.subset?xF(t.subset):hF,r),t.subset||t.escapeOnly)return e;return e.replace(fF,n).replace(mF,r);function n(a,o,d){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,d.charCodeAt(o+2),t)}function r(a,o,d){return t.format(a.charCodeAt(0),d.charCodeAt(o+1),t)}}function xF(e){let t=GC.get(e);return t||(t=yF(e),GC.set(e,t)),t}function yF(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(pF,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const bF=/[\dA-Fa-f]/;function vF(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!bF.test(String.fromCharCode(t))?r:r+";"}const _F=/\d/;function SF(e,t,n){const r="&#"+String(e);return n&&t&&!_F.test(String.fromCharCode(t))?r:r+";"}const wF=["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"],Sx={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:"€"},CF=["cent","copy","divide","gt","lt","not","para","times"],V2={}.hasOwnProperty,By={};let ph;for(ph in Sx)V2.call(Sx,ph)&&(By[Sx[ph]]=ph);const kF=/[^\dA-Za-z]/;function jF(e,t,n,r){const a=String.fromCharCode(e);if(V2.call(By,a)){const o=By[a],d="&"+o;return n&&wF.includes(o)&&!CF.includes(o)&&(!r||t&&t!==61&&kF.test(String.fromCharCode(t)))?d:d+";"}return""}function EF(e,t,n){let r=vF(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=jF(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const o=SF(e,t,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function _l(e,t){return gF(e,Object.assign({format:EF},t))}const NF=/^>|^->|<!--|-->|--!>|<!-$/g,TF=[">"],AF=["<",">"];function LF(e,t,n,r){return r.settings.bogusComments?"<?"+_l(e.value,Object.assign({},r.settings.characterReferences,{subset:TF}))+">":"<!--"+e.value.replace(NF,a)+"-->";function a(o){return _l(o,Object.assign({},r.settings.characterReferences,{subset:AF}))}}function RF(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function qC(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function DF(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function OF(e){return e.join(" ").trim()}const MF=/[ \t\n\f\r]/g;function hv(e){return typeof e=="object"?e.type==="text"?KC(e.value):!1:KC(e)}function KC(e){return e.replace(MF,"")===""}const zn=G2(1),W2=G2(-1),IF=[];function G2(e){return t;function t(n,r,a){const o=n?n.children:IF;let d=(r||0)+e,u=o[d];if(!a)for(;u&&hv(u);)d+=e,u=o[d];return u}}const PF={}.hasOwnProperty;function q2(e){return t;function t(n,r,a){return PF.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const fv=q2({body:$F,caption:wx,colgroup:wx,dd:UF,dt:HF,head:wx,html:BF,li:zF,optgroup:VF,option:WF,p:FF,rp:YC,rt:YC,tbody:qF,td:XC,tfoot:KF,th:XC,thead:GF,tr:YF});function wx(e,t,n){const r=zn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&hv(r.value.charAt(0)))}function BF(e,t,n){const r=zn(n,t);return!r||r.type!=="comment"}function $F(e,t,n){const r=zn(n,t);return!r||r.type!=="comment"}function FF(e,t,n){const r=zn(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 zF(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function HF(e,t,n){const r=zn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function UF(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function YC(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function VF(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function WF(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function GF(e,t,n){const r=zn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function qF(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function KF(e,t,n){return!zn(n,t)}function YF(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function XC(e,t,n){const r=zn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const XF=q2({body:ZF,colgroup:ez,head:JF,html:QF,tbody:tz});function QF(e){const t=zn(e,-1);return!t||t.type!=="comment"}function JF(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 ZF(e){const t=zn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&hv(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function ez(e,t,n){const r=W2(n,t),a=zn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&fv(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function tz(e,t,n){const r=W2(n,t),a=zn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&fv(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const gh={name:[[`
98
+ \f\r &/=>`.split(""),`
99
+ \f\r "&'/=>\``.split("")],[`\0
100
+ \f\r "&'/<=>`.split(""),`\0
101
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
102
+ \f\r &>`.split(""),`\0
103
+ \f\r "&'<=>\``.split("")],[`\0
104
+ \f\r "&'<=>\``.split(""),`\0
105
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function nz(e,t,n,r){const a=r.schema,o=a.space==="svg"?!1:r.settings.omitOptionalTags;let d=a.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const u=[];let c;a.space==="html"&&e.tagName==="svg"&&(r.schema=U2);const h=rz(r,e.properties),m=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,m&&(d=!1),(h||!o||!XF(e,t,n))&&(u.push("<",e.tagName,h?" "+h:""),d&&(a.space==="svg"||r.settings.closeSelfClosing)&&(c=h.charAt(h.length-1),(!r.settings.tightSelfClosing||c==="/"||c&&c!=='"'&&c!=="'")&&u.push(" "),u.push("/")),u.push(">")),u.push(m),!d&&(!o||!fv(e,t,n))&&u.push("</"+e.tagName+">"),u.join("")}function rz(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const o=sz(e,a,t[a]);o&&n.push(o)}}for(;++r<n.length;){const o=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function sz(e,t,n){const r=oF(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=e.settings.allowDangerousCharacters?0:1;let d=e.quote,u;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 c=_l(r.attribute,Object.assign({},e.settings.characterReferences,{subset:gh.name[a][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?DF:OF)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?c:(e.settings.preferUnquoted&&(u=_l(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:gh.unquoted[a][o]}))),u!==n&&(e.settings.quoteSmart&&qC(n,d)>qC(n,e.alternative)&&(d=e.alternative),u=d+_l(n,Object.assign({},e.settings.characterReferences,{subset:(d==="'"?gh.single:gh.double)[a][o],attribute:!0}))+d),c+(u&&"="+u))}const iz=["<","&"];function K2(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:_l(e.value,Object.assign({},r.settings.characterReferences,{subset:iz}))}function az(e,t,n,r){return r.settings.allowDangerousHtml?e.value:K2(e,t,n,r)}function oz(e,t,n,r){return r.all(e)}const lz=dF("type",{invalid:cz,unknown:uz,handlers:{comment:LF,doctype:RF,element:nz,raw:az,root:oz,text:K2}});function cz(e){throw new Error("Expected node, not `"+e+"`")}function uz(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const dz={},hz={},fz=[];function mz(e,t){const n=t||dz,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:pz,all:gz,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||tF,characterReferences:n.characterReferences||hz,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?U2:uF,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function pz(e,t,n){return lz(e,t,n,this)}function gz(e){const t=[],n=e&&e.children||fz;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const QC=/\s+/g;function Y2(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(QC)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(QC);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const xz=/:?lang=["']([^"']+)["']/g,yz=/(?:```|~~~)([\w-]+)/g,bz=/\\begin\{([\w-]+)\}/g,vz=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function _z(e){const t=hm(e,!0).map(([a])=>a);function n(a){if(a===e.length)return{line:t.length-1,character:t.at(-1).length};let o=a,d=0;for(const u of t){if(o<u.length)break;o-=u.length,d++}return{line:d,character:o}}function r(a,o){let d=0;for(let u=0;u<a;u++)d+=t[u].length;return d+=o,d}return{lines:t,indexToPos:n,posToIndex:r}}function Sz(e,t,n){const r=new Set;for(const o of e.matchAll(xz)){const d=o[1].toLowerCase().trim();d&&r.add(d)}for(const o of e.matchAll(yz)){const d=o[1].toLowerCase().trim();d&&r.add(d)}for(const o of e.matchAll(bz)){const d=o[1].toLowerCase().trim();d&&r.add(d)}for(const o of e.matchAll(vz)){const d=o[1].toLowerCase().trim(),u=d.includes("/")?d.split("/").pop():d;u&&r.add(u)}if(!n)return[...r];const a=n.getBundledLanguages();return[...r].filter(o=>o&&a[o])}const wz=["color","background-color"];function Cz(e,t){let n=0;const r=[];for(const a of t)a>n&&r.push({...e,content:e.content.slice(n,a),offset:e.offset+n}),n=a;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function kz(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,a)=>r-a);return n.length?e.map(r=>r.flatMap(a=>{const o=n.filter(d=>a.offset<d&&d<a.offset+a.content.length).map(d=>d-a.offset).sort((d,u)=>d-u);return o.length?Cz(a,o):a})):e}function jz(e,t,n,r,a="css-vars"){const o={content:e.content,explanation:e.explanation,offset:e.offset},d=t.map(m=>mf(e.variants[m])),u=new Set(d.flatMap(m=>Object.keys(m))),c={},h=(m,f)=>{const g=f==="color"?"":f==="background-color"?"-bg":`-${f}`;return n+t[m]+(f==="color"?"":g)};return d.forEach((m,f)=>{for(const g of u){const x=m[g]||"inherit";if(f===0&&r&&wz.includes(g))if(r==="light-dark()"&&d.length>1){const w=t.findIndex(v=>v==="light"),C=t.findIndex(v=>v==="dark");if(w===-1||C===-1)throw new un('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');c[g]=`light-dark(${d[w][g]||"inherit"}, ${d[C][g]||"inherit"})`,a==="css-vars"&&(c[h(f,g)]=x)}else c[g]=x;else a==="css-vars"&&(c[h(f,g)]=x)}}),o.htmlStyle=c,o}function mf(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&sr.Italic&&(t["font-style"]="italic"),e.fontStyle&sr.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&sr.Underline&&n.push("underline"),e.fontStyle&sr.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function $y(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function Ez(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let o=function(u){if(typeof u=="number"){if(u<0||u>n.source.length)throw new un(`Invalid decoration offset: ${u}. Code length: ${n.source.length}`);return{...a.indexToPos(u),offset:u}}else{const c=a.lines[u.line];if(c===void 0)throw new un(`Invalid decoration position ${JSON.stringify(u)}. Lines length: ${a.lines.length}`);let h=u.character;if(h<0&&(h=c.length+h),h<0||h>c.length)throw new un(`Invalid decoration position ${JSON.stringify(u)}. Line ${u.line} length: ${c.length}`);return{...u,character:h,offset:a.posToIndex(u.line,h)}}};var r=o;const a=_z(n.source),d=(n.options.decorations||[]).map(u=>({...u,start:o(u.start),end:o(u.end)}));Nz(d),e.set(n.meta,{decorations:d,converter:a,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){var r;if((r=this.options.decorations)!=null&&r.length)return kz(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var m;if(!((m=this.options.decorations)!=null&&m.length))return;const r=t(this),a=[...n.children].filter(f=>f.type==="element"&&f.tagName==="span");if(a.length!==r.converter.lines.length)throw new un(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(f,g,x,w){const C=a[f];let v="",S=-1,_=-1;if(g===0&&(S=0),x===0&&(_=0),x===Number.POSITIVE_INFINITY&&(_=C.children.length),S===-1||_===-1)for(let j=0;j<C.children.length;j++)v+=X2(C.children[j]),S===-1&&v.length===g&&(S=j+1),_===-1&&v.length===x&&(_=j+1);if(S===-1)throw new un(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(_===-1)throw new un(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const b=C.children.slice(S,_);if(!w.alwaysWrap&&b.length===C.children.length)u(C,w,"line");else if(!w.alwaysWrap&&b.length===1&&b[0].type==="element")u(b[0],w,"token");else{const j={type:"element",tagName:"span",properties:{},children:b};u(j,w,"wrapper"),C.children.splice(S,b.length,j)}}function d(f,g){a[f]=u(a[f],g,"line")}function u(f,g,x){var v;const w=g.properties||{},C=g.transform||(S=>S);return f.tagName=g.tagName||"span",f.properties={...f.properties,...w,class:f.properties.class},(v=g.properties)!=null&&v.class&&Y2(f,g.properties.class),f=C(f,x)||f,f}const c=[],h=r.decorations.sort((f,g)=>g.start.offset-f.start.offset||f.end.offset-g.end.offset);for(const f of h){const{start:g,end:x}=f;if(g.line===x.line)o(g.line,g.character,x.character,f);else if(g.line<x.line){o(g.line,g.character,Number.POSITIVE_INFINITY,f);for(let w=g.line+1;w<x.line;w++)c.unshift(()=>d(w,f));o(x.line,0,x.character,f)}}c.forEach(f=>f())}}}function Nz(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new un(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const a=e[r],o=n.start.offset<=a.start.offset&&a.start.offset<n.end.offset,d=n.start.offset<a.end.offset&&a.end.offset<=n.end.offset,u=a.start.offset<=n.start.offset&&n.start.offset<a.end.offset,c=a.start.offset<n.end.offset&&n.end.offset<=a.end.offset;if(o||d||u||c){if(o&&d||u&&c||u&&n.start.offset===n.end.offset||d&&a.start.offset===a.end.offset)continue;throw new un(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function X2(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(X2).join(""):""}const Tz=[Ez()];function pf(e){const t=Az(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Tz]}function Az(e){const t=[],n=[],r=[];for(const a of e)switch(a.enforce){case"pre":t.push(a);break;case"post":n.push(a);break;default:r.push(a)}return{pre:t,post:n,normal:r}}var qa=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Cx={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Lz(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 JC(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 Rz(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)Cx[r]&&t.push({type:"setDecoration",value:Cx[r]});else if(r<=29){const a=Cx[r-20];a&&(t.push({type:"resetDecoration",value:a}),a==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:qa[r-30]}});else if(r===38){const a=JC(e);a&&t.push({type:"setForegroundColor",value:a})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:qa[r-40]}});else if(r===48){const a=JC(e);a&&t.push({type:"setBackgroundColor",value:a})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:qa[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:qa[r-100+8]}})}return t}function Dz(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let o=0;do{const d=Lz(r,o),u=d.sequence?r.substring(o,d.startPosition):r.substring(o);if(u.length>0&&a.push({value:u,foreground:e,background:t,decorations:new Set(n)}),d.sequence){const c=Rz(d.sequence);for(const h of c)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 c)h.type==="setForegroundColor"?e=h.value:h.type==="setBackgroundColor"?t=h.value:h.type==="setDecoration"&&n.add(h.value)}o=d.position}while(o<r.length);return a}}}var Oz={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 Mz(e=Oz){function t(u){return e[u]}function n(u){return`#${u.map(c=>Math.max(0,Math.min(c,255)).toString(16).padStart(2,"0")).join("")}`}let r;function a(){if(r)return r;r=[];for(let h=0;h<qa.length;h++)r.push(t(qa[h]));let u=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let m=0;m<6;m++)for(let f=0;f<6;f++)r.push(n([u[h],u[m],u[f]]));let c=8;for(let h=0;h<24;h++,c+=10)r.push(n([c,c,c]));return r}function o(u){return a()[u]}function d(u){switch(u.type){case"named":return t(u.name);case"rgb":return n(u.rgb);case"table":return o(u.index)}}return{value:d}}const Iz=/#([0-9a-f]{3,8})/i,Pz=/var\((--[\w-]+-ansi-[\w-]+)\)/,Bz={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 $z(e,t,n){const r=ff(e,n),a=hm(t),o=Mz(Object.fromEntries(qa.map(u=>{var h;const c=`terminal.ansi${u[0].toUpperCase()}${u.substring(1)}`;return[u,((h=e.colors)==null?void 0:h[c])||Bz[u]]}))),d=Dz();return a.map(u=>d.parse(u[0]).map(c=>{let h,m;c.decorations.has("reverse")?(h=c.background?o.value(c.background):e.bg,m=c.foreground?o.value(c.foreground):e.fg):(h=c.foreground?o.value(c.foreground):e.fg,m=c.background?o.value(c.background):void 0),h=ua(h,r),m=ua(m,r),c.decorations.has("dim")&&(h=Fz(h));let f=sr.None;return c.decorations.has("bold")&&(f|=sr.Bold),c.decorations.has("italic")&&(f|=sr.Italic),c.decorations.has("underline")&&(f|=sr.Underline),c.decorations.has("strikethrough")&&(f|=sr.Strikethrough),{content:c.value,offset:u[1],color:h,bgColor:m,fontStyle:f}}))}function Fz(e){const t=e.match(Iz);if(t){const r=t[1];if(r.length===8){const a=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${a}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const a=r[0],o=r[1],d=r[2],u=r[3];return`#${a}${a}${o}${o}${d}${d}${Math.round(Number.parseInt(`${u}${u}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],o=r[1],d=r[2];return`#${a}${a}${o}${o}${d}${d}80`}}}const n=e.match(Pz);return n?`var(${n[1]}-dim)`:e}function Fy(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!um(r)&&!dm(a)&&r==="ansi"){const{theme:o}=e.setTheme(a);return $z(o,t,n)}return O2(e,t,n)}function gf(e,t,n){let r,a,o,d,u,c;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:m="--shiki-",colorsRendering:f="css-vars"}=n,g=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,_)=>S.color===h?-1:_.color===h?1:0);if(g.length===0)throw new un("`themes` option must not be empty");const x=M2(e,t,n,Fy);if(c=Cu(x),h&&h!=="light-dark()"&&!g.some(S=>S.color===h))throw new un(`\`themes\` option must contain the defaultColor key \`${h}\``);const w=g.map(S=>e.getTheme(S.theme)),C=g.map(S=>S.color);o=x.map(S=>S.map(_=>jz(_,C,m,h,f))),c&&fm(o,c);const v=g.map(S=>ff(S.theme,n));a=ZC(g,w,v,m,h,"fg",f),r=ZC(g,w,v,m,h,"bg",f),d=`shiki-themes ${w.map(S=>S.name).join(" ")}`,u=h?void 0:[a,r].join(";")}else if("theme"in n){const h=ff(n.theme,n);o=Fy(e,t,n);const m=e.getTheme(n.theme);r=ua(m.bg,h),a=ua(m.fg,h),d=m.name,c=Cu(o)}else throw new un("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:a,bg:r,themeName:d,rootStyle:u,grammarState:c}}function ZC(e,t,n,r,a,o,d){return e.map((u,c)=>{const h=ua(t[c][o],n[c])||"inherit",m=`${r+u.color}${o==="bg"?"-bg":""}:${h}`;if(c===0&&a){if(a==="light-dark()"&&e.length>1){const f=e.findIndex(x=>x.color==="light"),g=e.findIndex(x=>x.color==="dark");if(f===-1||g===-1)throw new un('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${ua(t[f][o],n[f])||"inherit"}, ${ua(t[g][o],n[g])||"inherit"});${m}`}return h}return d==="css-vars"?m:null}).filter(u=>!!u).join(";")}const Q2=/^\s+$/,zz=/^(\s*)(.*?)(\s*)$/;function xf(e,t,n,r={meta:{},options:n,codeToHast:(a,o)=>xf(e,a,o),codeToTokens:(a,o)=>gf(e,a,o)}){var w,C;let a=t;for(const v of pf(n))a=((w=v.preprocess)==null?void 0:w.call(r,a,n))||a;let{tokens:o,fg:d,bg:u,themeName:c,rootStyle:h,grammarState:m}=gf(e,a,n);const{mergeWhitespaces:f=!0,mergeSameStyleTokens:g=!1}=n;f===!0?o=Uz(o):f==="never"&&(o=Vz(o)),g&&(o=Wz(o));const x={...r,get source(){return a}};for(const v of pf(n))o=((C=v.tokens)==null?void 0:C.call(x,o))||o;return Hz(o,{...n,fg:d,bg:u,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},x,m)}function Hz(e,t,n,r=Cu(e)){var C,v,S,_;const a=pf(t),o=[],d={type:"root",children:[]},{structure:u="classic",tabindex:c="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}`),c!==!1&&c!=null&&(h.tabindex=c.toString());for(const[b,j]of Object.entries(t.meta||{}))b.startsWith("_")||(h[b]=j);let m={type:"element",tagName:"pre",properties:h,children:[],data:t.data},f={type:"element",tagName:"code",properties:{},children:o};const g=[],x={...n,structure:u,addClassToHast:Y2,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return d},get pre(){return m},get code(){return f},get lines(){return g}};if(e.forEach((b,j)=>{var L,A;j&&(u==="inline"?d.children.push({type:"element",tagName:"br",properties:{},children:[]}):u==="classic"&&o.push({type:"text",value:`
106
+ `}));let E={type:"element",tagName:"span",properties:{class:"line"},children:[]},N=0;for(const D of b){let O={type:"element",tagName:"span",properties:{...D.htmlAttrs},children:[{type:"text",value:D.content}]};const F=$y(D.htmlStyle||mf(D));F&&(O.properties.style=F);for(const P of a)O=((L=P==null?void 0:P.span)==null?void 0:L.call(x,O,j+1,N,E,D))||O;u==="inline"?d.children.push(O):u==="classic"&&E.children.push(O),N+=D.content.length}if(u==="classic"){for(const D of a)E=((A=D==null?void 0:D.line)==null?void 0:A.call(x,E,j+1))||E;g.push(E),o.push(E)}else u==="inline"&&g.push(E)}),u==="classic"){for(const b of a)f=((C=b==null?void 0:b.code)==null?void 0:C.call(x,f))||f;m.children.push(f);for(const b of a)m=((v=b==null?void 0:b.pre)==null?void 0:v.call(x,m))||m;d.children.push(m)}else if(u==="inline"){const b=[];let j={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const N of d.children)N.type==="element"&&N.tagName==="br"?(b.push(j),j={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(N.type==="element"||N.type==="text")&&j.children.push(N);b.push(j);let E={type:"element",tagName:"code",properties:{},children:b};for(const N of a)E=((S=N==null?void 0:N.code)==null?void 0:S.call(x,E))||E;d.children=[];for(let N=0;N<E.children.length;N++){N>0&&d.children.push({type:"element",tagName:"br",properties:{},children:[]});const L=E.children[N];L.type==="element"&&d.children.push(...L.children)}}let w=d;for(const b of a)w=((_=b==null?void 0:b.root)==null?void 0:_.call(x,w))||w;return r&&fm(w,r),w}function Uz(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((o,d)=>{const u=!(o.fontStyle&&(o.fontStyle&sr.Underline||o.fontStyle&sr.Strikethrough));u&&Q2.test(o.content)&&t[d+1]?(a===void 0&&(a=o.offset),r+=o.content):r?(u?n.push({...o,offset:a,content:r+o.content}):n.push({content:r,offset:a},o),a=void 0,r=""):n.push(o)}),n})}function Vz(e){return e.map(t=>t.flatMap(n=>{if(Q2.test(n.content))return n;const r=n.content.match(zz);if(!r)return n;const[,a,o,d]=r;if(!a&&!d)return n;const u=[{...n,offset:n.offset+a.length,content:o}];return a&&u.unshift({content:a,offset:n.offset}),d&&u.push({content:d,offset:n.offset+a.length+o.length}),u}))}function Wz(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const a=n.at(-1),o=$y(a.htmlStyle||mf(a)),d=$y(r.htmlStyle||mf(r)),u=a.fontStyle&&(a.fontStyle&sr.Underline||a.fontStyle&sr.Strikethrough),c=r.fontStyle&&(r.fontStyle&sr.Underline||r.fontStyle&sr.Strikethrough);!u&&!c&&o===d?a.content+=r.content:n.push({...r})}return n})}const Gz=mz;function qz(e,t,n){var o;const r={meta:{},options:n,codeToHast:(d,u)=>xf(e,d,u),codeToTokens:(d,u)=>gf(e,d,u)};let a=Gz(xf(e,t,n,r));for(const d of pf(n))a=((o=d.postprocess)==null?void 0:o.call(r,a,n))||a;return a}async function Kz(e){const t=await U$(e);return{getLastGrammarState:(...n)=>K$(t,...n),codeToTokensBase:(n,r)=>Fy(t,n,r),codeToTokensWithThemes:(n,r)=>M2(t,n,r),codeToTokens:(n,r)=>gf(t,n,r),codeToHast:(n,r)=>xf(t,n,r),codeToHtml:(n,r)=>qz(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Yz(e){const t=e.langs,n=e.themes,r=e.engine;async function a(o){function d(f){var g;if(typeof f=="string"){if(f=((g=o.langAlias)==null?void 0:g[f])||f,E2(f))return[];const x=t[f];if(!x)throw new un(`Language \`${f}\` is not included in this bundle. You may want to load it from external source.`);return x}return f}function u(f){if(N2(f))return"none";if(typeof f=="string"){const g=n[f];if(!g)throw new un(`Theme \`${f}\` is not included in this bundle. You may want to load it from external source.`);return g}return f}const c=(o.themes??[]).map(f=>u(f)),h=(o.langs??[]).map(f=>d(f)),m=await Kz({engine:o.engine??r(),...o,themes:c,langs:h});return{...m,loadLanguage(...f){return m.loadLanguage(...f.map(d))},loadTheme(...f){return m.loadTheme(...f.map(u))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function Xz(e){let t;async function n(r={}){if(t){const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}else{t=e({...r,themes:[],langs:[]});const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}}return n}function Qz(e,t){const n=Xz(e);async function r(a,o){var c;const d=await n({langs:[o.lang],themes:"theme"in o?[o.theme]:Object.values(o.themes)}),u=await((c=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:c.call(t,a,o.lang,d));return u&&await d.loadLanguage(...u),d}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,o){return(await r(a,o)).codeToHtml(a,o)},async codeToHast(a,o){return(await r(a,o)).codeToHast(a,o)},async codeToTokens(a,o){return(await r(a,o)).codeToTokens(a,o)},async codeToTokensBase(a,o){return(await r(a,o)).codeToTokensBase(a,o)},async codeToTokensWithThemes(a,o){return(await r(a,o)).codeToTokensWithThemes(a,o)},async getLastGrammarState(a,o){return(await n({langs:[o.lang],themes:[o.theme]})).getLastGrammarState(a,o)}}}var Jz=tv({bundledLanguages:()=>om,bundledLanguagesAlias:()=>rv,bundledLanguagesBase:()=>nv,bundledLanguagesInfo:()=>am,bundledThemes:()=>iv,bundledThemesInfo:()=>sv,codeToHast:()=>Z2,codeToHtml:()=>J2,codeToTokens:()=>eT,codeToTokensBase:()=>tT,codeToTokensWithThemes:()=>nT,createHighlighter:()=>pm,getLastGrammarState:()=>sT,getSingletonHighlighter:()=>rT});const pm=Yz({langs:om,themes:iv,engine:()=>(0,u2.createOnigurumaEngine)(ae(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:J2,codeToHast:Z2,codeToTokens:eT,codeToTokensBase:tT,codeToTokensWithThemes:nT,getSingletonHighlighter:rT,getLastGrammarState:sT}=Qz(pm,{guessEmbeddedLanguages:Sz}),ek=4294967295;var Zz=class{constructor(e,t={}){Te(this,"patterns");Te(this,"options");Te(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:a}=t;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(o=>{if(typeof o!="string")return o;const d=r==null?void 0:r.get(o);if(d){if(d instanceof RegExp)return d;if(n)return null;throw d}try{const u=a(o);return r==null||r.set(o,u),u}catch(u){if(r==null||r.set(o,u),n)return null;throw u}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function o(d,u,c=0){return{index:d,captureIndices:u.indices.map(h=>h==null?{start:ek,end:ek,length:0}:{start:h[0]+c,end:h[1]+c,length:h[1]-h[0]})}}for(let d=0;d<this.regexps.length;d++){const u=this.regexps[d];if(u)try{u.lastIndex=t;const c=u.exec(r);if(!c)continue;if(c.index===t)return o(d,c,0);a.push([d,c,0])}catch(c){if(this.options.forgiving)continue;throw c}}if(a.length){const d=Math.min(...a.map(u=>u[1].index));for(const[u,c,h]of a)if(c.index===d)return o(u,c,h)}return null}};function zl(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function eH(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const mv=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),qn=String.raw;function Hl(e,t){if(e==null)throw new Error(t??"Value expected");return e}const iT=qn`\[\^?`,aT=`c.? | C(?:-.?)?|${qn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${qn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${qn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${qn`o\{[^\}]*\}?`}|${qn`\d{1,3}`}`,pv=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,xh=new RegExp(qn`
107
+ \\ (?:
108
+ ${aT}
109
+ | [gk]<[^>]*>?
110
+ | [gk]'[^']*'?
111
+ | .
112
+ )
113
+ | \( (?:
114
+ \? (?:
115
+ [:=!>({]
116
+ | <[=!]
117
+ | <[^>]*>
118
+ | '[^']*'
119
+ | ~\|?
120
+ | #(?:[^)\\]|\\.?)*
121
+ | [^:)]*[:)]
122
+ )?
123
+ | \*[^\)]*\)?
124
+ )?
125
+ | (?:${pv.source})+
126
+ | ${iT}
127
+ | .
128
+ `.replace(/\s+/g,""),"gsu"),kx=new RegExp(qn`
129
+ \\ (?:
130
+ ${aT}
131
+ | .
132
+ )
133
+ | \[:(?:\^?\p{Alpha}+|\^):\]
134
+ | ${iT}
135
+ | &&
136
+ | .
137
+ `.replace(/\s+/g,""),"gsu");function tH(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=vH(n.flags),a=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(f){a.push(f)},replaceCurrentModX(f){a[a.length-1]=f},singleline:n.rules.singleline};let d=[],u;for(xh.lastIndex=0;u=xh.exec(e);){const f=nH(o,e,u[0],xh.lastIndex);f.tokens?d.push(...f.tokens):f.token&&d.push(f.token),f.lastIndex!==void 0&&(xh.lastIndex=f.lastIndex)}const c=[];let h=0;d.filter(f=>f.type==="GroupOpen").forEach(f=>{f.kind==="capturing"?f.number=++h:f.raw==="("&&c.push(f)}),h||c.forEach((f,g)=>{f.kind="capturing",f.number=g+1});const m=h||c.length;return{tokens:d.map(f=>f.type==="EscapedNumber"?SH(f,m):f).flat(),flags:r}}function nH(e,t,n,r){const[a,o]=n;if(n==="["||n==="[^"){const d=rH(t,n,r);return{tokens:d.tokens,lastIndex:d.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(o))return{token:tk(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:fH(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:lT(n)}}if(o==="K")return{token:cT("keep",n)};if(o==="N"||o==="R")return{token:Ka("newline",n,{negate:o==="N"})};if(o==="O")return{token:Ka("any",n)};if(o==="X")return{token:Ka("text_segment",n)};const d=oT(n,{inCharClass:!1});return Array.isArray(d)?{tokens:d}:{token:d}}if(a==="("){if(o==="*")return{token:xH(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:gH(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:ul("group",n)};if(n==="(?>")return{token:ul("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:ul(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:ul("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:ul("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:uH(n)}}if(e.getCurrentModX()){if(n==="#"){const d=t.indexOf(`
138
+ `,r);return{lastIndex:d===-1?t.length:d}}if(/^\s$/.test(n)){const d=/\s+/y;return d.lastIndex=r,{lastIndex:d.exec(t)?d.lastIndex:r}}}if(n===".")return{token:Ka("dot",n)};if(n==="^"||n==="$"){const d=e.singleline?{"^":qn`\A`,$:qn`\Z`}[n]:n;return{token:tk(d,n)}}return n==="|"?{token:iH(n)}:pv.test(n)?{tokens:wH(n)}:{token:_i(zl(n),n)}}function rH(e,t,n){const r=[nk(t[1]==="^",t)];let a=1,o;for(kx.lastIndex=n;o=kx.exec(e);){const d=o[0];if(d[0]==="["&&d[1]!==":")a++,r.push(nk(d[1]==="^",d));else if(d==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(_i(93,d));else if(a--,r.push(aH(d)),!a)break}else{const u=sH(d);Array.isArray(u)?r.push(...u):r.push(u)}}return{tokens:r,lastIndex:kx.lastIndex||e.length}}function sH(e){if(e[0]==="\\")return oT(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!mv.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Ka("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?oH(e):e==="&&"?lH(e):_i(zl(e),e)}function oT(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return pH(e);if("dDhHsSwW".includes(n))return yH(e);if(e.startsWith(qn`\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 bH(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(d=>parseInt(d,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...a].map(d=>{const u=[...o.encode(d)].map(c=>`\\x${c.toString(16)}`).join("");return _i(zl(d),u)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return _i(_H(e),e);if(rk.has(n))return _i(rk.get(n),e);if(/\d/.test(n))return cH(t,e);if(e==="\\")throw new Error(qn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return _i(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function iH(e){return{type:"Alternator",raw:e}}function tk(e,t){return{type:"Assertion",kind:e,raw:t}}function lT(e){return{type:"Backreference",raw:e}}function _i(e,t){return{type:"Character",value:e,raw:t}}function aH(e){return{type:"CharacterClassClose",raw:e}}function oH(e){return{type:"CharacterClassHyphen",raw:e}}function lH(e){return{type:"CharacterClassIntersector",raw:e}}function nk(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Ka(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function cT(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Hl(n.flags),raw:t}}function cH(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function uH(e){return{type:"GroupClose",raw:e}}function ul(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function dH(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function hH(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function fH(e){return{type:"Subroutine",raw:e}}const mH=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),rk=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function pH(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 _i(zl(t.toUpperCase())-64,e)}function gH(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const a=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),o=ik(n),d=ik(r),u={};if(o&&(u.enable=o),d&&(u.disable=d),e.endsWith(")"))return t.replaceCurrentModX(a),cT("flags",e,{flags:u});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,ul("group",e,{...(o||d)&&{flags:u}});throw new Error(`Unexpected flag modifier "${e}"`)}function xH(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:a}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const o=a?a.split(",").filter(m=>m!=="").map(m=>/^[+-]?\d+$/.test(m)?+m:m):[],[d,u,c]=o,h=mH.has(n)?n.toLowerCase():"custom";switch(h){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof d=="string")throw new Error(`Named callout argument must be a number "${d}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof d=="string"&&!/^[A-Za-z_]\w*$/.test(d))throw new Error(`Named callout argument one must be a tag or number "${d}"`);if(o.length===2&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${u}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof d=="number"||!/^[<>X]$/.test(d)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${d}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof d=="string"&&!/^[A-Za-z_]\w*$/.test(d))throw new Error(`Named callout argument one must be a tag or number "${d}"`);if(typeof u=="number"||!/^(?:[<>!=]=|[<>])$/.test(u))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${u}"`);if(typeof c=="string"&&!/^[A-Za-z_]\w*$/.test(c))throw new Error(`Named callout argument three must be a tag or number "${c}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${h}"`)}return dH(h,r??null,(a==null?void 0:a.split(","))??null,e)}function sk(e){let t=null,n,r;if(e[0]==="{"){const{minStr:a,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,d=1e5;if(+a>d||o&&+o>d)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+a,r=o===void 0?+a:o===""?1/0:+o,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 hH(t,n,r,e)}function yH(e){const t=e[1].toLowerCase();return Ka({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function bH(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Ka("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function ik(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 vH(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 _H(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 SH(e,t){const{raw:n,inCharClass:r}=e,a=n.slice(1);if(!r&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[lT(n)];const o=[],d=a.match(/^[0-7]+|\d/g);for(let u=0;u<d.length;u++){const c=d[u];let h;if(u===0&&c!=="8"&&c!=="9"){if(h=parseInt(c,8),h>127)throw new Error(qn`Octal encoded byte above 177 unsupported "${n}"`)}else h=zl(c);o.push(_i(h,(u===0?"\\":"")+c))}return o}function wH(e){const t=[],n=new RegExp(pv,"gy");let r;for(;r=n.exec(e);){const a=r[0];if(a[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(o){const{min:d,max:u}=o.groups;if(+d>+u&&a.endsWith("?")){n.lastIndex--,t.push(sk(a.slice(0,-1)));continue}}}t.push(sk(a))}return t}function uT(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 CH(e){return kH.has(e.type)}const kH=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function dT(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=tH(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(g,x)=>{const w=r.tokens[o.nextIndex];switch(o.parent=g,o.nextIndex++,w.type){case"Alternator":return oo();case"Assertion":return jH(w);case"Backreference":return EH(w,o);case"Character":return gm(w.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return NH(w,o,x);case"CharacterClassOpen":return TH(w,o,x);case"CharacterSet":return AH(w,o);case"Directive":return IH(w.kind,{flags:w.flags});case"GroupOpen":return LH(w,o,x);case"NamedCallout":return BH(w.kind,w.tag,w.arguments);case"Quantifier":return RH(w,o);case"Subroutine":return DH(w,o);default:throw new Error(`Unexpected token type "${w.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},d=FH(PH(r.flags));let u=d.body[0];for(;o.nextIndex<r.tokens.length;){const g=a(u,{});g.type==="Alternative"?(d.body.push(g),u=g):u.body.push(g)}const{capturingGroups:c,hasNumberedRef:h,namedGroupsByName:m,subroutines:f}=o;if(h&&m.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:g}of f)if(typeof g=="number"){if(g>c.length)throw new Error("Subroutine uses a group number that's not defined");g&&(c[g-1].isSubroutined=!0)}else if(m.has(g)){if(m.get(g).length>1)throw new Error(qn`Subroutine uses a duplicate group name "\g<${g}>"`);m.get(g)[0].isSubroutined=!0}else throw new Error(qn`Subroutine uses a group name that's not defined "\g<${g}>"`);return d}function jH({kind:e}){return zy(Hl({"^":"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===qn`\B`||e===qn`\Y`})}function EH({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),a=(o,d=!1)=>{const u=t.capturingGroups.length;let c=!1;if(o>u)if(t.skipBackrefValidation)c=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Hy(d?u+1-o:o,{orphan:c})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return a(+o.groups.num,!!o.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 Hy(r)}return a(+r)}function NH(e,t,n){const{tokens:r,walk:a}=t,o=t.parent,d=o.body.at(-1),u=r[t.nextIndex];if(!n.isCheckingRangeEnd&&d&&d.type!=="CharacterClass"&&d.type!=="CharacterClassRange"&&u&&u.type!=="CharacterClassOpen"&&u.type!=="CharacterClassClose"&&u.type!=="CharacterClassIntersector"){const c=a(o,{...n,isCheckingRangeEnd:!0});if(d.type==="Character"&&c.type==="Character")return o.body.pop(),MH(d,c);throw new Error("Invalid character class range")}return gm(zl("-"))}function TH({negate:e},t,n){const{tokens:r,walk:a}=t,o=[Gh()],d=r[t.nextIndex];let u=lk(d);for(;u.type!=="CharacterClassClose";){if(u.type==="CharacterClassIntersector")o.push(Gh()),t.nextIndex++;else{const h=o.at(-1);h.body.push(a(h,n))}u=lk(r[t.nextIndex],d)}const c=Gh({negate:e});return o.length===1?c.body=o[0].body:(c.kind="intersection",c.body=o.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,c}function AH({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:d}=r;if(e==="property"){const u=xm(n);if(mv.has(u)&&!(d!=null&&d.has(u)))e="posix",n=u;else return dl(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:d})}return e==="posix"?$H(n,{negate:t}):Uy(e,{negate:t})}function LH(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:o,skipLookbehindValidation:d,walk:u}=t,c=zH(e),h=c.type==="AbsenceFunction",m=ok(c),f=m&&c.negate;if(c.type==="CapturingGroup"&&(a.push(c),c.name&&eH(o,c.name,[]).push(c)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let g=ck(r[t.nextIndex]);for(;g.type!=="GroupClose";){if(g.type==="Alternator")c.body.push(oo()),t.nextIndex++;else{const x=c.body.at(-1),w=u(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||m,isInNegLookbehind:n.isInNegLookbehind||f});if(x.body.push(w),(m||n.isInLookbehind)&&!d){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(ak(w)||w.type==="CapturingGroup")throw new Error(C)}else if(ak(w)||ok(w)&&w.negate)throw new Error(C)}}g=ck(r[t.nextIndex])}return t.nextIndex++,c}function RH({kind:e,min:t,max:n},r){const a=r.parent,o=a.body.at(-1);if(!o||!CH(o))throw new Error("Quantifier requires a repeatable token");const d=fT(e,t,n,o);return a.body.pop(),d}function DH({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let a=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(o){const u=+o.groups.num,c=n.length;if(t.hasNumberedRef=!0,a={"":u,"+":c+u,"-":c+1-u}[o.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const d=mT(a);return r.push(d),d}function OH(e,t){return{type:"AbsenceFunction",kind:e,body:Pu(t==null?void 0:t.body)}}function oo(e){return{type:"Alternative",body:pT(e==null?void 0:e.body)}}function zy(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function Hy(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function hT(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!HH(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:Pu(t==null?void 0:t.body)}}function gm(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 Gh(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:pT(e==null?void 0:e.body)}}function MH(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Uy(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 IH(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Hl(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function PH(e){return{type:"Flags",...e}}function ms(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:Pu(e==null?void 0:e.body)}}function Ga(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Pu(e==null?void 0:e.body)}}function BH(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function $H(e,t){const n=!!(t!=null&&t.negate);if(!mv.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function fT(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 FH(e,t){return{type:"Regex",body:Pu(t==null?void 0:t.body),flags:e}}function mT(e){return{type:"Subroutine",ref:e}}function dl(e,t){var a;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(a=n.unicodePropertyMap)==null?void 0:a.get(xm(e));if(!r){if(n.normalizeUnknownPropertyNames)r=UH(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(qn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function zH({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return OH("repeater");case"atomic":return ms({atomic:!0});case"capturing":return hT(a,{name:n});case"group":return ms({flags:e});case"lookahead":case"lookbehind":return Ga({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function Pu(e){if(e===void 0)e=[oo()];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 pT(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 ak(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function ok(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function HH(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function UH(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 xm(e){return e.replace(/[- _]+/g,"").toLowerCase()}function lk(e,t){const n=t;return Hl(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function ck(e){return Hl(e,"Unclosed group")}function ou(e,t,n=null){function r(o,d){for(let u=0;u<o.length;u++){const c=a(o[u],d,u,o);u=Math.max(-1,u+c)}}function a(o,d=null,u=null,c=null){var S,_;let h=0,m=!1;const f={node:o,parent:d,key:u,container:c,root:e,remove(){yh(c).splice(Math.max(0,Zo(u)+h),1),h--,m=!0},removeAllNextSiblings(){return yh(c).splice(Zo(u)+1)},removeAllPrevSiblings(){const b=Zo(u)+h;return h-=b,yh(c).splice(0,Math.max(0,b))},replaceWith(b,j={}){const E=!!j.traverse;c?c[Math.max(0,Zo(u)+h)]=b:Hl(d,"Can't replace root node")[u]=b,E&&a(b,d,u,c),m=!0},replaceWithMultiple(b,j={}){const E=!!j.traverse;if(yh(c).splice(Math.max(0,Zo(u)+h),1,...b),h+=b.length-1,E){let N=0;for(let L=0;L<b.length;L++)N+=a(b[L],d,Zo(u)+L+N,c)}m=!0},skip(){m=!0}},{type:g}=o,x=t["*"],w=t[g],C=typeof x=="function"?x:x==null?void 0:x.enter,v=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(f,n),v==null||v(f,n),!m)switch(g){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(o.min,o,"min"),a(o.max,o,"max");break;case"Quantifier":a(o.body,o,"body");break;case"Regex":r(o.body,o),a(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${g}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,f,n),(_=x==null?void 0:x.exit)==null||_.call(x,f,n),h}return a(e),e}function yh(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Zo(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const VH=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function WH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function GH(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const ss=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function gv(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let d=0,u="";for(const c of e.matchAll(a)){const{0:h,groups:{$skip:m}}=c;if(!m&&(!r||r===ss.DEFAULT==!d)){n instanceof Function?u+=n(c,{context:d?ss.CHAR_CLASS:ss.DEFAULT,negated:o[o.length-1]}):u+=n;continue}h[0]==="["?(d++,o.push(h[1]==="^")):h==="]"&&d&&(d--,o.pop()),u+=h}return u}function gT(e,t,n,r){gv(e,t,n,r)}function qH(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=n;let o=0,d;for(;d=a.exec(e);){const{0:u,groups:{$skip:c}}=d;if(!c&&(!r||r===ss.DEFAULT==!o))return d;u==="["?o++:u==="]"&&o&&o--,a.lastIndex==d.index&&a.lastIndex++}return null}function bh(e,t,n){return!!qH(e,t,0,n)}function KH(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,a=0,o=1,d;for(;d=n.exec(e);){const[u]=d;if(u==="[")a++;else if(a)u==="]"&&a--;else if(u==="(")o++;else if(u===")"&&(o--,!o)){r=d.index;break}}return e.slice(t,r)}const uk=new RegExp(String.raw`(?<noncapturingStart>${VH})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function YH(e,t){const n=(t==null?void 0:t.hiddenCaptures)??[];let r=(t==null?void 0:t.captureTransfers)??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const a="(?>",o="(?:(?=(",d=[0],u=[];let c=0,h=0,m=NaN,f;do{f=!1;let g=0,x=0,w=!1,C;for(uk.lastIndex=Number.isNaN(m)?0:m+o.length;C=uk.exec(e);){const{0:v,index:S,groups:{capturingStart:_,noncapturingStart:b}}=C;if(v==="[")g++;else if(g)v==="]"&&g--;else if(v===a&&!w)m=S,w=!0;else if(w&&b)x++;else if(_)w?x++:(c++,d.push(c+h));else if(v===")"&&w){if(!x){h++;const j=c+h;if(e=`${e.slice(0,m)}${o}${e.slice(m+a.length,S)}))<$$${j}>)${e.slice(S+1)}`,f=!0,u.push(j),WH(n,j),r.size){const E=new Map;r.forEach((N,L)=>{E.set(L>=j?L+1:L,N.map(A=>A>=j?A+1:A))}),r=E}break}x--}}}while(f);return n.push(...u),e=gv(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:g,groups:{backrefNum:x,wrappedBackrefNum:w}})=>{if(x){const C=+x;if(C>d.length-1)throw new Error(`Backref "${g}" greater than number of captures`);return`\\${d[C]}`}return`\\${w}`},ss.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const xT=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,jx=new RegExp(String.raw`
139
+ \\(?: \d+
140
+ | c[A-Za-z]
141
+ | [gk]<[^>]+>
142
+ | [pPu]\{[^\}]+\}
143
+ | u[A-Fa-f\d]{4}
144
+ | x[A-Fa-f\d]{2}
145
+ )
146
+ | \((?: \? (?: [:=!>]
147
+ | <(?:[=!]|[^>]+>)
148
+ | [A-Za-z\-]+:
149
+ | \(DEFINE\)
150
+ ))?
151
+ | (?<qBase>${xT})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
152
+ | \\?.
153
+ `.replace(/\s+/g,""),"gsu");function XH(e){if(!new RegExp(`${xT}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",o=0,d;for(jx.lastIndex=0;d=jx.exec(e);){const{0:u,index:c,groups:{qBase:h,qMod:m,invalidQ:f}}=d;if(u==="[")o||(r=c),o++;else if(u==="]")o?o--:r=null;else if(!o)if(m==="+"&&a&&!a.startsWith("(")){if(f)throw new Error(`Invalid quantifier "${u}"`);let g=-1;if(/^\{\d+\}$/.test(h))e=GH(e,c+h.length,m,"");else{if(a===")"||a==="]"){const x=a===")"?n:r;if(x===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,x)}(?>${e.slice(x,c)}${h})${e.slice(c+u.length)}`}else e=`${e.slice(0,c-a.length)}(?>${a}${h})${e.slice(c+u.length)}`;g+=4}jx.lastIndex+=g}else u[0]==="("?t.push(c):u===")"&&(n=t.length?t.pop():null);a=u}return{pattern:e}}const ns=String.raw,QH=ns`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Vy=ns`\(\?R=(?<rDepth>[^\)]+)\)|${QH}`,ym=ns`\(\?<(?![=!])(?<captureName>[^>]+)>`,yT=ns`${ym}|(?<unnamed>\()(?!\?)`,Ba=new RegExp(ns`${ym}|${Vy}|\(\?|\\?.`,"gsu"),Ex="Cannot use multiple overlapping recursions";function JH(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(Vy,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&bh(e,ns`\(\?\(DEFINE\)`,ss.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],d=bh(e,ns`\\[1-9]`,ss.DEFAULT),u=new Map,c=[];let h=!1,m=0,f=0,g;for(Ba.lastIndex=0;g=Ba.exec(e);){const{0:x,groups:{captureName:w,rDepth:C,gRNameOrNum:v,gRDepth:S}}=g;if(x==="[")m++;else if(m)x==="]"&&m--;else if(C){if(dk(C),h)throw new Error(Ex);if(d)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const _=e.slice(0,g.index),b=e.slice(Ba.lastIndex);if(bh(b,Vy,ss.DEFAULT))throw new Error(Ex);const j=+C-1;e=hk(_,b,j,!1,n,o,f),a=mk(a,_,j,o.length,0,f);break}else if(v){dk(S);let _=!1;for(const P of c)if(P.name===v||P.num===+v){if(_=!0,P.hasRecursedWithin)throw new Error(Ex);break}if(!_)throw new Error(ns`Recursive \g cannot be used outside the referenced group "${r==="external"?v:ns`\g<${v}&R=${S}>`}"`);const b=u.get(v),j=KH(e,b);if(d&&bh(j,ns`${ym}|\((?!\?)`,ss.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const E=e.slice(b,g.index),N=j.slice(E.length+x.length),L=o.length,A=+S-1,D=hk(E,N,A,!0,n,o,f);a=mk(a,E,A,o.length-L,L,f);const O=e.slice(0,b),F=e.slice(b+j.length);e=`${O}${D}${F}`,Ba.lastIndex+=D.length-x.length-E.length-N.length,c.forEach(P=>P.hasRecursedWithin=!0),h=!0}else if(w)f++,u.set(String(f),Ba.lastIndex),u.set(w,Ba.lastIndex),c.push({num:f,name:w});else if(x[0]==="("){const _=x==="(";_&&(f++,u.set(String(f),Ba.lastIndex)),c.push(_?{num:f}:{})}else x===")"&&c.pop()}return n.push(...o),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function dk(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 hk(e,t,n,r,a,o,d){const u=new Set;r&&gT(e+t,ym,({groups:{captureName:h}})=>{u.add(h)},ss.DEFAULT);const c=[n,r?u:null,a,o,d];return`${e}${fk(`(?:${e}`,"forward",...c)}(?:)${fk(`${t})`,"backward",...c)}${t}`}function fk(e,t,n,r,a,o,d){const c=m=>t==="forward"?m+2:n-m+2-1;let h="";for(let m=0;m<n;m++){const f=c(m);h+=gv(e,ns`${yT}|\\k<(?<backref>[^>]+)>`,({0:g,groups:{captureName:x,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return g;const v=`_$${f}`;if(w||x){const S=d+o.length+1;return o.push(S),ZH(a,S),w?g:`(?<${x}${v}>`}return ns`\k<${C}${v}>`},ss.DEFAULT)}return h}function ZH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function mk(e,t,n,r,a,o){if(e.size&&r){let d=0;gT(t,yT,()=>d++,ss.DEFAULT);const u=o-d+a,c=new Map;return e.forEach((h,m)=>{const f=(r-d*n)/n,g=d*n,x=m>u+d?m+r:m,w=[];for(const C of h)if(C<=u)w.push(C);else if(C>u+d+f)w.push(C+r);else if(C<=u+d)for(let v=0;v<=n;v++)w.push(C+d*v);else for(let v=0;v<=n;v++)w.push(C+g+f*v);c.set(x,w)}),c}return e}var $n=String.fromCodePoint,wt=String.raw,vs={},bm=globalThis.RegExp;vs.flagGroups=(()=>{try{new bm("(?i:)")}catch{return!1}return!0})();vs.unicodeSets=(()=>{try{new bm("[[]]","v")}catch{return!1}return!0})();vs.bugFlagVLiteralHyphenIsRange=vs.unicodeSets?(()=>{try{new bm(wt`[\d\-a]`,"v")}catch{return!0}return!1})():!1;vs.bugNestedClassIgnoresNegation=vs.unicodeSets&&new bm("[[^a]]","v").test("a");function yf(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 ku(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Wy(e,t){return pk[e]>=pk[t]}function e7(e,t){if(e==null)throw new Error(t??"Value expected");return e}var pk={ES2025:2025,ES2024:2024,ES2018:2018},t7={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function bT(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!t7[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=vs.flagGroups?"ES2025":vs.unicodeSets?"ES2024":"ES2018"),t}var n7="[ -\r ]",r7=new Set([$n(304),$n(305)]),ui=wt`[\p{L}\p{M}\p{N}\p{Pc}]`;function vT(e){if(r7.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=a7.get(n),o=s7.get(n),d=i7.get(n);return[...r].length===1&&t.add(r),d&&t.add(d),a&&t.add(a),t.add(n),o&&t.add(o),[...t]}var xv=new Map(`C Other
154
+ Cc Control cntrl
155
+ Cf Format
156
+ Cn Unassigned
157
+ Co Private_Use
158
+ Cs Surrogate
159
+ L Letter
160
+ LC Cased_Letter
161
+ Ll Lowercase_Letter
162
+ Lm Modifier_Letter
163
+ Lo Other_Letter
164
+ Lt Titlecase_Letter
165
+ Lu Uppercase_Letter
166
+ M Mark Combining_Mark
167
+ Mc Spacing_Mark
168
+ Me Enclosing_Mark
169
+ Mn Nonspacing_Mark
170
+ N Number
171
+ Nd Decimal_Number digit
172
+ Nl Letter_Number
173
+ No Other_Number
174
+ P Punctuation punct
175
+ Pc Connector_Punctuation
176
+ Pd Dash_Punctuation
177
+ Pe Close_Punctuation
178
+ Pf Final_Punctuation
179
+ Pi Initial_Punctuation
180
+ Po Other_Punctuation
181
+ Ps Open_Punctuation
182
+ S Symbol
183
+ Sc Currency_Symbol
184
+ Sk Modifier_Symbol
185
+ Sm Math_Symbol
186
+ So Other_Symbol
187
+ Z Separator
188
+ Zl Line_Separator
189
+ Zp Paragraph_Separator
190
+ Zs Space_Separator
191
+ ASCII
192
+ ASCII_Hex_Digit AHex
193
+ Alphabetic Alpha
194
+ Any
195
+ Assigned
196
+ Bidi_Control Bidi_C
197
+ Bidi_Mirrored Bidi_M
198
+ Case_Ignorable CI
199
+ Cased
200
+ Changes_When_Casefolded CWCF
201
+ Changes_When_Casemapped CWCM
202
+ Changes_When_Lowercased CWL
203
+ Changes_When_NFKC_Casefolded CWKCF
204
+ Changes_When_Titlecased CWT
205
+ Changes_When_Uppercased CWU
206
+ Dash
207
+ Default_Ignorable_Code_Point DI
208
+ Deprecated Dep
209
+ Diacritic Dia
210
+ Emoji
211
+ Emoji_Component EComp
212
+ Emoji_Modifier EMod
213
+ Emoji_Modifier_Base EBase
214
+ Emoji_Presentation EPres
215
+ Extended_Pictographic ExtPict
216
+ Extender Ext
217
+ Grapheme_Base Gr_Base
218
+ Grapheme_Extend Gr_Ext
219
+ Hex_Digit Hex
220
+ IDS_Binary_Operator IDSB
221
+ IDS_Trinary_Operator IDST
222
+ ID_Continue IDC
223
+ ID_Start IDS
224
+ Ideographic Ideo
225
+ Join_Control Join_C
226
+ Logical_Order_Exception LOE
227
+ Lowercase Lower
228
+ Math
229
+ Noncharacter_Code_Point NChar
230
+ Pattern_Syntax Pat_Syn
231
+ Pattern_White_Space Pat_WS
232
+ Quotation_Mark QMark
233
+ Radical
234
+ Regional_Indicator RI
235
+ Sentence_Terminal STerm
236
+ Soft_Dotted SD
237
+ Terminal_Punctuation Term
238
+ Unified_Ideograph UIdeo
239
+ Uppercase Upper
240
+ Variation_Selector VS
241
+ White_Space space
242
+ XID_Continue XIDC
243
+ XID_Start XIDS`.split(/\s/).map(e=>[xm(e),e])),s7=new Map([["s",$n(383)],[$n(383),"s"]]),i7=new Map([[$n(223),$n(7838)],[$n(107),$n(8490)],[$n(229),$n(8491)],[$n(969),$n(8486)]]),a7=new Map([Ji(453),Ji(456),Ji(459),Ji(498),...Nx(8072,8079),...Nx(8088,8095),...Nx(8104,8111),Ji(8124),Ji(8140),Ji(8188)]),o7=new Map([["alnum",wt`[\p{Alpha}\p{Nd}]`],["alpha",wt`\p{Alpha}`],["ascii",wt`\p{ASCII}`],["blank",wt`[\p{Zs}\t]`],["cntrl",wt`\p{Cc}`],["digit",wt`\p{Nd}`],["graph",wt`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",wt`\p{Lower}`],["print",wt`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",wt`[\p{P}\p{S}]`],["space",wt`\p{space}`],["upper",wt`\p{Upper}`],["word",wt`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",wt`\p{AHex}`]]);function l7(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Ji(e){const t=$n(e);return[t.toLowerCase(),t]}function Nx(e,t){return l7(e,t).map(n=>Ji(n))}var _T=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function c7(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};ST(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Wy(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};ou(e,u7,r);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};ou(e,d7,o);const d={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return ou(e,h7,d),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var u7={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const o=ms();o.body[0].body.push(Ga({negate:!0,body:r}),dl("Any"));const d=ms();d.body[0].body.push(fT("greedy",0,1/0,o)),n(Nn(d,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const a=e.body.filter(o=>o.kind==="flags");for(let o=n+1;o<t.body.length;o++){const d=t.body[o];ku(r,d,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=CT(t.get(e));if(r){const a=ms({flags:r});a.body[0].body=e.body,e.body=[Nn(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:o,replaceWith:d},u){const{kind:c,negate:h}=e,{asciiWordBoundaries:m,avoidSubclass:f,supportedGNodes:g,wordIsAscii:x}=u;if(c==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(c==="line_end")d(Nn(Ga({body:[oo({body:[zy("string_end")]}),oo({body:[gm(10)]})]}),t));else if(c==="line_start")d(Nn(di(wt`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c==="search_start")if(g.has(e))a.flags.sticky=!0,o();else{const w=r[n-1];if(w&&y7(w))d(Nn(Ga({negate:!0}),t));else{if(f)throw new Error(wt`Uses "\G" in a way that requires a subclass`);d(Zi(zy("string_start"),t)),u.strategy="clip_search"}}else if(!(c==="string_end"||c==="string_start"))if(c==="string_end_newline")d(Nn(di(wt`(?=\n?\z)`),t));else if(c==="word_boundary"){if(!x&&!m){const w=`(?:(?<=${ui})(?!${ui})|(?<!${ui})(?=${ui}))`,C=`(?:(?<=${ui})(?=${ui})|(?<!${ui})(?!${ui}))`;d(Nn(di(h?C:w),t))}}else throw new Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Ax(n)&&(n=Tx(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Ax(r)&&(r=Tx(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=Gh({body:[e]});n(Nn(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:o,spaceIsAscii:d,wordIsAscii:u}){const{kind:c,negate:h,value:m}=e;if(o&&(c==="digit"||m==="digit")){n(Zi(Uy("digit",{negate:h}),t));return}if(d&&(c==="space"||m==="space")){n(Nn(Lx(di(n7),h),t));return}if(u&&(c==="word"||m==="word")){n(Zi(Uy("word",{negate:h}),t));return}if(c==="any")n(Zi(dl("Any"),t));else if(c==="digit")n(Zi(dl("Nd",{negate:h}),t));else if(c!=="dot")if(c==="text_segment"){if(r==="strict")throw new Error(wt`Use of "\X" requires non-strict accuracy`);const f="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",g=wt`\p{RI}{2}|${f}(?:\u200D${f})*`;n(Nn(di(wt`(?>\r\n|${a?wt`\p{RGI_Emoji}`:g}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c==="hex")n(Zi(dl("AHex",{negate:h}),t));else if(c==="newline")n(Nn(di(h?`[^
244
+ ]`:`(?>\r
245
+ ?|[
246
+ \v\f…\u2028\u2029])`),t));else if(c==="posix")if(!a&&(m==="graph"||m==="print")){if(r==="strict")throw new Error(`POSIX class "${m}" requires min target ES2024 or non-strict accuracy`);let f={graph:"!-~",print:" -~"}[m];h&&(f=`\0-${$n(f.codePointAt(0)-1)}${$n(f.codePointAt(2)+1)}-􏿿`),n(Nn(di(`[${f}]`),t))}else n(Nn(Lx(di(o7.get(m)),h),t));else if(c==="property")xv.has(xm(m))||(e.key="sc");else if(c==="space")n(Zi(dl("space",{negate:h}),t));else if(c==="word")n(Nn(Lx(di(ui),h),t));else throw new Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:a,removeAllPrevSiblings:o,removeAllNextSiblings:d}){const{kind:u,flags:c}=e;if(u==="flags")if(!c.enable&&!c.disable)r();else{const h=ms({flags:c});h.body[0].body=d(),a(Nn(h,t),{traverse:!0})}else if(u==="keep"){const h=n.body[0],f=n.body.length===1&&uT(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==f||f.body.length>1)throw new Error(wt`Uses "\K" in a way that's unsupported`);const g=Ga({behind:!0});g.body[0].body=o(),a(Nn(g,t))}else throw new Error(`Unexpected directive kind "${u}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(Nn(Ga({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=ms();t.body[0].body.push(e.body),e.body=Nn(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,a=!1;for(const o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const d=jT(o.body);d?(r=!0,Array.isArray(d)?n.push(...d):n.push(d)):a=!0}r&&!a&&n.forEach(o=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(wt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Ax(n)&&(n=Tx(n,t),e.ref=n)}},d7={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:a}=e;r||n.set(e,[...t.get(a).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:a,groupsByName:o,multiplexCapturesToLeftByRef:d,openRefs:u,reffedNodesByReferencer:c}){const h=a.get(e);if(h&&u.has(e.number)){const f=Zi(gk(e.number),t);c.set(f,u.get(e.number)),n(f);return}u.set(e.number,e),d.set(e.number,[]),e.name&&ku(d,e.name,[]);const m=d.get(e.name??e.number);for(let f=0;f<m.length;f++){const g=m[f];if(h===g.node||h&&h===g.origin||e===g.origin){m.splice(f,1);break}}if(d.get(e.number).push({node:e,origin:h}),e.name&&d.get(e.name).push({node:e,origin:h}),e.name){const f=ku(o,e.name,new Map);let g=!1;if(h)g=!0;else for(const x of f.values())if(!x.hasDuplicateNameToRemove){g=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:g})}},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=yf(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:a,ref:o}=e;if(a){let m=t;for(;(m=m.parent)&&!(m.type==="CapturingGroup"&&(m.name===o||m.number===o)););r.reffedNodesByReferencer.set(e,m);return}const d=r.subroutineRefMap.get(o),u=o===0,c=u?gk(0):wT(d,r.groupOriginByCopy,null);let h=c;if(!u){const m=CT(p7(d,g=>g.type==="Group"&&!!g.flags)),f=m?yf(r.globalFlags,m):r.globalFlags;f7(f,r.currentFlags)||(h=ms({flags:g7(f)}),h.body[0].body.push(c))}n(Nn(h,t),{traverse:!u})}},h7={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const o=r.reffedNodesByReferencer.get(e).filter(d=>m7(d,e));if(!o.length)n(Nn(Ga({negate:!0}),t));else if(o.length>1){const d=ms({atomic:!0,body:o.reverse().map(u=>oo({body:[Hy(u.number)]}))});n(Nn(d,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const a=hT();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function ST(e){ou(e,{"*"({node:t,parent:n}){t.parent=n}})}function f7(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function m7(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=kT(n.parent);for(const a of r){if(a===n)break;if(a===e||ET(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function wT(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[o,d]of Object.entries(e))o==="parent"?a.parent=Array.isArray(n)?r:n:d&&typeof d=="object"?a[o]=wT(d,t,a,n):(o==="type"&&d==="CapturingGroup"&&t.set(a,t.get(e)??e),a[o]=d);return a}function gk(e){const t=mT(e);return t.isRecursive=!0,t}function p7(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Tx(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 CT(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var o,d;(o=r.enable)!=null&&o[a]&&(delete n.disable[a],n.enable[a]=!0),(d=r.disable)!=null&&d[a]&&(n.disable[a]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function g7({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 kT(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function jT(e){const t=e.find(n=>n.kind==="search_start"||b7(n,{negate:!1})||!x7(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const a=jT(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function ET(e,t){const n=kT(e)??[];for(const r of n)if(r===t||ET(r,t))return!0;return!1}function x7({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function y7(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function b7(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&uT(e.body[0],{type:"Assertion",kind:"search_start"})}function Ax(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function di(e,t){const r=dT(e,{...t,unicodePropertyMap:xv}).body;return r.length>1||r[0].body.length>1?ms({body:r}):r[0].body[0]}function Lx(e,t){return e.negate=t,e}function Zi(e,t){return e.parent=t,e}function Nn(e,t){return ST(e),e.parent=t,e}function v7(e,t){const n=bT(t),r=Wy(n.target,"ES2024"),a=Wy(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let d=null,u=null;if(!a){const x=[e.flags.ignoreCase];ou(e,_7,{getCurrentModI:()=>x.at(-1),popModI(){x.pop()},pushModI(w){x.push(w)},setHasCasedChar(){x.at(-1)?d=!0:u=!0}})}const c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||d)&&!u)};let h=e;const m={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:h,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!a&&d&&u),useFlagMods:a,useFlagV:r,verbose:n.verbose};function f(x){return m.lastNode=h,h=x,e7(S7[x.type],`Unexpected node type "${x.type}"`)(x,m,f)}const g={pattern:e.body.map(f).join("|"),flags:f(e.flags),options:{...e.options}};return r||(delete g.options.force.v,g.options.disable.v=!0,g.options.unicodeSetsPlugin=null),g._captureTransfers=new Map,g._hiddenCaptures=[],m.captureMap.forEach((x,w)=>{x.hidden&&g._hiddenCaptures.push(w),x.transferTo&&ku(g._captureTransfers,x.transferTo,[]).push(w)}),g}var _7={"*":{enter({node:e},t){if(yk(e)){const n=t.getCurrentModI();t.pushModI(e.flags?yf({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){yk(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){yv($n(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),NT(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&_T.has(e.value)&&t.setHasCasedChar()}},S7={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?wt`\B`:wt`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:a,number:o}=e,d={ignoreCase:t.currentFlags.ignoreCase},u=t.originMap.get(e);return u&&(d.hidden=!0,o>u.number&&(d.transferTo=u.number)),t.captureMap.set(o,d),`(${a?`?<${a}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=$n(e),r=el(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&yv(n)){const a=vT(n);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:a,parent:o}=e;let{body:d}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");vs.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&d.some(bk)&&(d=[gm(45),...d.filter(h=>!bk(h))]);const u=()=>`[${a?"^":""}${d.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||vs.bugNestedClassIgnoresNegation)&&!a){const m=d.filter(f=>f.type==="CharacterClass"&&f.kind==="union"&&f.negate);if(m.length){const f=ms(),g=f.body[0];return f.parent=o,g.parent=f,d=d.filter(x=>!m.includes(x)),e.body=d,d.length?(e.parent=g,g.body.push(e)):f.body.pop(),m.forEach(x=>{const w=oo({body:[x]});x.parent=w,w.parent=f,f.body.push(w)}),n(f)}}t.inCharClass=!0;const h=u();return t.inCharClass=!1,h}const c=d[0];if(r==="union"&&!a&&c&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(vs.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&d.length===1&&c.type!=="CharacterClassRange"))return d.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return u()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=el(n,a),d=el(r,a),u=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const c=NT(e);E7(c).forEach(m=>{u.add(Array.isArray(m)?`${el(m[0],a)}-${el(m[1],a)}`:el(m,a))})}return`${o}-${d}${[...u].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":wt`[^\n]`;if(e==="digit")return t?wt`\D`:wt`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&_T.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?wt`\P`:wt`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?wt`\W`:wt`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},a,o){const d=a.currentFlags;n&&(a.currentFlags=yf(d,n));const u=t.map(o).join("|"),c=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?u:`(?${N7(e,n,a.useFlagMods)}${u})`;return a.currentFlags=d,c},LookaroundAssertion({body:e,kind:t,negate:n},r,a){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,t,n){return n(e.body)+T7(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})`:wt`\g<${t}&R=${r}>`}},w7=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),C7=new Set(["-","\\","]","^","["]),k7=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),xk=new Map([[9,wt`\t`],[10,wt`\n`],[11,wt`\v`],[12,wt`\f`],[13,wt`\r`],[8232,wt`\u2028`],[8233,wt`\u2029`],[65279,wt`\uFEFF`]]),j7=new RegExp("^\\p{Cased}$","u");function yv(e){return j7.test(e)}function NT(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,a=e.max.value,o=[];if(r<65&&(a===65535||a>=131071)||r===65536&&a>=131071)return o;for(let d=r;d<=a;d++){const u=$n(d);if(!yv(u))continue;const c=vT(u).filter(h=>{const m=h.codePointAt(0);return m<r||m>a});if(c.length&&(o.push(...c),n))break}return o}function el(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(xk.has(e))return xk.get(e);if(e<32||e>126&&e<160||e>262143||t&&A7(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?k7:C7:w7,o=$n(e);return(a.has(o)?"\\":"")+o}function E7(e){const t=e.map(a=>a.codePointAt(0)).sort((a,o)=>a-o),n=[];let r=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?r??(r=t[a]):r===null?n.push(t[a]):(n.push([r,t[a]]),r=null);return n}function N7(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:a,disable:o}=t;r=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(o?"-":"")+(o!=null&&o.ignoreCase?"i":"")+(o!=null&&o.dotAll?"s":"")}return`${r}:`}function T7({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 yk({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function A7(e){return e>47&&e<58}function bk({type:e,value:t}){return e==="Character"&&t===45}var na,gi,Xa,ra,Qa,Eu,Gy,da,L7=(da=class extends RegExp{constructor(n,r,a){var t=(...vK)=>(super(...vK),Oa(this,Eu),Oa(this,na,new Map),Oa(this,gi,null),Oa(this,Xa),Oa(this,ra,null),Oa(this,Qa,null),Te(this,"rawOptions",{}),this);const o=!!(a!=null&&a.lazyCompile);if(n instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const d=n;t(d,r),cs(this,Xa,d.source),d instanceof da&&(cs(this,na,lr(d,na)),cs(this,ra,lr(d,ra)),cs(this,Qa,lr(d,Qa)),this.rawOptions=d.rawOptions)}else{const d={hiddenCaptures:[],strategy:null,transfers:[],...a};t(o?"":n,r),cs(this,Xa,n),cs(this,na,D7(d.hiddenCaptures,d.transfers)),cs(this,Qa,d.strategy),this.rawOptions=a??{}}o||cs(this,gi,this)}get source(){return lr(this,Xa)||"(?:)"}exec(n){if(!lr(this,gi)){const{lazyCompile:o,...d}=this.rawOptions;cs(this,gi,new da(lr(this,Xa),this.flags,d))}const r=this.global||this.sticky,a=this.lastIndex;if(lr(this,Qa)==="clip_search"&&r&&a){this.lastIndex=0;const o=Rg(this,Eu,Gy).call(this,n.slice(a));return o&&(R7(o,a,n,this.hasIndices),this.lastIndex+=a),o}return Rg(this,Eu,Gy).call(this,n)}},na=new WeakMap,gi=new WeakMap,Xa=new WeakMap,ra=new WeakMap,Qa=new WeakMap,Eu=new WeakSet,Gy=function(n){lr(this,gi).lastIndex=this.lastIndex;const r=Tw(da.prototype,this,"exec").call(lr(this,gi),n);if(this.lastIndex=lr(this,gi).lastIndex,!r||!lr(this,na).size)return r;const a=[...r];r.length=1;let o;this.hasIndices&&(o=[...r.indices],r.indices.length=1);const d=[0];for(let u=1;u<a.length;u++){const{hidden:c,transferTo:h}=lr(this,na).get(u)??{};if(c?d.push(null):(d.push(r.length),r.push(a[u]),this.hasIndices&&r.indices.push(o[u])),h&&a[u]!==void 0){const m=d[h];if(!m)throw new Error(`Invalid capture transfer to "${m}"`);if(r[m]=a[u],this.hasIndices&&(r.indices[m]=o[u]),r.groups){lr(this,ra)||cs(this,ra,O7(this.source));const f=lr(this,ra).get(h);f&&(r.groups[f]=a[u],this.hasIndices&&(r.indices.groups[f]=o[u]))}}}return r},da);function R7(e,t,n,r){if(e.index+=t,e.input=n,r){const a=e.indices;for(let d=0;d<a.length;d++){const u=a[d];u&&(a[d]=[u[0]+t,u[1]+t])}const o=a.groups;o&&Object.keys(o).forEach(d=>{const u=o[d];u&&(o[d]=[u[0]+t,u[1]+t])})}}function D7(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,a]of t)for(const o of a)ku(n,o,{}).transferTo=r;return n}function O7(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,o;for(;o=t.exec(e);){const{0:d,groups:{capture:u,name:c}}=o;d==="["?r++:r?d==="]"&&r--:u&&(a++,c&&n.set(a,c))}return n}function M7(e,t){const n=I7(e,t);return n.options?new L7(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function I7(e,t){const n=bT(t),r=dT(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:xv}),a=c7(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=v7(a,n),d=JH(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),u=XH(d.pattern),c=YH(u.pattern,{captureTransfers:d.captureTransfers,hiddenCaptures:d.hiddenCaptures}),h={pattern:c.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const m=c.hiddenCaptures.sort((w,C)=>w-C),f=Array.from(c.captureTransfers),g=a._strategy,x=h.pattern.length>=n.lazyCompileLength;(m.length||f.length||g||x)&&(h.options={...m.length&&{hiddenCaptures:m},...f.length&&{transfers:f},...g&&{strategy:g},...x&&{lazyCompile:x}})}return h}function TT(e,t){return M7(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function P7(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>TT(n,{target:t.target})),{createScanner(n){return new Zz(n,t)},createString(n){return{content:n}}}}a2(tv({bundledLanguages:()=>om,bundledLanguagesAlias:()=>rv,bundledLanguagesBase:()=>nv,bundledLanguagesInfo:()=>am,bundledThemes:()=>iv,bundledThemesInfo:()=>sv,codeToHast:()=>Z2,codeToHtml:()=>J2,codeToTokens:()=>eT,codeToTokensBase:()=>tT,codeToTokensWithThemes:()=>nT,createHighlighter:()=>pm,createJavaScriptRegexEngine:()=>P7,createOnigurumaEngine:()=>c2,defaultJavaScriptRegexConstructor:()=>TT,getLastGrammarState:()=>sT,getSingletonHighlighter:()=>rT,loadWasm:()=>ov}),Jz);let Rx=null;const lu=new Set,vh=new Map,vk=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],B7=["github-dark-default","vitesse-light","monokai","dracula","nord","everforest-light","rose-pine-dawn","synthwave-84","one-dark-pro","night-owl","catppuccin-mocha","rose-pine","kanagawa-wave","light-plus"],Dx={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord","rose-pine-dawn":"rose-pine-dawn","everforest-light":"everforest-light","synthwave-84":"synthwave-84","one-dark-pro":"one-dark-pro","night-owl":"night-owl","catppuccin-mocha":"catppuccin-mocha","rose-pine":"rose-pine","kanagawa-wave":"kanagawa-wave","light-plus":"light-plus"};function $7(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function AT(){return Rx||(Rx=pm({themes:B7,langs:vk}).then(e=>(vk.forEach(t=>lu.add(t)),e))),Rx}async function F7(e){if(lu.has(e))return;if(vh.has(e))return vh.get(e);const t=(async()=>{const n=await AT(),r=om[e];if(r){await n.loadLanguage(r),lu.add(e);return}try{const a=await ae(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),lu.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();vh.set(e,t),await t,vh.delete(e)}const Gc=new Map,z7=50;function H7(e,t,n){return`${e}|${t}|${n}`}async function LT(e,t,n="github-dark-default"){t!=="text"&&!lu.has(t)&&await F7(t);const r=H7(e,t,n),a=Gc.get(r);if(a)return a;const d=(await AT()).codeToHtml(e,{lang:t,theme:n,transformers:[$7()]});if(Gc.size>=z7){const u=Gc.keys().next().value;u&&Gc.delete(u)}return Gc.set(r,d),d}const U7={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 vm(e){var a;if(!e)return"text";const t=Lu(e),n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return r?U7[r]??"text":"text"}function RT(){const e=Zt(r=>r.currentPreset),t=Zt(r=>r.isCustom),n=Zt(r=>r.basePreset);return V7(e,t,n)}function V7(e,t,n){return t?n&&n!=="system"&&Dx[n]?Dx[n]??"github-dark-default":"github-dark-default":Dx[e]??"github-dark-default"}function DT(e=2e3){const[t,n]=k.useState(!1),r=k.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const o=document.createElement("textarea");o.value=a,o.style.position="fixed",o.style.left="-9999px",document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}n(!0),setTimeout(()=>n(!1),e)}catch(o){console.error("Failed to copy:",o)}},[e]);return{copied:t,copy:r}}const W7=5e3,eu=new Map,G7=100,q7=20*1024*1024;let K7=q7,Ox=0;function Y7(e,t){for(eu.set(e,t),Ox+=e.length;eu.size>G7||Ox>K7;){const n=eu.keys().next().value;if(n===void 0)break;eu.delete(n),Ox-=n.length}return t}const X7=k.memo(function({language:t,codeString:n,showSyntaxHighlighting:r,deferHighlight:a}){const{copied:o,copy:d}=DT(),[u,c]=k.useState(null),h=RT(),m=k.useRef(n),f=t==="text"||n.length>W7;return k.useEffect(()=>{!r||a||f||(m.current=n,LT(n,t,h).then(g=>{m.current===n&&c(g)}))},[n,t,h,r,a,f]),s.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[s.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:[s.jsx("span",{children:t}),s.jsx("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),d(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:o?s.jsx(Us,{}):s.jsx(jl,{})})]}),r&&u?s.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):s.jsx(mn,{horizontal:!0,scope:"codeBlocks",children:s.jsx("pre",{className:"my-0 px-4 py-3 font-mono text-sm whitespace-pre-wrap break-word",children:s.jsx("code",{className:`language-${t}`,children:n})})})]})});function Q7(e,t,n){const r=e?"text-text-muted":"text-text-heading",a=e?"text-text-secondary":"text-text-bold";return{code({className:o,children:d,...u}){const c=/language-(\w+)/.exec(o||"");if(!c&&!String(d).includes(`
247
+ `)){const g=e?"text-text-muted":"text-text-code";return s.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${g} font-mono text-xs`,...u,children:d})}const m=(c==null?void 0:c[1])||"text",f=String(d).replace(/\n$/,"");return s.jsx(X7,{language:m,codeString:f,showSyntaxHighlighting:t,deferHighlight:n})},p({children:o}){const d=e?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${d} mb-1.5 last:mb-0 leading-tight break-words`,children:o})},ul({children:o}){return s.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:o})},ol({children:o}){return s.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:o})},li({children:o}){const d=e?"text-text-muted":"text-text-primary";return s.jsx("li",{className:`${d} text-sm list-item`,children:o})},h1({children:o}){return s.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:o})},h2({children:o}){return s.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:o})},h3({children:o}){return s.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:o})},h4({children:o}){return s.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:o})},strong({children:o}){return s.jsx("strong",{className:`font-bold ${a}`,children:o})},em({children:o}){return s.jsx("em",{className:e?"italic text-text-secondary":"italic",children:o})},a({href:o,children:d}){return s.jsx("a",{href:o,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:d})},blockquote({children:o}){const d=e?"text-text-muted":"text-text-secondary";return s.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${d} italic text-sm`,children:o})},table({children:o}){return s.jsx(mn,{horizontal:!0,className:"my-1.5",scope:"codeBlocks",children:s.jsx("table",{className:"min-w-full border border-border",children:o})})},th({children:o}){return s.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:o})},td({children:o}){return s.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:o})},hr(){return s.jsx("hr",{className:"border-border my-2"})},input({checked:o,...d}){return s.jsx("input",{type:"checkbox",checked:o,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...d})}}}const Zn=k.memo(function({content:t,className:n="",muted:r=!1,isStreaming:a=!1}){const{showSyntaxHighlighting:o,deferCodeHighlightWhileStreaming:d}=Hs(),u=k.useMemo(()=>a&&d&&MT(t)%2===1,[a,d,t]),c=k.useMemo(()=>Q7(r,o,u),[r,o,u]),h=k.useMemo(()=>{const m=J7(t);if(!eU(m)){if(!m.trim())return null;const f=r?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${f} mb-1.5 last:mb-0 leading-tight break-words whitespace-pre-line`,children:Z7(m)})}return a?OT(m,c):tU(m,c,r,o)},[t,a,c,r,o]);return s.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:h})});function J7(e){let t=nU(e);return t=rU(t),t.trimEnd()}function Z7(e){const t=e.split(/(https?:\/\/[^\s<>"']+)/g);return t.length===1?e:t.map((n,r)=>/^https?:\/\//.test(n)?s.jsx("a",{href:n,className:"text-text-link hover:underline",target:"_blank",rel:"noopener noreferrer",children:n},r):n)}function eU(e){return e.includes("`")||e.includes("~")||e.includes("<")||/^#{1,6}\s/m.test(e)||/^\s*[-*+]\s/m.test(e)||/^\s*\d+[.)]\s/m.test(e)||/^\s*>\s?/m.test(e)||/^\s*\|.*\|/m.test(e)||/^\s*([-*_])\1{2,}\s*$/m.test(e)||/\[[^\]]*\]\([^)]*\)/.test(e)||/!\[[^\]]*\]/.test(e)||/[*_]/.test(e)||e.includes("&")}function OT(e,t){return s.jsx(g6,{remarkPlugins:[T8],components:t,children:e})}function tU(e,t,n,r){const a=`${n?"m":"n"}|${r?"h":"p"}|${e}`,o=eu.get(a);if(o!==void 0)return o;const d=OT(e,t);return Y7(a,d)}function nU(e){let t=e.replace(/^(\s*)•\s/gm,"$1- ");return t=t.replace(/^(\d+)\.\s*\n(?=\S)/gm,"$1. "),t=t.replace(/^\|\s*$/gm,""),t=t.replace(/^\d+\|/gm,""),t}function MT(e){var t;return((t=e.match(/```/g))==null?void 0:t.length)??0}function rU(e){if(MT(e)%2===1){const n=e.lastIndexOf("```");return e.slice(n+3).includes(`
248
+ `),e+"\n```"}return e}function IT({isOpen:e,onClose:t,since:n}){const[r,a]=k.useState(null),[o,d]=k.useState(!1),{settings:u,getSetting:c,setSetting:h}=pa(),m=u[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";k.useEffect(()=>{e&&c(je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,c]),k.useEffect(()=>{if(!e)return;d(!0);const g=n?`/api/changelog?since=${encodeURIComponent(n)}`:"/api/changelog";ye(g).then(x=>x.json()).then(x=>{a(x.content)}).catch(()=>{a(`# Changelog
249
+
250
+ Failed to load changelog.`)}).finally(()=>d(!1))},[e,n]);const f=k.useCallback(()=>{const g=m?"false":"true";h(je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,g)},[m,h]);return s.jsx(Et,{isOpen:e,onClose:t,title:"What's New in OpenFox",size:"xl",closeOnBackdropClick:!0,showCloseButton:!0,footer:s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx(ys,{enabled:m,onClick:f}),s.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:s.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:o?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):s.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:s.jsx(Zn,{content:r??""})})})})}const sU="#6b7280";function lo(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??sU}const tl=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,ft=tr(e=>{const t=async n=>{e({loading:!0});try{const a=await(await ye(tl("/api/agents",n))).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],modelOverrides:a.modelOverrides??{},loading:!1})}catch{e({loading:!1})}};return{defaults:[],userItems:[],projectItems:[],modelOverrides:{},loading:!1,fetchAgents:t,fetchAgent:async(n,r)=>{try{const a=await ye(tl(`/api/agents/${n}`,r));return a.ok?await a.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ye(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r,a)=>{const o=await ha("POST",tl("/api/agents",a),{...n,destination:r});return o.success&&await t(a),o},updateAgent:async(n,r,a)=>{const o=await ha("PUT",tl(`/api/agents/${n}`,a),r);return o.success&&await t(a),o},deleteAgent:async(n,r)=>{try{const a=await ye(tl(`/api/agents/${n}`,r),{method:"DELETE"}),o=await a.json();return a.ok?(e(d=>({userItems:d.userItems.filter(u=>u.id!==n),projectItems:d.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r,a)=>Uf(tl(`/api/agents/${n}/duplicate`,a),()=>t(a),r)}});function iU({onClose:e}){const[,t]=Fn(),{settings:n,getSetting:r,setSetting:a}=pa(),o=n[je.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",d=n[je.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",u=n[je.CACHE_WARMING]==="true",[c,h]=k.useState({openInEditor:o,dynamicPrompt:d,cacheWarming:u}),[m,f]=k.useState({patterns:[],maxRetriesPerTurn:10}),[g,x]=k.useState(""),[w,C]=k.useState(""),[v,S]=k.useState(!1),[_,b,j,E]=gy(),[N,L]=k.useState(!1),[A,D]=k.useState(!1),O=an(B=>B.version),F=Si(B=>B.status),P=Si(B=>B.latest),z=Si(B=>B.check),K=O&&P?{current:O,latest:P}:null,[q,W]=k.useState(!1),Z=ft(B=>B.defaults),Q=ft(B=>B.userItems),H=ft(B=>B.fetchAgents),I=[...Z,...Q].filter(B=>!B.subagent);k.useEffect(()=>{h({openInEditor:o,dynamicPrompt:d,cacheWarming:u})},[o,d,u]),k.useEffect(()=>{r(je.DISPLAY_SHOW_OPEN_IN_EDITOR),r(je.LLM_DYNAMIC_SYSTEM_PROMPT),r(je.CACHE_WARMING),r(je.RETRY_PATTERNS),r(je.PROXY_URL)},[r]),k.useEffect(()=>{const B=n[je.RETRY_PATTERNS];if(B)try{f(JSON.parse(B))}catch{}},[n]),k.useEffect(()=>{const B=n[je.PROXY_URL];B!==void 0&&x(B)},[n]),k.useEffect(()=>{H().catch(()=>{})},[H]),k.useEffect(()=>{r(je.DEFAULT_AGENT)},[r]),k.useEffect(()=>{const B=n[je.DEFAULT_AGENT];B!==void 0&&(C(B),S(!0))},[n]);const M=k.useCallback(B=>{f(B),a(je.RETRY_PATTERNS,JSON.stringify(B))},[a]),V=B=>{x(B),a(je.PROXY_URL,B)};function $(){E(async()=>(await ye("/api/proxy/test",{method:"POST"})).json())}const ee=()=>{const B=!c.openInEditor;h(J=>({...J,openInEditor:B})),a(je.DISPLAY_SHOW_OPEN_IN_EDITOR,String(B))},Y=()=>{const B=!c.dynamicPrompt;h(J=>({...J,dynamicPrompt:B})),a(je.LLM_DYNAMIC_SYSTEM_PROMPT,String(B))},X=()=>{const B=!c.cacheWarming;h(J=>({...J,cacheWarming:B})),a(je.CACHE_WARMING,String(B))};function U(){e(),t("/onboarding")}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[F==="available"&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:O?s.jsxs(s.Fragment,{children:["Current version: ",s.jsxs("span",{className:"font-mono",children:["v",O]})]}):"Check for a new OpenFox version."}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ct,{variant:"secondary",onClick:()=>{W(!0),z()},disabled:F==="checking",children:F==="checking"?"Checking…":"Check for Updates"}),q&&F==="upToDate"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),F==="error"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),F==="available"&&s.jsxs("button",{onClick:()=>L(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",P," →"]})]})]}),s.jsx(eN,{isOpen:N,onClose:()=>L(!1),versionInfo:K}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("button",{onClick:()=>D(!0),className:"text-sm text-accent-primary hover:underline",children:"View Changelog →"}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("span",{className:"text-xs text-text-muted",children:"Show on update"}),s.jsx(ys,{enabled:(n[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const J=(n[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,J)}})]})]}),s.jsx(IT,{isOpen:A,onClose:()=>D(!1)}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Default Agent"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Choose which agent is used by default for new sessions. The stock Planner is read-only; custom agents can have broader capabilities."}),s.jsxs("select",{value:v?w:"",onChange:B=>{const J=B.target.value;C(J),a(je.DEFAULT_AGENT,J)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",children:[!v&&s.jsx("option",{value:"",children:"Loading…"}),v&&s.jsx("option",{value:"",children:"System default (planner)"}),I.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))]}),I.length===0&&v&&s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),s.jsx(ct,{variant:"secondary",onClick:U,children:"Launch Onboarding"})]}),s.jsx("hr",{className:"border-border"}),s.jsx("div",{children:s.jsx(Mx,{title:'Show "Open in VSCode" links',description:"Display a link on file reads to open the file directly in VS Code.",enabled:c.openInEditor,onToggle:ee})}),s.jsx("hr",{className:"border-border"}),s.jsx(Mx,{title:"Speculative Cache Warming",description:"On first keystroke in an empty session, prefill the LLM KV cache to reduce time-to-first-token.",enabled:c.cacheWarming,onToggle:X,boldTitle:!0}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Network"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"HTTP Proxy"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(xs,{type:"text",value:g,onChange:B=>V(B.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),s.jsx(ct,{variant:"secondary",onClick:$,style:j?{color:"rgb(63, 185, 80)"}:void 0,children:_})]}),b&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:b}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Proxy server all OpenFox network requests (AI, model fetching, web search, terminal). Leave empty for direct connection."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Define regex patterns that, when matched against LLM responses mid-stream, trigger an automatic retry with a "continue" prompt. The content that triggered the match is preserved in the chat feed.'}),s.jsx(tM,{value:m,onChange:M})]}),s.jsx("hr",{className:"border-border"}),s.jsx(Mx,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:c.dynamicPrompt,onToggle:Y,boldTitle:!0})]})}function Mx({title:e,description:t,enabled:n,onToggle:r,boldTitle:a}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),s.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0",children:s.jsx(ys,{enabled:n,onClick:r})})]})}function aU(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function oU({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:o,onClear:d,onReset:u,onCancelRecording:c}){const h=k.useRef(null),m=k.useRef(0),f=k.useRef("");return k.useEffect(()=>{if(!r)return;const g=new Set(["Control","Shift","Alt","Meta"]);let x=[];const w=v=>{if(v.preventDefault(),v.stopPropagation(),v.key==="Escape"){c();return}if(g.has(v.key)){const b=Date.now();if(v.key===f.current&&b-m.current<400){o({type:"double-press",key:v.key,threshold:300});return}m.current=b,f.current=v.key,v.ctrlKey&&!x.includes("ctrl")&&x.push("ctrl"),v.metaKey&&!x.includes("meta")&&x.push("meta"),v.altKey&&!x.includes("alt")&&x.push("alt"),v.shiftKey&&!x.includes("shift")&&x.push("shift");return}if(x.length>0||v.ctrlKey||v.metaKey||v.altKey||v.shiftKey){const b=[...x];v.ctrlKey&&!b.includes("ctrl")&&b.push("ctrl"),v.metaKey&&!b.includes("meta")&&b.push("meta"),v.altKey&&!b.includes("alt")&&b.push("alt"),v.shiftKey&&!b.includes("shift")&&b.push("shift"),o({type:"chord",key:D1(v),modifiers:b});return}const S=Date.now(),_=D1(v);if(_===f.current&&S-m.current<400){o({type:"double-press",key:_,threshold:300});return}m.current=S,f.current=_},C=v=>{v.key==="Control"&&(x=x.filter(S=>S!=="ctrl")),v.key==="Shift"&&(x=x.filter(S=>S!=="shift")),v.key==="Alt"&&(x=x.filter(S=>S!=="alt")),v.key==="Meta"&&(x=x.filter(S=>S!=="meta"))};return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",C,!0)}},[r,o,c]),s.jsxs("div",{ref:h,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${r?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-sm text-text-primary",children:e}),s.jsx("div",{className:"flex items-center gap-2",children:r?s.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:t?Lb(t):"None"}),t&&s.jsx("button",{type:"button",onClick:d,title:"Remove shortcut","aria-label":`Remove shortcut for ${e}`,className:"p-1 text-text-muted rounded hover:text-accent-error hover:bg-bg-tertiary transition-colors",children:s.jsx(Ab,{className:"w-3.5 h-3.5"})}),!aU(t,n)&&s.jsx("button",{type:"button",onClick:u,title:"Reset to default","aria-label":`Reset ${e} to default`,className:"p-1 text-text-muted rounded hover:text-accent-primary hover:bg-bg-tertiary transition-colors",children:s.jsx(Yf,{className:"w-3.5 h-3.5"})})]})})]})}function lU(){const{settings:e,loading:t,setSetting:n}=pa(),r=e[je.KEYBINDINGS],a=t[je.KEYBINDINGS]??!1,o=py(r),[d,u]=k.useState(null),c=[{id:"terminalToggle",label:"Toggle Terminal",binding:o.terminalToggle,defaultBinding:Ms.terminalToggle},{id:"quickAction",label:"Quick Action",binding:o.quickAction,defaultBinding:Ms.quickAction},{id:"modelSelector",label:"Select Model",binding:o.modelSelector,defaultBinding:Ms.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:o.sessionSearch,defaultBinding:Ms.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:o.criteriaSidebar,defaultBinding:Ms.criteriaSidebar},...o.agentSwitching.map((x,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:x,defaultBinding:Ms.agentSwitching[w]??null}))],h=x=>{u(x)},m=k.useCallback((x,w)=>{const C=py(r);if(x.startsWith("agentSwitching.")){const v=parseInt(x.split(".")[1],10);C.agentSwitching[v]=w}else x==="terminalToggle"?C.terminalToggle=w:x==="quickAction"?C.quickAction=w:x==="modelSelector"?C.modelSelector=w:x==="sessionSearch"?C.sessionSearch=w:x==="criteriaSidebar"&&(C.criteriaSidebar=w);n(je.KEYBINDINGS,JSON.stringify(C))},[r,n]),f=k.useCallback(x=>{d&&(u(null),m(d,x))},[d,m]),g=()=>{n(je.KEYBINDINGS,JSON.stringify(Ms))};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),s.jsx("button",{type:"button",onClick:g,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?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsx("div",{className:"space-y-1",children:c.map(x=>s.jsx(oU,{label:x.label,binding:x.binding,defaultBinding:x.defaultBinding,isRecording:d===x.id,onStartRecording:()=>h(x.id),onBindingRecorded:f,onClear:()=>m(x.id,null),onReset:()=>m(x.id,x.defaultBinding),onCancelRecording:()=>u(null)},x.id))})]})}function bv(e){switch(e){case"connected":return"text-accent-success";case"error":return"text-accent-error";case"disabled":return"text-text-muted";default:return"text-text-muted"}}function vv(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function bf(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function PT({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:o,onToolToggle:d,statusDot:u,statusColor:c,actions:h,authPanel:m}){var w;const[f,g]=k.useState(new Set),x=e.name;return s.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-bg-primary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer",onClick:()=>n(x),children:[s.jsx("span",{className:`text-sm ${c}`,children:u}),s.jsx("span",{className:"text-sm font-medium text-text-primary",children:x}),s.jsx("span",{className:"text-xs text-text-muted",children:e.config.transport}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",o.length," tools)"]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[bf(e.estimatedTokens)," tokens"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ys,{enabled:r,onClick:a}),h,s.jsx("span",{className:"text-xs text-text-muted",children:t?"▲":"▼"})]})]}),t&&s.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[e.config.command&&s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[e.config.command," ",((w=e.config.args)==null?void 0:w.join(" "))??""]}),e.config.url&&s.jsx("div",{className:"text-xs text-text-muted font-mono",children:e.config.url}),m,o.length===0?s.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):s.jsx("div",{className:"space-y-1",children:o.map(C=>s.jsxs("div",{className:"py-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[s.jsx("span",{className:"text-xs text-text-primary font-mono",children:C.name}),C.description&&C.description.length>80?s.jsxs("button",{onClick:()=>{const v=C.name;g(S=>{const _=new Set(S);return _.has(v)?_.delete(v):_.add(v),_})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[s.jsx("span",{className:"truncate max-w-[300px]",children:C.description}),s.jsx(gn,{rotate:f.has(C.name)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):C.description?s.jsx("span",{className:"text-xs text-text-muted ml-2",children:C.description}):null]}),s.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:bf(C.estimatedTokens)}),s.jsx(ys,{enabled:C.enabled,onClick:()=>d(C.name)})]}),C.description&&C.description.length>80&&f.has(C.name)&&s.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:C.description})]},C.name))})]})]},x)}function _k(e){const t={};return e.split(`
251
+ `).filter(Boolean).forEach(n=>{const r=n.indexOf("=");r>0&&(t[n.slice(0,r).trim()]=n.slice(r+1).trim())}),t}function Sk({formData:e,onChange:t}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>t({...e,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),s.jsx("button",{onClick:()=>t({...e,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),e.transport==="stdio"?s.jsxs(s.Fragment,{children:[s.jsx(rs,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),s.jsx(rs,{label:"Arguments",value:e.args,onChange:n=>t({...e,args:n}),placeholder:"space-separated args"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.jsx("textarea",{value:e.env,onChange:n=>t({...e,env:n.target.value}),placeholder:"API_KEY=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(rs,{label:"URL",value:e.url,onChange:n=>t({...e,url:n}),placeholder:"e.g. https://mcp.example.com/mcp"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.jsx("textarea",{value:e.headers,onChange:n=>t({...e,headers:n.target.value}),placeholder:"X-API-Key=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e.oauth,onChange:n=>t({...e,oauth:n.target.checked}),className:"mt-0.5"}),s.jsxs("span",{className:"text-xs text-text-secondary",children:["Authorize with OAuth",s.jsx("span",{className:"block text-text-muted",children:"For servers that require a sign in rather than a static credential. Expand the server afterwards to authorize."})]})]})]}),s.jsx(rs,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}const Ix="px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors disabled:opacity-50";function cU({serverName:e,onChanged:t}){const[n,r]=k.useState(!1),[a,o]=k.useState(""),[d,u]=k.useState(""),[c,h]=k.useState(""),m=`/api/mcp/servers/${encodeURIComponent(e)}/oauth`,f=async v=>{r(!0),h("");try{await v()}catch(S){h(S instanceof Error?S.message:String(S))}finally{r(!1)}},g=async(v,S)=>{const _=await ye(v,{method:"POST",headers:{"Content-Type":"application/json"},...S!==void 0?{body:JSON.stringify(S)}:{}}),b=await _.json();if(!_.ok)throw new Error(b.error??"Request failed");return b},x=()=>f(async()=>{const v=await g(`${m}/start`);if(v.status!=="redirect"){t();return}o(v.redirectUri??""),window.open(v.authorizationUrl,"_blank","noopener,noreferrer")}),w=()=>f(async()=>{await g(`${m}/complete`,{response:d}),u(""),o(""),t()}),C=()=>f(async()=>{if(!(await ye(m,{method:"DELETE"})).ok)throw new Error("Could not clear the stored credentials");t()});return s.jsxs("div",{className:"space-y-1.5 py-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:x,disabled:n,className:Ix,children:"Authorize"}),s.jsx("button",{onClick:C,disabled:n,className:Ix,children:"Forget credentials"})]}),a&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"text-xs text-text-muted",children:"A tab opened for you to sign in. If it ends up on a page that will not load, copy the whole address from it and paste it below."}),s.jsx("div",{className:"text-xs text-text-muted font-mono break-all",children:a}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{value:d,onChange:v=>u(v.target.value),placeholder:"paste the callback URL",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("button",{onClick:w,disabled:n||!d,className:Ix,children:"Finish"})]})]}),c&&s.jsx("div",{className:"text-xs text-accent-error",children:c})]})}function Px(e,t,n,r=250){const a=k.useRef(!0);k.useEffect(()=>{if(a.current){a.current=!1;return}const o=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(o)},[e,t,r,n])}function wk({saving:e,saveLabel:t,savingLabel:n,onCancel:r,onSave:a}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[s.jsx(ct,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),s.jsx(ct,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function uU(){const{settings:e,getSetting:t,setSetting:n}=pa(),[r,a]=k.useState(""),[o,d]=k.useState(""),[u,c]=k.useState(""),[h,m]=k.useState("");Px(o,je.SEARCH_TAVILY_API_KEY,n),Px(u,je.SEARCH_SEARXNG_URL,n),Px(h,je.SEARCH_SEARXNG_API_KEY,n);const[f,g,x,w]=gy(),[C,v,S,_]=gy();k.useEffect(()=>{t(je.SEARCH_ENGINE),t(je.SEARCH_TAVILY_API_KEY),t(je.SEARCH_SEARXNG_URL),t(je.SEARCH_SEARXNG_API_KEY),t(je.TOOLS_USE_RTK),t(je.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),k.useEffect(()=>{e[je.SEARCH_ENGINE]!==void 0&&(a(e[je.SEARCH_ENGINE]??""),d(e[je.SEARCH_TAVILY_API_KEY]??""),c(e[je.SEARCH_SEARXNG_URL]??""),m(e[je.SEARCH_SEARXNG_API_KEY]??""))},[e]);function b(re){a(re),n(je.SEARCH_ENGINE,re)}function j(){w(async()=>(await ye("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:o||void 0})})).json())}function E(){_(async()=>(await ye("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:u||void 0,searxngApiKey:h||void 0})})).json())}const[N,L]=k.useState("checking");k.useEffect(()=>{ye("/api/tools/rtk-check").then(re=>re.json()).then(re=>L(re.available?"available":"unavailable")).catch(()=>L("unavailable"))},[]);const[A,D]=k.useState([]);k.useEffect(()=>{t(je.TOOLS_SHELL),ye("/api/tools/shells").then(re=>re.json()).then(re=>D(re.shells??[])).catch(()=>D([]))},[t]);const O=e[je.TOOLS_SHELL]||"cmd",[F,P]=k.useState([]),[z,K]=k.useState(!0),[q,W]=k.useState(!1),[Z,Q]=k.useState(null),[H,I]=k.useState(new Set),[M,V]=k.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""}),[$,ee]=k.useState(""),[Y,X]=k.useState(""),[U,B]=k.useState(!1),{requestDelete:J,clearConfirm:se,isConfirming:ne}=Au(),ie=k.useCallback(async()=>{try{const Me=((await(await ye("/api/mcp/servers")).json()).servers??[]).sort((ce,Ne)=>ce.name.localeCompare(Ne.name));P(Me)}catch{}K(!1)},[]);k.useEffect(()=>{ie()},[ie]),k.useEffect(()=>{const re=()=>ie();return window.addEventListener("mcp-servers-changed",re),()=>window.removeEventListener("mcp-servers-changed",re)},[ie]);const de=re=>{I(_e=>{const Me=new Set(_e);return Me.has(re)?(Me.delete(re),Me):(Me.add(re),Me)})};function pe(){if(M.transport==="stdio"&&!M.command)return"Command is required for stdio transport";if(M.transport==="http"&&!M.url)return"URL is required for HTTP transport";if(M.timeout){const re=parseFloat(M.timeout);if(isNaN(re)||re<=0)return"Timeout must be a positive number"}return null}function Oe(re){const _e=re?{name:M.name,transport:M.transport}:{transport:M.transport};if(M.transport==="stdio"?(_e.command=M.command,_e.args=M.args?M.args.split(" ").filter(Boolean):[],_e.env=_k(M.env)):(_e.url=M.url,_e.headers=_k(M.headers),_e.oauth=M.oauth),M.timeout){const Me=parseFloat(M.timeout);!isNaN(Me)&&Me>0&&(_e.timeout=Me)}return _e}const $e={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""},Pe=async()=>{if(ee(""),!M.name){ee("Name is required");return}const re=pe();if(re){ee(re);return}B(!0);try{const _e=Oe(!0),Me=await ye("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e)});if(!Me.ok){const ce=await Me.json();throw new Error(ce.error??"Failed to add server")}W(!1),V($e),await ie()}catch(_e){ee(_e instanceof Error?_e.message:String(_e))}finally{B(!1)}},Ve=re=>{var _e;V({name:re.name,transport:re.config.transport,command:re.config.command??"",args:((_e=re.config.args)==null?void 0:_e.join(" "))??"",env:re.config.env?Object.entries(re.config.env).map(([Me,ce])=>`${Me}=${ce}`).join(`
252
+ `):"",url:re.config.url??"",headers:re.config.headers?Object.entries(re.config.headers).map(([Me,ce])=>`${Me}=${ce}`).join(`
253
+ `):"",oauth:re.config.oauth??!1,timeout:re.config.timeout!==void 0?String(re.config.timeout):""}),ee(""),Q(re.name)},Ye=async()=>{ee("");const re=pe();if(re){ee(re);return}B(!0);try{const _e=Oe(!1),Me=await ye(`/api/mcp/servers/${encodeURIComponent(Z)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e)});if(!Me.ok){const ce=await Me.json();throw new Error(ce.error??"Failed to update server")}Q(null),V($e),await ie()}catch(_e){ee(_e instanceof Error?_e.message:String(_e))}finally{B(!1)}},ot=async re=>{try{const _e=await ye(`/api/mcp/servers/${encodeURIComponent(re)}`,{method:"DELETE"});if(!_e.ok){const Me=await _e.json().catch(()=>({}));throw new Error(Me.error??"Failed to remove server")}se(),X(""),await ie()}catch(_e){X(_e instanceof Error?_e.message:String(_e))}},Ae=async(re,_e,Me)=>{try{const ce=await ye(`/api/mcp/servers/${encodeURIComponent(re)}/tools/${encodeURIComponent(_e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Me})});if(!ce.ok){const Ne=await ce.json().catch(()=>({}));throw new Error(Ne.error??"Failed to toggle tool")}X(""),await ie()}catch(ce){X(ce instanceof Error?ce.message:String(ce))}},me=async(re,_e)=>{try{const Me=await ye(`/api/mcp/servers/${encodeURIComponent(re)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:_e})});if(!Me.ok){const ce=await Me.json().catch(()=>({}));throw new Error(ce.error??"Failed to toggle server")}X(""),await ie()}catch(Me){X(Me instanceof Error?Me.message:String(Me))}};return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),s.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(re=>s.jsx("button",{onClick:()=>b(re),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===re?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:re||"Off"},re))})]}),r==="tavily"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(xs,{type:"password",value:o,onChange:re=>d(re.target.value),placeholder:"tvly-...",className:"flex-1"}),s.jsx(ct,{variant:"secondary",onClick:j,style:x?{color:"rgb(63, 185, 80)"}:void 0,children:f})]}),g&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:g}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",s.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),s.jsx(xs,{type:"url",value:u,onChange:re=>c(re.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx(xs,{type:"password",value:h,onChange:re=>m(re.target.value),placeholder:"Optional API key",className:"w-full"})]}),s.jsx(ct,{variant:"secondary",onClick:E,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),v&&s.jsx("p",{className:"text-xs text-red-500",children:v})]})]})]}),A.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Shell used to run agent commands and integrated terminals. Git Bash gives the agent a Unix-like toolset (grep, sed, ls…) and usually works better than cmd.exe."}),s.jsx("div",{className:"flex gap-2",children:A.map(re=>s.jsxs("button",{onClick:()=>n(je.TOOLS_SHELL,re.id),disabled:!re.available,title:re.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${O===re.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":re.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[re.label,!re.available&&" (not found)"]},re.id))}),s.jsx("p",{className:"text-xs text-text-muted mt-2",children:"Applies to new commands and newly opened terminals. Running terminals keep their current shell."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",s.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),N==="checking"&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),N==="available"&&s.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),N==="unavailable"&&s.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),s.jsx(ys,{enabled:e[je.TOOLS_USE_RTK]==="true",onClick:()=>n(je.TOOLS_USE_RTK,e[je.TOOLS_USE_RTK]==="true"?"false":"true")})]}),A.length>0&&e[je.TOOLS_USE_RTK]==="true"&&O!=="gitbash"&&s.jsx("p",{className:"text-xs text-accent-warning mt-1",children:"RTK only rewrites Unix-style commands — with this shell it will rarely apply and can break some commands. Git Bash is recommended."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Agent Confirmations"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Require confirmation for workspace changes and git mutations. When disabled, the agent proceeds without interruption."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Confirm on workspace & git actions"})}),s.jsx(ys,{enabled:e[je.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(je.CONFIRM_ON_WORKSPACE_ACTIONS,e[je.CONFIRM_ON_WORKSPACE_ACTIONS]==="true"?"false":"true")})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary","data-testid":"mcp-servers-heading",children:"MCP Servers"}),s.jsx(ct,{variant:"primary",size:"sm",onClick:()=>W(!0),children:"+ Add Server"})]}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Show per-conversation MCP toggle in chat bar"})}),s.jsx(ys,{enabled:e[je.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(je.FEATURES_PER_SESSION_MCP,e[je.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),Y&&s.jsx(vl,{message:Y}),s.jsx(Db,{loading:z,hasItems:F.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:F.map(re=>{const _e=H.has(re.name)?ne(re.name,"delete")?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ce=>{ce.stopPropagation(),ot(re.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),s.jsx("button",{onClick:ce=>{ce.stopPropagation(),se()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ce=>{ce.stopPropagation(),Ve(re)},className:"px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",children:"Edit"}),s.jsx("button",{onClick:ce=>{ce.stopPropagation(),J(re.name)},className:"px-2 py-1 rounded text-xs font-medium text-accent-error/80 hover:text-accent-error hover:bg-accent-error/10 transition-colors",children:"Remove"})]}):null,Me=re.status==="error"&&re.error?s.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:re.error,children:re.error}):null;return s.jsx(PT,{server:re,expanded:H.has(re.name),onToggleExpand:de,serverToggleEnabled:!re.config.disabled,onServerToggle:()=>me(re.name,!re.config.disabled),tools:re.tools,onToolToggle:ce=>{var Ne;return Ae(re.name,ce,!((Ne=re.tools.find(Xe=>Xe.name===ce))!=null&&Ne.enabled))},statusDot:vv(re.status),statusColor:bv(re.status),authPanel:re.config.oauth?s.jsx(cU,{serverName:re.name,onChanged:ie}):null,actions:s.jsxs(s.Fragment,{children:[Me,_e]})},re.name)})}),q&&s.jsx(Et,{isOpen:q,onClose:()=>{W(!1),ee("")},title:"Add MCP Server",size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(rs,{label:"Name",value:M.name,onChange:re=>V({...M,name:re}),placeholder:"e.g. filesystem"}),s.jsx(Sk,{formData:M,onChange:V}),$&&s.jsx(vl,{message:$}),s.jsx(wk,{saving:U,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{W(!1),ee(""),B(!1),V($e)},onSave:Pe})]})}),Z!==null&&s.jsx(Et,{isOpen:!0,onClose:()=>{Q(null),ee("")},title:`Edit MCP Server: ${Z}`,size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(Sk,{formData:M,onChange:V}),$&&s.jsx(vl,{message:$}),s.jsx(wk,{saving:U,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{Q(null),ee(""),B(!1),V($e)},onSave:Ye})]})})]})]})}const BT="openfox_user_plugins";function dU(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function Bx(e){const t=dU(e);if(!t)return null;try{const n=await fetch(`https://api.github.com/repos/${t.owner}/${t.repo}/releases/latest`,{signal:AbortSignal.timeout(5e3)});return n.ok?(await n.json()).tag_name??null:null}catch{return null}}function _h(){try{return JSON.parse(localStorage.getItem(BT)??"[]")}catch{return[]}}function Ck(e){localStorage.setItem(BT,JSON.stringify(e))}function hU({onAdd:e}){const[t,n]=k.useState(""),[r,a]=k.useState(""),[o,d]=k.useState(!1),u=c=>{c.preventDefault(),!(!t.trim()||!r.trim())&&(e({name:t.trim(),displayName:t.trim(),description:"User-added plugin",githubUrl:r.trim()}),n(""),a(""),d(!0),setTimeout(()=>d(!1),2e3))};return s.jsxs("form",{onSubmit:u,className:"flex gap-2 items-end",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.jsx("input",{type:"text",value:t,onChange:c=>n(c.target.value),placeholder:"my-plugin",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),s.jsxs("div",{className:"flex-[2]",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"GitHub URL"}),s.jsx("input",{type:"text",value:r,onChange:c=>a(c.target.value),placeholder:"https://github.com/user/repo",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),s.jsx(ct,{type:"submit",variant:"primary",size:"sm",children:o?"Added":"Add"})]})}function fU({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[o,d]=k.useState(t?"installed":"idle"),[u,c]=k.useState(!1),[h,m]=k.useState(""),[f,g]=k.useState(n),[x,w]=k.useState(!1),[C,v]=k.useState(!1);k.useEffect(()=>{g(n)},[n]);const S=k.useCallback(async()=>{const O=await ye("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),F=await O.json();if(O.ok)d("installed"),e.latestVersion&&g(e.latestVersion),F.loaded||m(F.loadError??"Plugin installed but failed to load");else throw new Error(F.error??"Install failed")},[e.githubUrl,e.name]),_=async()=>{d("installing"),m("");try{await S()}catch(O){d("error"),m(O instanceof Error?O.message:"Connection error")}},b=()=>{w(!0)},j=async()=>{v(!0);try{(await ye(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(d("idle"),r(e.name))}catch{}v(!1),w(!1)},E=async()=>{c(!0),m("");try{await S()}catch(O){m(O instanceof Error?O.message:"Update failed")}c(!1)},N=f??n,L=e.latestVersion&&N&&N!=="unknown"&&e.latestVersion!==N,A=o==="installing"?"Installing…":u?"Updating…":o==="installed"?"Installed ✓":"Install",D=o==="installing"||o==="installed"||u;return s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&s.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?s.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?s.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,N&&N!=="unknown"&&s.jsxs("span",{className:"text-text-muted",children:["installed: v",N]})]}),o==="error"&&h&&s.jsx("p",{className:"text-xs text-accent-error mt-1",children:h})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[s.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&s.jsx(ct,{variant:o==="installed"?"secondary":"primary",size:"sm",onClick:_,disabled:D,children:A}),L&&s.jsx(ct,{variant:"primary",size:"sm",onClick:E,children:"Update"}),o==="installed"&&s.jsx(ct,{variant:"danger",size:"sm",onClick:b,children:"Remove"})]}),o==="installed"&&s.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),s.jsx(Nl,{isOpen:x,onClose:()=>w(!1),onConfirm:j,title:`Remove "${e.displayName}"?`,message:`Remove the "${e.displayName}" plugin from your installation.`,confirmLabel:"Remove",confirmVariant:"danger",disabled:C})]})}function mU(){const[e,t]=k.useState([]),[n,r]=k.useState([]),[a,o]=k.useState({}),[d,u]=k.useState(!0),[c,h]=k.useState(""),[m,f]=k.useState("");k.useEffect(()=>{let S=!1;Promise.all([ye("/api/plugins/registry").then(b=>{if(!b.ok)throw new Error(`HTTP ${b.status}`);return b.json()}),ye("/api/plugins/installed").then(b=>b.ok?b.json():{installed:[]})]).then(([b,j])=>{if(S)return;const E={},N=j.installed;for(const F of N)E[F.name]=F.version;o(E);const L=b.plugins.map(F=>({...F,latestVersion:null,versionLoading:!0}));t(L),L.forEach(F=>{Bx(F.githubUrl).then(P=>{S||t(z=>z.map(K=>K.name===F.name?{...K,latestVersion:P,versionLoading:!1}:K))})});const A=new Set(L.map(F=>F.name)),D=_h(),O=[];for(const F of N)!A.has(F.name)&&!D.some(P=>P.name===F.name)&&O.push({name:F.name,displayName:F.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});O.length>0&&r(F=>[...F,...O])}).catch(b=>{S||h(b instanceof Error?b.message:"Failed to load plugins")}).finally(()=>{S||u(!1)});const _=_h();return _.length>0&&(r(_.map(b=>({...b,latestVersion:null,versionLoading:!0}))),_.forEach(b=>{Bx(b.githubUrl).then(j=>{S||r(E=>E.map(N=>N.name===b.name?{...N,latestVersion:j,versionLoading:!1}:N))})})),()=>{S=!0}},[]);const g=async S=>{try{S?await ye(`/api/plugins/${S}/open-folder`):await ye("/api/plugins/open-folder")}catch{}},x=k.useCallback(S=>{o(j=>{const E={...j};return delete E[S],E});const _=_h(),b=_.filter(j=>j.name!==S);b.length!==_.length&&Ck(b),r(j=>j.filter(E=>E.name!==S))},[]),w=k.useCallback(S=>{if(new Set(e.map(j=>j.name)).has(S.name)){f(`"${S.displayName}" is already listed in the registry and won't be added again.`);return}const b=_h();Ck([...b,S]),r(j=>[...j,{...S,latestVersion:null,versionLoading:!0}]),Bx(S.githubUrl).then(j=>{r(E=>E.map(N=>N.name===S.name?{...N,latestVersion:j,versionLoading:!1}:N))})},[e]),C=new Set,v=[...e,...n].filter(S=>C.has(S.name)?!1:(C.add(S.name),!0));return d?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading plugins..."}):s.jsxs("div",{className:"space-y-4",children:[c&&s.jsxs("div",{className:"text-sm text-accent-error bg-accent-error/10 border border-accent-error/30 rounded-lg p-3",children:["Failed to load plugin registry: ",c]}),m&&s.jsxs("div",{className:"text-sm text-accent-warning bg-accent-warning/10 border border-accent-warning/30 rounded-lg p-3 flex justify-between items-center",children:[s.jsx("span",{children:m}),s.jsx("button",{onClick:()=>f(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),s.jsx(hU,{onAdd:w})]}),v.length===0&&!c&&s.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),v.map(S=>s.jsx(fU,{plugin:S,initiallyInstalled:S.name in a,installedVersion:a[S.name]??null,onRemove:x,onOpenFolder:g},S.name))]})}function pU({isOpen:e,onClose:t}){const[n,r]=k.useState("instructions"),a=Si(d=>d.status==="available"),o=()=>{try{zt.send("context.checkDynamic",{})}catch{}t()};return s.jsx(Et,{isOpen:e,onClose:o,title:"Settings",size:"xl",scrollable:!1,children:s.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full min-h-0 -m-4",children:[s.jsxs(mt,{horizontal:!0,options:{scrollbars:{visibility:"hidden"}},className:"flex border-b border-border mb-4 flex-shrink-0 px-4 pt-4",children:[s.jsx(Xi,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),s.jsx(Xi,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),s.jsx(Xi,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),s.jsx(Xi,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),s.jsx(Xi,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),s.jsx(Xi,{label:"Display",active:n==="display",onClick:()=>r("display")}),s.jsx(Xi,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),s.jsx(Xi,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),s.jsxs(mt,{className:"flex-1 min-h-0 px-4 pb-4",children:[n==="instructions"&&s.jsx(IO,{isOpen:e}),n==="skills"&&s.jsx(MO,{isOpen:e}),n==="plugins"&&s.jsx(mU,{}),n==="notifications"&&s.jsx(kO,{}),n==="display"&&s.jsx(XO,{}),n==="keybindings"&&s.jsx(lU,{}),n==="tools"&&s.jsx(uU,{}),n==="advanced"&&s.jsx(iU,{onClose:t})]})]})})}function Xi({label:e,active:t,onClick:n,showDot:r}){return s.jsxs("button",{onClick:n,className:`relative px-4 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:[e,r&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]})}var $x={exports:{}},kk;function gU(){return kk||(kk=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(d,u,c){var h=this&&this.__decorate||function(_,b,j,E){var N,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,j,E);else for(var D=_.length-1;D>=0;D--)(N=_[D])&&(A=(L<3?N(A):L>3?N(b,j,A):N(b,j))||A);return L>3&&A&&Object.defineProperty(b,j,A),A},m=this&&this.__param||function(_,b){return function(j,E){b(j,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.AccessibilityManager=void 0;const f=c(9042),g=c(9924),x=c(844),w=c(4725),C=c(2585),v=c(3656);let S=u.AccessibilityManager=class extends x.Disposable{constructor(_,b,j,E){super(),this._terminal=_,this._coreBrowserService=j,this._renderService=E,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new g.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
254
+ `)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,v.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,x.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(_){for(let b=0;b<_;b++)this._handleChar(" ")}_handleChar(_){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==_&&(this._charsToAnnounce+=_):this._charsToAnnounce+=_,_===`
255
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=f.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(_){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(_)||this._charsToConsume.push(_)}_refreshRows(_,b){this._liveRegionDebouncer.refresh(_,b,this._terminal.rows)}_renderRows(_,b){const j=this._terminal.buffer,E=j.lines.length.toString();for(let N=_;N<=b;N++){const L=j.lines.get(j.ydisp+N),A=[],D=(L==null?void 0:L.translateToString(!0,void 0,void 0,A))||"",O=(j.ydisp+N+1).toString(),F=this._rowElements[N];F&&(D.length===0?(F.innerText=" ",this._rowColumns.set(F,[0,1])):(F.textContent=D,this._rowColumns.set(F,A)),F.setAttribute("aria-posinset",O),F.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(_,b){const j=_.target,E=this._rowElements[b===0?1:this._rowElements.length-2];if(j.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||_.relatedTarget!==E)return;let N,L;if(b===0?(N=j,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(N=this._rowElements.shift(),L=j,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const A=this._createAccessibilityTreeNode();this._rowElements.unshift(A),this._rowContainer.insertAdjacentElement("afterbegin",A)}else{const A=this._createAccessibilityTreeNode();this._rowElements.push(A),this._rowContainer.appendChild(A)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),_.preventDefault(),_.stopImmediatePropagation()}_handleSelectionChange(){var D;if(this._rowElements.length===0)return;const _=document.getSelection();if(!_)return;if(_.isCollapsed)return void(this._rowContainer.contains(_.anchorNode)&&this._terminal.clearSelection());if(!_.anchorNode||!_.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:_.anchorNode,offset:_.anchorOffset},j={node:_.focusNode,offset:_.focusOffset};if((b.node.compareDocumentPosition(j.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===j.node&&b.offset>j.offset)&&([b,j]=[j,b]),b.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(b={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(b.node))return;const E=this._rowElements.slice(-1)[0];if(j.node.compareDocumentPosition(E)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(j={node:E,offset:((D=E.textContent)==null?void 0:D.length)??0}),!this._rowContainer.contains(j.node))return;const N=({node:O,offset:F})=>{const P=O instanceof Text?O.parentNode:O;let z=parseInt(P==null?void 0:P.getAttribute("aria-posinset"),10)-1;if(isNaN(z))return console.warn("row is invalid. Race condition?"),null;const K=this._rowColumns.get(P);if(!K)return console.warn("columns is null. Race condition?"),null;let q=F<K.length?K[F]:K.slice(-1)[0]+1;return q>=this._terminal.cols&&(++z,q=0),{row:z,column:q}},L=N(b),A=N(j);if(L&&A){if(L.row>A.row||L.row===A.row&&L.column>=A.column)throw new Error("invalid range");this._terminal.select(L.column,L.row,(A.row-L.row)*this._terminal.cols-L.column+A.column)}}_handleResize(_){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>_;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const _=this._coreBrowserService.mainDocument.createElement("div");return _.setAttribute("role","listitem"),_.tabIndex=-1,this._refreshRowDimensions(_),_}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let _=0;_<this._terminal.rows;_++)this._refreshRowDimensions(this._rowElements[_])}}_refreshRowDimensions(_){_.style.height=`${this._renderService.dimensions.css.cell.height}px`}};u.AccessibilityManager=S=h([m(1,C.IInstantiationService),m(2,w.ICoreBrowserService),m(3,w.IRenderService)],S)},3614:(d,u)=>{function c(g){return g.replace(/\r?\n/g,"\r")}function h(g,x){return x?"\x1B[200~"+g+"\x1B[201~":g}function m(g,x,w,C){g=h(g=c(g),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(g,!0),x.value=""}function f(g,x,w){const C=w.getBoundingClientRect(),v=g.clientX-C.left-10,S=g.clientY-C.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${v}px`,x.style.top=`${S}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(u,"__esModule",{value:!0}),u.rightClickHandler=u.moveTextAreaUnderMouseCursor=u.paste=u.handlePasteEvent=u.copyHandler=u.bracketTextForPaste=u.prepareTextForTerminal=void 0,u.prepareTextForTerminal=c,u.bracketTextForPaste=h,u.copyHandler=function(g,x){g.clipboardData&&g.clipboardData.setData("text/plain",x.selectionText),g.preventDefault()},u.handlePasteEvent=function(g,x,w,C){g.stopPropagation(),g.clipboardData&&m(g.clipboardData.getData("text/plain"),x,w,C)},u.paste=m,u.moveTextAreaUnderMouseCursor=f,u.rightClickHandler=function(g,x,w,C,v){f(g,x,w),v&&C.rightClickSelect(g),x.value=C.selectionText,x.select()}},7239:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ColorContrastCache=void 0;const h=c(1505);u.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(m,f,g){this._css.set(m,f,g)}getCss(m,f){return this._css.get(m,f)}setColor(m,f,g){this._color.set(m,f,g)}getColor(m,f){return this._color.get(m,f)}clear(){this._color.clear(),this._css.clear()}}},3656:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.addDisposableDomListener=void 0,u.addDisposableDomListener=function(c,h,m,f){c.addEventListener(h,m,f);let g=!1;return{dispose:()=>{g||(g=!0,c.removeEventListener(h,m,f))}}}},3551:function(d,u,c){var h=this&&this.__decorate||function(S,_,b,j){var E,N=arguments.length,L=N<3?_:j===null?j=Object.getOwnPropertyDescriptor(_,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,_,b,j);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(L=(N<3?E(L):N>3?E(_,b,L):E(_,b))||L);return N>3&&L&&Object.defineProperty(_,b,L),L},m=this&&this.__param||function(S,_){return function(b,j){_(b,j,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Linkifier=void 0;const f=c(3656),g=c(8460),x=c(844),w=c(2585),C=c(4725);let v=u.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(S,_,b,j,E){super(),this._element=S,this._mouseService=_,this._renderService=b,this._bufferService=j,this._linkProviderService=E,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,f.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,f.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,f.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,f.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(S){this._lastMouseEvent=S;const _=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!_)return;this._isMouseOut=!1;const b=S.composedPath();for(let j=0;j<b.length;j++){const E=b[j];if(E.classList.contains("xterm"))break;if(E.classList.contains("xterm-hover"))return}this._lastBufferCell&&_.x===this._lastBufferCell.x&&_.y===this._lastBufferCell.y||(this._handleHover(_),this._lastBufferCell=_)}_handleHover(S){if(this._activeLine!==S.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(S,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,S)||(this._clearCurrentLink(),this._askForLink(S,!0))}_askForLink(S,_){var j,E;this._activeProviderReplies&&_||((j=this._activeProviderReplies)==null||j.forEach((N=>{N==null||N.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let b=!1;for(const[N,L]of this._linkProviderService.linkProviders.entries())_?(E=this._activeProviderReplies)!=null&&E.get(N)&&(b=this._checkLinkProviderResult(N,S,b)):L.provideLinks(S.y,(A=>{var O,F;if(this._isMouseOut)return;const D=A==null?void 0:A.map((P=>({link:P})));(O=this._activeProviderReplies)==null||O.set(N,D),b=this._checkLinkProviderResult(N,S,b),((F=this._activeProviderReplies)==null?void 0:F.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,_){const b=new Set;for(let j=0;j<_.size;j++){const E=_.get(j);if(E)for(let N=0;N<E.length;N++){const L=E[N],A=L.link.range.start.y<S?0:L.link.range.start.x,D=L.link.range.end.y>S?this._bufferService.cols:L.link.range.end.x;for(let O=A;O<=D;O++){if(b.has(O)){E.splice(N--,1);break}b.add(O)}}}}_checkLinkProviderResult(S,_,b){var N;if(!this._activeProviderReplies)return b;const j=this._activeProviderReplies.get(S);let E=!1;for(let L=0;L<S;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(E=!0);if(!E&&j){const L=j.find((A=>this._linkAtPosition(A.link,_)));L&&(b=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!b)for(let L=0;L<this._activeProviderReplies.size;L++){const A=(N=this._activeProviderReplies.get(L))==null?void 0:N.find((D=>this._linkAtPosition(D.link,_)));if(A){b=!0,this._handleNewLink(A);break}}return b}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const _=this._positionFromMouseEvent(S,this._element,this._mouseService);_&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,_)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,_){this._currentLink&&this._lastMouseEvent&&(!S||!_||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=_)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(S){if(!this._lastMouseEvent)return;const _=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);_&&this._linkAtPosition(S.link,_)&&(this._currentLink=S,this._currentLink.state={decorations:{underline:S.link.decorations===void 0||S.link.decorations.underline,pointerCursor:S.link.decorations===void 0||S.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,S.link,this._lastMouseEvent),S.link.decorations={},Object.defineProperties(S.link.decorations,{pointerCursor:{get:()=>{var b,j;return(j=(b=this._currentLink)==null?void 0:b.state)==null?void 0:j.decorations.pointerCursor},set:b=>{var j;(j=this._currentLink)!=null&&j.state&&this._currentLink.state.decorations.pointerCursor!==b&&(this._currentLink.state.decorations.pointerCursor=b,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",b))}},underline:{get:()=>{var b,j;return(j=(b=this._currentLink)==null?void 0:b.state)==null?void 0:j.decorations.underline},set:b=>{var j,E,N;(j=this._currentLink)!=null&&j.state&&((N=(E=this._currentLink)==null?void 0:E.state)==null?void 0:N.decorations.underline)!==b&&(this._currentLink.state.decorations.underline=b,this._currentLink.state.isHovered&&this._fireUnderlineEvent(S.link,b))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((b=>{if(!this._currentLink)return;const j=b.start===0?0:b.start+1+this._bufferService.buffer.ydisp,E=this._bufferService.buffer.ydisp+1+b.end;if(this._currentLink.link.range.start.y>=j&&this._currentLink.link.range.end.y<=E&&(this._clearCurrentLink(j,E),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(S,_,b){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),_.hover&&_.hover(b,_.text)}_fireUnderlineEvent(S,_){const b=S.range,j=this._bufferService.buffer.ydisp,E=this._createLinkUnderlineEvent(b.start.x-1,b.start.y-j-1,b.end.x,b.end.y-j-1,void 0);(_?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(E)}_linkLeave(S,_,b){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),_.leave&&_.leave(b,_.text)}_linkAtPosition(S,_){const b=S.range.start.y*this._bufferService.cols+S.range.start.x,j=S.range.end.y*this._bufferService.cols+S.range.end.x,E=_.y*this._bufferService.cols+_.x;return b<=E&&E<=j}_positionFromMouseEvent(S,_,b){const j=b.getCoords(S,_,this._bufferService.cols,this._bufferService.rows);if(j)return{x:j[0],y:j[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,_,b,j,E){return{x1:S,y1:_,x2:b,y2:j,cols:this._bufferService.cols,fg:E}}};u.Linkifier=v=h([m(1,C.IMouseService),m(2,C.IRenderService),m(3,w.IBufferService),m(4,C.ILinkProviderService)],v)},9042:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.tooMuchOutput=u.promptLabel=void 0,u.promptLabel="Terminal input",u.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(d,u,c){var h=this&&this.__decorate||function(C,v,S,_){var b,j=arguments.length,E=j<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,_);else for(var N=C.length-1;N>=0;N--)(b=C[N])&&(E=(j<3?b(E):j>3?b(v,S,E):b(v,S))||E);return j>3&&E&&Object.defineProperty(v,S,E),E},m=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkProvider=void 0;const f=c(511),g=c(2585);let x=u.OscLinkProvider=class{constructor(C,v,S){this._bufferService=C,this._optionsService=v,this._oscLinkService=S}provideLinks(C,v){var D;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void v(void 0);const _=[],b=this._optionsService.rawOptions.linkHandler,j=new f.CellData,E=S.getTrimmedLength();let N=-1,L=-1,A=!1;for(let O=0;O<E;O++)if(L!==-1||S.hasContent(O)){if(S.loadCell(O,j),j.hasExtendedAttrs()&&j.extended.urlId){if(L===-1){L=O,N=j.extended.urlId;continue}A=j.extended.urlId!==N}else L!==-1&&(A=!0);if(A||L!==-1&&O===E-1){const F=(D=this._oscLinkService.getLinkData(N))==null?void 0:D.uri;if(F){const P={start:{x:L+1,y:C},end:{x:O+(A||O!==E-1?0:1),y:C}};let z=!1;if(!(b!=null&&b.allowNonHttpProtocols))try{const K=new URL(F);["http:","https:"].includes(K.protocol)||(z=!0)}catch{z=!0}z||_.push({text:F,range:P,activate:(K,q)=>b?b.activate(K,q,P):w(0,q),hover:(K,q)=>{var W;return(W=b==null?void 0:b.hover)==null?void 0:W.call(b,K,q,P)},leave:(K,q)=>{var W;return(W=b==null?void 0:b.leave)==null?void 0:W.call(b,K,q,P)}})}A=!1,j.hasExtendedAttrs()&&j.extended.urlId?(L=O,N=j.extended.urlId):(L=-1,N=-1)}}v(_)}};function w(C,v){if(confirm(`Do you want to navigate to ${v}?
256
+
257
+ WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=v}else console.warn("Opening link blocked as opener could not be cleared")}}u.OscLinkProvider=x=h([m(0,g.IBufferService),m(1,g.IOptionsService),m(2,g.IOscLinkService)],x)},6193:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.RenderDebouncer=void 0,u.RenderDebouncer=class{constructor(c,h){this._renderCallback=c,this._coreBrowserService=h,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(c){return this._refreshCallbacks.push(c),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(c,h,m){this._rowCount=m,c=c!==void 0?c:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,c):c,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const c=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(c,h),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const c of this._refreshCallbacks)c(0);this._refreshCallbacks=[]}}},3236:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const h=c(3614),m=c(3656),f=c(3551),g=c(9042),x=c(3730),w=c(1680),C=c(3107),v=c(5744),S=c(2950),_=c(1296),b=c(428),j=c(4269),E=c(5114),N=c(8934),L=c(3230),A=c(9312),D=c(4725),O=c(6731),F=c(8055),P=c(8969),z=c(8460),K=c(844),q=c(6114),W=c(8437),Z=c(2584),Q=c(7399),H=c(5941),I=c(9074),M=c(2585),V=c(5435),$=c(4567),ee=c(779);class Y extends P.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(U={}){super(U),this.browser=q,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new K.MutableDisposable),this._onCursorMove=this.register(new z.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new z.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new z.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new z.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new z.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new z.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new z.EventEmitter),this._onBlur=this.register(new z.EventEmitter),this._onA11yCharEmitter=this.register(new z.EventEmitter),this._onA11yTabEmitter=this.register(new z.EventEmitter),this._onWillOpen=this.register(new z.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(I.DecorationService),this._instantiationService.setService(M.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ee.LinkProviderService),this._instantiationService.setService(D.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((B,J)=>this.refresh(B,J)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((B=>this._reportWindowsOptions(B)))),this.register(this._inputHandler.onColor((B=>this._handleColorEvent(B)))),this.register((0,z.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,z.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,z.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,z.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((B=>this._afterResize(B.cols,B.rows)))),this.register((0,K.toDisposable)((()=>{var B,J;this._customKeyEventHandler=void 0,(J=(B=this.element)==null?void 0:B.parentNode)==null||J.removeChild(this.element)})))}_handleColorEvent(U){if(this._themeService)for(const B of U){let J,se="";switch(B.index){case 256:J="foreground",se="10";break;case 257:J="background",se="11";break;case 258:J="cursor",se="12";break;default:J="ansi",se="4;"+B.index}switch(B.type){case 0:const ne=F.color.toColorRGB(J==="ansi"?this._themeService.colors.ansi[B.index]:this._themeService.colors[J]);this.coreService.triggerDataEvent(`${Z.C0.ESC}]${se};${(0,H.toRgbString)(ne)}${Z.C1_ESCAPED.ST}`);break;case 1:if(J==="ansi")this._themeService.modifyColors((ie=>ie.ansi[B.index]=F.channels.toColor(...B.color)));else{const ie=J;this._themeService.modifyColors((de=>de[ie]=F.channels.toColor(...B.color)))}break;case 2:this._themeService.restoreColor(B.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(U){U?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(U){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var U;return(U=this.textarea)==null?void 0:U.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const U=this.buffer.ybase+this.buffer.y,B=this.buffer.lines.get(U);if(!B)return;const J=Math.min(this.buffer.x,this.cols-1),se=this._renderService.dimensions.css.cell.height,ne=B.getWidth(J),ie=this._renderService.dimensions.css.cell.width*ne,de=this.buffer.y*this._renderService.dimensions.css.cell.height,pe=J*this._renderService.dimensions.css.cell.width;this.textarea.style.left=pe+"px",this.textarea.style.top=de+"px",this.textarea.style.width=ie+"px",this.textarea.style.height=se+"px",this.textarea.style.lineHeight=se+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,m.addDisposableDomListener)(this.element,"copy",(B=>{this.hasSelection()&&(0,h.copyHandler)(B,this._selectionService)})));const U=B=>(0,h.handlePasteEvent)(B,this.textarea,this.coreService,this.optionsService);this.register((0,m.addDisposableDomListener)(this.textarea,"paste",U)),this.register((0,m.addDisposableDomListener)(this.element,"paste",U)),q.isFirefox?this.register((0,m.addDisposableDomListener)(this.element,"mousedown",(B=>{B.button===2&&(0,h.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,m.addDisposableDomListener)(this.element,"contextmenu",(B=>{(0,h.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),q.isLinux&&this.register((0,m.addDisposableDomListener)(this.element,"auxclick",(B=>{B.button===1&&(0,h.moveTextAreaUnderMouseCursor)(B,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,m.addDisposableDomListener)(this.textarea,"keyup",(U=>this._keyUp(U)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keydown",(U=>this._keyDown(U)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keypress",(U=>this._keyPress(U)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionupdate",(U=>this._compositionHelper.compositionupdate(U)))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,m.addDisposableDomListener)(this.textarea,"input",(U=>this._inputEvent(U)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(U){var J;if(!U)throw new Error("Terminal requires a parent element.");if(U.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((J=this.element)==null?void 0:J.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=U.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"),U.appendChild(this.element);const B=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),B.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,m.addDisposableDomListener)(this.screenElement,"mousemove",(se=>this.updateCursorStyle(se)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),B.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),q.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(E.CoreBrowserService,this.textarea,U.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(D.ICoreBrowserService,this._coreBrowserService),this.register((0,m.addDisposableDomListener)(this.textarea,"focus",(se=>this._handleTextAreaFocus(se)))),this.register((0,m.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(b.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(D.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(O.ThemeService),this._instantiationService.setService(D.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(j.CharacterJoinerService),this._instantiationService.setService(D.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(L.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(D.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((se=>this._onRender.fire(se)))),this.onResize((se=>this._renderService.resize(se.cols,se.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(S.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(N.MouseService),this._instantiationService.setService(D.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(f.Linkifier,this.screenElement)),this.element.appendChild(B);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(A.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(D.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((se=>this._renderService.handleSelectionChanged(se.start,se.end,se.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((se=>{this.textarea.value=se,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((se=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,m.addDisposableDomListener)(this.element,"mousedown",(se=>this._selectionService.handleMouseDown(se)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(se=>this._handleScreenReaderModeOptionChange(se)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(se=>{!this._overviewRulerRenderer&&se&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(_.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const U=this,B=this.element;function J(ie){const de=U._mouseService.getMouseReportCoords(ie,U.screenElement);if(!de)return!1;let pe,Oe;switch(ie.overrideType||ie.type){case"mousemove":Oe=32,ie.buttons===void 0?(pe=3,ie.button!==void 0&&(pe=ie.button<3?ie.button:3)):pe=1&ie.buttons?0:4&ie.buttons?1:2&ie.buttons?2:3;break;case"mouseup":Oe=0,pe=ie.button<3?ie.button:3;break;case"mousedown":Oe=1,pe=ie.button<3?ie.button:3;break;case"wheel":if(U._customWheelEventHandler&&U._customWheelEventHandler(ie)===!1||U.viewport.getLinesScrolled(ie)===0)return!1;Oe=ie.deltaY<0?0:1,pe=4;break;default:return!1}return!(Oe===void 0||pe===void 0||pe>4)&&U.coreMouseService.triggerMouseEvent({col:de.col,row:de.row,x:de.x,y:de.y,button:pe,action:Oe,ctrl:ie.ctrlKey,alt:ie.altKey,shift:ie.shiftKey})}const se={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ne={mouseup:ie=>(J(ie),ie.buttons||(this._document.removeEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.removeEventListener("mousemove",se.mousedrag)),this.cancel(ie)),wheel:ie=>(J(ie),this.cancel(ie,!0)),mousedrag:ie=>{ie.buttons&&J(ie)},mousemove:ie=>{ie.buttons||J(ie)}};this.register(this.coreMouseService.onProtocolChange((ie=>{ie?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ie)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&ie?se.mousemove||(B.addEventListener("mousemove",ne.mousemove),se.mousemove=ne.mousemove):(B.removeEventListener("mousemove",se.mousemove),se.mousemove=null),16&ie?se.wheel||(B.addEventListener("wheel",ne.wheel,{passive:!1}),se.wheel=ne.wheel):(B.removeEventListener("wheel",se.wheel),se.wheel=null),2&ie?se.mouseup||(se.mouseup=ne.mouseup):(this._document.removeEventListener("mouseup",se.mouseup),se.mouseup=null),4&ie?se.mousedrag||(se.mousedrag=ne.mousedrag):(this._document.removeEventListener("mousemove",se.mousedrag),se.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,m.addDisposableDomListener)(B,"mousedown",(ie=>{if(ie.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ie))return J(ie),se.mouseup&&this._document.addEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.addEventListener("mousemove",se.mousedrag),this.cancel(ie)}))),this.register((0,m.addDisposableDomListener)(B,"wheel",(ie=>{if(!se.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(ie)===!1)return!1;if(!this.buffer.hasScrollback){const de=this.viewport.getLinesScrolled(ie);if(de===0)return;const pe=Z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ie.deltaY<0?"A":"B");let Oe="";for(let $e=0;$e<Math.abs(de);$e++)Oe+=pe;return this.coreService.triggerDataEvent(Oe,!0),this.cancel(ie,!0)}return this.viewport.handleWheel(ie)?this.cancel(ie):void 0}}),{passive:!1})),this.register((0,m.addDisposableDomListener)(B,"touchstart",(ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ie),this.cancel(ie)}),{passive:!0})),this.register((0,m.addDisposableDomListener)(B,"touchmove",(ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ie)?void 0:this.cancel(ie)}),{passive:!1}))}refresh(U,B){var J;(J=this._renderService)==null||J.refreshRows(U,B)}updateCursorStyle(U){var B;(B=this._selectionService)!=null&&B.shouldColumnSelect(U)?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(U,B,J=0){var se;J===1?(super.scrollLines(U,B,J),this.refresh(0,this.rows-1)):(se=this.viewport)==null||se.scrollLines(U)}paste(U){(0,h.paste)(U,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(U){this._customKeyEventHandler=U}attachCustomWheelEventHandler(U){this._customWheelEventHandler=U}registerLinkProvider(U){return this._linkProviderService.registerLinkProvider(U)}registerCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const B=this._characterJoinerService.register(U);return this.refresh(0,this.rows-1),B}deregisterCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(U)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(U){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+U)}registerDecoration(U){return this._decorationService.registerDecoration(U)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(U,B,J){this._selectionService.setSelection(U,B,J)}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 U;(U=this._selectionService)==null||U.clearSelection()}selectAll(){var U;(U=this._selectionService)==null||U.selectAll()}selectLines(U,B){var J;(J=this._selectionService)==null||J.selectLines(U,B)}_keyDown(U){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;const B=this.browser.isMac&&this.options.macOptionIsMeta&&U.altKey;if(!B&&!this._compositionHelper.keydown(U))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;B||U.key!=="Dead"&&U.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const J=(0,Q.evaluateKeyboardEvent)(U,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(U),J.type===3||J.type===2){const se=this.rows-1;return this.scrollLines(J.type===2?-se:se),this.cancel(U,!0)}return J.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,U)||(J.cancel&&this.cancel(U,!0),!J.key||!!(U.key&&!U.ctrlKey&&!U.altKey&&!U.metaKey&&U.key.length===1&&U.key.charCodeAt(0)>=65&&U.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(J.key!==Z.C0.ETX&&J.key!==Z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:J.key,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(J.key,!0),!this.optionsService.rawOptions.screenReaderMode||U.altKey||U.ctrlKey?this.cancel(U,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(U,B){const J=U.isMac&&!this.options.macOptionIsMeta&&B.altKey&&!B.ctrlKey&&!B.metaKey||U.isWindows&&B.altKey&&B.ctrlKey&&!B.metaKey||U.isWindows&&B.getModifierState("AltGraph");return B.type==="keypress"?J:J&&(!B.keyCode||B.keyCode>47)}_keyUp(U){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1||((function(B){return B.keyCode===16||B.keyCode===17||B.keyCode===18})(U)||this.focus(),this.updateCursorStyle(U),this._keyPressHandled=!1)}_keyPress(U){let B;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;if(this.cancel(U),U.charCode)B=U.charCode;else if(U.which===null||U.which===void 0)B=U.keyCode;else{if(U.which===0||U.charCode===0)return!1;B=U.which}return!(!B||(U.altKey||U.ctrlKey||U.metaKey)&&!this._isThirdLevelShift(this.browser,U)||(B=String.fromCharCode(B),this._onKey.fire({key:B,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(B,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(U){if(U.data&&U.inputType==="insertText"&&(!U.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const B=U.data;return this.coreService.triggerDataEvent(B,!0),this.cancel(U),!0}return!1}resize(U,B){U!==this.cols||B!==this.rows?super.resize(U,B):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(U,B){var J,se;(J=this._charSizeService)==null||J.measure(),(se=this.viewport)==null||se.syncScrollArea(!0)}clear(){var U;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 B=1;B<this.rows;B++)this.buffer.lines.push(this.buffer.getBlankLine(W.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(U=this.viewport)==null||U.reset(),this.refresh(0,this.rows-1)}}reset(){var B,J;this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),(B=this._selectionService)==null||B.reset(),this._decorationService.reset(),(J=this.viewport)==null||J.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){var U;(U=this._renderService)==null||U.clearTextureAtlas()}_reportFocus(){var U;(U=this.element)!=null&&U.classList.contains("focus")?this.coreService.triggerDataEvent(Z.C0.ESC+"[I"):this.coreService.triggerDataEvent(Z.C0.ESC+"[O")}_reportWindowsOptions(U){if(this._renderService)switch(U){case V.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const B=this._renderService.dimensions.css.canvas.width.toFixed(0),J=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[4;${J};${B}t`);break;case V.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const se=this._renderService.dimensions.css.cell.width.toFixed(0),ne=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[6;${ne};${se}t`)}}cancel(U,B){if(this.options.cancelEvents||B)return U.preventDefault(),U.stopPropagation(),!1}}u.Terminal=Y},9924:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.TimeBasedDebouncer=void 0,u.TimeBasedDebouncer=class{constructor(c,h=1e3){this._renderCallback=c,this._debounceThresholdMS=h,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(c,h,m){this._rowCount=m,c=c!==void 0?c:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,c):c,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h;const f=Date.now();if(f-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=f,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=f-this._lastRefreshMs,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const c=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(c,h)}}},1680:function(d,u,c){var h=this&&this.__decorate||function(S,_,b,j){var E,N=arguments.length,L=N<3?_:j===null?j=Object.getOwnPropertyDescriptor(_,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,_,b,j);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(L=(N<3?E(L):N>3?E(_,b,L):E(_,b))||L);return N>3&&L&&Object.defineProperty(_,b,L),L},m=this&&this.__param||function(S,_){return function(b,j){_(b,j,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Viewport=void 0;const f=c(3656),g=c(4725),x=c(8460),w=c(844),C=c(2585);let v=u.Viewport=class extends w.Disposable{constructor(S,_,b,j,E,N,L,A){super(),this._viewportElement=S,this._scrollArea=_,this._bufferService=b,this._optionsService=j,this._charSizeService=E,this._renderService=N,this._coreBrowserService=L,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((D=>this._activeBuffer=D.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((D=>this._renderDimensions=D))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((D=>this._handleThemeChange(D)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(S){if(S)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const _=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==_&&(this._lastRecordedBufferHeight=_,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const S=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==S&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=S),this._refreshAnimationFrame=null}syncScrollArea(S=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(S);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(S)}_handleScroll(S){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const _=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:_,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const S=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(S*(this._smoothScrollState.target-this._smoothScrollState.origin)),S<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(S,_){const b=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(_<0&&this._viewportElement.scrollTop!==0||_>0&&b<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const _=this._getPixelsScrolled(S);return _!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+_:this._smoothScrollState.target+=_,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=_,this._bubbleScroll(S,_))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const _=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+_,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:S,suppressScrollEvent:!1})}_getPixelsScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let _=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?_*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(_*=this._currentRowHeight*this._bufferService.rows),_}getBufferElements(S,_){var A;let b,j="";const E=[],N=_??this._bufferService.buffer.lines.length,L=this._bufferService.buffer.lines;for(let D=S;D<N;D++){const O=L.get(D);if(!O)continue;const F=(A=L.get(D+1))==null?void 0:A.isWrapped;if(j+=O.translateToString(!F),!F||D===L.length-1){const P=document.createElement("div");P.textContent=j,E.push(P),j.length>0&&(b=P),j=""}}return{bufferElements:E,cursorElement:b}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let _=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(_/=this._currentRowHeight+0,this._wheelPartialScroll+=_,_=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(_*=this._bufferService.rows),_}_applyScrollModifier(S,_){const b=this._optionsService.rawOptions.fastScrollModifier;return b==="alt"&&_.altKey||b==="ctrl"&&_.ctrlKey||b==="shift"&&_.shiftKey?S*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:S*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(S){this._lastTouchY=S.touches[0].pageY}handleTouchMove(S){const _=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,_!==0&&(this._viewportElement.scrollTop+=_,this._bubbleScroll(S,_))}};u.Viewport=v=h([m(2,C.IBufferService),m(3,C.IOptionsService),m(4,g.ICharSizeService),m(5,g.IRenderService),m(6,g.ICoreBrowserService),m(7,g.IThemeService)],v)},3107:function(d,u,c){var h=this&&this.__decorate||function(C,v,S,_){var b,j=arguments.length,E=j<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,_);else for(var N=C.length-1;N>=0;N--)(b=C[N])&&(E=(j<3?b(E):j>3?b(v,S,E):b(v,S))||E);return j>3&&E&&Object.defineProperty(v,S,E),E},m=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferDecorationRenderer=void 0;const f=c(4725),g=c(844),x=c(2585);let w=u.BufferDecorationRenderer=class extends g.Disposable{constructor(C,v,S,_,b){super(),this._screenElement=C,this._bufferService=v,this._coreBrowserService=S,this._decorationService=_,this._renderService=b,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((j=>this._removeDecoration(j)))),this.register((0,g.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var _;const v=this._coreBrowserService.mainDocument.createElement("div");v.classList.add("xterm-decoration"),v.classList.toggle("xterm-decoration-top-layer",((_=C==null?void 0:C.options)==null?void 0:_.layer)==="top"),v.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,v.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",v.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",v.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=C.options.x??0;return S&&S>this._bufferService.cols&&(v.style.display="none"),this._refreshXPosition(C,v),v}_refreshStyle(C){const v=C.marker.line-this._bufferService.buffers.active.ydisp;if(v<0||v>=this._bufferService.rows)C.element&&(C.element.style.display="none",C.onRenderEmitter.fire(C.element));else{let S=this._decorationElements.get(C);S||(S=this._createElement(C),C.element=S,this._decorationElements.set(C,S),this._container.appendChild(S),C.onDispose((()=>{this._decorationElements.delete(C),S.remove()}))),S.style.top=v*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(S)}}_refreshXPosition(C,v=C.element){if(!v)return;const S=C.options.x??0;(C.options.anchor||"left")==="right"?v.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":v.style.left=S?S*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var v;(v=this._decorationElements.get(C))==null||v.remove(),this._decorationElements.delete(C),C.dispose()}};u.BufferDecorationRenderer=w=h([m(1,x.IBufferService),m(2,f.ICoreBrowserService),m(3,x.IDecorationService),m(4,f.IRenderService)],w)},5871:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ColorZoneStore=void 0,u.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(c){if(c.options.overviewRulerOptions){for(const h of this._zones)if(h.color===c.options.overviewRulerOptions.color&&h.position===c.options.overviewRulerOptions.position){if(this._lineIntersectsZone(h,c.marker.line))return;if(this._lineAdjacentToZone(h,c.marker.line,c.options.overviewRulerOptions.position))return void this._addLineToZone(h,c.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=c.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=c.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=c.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=c.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:c.options.overviewRulerOptions.color,position:c.options.overviewRulerOptions.position,startBufferLine:c.marker.line,endBufferLine:c.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(c){this._linePadding=c}_lineIntersectsZone(c,h){return h>=c.startBufferLine&&h<=c.endBufferLine}_lineAdjacentToZone(c,h,m){return h>=c.startBufferLine-this._linePadding[m||"full"]&&h<=c.endBufferLine+this._linePadding[m||"full"]}_addLineToZone(c,h){c.startBufferLine=Math.min(c.startBufferLine,h),c.endBufferLine=Math.max(c.endBufferLine,h)}}},5744:function(d,u,c){var h=this&&this.__decorate||function(b,j,E,N){var L,A=arguments.length,D=A<3?j:N===null?N=Object.getOwnPropertyDescriptor(j,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(b,j,E,N);else for(var O=b.length-1;O>=0;O--)(L=b[O])&&(D=(A<3?L(D):A>3?L(j,E,D):L(j,E))||D);return A>3&&D&&Object.defineProperty(j,E,D),D},m=this&&this.__param||function(b,j){return function(E,N){j(E,N,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OverviewRulerRenderer=void 0;const f=c(5871),g=c(4725),x=c(844),w=c(2585),C={full:0,left:0,center:0,right:0},v={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let _=u.OverviewRulerRenderer=class extends x.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,j,E,N,L,A,D){var F;super(),this._viewportElement=b,this._screenElement=j,this._bufferService=E,this._decorationService=N,this._renderService=L,this._optionsService=A,this._coreBrowserService=D,this._colorZoneStore=new f.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(F=this._viewportElement.parentElement)==null||F.insertBefore(this._canvas,this._viewportElement);const O=this._canvas.getContext("2d");if(!O)throw new Error("Ctx cannot be null");this._ctx=O,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,x.toDisposable)((()=>{var P;(P=this._canvas)==null||P.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),j=Math.ceil(this._canvas.width/3);v.full=this._canvas.width,v.left=b,v.center=j,v.right=b,this._refreshDrawHeightConstants(),S.full=0,S.left=0,S.center=v.left,S.right=v.left+v.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,j=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowserService.dpr);C.left=j,C.center=j,C.right=j}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const j of this._decorationService.decorations)this._colorZoneStore.addDecoration(j);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const j of b)j.position!=="full"&&this._renderColorZone(j);for(const j of b)j.position==="full"&&this._renderColorZone(j);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(S[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-C[b.position||"full"]/2),v[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[b.position||"full"]))}_queueRefresh(b,j){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=j||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};u.OverviewRulerRenderer=_=h([m(2,w.IBufferService),m(3,w.IDecorationService),m(4,g.IRenderService),m(5,w.IOptionsService),m(6,g.ICoreBrowserService)],_)},2950:function(d,u,c){var h=this&&this.__decorate||function(C,v,S,_){var b,j=arguments.length,E=j<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,_);else for(var N=C.length-1;N>=0;N--)(b=C[N])&&(E=(j<3?b(E):j>3?b(v,S,E):b(v,S))||E);return j>3&&E&&Object.defineProperty(v,S,E),E},m=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CompositionHelper=void 0;const f=c(4725),g=c(2585),x=c(2584);let w=u.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,v,S,_,b,j){this._textarea=C,this._compositionView=v,this._bufferService=S,this._optionsService=_,this._coreService=b,this._renderService=j,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(C){this._compositionView.textContent=C.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(C){if(this._isComposing||this._isSendingComposition){if(C.keyCode===229||C.keyCode===16||C.keyCode===17||C.keyCode===18)return!1;this._finalizeComposition(!1)}return C.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(C){if(this._compositionView.classList.remove("active"),this._isComposing=!1,C){const v={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let S;this._isSendingComposition=!1,v.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(v.start,v.end):this._textarea.value.substring(v.start),S.length>0&&this._coreService.triggerDataEvent(S,!0)}}),0)}else{this._isSendingComposition=!1;const v=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(v,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const v=this._textarea.value,S=v.replace(C,"");this._dataAlreadySent=S,v.length>C.length?this._coreService.triggerDataEvent(S,!0):v.length<C.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):v.length===C.length&&v!==C&&this._coreService.triggerDataEvent(v,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const v=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),S=this._renderService.dimensions.css.cell.height,_=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,b=v*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=b+"px",this._compositionView.style.top=_+"px",this._compositionView.style.height=S+"px",this._compositionView.style.lineHeight=S+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const j=this._compositionView.getBoundingClientRect();this._textarea.style.left=b+"px",this._textarea.style.top=_+"px",this._textarea.style.width=Math.max(j.width,1)+"px",this._textarea.style.height=Math.max(j.height,1)+"px",this._textarea.style.lineHeight=j.height+"px"}C||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};u.CompositionHelper=w=h([m(2,g.IBufferService),m(3,g.IOptionsService),m(4,g.ICoreService),m(5,f.IRenderService)],w)},9806:(d,u)=>{function c(h,m,f){const g=f.getBoundingClientRect(),x=h.getComputedStyle(f),w=parseInt(x.getPropertyValue("padding-left")),C=parseInt(x.getPropertyValue("padding-top"));return[m.clientX-g.left-w,m.clientY-g.top-C]}Object.defineProperty(u,"__esModule",{value:!0}),u.getCoords=u.getCoordsRelativeToElement=void 0,u.getCoordsRelativeToElement=c,u.getCoords=function(h,m,f,g,x,w,C,v,S){if(!w)return;const _=c(h,m,f);return _?(_[0]=Math.ceil((_[0]+(S?C/2:0))/C),_[1]=Math.ceil(_[1]/v),_[0]=Math.min(Math.max(_[0],1),g+(S?1:0)),_[1]=Math.min(Math.max(_[1],1),x),_):void 0}},9504:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.moveToCellSequence=void 0;const h=c(2584);function m(v,S,_,b){const j=v-f(v,_),E=S-f(S,_),N=Math.abs(j-E)-(function(L,A,D){let O=0;const F=L-f(L,D),P=A-f(A,D);for(let z=0;z<Math.abs(F-P);z++){const K=g(L,A)==="A"?-1:1,q=D.buffer.lines.get(F+K*z);q!=null&&q.isWrapped&&O++}return O})(v,S,_);return C(N,w(g(v,S),b))}function f(v,S){let _=0,b=S.buffer.lines.get(v),j=b==null?void 0:b.isWrapped;for(;j&&v>=0&&v<S.rows;)_++,b=S.buffer.lines.get(--v),j=b==null?void 0:b.isWrapped;return _}function g(v,S){return v>S?"A":"B"}function x(v,S,_,b,j,E){let N=v,L=S,A="";for(;N!==_||L!==b;)N+=j?1:-1,j&&N>E.cols-1?(A+=E.buffer.translateBufferLineToString(L,!1,v,N),N=0,v=0,L++):!j&&N<0&&(A+=E.buffer.translateBufferLineToString(L,!1,0,v+1),N=E.cols-1,v=N,L--);return A+E.buffer.translateBufferLineToString(L,!1,v,N)}function w(v,S){const _=S?"O":"[";return h.C0.ESC+_+v}function C(v,S){v=Math.floor(v);let _="";for(let b=0;b<v;b++)_+=S;return _}u.moveToCellSequence=function(v,S,_,b){const j=_.buffer.x,E=_.buffer.y;if(!_.buffer.hasScrollback)return(function(A,D,O,F,P,z){return m(D,F,P,z).length===0?"":C(x(A,D,A,D-f(D,P),!1,P).length,w("D",z))})(j,E,0,S,_,b)+m(E,S,_,b)+(function(A,D,O,F,P,z){let K;K=m(D,F,P,z).length>0?F-f(F,P):D;const q=F,W=(function(Z,Q,H,I,M,V){let $;return $=m(H,I,M,V).length>0?I-f(I,M):Q,Z<H&&$<=I||Z>=H&&$<I?"C":"D"})(A,D,O,F,P,z);return C(x(A,K,O,q,W==="C",P).length,w(W,z))})(j,E,v,S,_,b);let N;if(E===S)return N=j>v?"D":"C",C(Math.abs(j-v),w(N,b));N=E>S?"D":"C";const L=Math.abs(E-S);return C((function(A,D){return D.cols-A})(E>S?v:j,_)+(L-1)*_.cols+1+((E>S?j:v)-1),w(N,b))}},1296:function(d,u,c){var h=this&&this.__decorate||function(z,K,q,W){var Z,Q=arguments.length,H=Q<3?K:W===null?W=Object.getOwnPropertyDescriptor(K,q):W;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(z,K,q,W);else for(var I=z.length-1;I>=0;I--)(Z=z[I])&&(H=(Q<3?Z(H):Q>3?Z(K,q,H):Z(K,q))||H);return Q>3&&H&&Object.defineProperty(K,q,H),H},m=this&&this.__param||function(z,K){return function(q,W){K(q,W,z)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRenderer=void 0;const f=c(3787),g=c(2550),x=c(2223),w=c(6171),C=c(6052),v=c(4725),S=c(8055),_=c(8460),b=c(844),j=c(2585),E="xterm-dom-renderer-owner-",N="xterm-rows",L="xterm-fg-",A="xterm-bg-",D="xterm-focus",O="xterm-selection";let F=1,P=u.DomRenderer=class extends b.Disposable{constructor(z,K,q,W,Z,Q,H,I,M,V,$,ee,Y){super(),this._terminal=z,this._document=K,this._element=q,this._screenElement=W,this._viewportElement=Z,this._helperContainer=Q,this._linkifier2=H,this._charSizeService=M,this._optionsService=V,this._bufferService=$,this._coreBrowserService=ee,this._themeService=Y,this._terminalClass=F++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new _.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(N),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(O),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((X=>this._injectCss(X)))),this._injectCss(this._themeService.colors),this._rowFactory=I.createInstance(f.DomRendererRowFactory,document),this._element.classList.add(E+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((X=>this._handleLinkHover(X)))),this.register(this._linkifier2.onHideLinkUnderline((X=>this._handleLinkLeave(X)))),this.register((0,b.toDisposable)((()=>{this._element.classList.remove(E+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const z=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*z,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*z),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/z),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/z),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const q of this._rowElements)q.style.width=`${this.dimensions.css.canvas.width}px`,q.style.height=`${this.dimensions.css.cell.height}px`,q.style.lineHeight=`${this.dimensions.css.cell.height}px`,q.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const K=`${this._terminalSelector} .${N} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=K,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(z){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let K=`${this._terminalSelector} .${N} { color: ${z.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;K+=`${this._terminalSelector} .${N} .xterm-dim { color: ${S.color.multiplyOpacity(z.foreground,.5).css};}`,K+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;const q=`blink_underline_${this._terminalClass}`,W=`blink_bar_${this._terminalClass}`,Z=`blink_block_${this._terminalClass}`;K+=`@keyframes ${q} { 50% { border-bottom-style: hidden; }}`,K+=`@keyframes ${W} { 50% { box-shadow: none; }}`,K+=`@keyframes ${Z} { 0% { background-color: ${z.cursor.css}; color: ${z.cursorAccent.css}; } 50% { background-color: inherit; color: ${z.cursor.css}; }}`,K+=`${this._terminalSelector} .${N}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${q} 1s step-end infinite;}${this._terminalSelector} .${N}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${W} 1s step-end infinite;}${this._terminalSelector} .${N}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Z} 1s step-end infinite;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block { background-color: ${z.cursor.css}; color: ${z.cursorAccent.css};}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${z.cursor.css} !important; color: ${z.cursorAccent.css} !important;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${z.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${z.cursor.css} inset;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${z.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,K+=`${this._terminalSelector} .${O} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${O} div { position: absolute; background-color: ${z.selectionBackgroundOpaque.css};}${this._terminalSelector} .${O} div { position: absolute; background-color: ${z.selectionInactiveBackgroundOpaque.css};}`;for(const[Q,H]of z.ansi.entries())K+=`${this._terminalSelector} .${L}${Q} { color: ${H.css}; }${this._terminalSelector} .${L}${Q}.xterm-dim { color: ${S.color.multiplyOpacity(H,.5).css}; }${this._terminalSelector} .${A}${Q} { background-color: ${H.css}; }`;K+=`${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(z.background).css}; }${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(z.background),.5).css}; }${this._terminalSelector} .${A}${x.INVERTED_DEFAULT_COLOR} { background-color: ${z.foreground.css}; }`,this._themeStyleElement.textContent=K}_setDefaultSpacing(){const z=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${z}px`,this._rowFactory.defaultSpacing=z}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(z,K){for(let q=this._rowElements.length;q<=K;q++){const W=this._document.createElement("div");this._rowContainer.appendChild(W),this._rowElements.push(W)}for(;this._rowElements.length>K;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(z,K){this._refreshRowElements(z,K),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(D),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(D),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(z,K,q){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(z,K,q),this.renderRows(0,this._bufferService.rows-1),!z||!K)return;this._selectionRenderModel.update(this._terminal,z,K,q);const W=this._selectionRenderModel.viewportStartRow,Z=this._selectionRenderModel.viewportEndRow,Q=this._selectionRenderModel.viewportCappedStartRow,H=this._selectionRenderModel.viewportCappedEndRow;if(Q>=this._bufferService.rows||H<0)return;const I=this._document.createDocumentFragment();if(q){const M=z[0]>K[0];I.appendChild(this._createSelectionElement(Q,M?K[0]:z[0],M?z[0]:K[0],H-Q+1))}else{const M=W===Q?z[0]:0,V=Q===Z?K[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(Q,M,V));const $=H-Q-1;if(I.appendChild(this._createSelectionElement(Q+1,0,this._bufferService.cols,$)),Q!==H){const ee=Z===H?K[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(H,0,ee))}}this._selectionContainer.appendChild(I)}_createSelectionElement(z,K,q,W=1){const Z=this._document.createElement("div"),Q=K*this.dimensions.css.cell.width;let H=this.dimensions.css.cell.width*(q-K);return Q+H>this.dimensions.css.canvas.width&&(H=this.dimensions.css.canvas.width-Q),Z.style.height=W*this.dimensions.css.cell.height+"px",Z.style.top=z*this.dimensions.css.cell.height+"px",Z.style.left=`${Q}px`,Z.style.width=`${H}px`,Z}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const z of this._rowElements)z.replaceChildren()}renderRows(z,K){const q=this._bufferService.buffer,W=q.ybase+q.y,Z=Math.min(q.x,this._bufferService.cols-1),Q=this._optionsService.rawOptions.cursorBlink,H=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let M=z;M<=K;M++){const V=M+q.ydisp,$=this._rowElements[M],ee=q.lines.get(V);if(!$||!ee)break;$.replaceChildren(...this._rowFactory.createRow(ee,V,V===W,H,I,Z,Q,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${E}${this._terminalClass}`}_handleLinkHover(z){this._setCellUnderline(z.x1,z.x2,z.y1,z.y2,z.cols,!0)}_handleLinkLeave(z){this._setCellUnderline(z.x1,z.x2,z.y1,z.y2,z.cols,!1)}_setCellUnderline(z,K,q,W,Z,Q){q<0&&(z=0),W<0&&(K=0);const H=this._bufferService.rows-1;q=Math.max(Math.min(q,H),0),W=Math.max(Math.min(W,H),0),Z=Math.min(Z,this._bufferService.cols);const I=this._bufferService.buffer,M=I.ybase+I.y,V=Math.min(I.x,Z-1),$=this._optionsService.rawOptions.cursorBlink,ee=this._optionsService.rawOptions.cursorStyle,Y=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=q;X<=W;++X){const U=X+I.ydisp,B=this._rowElements[X],J=I.lines.get(U);if(!B||!J)break;B.replaceChildren(...this._rowFactory.createRow(J,U,U===M,ee,Y,V,$,this.dimensions.css.cell.width,this._widthCache,Q?X===q?z:0:-1,Q?(X===W?K:Z)-1:-1))}}};u.DomRenderer=P=h([m(7,j.IInstantiationService),m(8,v.ICharSizeService),m(9,j.IOptionsService),m(10,j.IBufferService),m(11,v.ICoreBrowserService),m(12,v.IThemeService)],P)},3787:function(d,u,c){var h=this&&this.__decorate||function(N,L,A,D){var O,F=arguments.length,P=F<3?L:D===null?D=Object.getOwnPropertyDescriptor(L,A):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(N,L,A,D);else for(var z=N.length-1;z>=0;z--)(O=N[z])&&(P=(F<3?O(P):F>3?O(L,A,P):O(L,A))||P);return F>3&&P&&Object.defineProperty(L,A,P),P},m=this&&this.__param||function(N,L){return function(A,D){L(A,D,N)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRendererRowFactory=void 0;const f=c(2223),g=c(643),x=c(511),w=c(2585),C=c(8055),v=c(4725),S=c(4269),_=c(6171),b=c(3734);let j=u.DomRendererRowFactory=class{constructor(N,L,A,D,O,F,P){this._document=N,this._characterJoinerService=L,this._optionsService=A,this._coreBrowserService=D,this._coreService=O,this._decorationService=F,this._themeService=P,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(N,L,A){this._selectionStart=N,this._selectionEnd=L,this._columnSelectMode=A}createRow(N,L,A,D,O,F,P,z,K,q,W){const Z=[],Q=this._characterJoinerService.getJoinedCharacters(L),H=this._themeService.colors;let I,M=N.getNoBgTrimmedLength();A&&M<F+1&&(M=F+1);let V=0,$="",ee=0,Y=0,X=0,U=!1,B=0,J=!1,se=0;const ne=[],ie=q!==-1&&W!==-1;for(let de=0;de<M;de++){N.loadCell(de,this._workCell);let pe=this._workCell.getWidth();if(pe===0)continue;let Oe=!1,$e=de,Pe=this._workCell;if(Q.length>0&&de===Q[0][0]){Oe=!0;const Ze=Q.shift();Pe=new S.JoinedCellData(this._workCell,N.translateToString(!0,Ze[0],Ze[1]),Ze[1]-Ze[0]),$e=Ze[1]-1,pe=Pe.getWidth()}const Ve=this._isCellInSelection(de,L),Ye=A&&de===F,ot=ie&&de>=q&&de<=W;let Ae=!1;this._decorationService.forEachDecorationAtCell(de,L,void 0,(Ze=>{Ae=!0}));let me=Pe.getChars()||g.WHITESPACE_CELL_CHAR;if(me===" "&&(Pe.isUnderline()||Pe.isOverline())&&(me=" "),se=pe*z-K.get(me,Pe.isBold(),Pe.isItalic()),I){if(V&&(Ve&&J||!Ve&&!J&&Pe.bg===ee)&&(Ve&&J&&H.selectionForeground||Pe.fg===Y)&&Pe.extended.ext===X&&ot===U&&se===B&&!Ye&&!Oe&&!Ae){Pe.isInvisible()?$+=g.WHITESPACE_CELL_CHAR:$+=me,V++;continue}V&&(I.textContent=$),I=this._document.createElement("span"),V=0,$=""}else I=this._document.createElement("span");if(ee=Pe.bg,Y=Pe.fg,X=Pe.extended.ext,U=ot,B=se,J=Ve,Oe&&F>=de&&F<=$e&&(F=de),!this._coreService.isCursorHidden&&Ye&&this._coreService.isCursorInitialized){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)P&&ne.push("xterm-cursor-blink"),ne.push(D==="bar"?"xterm-cursor-bar":D==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(O)switch(O){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline")}}if(Pe.isBold()&&ne.push("xterm-bold"),Pe.isItalic()&&ne.push("xterm-italic"),Pe.isDim()&&ne.push("xterm-dim"),$=Pe.isInvisible()?g.WHITESPACE_CELL_CHAR:Pe.getChars()||g.WHITESPACE_CELL_CHAR,Pe.isUnderline()&&(ne.push(`xterm-underline-${Pe.extended.underlineStyle}`),$===" "&&($=" "),!Pe.isUnderlineColorDefault()))if(Pe.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${b.AttributeData.toColorRGB(Pe.getUnderlineColor()).join(",")})`;else{let Ze=Pe.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Pe.isBold()&&Ze<8&&(Ze+=8),I.style.textDecorationColor=H.ansi[Ze].css}Pe.isOverline()&&(ne.push("xterm-overline"),$===" "&&($=" ")),Pe.isStrikethrough()&&ne.push("xterm-strikethrough"),ot&&(I.style.textDecoration="underline");let re=Pe.getFgColor(),_e=Pe.getFgColorMode(),Me=Pe.getBgColor(),ce=Pe.getBgColorMode();const Ne=!!Pe.isInverse();if(Ne){const Ze=re;re=Me,Me=Ze;const it=_e;_e=ce,ce=it}let Xe,at,fe,We=!1;switch(this._decorationService.forEachDecorationAtCell(de,L,void 0,(Ze=>{Ze.options.layer!=="top"&&We||(Ze.backgroundColorRGB&&(ce=50331648,Me=Ze.backgroundColorRGB.rgba>>8&16777215,Xe=Ze.backgroundColorRGB),Ze.foregroundColorRGB&&(_e=50331648,re=Ze.foregroundColorRGB.rgba>>8&16777215,at=Ze.foregroundColorRGB),We=Ze.options.layer==="top")})),!We&&Ve&&(Xe=this._coreBrowserService.isFocused?H.selectionBackgroundOpaque:H.selectionInactiveBackgroundOpaque,Me=Xe.rgba>>8&16777215,ce=50331648,We=!0,H.selectionForeground&&(_e=50331648,re=H.selectionForeground.rgba>>8&16777215,at=H.selectionForeground)),We&&ne.push("xterm-decoration-top"),ce){case 16777216:case 33554432:fe=H.ansi[Me],ne.push(`xterm-bg-${Me}`);break;case 50331648:fe=C.channels.toColor(Me>>16,Me>>8&255,255&Me),this._addStyle(I,`background-color:#${E((Me>>>0).toString(16),"0",6)}`);break;default:Ne?(fe=H.foreground,ne.push(`xterm-bg-${f.INVERTED_DEFAULT_COLOR}`)):fe=H.background}switch(Xe||Pe.isDim()&&(Xe=C.color.multiplyOpacity(fe,.5)),_e){case 16777216:case 33554432:Pe.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(I,fe,H.ansi[re],Pe,Xe,void 0)||ne.push(`xterm-fg-${re}`);break;case 50331648:const Ze=C.channels.toColor(re>>16&255,re>>8&255,255&re);this._applyMinimumContrast(I,fe,Ze,Pe,Xe,at)||this._addStyle(I,`color:#${E(re.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,fe,H.foreground,Pe,Xe,at)||Ne&&ne.push(`xterm-fg-${f.INVERTED_DEFAULT_COLOR}`)}ne.length&&(I.className=ne.join(" "),ne.length=0),Ye||Oe||Ae?I.textContent=$:V++,se!==this.defaultSpacing&&(I.style.letterSpacing=`${se}px`),Z.push(I),de=$e}return I&&V&&(I.textContent=$),Z}_applyMinimumContrast(N,L,A,D,O,F){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,_.treatGlyphAsBackgroundColor)(D.getCode()))return!1;const P=this._getContrastCache(D);let z;if(O||F||(z=P.getColor(L.rgba,A.rgba)),z===void 0){const K=this._optionsService.rawOptions.minimumContrastRatio/(D.isDim()?2:1);z=C.color.ensureContrastRatio(O||L,F||A,K),P.setColor((O||L).rgba,(F||A).rgba,z??null)}return!!z&&(this._addStyle(N,`color:${z.css}`),!0)}_getContrastCache(N){return N.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(N,L){N.setAttribute("style",`${N.getAttribute("style")||""}${L};`)}_isCellInSelection(N,L){const A=this._selectionStart,D=this._selectionEnd;return!(!A||!D)&&(this._columnSelectMode?A[0]<=D[0]?N>=A[0]&&L>=A[1]&&N<D[0]&&L<=D[1]:N<A[0]&&L>=A[1]&&N>=D[0]&&L<=D[1]:L>A[1]&&L<D[1]||A[1]===D[1]&&L===A[1]&&N>=A[0]&&N<D[0]||A[1]<D[1]&&L===D[1]&&N<D[0]||A[1]<D[1]&&L===A[1]&&N>=A[0])}};function E(N,L,A){for(;N.length<A;)N=L+N;return N}u.DomRendererRowFactory=j=h([m(1,v.ICharacterJoinerService),m(2,w.IOptionsService),m(3,v.ICoreBrowserService),m(4,w.ICoreService),m(5,w.IDecorationService),m(6,v.IThemeService)],j)},2550:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WidthCache=void 0,u.WidthCache=class{constructor(c,h){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=c.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const m=c.createElement("span");m.classList.add("xterm-char-measure-element");const f=c.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontWeight="bold";const g=c.createElement("span");g.classList.add("xterm-char-measure-element"),g.style.fontStyle="italic";const x=c.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontWeight="bold",x.style.fontStyle="italic",this._measureElements=[m,f,g,x],this._container.appendChild(m),this._container.appendChild(f),this._container.appendChild(g),this._container.appendChild(x),h.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(c,h,m,f){c===this._font&&h===this._fontSize&&m===this._weight&&f===this._weightBold||(this._font=c,this._fontSize=h,this._weight=m,this._weightBold=f,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${m}`,this._measureElements[1].style.fontWeight=`${f}`,this._measureElements[2].style.fontWeight=`${m}`,this._measureElements[3].style.fontWeight=`${f}`,this.clear())}get(c,h,m){let f=0;if(!h&&!m&&c.length===1&&(f=c.charCodeAt(0))<256){if(this._flat[f]!==-9999)return this._flat[f];const w=this._measure(c,0);return w>0&&(this._flat[f]=w),w}let g=c;h&&(g+="B"),m&&(g+="I");let x=this._holey.get(g);if(x===void 0){let w=0;h&&(w|=1),m&&(w|=2),x=this._measure(c,w),x>0&&this._holey.set(g,x)}return x}_measure(c,h){const m=this._measureElements[h];return m.textContent=c.repeat(32),m.offsetWidth/32}}},2223:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.TEXT_BASELINE=u.DIM_OPACITY=u.INVERTED_DEFAULT_COLOR=void 0;const h=c(6114);u.INVERTED_DEFAULT_COLOR=257,u.DIM_OPACITY=.5,u.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(d,u)=>{function c(m){return 57508<=m&&m<=57558}function h(m){return m>=128512&&m<=128591||m>=127744&&m<=128511||m>=128640&&m<=128767||m>=9728&&m<=9983||m>=9984&&m<=10175||m>=65024&&m<=65039||m>=129280&&m<=129535||m>=127462&&m<=127487}Object.defineProperty(u,"__esModule",{value:!0}),u.computeNextVariantOffset=u.createRenderDimensions=u.treatGlyphAsBackgroundColor=u.allowRescaling=u.isEmoji=u.isRestrictedPowerlineGlyph=u.isPowerlineGlyph=u.throwIfFalsy=void 0,u.throwIfFalsy=function(m){if(!m)throw new Error("value must not be falsy");return m},u.isPowerlineGlyph=c,u.isRestrictedPowerlineGlyph=function(m){return 57520<=m&&m<=57527},u.isEmoji=h,u.allowRescaling=function(m,f,g,x){return f===1&&g>Math.ceil(1.5*x)&&m!==void 0&&m>255&&!h(m)&&!c(m)&&!(function(w){return 57344<=w&&w<=63743})(m)},u.treatGlyphAsBackgroundColor=function(m){return c(m)||(function(f){return 9472<=f&&f<=9631})(m)},u.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},u.computeNextVariantOffset=function(m,f,g=0){return(m-(2*Math.round(f)-g))%(2*Math.round(f))}},6052:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createSelectionRenderModel=void 0;class c{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(m,f,g,x=!1){if(this.selectionStart=f,this.selectionEnd=g,!f||!g||f[0]===g[0]&&f[1]===g[1])return void this.clear();const w=m.buffers.active.ydisp,C=f[1]-w,v=g[1]-w,S=Math.max(C,0),_=Math.min(v,m.rows-1);S>=m.rows||_<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=x,this.viewportStartRow=C,this.viewportEndRow=v,this.viewportCappedStartRow=S,this.viewportCappedEndRow=_,this.startCol=f[0],this.endCol=g[0])}isCellSelected(m,f,g){return!!this.hasSelection&&(g-=m.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?f>=this.startCol&&g>=this.viewportCappedStartRow&&f<this.endCol&&g<=this.viewportCappedEndRow:f<this.startCol&&g>=this.viewportCappedStartRow&&f>=this.endCol&&g<=this.viewportCappedEndRow:g>this.viewportStartRow&&g<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&g===this.viewportStartRow&&f>=this.startCol&&f<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportEndRow&&f<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportStartRow&&f>=this.startCol)}}u.createSelectionRenderModel=function(){return new c}},456:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionModel=void 0,u.SelectionModel=class{constructor(c){this._bufferService=c,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const c=this.selectionStart[0]+this.selectionStartLength;return c>this._bufferService.cols?c%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(c/this._bufferService.cols)-1]:[c%this._bufferService.cols,this.selectionStart[1]+Math.floor(c/this._bufferService.cols)]:[c,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const c=this.selectionStart[0]+this.selectionStartLength;return c>this._bufferService.cols?[c%this._bufferService.cols,this.selectionStart[1]+Math.floor(c/this._bufferService.cols)]:[Math.max(c,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const c=this.selectionStart,h=this.selectionEnd;return!(!c||!h)&&(c[1]>h[1]||c[1]===h[1]&&c[0]>h[0])}handleTrim(c){return this.selectionStart&&(this.selectionStart[1]-=c),this.selectionEnd&&(this.selectionEnd[1]-=c),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(d,u,c){var h=this&&this.__decorate||function(_,b,j,E){var N,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,j,E);else for(var D=_.length-1;D>=0;D--)(N=_[D])&&(A=(L<3?N(A):L>3?N(b,j,A):N(b,j))||A);return L>3&&A&&Object.defineProperty(b,j,A),A},m=this&&this.__param||function(_,b){return function(j,E){b(j,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharSizeService=void 0;const f=c(2585),g=c(8460),x=c(844);let w=u.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(_,b,j){super(),this._optionsService=j,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(this._optionsService))}catch{this._measureStrategy=this.register(new v(_,b,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const _=this._measureStrategy.measure();_.width===this.width&&_.height===this.height||(this.width=_.width,this.height=_.height,this._onCharSizeChange.fire())}};u.CharSizeService=w=h([m(2,f.IOptionsService)],w);class C extends x.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(b,j){b!==void 0&&b>0&&j!==void 0&&j>0&&(this._result.width=b,this._result.height=j)}}class v extends C{constructor(b,j,E){super(),this._document=b,this._parentElement=j,this._optionsService=E,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class S extends C{constructor(b){super(),this._optionsService=b,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const j=this._ctx.measureText("W");if(!("width"in j&&"fontBoundingBoxAscent"in j&&"fontBoundingBoxDescent"in j))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const b=this._ctx.measureText("W");return this._validateAndSet(b.width,b.fontBoundingBoxAscent+b.fontBoundingBoxDescent),this._result}}},4269:function(d,u,c){var h=this&&this.__decorate||function(S,_,b,j){var E,N=arguments.length,L=N<3?_:j===null?j=Object.getOwnPropertyDescriptor(_,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,_,b,j);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(L=(N<3?E(L):N>3?E(_,b,L):E(_,b))||L);return N>3&&L&&Object.defineProperty(_,b,L),L},m=this&&this.__param||function(S,_){return function(b,j){_(b,j,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharacterJoinerService=u.JoinedCellData=void 0;const f=c(3734),g=c(643),x=c(511),w=c(2585);class C extends f.AttributeData{constructor(_,b,j){super(),this.content=0,this.combinedData="",this.fg=_.fg,this.bg=_.bg,this.combinedData=b,this._width=j}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(_){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}u.JoinedCellData=C;let v=u.CharacterJoinerService=class $T{constructor(_){this._bufferService=_,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(_){const b={id:this._nextCharacterJoinerId++,handler:_};return this._characterJoiners.push(b),b.id}deregister(_){for(let b=0;b<this._characterJoiners.length;b++)if(this._characterJoiners[b].id===_)return this._characterJoiners.splice(b,1),!0;return!1}getJoinedCharacters(_){if(this._characterJoiners.length===0)return[];const b=this._bufferService.buffer.lines.get(_);if(!b||b.length===0)return[];const j=[],E=b.translateToString(!0);let N=0,L=0,A=0,D=b.getFg(0),O=b.getBg(0);for(let F=0;F<b.getTrimmedLength();F++)if(b.loadCell(F,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==D||this._workCell.bg!==O){if(F-N>1){const P=this._getJoinedRanges(E,A,L,b,N);for(let z=0;z<P.length;z++)j.push(P[z])}N=F,A=L,D=this._workCell.fg,O=this._workCell.bg}L+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-N>1){const F=this._getJoinedRanges(E,A,L,b,N);for(let P=0;P<F.length;P++)j.push(F[P])}return j}_getJoinedRanges(_,b,j,E,N){const L=_.substring(b,j);let A=[];try{A=this._characterJoiners[0].handler(L)}catch(D){console.error(D)}for(let D=1;D<this._characterJoiners.length;D++)try{const O=this._characterJoiners[D].handler(L);for(let F=0;F<O.length;F++)$T._mergeRanges(A,O[F])}catch(O){console.error(O)}return this._stringRangesToCellRanges(A,E,N),A}_stringRangesToCellRanges(_,b,j){let E=0,N=!1,L=0,A=_[E];if(A){for(let D=j;D<this._bufferService.cols;D++){const O=b.getWidth(D),F=b.getString(D).length||g.WHITESPACE_CELL_CHAR.length;if(O!==0){if(!N&&A[0]<=L&&(A[0]=D,N=!0),A[1]<=L){if(A[1]=D,A=_[++E],!A)break;A[0]<=L?(A[0]=D,N=!0):N=!1}L+=F}}A&&(A[1]=this._bufferService.cols)}}static _mergeRanges(_,b){let j=!1;for(let E=0;E<_.length;E++){const N=_[E];if(j){if(b[1]<=N[0])return _[E-1][1]=b[1],_;if(b[1]<=N[1])return _[E-1][1]=Math.max(b[1],N[1]),_.splice(E,1),_;_.splice(E,1),E--}else{if(b[1]<=N[0])return _.splice(E,0,b),_;if(b[1]<=N[1])return N[0]=Math.min(b[0],N[0]),_;b[0]<N[1]&&(N[0]=Math.min(b[0],N[0]),j=!0)}}return j?_[_.length-1][1]=b[1]:_.push(b),_}};u.CharacterJoinerService=v=h([m(0,w.IBufferService)],v)},5114:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreBrowserService=void 0;const h=c(844),m=c(8460),f=c(3656);class g extends h.Disposable{constructor(C,v,S){super(),this._textarea=C,this._window=v,this.mainDocument=S,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new x(this._window),this._onDprChange=this.register(new m.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new m.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((_=>this._screenDprMonitor.setWindow(_)))),this.register((0,m.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}u.CoreBrowserService=g;class x extends h.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new m.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,h.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,f.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.LinkProviderService=void 0;const h=c(844);class m extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(g){return this.linkProviders.push(g),{dispose:()=>{const x=this.linkProviders.indexOf(g);x!==-1&&this.linkProviders.splice(x,1)}}}}u.LinkProviderService=m},8934:function(d,u,c){var h=this&&this.__decorate||function(w,C,v,S){var _,b=arguments.length,j=b<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,v):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(w,C,v,S);else for(var E=w.length-1;E>=0;E--)(_=w[E])&&(j=(b<3?_(j):b>3?_(C,v,j):_(C,v))||j);return b>3&&j&&Object.defineProperty(C,v,j),j},m=this&&this.__param||function(w,C){return function(v,S){C(v,S,w)}};Object.defineProperty(u,"__esModule",{value:!0}),u.MouseService=void 0;const f=c(4725),g=c(9806);let x=u.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,v,S,_){return(0,g.getCoords)(window,w,C,v,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,_)}getMouseReportCoords(w,C){const v=(0,g.getCoordsRelativeToElement)(window,w,C);if(this._charSizeService.hasValidSize)return v[0]=Math.min(Math.max(v[0],0),this._renderService.dimensions.css.canvas.width-1),v[1]=Math.min(Math.max(v[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(v[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(v[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(v[0]),y:Math.floor(v[1])}}};u.MouseService=x=h([m(0,f.IRenderService),m(1,f.ICharSizeService)],x)},3230:function(d,u,c){var h=this&&this.__decorate||function(_,b,j,E){var N,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,j,E);else for(var D=_.length-1;D>=0;D--)(N=_[D])&&(A=(L<3?N(A):L>3?N(b,j,A):N(b,j))||A);return L>3&&A&&Object.defineProperty(b,j,A),A},m=this&&this.__param||function(_,b){return function(j,E){b(j,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.RenderService=void 0;const f=c(6193),g=c(4725),x=c(8460),w=c(844),C=c(7226),v=c(2585);let S=u.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,b,j,E,N,L,A,D){super(),this._rowCount=_,this._charSizeService=E,this._renderer=this.register(new w.MutableDisposable),this._pausedResizeTask=new C.DebouncedIdleTask,this._observerDisposable=this.register(new w.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new f.RenderDebouncer(((O,F)=>this._renderRows(O,F)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(L.onResize((()=>this._fullRefresh()))),this.register(L.buffers.onBufferActivate((()=>{var O;return(O=this._renderer.value)==null?void 0:O.clear()}))),this.register(j.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(N.onDecorationRegistered((()=>this._fullRefresh()))),this.register(N.onDecorationRemoved((()=>this._fullRefresh()))),this.register(j.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(L.cols,L.rows),this._fullRefresh()}))),this.register(j.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(L.buffer.y,L.buffer.y,!0)))),this.register(D.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,b),this.register(A.onWindowChange((O=>this._registerIntersectionObserver(O,b))))}_registerIntersectionObserver(_,b){if("IntersectionObserver"in _){const j=new _.IntersectionObserver((E=>this._handleIntersectionChange(E[E.length-1])),{threshold:0});j.observe(b),this._observerDisposable.value=(0,w.toDisposable)((()=>j.disconnect()))}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(_,b,j=!1){this._isPaused?this._needsFullRefresh=!0:(j||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,b,this._rowCount))}_renderRows(_,b){this._renderer.value&&(_=Math.min(_,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(_,b),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:_,end:b}),this._onRender.fire({start:_,end:b}),this._isNextRenderRedrawOnly=!0)}resize(_,b){this._rowCount=b,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(_){this._renderer.value=_,this._renderer.value&&(this._renderer.value.onRequestRedraw((b=>this.refreshRows(b.start,b.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,b;this._renderer.value&&((b=(_=this._renderer.value).clearTextureAtlas)==null||b.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var j;return(j=this._renderer.value)==null?void 0:j.handleResize(_,b)})):this._renderer.value.handleResize(_,b),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)==null||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)==null||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)==null||_.handleFocus()}handleSelectionChanged(_,b,j){var E;this._selectionState.start=_,this._selectionState.end=b,this._selectionState.columnSelectMode=j,(E=this._renderer.value)==null||E.handleSelectionChanged(_,b,j)}handleCursorMove(){var _;(_=this._renderer.value)==null||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)==null||_.clear()}};u.RenderService=S=h([m(2,v.IOptionsService),m(3,g.ICharSizeService),m(4,v.IDecorationService),m(5,v.IBufferService),m(6,g.ICoreBrowserService),m(7,g.IThemeService)],S)},9312:function(d,u,c){var h=this&&this.__decorate||function(A,D,O,F){var P,z=arguments.length,K=z<3?D:F===null?F=Object.getOwnPropertyDescriptor(D,O):F;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate(A,D,O,F);else for(var q=A.length-1;q>=0;q--)(P=A[q])&&(K=(z<3?P(K):z>3?P(D,O,K):P(D,O))||K);return z>3&&K&&Object.defineProperty(D,O,K),K},m=this&&this.__param||function(A,D){return function(O,F){D(O,F,A)}};Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionService=void 0;const f=c(9806),g=c(9504),x=c(456),w=c(4725),C=c(8460),v=c(844),S=c(6114),_=c(4841),b=c(511),j=c(2585),E=" ",N=new RegExp(E,"g");let L=u.SelectionService=class extends v.Disposable{constructor(A,D,O,F,P,z,K,q,W){super(),this._element=A,this._screenElement=D,this._linkifier=O,this._bufferService=F,this._coreService=P,this._mouseService=z,this._optionsService=K,this._renderService=q,this._coreBrowserService=W,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new b.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new C.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new C.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=Z=>this._handleMouseMove(Z),this._mouseUpListener=Z=>this._handleMouseUp(Z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((Z=>this._handleTrim(Z))),this.register(this._bufferService.buffers.onBufferActivate((Z=>this._handleBufferActivate(Z)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,v.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!A||!D||A[0]===D[0]&&A[1]===D[1])}get selectionText(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;if(!A||!D)return"";const O=this._bufferService.buffer,F=[];if(this._activeSelectionMode===3){if(A[0]===D[0])return"";const P=A[0]<D[0]?A[0]:D[0],z=A[0]<D[0]?D[0]:A[0];for(let K=A[1];K<=D[1];K++){const q=O.translateBufferLineToString(K,!0,P,z);F.push(q)}}else{const P=A[1]===D[1]?D[0]:void 0;F.push(O.translateBufferLineToString(A[1],!0,A[0],P));for(let z=A[1]+1;z<=D[1]-1;z++){const K=O.lines.get(z),q=O.translateBufferLineToString(z,!0);K!=null&&K.isWrapped?F[F.length-1]+=q:F.push(q)}if(A[1]!==D[1]){const z=O.lines.get(D[1]),K=O.translateBufferLineToString(D[1],!0,0,D[0]);z&&z.isWrapped?F[F.length-1]+=K:F.push(K)}}return F.map((P=>P.replace(N," "))).join(S.isWindows?`\r
258
+ `:`
259
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(A){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),S.isLinux&&A&&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(A){const D=this._getMouseBufferCoords(A),O=this._model.finalSelectionStart,F=this._model.finalSelectionEnd;return!!(O&&F&&D)&&this._areCoordsInSelection(D,O,F)}isCellInSelection(A,D){const O=this._model.finalSelectionStart,F=this._model.finalSelectionEnd;return!(!O||!F)&&this._areCoordsInSelection([A,D],O,F)}_areCoordsInSelection(A,D,O){return A[1]>D[1]&&A[1]<O[1]||D[1]===O[1]&&A[1]===D[1]&&A[0]>=D[0]&&A[0]<O[0]||D[1]<O[1]&&A[1]===O[1]&&A[0]<O[0]||D[1]<O[1]&&A[1]===D[1]&&A[0]>=D[0]}_selectWordAtCursor(A,D){var P,z;const O=(z=(P=this._linkifier.currentLink)==null?void 0:P.link)==null?void 0:z.range;if(O)return this._model.selectionStart=[O.start.x-1,O.start.y-1],this._model.selectionStartLength=(0,_.getRangeLength)(O,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const F=this._getMouseBufferCoords(A);return!!F&&(this._selectWordAt(F,D),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,D){this._model.clearSelection(),A=Math.max(A,0),D=Math.min(D,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,D],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const D=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(D)return D[0]--,D[1]--,D[1]+=this._bufferService.buffer.ydisp,D}_getMouseEventScrollAmount(A){let D=(0,f.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const O=this._renderService.dimensions.css.canvas.height;return D>=0&&D<=O?0:(D>O&&(D-=O),D=Math.min(Math.max(D,-50),50),D/=50,D/Math.abs(D)+Math.round(14*D))}shouldForceSelection(A){return S.isMac?A.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:A.shiftKey}handleMouseDown(A){if(this._mouseDownTimeStamp=A.timeStamp,(A.button!==2||!this.hasSelection)&&A.button===0){if(!this._enabled){if(!this.shouldForceSelection(A))return;A.stopPropagation()}A.preventDefault(),this._dragScrollAmount=0,this._enabled&&A.shiftKey?this._handleIncrementalClick(A):A.detail===1?this._handleSingleClick(A):A.detail===2?this._handleDoubleClick(A):A.detail===3&&this._handleTripleClick(A),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(A){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(A))}_handleSingleClick(A){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(A)?3:0,this._model.selectionStart=this._getMouseBufferCoords(A),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const D=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);D&&D.length!==this._model.selectionStart[0]&&D.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const D=this._getMouseBufferCoords(A);D&&(this._activeSelectionMode=2,this._selectLineAt(D[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const D=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(A),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(A),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const O=this._bufferService.buffer;if(this._model.selectionEnd[1]<O.lines.length){const F=O.lines.get(this._model.selectionEnd[1]);F&&F.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}D&&D[0]===this._model.selectionEnd[0]&&D[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const A=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(A.ydisp+this._bufferService.rows,A.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=A.ydisp),this.refresh()}}_handleMouseUp(A){const D=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&D<500&&A.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const O=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(O&&O[0]!==void 0&&O[1]!==void 0){const F=(0,g.moveToCellSequence)(O[0]-1,O[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(F,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd,O=!(!A||!D||A[0]===D[0]&&A[1]===D[1]);O?A&&D&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&D[0]===this._oldSelectionEnd[0]&&D[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,D,O)):this._oldHasSelection&&this._fireOnSelectionChange(A,D,O)}_fireOnSelectionChange(A,D,O){this._oldSelectionStart=A,this._oldSelectionEnd=D,this._oldHasSelection=O,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((D=>this._handleTrim(D)))}_convertViewportColToCharacterIndex(A,D){let O=D;for(let F=0;D>=F;F++){const P=A.loadCell(F,this._workCell).getChars().length;this._workCell.getWidth()===0?O--:P>1&&D!==F&&(O+=P-1)}return O}setSelection(A,D,O){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,D],this._model.selectionStartLength=O,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,D,O=!0,F=!0){if(A[0]>=this._bufferService.cols)return;const P=this._bufferService.buffer,z=P.lines.get(A[1]);if(!z)return;const K=P.translateBufferLineToString(A[1],!1);let q=this._convertViewportColToCharacterIndex(z,A[0]),W=q;const Z=A[0]-q;let Q=0,H=0,I=0,M=0;if(K.charAt(q)===" "){for(;q>0&&K.charAt(q-1)===" ";)q--;for(;W<K.length&&K.charAt(W+1)===" ";)W++}else{let ee=A[0],Y=A[0];z.getWidth(ee)===0&&(Q++,ee--),z.getWidth(Y)===2&&(H++,Y++);const X=z.getString(Y).length;for(X>1&&(M+=X-1,W+=X-1);ee>0&&q>0&&!this._isCharWordSeparator(z.loadCell(ee-1,this._workCell));){z.loadCell(ee-1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===0?(Q++,ee--):U>1&&(I+=U-1,q-=U-1),q--,ee--}for(;Y<z.length&&W+1<K.length&&!this._isCharWordSeparator(z.loadCell(Y+1,this._workCell));){z.loadCell(Y+1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===2?(H++,Y++):U>1&&(M+=U-1,W+=U-1),W++,Y++}}W++;let V=q+Z-Q+I,$=Math.min(this._bufferService.cols,W-q+Q+H-I-M);if(D||K.slice(q,W).trim()!==""){if(O&&V===0&&z.getCodePoint(0)!==32){const ee=P.lines.get(A[1]-1);if(ee&&z.isWrapped&&ee.getCodePoint(this._bufferService.cols-1)!==32){const Y=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(Y){const X=this._bufferService.cols-Y.start;V-=X,$+=X}}}if(F&&V+$===this._bufferService.cols&&z.getCodePoint(this._bufferService.cols-1)!==32){const ee=P.lines.get(A[1]+1);if(ee!=null&&ee.isWrapped&&ee.getCodePoint(0)!==32){const Y=this._getWordAt([0,A[1]+1],!1,!1,!0);Y&&($+=Y.length)}}return{start:V,length:$}}}_selectWordAt(A,D){const O=this._getWordAt(A,D);if(O){for(;O.start<0;)O.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[O.start,A[1]],this._model.selectionStartLength=O.length}}_selectToWordAt(A){const D=this._getWordAt(A,!0);if(D){let O=A[1];for(;D.start<0;)D.start+=this._bufferService.cols,O--;if(!this._model.areSelectionValuesReversed())for(;D.start+D.length>this._bufferService.cols;)D.length-=this._bufferService.cols,O++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?D.start:D.start+D.length,O]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const D=this._bufferService.buffer.getWrappedRangeForLine(A),O={start:{x:0,y:D.first},end:{x:this._bufferService.cols-1,y:D.last}};this._model.selectionStart=[0,D.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,_.getRangeLength)(O,this._bufferService.cols)}};u.SelectionService=L=h([m(3,j.IBufferService),m(4,j.ICoreService),m(5,w.IMouseService),m(6,j.IOptionsService),m(7,w.IRenderService),m(8,w.ICoreBrowserService)],L)},4725:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ILinkProviderService=u.IThemeService=u.ICharacterJoinerService=u.ISelectionService=u.IRenderService=u.IMouseService=u.ICoreBrowserService=u.ICharSizeService=void 0;const h=c(8343);u.ICharSizeService=(0,h.createDecorator)("CharSizeService"),u.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),u.IMouseService=(0,h.createDecorator)("MouseService"),u.IRenderService=(0,h.createDecorator)("RenderService"),u.ISelectionService=(0,h.createDecorator)("SelectionService"),u.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),u.IThemeService=(0,h.createDecorator)("ThemeService"),u.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(d,u,c){var h=this&&this.__decorate||function(L,A,D,O){var F,P=arguments.length,z=P<3?A:O===null?O=Object.getOwnPropertyDescriptor(A,D):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(L,A,D,O);else for(var K=L.length-1;K>=0;K--)(F=L[K])&&(z=(P<3?F(z):P>3?F(A,D,z):F(A,D))||z);return P>3&&z&&Object.defineProperty(A,D,z),z},m=this&&this.__param||function(L,A){return function(D,O){A(D,O,L)}};Object.defineProperty(u,"__esModule",{value:!0}),u.ThemeService=u.DEFAULT_ANSI_COLORS=void 0;const f=c(7239),g=c(8055),x=c(8460),w=c(844),C=c(2585),v=g.css.toColor("#ffffff"),S=g.css.toColor("#000000"),_=g.css.toColor("#ffffff"),b=g.css.toColor("#000000"),j={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};u.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const L=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],A=[0,95,135,175,215,255];for(let D=0;D<216;D++){const O=A[D/36%6|0],F=A[D/6%6|0],P=A[D%6];L.push({css:g.channels.toCss(O,F,P),rgba:g.channels.toRgba(O,F,P)})}for(let D=0;D<24;D++){const O=8+10*D;L.push({css:g.channels.toCss(O,O,O),rgba:g.channels.toRgba(O,O,O)})}return L})());let E=u.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(L){super(),this._optionsService=L,this._contrastCache=new f.ColorContrastCache,this._halfContrastCache=new f.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:v,background:S,cursor:_,cursorAccent:b,selectionForeground:void 0,selectionBackgroundTransparent:j,selectionBackgroundOpaque:g.color.blend(S,j),selectionInactiveBackgroundTransparent:j,selectionInactiveBackgroundOpaque:g.color.blend(S,j),ansi:u.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(L={}){const A=this._colors;if(A.foreground=N(L.foreground,v),A.background=N(L.background,S),A.cursor=N(L.cursor,_),A.cursorAccent=N(L.cursorAccent,b),A.selectionBackgroundTransparent=N(L.selectionBackground,j),A.selectionBackgroundOpaque=g.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=N(L.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=g.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=L.selectionForeground?N(L.selectionForeground,g.NULL_COLOR):void 0,A.selectionForeground===g.NULL_COLOR&&(A.selectionForeground=void 0),g.color.isOpaque(A.selectionBackgroundTransparent)&&(A.selectionBackgroundTransparent=g.color.opacity(A.selectionBackgroundTransparent,.3)),g.color.isOpaque(A.selectionInactiveBackgroundTransparent)&&(A.selectionInactiveBackgroundTransparent=g.color.opacity(A.selectionInactiveBackgroundTransparent,.3)),A.ansi=u.DEFAULT_ANSI_COLORS.slice(),A.ansi[0]=N(L.black,u.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=N(L.red,u.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=N(L.green,u.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=N(L.yellow,u.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=N(L.blue,u.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=N(L.magenta,u.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=N(L.cyan,u.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=N(L.white,u.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=N(L.brightBlack,u.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=N(L.brightRed,u.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=N(L.brightGreen,u.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=N(L.brightYellow,u.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=N(L.brightBlue,u.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=N(L.brightMagenta,u.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=N(L.brightCyan,u.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=N(L.brightWhite,u.DEFAULT_ANSI_COLORS[15]),L.extendedAnsi){const D=Math.min(A.ansi.length-16,L.extendedAnsi.length);for(let O=0;O<D;O++)A.ansi[O+16]=N(L.extendedAnsi[O],u.DEFAULT_ANSI_COLORS[O+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(L){this._restoreColor(L),this._onChangeColors.fire(this.colors)}_restoreColor(L){if(L!==void 0)switch(L){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[L]=this._restoreColors.ansi[L]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}modifyColors(L){L(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function N(L,A){if(L!==void 0)try{return g.css.toColor(L)}catch{}return A}u.ThemeService=E=h([m(0,C.IOptionsService)],E)},6349:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CircularList=void 0;const h=c(8460),m=c(844);class f extends m.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(x){if(this._maxLength===x)return;const w=new Array(x);for(let C=0;C<Math.min(x,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,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(x,w,...C){if(w){for(let v=x;v<this._length-w;v++)this._array[this._getCyclicIndex(v)]=this._array[this._getCyclicIndex(v+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let v=this._length-1;v>=x;v--)this._array[this._getCyclicIndex(v+C.length)]=this._array[this._getCyclicIndex(v)];for(let v=0;v<C.length;v++)this._array[this._getCyclicIndex(x+v)]=C[v];if(C.length&&this.onInsertEmitter.fire({index:x,amount:C.length}),this._length+C.length>this._maxLength){const v=this._length+C.length-this._maxLength;this._startIndex+=v,this._length=this._maxLength,this.onTrimEmitter.fire(v)}else this._length+=C.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,C){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(x+S+C,this.get(x+S));const v=x+w+C-this._length;if(v>0)for(this._length+=v;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let v=0;v<w;v++)this.set(x+v+C,this.get(x+v))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}u.CircularList=f},1439:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.clone=void 0,u.clone=function c(h,m=5){if(typeof h!="object")return h;const f=Array.isArray(h)?[]:{};for(const g in h)f[g]=m<=1?h[g]:h[g]&&c(h[g],m-1);return f}},8055:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.contrastRatio=u.toPaddedHex=u.rgba=u.rgb=u.css=u.color=u.channels=u.NULL_COLOR=void 0;let c=0,h=0,m=0,f=0;var g,x,w,C,v;function S(b){const j=b.toString(16);return j.length<2?"0"+j:j}function _(b,j){return b<j?(j+.05)/(b+.05):(b+.05)/(j+.05)}u.NULL_COLOR={css:"#00000000",rgba:0},(function(b){b.toCss=function(j,E,N,L){return L!==void 0?`#${S(j)}${S(E)}${S(N)}${S(L)}`:`#${S(j)}${S(E)}${S(N)}`},b.toRgba=function(j,E,N,L=255){return(j<<24|E<<16|N<<8|L)>>>0},b.toColor=function(j,E,N,L){return{css:b.toCss(j,E,N,L),rgba:b.toRgba(j,E,N,L)}}})(g||(u.channels=g={})),(function(b){function j(E,N){return f=Math.round(255*N),[c,h,m]=v.toChannels(E.rgba),{css:g.toCss(c,h,m,f),rgba:g.toRgba(c,h,m,f)}}b.blend=function(E,N){if(f=(255&N.rgba)/255,f===1)return{css:N.css,rgba:N.rgba};const L=N.rgba>>24&255,A=N.rgba>>16&255,D=N.rgba>>8&255,O=E.rgba>>24&255,F=E.rgba>>16&255,P=E.rgba>>8&255;return c=O+Math.round((L-O)*f),h=F+Math.round((A-F)*f),m=P+Math.round((D-P)*f),{css:g.toCss(c,h,m),rgba:g.toRgba(c,h,m)}},b.isOpaque=function(E){return(255&E.rgba)==255},b.ensureContrastRatio=function(E,N,L){const A=v.ensureContrastRatio(E.rgba,N.rgba,L);if(A)return g.toColor(A>>24&255,A>>16&255,A>>8&255)},b.opaque=function(E){const N=(255|E.rgba)>>>0;return[c,h,m]=v.toChannels(N),{css:g.toCss(c,h,m),rgba:N}},b.opacity=j,b.multiplyOpacity=function(E,N){return f=255&E.rgba,j(E,f*N/255)},b.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(x||(u.color=x={})),(function(b){let j,E;try{const N=document.createElement("canvas");N.width=1,N.height=1;const L=N.getContext("2d",{willReadFrequently:!0});L&&(j=L,j.globalCompositeOperation="copy",E=j.createLinearGradient(0,0,1,1))}catch{}b.toColor=function(N){if(N.match(/#[\da-f]{3,8}/i))switch(N.length){case 4:return c=parseInt(N.slice(1,2).repeat(2),16),h=parseInt(N.slice(2,3).repeat(2),16),m=parseInt(N.slice(3,4).repeat(2),16),g.toColor(c,h,m);case 5:return c=parseInt(N.slice(1,2).repeat(2),16),h=parseInt(N.slice(2,3).repeat(2),16),m=parseInt(N.slice(3,4).repeat(2),16),f=parseInt(N.slice(4,5).repeat(2),16),g.toColor(c,h,m,f);case 7:return{css:N,rgba:(parseInt(N.slice(1),16)<<8|255)>>>0};case 9:return{css:N,rgba:parseInt(N.slice(1),16)>>>0}}const L=N.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(L)return c=parseInt(L[1]),h=parseInt(L[2]),m=parseInt(L[3]),f=Math.round(255*(L[5]===void 0?1:parseFloat(L[5]))),g.toColor(c,h,m,f);if(!j||!E)throw new Error("css.toColor: Unsupported css format");if(j.fillStyle=E,j.fillStyle=N,typeof j.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(j.fillRect(0,0,1,1),[c,h,m,f]=j.getImageData(0,0,1,1).data,f!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:g.toRgba(c,h,m,f),css:N}}})(w||(u.css=w={})),(function(b){function j(E,N,L){const A=E/255,D=N/255,O=L/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(O<=.03928?O/12.92:Math.pow((O+.055)/1.055,2.4))}b.relativeLuminance=function(E){return j(E>>16&255,E>>8&255,255&E)},b.relativeLuminance2=j})(C||(u.rgb=C={})),(function(b){function j(N,L,A){const D=N>>24&255,O=N>>16&255,F=N>>8&255;let P=L>>24&255,z=L>>16&255,K=L>>8&255,q=_(C.relativeLuminance2(P,z,K),C.relativeLuminance2(D,O,F));for(;q<A&&(P>0||z>0||K>0);)P-=Math.max(0,Math.ceil(.1*P)),z-=Math.max(0,Math.ceil(.1*z)),K-=Math.max(0,Math.ceil(.1*K)),q=_(C.relativeLuminance2(P,z,K),C.relativeLuminance2(D,O,F));return(P<<24|z<<16|K<<8|255)>>>0}function E(N,L,A){const D=N>>24&255,O=N>>16&255,F=N>>8&255;let P=L>>24&255,z=L>>16&255,K=L>>8&255,q=_(C.relativeLuminance2(P,z,K),C.relativeLuminance2(D,O,F));for(;q<A&&(P<255||z<255||K<255);)P=Math.min(255,P+Math.ceil(.1*(255-P))),z=Math.min(255,z+Math.ceil(.1*(255-z))),K=Math.min(255,K+Math.ceil(.1*(255-K))),q=_(C.relativeLuminance2(P,z,K),C.relativeLuminance2(D,O,F));return(P<<24|z<<16|K<<8|255)>>>0}b.blend=function(N,L){if(f=(255&L)/255,f===1)return L;const A=L>>24&255,D=L>>16&255,O=L>>8&255,F=N>>24&255,P=N>>16&255,z=N>>8&255;return c=F+Math.round((A-F)*f),h=P+Math.round((D-P)*f),m=z+Math.round((O-z)*f),g.toRgba(c,h,m)},b.ensureContrastRatio=function(N,L,A){const D=C.relativeLuminance(N>>8),O=C.relativeLuminance(L>>8);if(_(D,O)<A){if(O<D){const z=j(N,L,A),K=_(D,C.relativeLuminance(z>>8));if(K<A){const q=E(N,L,A);return K>_(D,C.relativeLuminance(q>>8))?z:q}return z}const F=E(N,L,A),P=_(D,C.relativeLuminance(F>>8));if(P<A){const z=j(N,L,A);return P>_(D,C.relativeLuminance(z>>8))?F:z}return F}},b.reduceLuminance=j,b.increaseLuminance=E,b.toChannels=function(N){return[N>>24&255,N>>16&255,N>>8&255,255&N]}})(v||(u.rgba=v={})),u.toPaddedHex=S,u.contrastRatio=_},8969:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreTerminal=void 0;const h=c(844),m=c(2585),f=c(4348),g=c(7866),x=c(744),w=c(7302),C=c(6975),v=c(8460),S=c(1753),_=c(1480),b=c(7994),j=c(9282),E=c(5435),N=c(5981),L=c(2660);let A=!1;class D extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new v.EventEmitter),this._onScroll.event((F=>{var P;(P=this._onScrollApi)==null||P.fire(F.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(F){for(const P in F)this.optionsService.options[P]=F[P]}constructor(F){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new v.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new v.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new v.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new v.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new v.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new v.EventEmitter),this._instantiationService=new f.InstantiationService,this.optionsService=this.register(new w.OptionsService(F)),this._instantiationService.setService(m.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(m.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(m.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(m.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(m.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(_.UnicodeService)),this._instantiationService.setService(m.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(b.CharsetService),this._instantiationService.setService(m.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(L.OscLinkService),this._instantiationService.setService(m.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new E.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,v.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,v.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,v.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,v.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((P=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((P=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new N.WriteBuffer(((P,z)=>this._inputHandler.parse(P,z)))),this.register((0,v.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(F,P){this._writeBuffer.write(F,P)}writeSync(F,P){this._logService.logLevel<=m.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(F,P)}input(F,P=!0){this.coreService.triggerDataEvent(F,P)}resize(F,P){isNaN(F)||isNaN(P)||(F=Math.max(F,x.MINIMUM_COLS),P=Math.max(P,x.MINIMUM_ROWS),this._bufferService.resize(F,P))}scroll(F,P=!1){this._bufferService.scroll(F,P)}scrollLines(F,P,z){this._bufferService.scrollLines(F,P,z)}scrollPages(F){this.scrollLines(F*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(F){const P=F-this._bufferService.buffer.ydisp;P!==0&&this.scrollLines(P)}registerEscHandler(F,P){return this._inputHandler.registerEscHandler(F,P)}registerDcsHandler(F,P){return this._inputHandler.registerDcsHandler(F,P)}registerCsiHandler(F,P){return this._inputHandler.registerCsiHandler(F,P)}registerOscHandler(F,P){return this._inputHandler.registerOscHandler(F,P)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let F=!1;const P=this.optionsService.rawOptions.windowsPty;P&&P.buildNumber!==void 0&&P.buildNumber!==void 0?F=P.backend==="conpty"&&P.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(F=!0),F?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const F=[];F.push(this.onLineFeed(j.updateWindowsModeWrappedState.bind(null,this._bufferService))),F.push(this.registerCsiHandler({final:"H"},(()=>((0,j.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const P of F)P.dispose()}))}}}u.CoreTerminal=D},8460:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.runAndSubscribe=u.forwardEvent=u.EventEmitter=void 0,u.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=c=>(this._listeners.push(c),{dispose:()=>{if(!this._disposed){for(let h=0;h<this._listeners.length;h++)if(this._listeners[h]===c)return void this._listeners.splice(h,1)}}})),this._event}fire(c,h){const m=[];for(let f=0;f<this._listeners.length;f++)m.push(this._listeners[f]);for(let f=0;f<m.length;f++)m[f].call(void 0,c,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},u.forwardEvent=function(c,h){return c((m=>h.fire(m)))},u.runAndSubscribe=function(c,h){return h(void 0),c((m=>h(m)))}},5435:function(d,u,c){var h=this&&this.__decorate||function(Q,H,I,M){var V,$=arguments.length,ee=$<3?H:M===null?M=Object.getOwnPropertyDescriptor(H,I):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ee=Reflect.decorate(Q,H,I,M);else for(var Y=Q.length-1;Y>=0;Y--)(V=Q[Y])&&(ee=($<3?V(ee):$>3?V(H,I,ee):V(H,I))||ee);return $>3&&ee&&Object.defineProperty(H,I,ee),ee},m=this&&this.__param||function(Q,H){return function(I,M){H(I,M,Q)}};Object.defineProperty(u,"__esModule",{value:!0}),u.InputHandler=u.WindowsOptionsReportType=void 0;const f=c(2584),g=c(7116),x=c(2015),w=c(844),C=c(482),v=c(8437),S=c(8460),_=c(643),b=c(511),j=c(3734),E=c(2585),N=c(1480),L=c(6242),A=c(6351),D=c(5941),O={"(":0,")":1,"*":2,"+":3,"-":1,".":2},F=131072;function P(Q,H){if(Q>24)return H.setWinLines||!1;switch(Q){case 1:return!!H.restoreWin;case 2:return!!H.minimizeWin;case 3:return!!H.setWinPosition;case 4:return!!H.setWinSizePixels;case 5:return!!H.raiseWin;case 6:return!!H.lowerWin;case 7:return!!H.refreshWin;case 8:return!!H.setWinSizeChars;case 9:return!!H.maximizeWin;case 10:return!!H.fullscreenWin;case 11:return!!H.getWinState;case 13:return!!H.getWinPosition;case 14:return!!H.getWinSizePixels;case 15:return!!H.getScreenSizePixels;case 16:return!!H.getCellSizePixels;case 18:return!!H.getWinSizeChars;case 19:return!!H.getScreenSizeChars;case 20:return!!H.getIconTitle;case 21:return!!H.getWinTitle;case 22:return!!H.pushTitle;case 23:return!!H.popTitle;case 24:return!!H.setWinLines}return!1}var z;(function(Q){Q[Q.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",Q[Q.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(z||(u.WindowsOptionsReportType=z={}));let K=0;class q extends w.Disposable{getAttrData(){return this._curAttrData}constructor(H,I,M,V,$,ee,Y,X,U=new x.EscapeSequenceParser){super(),this._bufferService=H,this._charsetService=I,this._coreService=M,this._logService=V,this._optionsService=$,this._oscLinkService=ee,this._coreMouseService=Y,this._unicodeService=X,this._parser=U,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new b.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new S.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new S.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new S.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new S.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new S.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new S.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new S.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new S.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new S.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new S.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new S.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new S.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new S.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new W(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((B=>this._activeBuffer=B.activeBuffer))),this._parser.setCsiHandlerFallback(((B,J)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(B),params:J.toArray()})})),this._parser.setEscHandlerFallback((B=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(B)})})),this._parser.setExecuteHandlerFallback((B=>{this._logService.debug("Unknown EXECUTE code: ",{code:B})})),this._parser.setOscHandlerFallback(((B,J,se)=>{this._logService.debug("Unknown OSC code: ",{identifier:B,action:J,data:se})})),this._parser.setDcsHandlerFallback(((B,J,se)=>{J==="HOOK"&&(se=se.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(B),action:J,payload:se})})),this._parser.setPrintHandler(((B,J,se)=>this.print(B,J,se))),this._parser.registerCsiHandler({final:"@"},(B=>this.insertChars(B))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(B=>this.scrollLeft(B))),this._parser.registerCsiHandler({final:"A"},(B=>this.cursorUp(B))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(B=>this.scrollRight(B))),this._parser.registerCsiHandler({final:"B"},(B=>this.cursorDown(B))),this._parser.registerCsiHandler({final:"C"},(B=>this.cursorForward(B))),this._parser.registerCsiHandler({final:"D"},(B=>this.cursorBackward(B))),this._parser.registerCsiHandler({final:"E"},(B=>this.cursorNextLine(B))),this._parser.registerCsiHandler({final:"F"},(B=>this.cursorPrecedingLine(B))),this._parser.registerCsiHandler({final:"G"},(B=>this.cursorCharAbsolute(B))),this._parser.registerCsiHandler({final:"H"},(B=>this.cursorPosition(B))),this._parser.registerCsiHandler({final:"I"},(B=>this.cursorForwardTab(B))),this._parser.registerCsiHandler({final:"J"},(B=>this.eraseInDisplay(B,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(B=>this.eraseInDisplay(B,!0))),this._parser.registerCsiHandler({final:"K"},(B=>this.eraseInLine(B,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(B=>this.eraseInLine(B,!0))),this._parser.registerCsiHandler({final:"L"},(B=>this.insertLines(B))),this._parser.registerCsiHandler({final:"M"},(B=>this.deleteLines(B))),this._parser.registerCsiHandler({final:"P"},(B=>this.deleteChars(B))),this._parser.registerCsiHandler({final:"S"},(B=>this.scrollUp(B))),this._parser.registerCsiHandler({final:"T"},(B=>this.scrollDown(B))),this._parser.registerCsiHandler({final:"X"},(B=>this.eraseChars(B))),this._parser.registerCsiHandler({final:"Z"},(B=>this.cursorBackwardTab(B))),this._parser.registerCsiHandler({final:"`"},(B=>this.charPosAbsolute(B))),this._parser.registerCsiHandler({final:"a"},(B=>this.hPositionRelative(B))),this._parser.registerCsiHandler({final:"b"},(B=>this.repeatPrecedingCharacter(B))),this._parser.registerCsiHandler({final:"c"},(B=>this.sendDeviceAttributesPrimary(B))),this._parser.registerCsiHandler({prefix:">",final:"c"},(B=>this.sendDeviceAttributesSecondary(B))),this._parser.registerCsiHandler({final:"d"},(B=>this.linePosAbsolute(B))),this._parser.registerCsiHandler({final:"e"},(B=>this.vPositionRelative(B))),this._parser.registerCsiHandler({final:"f"},(B=>this.hVPosition(B))),this._parser.registerCsiHandler({final:"g"},(B=>this.tabClear(B))),this._parser.registerCsiHandler({final:"h"},(B=>this.setMode(B))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(B=>this.setModePrivate(B))),this._parser.registerCsiHandler({final:"l"},(B=>this.resetMode(B))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(B=>this.resetModePrivate(B))),this._parser.registerCsiHandler({final:"m"},(B=>this.charAttributes(B))),this._parser.registerCsiHandler({final:"n"},(B=>this.deviceStatus(B))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(B=>this.deviceStatusPrivate(B))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(B=>this.softReset(B))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(B=>this.setCursorStyle(B))),this._parser.registerCsiHandler({final:"r"},(B=>this.setScrollRegion(B))),this._parser.registerCsiHandler({final:"s"},(B=>this.saveCursor(B))),this._parser.registerCsiHandler({final:"t"},(B=>this.windowOptions(B))),this._parser.registerCsiHandler({final:"u"},(B=>this.restoreCursor(B))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(B=>this.insertColumns(B))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(B=>this.deleteColumns(B))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(B=>this.selectProtected(B))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(B=>this.requestMode(B,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(B=>this.requestMode(B,!1))),this._parser.setExecuteHandler(f.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(f.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(f.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(f.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(f.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(f.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(f.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(f.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(f.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new L.OscHandler((B=>(this.setTitle(B),this.setIconName(B),!0)))),this._parser.registerOscHandler(1,new L.OscHandler((B=>this.setIconName(B)))),this._parser.registerOscHandler(2,new L.OscHandler((B=>this.setTitle(B)))),this._parser.registerOscHandler(4,new L.OscHandler((B=>this.setOrReportIndexedColor(B)))),this._parser.registerOscHandler(8,new L.OscHandler((B=>this.setHyperlink(B)))),this._parser.registerOscHandler(10,new L.OscHandler((B=>this.setOrReportFgColor(B)))),this._parser.registerOscHandler(11,new L.OscHandler((B=>this.setOrReportBgColor(B)))),this._parser.registerOscHandler(12,new L.OscHandler((B=>this.setOrReportCursorColor(B)))),this._parser.registerOscHandler(104,new L.OscHandler((B=>this.restoreIndexedColor(B)))),this._parser.registerOscHandler(110,new L.OscHandler((B=>this.restoreFgColor(B)))),this._parser.registerOscHandler(111,new L.OscHandler((B=>this.restoreBgColor(B)))),this._parser.registerOscHandler(112,new L.OscHandler((B=>this.restoreCursorColor(B)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const B in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:B},(()=>this.selectCharset("("+B))),this._parser.registerEscHandler({intermediates:")",final:B},(()=>this.selectCharset(")"+B))),this._parser.registerEscHandler({intermediates:"*",final:B},(()=>this.selectCharset("*"+B))),this._parser.registerEscHandler({intermediates:"+",final:B},(()=>this.selectCharset("+"+B))),this._parser.registerEscHandler({intermediates:"-",final:B},(()=>this.selectCharset("-"+B))),this._parser.registerEscHandler({intermediates:".",final:B},(()=>this.selectCharset("."+B))),this._parser.registerEscHandler({intermediates:"/",final:B},(()=>this.selectCharset("/"+B)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((B=>(this._logService.error("Parsing error: ",B),B))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((B,J)=>this.requestStatusString(B,J))))}_preserveStack(H,I,M,V){this._parseStack.paused=!0,this._parseStack.cursorStartX=H,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=M,this._parseStack.position=V}_logSlowResolvingAsync(H){this._logService.logLevel<=E.LogLevelEnum.WARN&&Promise.race([H,new Promise(((I,M)=>setTimeout((()=>M("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(H,I){let M,V=this._activeBuffer.x,$=this._activeBuffer.y,ee=0;const Y=this._parseStack.paused;if(Y){if(M=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync(M),M;V=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,H.length>F&&(ee=this._parseStack.position+F)}if(this._logService.logLevel<=E.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof H=="string"?` "${H}"`:` "${Array.prototype.map.call(H,(B=>String.fromCharCode(B))).join("")}"`),typeof H=="string"?H.split("").map((B=>B.charCodeAt(0))):H),this._parseBuffer.length<H.length&&this._parseBuffer.length<F&&(this._parseBuffer=new Uint32Array(Math.min(H.length,F))),Y||this._dirtyRowTracker.clearRange(),H.length>F)for(let B=ee;B<H.length;B+=F){const J=B+F<H.length?B+F:H.length,se=typeof H=="string"?this._stringDecoder.decode(H.substring(B,J),this._parseBuffer):this._utf8Decoder.decode(H.subarray(B,J),this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,se))return this._preserveStack(V,$,se,B),this._logSlowResolvingAsync(M),M}else if(!Y){const B=typeof H=="string"?this._stringDecoder.decode(H,this._parseBuffer):this._utf8Decoder.decode(H,this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,B))return this._preserveStack(V,$,B,0),this._logSlowResolvingAsync(M),M}this._activeBuffer.x===V&&this._activeBuffer.y===$||this._onCursorMove.fire();const X=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),U=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);U<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(U,this._bufferService.rows-1),Math.min(X,this._bufferService.rows-1))}print(H,I,M){let V,$;const ee=this._charsetService.charset,Y=this._optionsService.rawOptions.screenReaderMode,X=this._bufferService.cols,U=this._coreService.decPrivateModes.wraparound,B=this._coreService.modes.insertMode,J=this._curAttrData;let se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&M-I>0&&se.getWidth(this._activeBuffer.x-1)===2&&se.setCellFromCodepoint(this._activeBuffer.x-1,0,1,J);let ne=this._parser.precedingJoinState;for(let ie=I;ie<M;++ie){if(V=H[ie],V<127&&ee){const $e=ee[String.fromCharCode(V)];$e&&(V=$e.charCodeAt(0))}const de=this._unicodeService.charProperties(V,ne);$=N.UnicodeService.extractWidth(de);const pe=N.UnicodeService.extractShouldJoin(de),Oe=pe?N.UnicodeService.extractWidth(ne):0;if(ne=de,Y&&this._onA11yChar.fire((0,C.stringFromCodePoint)(V)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+$-Oe>X){if(U){const $e=se;let Pe=this._activeBuffer.x-Oe;for(this._activeBuffer.x=Oe,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Oe>0&&se instanceof v.BufferLine&&se.copyCellsFrom($e,Pe,0,Oe,!1);Pe<X;)$e.setCellFromCodepoint(Pe++,0,1,J)}else if(this._activeBuffer.x=X-1,$===2)continue}if(pe&&this._activeBuffer.x){const $e=se.getWidth(this._activeBuffer.x-1)?1:2;se.addCodepointToCell(this._activeBuffer.x-$e,V,$);for(let Pe=$-Oe;--Pe>=0;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,J)}else if(B&&(se.insertCells(this._activeBuffer.x,$-Oe,this._activeBuffer.getNullCell(J)),se.getWidth(X-1)===2&&se.setCellFromCodepoint(X-1,_.NULL_CELL_CODE,_.NULL_CELL_WIDTH,J)),se.setCellFromCodepoint(this._activeBuffer.x++,V,$,J),$>0)for(;--$;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,J)}this._parser.precedingJoinState=ne,this._activeBuffer.x<X&&M-I>0&&se.getWidth(this._activeBuffer.x)===0&&!se.hasContent(this._activeBuffer.x)&&se.setCellFromCodepoint(this._activeBuffer.x,0,1,J),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(H,I){return H.final!=="t"||H.prefix||H.intermediates?this._parser.registerCsiHandler(H,I):this._parser.registerCsiHandler(H,(M=>!P(M.params[0],this._optionsService.rawOptions.windowOptions)||I(M)))}registerDcsHandler(H,I){return this._parser.registerDcsHandler(H,new A.DcsHandler(I))}registerEscHandler(H,I){return this._parser.registerEscHandler(H,I)}registerOscHandler(H,I){return this._parser.registerOscHandler(H,new L.OscHandler(I))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var H;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&&((H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&H.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);I.hasWidth(this._activeBuffer.x)&&!I.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const H=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-H),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(H=this._bufferService.cols-1){this._activeBuffer.x=Math.min(H,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(H,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=H,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=H,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(H,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+H,this._activeBuffer.y+I)}cursorUp(H){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,H.params[0]||1)):this._moveCursor(0,-(H.params[0]||1)),!0}cursorDown(H){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,H.params[0]||1)):this._moveCursor(0,H.params[0]||1),!0}cursorForward(H){return this._moveCursor(H.params[0]||1,0),!0}cursorBackward(H){return this._moveCursor(-(H.params[0]||1),0),!0}cursorNextLine(H){return this.cursorDown(H),this._activeBuffer.x=0,!0}cursorPrecedingLine(H){return this.cursorUp(H),this._activeBuffer.x=0,!0}cursorCharAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(H){return this._setCursor(H.length>=2?(H.params[1]||1)-1:0,(H.params[0]||1)-1),!0}charPosAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(H){return this._moveCursor(H.params[0]||1,0),!0}linePosAbsolute(H){return this._setCursor(this._activeBuffer.x,(H.params[0]||1)-1),!0}vPositionRelative(H){return this._moveCursor(0,H.params[0]||1),!0}hVPosition(H){return this.cursorPosition(H),!0}tabClear(H){const I=H.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=H.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=H.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(H){const I=H.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(H,I,M,V=!1,$=!1){const ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);ee.replaceCells(I,M,this._activeBuffer.getNullCell(this._eraseAttrData()),$),V&&(ee.isWrapped=!1)}_resetBufferLine(H,I=!1){const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);M&&(M.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+H),M.isWrapped=!1)}eraseInDisplay(H,I=!1){let M;switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);M<this._bufferService.rows;M++)this._resetBufferLine(M,I);this._dirtyRowTracker.markDirty(M);break;case 1:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M,0,this._activeBuffer.x+1,!0,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(M+1).isWrapped=!1);M--;)this._resetBufferLine(M,I);this._dirtyRowTracker.markDirty(0);break;case 2:for(M=this._bufferService.rows,this._dirtyRowTracker.markDirty(M-1);M--;)this._resetBufferLine(M,I);this._dirtyRowTracker.markDirty(0);break;case 3:const V=this._activeBuffer.lines.length-this._bufferService.rows;V>0&&(this._activeBuffer.lines.trimStart(V),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-V,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-V,0),this._onScroll.fire(0))}return!0}eraseInLine(H,I=!1){switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(H){this._restrictCursor();let I=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y,V=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-V+1;for(;I--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(M,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(H){this._restrictCursor();let I=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y;let V;for(V=this._bufferService.rows-1-this._activeBuffer.scrollBottom,V=this._bufferService.rows-1+this._activeBuffer.ybase-V;I--;)this._activeBuffer.lines.splice(M,1),this._activeBuffer.lines.splice(V,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(H){let I=H.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(H){let I=H.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(v.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);V.deleteCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);V.insertCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);V.insertCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);V.deleteCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(H.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(H){const I=this._parser.precedingJoinState;if(!I)return!0;const M=H.params[0]||1,V=N.UnicodeService.extractWidth(I),$=this._activeBuffer.x-V,ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString($),Y=new Uint32Array(ee.length*M);let X=0;for(let B=0;B<ee.length;){const J=ee.codePointAt(B)||0;Y[X++]=J,B+=J>65535?2:1}let U=X;for(let B=1;B<M;++B)Y.copyWithin(U,0,X),U+=X;return this.print(Y,0,U),!0}sendDeviceAttributesPrimary(H){return H.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(f.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(f.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(H){return H.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(f.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(f.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(H.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(f.C0.ESC+"[>83;40003;0c")),!0}_is(H){return(this._optionsService.rawOptions.termName+"").indexOf(H)===0}setMode(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),H.params[I]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(H,I){const M=this._coreService.decPrivateModes,{activeProtocol:V,activeEncoding:$}=this._coreMouseService,ee=this._coreService,{buffers:Y,cols:X}=this._bufferService,{active:U,alt:B}=Y,J=this._optionsService.rawOptions,se=pe=>pe?1:2,ne=H.params[0];return ie=ne,de=I?ne===2?4:ne===4?se(ee.modes.insertMode):ne===12?3:ne===20?se(J.convertEol):0:ne===1?se(M.applicationCursorKeys):ne===3?J.windowOptions.setWinLines?X===80?2:X===132?1:0:0:ne===6?se(M.origin):ne===7?se(M.wraparound):ne===8?3:ne===9?se(V==="X10"):ne===12?se(J.cursorBlink):ne===25?se(!ee.isCursorHidden):ne===45?se(M.reverseWraparound):ne===66?se(M.applicationKeypad):ne===67?4:ne===1e3?se(V==="VT200"):ne===1002?se(V==="DRAG"):ne===1003?se(V==="ANY"):ne===1004?se(M.sendFocus):ne===1005?4:ne===1006?se($==="SGR"):ne===1015?4:ne===1016?se($==="SGR_PIXELS"):ne===1048?1:ne===47||ne===1047||ne===1049?se(U===B):ne===2004?se(M.bracketedPasteMode):0,ee.triggerDataEvent(`${f.C0.ESC}[${I?"":"?"}${ie};${de}$y`),!0;var ie,de}_updateAttrColor(H,I,M,V,$){return I===2?(H|=50331648,H&=-16777216,H|=j.AttributeData.fromColorRGB([M,V,$])):I===5&&(H&=-50331904,H|=33554432|255&M),H}_extractColor(H,I,M){const V=[0,0,-1,0,0,0];let $=0,ee=0;do{if(V[ee+$]=H.params[I+ee],H.hasSubParams(I+ee)){const Y=H.getSubParams(I+ee);let X=0;do V[1]===5&&($=1),V[ee+X+1+$]=Y[X];while(++X<Y.length&&X+ee+1+$<V.length);break}if(V[1]===5&&ee+$>=2||V[1]===2&&ee+$>=5)break;V[1]&&($=1)}while(++ee+I<H.length&&ee+$<V.length);for(let Y=2;Y<V.length;++Y)V[Y]===-1&&(V[Y]=0);switch(V[0]){case 38:M.fg=this._updateAttrColor(M.fg,V[1],V[3],V[4],V[5]);break;case 48:M.bg=this._updateAttrColor(M.bg,V[1],V[3],V[4],V[5]);break;case 58:M.extended=M.extended.clone(),M.extended.underlineColor=this._updateAttrColor(M.extended.underlineColor,V[1],V[3],V[4],V[5])}return ee}_processUnderline(H,I){I.extended=I.extended.clone(),(!~H||H>5)&&(H=1),I.extended.underlineStyle=H,I.fg|=268435456,H===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0(H){H.fg=v.DEFAULT_ATTR_DATA.fg,H.bg=v.DEFAULT_ATTR_DATA.bg,H.extended=H.extended.clone(),H.extended.underlineStyle=0,H.extended.underlineColor&=-67108864,H.updateExtended()}charAttributes(H){if(H.length===1&&H.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=H.length;let M;const V=this._curAttrData;for(let $=0;$<I;$++)M=H.params[$],M>=30&&M<=37?(V.fg&=-50331904,V.fg|=16777216|M-30):M>=40&&M<=47?(V.bg&=-50331904,V.bg|=16777216|M-40):M>=90&&M<=97?(V.fg&=-50331904,V.fg|=16777224|M-90):M>=100&&M<=107?(V.bg&=-50331904,V.bg|=16777224|M-100):M===0?this._processSGR0(V):M===1?V.fg|=134217728:M===3?V.bg|=67108864:M===4?(V.fg|=268435456,this._processUnderline(H.hasSubParams($)?H.getSubParams($)[0]:1,V)):M===5?V.fg|=536870912:M===7?V.fg|=67108864:M===8?V.fg|=1073741824:M===9?V.fg|=2147483648:M===2?V.bg|=134217728:M===21?this._processUnderline(2,V):M===22?(V.fg&=-134217729,V.bg&=-134217729):M===23?V.bg&=-67108865:M===24?(V.fg&=-268435457,this._processUnderline(0,V)):M===25?V.fg&=-536870913:M===27?V.fg&=-67108865:M===28?V.fg&=-1073741825:M===29?V.fg&=2147483647:M===39?(V.fg&=-67108864,V.fg|=16777215&v.DEFAULT_ATTR_DATA.fg):M===49?(V.bg&=-67108864,V.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):M===38||M===48||M===58?$+=this._extractColor(H,$,V):M===53?V.bg|=1073741824:M===55?V.bg&=-1073741825:M===59?(V.extended=V.extended.clone(),V.extended.underlineColor=-1,V.updateExtended()):M===100?(V.fg&=-67108864,V.fg|=16777215&v.DEFAULT_ATTR_DATA.fg,V.bg&=-67108864,V.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",M);return!0}deviceStatus(H){switch(H.params[0]){case 5:this._coreService.triggerDataEvent(`${f.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${f.C0.ESC}[${I};${M}R`)}return!0}deviceStatusPrivate(H){if(H.params[0]===6){const I=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${f.C0.ESC}[?${I};${M}R`)}return!0}softReset(H){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(H){const I=H.params[0]||1;switch(I){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const M=I%2==1;return this._optionsService.options.cursorBlink=M,!0}setScrollRegion(H){const I=H.params[0]||1;let M;return(H.length<2||(M=H.params[1])>this._bufferService.rows||M===0)&&(M=this._bufferService.rows),M>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=M-1,this._setCursor(0,0)),!0}windowOptions(H){if(!P(H.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=H.length>1?H.params[1]:0;switch(H.params[0]){case 14:I!==2&&this._onRequestWindowsOptionsReport.fire(z.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(z.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${f.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(H){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(H){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(H){return this._windowTitle=H,this._onTitleChange.fire(H),!0}setIconName(H){return this._iconName=H,!0}setOrReportIndexedColor(H){const I=[],M=H.split(";");for(;M.length>1;){const V=M.shift(),$=M.shift();if(/^\d+$/.exec(V)){const ee=parseInt(V);if(Z(ee))if($==="?")I.push({type:0,index:ee});else{const Y=(0,D.parseColor)($);Y&&I.push({type:1,index:ee,color:Y})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink(H){const I=H.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink(H,I){this._getCurrentLinkId()&&this._finishHyperlink();const M=H.split(":");let V;const $=M.findIndex((ee=>ee.startsWith("id=")));return $!==-1&&(V=M[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:V,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(H,I){const M=H.split(";");for(let V=0;V<M.length&&!(I>=this._specialColors.length);++V,++I)if(M[V]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const $=(0,D.parseColor)(M[V]);$&&this._onColor.fire([{type:1,index:this._specialColors[I],color:$}])}return!0}setOrReportFgColor(H){return this._setOrReportSpecialColor(H,0)}setOrReportBgColor(H){return this._setOrReportSpecialColor(H,1)}setOrReportCursorColor(H){return this._setOrReportSpecialColor(H,2)}restoreIndexedColor(H){if(!H)return this._onColor.fire([{type:2}]),!0;const I=[],M=H.split(";");for(let V=0;V<M.length;++V)if(/^\d+$/.exec(M[V])){const $=parseInt(M[V]);Z($)&&I.push({type:2,index:$})}return I.length&&this._onColor.fire(I),!0}restoreFgColor(H){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(H){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(H){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,g.DEFAULT_CHARSET),!0}selectCharset(H){return H.length!==2?(this.selectDefaultCharset(),!0):(H[0]==="/"||this._charsetService.setgCharset(O[H[0]],g.CHARSETS[H[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const H=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,H,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=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(H){return this._charsetService.setgLevel(H),!0}screenAlignmentPattern(){const H=new b.CellData;H.content=4194373,H.fg=this._curAttrData.fg,H.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const M=this._activeBuffer.ybase+this._activeBuffer.y+I,V=this._activeBuffer.lines.get(M);V&&(V.fill(H),V.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(H,I){const M=this._bufferService.buffer,V=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${f.C0.ESC}${$}${f.C0.ESC}\\`),!0))(H==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:H==='"p'?'P1$r61;1"p':H==="r"?`P1$r${M.scrollTop+1};${M.scrollBottom+1}r`:H==="m"?"P1$r0m":H===" q"?`P1$r${{block:2,underline:4,bar:6}[V.cursorStyle]-(V.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(H,I){this._dirtyRowTracker.markRangeDirty(H,I)}}u.InputHandler=q;let W=class{constructor(Q){this._bufferService=Q,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(Q){Q<this.start?this.start=Q:Q>this.end&&(this.end=Q)}markRangeDirty(Q,H){Q>H&&(K=Q,Q=H,H=K),Q<this.start&&(this.start=Q),H>this.end&&(this.end=H)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Z(Q){return 0<=Q&&Q<256}W=h([m(0,E.IBufferService)],W)},844:(d,u)=>{function c(h){for(const m of h)m.dispose();h.length=0}Object.defineProperty(u,"__esModule",{value:!0}),u.getDisposeArrayDisposable=u.disposeArray=u.toDisposable=u.MutableDisposable=u.Disposable=void 0,u.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const m=this._disposables.indexOf(h);m!==-1&&this._disposables.splice(m,1)}},u.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){var m;this._isDisposed||h===this._value||((m=this._value)==null||m.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){var h;this._isDisposed=!0,(h=this._value)==null||h.dispose(),this._value=void 0}},u.toDisposable=function(h){return{dispose:h}},u.disposeArray=c,u.getDisposeArrayDisposable=function(h){return{dispose:()=>c(h)}}},1505:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.FourKeyMap=u.TwoKeyMap=void 0;class c{constructor(){this._data={}}set(m,f,g){this._data[m]||(this._data[m]={}),this._data[m][f]=g}get(m,f){return this._data[m]?this._data[m][f]:void 0}clear(){this._data={}}}u.TwoKeyMap=c,u.FourKeyMap=class{constructor(){this._data=new c}set(h,m,f,g,x){this._data.get(h,m)||this._data.set(h,m,new c),this._data.get(h,m).set(f,g,x)}get(h,m,f,g){var x;return(x=this._data.get(h,m))==null?void 0:x.get(f,g)}clear(){this._data.clear()}}},6114:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.isChromeOS=u.isLinux=u.isWindows=u.isIphone=u.isIpad=u.isMac=u.getSafariVersion=u.isSafari=u.isLegacyEdge=u.isFirefox=u.isNode=void 0,u.isNode=typeof process<"u"&&"title"in process;const c=u.isNode?"node":navigator.userAgent,h=u.isNode?"node":navigator.platform;u.isFirefox=c.includes("Firefox"),u.isLegacyEdge=c.includes("Edge"),u.isSafari=/^((?!chrome|android).)*safari/i.test(c),u.getSafariVersion=function(){if(!u.isSafari)return 0;const m=c.match(/Version\/(\d+)/);return m===null||m.length<2?0:parseInt(m[1])},u.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h),u.isIpad=h==="iPad",u.isIphone=h==="iPhone",u.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),u.isLinux=h.indexOf("Linux")>=0,u.isChromeOS=/\bCrOS\b/.test(c)},6106:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.SortedList=void 0;let c=0;u.SortedList=class{constructor(h){this._getKey=h,this._array=[]}clear(){this._array.length=0}insert(h){this._array.length!==0?(c=this._search(this._getKey(h)),this._array.splice(c,0,h)):this._array.push(h)}delete(h){if(this._array.length===0)return!1;const m=this._getKey(h);if(m===void 0||(c=this._search(m),c===-1)||this._getKey(this._array[c])!==m)return!1;do if(this._array[c]===h)return this._array.splice(c,1),!0;while(++c<this._array.length&&this._getKey(this._array[c])===m);return!1}*getKeyIterator(h){if(this._array.length!==0&&(c=this._search(h),!(c<0||c>=this._array.length)&&this._getKey(this._array[c])===h))do yield this._array[c];while(++c<this._array.length&&this._getKey(this._array[c])===h)}forEachByKey(h,m){if(this._array.length!==0&&(c=this._search(h),!(c<0||c>=this._array.length)&&this._getKey(this._array[c])===h))do m(this._array[c]);while(++c<this._array.length&&this._getKey(this._array[c])===h)}values(){return[...this._array].values()}_search(h){let m=0,f=this._array.length-1;for(;f>=m;){let g=m+f>>1;const x=this._getKey(this._array[g]);if(x>h)f=g-1;else{if(!(x<h)){for(;g>0&&this._getKey(this._array[g-1])===h;)g--;return g}m=g+1}}return m}}},7226:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DebouncedIdleTask=u.IdleTaskQueue=u.PriorityTaskQueue=void 0;const h=c(6114);class m{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),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(x){this._idleCallback=void 0;let w=0,C=0,v=x.timeRemaining(),S=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),S=x.timeRemaining(),1.5*C>S)return v-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(v-w))}ms`),void this._start();v=S}this.clear()}}class f extends m{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}u.PriorityTaskQueue=f,u.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends m{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:f,u.DebouncedIdleTask=class{constructor(){this._queue=new u.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.updateWindowsModeWrappedState=void 0;const h=c(643);u.updateWindowsModeWrappedState=function(m){const f=m.buffer.lines.get(m.buffer.ybase+m.buffer.y-1),g=f==null?void 0:f.get(m.cols-1),x=m.buffer.lines.get(m.buffer.ybase+m.buffer.y);x&&g&&(x.isWrapped=g[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&g[h.CHAR_DATA_CODE_INDEX]!==h.WHITESPACE_CELL_CODE)}},3734:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ExtendedAttrs=u.AttributeData=void 0;class c{constructor(){this.fg=0,this.bg=0,this.extended=new h}static toColorRGB(f){return[f>>>16&255,f>>>8&255,255&f]}static fromColorRGB(f){return(255&f[0])<<16|(255&f[1])<<8|255&f[2]}clone(){const f=new c;return f.fg=this.fg,f.bg=this.bg,f.extended=this.extended.clone(),f}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}u.AttributeData=c;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(f){this._ext=f}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(f){this._ext&=-469762049,this._ext|=f<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(f){this._ext&=-67108864,this._ext|=67108863&f}get urlId(){return this._urlId}set urlId(f){this._urlId=f}get underlineVariantOffset(){const f=(3758096384&this._ext)>>29;return f<0?4294967288^f:f}set underlineVariantOffset(f){this._ext&=536870911,this._ext|=f<<29&3758096384}constructor(f=0,g=0){this._ext=0,this._urlId=0,this._ext=f,this._urlId=g}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}u.ExtendedAttrs=h},9092:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Buffer=u.MAX_BUFFER_SIZE=void 0;const h=c(6349),m=c(7226),f=c(3734),g=c(8437),x=c(4634),w=c(511),C=c(643),v=c(4863),S=c(7116);u.MAX_BUFFER_SIZE=4294967295,u.Buffer=class{constructor(_,b,j){this._hasScrollback=_,this._optionsService=b,this._bufferService=j,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new m.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(_){return _?(this._nullCell.fg=_.fg,this._nullCell.bg=_.bg,this._nullCell.extended=_.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new f.ExtendedAttrs),this._nullCell}getWhitespaceCell(_){return _?(this._whitespaceCell.fg=_.fg,this._whitespaceCell.bg=_.bg,this._whitespaceCell.extended=_.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new f.ExtendedAttrs),this._whitespaceCell}getBlankLine(_,b){return new g.BufferLine(this._bufferService.cols,this.getNullCell(_),b)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const _=this.ybase+this.y-this.ydisp;return _>=0&&_<this._rows}_getCorrectBufferLength(_){if(!this._hasScrollback)return _;const b=_+this._optionsService.rawOptions.scrollback;return b>u.MAX_BUFFER_SIZE?u.MAX_BUFFER_SIZE:b}fillViewportRows(_){if(this.lines.length===0){_===void 0&&(_=g.DEFAULT_ATTR_DATA);let b=this._rows;for(;b--;)this.lines.push(this.getBlankLine(_))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(_,b){const j=this.getNullCell(g.DEFAULT_ATTR_DATA);let E=0;const N=this._getCorrectBufferLength(b);if(N>this.lines.maxLength&&(this.lines.maxLength=N),this.lines.length>0){if(this._cols<_)for(let A=0;A<this.lines.length;A++)E+=+this.lines.get(A).resize(_,j);let L=0;if(this._rows<b)for(let A=this._rows;A<b;A++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(_,j)):this.ybase>0&&this.lines.length<=this.ybase+this.y+L+1?(this.ybase--,L++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(_,j)));else for(let A=this._rows;A>b;A--)this.lines.length>b+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(N<this.lines.maxLength){const A=this.lines.length-N;A>0&&(this.lines.trimStart(A),this.ybase=Math.max(this.ybase-A,0),this.ydisp=Math.max(this.ydisp-A,0),this.savedY=Math.max(this.savedY-A,0)),this.lines.maxLength=N}this.x=Math.min(this.x,_-1),this.y=Math.min(this.y,b-1),L&&(this.y+=L),this.savedX=Math.min(this.savedX,_-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(_,b),this._cols>_))for(let L=0;L<this.lines.length;L++)E+=+this.lines.get(L).resize(_,j);this._cols=_,this._rows=b,this._memoryCleanupQueue.clear(),E>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let _=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,_=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if(b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),b>100)return!0;return _}get _isReflowEnabled(){const _=this._optionsService.rawOptions.windowsPty;return _&&_.buildNumber?this._hasScrollback&&_.backend==="conpty"&&_.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(_,b){this._cols!==_&&(_>this._cols?this._reflowLarger(_,b):this._reflowSmaller(_,b))}_reflowLarger(_,b){const j=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,_,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(j.length>0){const E=(0,x.reflowLargerCreateNewLayout)(this.lines,j);(0,x.reflowLargerApplyNewLayout)(this.lines,E.layout),this._reflowLargerAdjustViewport(_,b,E.countRemoved)}}_reflowLargerAdjustViewport(_,b,j){const E=this.getNullCell(g.DEFAULT_ATTR_DATA);let N=j;for(;N-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new g.BufferLine(_,E))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-j,0)}_reflowSmaller(_,b){const j=this.getNullCell(g.DEFAULT_ATTR_DATA),E=[];let N=0;for(let L=this.lines.length-1;L>=0;L--){let A=this.lines.get(L);if(!A||!A.isWrapped&&A.getTrimmedLength()<=_)continue;const D=[A];for(;A.isWrapped&&L>0;)A=this.lines.get(--L),D.unshift(A);const O=this.ybase+this.y;if(O>=L&&O<L+D.length)continue;const F=D[D.length-1].getTrimmedLength(),P=(0,x.reflowSmallerGetNewLineLengths)(D,this._cols,_),z=P.length-D.length;let K;K=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+z):Math.max(0,this.lines.length-this.lines.maxLength+z);const q=[];for(let M=0;M<z;M++){const V=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);q.push(V)}q.length>0&&(E.push({start:L+D.length+N,newLines:q}),N+=q.length),D.push(...q);let W=P.length-1,Z=P[W];Z===0&&(W--,Z=P[W]);let Q=D.length-z-1,H=F;for(;Q>=0;){const M=Math.min(H,Z);if(D[W]===void 0)break;if(D[W].copyCellsFrom(D[Q],H-M,Z-M,M,!0),Z-=M,Z===0&&(W--,Z=P[W]),H-=M,H===0){Q--;const V=Math.max(Q,0);H=(0,x.getWrappedLineTrimmedLength)(D,V,this._cols)}}for(let M=0;M<D.length;M++)P[M]<_&&D[M].setCell(P[M],j);let I=z-K;for(;I-- >0;)this.ybase===0?this.y<b-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+N)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+z,this.ybase+b-1)}if(E.length>0){const L=[],A=[];for(let W=0;W<this.lines.length;W++)A.push(this.lines.get(W));const D=this.lines.length;let O=D-1,F=0,P=E[F];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+N);let z=0;for(let W=Math.min(this.lines.maxLength-1,D+N-1);W>=0;W--)if(P&&P.start>O+z){for(let Z=P.newLines.length-1;Z>=0;Z--)this.lines.set(W--,P.newLines[Z]);W++,L.push({index:O+1,amount:P.newLines.length}),z+=P.newLines.length,P=E[++F]}else this.lines.set(W,A[O--]);let K=0;for(let W=L.length-1;W>=0;W--)L[W].index+=K,this.lines.onInsertEmitter.fire(L[W]),K+=L[W].amount;const q=Math.max(0,D+N-this.lines.maxLength);q>0&&this.lines.onTrimEmitter.fire(q)}}translateBufferLineToString(_,b,j=0,E){const N=this.lines.get(_);return N?N.translateToString(b,j,E):""}getWrappedRangeForLine(_){let b=_,j=_;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;j+1<this.lines.length&&this.lines.get(j+1).isWrapped;)j++;return{first:b,last:j}}setupTabStops(_){for(_!=null?this.tabs[_]||(_=this.prevStop(_)):(this.tabs={},_=0);_<this._cols;_+=this._optionsService.rawOptions.tabStopWidth)this.tabs[_]=!0}prevStop(_){for(_==null&&(_=this.x);!this.tabs[--_]&&_>0;);return _>=this._cols?this._cols-1:_<0?0:_}nextStop(_){for(_==null&&(_=this.x);!this.tabs[++_]&&_<this._cols;);return _>=this._cols?this._cols-1:_<0?0:_}clearMarkers(_){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].line===_&&(this.markers[b].dispose(),this.markers.splice(b--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let _=0;_<this.markers.length;_++)this.markers[_].dispose(),this.markers.splice(_--,1);this._isClearing=!1}addMarker(_){const b=new v.Marker(_);return this.markers.push(b),b.register(this.lines.onTrim((j=>{b.line-=j,b.line<0&&b.dispose()}))),b.register(this.lines.onInsert((j=>{b.line>=j.index&&(b.line+=j.amount)}))),b.register(this.lines.onDelete((j=>{b.line>=j.index&&b.line<j.index+j.amount&&b.dispose(),b.line>j.index&&(b.line-=j.amount)}))),b.register(b.onDispose((()=>this._removeMarker(b)))),b}_removeMarker(_){this._isClearing||this.markers.splice(this.markers.indexOf(_),1)}}},8437:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLine=u.DEFAULT_ATTR_DATA=void 0;const h=c(3734),m=c(511),f=c(643),g=c(482);u.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let x=0;class w{constructor(v,S,_=!1){this.isWrapped=_,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*v);const b=S||m.CellData.fromCharData([0,f.NULL_CELL_CHAR,f.NULL_CELL_WIDTH,f.NULL_CELL_CODE]);for(let j=0;j<v;++j)this.setCell(j,b);this.length=v}get(v){const S=this._data[3*v+0],_=2097151&S;return[this._data[3*v+1],2097152&S?this._combined[v]:_?(0,g.stringFromCodePoint)(_):"",S>>22,2097152&S?this._combined[v].charCodeAt(this._combined[v].length-1):_]}set(v,S){this._data[3*v+1]=S[f.CHAR_DATA_ATTR_INDEX],S[f.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[v]=S[1],this._data[3*v+0]=2097152|v|S[f.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*v+0]=S[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[f.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(v){return this._data[3*v+0]>>22}hasWidth(v){return 12582912&this._data[3*v+0]}getFg(v){return this._data[3*v+1]}getBg(v){return this._data[3*v+2]}hasContent(v){return 4194303&this._data[3*v+0]}getCodePoint(v){const S=this._data[3*v+0];return 2097152&S?this._combined[v].charCodeAt(this._combined[v].length-1):2097151&S}isCombined(v){return 2097152&this._data[3*v+0]}getString(v){const S=this._data[3*v+0];return 2097152&S?this._combined[v]:2097151&S?(0,g.stringFromCodePoint)(2097151&S):""}isProtected(v){return 536870912&this._data[3*v+2]}loadCell(v,S){return x=3*v,S.content=this._data[x+0],S.fg=this._data[x+1],S.bg=this._data[x+2],2097152&S.content&&(S.combinedData=this._combined[v]),268435456&S.bg&&(S.extended=this._extendedAttrs[v]),S}setCell(v,S){2097152&S.content&&(this._combined[v]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[v]=S.extended),this._data[3*v+0]=S.content,this._data[3*v+1]=S.fg,this._data[3*v+2]=S.bg}setCellFromCodepoint(v,S,_,b){268435456&b.bg&&(this._extendedAttrs[v]=b.extended),this._data[3*v+0]=S|_<<22,this._data[3*v+1]=b.fg,this._data[3*v+2]=b.bg}addCodepointToCell(v,S,_){let b=this._data[3*v+0];2097152&b?this._combined[v]+=(0,g.stringFromCodePoint)(S):2097151&b?(this._combined[v]=(0,g.stringFromCodePoint)(2097151&b)+(0,g.stringFromCodePoint)(S),b&=-2097152,b|=2097152):b=S|4194304,_&&(b&=-12582913,b|=_<<22),this._data[3*v+0]=b}insertCells(v,S,_){if((v%=this.length)&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),S<this.length-v){const b=new m.CellData;for(let j=this.length-v-S-1;j>=0;--j)this.setCell(v+S+j,this.loadCell(v+j,b));for(let j=0;j<S;++j)this.setCell(v+j,_)}else for(let b=v;b<this.length;++b)this.setCell(b,_);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,_)}deleteCells(v,S,_){if(v%=this.length,S<this.length-v){const b=new m.CellData;for(let j=0;j<this.length-v-S;++j)this.setCell(v+j,this.loadCell(v+S+j,b));for(let j=this.length-S;j<this.length;++j)this.setCell(j,_)}else for(let b=v;b<this.length;++b)this.setCell(b,_);v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),this.getWidth(v)!==0||this.hasContent(v)||this.setCellFromCodepoint(v,0,1,_)}replaceCells(v,S,_,b=!1){if(b)for(v&&this.getWidth(v-1)===2&&!this.isProtected(v-1)&&this.setCellFromCodepoint(v-1,0,1,_),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,_);v<S&&v<this.length;)this.isProtected(v)||this.setCell(v,_),v++;else for(v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,_);v<S&&v<this.length;)this.setCell(v++,_)}resize(v,S){if(v===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const _=3*v;if(v>this.length){if(this._data.buffer.byteLength>=4*_)this._data=new Uint32Array(this._data.buffer,0,_);else{const b=new Uint32Array(_);b.set(this._data),this._data=b}for(let b=this.length;b<v;++b)this.setCell(b,S)}else{this._data=this._data.subarray(0,_);const b=Object.keys(this._combined);for(let E=0;E<b.length;E++){const N=parseInt(b[E],10);N>=v&&delete this._combined[N]}const j=Object.keys(this._extendedAttrs);for(let E=0;E<j.length;E++){const N=parseInt(j[E],10);N>=v&&delete this._extendedAttrs[N]}}return this.length=v,4*_*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const v=new Uint32Array(this._data.length);return v.set(this._data),this._data=v,1}return 0}fill(v,S=!1){if(S)for(let _=0;_<this.length;++_)this.isProtected(_)||this.setCell(_,v);else{this._combined={},this._extendedAttrs={};for(let _=0;_<this.length;++_)this.setCell(_,v)}}copyFrom(v){this.length!==v.length?this._data=new Uint32Array(v._data):this._data.set(v._data),this.length=v.length,this._combined={};for(const S in v._combined)this._combined[S]=v._combined[S];this._extendedAttrs={};for(const S in v._extendedAttrs)this._extendedAttrs[S]=v._extendedAttrs[S];this.isWrapped=v.isWrapped}clone(){const v=new w(0);v._data=new Uint32Array(this._data),v.length=this.length;for(const S in this._combined)v._combined[S]=this._combined[S];for(const S in this._extendedAttrs)v._extendedAttrs[S]=this._extendedAttrs[S];return v.isWrapped=this.isWrapped,v}getTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0])return v+(this._data[3*v+0]>>22);return 0}getNoBgTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0]||50331648&this._data[3*v+2])return v+(this._data[3*v+0]>>22);return 0}copyCellsFrom(v,S,_,b,j){const E=v._data;if(j)for(let L=b-1;L>=0;L--){for(let A=0;A<3;A++)this._data[3*(_+L)+A]=E[3*(S+L)+A];268435456&E[3*(S+L)+2]&&(this._extendedAttrs[_+L]=v._extendedAttrs[S+L])}else for(let L=0;L<b;L++){for(let A=0;A<3;A++)this._data[3*(_+L)+A]=E[3*(S+L)+A];268435456&E[3*(S+L)+2]&&(this._extendedAttrs[_+L]=v._extendedAttrs[S+L])}const N=Object.keys(v._combined);for(let L=0;L<N.length;L++){const A=parseInt(N[L],10);A>=S&&(this._combined[A-S+_]=v._combined[A])}}translateToString(v,S,_,b){S=S??0,_=_??this.length,v&&(_=Math.min(_,this.getTrimmedLength())),b&&(b.length=0);let j="";for(;S<_;){const E=this._data[3*S+0],N=2097151&E,L=2097152&E?this._combined[S]:N?(0,g.stringFromCodePoint)(N):f.WHITESPACE_CELL_CHAR;if(j+=L,b)for(let A=0;A<L.length;++A)b.push(S);S+=E>>22||1}return b&&b.push(S),j}}u.BufferLine=w},4841:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.getRangeLength=void 0,u.getRangeLength=function(c,h){if(c.start.y>c.end.y)throw new Error(`Buffer range end (${c.end.x}, ${c.end.y}) cannot be before start (${c.start.x}, ${c.start.y})`);return h*(c.end.y-c.start.y)+(c.end.x-c.start.x+1)}},4634:(d,u)=>{function c(h,m,f){if(m===h.length-1)return h[m].getTrimmedLength();const g=!h[m].hasContent(f-1)&&h[m].getWidth(f-1)===1,x=h[m+1].getWidth(0)===2;return g&&x?f-1:f}Object.defineProperty(u,"__esModule",{value:!0}),u.getWrappedLineTrimmedLength=u.reflowSmallerGetNewLineLengths=u.reflowLargerApplyNewLayout=u.reflowLargerCreateNewLayout=u.reflowLargerGetLinesToRemove=void 0,u.reflowLargerGetLinesToRemove=function(h,m,f,g,x){const w=[];for(let C=0;C<h.length-1;C++){let v=C,S=h.get(++v);if(!S.isWrapped)continue;const _=[h.get(C)];for(;v<h.length&&S.isWrapped;)_.push(S),S=h.get(++v);if(g>=C&&g<v){C+=_.length-1;continue}let b=0,j=c(_,b,m),E=1,N=0;for(;E<_.length;){const A=c(_,E,m),D=A-N,O=f-j,F=Math.min(D,O);_[b].copyCellsFrom(_[E],N,j,F,!1),j+=F,j===f&&(b++,j=0),N+=F,N===A&&(E++,N=0),j===0&&b!==0&&_[b-1].getWidth(f-1)===2&&(_[b].copyCellsFrom(_[b-1],f-1,j++,1,!1),_[b-1].setCell(f-1,x))}_[b].replaceCells(j,f,x);let L=0;for(let A=_.length-1;A>0&&(A>b||_[A].getTrimmedLength()===0);A--)L++;L>0&&(w.push(C+_.length-L),w.push(L)),C+=_.length-1}return w},u.reflowLargerCreateNewLayout=function(h,m){const f=[];let g=0,x=m[g],w=0;for(let C=0;C<h.length;C++)if(x===C){const v=m[++g];h.onDeleteEmitter.fire({index:C-w,amount:v}),C+=v-1,w+=v,x=m[++g]}else f.push(C);return{layout:f,countRemoved:w}},u.reflowLargerApplyNewLayout=function(h,m){const f=[];for(let g=0;g<m.length;g++)f.push(h.get(m[g]));for(let g=0;g<f.length;g++)h.set(g,f[g]);h.length=m.length},u.reflowSmallerGetNewLineLengths=function(h,m,f){const g=[],x=h.map(((S,_)=>c(h,_,m))).reduce(((S,_)=>S+_));let w=0,C=0,v=0;for(;v<x;){if(x-v<f){g.push(x-v);break}w+=f;const S=c(h,C,m);w>S&&(w-=S,C++);const _=h[C].getWidth(w-1)===2;_&&w--;const b=_?f-1:f;g.push(b),v+=b}return g},u.getWrappedLineTrimmedLength=c},5295:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferSet=void 0;const h=c(8460),m=c(844),f=c(9092);class g extends m.Disposable{constructor(w,C){super(),this._optionsService=w,this._bufferService=C,this._onBufferActivate=this.register(new h.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new f.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new f.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}u.BufferSet=g},511:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CellData=void 0;const h=c(482),m=c(643),f=c(3734);class g extends f.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new f.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new g;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[m.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[m.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[m.CHAR_DATA_CHAR_INDEX].length===2){const v=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=v&&v<=56319){const S=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(v-55296)+S-56320+65536|w[m.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[m.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[m.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[m.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}u.CellData=g},643:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WHITESPACE_CELL_CODE=u.WHITESPACE_CELL_WIDTH=u.WHITESPACE_CELL_CHAR=u.NULL_CELL_CODE=u.NULL_CELL_WIDTH=u.NULL_CELL_CHAR=u.CHAR_DATA_CODE_INDEX=u.CHAR_DATA_WIDTH_INDEX=u.CHAR_DATA_CHAR_INDEX=u.CHAR_DATA_ATTR_INDEX=u.DEFAULT_EXT=u.DEFAULT_ATTR=u.DEFAULT_COLOR=void 0,u.DEFAULT_COLOR=0,u.DEFAULT_ATTR=256|u.DEFAULT_COLOR<<9,u.DEFAULT_EXT=0,u.CHAR_DATA_ATTR_INDEX=0,u.CHAR_DATA_CHAR_INDEX=1,u.CHAR_DATA_WIDTH_INDEX=2,u.CHAR_DATA_CODE_INDEX=3,u.NULL_CELL_CHAR="",u.NULL_CELL_WIDTH=1,u.NULL_CELL_CODE=0,u.WHITESPACE_CELL_CHAR=" ",u.WHITESPACE_CELL_WIDTH=1,u.WHITESPACE_CELL_CODE=32},4863:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Marker=void 0;const h=c(8460),m=c(844);class f{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=f._nextId++,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,m.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}u.Marker=f,f._nextId=1},7116:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DEFAULT_CHARSET=u.CHARSETS=void 0,u.CHARSETS={},u.DEFAULT_CHARSET=u.CHARSETS.B,u.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},u.CHARSETS.A={"#":"£"},u.CHARSETS.B=void 0,u.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},u.CHARSETS.C=u.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},u.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},u.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},u.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},u.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},u.CHARSETS.E=u.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},u.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},u.CHARSETS.H=u.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},u.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(d,u)=>{var c,h,m;Object.defineProperty(u,"__esModule",{value:!0}),u.C1_ESCAPED=u.C1=u.C0=void 0,(function(f){f.NUL="\0",f.SOH="",f.STX="",f.ETX="",f.EOT="",f.ENQ="",f.ACK="",f.BEL="\x07",f.BS="\b",f.HT=" ",f.LF=`
260
+ `,f.VT="\v",f.FF="\f",f.CR="\r",f.SO="",f.SI="",f.DLE="",f.DC1="",f.DC2="",f.DC3="",f.DC4="",f.NAK="",f.SYN="",f.ETB="",f.CAN="",f.EM="",f.SUB="",f.ESC="\x1B",f.FS="",f.GS="",f.RS="",f.US="",f.SP=" ",f.DEL=""})(c||(u.C0=c={})),(function(f){f.PAD="€",f.HOP="",f.BPH="‚",f.NBH="ƒ",f.IND="„",f.NEL="…",f.SSA="†",f.ESA="‡",f.HTS="ˆ",f.HTJ="‰",f.VTS="Š",f.PLD="‹",f.PLU="Œ",f.RI="",f.SS2="Ž",f.SS3="",f.DCS="",f.PU1="‘",f.PU2="’",f.STS="“",f.CCH="”",f.MW="•",f.SPA="–",f.EPA="—",f.SOS="˜",f.SGCI="™",f.SCI="š",f.CSI="›",f.ST="œ",f.OSC="",f.PM="ž",f.APC="Ÿ"})(h||(u.C1=h={})),(function(f){f.ST=`${c.ESC}\\`})(m||(u.C1_ESCAPED=m={}))},7399:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.evaluateKeyboardEvent=void 0;const h=c(2584),m={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:["'",'"']};u.evaluateKeyboardEvent=function(f,g,x,w){const C={type:0,cancel:!1,key:void 0},v=(f.shiftKey?1:0)|(f.altKey?2:0)|(f.ctrlKey?4:0)|(f.metaKey?8:0);switch(f.keyCode){case 0:f.key==="UIKeyInputUpArrow"?C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A":f.key==="UIKeyInputLeftArrow"?C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D":f.key==="UIKeyInputRightArrow"?C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C":f.key==="UIKeyInputDownArrow"&&(C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:C.key=f.ctrlKey?"\b":h.C0.DEL,f.altKey&&(C.key=h.C0.ESC+C.key);break;case 9:if(f.shiftKey){C.key=h.C0.ESC+"[Z";break}C.key=h.C0.HT,C.cancel=!0;break;case 13:C.key=f.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,C.cancel=!0;break;case 27:C.key=h.C0.ESC,f.altKey&&(C.key=h.C0.ESC+h.C0.ESC),C.cancel=!0;break;case 37:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"D",C.key===h.C0.ESC+"[1;3D"&&(C.key=h.C0.ESC+(x?"b":"[1;5D"))):C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"C",C.key===h.C0.ESC+"[1;3C"&&(C.key=h.C0.ESC+(x?"f":"[1;5C"))):C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"A",x||C.key!==h.C0.ESC+"[1;3A"||(C.key=h.C0.ESC+"[1;5A")):C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"B",x||C.key!==h.C0.ESC+"[1;3B"||(C.key=h.C0.ESC+"[1;5B")):C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:f.shiftKey||f.ctrlKey||(C.key=h.C0.ESC+"[2~");break;case 46:C.key=v?h.C0.ESC+"[3;"+(v+1)+"~":h.C0.ESC+"[3~";break;case 36:C.key=v?h.C0.ESC+"[1;"+(v+1)+"H":g?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:C.key=v?h.C0.ESC+"[1;"+(v+1)+"F":g?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:f.shiftKey?C.type=2:f.ctrlKey?C.key=h.C0.ESC+"[5;"+(v+1)+"~":C.key=h.C0.ESC+"[5~";break;case 34:f.shiftKey?C.type=3:f.ctrlKey?C.key=h.C0.ESC+"[6;"+(v+1)+"~":C.key=h.C0.ESC+"[6~";break;case 112:C.key=v?h.C0.ESC+"[1;"+(v+1)+"P":h.C0.ESC+"OP";break;case 113:C.key=v?h.C0.ESC+"[1;"+(v+1)+"Q":h.C0.ESC+"OQ";break;case 114:C.key=v?h.C0.ESC+"[1;"+(v+1)+"R":h.C0.ESC+"OR";break;case 115:C.key=v?h.C0.ESC+"[1;"+(v+1)+"S":h.C0.ESC+"OS";break;case 116:C.key=v?h.C0.ESC+"[15;"+(v+1)+"~":h.C0.ESC+"[15~";break;case 117:C.key=v?h.C0.ESC+"[17;"+(v+1)+"~":h.C0.ESC+"[17~";break;case 118:C.key=v?h.C0.ESC+"[18;"+(v+1)+"~":h.C0.ESC+"[18~";break;case 119:C.key=v?h.C0.ESC+"[19;"+(v+1)+"~":h.C0.ESC+"[19~";break;case 120:C.key=v?h.C0.ESC+"[20;"+(v+1)+"~":h.C0.ESC+"[20~";break;case 121:C.key=v?h.C0.ESC+"[21;"+(v+1)+"~":h.C0.ESC+"[21~";break;case 122:C.key=v?h.C0.ESC+"[23;"+(v+1)+"~":h.C0.ESC+"[23~";break;case 123:C.key=v?h.C0.ESC+"[24;"+(v+1)+"~":h.C0.ESC+"[24~";break;default:if(!f.ctrlKey||f.shiftKey||f.altKey||f.metaKey)if(x&&!w||!f.altKey||f.metaKey)!x||f.altKey||f.ctrlKey||f.shiftKey||!f.metaKey?f.key&&!f.ctrlKey&&!f.altKey&&!f.metaKey&&f.keyCode>=48&&f.key.length===1?C.key=f.key:f.key&&f.ctrlKey&&(f.key==="_"&&(C.key=h.C0.US),f.key==="@"&&(C.key=h.C0.NUL)):f.keyCode===65&&(C.type=1);else{const S=m[f.keyCode],_=S==null?void 0:S[f.shiftKey?1:0];if(_)C.key=h.C0.ESC+_;else if(f.keyCode>=65&&f.keyCode<=90){const b=f.ctrlKey?f.keyCode-64:f.keyCode+32;let j=String.fromCharCode(b);f.shiftKey&&(j=j.toUpperCase()),C.key=h.C0.ESC+j}else if(f.keyCode===32)C.key=h.C0.ESC+(f.ctrlKey?h.C0.NUL:" ");else if(f.key==="Dead"&&f.code.startsWith("Key")){let b=f.code.slice(3,4);f.shiftKey||(b=b.toLowerCase()),C.key=h.C0.ESC+b,C.cancel=!0}}else f.keyCode>=65&&f.keyCode<=90?C.key=String.fromCharCode(f.keyCode-64):f.keyCode===32?C.key=h.C0.NUL:f.keyCode>=51&&f.keyCode<=55?C.key=String.fromCharCode(f.keyCode-51+27):f.keyCode===56?C.key=h.C0.DEL:f.keyCode===219?C.key=h.C0.ESC:f.keyCode===220?C.key=h.C0.FS:f.keyCode===221&&(C.key=h.C0.GS)}return C}},482:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Utf8ToUtf32=u.StringToUtf32=u.utf32ToString=u.stringFromCodePoint=void 0,u.stringFromCodePoint=function(c){return c>65535?(c-=65536,String.fromCharCode(55296+(c>>10))+String.fromCharCode(c%1024+56320)):String.fromCharCode(c)},u.utf32ToString=function(c,h=0,m=c.length){let f="";for(let g=h;g<m;++g){let x=c[g];x>65535?(x-=65536,f+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):f+=String.fromCharCode(x)}return f},u.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(c,h){const m=c.length;if(!m)return 0;let f=0,g=0;if(this._interim){const x=c.charCodeAt(g++);56320<=x&&x<=57343?h[f++]=1024*(this._interim-55296)+x-56320+65536:(h[f++]=this._interim,h[f++]=x),this._interim=0}for(let x=g;x<m;++x){const w=c.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=m)return this._interim=w,f;const C=c.charCodeAt(x);56320<=C&&C<=57343?h[f++]=1024*(w-55296)+C-56320+65536:(h[f++]=w,h[f++]=C)}else w!==65279&&(h[f++]=w)}return f}},u.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(c,h){const m=c.length;if(!m)return 0;let f,g,x,w,C=0,v=0,S=0;if(this.interim[0]){let j=!1,E=this.interim[0];E&=(224&E)==192?31:(240&E)==224?15:7;let N,L=0;for(;(N=63&this.interim[++L])&&L<4;)E<<=6,E|=N;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,D=A-L;for(;S<D;){if(S>=m)return 0;if(N=c[S++],(192&N)!=128){S--,j=!0;break}this.interim[L++]=N,E<<=6,E|=63&N}j||(A===2?E<128?S--:h[C++]=E:A===3?E<2048||E>=55296&&E<=57343||E===65279||(h[C++]=E):E<65536||E>1114111||(h[C++]=E)),this.interim.fill(0)}const _=m-4;let b=S;for(;b<m;){for(;!(!(b<_)||128&(f=c[b])||128&(g=c[b+1])||128&(x=c[b+2])||128&(w=c[b+3]));)h[C++]=f,h[C++]=g,h[C++]=x,h[C++]=w,b+=4;if(f=c[b++],f<128)h[C++]=f;else if((224&f)==192){if(b>=m)return this.interim[0]=f,C;if(g=c[b++],(192&g)!=128){b--;continue}if(v=(31&f)<<6|63&g,v<128){b--;continue}h[C++]=v}else if((240&f)==224){if(b>=m)return this.interim[0]=f,C;if(g=c[b++],(192&g)!=128){b--;continue}if(b>=m)return this.interim[0]=f,this.interim[1]=g,C;if(x=c[b++],(192&x)!=128){b--;continue}if(v=(15&f)<<12|(63&g)<<6|63&x,v<2048||v>=55296&&v<=57343||v===65279)continue;h[C++]=v}else if((248&f)==240){if(b>=m)return this.interim[0]=f,C;if(g=c[b++],(192&g)!=128){b--;continue}if(b>=m)return this.interim[0]=f,this.interim[1]=g,C;if(x=c[b++],(192&x)!=128){b--;continue}if(b>=m)return this.interim[0]=f,this.interim[1]=g,this.interim[2]=x,C;if(w=c[b++],(192&w)!=128){b--;continue}if(v=(7&f)<<18|(63&g)<<12|(63&x)<<6|63&w,v<65536||v>1114111)continue;h[C++]=v}}return C}}},225:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeV6=void 0;const h=c(1480),m=[[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]],f=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let g;u.UnicodeV6=class{constructor(){if(this.version="6",!g){g=new Uint8Array(65536),g.fill(1),g[0]=0,g.fill(0,1,32),g.fill(0,127,160),g.fill(2,4352,4448),g[9001]=2,g[9002]=2,g.fill(2,11904,42192),g[12351]=1,g.fill(2,44032,55204),g.fill(2,63744,64256),g.fill(2,65040,65050),g.fill(2,65072,65136),g.fill(2,65280,65377),g.fill(2,65504,65511);for(let x=0;x<m.length;++x)g.fill(0,m[x][0],m[x][1]+1)}}wcwidth(x){return x<32?0:x<127?1:x<65536?g[x]:(function(w,C){let v,S=0,_=C.length-1;if(w<C[0][0]||w>C[_][1])return!1;for(;_>=S;)if(v=S+_>>1,w>C[v][1])S=v+1;else{if(!(w<C[v][0]))return!0;_=v-1}return!1})(x,f)?0:x>=131072&&x<=196605||x>=196608&&x<=262141?2:1}charProperties(x,w){let C=this.wcwidth(x),v=C===0&&w!==0;if(v){const S=h.UnicodeService.extractWidth(w);S===0?v=!1:S>C&&(C=S)}return h.UnicodeService.createPropertyValue(0,C,v)}}},5981:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WriteBuffer=void 0;const h=c(8460),m=c(844);class f extends m.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const v=this._callbacks.shift();v&&v()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w)}_innerWrite(x=0,w=!0){const C=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const v=this._writeBuffer[this._bufferOffset],S=this._action(v,w);if(S){const b=j=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,j))):this._innerWrite(C,j);return void S.catch((j=>(queueMicrotask((()=>{throw j})),Promise.resolve(!1)))).then(b)}const _=this._callbacks[this._bufferOffset];if(_&&_(),this._bufferOffset++,this._pendingData-=v.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}u.WriteBuffer=f},5941:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.toRgbString=u.parseColor=void 0;const c=/^([\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})$/,h=/^[\da-f]+$/;function m(f,g){const x=f.toString(16),w=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}u.parseColor=function(f){if(!f)return;let g=f.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const x=c.exec(g);if(x){const w=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/w*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/w*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/w*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),h.exec(g)&&[3,6,9,12].includes(g.length))){const x=g.length/3,w=[0,0,0];for(let C=0;C<3;++C){const v=parseInt(g.slice(x*C,x*C+x),16);w[C]=x===1?v<<4:x===2?v:x===3?v>>4:v>>8}return w}},u.toRgbString=function(f,g=16){const[x,w,C]=f;return`rgb:${m(x,g)}/${m(w,g)}/${m(C,g)}`}},5770:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.PAYLOAD_LIMIT=void 0,u.PAYLOAD_LIMIT=1e7},6351:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DcsHandler=u.DcsParser=void 0;const h=c(482),m=c(8742),f=c(5770),g=[];u.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const v=this._handlers[w];return v.push(C),{dispose:()=>{const S=v.indexOf(C);S!==-1&&v.splice(S,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||g,this._active.length)for(let v=this._active.length-1;v>=0;v--)this._active[v].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,v){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,C,v);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(w,C,v))}unhook(w,C=!0){if(this._active.length){let v=!1,S=this._active.length-1,_=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,v=C,_=this._stack.fallThrough,this._stack.paused=!1),!_&&v===!1){for(;S>=0&&(v=this._active[S].unhook(w),v!==!0);S--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,v;S--}for(;S>=0;S--)if(v=this._active[S].unhook(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,v}else this._handlerFb(this._ident,"UNHOOK",w);this._active=g,this._ident=0}};const x=new m.Params;x.addParam(0),u.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=x,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():x,this._data="",this._hitLimit=!1}put(w,C,v){this._hitLimit||(this._data+=(0,h.utf32ToString)(w,C,v),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((v=>(this._params=x,this._data="",this._hitLimit=!1,v)));return this._params=x,this._data="",this._hitLimit=!1,C}}},2015:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.EscapeSequenceParser=u.VT500_TRANSITION_TABLE=u.TransitionTable=void 0;const h=c(844),m=c(8742),f=c(6242),g=c(6351);class x{constructor(S){this.table=new Uint8Array(S)}setDefault(S,_){this.table.fill(S<<4|_)}add(S,_,b,j){this.table[_<<8|S]=b<<4|j}addMany(S,_,b,j){for(let E=0;E<S.length;E++)this.table[_<<8|S[E]]=b<<4|j}}u.TransitionTable=x;const w=160;u.VT500_TRANSITION_TABLE=(function(){const v=new x(4095),S=Array.apply(null,Array(256)).map(((L,A)=>A)),_=(L,A)=>S.slice(L,A),b=_(32,127),j=_(0,24);j.push(25),j.push.apply(j,_(28,32));const E=_(0,14);let N;for(N in v.setDefault(1,0),v.addMany(b,0,2,0),E)v.addMany([24,26,153,154],N,3,0),v.addMany(_(128,144),N,3,0),v.addMany(_(144,152),N,3,0),v.add(156,N,0,0),v.add(27,N,11,1),v.add(157,N,4,8),v.addMany([152,158,159],N,0,7),v.add(155,N,11,3),v.add(144,N,11,9);return v.addMany(j,0,3,0),v.addMany(j,1,3,1),v.add(127,1,0,1),v.addMany(j,8,0,8),v.addMany(j,3,3,3),v.add(127,3,0,3),v.addMany(j,4,3,4),v.add(127,4,0,4),v.addMany(j,6,3,6),v.addMany(j,5,3,5),v.add(127,5,0,5),v.addMany(j,2,3,2),v.add(127,2,0,2),v.add(93,1,4,8),v.addMany(b,8,5,8),v.add(127,8,5,8),v.addMany([156,27,24,26,7],8,6,0),v.addMany(_(28,32),8,0,8),v.addMany([88,94,95],1,0,7),v.addMany(b,7,0,7),v.addMany(j,7,0,7),v.add(156,7,0,0),v.add(127,7,0,7),v.add(91,1,11,3),v.addMany(_(64,127),3,7,0),v.addMany(_(48,60),3,8,4),v.addMany([60,61,62,63],3,9,4),v.addMany(_(48,60),4,8,4),v.addMany(_(64,127),4,7,0),v.addMany([60,61,62,63],4,0,6),v.addMany(_(32,64),6,0,6),v.add(127,6,0,6),v.addMany(_(64,127),6,0,0),v.addMany(_(32,48),3,9,5),v.addMany(_(32,48),5,9,5),v.addMany(_(48,64),5,0,6),v.addMany(_(64,127),5,7,0),v.addMany(_(32,48),4,9,5),v.addMany(_(32,48),1,9,2),v.addMany(_(32,48),2,9,2),v.addMany(_(48,127),2,10,0),v.addMany(_(48,80),1,10,0),v.addMany(_(81,88),1,10,0),v.addMany([89,90,92],1,10,0),v.addMany(_(96,127),1,10,0),v.add(80,1,11,9),v.addMany(j,9,0,9),v.add(127,9,0,9),v.addMany(_(28,32),9,0,9),v.addMany(_(32,48),9,9,12),v.addMany(_(48,60),9,8,10),v.addMany([60,61,62,63],9,9,10),v.addMany(j,11,0,11),v.addMany(_(32,128),11,0,11),v.addMany(_(28,32),11,0,11),v.addMany(j,10,0,10),v.add(127,10,0,10),v.addMany(_(28,32),10,0,10),v.addMany(_(48,60),10,8,10),v.addMany([60,61,62,63],10,0,11),v.addMany(_(32,48),10,9,12),v.addMany(j,12,0,12),v.add(127,12,0,12),v.addMany(_(28,32),12,0,12),v.addMany(_(32,48),12,9,12),v.addMany(_(48,64),12,0,11),v.addMany(_(64,127),12,12,13),v.addMany(_(64,127),10,12,13),v.addMany(_(64,127),9,12,13),v.addMany(j,13,13,13),v.addMany(b,13,13,13),v.add(127,13,0,13),v.addMany([27,156,24,26],13,14,0),v.add(w,0,2,0),v.add(w,8,5,8),v.add(w,6,0,6),v.add(w,11,0,11),v.add(w,13,13,13),v})();class C extends h.Disposable{constructor(S=u.VT500_TRANSITION_TABLE){super(),this._transitions=S,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new m.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(_,b,j)=>{},this._executeHandlerFb=_=>{},this._csiHandlerFb=(_,b)=>{},this._escHandlerFb=_=>{},this._errorHandlerFb=_=>_,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new f.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,_=[64,126]){let b=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(b=S.prefix.charCodeAt(0),b&&60>b||b>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(S.intermediates){if(S.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let E=0;E<S.intermediates.length;++E){const N=S.intermediates.charCodeAt(E);if(32>N||N>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");b<<=8,b|=N}}if(S.final.length!==1)throw new Error("final must be a single byte");const j=S.final.charCodeAt(0);if(_[0]>j||j>_[1])throw new Error(`final must be in range ${_[0]} .. ${_[1]}`);return b<<=8,b|=j,b}identToString(S){const _=[];for(;S;)_.push(String.fromCharCode(255&S)),S>>=8;return _.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,_){const b=this._identifier(S,[48,126]);this._escHandlers[b]===void 0&&(this._escHandlers[b]=[]);const j=this._escHandlers[b];return j.push(_),{dispose:()=>{const E=j.indexOf(_);E!==-1&&j.splice(E,1)}}}clearEscHandler(S){this._escHandlers[this._identifier(S,[48,126])]&&delete this._escHandlers[this._identifier(S,[48,126])]}setEscHandlerFallback(S){this._escHandlerFb=S}setExecuteHandler(S,_){this._executeHandlers[S.charCodeAt(0)]=_}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,_){const b=this._identifier(S);this._csiHandlers[b]===void 0&&(this._csiHandlers[b]=[]);const j=this._csiHandlers[b];return j.push(_),{dispose:()=>{const E=j.indexOf(_);E!==-1&&j.splice(E,1)}}}clearCsiHandler(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,_){return this._dcsParser.registerHandler(this._identifier(S),_)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,_){return this._oscParser.registerHandler(S,_)}clearOscHandler(S){this._oscParser.clearHandler(S)}setOscHandlerFallback(S){this._oscParser.setHandlerFallback(S)}setErrorHandler(S){this._errorHandler=S}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(S,_,b,j,E){this._parseStack.state=S,this._parseStack.handlers=_,this._parseStack.handlerPos=b,this._parseStack.transition=j,this._parseStack.chunkPos=E}parse(S,_,b){let j,E=0,N=0,L=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,L=this._parseStack.chunkPos+1;else{if(b===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const A=this._parseStack.handlers;let D=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(b===!1&&D>-1){for(;D>=0&&(j=A[D](this._params),j!==!0);D--)if(j instanceof Promise)return this._parseStack.handlerPos=D,j}this._parseStack.handlers=[];break;case 4:if(b===!1&&D>-1){for(;D>=0&&(j=A[D](),j!==!0);D--)if(j instanceof Promise)return this._parseStack.handlerPos=D,j}this._parseStack.handlers=[];break;case 6:if(E=S[this._parseStack.chunkPos],j=this._dcsParser.unhook(E!==24&&E!==26,b),j)return j;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(E=S[this._parseStack.chunkPos],j=this._oscParser.end(E!==24&&E!==26,b),j)return j;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,L=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let A=L;A<_;++A){switch(E=S[A],N=this._transitions.table[this.currentState<<8|(E<160?E:w)],N>>4){case 2:for(let z=A+1;;++z){if(z>=_||(E=S[z])<32||E>126&&E<w){this._printHandler(S,A,z),A=z-1;break}if(++z>=_||(E=S[z])<32||E>126&&E<w){this._printHandler(S,A,z),A=z-1;break}if(++z>=_||(E=S[z])<32||E>126&&E<w){this._printHandler(S,A,z),A=z-1;break}if(++z>=_||(E=S[z])<32||E>126&&E<w){this._printHandler(S,A,z),A=z-1;break}}break;case 3:this._executeHandlers[E]?this._executeHandlers[E]():this._executeHandlerFb(E),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:A,code:E,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const D=this._csiHandlers[this._collect<<8|E];let O=D?D.length-1:-1;for(;O>=0&&(j=D[O](this._params),j!==!0);O--)if(j instanceof Promise)return this._preserveStack(3,D,O,N,A),j;O<0&&this._csiHandlerFb(this._collect<<8|E,this._params),this.precedingJoinState=0;break;case 8:do switch(E){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(E-48)}while(++A<_&&(E=S[A])>47&&E<60);A--;break;case 9:this._collect<<=8,this._collect|=E;break;case 10:const F=this._escHandlers[this._collect<<8|E];let P=F?F.length-1:-1;for(;P>=0&&(j=F[P](),j!==!0);P--)if(j instanceof Promise)return this._preserveStack(4,F,P,N,A),j;P<0&&this._escHandlerFb(this._collect<<8|E),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|E,this._params);break;case 13:for(let z=A+1;;++z)if(z>=_||(E=S[z])===24||E===26||E===27||E>127&&E<w){this._dcsParser.put(S,A,z),A=z-1;break}break;case 14:if(j=this._dcsParser.unhook(E!==24&&E!==26),j)return this._preserveStack(6,[],0,N,A),j;E===27&&(N|=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 z=A+1;;z++)if(z>=_||(E=S[z])<32||E>127&&E<w){this._oscParser.put(S,A,z),A=z-1;break}break;case 6:if(j=this._oscParser.end(E!==24&&E!==26),j)return this._preserveStack(5,[],0,N,A),j;E===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&N}}}u.EscapeSequenceParser=C},6242:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OscHandler=u.OscParser=void 0;const h=c(5770),m=c(482),f=[];u.OscParser=class{constructor(){this._state=0,this._active=f,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const w=this._handlers[g];return w.push(x),{dispose:()=>{const C=w.indexOf(x);C!==-1&&w.splice(C,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=f,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||f,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,x,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(g,x,w);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(g,x,w))}start(){this.reset(),this._state=1}put(g,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const C=g[x++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-x>0&&this._put(g,x,w)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,v=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=x,v=this._stack.fallThrough,this._stack.paused=!1),!v&&w===!1){for(;C>=0&&(w=this._active[C].end(g),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",g);this._active=f,this._id=-1,this._state=0}}},u.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,x,w){this._hitLimit||(this._data+=(0,m.utf32ToString)(g,x,w),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,x}}},8742:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Params=void 0;const c=2147483647;class h{static fromArray(f){const g=new h;if(!f.length)return g;for(let x=Array.isArray(f[0])?1:0;x<f.length;++x){const w=f[x];if(Array.isArray(w))for(let C=0;C<w.length;++C)g.addSubParam(w[C]);else g.addParam(w)}return g}constructor(f=32,g=32){if(this.maxLength=f,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(f),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(f),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const f=new h(this.maxLength,this.maxSubParamsLength);return f.params.set(this.params),f.length=this.length,f._subParams.set(this._subParams),f._subParamsLength=this._subParamsLength,f._subParamsIdx.set(this._subParamsIdx),f._rejectDigits=this._rejectDigits,f._rejectSubDigits=this._rejectSubDigits,f._digitIsSub=this._digitIsSub,f}toArray(){const f=[];for(let g=0;g<this.length;++g){f.push(this.params[g]);const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&f.push(Array.prototype.slice.call(this._subParams,x,w))}return f}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(f){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(f<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=f>c?c:f}}addSubParam(f){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(f<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=f>c?c:f,this._subParamsIdx[this.length-1]++}}hasSubParams(f){return(255&this._subParamsIdx[f])-(this._subParamsIdx[f]>>8)>0}getSubParams(f){const g=this._subParamsIdx[f]>>8,x=255&this._subParamsIdx[f];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const f={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&(f[g]=this._subParams.slice(x,w))}return f}addDigit(f){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[g-1];x[g-1]=~w?Math.min(10*w+f,c):f}}u.Params=h},5741:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.AddonManager=void 0,u.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let c=this._addons.length-1;c>=0;c--)this._addons[c].instance.dispose()}loadAddon(c,h){const m={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(m),h.dispose=()=>this._wrappedAddonDispose(m),h.activate(c)}_wrappedAddonDispose(c){if(c.isDisposed)return;let h=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===c){h=m;break}if(h===-1)throw new Error("Could not dispose an addon that has not been loaded");c.isDisposed=!0,c.dispose.apply(c.instance),this._addons.splice(h,1)}}},8771:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferApiView=void 0;const h=c(3785),m=c(511);u.BufferApiView=class{constructor(f,g){this._buffer=f,this.type=g}init(f){return this._buffer=f,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(f){const g=this._buffer.lines.get(f);if(g)return new h.BufferLineApiView(g)}getNullCell(){return new m.CellData}}},3785:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLineApiView=void 0;const h=c(511);u.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,f){if(!(m<0||m>=this._line.length))return f?(this._line.loadCell(m,f),f):this._line.loadCell(m,new h.CellData)}translateToString(m,f,g){return this._line.translateToString(m,f,g)}}},8285:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferNamespaceApi=void 0;const h=c(8771),m=c(8460),f=c(844);class g extends f.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new m.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}u.BufferNamespaceApi=g},7975:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ParserApi=void 0,u.ParserApi=class{constructor(c){this._core=c}registerCsiHandler(c,h){return this._core.registerCsiHandler(c,(m=>h(m.toArray())))}addCsiHandler(c,h){return this.registerCsiHandler(c,h)}registerDcsHandler(c,h){return this._core.registerDcsHandler(c,((m,f)=>h(m,f.toArray())))}addDcsHandler(c,h){return this.registerDcsHandler(c,h)}registerEscHandler(c,h){return this._core.registerEscHandler(c,h)}addEscHandler(c,h){return this.registerEscHandler(c,h)}registerOscHandler(c,h){return this._core.registerOscHandler(c,h)}addOscHandler(c,h){return this.registerOscHandler(c,h)}}},7090:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeApi=void 0,u.UnicodeApi=class{constructor(c){this._core=c}register(c){this._core.unicodeService.register(c)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(c){this._core.unicodeService.activeVersion=c}}},744:function(d,u,c){var h=this&&this.__decorate||function(v,S,_,b){var j,E=arguments.length,N=E<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,_):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(v,S,_,b);else for(var L=v.length-1;L>=0;L--)(j=v[L])&&(N=(E<3?j(N):E>3?j(S,_,N):j(S,_))||N);return E>3&&N&&Object.defineProperty(S,_,N),N},m=this&&this.__param||function(v,S){return function(_,b){S(_,b,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferService=u.MINIMUM_ROWS=u.MINIMUM_COLS=void 0;const f=c(8460),g=c(844),x=c(5295),w=c(2585);u.MINIMUM_COLS=2,u.MINIMUM_ROWS=1;let C=u.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(v){super(),this.isUserScrolling=!1,this._onResize=this.register(new f.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new f.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(v.rawOptions.cols||0,u.MINIMUM_COLS),this.rows=Math.max(v.rawOptions.rows||0,u.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(v,this))}resize(v,S){this.cols=v,this.rows=S,this.buffers.resize(v,S),this._onResize.fire({cols:v,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(v,S=!1){const _=this.buffer;let b;b=this._cachedBlankLine,b&&b.length===this.cols&&b.getFg(0)===v.fg&&b.getBg(0)===v.bg||(b=_.getBlankLine(v,S),this._cachedBlankLine=b),b.isWrapped=S;const j=_.ybase+_.scrollTop,E=_.ybase+_.scrollBottom;if(_.scrollTop===0){const N=_.lines.isFull;E===_.lines.length-1?N?_.lines.recycle().copyFrom(b):_.lines.push(b.clone()):_.lines.splice(E+1,0,b.clone()),N?this.isUserScrolling&&(_.ydisp=Math.max(_.ydisp-1,0)):(_.ybase++,this.isUserScrolling||_.ydisp++)}else{const N=E-j+1;_.lines.shiftElements(j+1,N-1,-1),_.lines.set(E,b.clone())}this.isUserScrolling||(_.ydisp=_.ybase),this._onScroll.fire(_.ydisp)}scrollLines(v,S,_){const b=this.buffer;if(v<0){if(b.ydisp===0)return;this.isUserScrolling=!0}else v+b.ydisp>=b.ybase&&(this.isUserScrolling=!1);const j=b.ydisp;b.ydisp=Math.max(Math.min(b.ydisp+v,b.ybase),0),j!==b.ydisp&&(S||this._onScroll.fire(b.ydisp))}};u.BufferService=C=h([m(0,w.IOptionsService)],C)},7994:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CharsetService=void 0,u.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(c){this.glevel=c,this.charset=this._charsets[c]}setgCharset(c,h){this._charsets[c]=h,this.glevel===c&&(this.charset=h)}}},1753:function(d,u,c){var h=this&&this.__decorate||function(b,j,E,N){var L,A=arguments.length,D=A<3?j:N===null?N=Object.getOwnPropertyDescriptor(j,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(b,j,E,N);else for(var O=b.length-1;O>=0;O--)(L=b[O])&&(D=(A<3?L(D):A>3?L(j,E,D):L(j,E))||D);return A>3&&D&&Object.defineProperty(j,E,D),D},m=this&&this.__param||function(b,j){return function(E,N){j(E,N,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreMouseService=void 0;const f=c(2585),g=c(8460),x=c(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:b=>b.button!==4&&b.action===1&&(b.ctrl=!1,b.alt=!1,b.shift=!1,!0)},VT200:{events:19,restrict:b=>b.action!==32},DRAG:{events:23,restrict:b=>b.action!==32||b.button!==3},ANY:{events:31,restrict:b=>!0}};function C(b,j){let E=(b.ctrl?16:0)|(b.shift?4:0)|(b.alt?8:0);return b.button===4?(E|=64,E|=b.action):(E|=3&b.button,4&b.button&&(E|=64),8&b.button&&(E|=128),b.action===32?E|=32:b.action!==0||j||(E|=3)),E}const v=String.fromCharCode,S={DEFAULT:b=>{const j=[C(b,!1)+32,b.col+32,b.row+32];return j[0]>255||j[1]>255||j[2]>255?"":`\x1B[M${v(j[0])}${v(j[1])}${v(j[2])}`},SGR:b=>{const j=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.col};${b.row}${j}`},SGR_PIXELS:b=>{const j=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.x};${b.y}${j}`}};let _=u.CoreMouseService=class extends x.Disposable{constructor(b,j){super(),this._bufferService=b,this._coreService=j,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const E of Object.keys(w))this.addProtocol(E,w[E]);for(const E of Object.keys(S))this.addEncoding(E,S[E]);this.reset()}addProtocol(b,j){this._protocols[b]=j}addEncoding(b,j){this._encodings[b]=j}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(b){if(!this._protocols[b])throw new Error(`unknown protocol "${b}"`);this._activeProtocol=b,this._onProtocolChange.fire(this._protocols[b].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(b){if(!this._encodings[b])throw new Error(`unknown encoding "${b}"`);this._activeEncoding=b}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(b){if(b.col<0||b.col>=this._bufferService.cols||b.row<0||b.row>=this._bufferService.rows||b.button===4&&b.action===32||b.button===3&&b.action!==32||b.button!==4&&(b.action===2||b.action===3)||(b.col++,b.row++,b.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,b,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(b))return!1;const j=this._encodings[this._activeEncoding](b);return j&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(j):this._coreService.triggerDataEvent(j,!0)),this._lastEvent=b,!0}explainEvents(b){return{down:!!(1&b),up:!!(2&b),drag:!!(4&b),move:!!(8&b),wheel:!!(16&b)}}_equalEvents(b,j,E){if(E){if(b.x!==j.x||b.y!==j.y)return!1}else if(b.col!==j.col||b.row!==j.row)return!1;return b.button===j.button&&b.action===j.action&&b.ctrl===j.ctrl&&b.alt===j.alt&&b.shift===j.shift}};u.CoreMouseService=_=h([m(0,f.IBufferService),m(1,f.ICoreService)],_)},6975:function(d,u,c){var h=this&&this.__decorate||function(_,b,j,E){var N,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,j,E);else for(var D=_.length-1;D>=0;D--)(N=_[D])&&(A=(L<3?N(A):L>3?N(b,j,A):N(b,j))||A);return L>3&&A&&Object.defineProperty(b,j,A),A},m=this&&this.__param||function(_,b){return function(j,E){b(j,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreService=void 0;const f=c(1439),g=c(8460),x=c(844),w=c(2585),C=Object.freeze({insertMode:!1}),v=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let S=u.CoreService=class extends x.Disposable{constructor(_,b,j){super(),this._bufferService=_,this._logService=b,this._optionsService=j,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,f.clone)(C),this.decPrivateModes=(0,f.clone)(v)}reset(){this.modes=(0,f.clone)(C),this.decPrivateModes=(0,f.clone)(v)}triggerDataEvent(_,b=!1){if(this._optionsService.rawOptions.disableStdin)return;const j=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&j.ybase!==j.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${_}"`,(()=>_.split("").map((E=>E.charCodeAt(0))))),this._onData.fire(_)}triggerBinaryEvent(_){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${_}"`,(()=>_.split("").map((b=>b.charCodeAt(0))))),this._onBinary.fire(_))}};u.CoreService=S=h([m(0,w.IBufferService),m(1,w.ILogService),m(2,w.IOptionsService)],S)},9074:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DecorationService=void 0;const h=c(8055),m=c(8460),f=c(844),g=c(6106);let x=0,w=0;class C extends f.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((_=>_==null?void 0:_.marker.line)),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,f.toDisposable)((()=>this.reset())))}registerDecoration(_){if(_.marker.isDisposed)return;const b=new v(_);if(b){const j=b.marker.onDispose((()=>b.dispose()));b.onDispose((()=>{b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),j.dispose())})),this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(const _ of this._decorations.values())_.dispose();this._decorations.clear()}*getDecorationsAtCell(_,b,j){let E=0,N=0;for(const L of this._decorations.getKeyIterator(b))E=L.options.x??0,N=E+(L.options.width??1),_>=E&&_<N&&(!j||(L.options.layer??"bottom")===j)&&(yield L)}forEachDecorationAtCell(_,b,j,E){this._decorations.forEachByKey(b,(N=>{x=N.options.x??0,w=x+(N.options.width??1),_>=x&&_<w&&(!j||(N.options.layer??"bottom")===j)&&E(N)}))}}u.DecorationService=C;class v extends f.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(_){super(),this.options=_,this.onRenderEmitter=this.register(new m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=_.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.InstantiationService=u.ServiceCollection=void 0;const h=c(2585),m=c(8343);class f{constructor(...x){this._entries=new Map;for(const[w,C]of x)this.set(w,C)}set(x,w){const C=this._entries.get(x);return this._entries.set(x,w),C}forEach(x){for(const[w,C]of this._entries.entries())x(w,C)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}u.ServiceCollection=f,u.InstantiationService=class{constructor(){this._services=new f,this._services.set(h.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const w=(0,m.getServiceDependencies)(g).sort(((S,_)=>S.index-_.index)),C=[];for(const S of w){const _=this._services.get(S.id);if(!_)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${S.id}.`);C.push(_)}const v=w.length>0?w[0].index:x.length;if(x.length!==v)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${v+1} conflicts with ${x.length} static arguments`);return new g(...x,...C)}}},7866:function(d,u,c){var h=this&&this.__decorate||function(v,S,_,b){var j,E=arguments.length,N=E<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,_):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(v,S,_,b);else for(var L=v.length-1;L>=0;L--)(j=v[L])&&(N=(E<3?j(N):E>3?j(S,_,N):j(S,_))||N);return E>3&&N&&Object.defineProperty(S,_,N),N},m=this&&this.__param||function(v,S){return function(_,b){S(_,b,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.traceCall=u.setTraceLogger=u.LogService=void 0;const f=c(844),g=c(2585),x={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let w,C=u.LogService=class extends f.Disposable{get logLevel(){return this._logLevel}constructor(v){super(),this._optionsService=v,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(v){for(let S=0;S<v.length;S++)typeof v[S]=="function"&&(v[S]=v[S]())}_log(v,S,_){this._evalLazyOptionalParams(_),v.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,..._)}trace(v,...S){var _;this._logLevel<=g.LogLevelEnum.TRACE&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.trace.bind(this._optionsService.options.logger))??console.log,v,S)}debug(v,...S){var _;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.debug.bind(this._optionsService.options.logger))??console.log,v,S)}info(v,...S){var _;this._logLevel<=g.LogLevelEnum.INFO&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.info.bind(this._optionsService.options.logger))??console.info,v,S)}warn(v,...S){var _;this._logLevel<=g.LogLevelEnum.WARN&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.warn.bind(this._optionsService.options.logger))??console.warn,v,S)}error(v,...S){var _;this._logLevel<=g.LogLevelEnum.ERROR&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.error.bind(this._optionsService.options.logger))??console.error,v,S)}};u.LogService=C=h([m(0,g.IOptionsService)],C),u.setTraceLogger=function(v){w=v},u.traceCall=function(v,S,_){if(typeof _.value!="function")throw new Error("not supported");const b=_.value;_.value=function(...j){if(w.logLevel!==g.LogLevelEnum.TRACE)return b.apply(this,j);w.trace(`GlyphRenderer#${b.name}(${j.map((N=>JSON.stringify(N))).join(", ")})`);const E=b.apply(this,j);return w.trace(`GlyphRenderer#${b.name} return`,E),E}}},7302:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OptionsService=u.DEFAULT_OPTIONS=void 0;const h=c(8460),m=c(844),f=c(6114);u.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:f.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends m.Disposable{constructor(C){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const v={...u.DEFAULT_OPTIONS};for(const S in C)if(S in v)try{const _=C[S];v[S]=this._sanitizeAndValidateOption(S,_)}catch(_){console.error(_)}this.rawOptions=v,this.options={...v},this._setupOptions(),this.register((0,m.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,v){return this.onOptionChange((S=>{S===C&&v(this.rawOptions[C])}))}onMultipleOptionChange(C,v){return this.onOptionChange((S=>{C.indexOf(S)!==-1&&v()}))}_setupOptions(){const C=S=>{if(!(S in u.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},v=(S,_)=>{if(!(S in u.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);_=this._sanitizeAndValidateOption(S,_),this.rawOptions[S]!==_&&(this.rawOptions[S]=_,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const _={get:C.bind(this,S),set:v.bind(this,S)};Object.defineProperty(this.options,S,_)}}_sanitizeAndValidateOption(C,v){switch(C){case"cursorStyle":if(v||(v=u.DEFAULT_OPTIONS[C]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(v))throw new Error(`"${v}" is not a valid value for ${C}`);break;case"wordSeparator":v||(v=u.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof v=="number"&&1<=v&&v<=1e3)break;v=g.includes(v)?v:u.DEFAULT_OPTIONS[C];break;case"cursorWidth":v=Math.floor(v);case"lineHeight":case"tabStopWidth":if(v<1)throw new Error(`${C} cannot be less than 1, value: ${v}`);break;case"minimumContrastRatio":v=Math.max(1,Math.min(21,Math.round(10*v)/10));break;case"scrollback":if((v=Math.min(v,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${v}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(v<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${v}`);break;case"rows":case"cols":if(!v&&v!==0)throw new Error(`${C} must be numeric, value: ${v}`);break;case"windowsPty":v=v??{}}return v}}u.OptionsService=x},2660:function(d,u,c){var h=this&&this.__decorate||function(x,w,C,v){var S,_=arguments.length,b=_<3?w:v===null?v=Object.getOwnPropertyDescriptor(w,C):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(x,w,C,v);else for(var j=x.length-1;j>=0;j--)(S=x[j])&&(b=(_<3?S(b):_>3?S(w,C,b):S(w,C))||b);return _>3&&b&&Object.defineProperty(w,C,b),b},m=this&&this.__param||function(x,w){return function(C,v){w(C,v,x)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkService=void 0;const f=c(2585);let g=u.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const w=this._bufferService.buffer;if(x.id===void 0){const j=w.addMarker(w.ybase+w.y),E={data:x,id:this._nextId++,lines:[j]};return j.onDispose((()=>this._removeMarkerFromLink(E,j))),this._dataByLinkId.set(E.id,E),E.id}const C=x,v=this._getEntryIdKey(C),S=this._entriesWithId.get(v);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const _=w.addMarker(w.ybase+w.y),b={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(b,_))),this._entriesWithId.set(b.key,b),this._dataByLinkId.set(b.id,b),b.id}addLineToLink(x,w){const C=this._dataByLinkId.get(x);if(C&&C.lines.every((v=>v.line!==w))){const v=this._bufferService.buffer.addMarker(w);C.lines.push(v),v.onDispose((()=>this._removeMarkerFromLink(C,v)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))==null?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const C=x.lines.indexOf(w);C!==-1&&(x.lines.splice(C,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};u.OscLinkService=g=h([m(0,f.IBufferService)],g)},8343:(d,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createDecorator=u.getServiceDependencies=u.serviceRegistry=void 0;const c="di$target",h="di$dependencies";u.serviceRegistry=new Map,u.getServiceDependencies=function(m){return m[h]||[]},u.createDecorator=function(m){if(u.serviceRegistry.has(m))return u.serviceRegistry.get(m);const f=function(g,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,v,S){v[c]===v?v[h].push({id:C,index:S}):(v[h]=[{id:C,index:S}],v[c]=v)})(f,g,w)};return f.toString=()=>m,u.serviceRegistry.set(m,f),f}},2585:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.IDecorationService=u.IUnicodeService=u.IOscLinkService=u.IOptionsService=u.ILogService=u.LogLevelEnum=u.IInstantiationService=u.ICharsetService=u.ICoreService=u.ICoreMouseService=u.IBufferService=void 0;const h=c(8343);var m;u.IBufferService=(0,h.createDecorator)("BufferService"),u.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),u.ICoreService=(0,h.createDecorator)("CoreService"),u.ICharsetService=(0,h.createDecorator)("CharsetService"),u.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(f){f[f.TRACE=0]="TRACE",f[f.DEBUG=1]="DEBUG",f[f.INFO=2]="INFO",f[f.WARN=3]="WARN",f[f.ERROR=4]="ERROR",f[f.OFF=5]="OFF"})(m||(u.LogLevelEnum=m={})),u.ILogService=(0,h.createDecorator)("LogService"),u.IOptionsService=(0,h.createDecorator)("OptionsService"),u.IOscLinkService=(0,h.createDecorator)("OscLinkService"),u.IUnicodeService=(0,h.createDecorator)("UnicodeService"),u.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(d,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeService=void 0;const h=c(8460),m=c(225);class f{static extractShouldJoin(x){return(1&x)!=0}static extractWidth(x){return x>>1&3}static extractCharKind(x){return x>>3}static createPropertyValue(x,w,C=!1){return(16777215&x)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new h.EventEmitter,this.onChange=this._onChange.event;const x=new m.UnicodeV6;this.register(x),this._active=x.version,this._activeProvider=x}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(x){if(!this._providers[x])throw new Error(`unknown Unicode version "${x}"`);this._active=x,this._activeProvider=this._providers[x],this._onChange.fire(x)}register(x){this._providers[x.version]=x}wcwidth(x){return this._activeProvider.wcwidth(x)}getStringCellWidth(x){let w=0,C=0;const v=x.length;for(let S=0;S<v;++S){let _=x.charCodeAt(S);if(55296<=_&&_<=56319){if(++S>=v)return w+this.wcwidth(_);const E=x.charCodeAt(S);56320<=E&&E<=57343?_=1024*(_-55296)+E-56320+65536:w+=this.wcwidth(E)}const b=this.charProperties(_,C);let j=f.extractWidth(b);f.extractShouldJoin(b)&&(j-=f.extractWidth(C)),w+=j,C=b}return w}charProperties(x,w){return this._activeProvider.charProperties(x,w)}}u.UnicodeService=f}},r={};function a(d){var u=r[d];if(u!==void 0)return u.exports;var c=r[d]={exports:{}};return n[d].call(c.exports,c,c.exports,a),c.exports}var o={};return(()=>{var d=o;Object.defineProperty(d,"__esModule",{value:!0}),d.Terminal=void 0;const u=a(9042),c=a(3236),h=a(844),m=a(5741),f=a(8285),g=a(7975),x=a(7090),w=["cols","rows"];class C extends h.Disposable{constructor(S){super(),this._core=this.register(new c.Terminal(S)),this._addonManager=this.register(new m.AddonManager),this._publicOptions={...this._core.options};const _=j=>this._core.options[j],b=(j,E)=>{this._checkReadonlyOptions(j),this._core.options[j]=E};for(const j in this._core.options){const E={get:_.bind(this,j),set:b.bind(this,j)};Object.defineProperty(this._publicOptions,j,E)}}_checkReadonlyOptions(S){if(w.includes(S))throw new Error(`Option "${S}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new f.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const S=this._core.coreService.decPrivateModes;let _="none";switch(this._core.coreMouseService.activeProtocol){case"X10":_="x10";break;case"VT200":_="vt200";break;case"DRAG":_="drag";break;case"ANY":_="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:_,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const _ in S)this._publicOptions[_]=S[_]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,_=!0){this._core.input(S,_)}resize(S,_){this._verifyIntegers(S,_),this._core.resize(S,_)}open(S){this._core.open(S)}attachCustomKeyEventHandler(S){this._core.attachCustomKeyEventHandler(S)}attachCustomWheelEventHandler(S){this._core.attachCustomWheelEventHandler(S)}registerLinkProvider(S){return this._core.registerLinkProvider(S)}registerCharacterJoiner(S){return this._checkProposedApi(),this._core.registerCharacterJoiner(S)}deregisterCharacterJoiner(S){this._checkProposedApi(),this._core.deregisterCharacterJoiner(S)}registerMarker(S=0){return this._verifyIntegers(S),this._core.registerMarker(S)}registerDecoration(S){return this._checkProposedApi(),this._verifyPositiveIntegers(S.x??0,S.width??0,S.height??0),this._core.registerDecoration(S)}hasSelection(){return this._core.hasSelection()}select(S,_,b){this._verifyIntegers(S,_,b),this._core.select(S,_,b)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,_){this._verifyIntegers(S,_),this._core.selectLines(S,_)}dispose(){super.dispose()}scrollLines(S){this._verifyIntegers(S),this._core.scrollLines(S)}scrollPages(S){this._verifyIntegers(S),this._core.scrollPages(S)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(S){this._verifyIntegers(S),this._core.scrollToLine(S)}clear(){this._core.clear()}write(S,_){this._core.write(S,_)}writeln(S,_){this._core.write(S),this._core.write(`\r
261
+ `,_)}paste(S){this._core.paste(S)}refresh(S,_){this._verifyIntegers(S,_),this._core.refresh(S,_)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return u}_verifyIntegers(...S){for(const _ of S)if(_===1/0||isNaN(_)||_%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const _ of S)if(_&&(_===1/0||isNaN(_)||_%1!=0||_<0))throw new Error("This API only accepts positive integers")}}d.Terminal=C})(),o})()))})($x)),$x.exports}var xU=gU();/**
262
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
263
+ * @license MIT
264
+ *
265
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
266
+ * @license MIT
267
+ *
268
+ * Originally forked from (with the author's permission):
269
+ * Fabrice Bellard's javascript vt100 for jslinux:
270
+ * http://bellard.org/jslinux/
271
+ * Copyright (c) 2011 Fabrice Bellard
272
+ */var yU=2,bU=1,vU=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var f;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((f=this._terminal.options.overviewRuler)==null?void 0:f.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),d={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},u=d.top+d.bottom,c=d.right+d.left,h=r-u,m=a-c-t;return{cols:Math.max(yU,Math.floor(m/e.css.cell.width)),rows:Math.max(bU,Math.floor(h/e.css.cell.height))}}};function _U({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=k.useRef(null),o=k.useRef(e),d=k.useRef(null),u=k.useRef(null),c=fs(f=>f.writeSession),h=fs(f=>f.resizeSession),m=Bt(f=>f.settings[je.DISPLAY_TERMINAL_FONT]??Hh);return k.useEffect(()=>{o.current=e},[e]),k.useEffect(()=>{Bt.getState().getSetting(je.DISPLAY_TERMINAL_FONT)},[]),k.useEffect(()=>{if(!n)return;const f=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),k.useEffect(()=>{if(!a.current)return;const f=new xU.Terminal({fontFamily:m,fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new vU;f.loadAddon(g),d.current={term:f,fitAddon:g},a.current.addEventListener("keydown",v=>{v.key==="Escape"&&n&&(v.preventDefault(),v.stopPropagation(),n())}),f.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),g.fit(),r&&setTimeout(()=>{f.focus()},150);const w=new ResizeObserver(()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{requestAnimationFrame(()=>{var S;g.fit&&g.fit();const v=(S=d.current)==null?void 0:S.term;v&&v.cols>0&&v.rows>0&&h(o.current,v.cols,v.rows)})},100)});w.observe(a.current),f.onData(v=>{if(v==="\x1B"&&n){n();return}c(o.current,v)}),f.onKey(v=>{v.key==="\x1B"&&n&&(v.domEvent.stopPropagation(),n())});const C=zt.subscribe(v=>{const S=v.payload;if(v.type==="terminal.output"&&(S==null?void 0:S.sessionId)===o.current){const _=S==null?void 0:S.data;_&&f.write(_)}});return()=>{C(),w.disconnect(),u.current&&clearTimeout(u.current),f.dispose(),d.current=null}},[e,c,h]),k.useEffect(()=>{const f=d.current;if(!f)return;f.term.options.fontFamily=m,f.fitAddon.fit();const{cols:g,rows:x}=f.term;g>0&&x>0&&h(o.current,g,x)},[m,h]),s.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[s.jsx("div",{}),s.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:s.jsx(Ab,{})})]}),s.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:f=>{f.key==="Escape"&&n&&(f.preventDefault(),f.stopPropagation(),n())}})]})}const FT="openfox-chat-textarea";function ju(e){if(!Wt())return;const t=document.getElementById(FT);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function SU(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 wU({isOpen:e,onClose:t}){const n=fs(C=>C.createSession),r=fs(C=>C.killSession),a=fs(C=>C.sessions),o=fs(C=>C.setWorkdir),d=fs(C=>C.fetchSessions),u=Pt(C=>C.currentProject),c=Le(C=>C.currentSession),[h,m]=k.useState(!0),f=k.useRef(null),g=k.useRef(!1),x=k.useRef(!1),w=k.useCallback(()=>{t()},[t]);return k.useEffect(()=>{const C=(c==null?void 0:c.workspace)??(u==null?void 0:u.workdir);C&&o(C)},[c==null?void 0:c.workspace,u==null?void 0:u.workdir,o]),k.useEffect(()=>{e?(m(!0),d(u==null?void 0:u.id).finally(()=>m(!1))):ju()},[e,d,u==null?void 0:u.id]),k.useEffect(()=>{e&&a.length===0&&!h&&!x.current&&(x.current=!0,n(void 0,(c==null?void 0:c.projectId)??(u==null?void 0:u.id)))},[e,a.length,h,n,c==null?void 0:c.projectId,u==null?void 0:u.id]),k.useEffect(()=>{e?(g.current=!0,setTimeout(()=>{var C;Wt()&&((C=f.current)==null||C.focus()),setTimeout(()=>{g.current=!1},200)},100)):x.current=!1},[e]),k.useEffect(()=>{if(!e)return;const C=v=>{g.current||v.key==="Escape"&&(v.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:w}),s.jsxs("div",{ref:f,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),w())},children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>n(void 0,(c==null?void 0:c.projectId)??(u==null?void 0:u.id)),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:s.jsx(cO,{})}),s.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:s.jsx(ws,{})})]})]}),s.jsx(mt,{className:"flex-1 min-h-0 p-2",children:h?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"mb-4",children:"No terminal sessions"}),s.jsx("button",{onClick:()=>n(void 0,(c==null?void 0:c.projectId)??(u==null?void 0:u.id)),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):s.jsx("div",{className:`grid ${SU(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>s.jsx(_U,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1&&Wt()},C.id))})})]})]}):null}function ho({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",align:a="left",isOpen:o,onOpenChange:d,labelActionClassName:u}){const[c,h]=k.useState(!1),m=o!==void 0,f=m?o:c,g=q=>{if(m){const W=typeof q=="function"?q(c):q;d==null||d(W)}else h(q)},[x,w]=k.useState(null),C=k.useRef(null),v=k.useRef(null),[S,_]=k.useState(0),b=k.useRef(0),j=k.useMemo(()=>[...e,...t],[e,t]),E=k.useRef(j),N=k.useCallback(()=>{if(!C.current)return;const q=C.current.getBoundingClientRect(),W=200,Z=Number.parseInt(r,10)||120,H=window.innerHeight-q.bottom<W;w({top:H?q.top-W-4:q.bottom+4,left:a==="right"?q.right-Z:q.left,alignToTop:H})},[a,r]);k.useEffect(()=>{E.current=j},[j]),k.useEffect(()=>{function q(W){if(v.current){const Z=W.target;v.current.contains(Z)||g(!1)}}return f&&document.addEventListener("mousedown",q),()=>{document.removeEventListener("mousedown",q)}},[f]),k.useEffect(()=>{f&&N()},[f,N]),k.useEffect(()=>{if(!f)return;setTimeout(()=>{var W;(W=v.current)==null||W.focus()},0);function q(W){const Z=E.current,Q=Z.filter(I=>!L(I)),H=A(b.current,Z);switch(W.key){case"ArrowDown":if(W.preventDefault(),W.stopPropagation(),H<Q.length-1){const I=D(b.current+1,Z);b.current=I,_(I)}break;case"ArrowUp":if(W.preventDefault(),W.stopPropagation(),H>0){const I=O(b.current-1,Z);b.current=I,_(I)}break;case"Enter":W.preventDefault(),W.stopPropagation(),F(b.current,Z);break;case"Escape":W.preventDefault(),W.stopPropagation(),g(!1);break}}return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[f,j]);function L(q){var Q;const W=q.label;return W?String(((Q=W.props)==null?void 0:Q.className)??"").includes("cursor-default"):!1}function A(q,W){let Z=0;for(let Q=0;Q<q;Q++){const H=W[Q];H&&!L(H)&&Z++}return Z}function D(q,W){for(let Z=q;Z<W.length;Z++){const Q=W[Z];if(Q&&!L(Q))return Z}return q}function O(q,W){for(let Z=q;Z>=0;Z--){const Q=W[Z];if(Q&&!L(Q))return Z}return q}function F(q,W){var Q;const Z=W[q];!Z||L(Z)||((Q=Z.onClick)==null||Q.call(Z),Z.href&&(window.history.pushState(null,"",Z.href),window.dispatchEvent(new PopStateEvent("popstate"))),g(!1))}k.useEffect(()=>{f&&(_(j.findIndex(q=>!L(q))),b.current=j.findIndex(q=>!L(q)))},[f,j]);const P=q=>{q.stopPropagation(),f||N(),g(!f)};function z(q,W,Z,Q){const I=!L(q)&&Q===S,M=s.jsxs(s.Fragment,{children:[q.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:q.icon}),s.jsx("span",{className:"min-w-0",children:q.label})]}),$=W!==Z-1?"border-b border-border":"",Y=`px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${q.danger?"text-accent-error hover:bg-accent-error/10":I?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,X=q.href?s.jsx(er,{href:q.href,onClick:U=>{var B;(B=q.onClick)==null||B.call(q,U),g(!1)},onAuxClick:()=>g(!1),className:`w-full ${Y}`,children:M}):s.jsx("button",{onClick:U=>{var B;(B=q.onClick)==null||B.call(q,U),q.closeOnClick!==!1&&g(!1)},className:`w-full ${Y}`,children:M});return q.labelAction?s.jsxs("div",{className:`flex items-center gap-1 pr-1 ${$} ${u??""}`,children:[X,s.jsx("span",{className:"flex-shrink-0",children:q.labelAction})]},Q):s.jsx("div",{className:$,children:X},Q)}const K=x&&s.jsxs("div",{ref:v,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${x.alignToTop?"mb-1":"mt-1"}`,style:{top:x.top,left:x.left,minWidth:r},tabIndex:-1,children:[s.jsx(mt,{className:"max-h-[60vh]",children:e.map((q,W)=>z(q,W,e.length,W))}),t.length>0&&s.jsx("div",{className:"border-t border-border",children:t.map((q,W)=>z(q,W,t.length,e.length+W))})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative",children:s.jsx("div",{ref:C,onClick:P,children:n})}),f&&Cs.createPortal(K,document.body)]})}function CU(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 zT({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,o]=k.useState(!1),[d,u]=k.useState(null),[c,h]=k.useState(null);k.useEffect(()=>{e&&m()},[e]);const m=async()=>{try{const j=await(await ye("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:j.sudoAvailable,userInGroup:j.userInGroup,groupHasWrite:j.groupHasWrite,groupName:j.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},f=k.useCallback(async b=>{o(!0),u(null);try{const E=await(await ye("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:b})})).json();E.success?(r(),t()):E.sudoAvailable?u("Failed to fix permissions: "+(E.error||"Unknown error")):u(`Passwordless sudo is not available. Please fix permissions manually:
273
+
274
+ `+(b==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(j){u("Failed to fix permissions: "+(j instanceof Error?j.message:"Unknown error"))}finally{o(!1)}},[n,r,t]),g=(c==null?void 0:c.userInGroup)??!1,x=(c==null?void 0:c.groupHasWrite)??!1,w=(c==null?void 0:c.sudoAvailable)??!1,C=(c==null?void 0:c.groupName)??"",v=g&&!x,S=!g&&x,_=!g&&!x;return s.jsx(Et,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-sm text-text-secondary",children:[s.jsx("p",{children:v?s.jsxs(s.Fragment,{children:["The group ",s.jsx("strong",{children:C})," doesn't have write access:"]}):S?s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C}),":"]}):s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C})," and it doesn't have write access:"]})}),s.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),d?s.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:d}):c?s.jsxs("div",{className:"flex flex-col gap-2",children:[v&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{type:"button",variant:"primary",onClick:()=>f("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{type:"button",variant:"primary",onClick:()=>f("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),_&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{type:"button",variant:"primary",onClick:()=>f("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",s.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!d&&s.jsxs("div",{className:"text-xs text-text-secondary",children:[s.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),s.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),s.jsx("div",{className:"flex justify-end",children:s.jsx(ct,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function HT({isOpen:e,onClose:t}){const[,n]=Fn(),r=Pt(E=>E.listProjects),[a,o]=k.useState(""),[d,u]=k.useState(null),[c,h]=k.useState(!1),[m,f]=k.useState(""),[g,x]=k.useState(null),w=k.useRef(null);k.useEffect(()=>{e&&(ye("/api/config").then(E=>E.json()).then(E=>{E.workdir&&f(E.workdir)}),o(""),u(null),h(!1),x(null),setTimeout(()=>{var E;Wt()&&((E=w.current)==null||E.focus())},100))},[e]);const C=k.useCallback(async E=>{E.preventDefault();const N=CU(a);if(!N.valid){u(N.error);return}const L=`${m}/${a}`;await _(L)},[a,n,t,m]),v=k.useCallback(()=>{x(null)},[]),S=k.useCallback(async()=>{const E=`${m}/${a}`;await _(E)},[m,a,n,t,x,u,h]);async function _(E){h(!0),u(null),x(null);try{const N=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:E})});if(!N.ok){const D=await N.json().catch(()=>({}));if(D.code==="EACCES"){x(E),h(!1);return}throw new Error(D.error||"Failed to create project")}const A=(await N.json()).project;t(),await r(),n(`/p/${A.id}`)}catch(N){u(N instanceof Error?N.message:"Failed to create project"),h(!1)}}const b=k.useCallback(()=>{o(""),u(null),t()},[t]),j=a?`${m}/${a}`:"";return s.jsxs(s.Fragment,{children:[s.jsx(Et,{isOpen:e,onClose:b,title:"Create New Project",size:"sm",children:s.jsxs("form",{onSubmit:C,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),s.jsx(xs,{ref:w,id:"project-name",value:a,onChange:E=>{o(E.target.value),u(null)},placeholder:"my-project",disabled:c,"data-testid":"create-project-name-input",className:"w-full"}),a&&s.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",s.jsx("span",{className:"font-mono",children:j})]}),d&&s.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:d})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ct,{type:"button",variant:"secondary",onClick:b,disabled:c,children:"Cancel"}),s.jsx(ct,{type:"submit",variant:"primary",disabled:c||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:c?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Fr,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&s.jsx(zT,{isOpen:!!g,onClose:v,path:g,onRetry:S})]})}function UT(){return an(e=>e.workdir)}function jk({projects:e,currentProject:t}){const[,n]=Fn(),r=Pt(v=>v.loadProject),a=Pt(v=>v.toggleStar),o=Pt(v=>v.createProject),d=Pt(v=>v.listProjects),[u,c]=k.useState(!1),[h,m]=k.useState(!1),f=UT(),g=k.useCallback(async v=>{const S=Lu(v),_=await o(S,v);return _&&"id"in _?(await d(),m(!1),n(`/p/${_.id}`),!0):!1},[o,d,n]),w=k.useMemo(()=>{const v=e.filter(_=>_.isStarred).sort((_,b)=>_.name.localeCompare(b.name)),S=e.filter(_=>!_.isStarred).sort((_,b)=>_.name.localeCompare(b.name));return[...v,...S]},[e]).map(v=>({label:s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsx("span",{className:"truncate flex-1",children:v.name}),s.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),a(v.id,!v.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:v.isStarred?"Unstar project":"Star project",children:v.isStarred?s.jsx(El,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Xf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:v.id===(t==null?void 0:t.id)?s.jsx(Us,{}):void 0,href:`/p/${v.id}`,closeOnClick:!0,onClick:()=>{r(v.id)}})),C=[{label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wr,{className:"w-4 h-4"}),s.jsx("span",{children:"Open Project"})]}),onClick:()=>m(!0)},{label:s.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[s.jsx(Fr,{className:"w-4 h-4"}),s.jsx("span",{children:"New Project"})]}),onClick:()=>c(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(ho,{items:w,footerItems:C,trigger:s.jsxs("button",{className:`text-text-secondary hover:text-text-primary text-sm truncate flex items-center gap-1 ${t?"hover:underline":""}`,title:(t==null?void 0:t.name)??"Select project",children:[(t==null?void 0:t.name)??s.jsx("span",{className:"text-text-muted",children:"Select project..."}),s.jsx(gn,{})]}),minWidth:"250px"}),u&&s.jsx(HT,{isOpen:u,onClose:()=>c(!1)}),h&&s.jsx(em,{initialPath:f??void 0,onSelect:g,onClose:()=>m(!1)})]})}function VT(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),d=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${o}/${d}`}function _m(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function WT(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),d=_m(e);if(o===0)return`today ${d}`;if(o===1)return`yesterday ${d}`;if(o<7)return`${o} days ago ${d}`;{const u=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),h=String(t.getDate()).padStart(2,"0");return`${u}/${c}/${h} ${d}`}}function GT(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 kU(e){const{year:t,month:n,day:r}=GT(e);return`${t}-${n}-${r}`}function qT(e){const t=new Map;for(const a of e){const o=kU(a.updatedAt);t.has(o)||t.set(o,[]),t.get(o).push(a)}for(const[a,o]of t)o.sort((d,u)=>{const c=new Date(d.updatedAt).getTime();return new Date(u.updatedAt).getTime()-c});const n=Array.from(t.keys()).sort((a,o)=>o.localeCompare(a)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function jU(e){const{year:t,month:n,day:r}=GT(e);return`${t}/${n}/${r} ${_m(e)}`}function vf(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function EU({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var w;const o=Le(C=>C.loadSession),d=Le(C=>C.toggleFavorite),u=50,c=e.filter(C=>C.projectId===t.id).slice(0,15),h=c.filter(C=>C.isFavorite),m=c.filter(C=>!C.isFavorite),f=k.useMemo(()=>{const C=[];C.push({label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Fr,{className:"w-4 h-4 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});const v=(_,b)=>{C.push({label:s.jsxs("div",{className:"min-w-[160px]",children:[s.jsx("div",{className:"truncate text-sm",children:vf(_.title??_.id.slice(0,8),u)}),b&&s.jsx("div",{className:"text-text-muted text-xs",children:_m(_.updatedAt)})]}),icon:_.id===(n==null?void 0:n.id)?s.jsx(Us,{}):void 0,href:`/p/${t.id}/s/${_.id}`,onClick:()=>{o(_.id)},labelAction:s.jsx("button",{onClick:()=>d(_.id,!_.isFavorite),className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:_.isFavorite?"Unfavorite session":"Favorite session",children:_.isFavorite?s.jsx(El,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Xf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})})},S=_=>{const b=qT(_);for(const[j,E]of b){const N=E[0];if(N){C.push({label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:VT(N.updatedAt)}),onClick:()=>{}});for(const L of E)v(L,!0)}}};if(h.length>0)for(const _ of h)v(_,!1);return S(m),C},[t.id,h,m,n==null?void 0:n.id]),g=((w=n==null?void 0:n.metadata)==null?void 0:w.title)??(n?n.id.slice(0,8):null),x=g?vf(g,u):"No session selected";return s.jsx(ho,{items:f,isOpen:r,onOpenChange:a,trigger:s.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:g??"","data-testid":"header-session-dropdown",children:[x,s.jsx(gn,{})]}),minWidth:"280px",labelActionClassName:"pr-3"})}function NU({items:e,trigger:t,isActive:n=!1}){const[r,a]=k.useState(!1),o=k.useRef(null);return k.useEffect(()=>{function d(u){o.current&&!o.current.contains(u.target)&&a(!1)}if(r)return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[r]),s.jsxs("div",{className:"relative",ref:o,children:[s.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,s.jsx(gn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&s.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((d,u)=>{const c=d.label&&typeof d.label=="object"&&d.label.type===er?d.label:null;if(c){const h=c.props.href||"";return s.jsxs(er,{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:[d.icon,c.props.children]},u)}return d.href?s.jsxs("a",{href:d.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[d.icon,d.label]},u):s.jsxs("button",{type:"button",onClick:()=>{var h;(h=d.onClick)==null||h.call(d),a(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[d.icon,d.label]},u)})})]})}function TU({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const a=t.filter(d=>d.projectId===e.id).sort((d,u)=>new Date(u.updatedAt).getTime()-new Date(d.updatedAt).getTime()).slice(0,5),o=[{label:s.jsxs(er,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[s.jsx(Fr,{className:"w-3 h-3 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(d=>({label:s.jsx(er,{href:`/p/${e.id}/s/${d.id}`,className:"flex items-center gap-2 truncate text-sm",children:s.jsx("span",{children:vf(d.title??d.id.slice(0,8),50)})}),icon:d.id===(n==null?void 0:n.id)?s.jsx(Us,{className:"w-3 h-3"}):void 0})),{label:s.jsxs(er,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[s.jsx(rO,{className:"w-3 h-3"}),s.jsx("span",{className:"text-sm",children:"Projects"})]})}];return s.jsx(NU,{items:o,trigger:s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function KT(){const e=ft(a=>a.defaults),t=ft(a=>a.userItems),n=ft(a=>a.projectItems),r=ft(a=>a.fetchAgents);return{agents:[...e,...t,...n],fetchAgents:r}}function YT({projectName:e,children:t}){return s.jsxs("span",{className:"inline-flex items-center gap-1.5 min-w-0",children:[s.jsx("span",{className:"truncate max-w-[240px] font-normal text-text-muted",title:e,children:e}),s.jsx(sO,{className:"w-3 h-3 text-text-muted shrink-0"}),s.jsx("span",{className:"truncate",children:t})]})}function AU({task:e,projectId:t,agents:n,queuePosition:r,onEdit:a,onMove:o,onMoveUp:d,onMoveDown:u,onDuplicate:c,onDelete:h,onDragStart:m,onDropOnCard:f,onOpenSession:g}){const[x,w]=k.useState(!1),C=n.find(E=>E.id===e.agentId),v=e.agentId?lo(n,e.agentId):void 0,S=e.attachments.filter(E=>E.mimeType.startsWith("image/")),_=e.activeSessionId??e.sessionIds[e.sessionIds.length-1],b=[{label:"Edit",icon:s.jsx(kb,{className:"w-3.5 h-3.5"}),onClick:()=>a(e)},{label:"History & evidence",icon:s.jsx(qf,{className:"w-3.5 h-3.5"}),onClick:()=>w(E=>!E)},{label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:"Move to…"}),onClick:()=>{}},{label:"To Do",onClick:()=>o(e,"todo")},{label:"In Progress",onClick:()=>o(e,"in_progress")},{label:"Done",onClick:()=>o(e,"done")},{label:"Move up",icon:s.jsx(Cb,{className:"w-3.5 h-3.5"}),onClick:()=>d(e)},{label:"Move down",icon:s.jsx(gn,{className:"w-3.5 h-3.5"}),onClick:()=>u(e)}],j=[{label:"Duplicate",icon:s.jsx(jl,{className:"w-3.5 h-3.5"}),onClick:()=>c(e)},{label:"Delete",icon:s.jsx(Ci,{className:"w-3.5 h-3.5"}),danger:!0,onClick:()=>h(e)}];return s.jsxs("div",{draggable:!0,onClick:()=>a(e),onDragStart:E=>{E.dataTransfer.effectAllowed="move",m(e)},onDragOver:E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},onDrop:E=>{E.preventDefault(),f(e)},className:`group relative cursor-pointer bg-bg-tertiary border border-border rounded-lg p-2.5 hover:border-accent-primary/40 transition-colors ${e.status==="in_progress"?"ring-1 ring-inset ring-accent-primary/20":""}`,children:[e.status==="in_progress"&&s.jsxs("span",{className:`mb-1.5 inline-flex items-center gap-1 text-xs font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded ${e.runState==="running"?"bg-emerald-500/15 text-emerald-400":"bg-amber-500/15 text-amber-400"}`,children:[e.runState==="running"?s.jsx(Kf,{className:"w-2.5 h-2.5"}):s.jsx(PE,{className:"w-2.5 h-2.5"}),e.runState==="running"?"Running":`Queued${r!==void 0?` · ${r}`:""}`]}),s.jsx("p",{className:"pr-8 text-sm text-text-primary leading-relaxed line-clamp-3 break-words whitespace-pre-wrap",children:e.prompt}),s.jsx("div",{className:"absolute top-2 right-2",onClick:E=>E.stopPropagation(),children:s.jsx(ho,{items:b,footerItems:j,minWidth:"176px",align:"right",trigger:s.jsx("button",{type:"button",className:"p-1 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Task actions","aria-label":`Actions for ${e.prompt.slice(0,40)}`,children:s.jsx(jb,{className:"w-4 h-4"})})})}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.attachments.length>0&&s.jsxs("span",{className:"text-xs text-text-muted flex items-center gap-1",title:`${e.attachments.length} attachment(s)`,children:["📎 ",e.attachments.length]}),S.length>0&&s.jsx("span",{className:"flex -space-x-1",children:S.slice(0,3).map(E=>s.jsx("img",{src:E.data,alt:"",className:"w-6 h-6 rounded object-cover ring-2 ring-bg-tertiary"},E.id))}),e.model&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-secondary border border-border text-text-muted truncate max-w-36",title:e.model,children:e.model}),C&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-secondary border border-border flex items-center gap-1",style:{color:v},children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:v}}),C.name]}),_&&s.jsxs(er,{href:`/p/${t}/s/${_}`,onClick:E=>{E.stopPropagation(),g==null||g(_)},className:"ml-auto text-xs px-1.5 py-1 rounded bg-accent-primary/10 text-accent-primary hover:bg-accent-primary/20 flex items-center gap-1",children:["Open session ",s.jsx(Nb,{className:"w-2.5 h-2.5"})]})]}),x&&e.auditTrail.length>0&&s.jsxs("div",{className:"mt-2 pt-2 border-t border-border space-y-1",children:[s.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"History"}),e.auditTrail.map(E=>s.jsxs("div",{className:"text-xs text-text-muted leading-relaxed",children:[s.jsx("span",{className:"text-text-primary",children:E.action}),E.detail&&s.jsxs("span",{children:[" — ",E.detail]}),s.jsxs("span",{className:"text-text-muted/70",children:[" ","· ",E.actor,E.actorName&&E.actorName!==E.actor?` (${E.actorName})`:""," ·"," ",new Date(E.timestamp).toLocaleString()]})]},E.id))]})]})}function LU({title:e,accentClass:t,hint:n,tasks:r,projectId:a,agents:o,queuePositionOf:d,headerAction:u,footer:c,onEdit:h,onMove:m,onMoveUp:f,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnColumn:v,onDropOnCard:S,onOpenSession:_}){return s.jsxs("section",{onDragOver:b=>{b.preventDefault(),b.dataTransfer.dropEffect="move"},onDrop:b=>{b.preventDefault(),v()},className:"flex flex-col min-w-64 w-72 max-w-72 bg-bg-secondary/60 border border-border rounded-lg overflow-hidden",children:[s.jsxs("header",{className:`flex items-center gap-2 min-h-[51px] px-3 py-2 border-b border-border ${t}`,children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[s.jsx("span",{className:"text-sm font-semibold uppercase tracking-wide text-text-primary",children:e}),s.jsx("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded-full",children:r.length})]}),u]}),n&&s.jsx("p",{className:"px-3 pt-2 text-sm text-text-muted italic",children:n}),s.jsxs("div",{className:"p-2 space-y-2 overflow-y-auto flex-1 min-h-24",children:[r.map(b=>s.jsx(AU,{task:b,projectId:a,agents:o,queuePosition:d(b),onEdit:h,onMove:m,onMoveUp:f,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnCard:S,onOpenSession:_},b.id)),r.length===0&&s.jsx("div",{className:"text-sm text-text-muted text-center py-6 border border-dashed border-border rounded-lg",children:"Empty"})]}),c&&s.jsx("div",{className:"border-t border-border",children:c})]})}const RU={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},DU="M6 18L18 6M6 6l12 12";function Bu({onClick:e,className:t="",size:n="md",variant:r="default","aria-label":a,title:o="Close"}){const d=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 s.jsx(Jf,{onClick:e,icon:DU,iconSize:RU[n],className:`${d} ${t}`,title:o,...a!==void 0?{"aria-label":a}:{}})}const OU=["text/"],MU=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function qh(e){return e.startsWith("image/")}function XT(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function _v(e){return MU.includes(e)||OU.some(t=>e.startsWith(t))}function gl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function QT(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const IU={"text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/javascript":"js","text/xml":"xml","text/x-yaml":"yaml","text/x-sh":"sh","text/tab-separated-values":"tsv","text/x-python":"py","text/x-java-source":"java","text/x-json":"json","text/x-typescript":"ts","text/css":"css","application/json":"json","application/xml":"xml","application/yaml":"yaml","application/x-yaml":"yaml","application/javascript":"js","application/xhtml+xml":"xhtml","application/x-sh":"sh","application/pdf":"pdf","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/svg+xml":"svg"};function PU(e){var t;return IU[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function BU(e){return qh(e)||_v(e)||e==="application/pdf"}function Sv({attachment:e,onRemove:t}){const n=QT(e.filename);return s.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[s.jsx(Bu,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),XT(e.mimeType)?s.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):s.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-md bg-bg-secondary text-xs font-bold text-text-muted",children:n}),s.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:gl(e.size)})]})}function $U(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function FU(e,t){const n=t.toLowerCase(),r=(e.name??"").toLowerCase(),a=e.id.toLowerCase(),o=a.replace(/-/g," ");return r.includes(n)||a.includes(n)||o.includes(n)}function Ek(e){return e.models.some(n=>n.selected)?e.models.filter(n=>n.selected):e.models}function JT({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:o,settingDefault:d,highlighted:u,onModelClick:c,onSetDefault:h,onEditModel:m}){var f;return s.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${u?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[s.jsx("button",{type:"button",onClick:()=>c(e,t.id),disabled:a,className:"flex-1 truncate text-left",children:t.name??((f=t.id.split("/").pop())==null?void 0:f.replace(/-/g," "))??t.id}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[s.jsx("span",{className:"text-xs text-text-muted",children:$U(t.contextWindow)}),o&&h&&s.jsx("button",{type:"button",onClick:g=>h(g,e,t.id),disabled:d,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:r?"Default model":"Set as default model",children:r?s.jsx(El,{className:"w-3.5 h-3.5 text-accent-warning"}):s.jsx(Xf,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),m&&s.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),m(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:s.jsx(kb,{className:"w-3 h-3 text-text-muted"})}),n&&s.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:s.jsx(Us,{className:"w-3.5 h-3.5"})})]})]})}function ZT({providers:e,onSelect:t,onEscape:n,extraItemCount:r=0}){const[a,o]=k.useState(""),[d,u]=k.useState(-1),c=k.useRef(null),h=k.useRef(null),m=k.useMemo(()=>a.trim()?e.map(w=>({provider:w,models:Ek(w).filter(C=>FU(C,a))})).filter(w=>w.models.length>0):e.map(w=>({provider:w,models:Ek(w)})),[e,a]),f=k.useMemo(()=>m.flatMap(w=>w.models.map(C=>({providerId:w.provider.id,modelConfig:C}))),[m]),g=f.length+r;return k.useEffect(()=>{g<=1?u(-1):d>=g?u(g-1):d<0&&a.trim()&&u(0)},[g,d,a]),k.useEffect(()=>{d>=0&&c.current&&c.current.scrollIntoView({block:"nearest"})},[d]),{searchQuery:a,setSearchQuery:o,highlightedIndex:d,setHighlightedIndex:u,visibleGroups:m,flatItems:f,totalNavItems:g,handleSearchKeyDown:w=>{switch(w.key){case"Escape":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),g>0&&u(C=>C<g-1?C+1:0);break;case"ArrowUp":w.preventDefault(),g>0&&u(C=>C>0?C-1:g-1);break;case"Home":w.preventDefault(),u(0);break;case"End":w.preventDefault(),u(g-1);break;case"Enter":if(w.preventDefault(),d>=0&&d<f.length){const C=f[d];C&&t(C.providerId,C.modelConfig.id)}break}},highlightedRef:c,inputRef:h}}function wv({providers:e,value:t,onChange:n,defaultLabel:r="Default (global model)"}){var N;const[a,o]=k.useState(!1),d=k.useRef(null),u=k.useRef(null),[c,h]=k.useState({}),m=t==null?void 0:t.split("/").slice(1).join("/"),f=m?((N=m.split("/").pop())==null?void 0:N.replace(/-/g," "))??m:void 0,{searchQuery:g,setSearchQuery:x,highlightedIndex:w,setHighlightedIndex:C,visibleGroups:v,flatItems:S,handleSearchKeyDown:_,highlightedRef:b,inputRef:j}=ZT({providers:e,onSelect:(L,A)=>{n(`${L}/${A}`),o(!1)},onEscape:()=>o(!1)}),E=k.useCallback(()=>{if(!a||!u.current)return;const L=u.current.getBoundingClientRect();h({position:"fixed",top:`${L.bottom+4}px`,left:`${L.left}px`,width:`${Math.max(L.width,288)}px`})},[a]);return k.useEffect(()=>(E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}),[E]),k.useEffect(()=>{if(!a)return;function L(D){var O;d.current&&!d.current.contains(D.target)&&!((O=D.target)!=null&&O.closest("[data-model-picker-dropdown]"))&&(o(!1),x(""),C(-1))}const A=setTimeout(()=>{document.addEventListener("mousedown",L)},0);return()=>{clearTimeout(A),document.removeEventListener("mousedown",L)}},[a,x,C]),k.useEffect(()=>{var L;a?(E(),Wt()&&((L=j.current)==null||L.focus())):(x(""),C(-1))},[a,x,C,j,E]),s.jsxs("div",{className:"relative",ref:d,children:[s.jsxs("button",{ref:u,type:"button",onClick:()=>o(!a),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary hover:bg-bg-secondary transition-colors",children:[s.jsx("span",{className:f?"text-text-primary":"text-text-muted",children:f??r}),s.jsx(gn,{className:`w-3 h-3 text-text-muted transition-transform ${a?"rotate-180":""}`})]}),a&&typeof document<"u"&&Cs.createPortal(s.jsx("div",{"data-model-picker-dropdown":!0,className:"z-50",style:c,children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg flex flex-col max-h-80",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(Fs,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:j,type:"text",value:g,onInput:L=>{x(L.currentTarget.value),C(-1)},onKeyDown:_,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsxs(mt,{className:"flex-1",children:[s.jsx("button",{type:"button",onClick:()=>{n(void 0),o(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors hover:bg-bg-tertiary ${t?"text-text-muted":"text-accent-primary bg-accent-primary/5"}`,children:r}),v.map(L=>s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-1.5 text-xs font-medium text-text-muted uppercase tracking-wider bg-bg-tertiary/50",children:L.provider.name}),L.models.map(A=>{const O=S.findIndex(P=>P.providerId===L.provider.id&&P.modelConfig.id===A.id)===w,F=t===`${L.provider.id}/${A.id}`;return s.jsx("div",{ref:O?b:void 0,children:s.jsx(JT,{providerId:L.provider.id,modelConfig:A,isActive:F,highlighted:O,onModelClick:(P,z)=>{n(`${P}/${z}`),o(!1)}})},`${L.provider.id}/${A.id}`)})]},L.provider.id)),v.length===0&&g.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})]})}),document.body)]})}const zU=4;function HU(e,t,n,r=zU){const a=Math.max(0,n.width-t.width),o=Math.min(Math.max(0,e.left),a);return n.height-e.bottom>=t.height+r?{top:e.bottom+r,left:o}:{top:Math.max(r,e.top-t.height-r),left:o}}function eA(e,t){const n=k.useRef(null),[r,a]=k.useState(null),o=k.useCallback(()=>{const d=e==null?void 0:e.current,u=n.current;if(!d||!u)return;const c=d.getBoundingClientRect(),h=u.getBoundingClientRect(),{top:m,left:f}=HU({top:c.top,bottom:c.bottom,left:c.left,width:c.width},{width:h.width||c.width,height:h.height},{width:window.innerWidth,height:window.innerHeight});a({top:m,left:f,width:c.width})},[e]);return k.useLayoutEffect(()=>{if(!t){a(null);return}o()},[t,o]),k.useEffect(()=>{if(!t)return;let d=0;const u=()=>{cancelAnimationFrame(d),d=requestAnimationFrame(o)};window.addEventListener("scroll",u,!0),window.addEventListener("resize",u);let c=null;const h=e==null?void 0:e.current,m=n.current;return typeof ResizeObserver<"u"&&h&&m&&(c=new ResizeObserver(u),c.observe(m),c.observe(h)),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),cancelAnimationFrame(d),c==null||c.disconnect()}},[t,e,o]),{panelRef:n,layout:r}}function UU(e,t){const n=e.slice(0,t);if(n.length===0||n[0]!=="/")return null;const r=n.slice(1);return r.includes(" ")||r.includes(`
275
+ `)||r.includes(" ")?null:{query:r,startIndex:0}}const Cv={builtin:"Built-in",user:"Global",project:"Project"};function _f(e,t){const n=e.filter(r=>r.id===t);if(n.length!==0)return n.find(r=>r.scope==="project")??n.find(r=>r.scope==="user")??n.find(r=>r.scope==="builtin")}function qy(e,t,n){return n!=="auto"?e.find(r=>r.id===t&&r.scope===n)??_f(e,t):_f(e,t)}const tA=k.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:o,anchorRef:d},u){const c=UU(t,n),[h,m]=k.useState(0),f=k.useRef(null),g=k.useRef([]),x=k.useRef(0),w=k.useRef([]);k.useEffect(()=>{x.current=h},[h]),k.useEffect(()=>{w.current=v});const C=(c==null?void 0:c.query)??"",v=(()=>{if(!c)return[];const E=C.toLowerCase(),N=r.filter(A=>A.id.toLowerCase().includes(E)||A.name.toLowerCase().includes(E)).map(A=>({type:"workflow",id:A.id,name:A.name,scope:A.scope,paramCount:(A.parameters??[]).length})),L=a.filter(A=>A.id.toLowerCase().includes(E)||A.name.toLowerCase().includes(E)).map(A=>({type:"command",id:A.id,name:A.name,paramCount:0}));return[...N,...L]})();k.useEffect(()=>{m(0),x.current=0},[v.length]);const S=k.useCallback(E=>{if(!c||v.length===0)return!1;switch(E.key){case"ArrowDown":return E.preventDefault(),m(N=>{var A;const L=Math.min(N+1,v.length-1);return(A=g.current[L])==null||A.scrollIntoView({block:"nearest"}),L}),!0;case"ArrowUp":return E.preventDefault(),m(N=>{var A;const L=Math.max(N-1,0);return(A=g.current[L])==null||A.scrollIntoView({block:"nearest"}),L}),!0;case"Enter":case"Tab":{const N=v[x.current];return N?(E.preventDefault(),o(N,c.startIndex),!0):!1}case"Escape":return E.preventDefault(),!0}return!1},[c,v,o]);k.useImperativeHandle(u,()=>({handleKeyDown:S}),[S]);const{panelRef:_,layout:b}=eA(d,!!c&&v.length>0);if(!c||v.length===0)return null;const j=s.jsx("div",{children:v.map((E,N)=>s.jsxs("button",{ref:L=>{g.current[N]=L},role:"option","aria-selected":N===h,className:`w-full text-left px-3 py-2 flex items-center gap-2 text-sm ${N===h?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{c&&o(E,c.startIndex)},children:[s.jsxs("span",{className:`font-medium ${E.type==="workflow"?"text-accent-primary":"text-accent-warning"}`,children:["/",E.id]}),s.jsx("span",{className:"truncate flex-1",children:E.name}),E.type==="workflow"&&s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:Cv[E.scope]}),E.paramCount>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:[E.paramCount," param",E.paramCount>1?"s":""]})]},`${E.type}-${E.id}-${E.type==="workflow"?E.scope:""}`))});if(d){const E=s.jsx("div",{ref:_,role:"listbox",className:"fixed z-[100]",style:{top:(b==null?void 0:b.top)??0,left:(b==null?void 0:b.left)??0,width:b==null?void 0:b.width},children:s.jsx(mt,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:j})});return Cs.createPortal(E,document.body)}return s.jsx("div",{ref:f,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:s.jsx(mt,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:j})})});function VU(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return null;const a=n.slice(r+1);return a.includes(" ")||a.includes(`
276
+ `)||a.includes(" ")?null:{query:a,startIndex:r}}const nA=k.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a,anchorRef:o},d){const u=VU(t,n),[c,h]=k.useState([]),[m,f]=k.useState(!1),[g,x]=k.useState(0),w=k.useRef(null),C=k.useRef([]),v=k.useRef(0),S=k.useRef([]);k.useEffect(()=>{v.current=g},[g]),k.useEffect(()=>{S.current=c},[c]),k.useEffect(()=>{if(!u){h([]);return}const A=setTimeout(()=>{_(u.query)},150);return()=>clearTimeout(A)},[u==null?void 0:u.query,r]);const _=async A=>{f(!0);try{const D=new URLSearchParams({q:A});r&&D.set("workdir",r);const F=await(await ye(`/api/files?${D.toString()}`)).json();h(F),x(0),v.current=0}catch(D){console.error("File search failed:",D),h([])}finally{f(!1)}},b=k.useCallback(A=>{if(!u)return!1;switch(A.key){case"ArrowDown":return A.preventDefault(),x(D=>{var F;const O=Math.min(D+1,S.current.length-1);return C.current[O]&&((F=C.current[O])==null||F.scrollIntoView({block:"nearest"})),O}),v.current=Math.min(v.current+1,S.current.length-1),!0;case"ArrowUp":return A.preventDefault(),x(D=>{var F;const O=Math.max(D-1,0);return C.current[O]&&((F=C.current[O])==null||F.scrollIntoView({block:"nearest"})),O}),v.current=Math.max(v.current-1,0),!0;case"Enter":case"Tab":{const D=S.current;return D[v.current]?(A.preventDefault(),a(D[v.current],u.startIndex),!0):!1}case"Escape":return A.preventDefault(),h([]),!0}return!1},[u,a]);k.useImperativeHandle(d,()=>({handleKeyDown:b}),[b]),k.useEffect(()=>{if(!u)return;const A=D=>{w.current&&!w.current.contains(D.target)&&h([])};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[u]);const{panelRef:j,layout:E}=eA(o,!!u&&(m||c.length>0));if(!u||!m&&c.length===0)return null;const N=s.jsx("ul",{children:c.map((A,D)=>s.jsxs("li",{ref:O=>{C.current[D]=O},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${D===g?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{u&&a(A,u.startIndex)},children:[A.type==="directory"?s.jsx(wr,{className:"w-4 h-4 shrink-0"}):s.jsx("span",{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"truncate",children:A.path})]},A.path))}),L=m?s.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:s.jsx("div",{className:"p-4 text-center",children:s.jsx(ma,{size:"sm"})})}):s.jsx(mt,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:N});if(o){const A=s.jsx("div",{ref:D=>{j.current=D,w.current=D},role:"listbox",className:"fixed z-[100]",style:{top:(E==null?void 0:E.top)??0,left:(E==null?void 0:E.left)??0,width:E==null?void 0:E.width},children:L});return Cs.createPortal(A,document.body)}return s.jsx("div",{ref:w,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:L})}),Nk=e=>Symbol.iterator in e,Tk=e=>"entries"in e,Ak=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[a,o]of n)if(!r.has(a)||!Object.is(o,r.get(a)))return!1;return!0},WU=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let a=n.next(),o=r.next();for(;!a.done&&!o.done;){if(!Object.is(a.value,o.value))return!1;a=n.next(),o=r.next()}return!!a.done&&!!o.done};function GU(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Nk(e)&&Nk(t)?Tk(e)&&Tk(t)?Ak(e,t):WU(e,t):Ak({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function kv(e){const t=ps.useRef(void 0);return n=>{const r=e(n);return GU(t.current,r)?t.current:t.current=r}}const $a=e=>e?`?workdir=${encodeURIComponent(e)}`:"",Fx=e=>e?`&scope=${e}`:"",Al=e=>[...e.defaults,...e.userItems,...e.projectItems],$u=()=>Gt(kv(Al)),Gt=tr((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],setWorkdir:n=>e({workdir:n}),fetchTemplateVariables:async()=>{try{const r=await(await ye("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async n=>{e({loading:!0});try{const a=await(await ye(`/api/workflows${$a(n??t().workdir)}`)).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],activeWorkflowId:a.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async(n,r,a)=>{try{const o=await ye(`/api/workflows/${n}${$a(r??t().workdir)}${Fx(a)}`);return o.ok?await o.json():null}catch{return null}},fetchDefaultContent:async(n,r)=>{try{const a=await ye(`/api/workflows/defaults/${n}${$a(r??t().workdir)}`);return a.ok?await a.json():null}catch{return null}},createWorkflow:async(n,r,a)=>{const o=a??t().workdir,d=await ha("POST",`/api/workflows${$a(o)}`,{...n,destination:r});return d.success&&await t().fetchWorkflows(o),d},updateWorkflow:async(n,r,a,o)=>{const d=a??t().workdir,u=await ha("PUT",`/api/workflows/${n}${$a(d)}${Fx(o)}`,r);return u.success&&await t().fetchWorkflows(d),u},deleteWorkflow:async(n,r,a)=>{try{const o=await ye(`/api/workflows/${n}${$a(a??t().workdir)}${Fx(r)}`,{method:"DELETE"}),d=await o.json();return o.ok?(e(u=>({...r==="user"?{userItems:u.userItems.filter(c=>c.id!==n)}:{},...r==="project"?{projectItems:u.projectItems.filter(c=>c.id!==n)}:{}})),{success:!0}):{success:!1,error:d.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r,a)=>{const o=a??t().workdir;return Uf(`/api/workflows/${n}/duplicate${$a(o)}`,()=>t().fetchWorkflows(o),r)}}));async function qU(e,t,n){t({loading:!0});try{const a=await(await ye(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const nl=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,cn=tr((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async n=>{await qU(nl("/api/commands",n),e,!0)},fetchCommand:async(n,r)=>{try{const a=await ye(nl(`/api/commands/${n}`,r));return a.ok?await a.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ye(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r,a)=>{const o=await ha("POST",nl("/api/commands",a),{...n,destination:r});return o.success&&await t().fetchCommands(a),o},updateCommand:async(n,r,a)=>{const o=await ha("PUT",nl(`/api/commands/${n}`,a),r);return o.success&&await t().fetchCommands(a),o},deleteCommand:async(n,r)=>{try{const a=await ye(nl(`/api/commands/${n}`,r),{method:"DELETE"}),o=await a.json();return a.ok?(e(d=>({userItems:d.userItems.filter(u=>u.id!==n),projectItems:d.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r,a)=>Uf(nl(`/api/commands/${n}/duplicate`,a),()=>t().fetchCommands(a),r)}));function Gn(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function Ky(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),a=new Array(e.length).fill(!1),o=n.indexOf(r);if(o>=0)for(let m=o;m<o+r.length;m++)a[m]=!0;else{let m=0;for(let f=0;f<e.length&&m<r.length;f++)n[f]===r[m]&&(a[f]=!0,m++)}const d=Array.from(e),u=[];let c="",h=a[0]??!1;for(let m=0;m<d.length;m++){const f=d[m]??"";a[m]===h?c+=f:(u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:c},u.length):c),c=f,h=a[m]??!1)}return u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:c},u.length):c),s.jsx(s.Fragment,{children:u})}function oa(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const o of r){let d=0;for(let u=0;u<o.length&&d<a.length;u++)o[u]===a[d]&&d++;if(d===a.length)return!0}return!1})}function jv(e,t,n,r,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(o=>Math.min(o+1,t));break;case"ArrowUp":e.preventDefault(),n(o=>Math.max(o-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),a();break}}function Sf(e,t,n,r){const a=e.slice(0,n),o=e.slice(t);return{newText:`${a}${r}${o}`,newCursorPos:n+r.length}}function wf(e,t){e&&(e.selectionStart=t,e.selectionEnd=t,e.focus())}function rA(e){if(e.type==="workflow"){const r=Al(Gt.getState()).find(a=>a.id===e.id&&a.scope===e.scope);return((r==null?void 0:r.parameters)??[]).map(a=>a.id)}const t=cn.getState(),n=Gn(Gn(t.defaults,t.userItems),t.projectItems).find(r=>r.id===e.id);return(n==null?void 0:n.paramNames)??[]}const KU={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function YU(e,t={}){const n={...KU,...t};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=n.maxSizeBytes){const a=await e.arrayBuffer(),o=n9(a),d=`data:${e.type};base64,${o}`,u=await sA(d);return{dataUrl:d,mimeType:e.type,size:e.size,width:u.width,height:u.height}}return await XU(e,n)}async function XU(e,t){const n=await JU(e),r=await sA(n),{width:a,height:o}=QU(r.width,r.height,t.maxWidth,t.maxHeight),d=ZU();d.width=a,d.height=o;const u=d.getContext("2d");if(!u)throw new Error("Failed to get canvas context");u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(r,0,0,a,o);let c=t.quality,h="";for(let f=0;f<10&&(h=d.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,c),!(Lk(h)<=t.maxSizeBytes||c<=.3));f++)c-=.1;const m=Lk(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:m,width:a,height:o}}function QU(e,t,n,r){const a=e/t;return e>t&&e>n?{width:n,height:Math.round(n/a)}:t>e&&t>r?{width:Math.round(r*a),height:r}:{width:e,height:t}}function JU(e){return new Promise((t,n)=>{const r=t9(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function sA(e){return new Promise((t,n)=>{const r=e9(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function ZU(){var t;const e=Ev();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function e9(){const e=Ev();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function t9(){const e=Ev();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Ev(){return globalThis}function n9(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const a=t[r];a!==void 0&&(n+=String.fromCharCode(a))}return btoa(n)}function Lk(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const Rk=50*1024*1024,Dk=1024*1024,r9=["image/png","image/jpeg","image/gif"];function s9(e){return e==="application/pdf"}function i9(e){return r9.includes(e.type)}async function a9(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(e)})}async function Yy(e,t,n){try{if(_v(e.type)){if(e.size>Dk){n(`Text file too large (${gl(e.size)}). Maximum is ${gl(Dk)}.`);return}const r=await e.text(),a={id:$h(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(qh(e.type)||s9(e.type)){if(e.size>Rk){const r=qh(e.type)?"Image":"PDF";n(`${r} file too large (${gl(e.size)}). Maximum is ${gl(Rk)}.`);return}if(qh(e.type)&&i9(e)){const r=await YU(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:$h(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await a9(e),a={id:$h(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}}else n(`Unsupported file type: ${e.type}. Supported types: images (PNG, JPG, GIF, WebP, BMP, SVG), PDF, text files, JSON, XML, YAML, and other common text-based formats.`)}catch(r){const a=r instanceof Error?r.message??"Failed to process file":"Failed to process file";n(a)}}const o9="openfox:task-draft";function l9({projectId:e,initialTask:t,onClose:n,onSaved:r}){var me;const a=!!t,o=Ht(re=>re.createTask),d=Ht(re=>re.updateTask),u=Ht(re=>re.lastError),{agents:c,fetchAgents:h}=KT(),m=c.filter(re=>!re.subagent),f=an(re=>re.providers),x=(me=Pt(re=>re.projects).find(re=>re.id===e))==null?void 0:me.workdir,w=Gt(re=>re.fetchWorkflows),C=cn(re=>re.fetchCommands);k.useEffect(()=>{h()},[h]),k.useEffect(()=>{w(x),C(x)},[x,w,C]);const v=`${o9}:${e}:${(t==null?void 0:t.id)??"new"}`,[S,_]=k.useState(()=>(t==null?void 0:t.prompt)??""),[b,j]=k.useState(()=>(t==null?void 0:t.attachments)??[]),[E,N]=k.useState(()=>(t==null?void 0:t.agentId)??void 0),[L,A]=k.useState(()=>t==null?void 0:t.providerId),[D,O]=k.useState(()=>t==null?void 0:t.model),[F,P]=k.useState(null),[z,K]=k.useState(!1),[q,W]=k.useState([]),Z=k.useRef(null),Q=k.useRef(null),H=k.useRef(null),I=k.useRef(null),M=k.useRef(null),V=k.useRef(0),$=k.useRef([]),[ee,Y]=k.useState(!1);k.useEffect(()=>{if(x)return;let re=!1;return ye(`/api/projects/${e}`).then(_e=>_e.ok?_e.json():null).then(_e=>{var Me;!re&&((Me=_e==null?void 0:_e.project)!=null&&Me.workdir)&&Pt.setState({currentProject:_e.project})}).catch(()=>{}),()=>{re=!0}},[e,x]),k.useEffect(()=>{try{const re=localStorage.getItem(v);if(re){const _e=JSON.parse(re);_e.prompt&&_(_e.prompt)}}catch{}},[]),k.useEffect(()=>{const re=setTimeout(()=>{try{localStorage.setItem(v,JSON.stringify({prompt:S}))}catch{}},300);return()=>clearTimeout(re)},[S,v]);const X=k.useCallback(re=>{for(const _e of Array.from(re))Yy(_e,Me=>j(ce=>[...ce,Me]),Me=>P(Me))},[]),U=re=>{re.clipboardData.files.length>0&&X(re.clipboardData.files)},B=re=>{re.preventDefault()},J=re=>{re.preventDefault(),re.dataTransfer.files.length>0&&X(re.dataTransfer.files)},se=re=>{$.current.push(re),$.current.length>50&&$.current.shift(),Y(!0)},ne=re=>{re!==S&&(se(S),_(re))},ie=()=>{var _e;const re=$.current.pop();re!==void 0&&(_(re),Y($.current.length>0),(_e=Z.current)==null||_e.focus())},de=k.useCallback((re,_e)=>{const{newText:Me,newCursorPos:ce}=Sf(S,V.current,_e,`/${re.id} `);se(S),_(Me),V.current=ce,wf(Z.current,ce),W(rA(re))},[S]),pe=k.useCallback((re,_e)=>{const ce=re.type==="directory"?"/":" ",{newText:Ne,newCursorPos:Xe}=Sf(S,V.current,_e,`@${re.path}${ce}`);se(S),_(Ne),V.current=Xe,wf(Z.current,Xe)},[S]),Oe=async()=>{const re=S.trim().length>0,_e=b.length>0;if(!re&&!_e){P("Add a prompt or an attachment");return}K(!0),P(null);const Me={prompt:S,...b.length>0?{attachments:b}:{},...a?{agentId:E??null}:E?{agentId:E}:{},...a&&(t!=null&&t.providerId)&&!L?{providerId:null}:L?{providerId:L}:{},...a&&(t!=null&&t.model)&&!D?{model:null}:D?{model:D}:{}},ce=a?await d(e,t.id,Me):await o(e,Me);if(K(!1),ce){try{localStorage.removeItem(v)}catch{}r(ce)}else P(u??"Could not save the task")},$e=re=>{var _e,Me;if(!((_e=M.current)!=null&&_e.handleKeyDown(re))&&!((Me=I.current)!=null&&Me.handleKeyDown(re))){if(re.key==="z"&&(re.metaKey||re.ctrlKey)){re.preventDefault(),ie();return}re.key==="Enter"&&re.shiftKey&&!re.nativeEvent.isComposing&&(re.preventDefault(),Oe())}},Pe=$u(),Ve=cn(kv(re=>Gn(Gn(re.defaults,re.userItems),re.projectItems))),Ye=(()=>{if(q.length===0)return 0;const re=S.match(/\/(\w+)\s+(.*)$/),Me=(re?re[2].trim().split(/\s+/):[]).filter(Boolean).length;return q[Me]?q.length-Me:0})(),ot=L&&D?`${L}/${D}`:void 0,Ae=a&&t.status==="in_progress"&&t.runState==="running";return s.jsxs(Et,{isOpen:!0,onClose:n,title:a?"Edit task":"New task",size:"lg",showCloseButton:!0,footer:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-sm text-text-muted truncate",children:Ae?"This task is already in progress — changes apply to the next run.":"Shift+Enter to save · Enter for a new line"}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(ct,{onClick:n,children:"Cancel"}),s.jsx(ct,{variant:"primary",onClick:()=>void Oe(),disabled:z,children:z?"Saving…":a?"Save changes":"Create task"})]})]}),children:[Ae&&s.jsx("div",{className:"mb-3 px-3 py-2 rounded bg-accent-primary/10 border border-accent-primary/30 text-sm text-text-primary",children:"This task is already in progress — changes apply to the next run."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Prompt"}),s.jsxs("div",{className:"relative",ref:Q,onDragOver:B,onDrop:J,children:[s.jsx("textarea",{ref:Z,value:S,onChange:re=>{V.current=re.target.selectionStart,ne(re.target.value)},onSelect:re=>{V.current=re.currentTarget.selectionStart},onPaste:U,onKeyDown:$e,rows:6,placeholder:"Describe the task. Slash commands (/cmd) and workflows resolve exactly as in chat when the task launches.",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary resize-y min-h-32"}),s.jsx(nA,{ref:I,text:S,cursorPos:V.current,workdir:x,anchorRef:Q,onSelect:pe}),s.jsx(tA,{ref:M,text:S,cursorPos:V.current,workflows:Pe,commands:Ve,anchorRef:Q,onSelect:de}),q.length>0&&Ye>0&&s.jsxs("div",{className:"absolute top-2 right-14 text-xs text-text-muted bg-bg-secondary/90 border border-border rounded px-2 py-1",children:[Ye," required param",Ye>1?"s":""," — tab through after the command"]}),s.jsxs("div",{className:"absolute bottom-2 right-2 flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:ie,disabled:!ee,className:"p-1.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors disabled:opacity-40 disabled:hover:bg-transparent",title:"Undo (Ctrl+Z)",children:"↩︎"}),s.jsx("button",{type:"button",onClick:()=>{var re;return(re=H.current)==null?void 0:re.click()},className:"p-1.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors",title:"Attach files",children:s.jsx(DE,{})})]}),s.jsx("input",{ref:H,type:"file",multiple:!0,className:"hidden",onChange:re=>{re.target.files&&X(re.target.files),re.target.value=""}})]})]}),b.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(re=>s.jsx(Sv,{attachment:re,onRemove:_e=>j(Me=>Me.filter(ce=>ce.id!==_e))},re.id))}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Agent"}),s.jsxs("select",{value:E??"",onChange:re=>N(re.target.value||void 0),className:"w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"",children:"Default agent"}),m.map(re=>s.jsx("option",{value:re.id,children:re.name},re.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Model"}),s.jsx(wv,{providers:f,value:ot,onChange:re=>{if(re){const _e=re.indexOf("/");A(re.slice(0,_e)),O(re.slice(_e+1))}else A(void 0),O(void 0)}})]})]}),F&&s.jsx("div",{className:"text-sm text-accent-error",children:F})]})]})}const c9=()=>`gate_${crypto.randomUUID().slice(0,8)}`;function u9({projectId:e,onClose:t}){const n=Ht(x=>x.gates),r=Ht(x=>x.loadGates),a=Ht(x=>x.setGateConfig),[o,d]=k.useState([]),[u,c]=k.useState(!1);k.useEffect(()=>{r(e)},[e,r]),k.useEffect(()=>{d(n)},[n]);const h=(x,w)=>{d(C=>C.map((v,S)=>S===x?{...v,...w}:v))},m=()=>{d(x=>[...x,{id:c9(),name:"",description:"",required:!0,variant:"done"}])},f=x=>{d(w=>w.filter((C,v)=>v!==x))},g=async()=>{const x=o.filter(w=>w.name.trim().length>0).map((w,C)=>({...w,id:w.id||`gate_${C}`,name:w.name.trim()}));c(!0),await a(e,x),c(!1),t()};return s.jsx(Et,{isOpen:!0,onClose:t,title:"Definition of Done",size:"lg",footer:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"text-sm text-text-muted",children:["Gates define what a task must carry before it may enter ",s.jsx("strong",{children:"Done"}),". Values are set by you or the agent, each recorded with actor + timestamp."]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(ct,{onClick:t,children:"Cancel"}),s.jsx(ct,{variant:"primary",onClick:()=>void g(),disabled:u,children:u?"Saving…":"Save gates"})]})]}),children:s.jsxs("div",{className:"space-y-3",children:[o.length===0&&s.jsx("p",{className:"text-sm text-text-muted",children:"No gates configured — any task can move straight to Done. Add a gate like “all green” (every criterion passes with evidence) or “commit” (work committed with a commit reference)."}),o.map((x,w)=>s.jsxs("div",{className:"border border-border rounded-lg p-3 space-y-2 bg-bg-tertiary/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xs,{type:"text",value:x.name,onChange:C=>h(w,{name:C.target.value}),placeholder:"Gate name, e.g. “all green” or “commit”",className:"flex-1 text-sm"}),s.jsx("button",{type:"button",onClick:()=>f(w),className:"p-1.5 rounded hover:bg-accent-error/10 text-text-muted hover:text-accent-error transition-colors",title:"Remove gate",children:s.jsx(Ci,{className:"w-4 h-4"})})]}),s.jsx("textarea",{value:x.description,onChange:C=>h(w,{description:C.target.value}),rows:2,placeholder:"What counts as acceptable proof? e.g. “every acceptance criterion passes with evidence, or work is committed with a commit SHA”",className:"w-full px-2.5 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary resize-y"}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-text-muted",children:[s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"checkbox",checked:x.required,onChange:C=>h(w,{required:C.target.checked})}),"Required"]}),s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"radio",name:`variant-${x.id}`,checked:x.variant==="done",onChange:()=>h(w,{variant:"done"})}),"Blocks Done"]}),s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"radio",name:`variant-${x.id}`,checked:x.variant==="ready",onChange:()=>h(w,{variant:"ready"})}),"Definition of ready (blocks In Progress)"]})]})]},x.id)),s.jsxs(ct,{onClick:m,children:[s.jsx(Fr,{className:"w-3.5 h-3.5 mr-1 inline-block"})," Add gate"]})]})})}function Sm({isOpen:e,onClose:t,projectId:n}){const r=Ht(U=>U.tasks),a=Ht(U=>U.settings),o=Ht(U=>U.loadBoard),d=Ht(U=>U.loadGates),u=Ht(U=>U.moveTask),c=Ht(U=>U.reorderTask),h=Ht(U=>U.deleteTask),m=Ht(U=>U.duplicateTask),f=Ht(U=>U.setSettings),g=Ht(U=>U.lastError),x=Pt(U=>U.projects.find(B=>B.id===n)),{agents:w,fetchAgents:C}=KT(),[v,S]=k.useState(null),[_,b]=k.useState(!1),[j,E]=k.useState(""),[N,L]=k.useState(null),A=k.useRef(null);k.useEffect(()=>{e&&(o(n),d(n),C())},[e,n,o,d,C]);const D=k.useMemo(()=>{if(!j.trim())return r;const U=j.toLowerCase();return r.filter(B=>B.prompt.toLowerCase().includes(U))},[r,j]),O=k.useMemo(()=>{const U=D.filter(se=>se.status==="todo").sort((se,ne)=>se.position-ne.position),B=D.filter(se=>se.status==="in_progress").sort((se,ne)=>se.runState==="running"!=(ne.runState==="running")?se.runState==="running"?-1:1:se.position-ne.position),J=D.filter(se=>se.status==="done").sort((se,ne)=>se.position-ne.position);return{todo:U,in_progress:B,done:J}},[D]),F=k.useMemo(()=>{const U=r.filter(J=>J.status==="in_progress"&&J.runState==="queued").sort((J,se)=>J.position-se.position),B=new Map;return U.forEach((J,se)=>B.set(J.id,se+1)),B},[r]),P=k.useMemo(()=>r.filter(U=>U.status==="in_progress"&&U.runState==="running").length,[r]),z=k.useMemo(()=>r.filter(U=>U.status==="in_progress"&&U.runState==="queued").length,[r]),K=k.useCallback(U=>{if(U.runState==="queued")return U.queuePosition!==void 0?U.queuePosition:F.get(U.id)},[F]),q=k.useCallback(async(U,B)=>{await u(n,U.id,B)},[u,n]),W=k.useCallback(async U=>{const B=A.current;A.current=null,B&&B.task.status!==U&&await q(B.task,U)},[q]),Z=k.useCallback(async U=>{const B=A.current;if(A.current=null,!B||B.task.id===U.task.id)return;const J=O[U.task.status].findIndex(se=>se.id===U.task.id);J<0||(B.task.status===U.task.status?await c(n,B.task.id,U.task.status,J):(await q(B.task,U.task.status),await c(n,B.task.id,U.task.status,J)))},[O,c,n,q]),Q=k.useCallback(U=>{const B=O[U.status].findIndex(J=>J.id===U.id);B>0&&c(n,U.id,U.status,B-1)},[O,c,n]),H=k.useCallback(U=>{const B=O[U.status].findIndex(J=>J.id===U.id);B>=0&&B<O[U.status].length-1&&c(n,U.id,U.status,B+1)},[O,c,n]),I=k.useCallback(U=>{m(n,U.id)},[m,n]),M=k.useCallback(async()=>{N&&(await h(n,N.id),L(null))},[N,h,n]),V=U=>{const B=Ht.getState().settings.slotLimit,J=Math.max(1,Math.min(10,B+U));J!==B&&f(n,{slotLimit:J})},$=()=>{const U=Ht.getState().settings.queuePaused;f(n,{queuePaused:!U})},ee={projectId:n,agents:w,queuePositionOf:K,onEdit:U=>S({mode:"edit",task:U}),onMove:(U,B)=>void q(U,B),onMoveUp:Q,onMoveDown:H,onDuplicate:I,onDelete:U=>L(U),onDragStart:U=>{A.current={task:U}},onOpenSession:()=>t()},Y=U=>{const B={todo:{title:"To Do",accentClass:"border-t-2 border-t-blue-500/60"},in_progress:{title:"In Progress",accentClass:"border-t-2 border-t-amber-500/60",hint:"Moving a task here starts it automatically."},done:{title:"Done",accentClass:"border-t-2 border-t-emerald-500/60"}}[U];return s.jsx(LU,{title:B.title,accentClass:B.accentClass,hint:"hint"in B?B.hint:void 0,tasks:O[U],headerAction:U==="todo"?s.jsxs(ct,{variant:"primary",onClick:()=>S({mode:"create"}),children:[s.jsx(Fr,{className:"w-4 h-4 mr-1 inline-block"})," New Task"]}):U==="done"?s.jsx(ct,{onClick:()=>b(!0),children:"Gates"}):void 0,footer:U==="in_progress"?X:void 0,onDropOnColumn:()=>void W(U),onDropOnCard:J=>void Z({task:J}),...ee},U)},X=s.jsxs("div",{className:"px-3 py-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-muted",children:"Parallel slots"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>V(-1),disabled:a.slotLimit<=1,"aria-label":"Decrease slot limit",className:"w-7 h-7 rounded-md bg-bg-tertiary border border-border text-text-primary text-lg leading-none hover:bg-border disabled:opacity-40 disabled:hover:bg-bg-tertiary transition-colors",children:"−"}),s.jsx("span",{className:"w-9 text-center text-sm font-semibold text-text-primary tabular-nums",title:"Parallel-slot limit",children:a.slotLimit}),s.jsx("button",{type:"button",onClick:()=>V(1),disabled:a.slotLimit>=10,"aria-label":"Increase slot limit",className:"w-7 h-7 rounded-md bg-bg-tertiary border border-border text-text-primary text-lg leading-none hover:bg-border disabled:opacity-40 disabled:hover:bg-bg-tertiary transition-colors",children:"+"})]})]}),s.jsx("div",{className:"pt-3 border-t border-border/70",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm text-text-muted",title:"Active tasks / limit",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 shrink-0"}),s.jsx("strong",{className:"text-text-primary tabular-nums",children:P})," / ",a.slotLimit," running"]}),z>0&&s.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"}),s.jsx("strong",{className:"text-text-primary tabular-nums",children:z})," queued"]})]}),s.jsxs(ct,{size:"sm",onClick:$,className:`shrink-0 flex items-center gap-1 whitespace-nowrap border ${a.queuePaused?"border-amber-400/40 text-amber-400 hover:bg-amber-400/10":"border-border text-text-muted hover:bg-bg-tertiary"}`,title:a.queuePaused?"Resume auto-launch of queued tasks":"Pause auto-launch of queued tasks",children:[a.queuePaused?s.jsx(Kf,{className:"w-3 h-3"}):s.jsx(PE,{className:"w-3 h-3"}),a.queuePaused?"Resume":"Pause"]})]})})]});return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{isOpen:e,onClose:t,title:s.jsx(YT,{projectName:(x==null?void 0:x.name)??n,children:"Tasks"}),size:"full",showCloseButton:!0,closeOnBackdropClick:!0,scrollable:!1,headerRight:s.jsx("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:s.jsxs("div",{className:"relative flex-1 min-w-0 sm:min-w-64",children:[s.jsx(Fs,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-text-muted"}),s.jsx(xs,{type:"text",value:j,onChange:U=>E(U.target.value),placeholder:"Search tasks…",className:"pl-7 pr-2 w-full text-sm"})]})}),children:[g&&s.jsxs("div",{className:"mb-2 px-3 py-2 rounded bg-accent-error/10 border border-accent-error/30 text-sm text-accent-error flex items-center justify-between",children:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>Ht.setState({lastError:null}),className:"text-sm underline",children:"Dismiss"})]}),s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2 h-full",children:[Y("todo"),Y("in_progress"),Y("done")]})]}),v&&s.jsx(l9,{projectId:n,initialTask:v.mode==="edit"?v.task:null,onClose:()=>S(null),onSaved:()=>S(null)}),_&&s.jsx(u9,{projectId:n,onClose:()=>b(!1)}),N&&s.jsx(Nl,{isOpen:!0,onClose:()=>L(null),onConfirm:()=>void M(),title:"Delete task?",message:`“${N.prompt.slice(0,60)}” will be removed from the board. Its sessions and history stay untouched.`,confirmLabel:"Delete task",confirmVariant:"danger"})]})}function d9({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=k.useState(!1),[a,o]=k.useState(!1),[d,u]=k.useState(!!document.fullscreenElement),[c,h]=Fn(),[m,f]=k.useState(!1),g=Ht(W=>W.counts.running),x=Ht(W=>W.loadCounts),w=Ht(W=>W.activeProjectId),C=Ht(W=>W.lastAutoLaunch),v=Ht(W=>W.clearAutoLaunch);k.useEffect(()=>{const W=()=>u(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const S=c.startsWith("/p/"),_=/^\/p\/[^/]+\/s\/[^/]+$/.test(c),b=kE(),j=Le(W=>W.openSessionIds.length),E=Le(W=>W.currentSession),N=Le(W=>W.sessions),L=Pt(W=>W.currentProject),A=Pt(W=>W.projects),D=an(W=>W.startAutoRefresh),O=an(W=>W.stopAutoRefresh),F=fs(W=>W.setOpen),P=fs(W=>W.isOpen),z=Si(W=>W.status==="available"),K=Si(W=>W.check);k.useEffect(()=>{Si.getState().status==="idle"&&K()},[K]),k.useEffect(()=>{const W=()=>o(!0);return window.addEventListener("open-session-dropdown",W),()=>window.removeEventListener("open-session-dropdown",W)},[]);const q=Tu();return xu(q.terminalToggle,()=>{fs.getState().toggleOpen()},{capture:!0}),k.useEffect(()=>{L!=null&&L.id&&w!==L.id&&x(L.id)},[L==null?void 0:L.id,w,x]),k.useEffect(()=>(D(),()=>O()),[D,O]),s.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&_||e&&b?s.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:b?"Toggle split view control panel":"Toggle session list","aria-label":b?"Toggle split view control panel":"Toggle session list",children:s.jsx(hy,{})}):null,s.jsx(er,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),!b&&L&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(jk,{projects:A,currentProject:L})}),s.jsx("span",{className:"md:hidden",children:s.jsx(TU,{currentProject:L,sessions:N,currentSession:E,projectIdFromUrl:S&&c.split("/")[2]||null},L==null?void 0:L.id)}),s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(EU,{sessions:N,currentProject:L,currentSession:E,isOpen:a,onOpenChange:o})})]}),!b&&!L&&s.jsx("span",{className:"hidden md:inline",children:s.jsx(jk,{projects:A})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!b&&s.jsx("button",{onClick:()=>{const W=E==null?void 0:E.id;_&&W&&Le.getState().openPane(W,{focus:!0}),h("/split-view")},className:"p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Open split view","aria-label":"Open split view",children:s.jsx(gu,{className:"w-4 h-4"})}),b&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1 text-xs text-text-muted px-1.5",title:"Split view active","data-testid":"split-indicator",children:[s.jsx(gu,{className:"w-3.5 h-3.5"}),j]}),s.jsx("button",{onClick:()=>{Le.getState().exitSplitView(),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Exit split view","aria-label":"Exit split view",children:s.jsx(ws,{className:"w-4 h-4"})})]}),_&&s.jsx("button",{onClick:()=>{var W,Z,Q;document.fullscreenElement?(W=document.exitFullscreen)==null||W.call(document):(Q=(Z=document.documentElement).requestFullscreen)==null||Q.call(Z)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:d?"Exit fullscreen":"Enter fullscreen",children:d?s.jsx(aO,{}):s.jsx(oO,{})}),S&&s.jsxs("button",{onClick:()=>f(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Project tasks","aria-label":"Open project tasks",children:[s.jsx(Qf,{className:"w-4 h-4"}),g>0&&s.jsx("span",{className:"absolute top-0.5 right-0.5 min-w-3.5 h-3.5 px-0.5 rounded-full bg-accent-success text-white text-[9px] font-semibold flex items-center justify-center",children:g>99?"99+":g})]}),S&&s.jsx("button",{onClick:()=>F(!P),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${P?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:s.jsx(hO,{})}),S&&L&&s.jsx("button",{onClick:()=>ye(`/api/projects/${L.id}/open-folder`).catch(()=>{}),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Open project folder",children:s.jsx(wr,{className:"w-4 h-4"})}),s.jsxs("button",{onClick:()=>r(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:z?"Settings — update available":"Settings",children:[s.jsx(IE,{}),z&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),s.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:s.jsx(lO,{})}),t&&_&&s.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:q.criteriaSidebar?`Toggle criteria sidebar (${Lb(q.criteriaSidebar)})`:"Toggle criteria sidebar",children:s.jsx(hy,{})})]}),s.jsx(pU,{isOpen:n,onClose:()=>r(!1)}),s.jsx(wU,{isOpen:P,onClose:()=>F(!1)}),L&&s.jsx(Sm,{isOpen:m,onClose:()=>f(!1),projectId:L.id}),C&&s.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg bg-bg-secondary border border-border shadow-xl text-sm text-text-primary",children:[s.jsxs("span",{children:["“",C.taskTitle,"” auto-launched — a slot freed up."]}),s.jsxs("button",{type:"button",onClick:()=>{const W=C.sessionId,Z=C.projectId;v(),h(`/p/${Z}/s/${W}`)},className:"flex items-center gap-1 px-2.5 py-1 rounded bg-accent-primary/25 hover:bg-accent-primary/40 font-medium transition-colors",children:["Open session ",s.jsx(Gf,{className:"w-3 h-3"})]}),s.jsx("button",{type:"button",onClick:v,className:"text-xs text-text-muted underline",children:"Dismiss"})]})]})}function iA({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:o=n?"Saving...":"Save"}){return s.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[s.jsx(ct,{variant:"secondary",onClick:e,children:a}),s.jsx(ct,{variant:"primary",onClick:t,disabled:r??n,children:o})]})}const Sh=tr()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await ye(`/api/workspace/config?workdir=${encodeURIComponent(t)}`)).json();e({config:r.config??null,loading:!1})}catch{e({loading:!1})}},saveConfig:async(t,n)=>{const r=await ye(`/api/workspace/config?workdir=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error("Failed to save workspace config");const a=await r.json();e({config:a.config??n})}})),h9=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],f9=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"],aA=/^[a-zA-Z]:$/;function m9(e,t=h9,n=f9){if(!e)return null;const r=e.replace(/[\\/]+$/,"")||"/";if(aA.test(r)||t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function oA(e){const t=e.replace(/[\\/]+$/,"");return t?aA.test(t)?`${t}\\`:t:"/"}function p9(e,t){const n=oA(e);return/[\\/]$/.test(n)?`${n}${t}`:`${n}/${t}`}function lA({isOpen:e,onClose:t,project:n}){const r=Pt(ve=>ve.updateProject),a=Sh(ve=>ve.config),o=Sh(ve=>ve.loading),d=Sh(ve=>ve.fetchConfig),u=Sh(ve=>ve.saveConfig),c=ft(ve=>ve.defaults),h=ft(ve=>ve.userItems),m=ft(ve=>ve.projectItems),f=ft(ve=>ve.fetchAgents),g={builtin:c.filter(ve=>!ve.subagent),user:h.filter(ve=>!ve.subagent),project:m.filter(ve=>!ve.subagent)},x=Gn(Gn(g.builtin,g.user),g.project),w=[{label:"Project",agents:g.project},{label:"User",agents:g.user},{label:"Built-in",agents:g.builtin}],C=w.map(ve=>({label:ve.label,agents:ve.agents.filter(tt=>!w.slice(0,w.indexOf(ve)).some(et=>et.agents.some(dt=>dt.id===tt.id)))})),v=()=>{try{zt.send("context.checkDynamic",{})}catch{}t()},[S,_]=k.useState(n.customInstructions??""),[b,j]=k.useState(n.dangerLevel??""),[E,N]=k.useState(n.defaultAgent??""),[L,A]=k.useState(!1),[D,O]=k.useState(!1),[F,P]=k.useState(!1),[z,K]=k.useState(!1),[q,W]=k.useState(null),Z=E!==""&&!x.some(ve=>ve.id===E),[Q,H]=k.useState(""),[I,M]=k.useState(!1),[V,$]=k.useState(""),[ee,Y]=k.useState(!1),[X,U]=k.useState(""),[B,J]=k.useState(!1),[se,ne]=k.useState(!1),[ie,de]=k.useState([]),[pe,Oe]=k.useState(""),[$e,Pe]=k.useState({}),[Ve,Ye]=k.useState(!1),[ot,Ae]=k.useState(new Set),me=L||D||F||I||ee||Ve;k.useEffect(()=>{e&&(_(n.customInstructions??""),j(n.dangerLevel??""),N(n.defaultAgent??""),A(!1),O(!1),P(!1),M(!1),Y(!1),Ye(!1),Ae(new Set),d(n.workdir),f(n.workdir).catch(()=>{}))},[e,n,d,f]),k.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?H(a.setup.join(" && ")):H(""),$((a==null?void 0:a.rootDir)??""),Pe((a==null?void 0:a.mcpOverrides)??{})},[a]);const re=mu(ve=>ve.servers),_e=ve=>$e[ve]??{},Me=ve=>{var dt;const tt=_e(ve);if(tt.disabled!==void 0)return tt.disabled;const et=re.find(Lt=>Lt.name===ve);return!!((dt=et==null?void 0:et.config)!=null&&dt.disabled)},ce=(ve,tt)=>{var dt;return((dt=_e(ve).disabledTools)==null?void 0:dt.includes(tt))??!1},Ne=ve=>{Pe(tt=>({...tt,[ve]:{...tt[ve],disabled:!Me(ve)}})),Ye(!0)},Xe=(ve,tt)=>{Pe(et=>{const dt=et[ve]??{},Lt=dt.disabledTools??[],qt=Lt.includes(tt)?Lt.filter(vn=>vn!==tt):[...Lt,tt];return{...et,[ve]:{...dt,disabledTools:qt.length>0?qt:void 0}}}),Ye(!0)},at=ve=>{Ae(tt=>{if(tt.has(ve)){const dt=new Set(tt);return dt.delete(ve),dt}const et=new Set(tt);return et.add(ve),et})},fe=ve=>{_(ve.target.value),A(!0)},We=ve=>{j(ve),O(!0)},Ze=ve=>{H(ve.target.value),M(!0)},it=ve=>{$(ve.target.value),Y(!0)},nt=k.useCallback(async()=>{const tt={customInstructions:S||null,dangerLevel:b===""?null:b};if(F&&(tt.defaultAgent=E===""?null:E),await r(n.id,tt),I||ee||Ve){const et=Q.trim()?Q.split("&&").map(Lt=>Lt.trim()).filter(Boolean):[],dt={};I&&(dt.setup=et),ee&&(dt.rootDir=V.trim()),Object.keys($e).length>0&&(dt.mcpOverrides=$e),await u(n.workdir,dt)}A(!1),O(!1),P(!1),M(!1),Y(!1),Ye(!1),v()},[n.id,b,S,E,F,Q,V,$e,I,ee,Ve,r,u,n.workdir,v]),De=async()=>{const ve=V.trim(),tt=(a==null?void 0:a.rootDir)??"";if(ve){const et=m9(ve);if(et==="exact"){const dt=oA(ve);W(`Cannot use "${dt}" directly as workspace root. Use a subdirectory like "${p9(ve,n.name)}" instead.`);return}if(et==="virtual_fs"){W(`Cannot use paths under "${ve}" for workspaces.`);return}}if(!ee||!ve||ve===tt){K(!0),W(null);try{await nt()}catch(et){W(et instanceof Error?et.message:"Failed to save settings")}finally{K(!1)}return}U(ve),K(!0),W(null);try{const et=await ye(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:ve,workdir:n.workdir,projectName:n.name})});if(!et.ok){const Lt=await et.json().catch(()=>({}));W((Lt==null?void 0:Lt.error)??"Failed to validate workspace root directory");return}const dt=await et.json();if(!dt.exists){Oe(dt.resolvedPath),J(!0);return}if(dt.workspaces&&dt.workspaces.length>0){de(dt.workspaces),ne(!0);return}W(null),await nt()}catch(et){W(et instanceof Error?et.message:"Failed to validate settings")}finally{K(!1)}},Re=async()=>{J(!1),K(!0);try{const ve=await ye(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:X,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!ve.ok){const et=await ve.json().catch(()=>({}));W((et==null?void 0:et.error)??"Failed to create directory"),K(!1);return}const tt=await ve.json();if(tt.workspaces&&tt.workspaces.length>0){de(tt.workspaces),ne(!0),K(!1);return}await nt()}catch(ve){W(ve instanceof Error?ve.message:"Failed to create directory")}finally{K(!1)}},Se=async()=>{ne(!1),K(!0),W(null);try{await nt()}catch(ve){W(ve instanceof Error?ve.message:"Failed to save settings")}finally{K(!1)}},Ue=()=>{J(!1),ne(!1),_(n.customInstructions??""),j(n.dangerLevel??""),N(n.defaultAgent??""),A(!1),O(!1),P(!1),M(!1),Y(!1),v()};return s.jsxs(Et,{isOpen:e,onClose:Ue,title:s.jsx(YT,{projectName:n.name,children:"Settings"}),size:"lg",footer:s.jsx(iA,{onCancel:Ue,onSave:De,saving:z,saveDisabled:!me||z}),children:[s.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),s.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."}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[s.jsx("button",{type:"button",onClick:()=>We(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${b===""?"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"}),s.jsx("button",{type:"button",onClick:()=>We("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${b==="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"}),s.jsx("button",{type:"button",onClick:()=>We("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${b==="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"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-default-agent",className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Agent"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Default agent for new sessions in this project. Choose "Use system default" to follow the global default agent. Existing sessions are not affected.'}),s.jsxs("select",{id:"project-default-agent",value:E,onChange:ve=>{N(ve.target.value),P(!0)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",disabled:z,children:[s.jsx("option",{value:"",children:"Use system default"}),Z&&s.jsxs("option",{value:E,children:[E," (missing agent)"]}),C.map(({label:ve,agents:tt})=>tt.length>0&&s.jsx("optgroup",{label:ve,children:tt.map(et=>s.jsx("option",{value:et.id,children:et.name},et.id))},ve))]}),Z&&s.jsxs("p",{className:"text-xs text-red-400 mt-1",children:['The stored default agent "',E,'" no longer exists. Pick another agent to restore a valid default.']}),x.length===0&&s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),s.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),s.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."}),s.jsx("textarea",{value:S,onChange:fe,placeholder:"Enter project-specific instructions...",className:"w-full h-32 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:z})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),o&&s.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),s.jsx("input",{type:"text",value:Q,onChange:Ze,placeholder:"npm install --prefer-offline",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:o||z})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Root Directory"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Override the default workspace location. Leave empty to use the global directory"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"~/.local/share/openfox/workspaces/"}),". Supports absolute paths or paths relative to the project."]}),s.jsx("input",{type:"text",value:V,onChange:it,placeholder:"/absolute/or/relative/path",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:o||z})]}),re.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"MCP Servers"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Override MCP server availability for this project. These overrides apply to new conversations in this project and can be further overridden per conversation from the chat MCP selector."}),s.jsx("div",{className:"space-y-2",children:re.map(ve=>{const tt=Me(ve.name);return s.jsx(PT,{server:ve,expanded:ot.has(ve.name),onToggleExpand:at,serverToggleEnabled:!tt,onServerToggle:()=>Ne(ve.name),tools:ve.tools.map(et=>({...et,enabled:!ce(ve.name,et.name)})),onToolToggle:et=>Xe(ve.name,et),statusDot:vv(tt?"disabled":ve.status),statusColor:bv(tt?"disabled":ve.status)},ve.name)})})]}),q&&s.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:q})]}),B&&s.jsxs(Et,{isOpen:B,onClose:()=>J(!1),title:"Directory not found",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>J(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Re,className:"px-4 py-2 text-sm font-medium rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:"Create"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:["The directory ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:pe})," does not exist."]}),s.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),se&&s.jsxs(Et,{isOpen:se,onClose:()=>ne(!1),title:"Orphaned workspaces",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>ne(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Se,className:"px-4 py-2 text-sm font-medium rounded bg-red-500 text-white hover:opacity-90 transition-colors",children:"Confirm change"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:[ie.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),s.jsx("ul",{className:"mt-2 space-y-1",children:ie.map(ve=>s.jsx("li",{className:"text-sm font-mono text-text-muted",children:ve.name},ve.name))}),s.jsx("p",{className:"text-sm text-text-muted mt-3",children:"Existing workspaces will remain in the old location but will no longer be accessible from this project."})]})]})}function cA({initialWidth:e,minWidth:t,maxWidth:n,direction:r}){const[a,o]=k.useState(e),[d,u]=k.useState(!1),c=k.useRef({startX:0,startWidth:e}),h=k.useCallback(m=>{m.preventDefault(),m.stopPropagation(),c.current={startX:m.clientX,startWidth:a},u(!0)},[a]);return k.useEffect(()=>{if(!d)return;const m=w=>{const{startX:C,startWidth:v}=c.current,S=w.clientX-C,_=r==="left"?v+S:v-S;o(Math.max(t,Math.min(n,_)))},f=()=>{u(!1)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",f);const g=document.body.style.userSelect,x=document.body.style.cursor;return document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",f),document.body.style.userSelect=g,document.body.style.cursor=x}},[d,r,t,n]),{width:a,isResizing:d,handleMouseDown:h}}function uA({side:e,onMouseDown:t,className:n=""}){return s.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:t,className:`absolute top-0 bottom-0 w-1 z-20 cursor-col-resize hover:bg-accent-primary/30 transition-colors ${e==="left"?"left-0 -ml-0.5":"right-0 -mr-0.5"} ${n}`})}function dA({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Fn(),[a,o]=k.useState(!1),[d,u]=k.useState(null),[c,h]=k.useState(null),[m,f]=k.useState(""),[g,x]=k.useState(!1),w=Le(Ae=>Ae.sessions),C=Le(Ae=>Ae.currentSession),v=Le(Ae=>Ae.unreadSessionIds),S=Le(Ae=>Ae.deleteSession),_=Le(Ae=>Ae.deleteAllSessions),b=Le(Ae=>Ae.loadMoreSessions),j=Le(Ae=>Ae.sessionsHasMore),E=Le(Ae=>Ae.sessionsPaginationLoading),N=Le(Ae=>Ae.sessionsWithPendingConfirmations),L=Le(Ae=>Ae.pendingPathConfirmations),A=Le(Ae=>Ae.toggleFavorite),D=Pt(Ae=>Ae.currentProject),[O,F]=k.useState(""),[P,z]=k.useState(-1),K=k.useRef(null),q=k.useRef(null),{width:W,handleMouseDown:Z}=cA({initialWidth:300,minWidth:200,maxWidth:600,direction:"left"}),Q=k.useRef(!1),H=Tu();xu(H.sessionSearch,()=>{var Ae;if(t&&document.activeElement===K.current){n==null||n();return}t||(Q.current=!0,n==null||n()),Wt()&&((Ae=K.current)==null||Ae.focus())});const I=k.useRef(null),M=k.useCallback(()=>{j&&!E&&D&&b(D.id)},[j,E,D,b]);k.useEffect(()=>{if(!I.current||!j)return;const Ae=new IntersectionObserver(me=>{const re=me[0];re&&re.isIntersecting&&M()},{threshold:.1});return Ae.observe(I.current),()=>Ae.disconnect()},[j,M]);const V=w.filter(Ae=>Ae.projectId===(D==null?void 0:D.id)),[$,ee]=k.useMemo(()=>{const Ae=[],me=[];for(const re of V)re.isFavorite?Ae.push(re):me.push(re);return[Ae,me]},[V]),Y=Ae=>O?Ae.filter(me=>{var Me;const re=me.title??"",_e=(((Me=me.recentUserPrompts)==null?void 0:Me.map(ce=>ce.content))??[]).join(" ");return oa(re,O)||oa(_e,O)}):Ae,X=k.useMemo(()=>Y($),[$,O]),U=k.useMemo(()=>Y(ee),[ee,O]),B=[...X,...U],J=O.length>0,se=J&&B.length===0;k.useEffect(()=>{z(B.length>0?0:-1)},[B.length]),k.useEffect(()=>{var me;if(P<0)return;const Ae=(me=q.current)==null?void 0:me.querySelector(`[data-sidx="${P}"]`);Ae==null||Ae.scrollIntoView({block:"nearest"})},[P]);const ne=(Ae,me)=>{me==null||me.stopPropagation(),u(Ae)},ie=()=>{d&&(S(d),(C==null?void 0:C.id)===d&&r(`/p/${e}`),u(null))},de=(Ae,me)=>{me==null||me.stopPropagation();const re=w.find(Me=>Me.id===Ae),_e=(re==null?void 0:re.title)??Ae.slice(0,6);f(_e),h(Ae)},pe=()=>{if(!c||m.trim()==="")return;const Ae=Le.getState().renameSession;Ae(c,m.trim()),h(null),f("")},Oe=()=>{x(!0)},$e=()=>{_(e),r(`/p/${e}`),x(!1)},Pe=(Ae,me)=>{A(Ae,!me)},Ve=Ae=>{if(!Q.current)return;Ae.target.closest('a[href*="/s/"]')&&(Q.current=!1,n==null||n())},Ye=()=>{var Ae;F(""),Wt()&&((Ae=K.current)==null||Ae.focus())},ot=Ae=>{var me;switch(Ae.key){case"Escape":F(""),(me=K.current)==null||me.blur();break;case"ArrowDown":Ae.preventDefault(),z(re=>re<B.length-1?re+1:re);break;case"ArrowUp":Ae.preventDefault(),z(re=>re>0?re-1:0);break;case"Enter":{Ae.preventDefault();const re=B[P];re&&(r(`/p/${e}/s/${re.id}`),Q.current&&(Q.current=!1,n==null||n()));break}}};return s.jsxs(s.Fragment,{children:[t&&n&&s.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),(()=>{const Ae=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[s.jsx(er,{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"}),s.jsx(ho,{items:[{label:"Edit project settings",onClick:()=>o(!0)},{label:"Delete all sessions",onClick:Oe,danger:!0}],trigger:s.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:s.jsx(jb,{})})}),n&&s.jsx(Bu,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),s.jsxs("div",{className:"px-4 py-2 border-b border-border",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(Fs,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{ref:K,type:"text",value:O,onChange:me=>F(me.target.value),onKeyDown:ot,placeholder:"Search sessions...",className:"w-full bg-bg-tertiary border border-border rounded pl-8 pr-8 py-1.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),O&&s.jsx("button",{type:"button",onClick:Ye,className:"absolute right-1.5 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:s.jsx(ws,{className:"w-3.5 h-3.5"})})]}),J&&!se&&s.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[B.length," ",B.length===1?"match":"matches"]})]}),D&&s.jsx(lA,{isOpen:a,onClose:()=>o(!1),project:D}),s.jsx(Nl,{isOpen:d!==null,onClose:()=>u(null),onConfirm:ie,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),s.jsx(Nl,{isOpen:g,onClose:()=>x(!1),onConfirm:$e,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),s.jsx(Et,{isOpen:c!==null,onClose:()=>{h(null),f("")},title:"Rename session",size:"sm",footer:s.jsx(iA,{onCancel:()=>{h(null),f("")},onSave:pe,saving:!1,saveDisabled:m.trim()==="",saveLabel:"Rename"}),children:s.jsx("input",{type:"text",value:m,onChange:me=>f(me.target.value),onKeyDown:me=>{me.key==="Enter"&&pe()},onFocus:me=>me.target.select(),className:"w-full px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:Wt()})}),s.jsx(mt,{className:"flex-1",children:B.length===0?s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:J?"No matching sessions":"No sessions"}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"divide-y divide-border",ref:q,onClick:Ve,children:g9(X,U,C,v,ne,de,Pe,e,N,L,O,P)}),E&&s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),s.jsx("div",{ref:I,className:"h-px"})]})})]});return s.jsxs("aside",{className:`
277
+ ${t?"md:w-[var(--sidebar-w)] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden md:border-r-0"}
278
+ md:relative md:h-auto md:translate-x-0
279
+
280
+ fixed z-50 h-[calc(100vh-32px)]
281
+ w-[300px] bg-secondary border-r border-border flex flex-col
282
+ transition-transform duration-300 ease-in-out
283
+ ${t?"translate-x-0":"-translate-x-full"}
284
+ `,style:{"--sidebar-w":`${W}px`},children:[Ae,t&&s.jsx(uA,{side:"right",onMouseDown:Z,className:"hidden md:block"})]})})()]})}function g9(e,t,n,r,a,o,d,u,c,h,m,f){let g=0;const x=C=>{const v=g++,S=(n==null?void 0:n.id)===C.id,_=v===f,b=r.includes(C.id),j=C.isRunning,E=C.isFavorite,N=c.includes(C.id)||S&&h.length>0;return s.jsx("div",{"data-sidx":v,className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${S?"bg-bg-tertiary":""} ${_?"bg-accent-primary/10":""}`,children:s.jsxs(er,{href:`/p/${u}/s/${C.id}`,className:`block ${S?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[s.jsxs("div",{className:"flex justify-between items-center mb-1",children:[s.jsx("span",{className:`font-medium truncate text-sm ${S?"text-accent-primary":"text-text-primary"}`,children:m?Ky(C.title??C.id.slice(0,6),m):C.title??C.id.slice(0,6)}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(ho,{items:[{label:E?"Remove from favorites":"Add to favorites",icon:E?s.jsx(El,{className:"w-3.5 h-3.5 text-amber-400"}):s.jsx(Xf,{className:"w-3.5 h-3.5"}),onClick:()=>d(C.id,E)},{label:"Rename session",onClick:L=>o(C.id,L)},{label:"Delete session",onClick:L=>a(C.id,L),danger:!0}],trigger:s.jsx("button",{onClick:L=>{L.preventDefault()},className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:s.jsx(jb,{})})})})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[N?s.jsx("span",{title:"Awaiting confirmation",children:s.jsx(Tb,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):j?s.jsx(uO,{}):b&&!S?s.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,!E&&s.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:_m(C.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)},w=C=>{const v=qT(C);return Array.from(v).map(([S,_])=>{const b=_[0];return b?s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:VT(b.updatedAt)}),_.map(j=>x(j))]},S):null})};return s.jsxs(s.Fragment,{children:[e.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"px-4 py-2 bg-bg-tertiary/50 text-text-primary text-xs font-semibold flex items-center gap-1",children:[s.jsx(El,{className:"w-3 h-3 text-amber-400"}),"Favorites"]}),e.map(C=>x(C))]}),t.length>0&&w(t)]})}const Ok=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function x9(){var d;const e=Pt(u=>u.currentProject),t=Le(u=>u.currentSession),n=Wf(),r=k.useRef(0),a=k.useRef(null);k.useEffect(()=>(n?(a.current||(r.current=0),a.current=window.setInterval(()=>{r.current=(r.current+1)%Ok.length,o()},150),o()):(a.current&&(clearInterval(a.current),a.current=null),o()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t]);const o=()=>{var m;const c=(m=t==null?void 0:t.metadata)==null?void 0:m.title,h=n?`${Ok[r.current]} `:"";e&&c?document.title=`${h}${e.name} - ${c} | OpenFox`:e?document.title=`${h}${e.name} | OpenFox`:document.title=`${h}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}const y9={idle:"Idle",plan:"Plan",build:"Build",verification:"Verify",blocked:"Blocked",done:"Done"};function b9(){const[,e]=Fn(),t=Le(c=>c.sessions),n=Le(c=>c.sessionsWithPendingConfirmations),r=Pt(c=>c.projects),a=k.useMemo(()=>new Map(r.map(c=>[c.id,c])),[r]),o=k.useMemo(()=>t.filter(c=>c.isRunning||n.includes(c.id)||c.phase==="blocked").sort((c,h)=>new Date(h.updatedAt).getTime()-new Date(c.updatedAt).getTime()),[t,n]),d=()=>{const c=o.map(h=>h.id);c.length!==0&&(Le.getState().enterSplitView(c,c[0]),e("/split-view"))},u=c=>{Le.getState().openPane(c,{focus:!0}),e("/split-view")};return o.length===0?null:s.jsxs("div",{className:"mb-6 md:mb-8",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold uppercase tracking-wide text-text-muted",children:"Currently running"}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-emerald-400 font-medium",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),o.length]})]}),o.length>1&&s.jsxs(ct,{variant:"primary",size:"sm",onClick:d,className:"flex items-center gap-1.5",children:[s.jsx(gu,{className:"w-3.5 h-3.5"}),"Open split view"]})]}),s.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:s.jsx("ul",{className:"divide-y divide-border",children:o.map(c=>{const h=a.get(c.projectId),m=n.includes(c.id);return s.jsxs("li",{className:"flex items-center gap-3 px-3 md:px-4 py-2.5",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${c.isRunning?"bg-emerald-400 animate-pulse":"bg-amber-400"}`,title:m?"Waiting for your input":c.isRunning?"Running":"Needs attention"}),s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[90px] truncate",children:(h==null?void 0:h.name)??c.projectId.slice(0,10)}),s.jsx("button",{type:"button",onClick:()=>e(`/p/${c.projectId}/s/${c.id}`),className:"text-sm text-text-primary truncate flex-1 min-w-0 text-left hover:underline",title:c.title??c.id,children:c.title??c.id.slice(0,8)}),s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-text-muted shrink-0",children:y9[c.phase]??c.phase}),m&&s.jsx("span",{className:"text-[10px] text-amber-400 shrink-0",title:"Pending confirmation",children:"Needs you"}),s.jsx("span",{className:"text-xs text-text-muted shrink-0 hidden sm:inline",children:WT(c.updatedAt)}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx(ct,{variant:"secondary",size:"sm",onClick:()=>e(`/p/${c.projectId}/s/${c.id}`),children:"Open"}),s.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>u(c.id),title:"Add to split view",className:"flex items-center gap-1",children:[s.jsx(gu,{className:"w-3.5 h-3.5"}),"Split"]})]})]},c.id)})})})]})}function hA({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return s.jsx(Nl,{isOpen:e,onClose:t,onConfirm:a,title:"Delete Project",confirmLabel:"Delete",confirmVariant:"danger",message:s.jsxs(s.Fragment,{children:["This will permanently delete the project"," ",s.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]})})}function v9({isOpen:e,onClose:t}){const[,n]=Fn(),[r,a]=k.useState(!1),o=UT(),[d,u]=k.useState(!1),c=Pt(A=>A.projects),h=Pt(A=>A.createProject),m=Pt(A=>A.listProjects),f=Pt(A=>A.deleteProject),[g,x]=k.useState(null),[w,C]=k.useState(null);k.useEffect(()=>{e&&m()},[e,m]);const v=A=>{n(`/p/${A}`),t()},S=(A,D)=>{D.stopPropagation(),x(A)},_=()=>{g&&(f(g.id),x(null))},b=async A=>E(A);function j(A){return A!=null&&typeof A=="object"&&"error"in A&&A.error!=null&&typeof A.error=="object"&&"code"in A.error&&A.error.code==="EACCES"}async function E(A){const D=Lu(A),O=await h(D,A);return m(),j(O)?(C(O.error.path||A),!1):O&&"id"in O?(n(`/p/${O.id}`),t(),!0):!1}const N=k.useCallback(()=>{C(null)},[]),L=k.useCallback(async()=>{const A=w;C(null),A&&await E(A)},[w]);return e?s.jsxs(Et,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:s.jsx("div",{className:"flex justify-end gap-2",children:s.jsx(ct,{variant:"secondary",onClick:t,children:"Close"})}),children:[s.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[s.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:[s.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:s.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),s.jsx(mt,{className:"flex-1",children:c.length===0?s.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[s.jsx("p",{className:"mb-2",children:"No recent projects"}),s.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):s.jsx("div",{className:"divide-y divide-border",children:c.map(A=>s.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[s.jsxs("button",{onClick:()=>v(A.id),className:"flex-1 flex items-center gap-3 text-left",children:[s.jsx(wr,{className:"w-5 h-5 text-accent-primary"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"font-medium truncate",children:A.name}),s.jsx("div",{className:"text-xs text-text-muted truncate",children:Ob(A.workdir,32)})]})]}),s.jsx("button",{onClick:D=>S(A,D),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:s.jsx(Ci,{className:"w-4 h-4"})})]},A.id))})})]}),s.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:s.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[s.jsx(ct,{variant:"primary",onClick:()=>u(!0),children:"Select existing project"}),s.jsx(ct,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&s.jsx(HT,{isOpen:r,onClose:()=>a(!1)}),g&&s.jsx(hA,{isOpen:!0,onClose:()=>x(null),projectName:g.name,onConfirm:_}),d&&s.jsx(em,{initialPath:o??void 0,onSelect:A=>{b(A)},onClose:()=>u(!1)}),w&&s.jsx(zT,{isOpen:!0,onClose:N,path:w,onRetry:L})]}):null}const _9=[{key:"todo",label:"To Do",color:"text-blue-400"},{key:"queued",label:"Queued",color:"text-amber-400"},{key:"running",label:"Running",color:"text-emerald-400"},{key:"done",label:"Done",color:"text-text-muted"}];function S9({counts:e}){return!e||e.todo+e.queued+e.running+e.done===0?null:s.jsx("span",{className:"flex items-center gap-1.5",children:_9.map(n=>{const r=e[n.key];return r===0?null:s.jsxs("span",{title:n.label,className:`flex items-center gap-1 ${n.color}`,children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current"}),r]},n.key)})})}function w9(){const[e,t]=k.useState(!1),[n,r]=k.useState(null),[a,o]=k.useState(""),[d,u]=k.useState(""),[c,h]=k.useState(null),m=k.useRef(null),f=Le(M=>M.searchSessions??M.sessions),g=Le(M=>M.searchSessions!==null),x=Pt(M=>M.projects),w=Pt(M=>M.loading),C=Pt(M=>M.listProjects),v=Le(M=>M.listHomeSessions),S=Le(M=>M.ensureFullSessionList),_=Pt(M=>M.deleteProject),b=Le(M=>M.connectionStatus),j=Ht(M=>M.summaries),E=Ht(M=>M.loadSummaries);k.useEffect(()=>{b==="connected"&&(C(),v())},[b,C,v]);const N=x.map(M=>M.id).sort().join(",");k.useEffect(()=>{N&&E(N.split(","))},[N,E]),k.useEffect(()=>{const M=setTimeout(()=>u(a),150);return()=>clearTimeout(M)},[a]),k.useEffect(()=>{d&&!g&&S()},[d,g,S]);const{matchCount:L,filteredSessionIds:A,relevanceScores:D,matchTypes:O,promptSnippets:F}=k.useMemo(()=>{if(!d)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const M=new Map(x.map(X=>[X.id,X])),V=new Map,$=new Map,ee=new Map,Y=f.filter(X=>{var pe;const U=M.get(X.projectId),B=(U==null?void 0:U.name)??"",J=X.title??"",se=((pe=X.recentUserPrompts)==null?void 0:pe.map(Oe=>Oe.content))??[],ne=se.join(" ");let ie=0,de="";if(oa(J,d)&&(ie+=10,de="title"),oa(ne,d)){ie+=3,de=de==="title"?"title":"prompts";const Oe=se.find($e=>oa($e,d));if(Oe){const $e=Oe.toLowerCase().indexOf(d.toLowerCase());if($e>=0){const Pe=Math.max(0,$e-30),Ve=Math.min(Oe.length,$e+d.length+30);ee.set(X.id,(Pe>0?"…":"")+Oe.slice(Pe,Ve)+(Ve<Oe.length?"…":""))}else ee.set(X.id,Oe.slice(0,80)+(Oe.length>80?"…":""))}}return oa(B,d)&&(ie+=1,de=de||"project"),V.set(X.id,ie),$.set(X.id,de),ie>0});return{matchCount:Y.length,filteredSessionIds:new Set(Y.map(X=>X.id)),relevanceScores:V,matchTypes:$,promptSnippets:ee}},[f,d,x]),P=k.useMemo(()=>{const M=new Map;for(const V of f){const $=new Date(V.updatedAt).getTime(),ee=M.get(V.projectId)??0;$>ee&&M.set(V.projectId,$)}return M},[f]),z=k.useMemo(()=>{const M=new Map;for(const V of f){const $=M.get(V.projectId);$?$.push(V):M.set(V.projectId,[V])}for(const[,V]of M)V.sort(($,ee)=>new Date(ee.updatedAt).getTime()-new Date($.updatedAt).getTime());return M},[f]),K=k.useMemo(()=>{let M=x;return d&&A&&(M=x.filter(V=>{const $=z.get(V.id);return $==null?void 0:$.some(ee=>A.has(ee.id))})),[...M].sort((V,$)=>{const ee=P.get(V.id)??new Date(V.updatedAt).getTime();return(P.get($.id)??new Date($.updatedAt).getTime())-ee})},[x,z,d,A,P]),q=k.useCallback(M=>{const V=z.get(M);return V?d&&A&&D?V.filter($=>A.has($.id)).sort(($,ee)=>{const Y=(D.get(ee.id)??0)-(D.get($.id)??0);return Y!==0?Y:new Date(ee.updatedAt).getTime()-new Date($.updatedAt).getTime()}):V.slice(0,5):[]},[z,d,A,D]),W=()=>{t(!0)},Z=()=>{var M;o(""),u(""),Wt()&&((M=m.current)==null||M.focus())},Q=M=>{var V;M.key==="Escape"&&(Z(),(V=m.current)==null||V.blur())},H=d.length>0,I=H&&L===0;return s.jsxs(mt,{className:"flex-1 flex flex-col bg-primary",children:[s.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),s.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(er,{href:"/split-view",className:"inline-flex items-center gap-1.5 rounded font-medium transition-colors bg-bg-secondary border border-border text-text-primary hover:bg-bg-tertiary px-3 py-1.5 text-sm",children:[s.jsx(gu,{className:"w-4 h-4"}),"Open split view"]}),s.jsx(ct,{variant:"primary",onClick:W,children:"Open Project"})]})]}),s.jsx(b9,{}),f.length>0&&s.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(Fs,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),s.jsx("input",{ref:m,type:"text",value:a,onChange:M=>o(M.target.value),onKeyDown:Q,placeholder:"Search sessions by title or keyword...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-10 pr-10 py-2.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),a&&s.jsx("button",{type:"button",onClick:Z,className:"absolute right-3 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:s.jsx(ws,{className:"w-4 h-4"})})]}),H&&!I&&s.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[L," ",L===1?"match":"matches"]})]}),I?s.jsxs("div",{className:"text-center py-16 text-text-muted",children:[s.jsx(Fs,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),s.jsxs("p",{className:"text-lg",children:["No sessions matching ",s.jsxs("span",{className:"text-text-primary font-medium",children:["“",d,"”"]})]}),s.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):K.map(M=>{const V=q(M.id);return s.jsx("div",{className:"mb-6 md:mb-8",children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[s.jsxs(er,{href:`/p/${M.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[s.jsx(wr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),s.jsx("span",{className:"text-text-primary font-semibold",children:M.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>h(M.id),title:`Tasks for ${M.name}`,"aria-label":`Tasks for ${M.name}`,className:"flex items-center gap-1.5",children:[s.jsx(Qf,{className:"w-4 h-4"}),s.jsx("span",{children:"Tasks"}),s.jsx(S9,{counts:j[M.id]})]}),s.jsx(er,{href:`/p/${M.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"})]}),s.jsx("button",{type:"button",onClick:()=>r({id:M.id,name:M.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:s.jsx(Ci,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"divide-y divide-border",children:V.length>0?V.map($=>{const ee=x.find(B=>$.projectId===B.id),Y=ee?`/p/${ee.id}/s/${$.id}`:"#",X=$.title??$.id.slice(0,8),U=O==null?void 0:O.get($.id);return s.jsx(er,{href:Y,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-muted truncate",children:H&&U==="title"?Ky(X,d):X}),H&&U&&U!=="title"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[s.jsx("span",{className:"text-[10px] font-medium text-accent-primary border border-accent-primary/30 bg-accent-primary/8 rounded px-1 py-0.5 leading-none",children:U==="prompts"?"prompts":"project"}),U==="prompts"&&(F==null?void 0:F.get($.id))&&s.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:Ky(F.get($.id),d)})]})]})}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:"text-text-muted text-xs",children:WT($.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs",children:[$.messageCount," msgs"]})]})]})},$.id)}):s.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},M.id)}),!H&&K.length===0&&!w&&s.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),w&&s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ma,{})})]}),e&&s.jsx(v9,{isOpen:e,onClose:()=>t(!1)}),c&&s.jsx(Sm,{isOpen:!0,onClose:()=>h(null),projectId:c}),n&&s.jsx(hA,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>_(n.id)})]})}function C9(){const[,e]=Ol("/p/:projectId/new"),[,t]=Fn(),n=e==null?void 0:e.projectId,r=Le(d=>d.createSession),a=Le(d=>d.resetPendingSessionCreate),o=k.useCallback(async()=>{if(!n)return;const d=await r(n);d?(t(`/p/${n}/s/${d.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return k.useEffect(()=>{o()},[o]),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ma,{})})}function k9(){const e=Pt(t=>t.currentProject);return s.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),s.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),s.jsxs("div",{className:"flex flex-col gap-3",children:[e&&s.jsx(er,{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"}),s.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const fA=k.createContext(null),j9=fA.Provider;function jr(){const e=k.useContext(fA),t=Le(n=>{var r;return n.focusedSessionId??((r=n.currentSession)==null?void 0:r.id)??null});return e||t}function on(e,t,n,r){return Le(a=>{var o,d;if(e){const u=(o=a.panes)==null?void 0:o[e];return u?t(u):((d=a.currentSession)==null?void 0:d.id)===e?n(a):r}return n(a)})}function Ul(){const e=jr(),t=on(e,r=>r.contextState??null,r=>r.contextState,null),n=on(e,r=>r.session??null,r=>r.currentSession,null);return{sessionId:e,contextState:t,currentSession:n}}function mA(){const e=jr(),t=Le(n=>n.queueUpdate);return k.useCallback(n=>{n?e&&t(e):zt.send("context.applyDynamic",{...e?{sessionId:e}:{}})},[e,t])}const qc=e=>Math.round(e*10)/10;function E9(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function Xy(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function N9(e){return`${e.providerId}::${e.model}`}function T9(e){return`${e.providerName} > ${e.model}`}function Mk(e){let t=0,n=0,r=0,a=0,o=0,d=0;const u=[],c=[];let h=0;for(const[g,x]of e.entries()){const w=x.stats,C=Xy(w);t+=w.totalTime,n+=w.toolTime,r+=w.prefillTokens,a+=w.generationTokens;const v=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;o+=v,d+=S,u.push({messageId:x.id,timestamp:x.timestamp,...C,mode:w.mode,responseIndex:g+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const _=w.llmCalls??[];for(const b of _)h+=1,c.push({messageId:x.id,timestamp:b.timestamp??x.timestamp,providerId:b.providerId,providerName:b.providerName,backend:b.backend,model:b.model,mode:w.mode,responseIndex:g+1,sessionCallIndex:h,callIndex:b.callIndex,promptTokens:b.promptTokens,completionTokens:b.completionTokens,ttft:b.ttft,completionTime:b.completionTime,prefillSpeed:b.prefillSpeed,generationSpeed:b.generationSpeed,totalTime:b.totalTime,...b.temperature!==void 0&&{temperature:b.temperature},...b.topP!==void 0&&{topP:b.topP},...b.topK!==void 0&&{topK:b.topK},...b.maxTokens!==void 0&&{maxTokens:b.maxTokens}})}const m=o>0?qc(r/o):0,f=d>0?qc(a/d):0;return{totalTime:qc(t),aiTime:qc(t-n),toolTime:qc(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:m,avgGenerationSpeed:f,responseCount:e.length,llmCallCount:c.length,dataPoints:u,callDataPoints:c}}function pA(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&E9(a.stats)).sort((a,o)=>new Date(a.timestamp).getTime()-new Date(o.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const o=N9(Xy(a.stats)),d=n.get(o)??[];n.set(o,[...d,a])}const r=Array.from(n.entries()).map(([a,o])=>{const d=Xy(o[0].stats),u=Mk(o);return{...d,key:a,label:T9(d),...u}});return{...Mk(t),modelGroups:r}}function A9(e){return k.useMemo(()=>pA(e),[e])}function Nv(){var o;const{sessionId:e,currentSession:t}=Ul(),n=on(e,d=>d.gitStatus,d=>d.gitStatus,null),[r,a]=k.useState(!0);return k.useEffect(()=>{t!=null&&t.workdir&&a(!1)},[t==null?void 0:t.workdir]),{branch:(n==null?void 0:n.branch)??null,diff:{files:((o=n==null?void 0:n.diff)==null?void 0:o.files)??[],loading:r,error:null}}}function Ll(e){return e.toLocaleString("en-US").replace(/,/g," ")}function Ik(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Bs(e){if(!Number.isFinite(e))return"0s";if(e<10)return`${e.toFixed(1)}s`;const t=Math.round(e);if(t<60)return`${t}s`;if(t<3600){const d=Math.floor(t/60),u=t%60;return`${d}m ${u}s`}const n=Math.floor(t/3600),r=t%3600,a=Math.floor(r/60),o=r%60;return`${n}h ${a}m ${o}s`}const Pk=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),Bk=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function Sl(e){return Object.hasOwn(Pk,e)?Pk[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function L9(e){return Object.hasOwn(Bk,e)?Bk[e]:e.replace(/_/g," ")}const $k=["▁","▂","▃","▄","▅","▆","▇","█"];function R9(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 D9(e,t){if(e===t){const a=Math.max(Math.abs(e)*.05,1);return{minY:e-a,maxY:t+a}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function O9(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,x)=>g.x-x.x),r=n[0].x,a=n[n.length-1].x,o=Math.min(...n.map(g=>g.y)),d=Math.max(...n.map(g=>g.y)),{minY:u,maxY:c}=D9(o,d),h=Math.max(0,u),m=Array.from({length:t},()=>" "),f=new Map;for(const g of n){const x=a===r?0:Math.round((g.x-r)/(a-r)*(t-1)),w=f.get(x)??[];f.set(x,[...w,g.y])}for(const[g,x]of f){const w=Math.max(...x);m[g]=$k[R9(w,u,c)]??$k[0]}return{blocks:m.join(""),minX:r,maxX:a,minY:h,maxY:c}}function Fk(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function zk({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:o,showAxes:d=!0,formatY:u=Fk,formatX:c=Fk}){const h=k.useMemo(()=>{const m=O9(e,t),f=Math.max(t*6,240),g=10,x=8,C=[...e].sort((b,j)=>b.x-j.x).map(b=>{const j=m.maxX===m.minX?f/2:g+(b.x-m.minX)/(m.maxX-m.minX)*(f-g*2),E=m.maxY===m.minY?n/2:x+(m.maxY-b.y)/(m.maxY-m.minY)*(n-x*2);return{...b,cx:j,cy:E,leftPercent:j/f*100,topPercent:E/n*100}}),v=C.map((b,j)=>`${j===0?"M":"L"} ${b.cx.toFixed(1)} ${b.cy.toFixed(1)}`).join(" "),_=[m.maxY,(m.maxY+m.minY)/2,m.minY].map(b=>({value:b,y:m.maxY===m.minY?n/2:x+(m.maxY-b)/(m.maxY-m.minY)*(n-x*2)}));return{...m,chartWidth:f,points:C,path:v,gridLines:_}},[e,n,t]);return e.length===0?s.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&s.jsx("div",{className:"mb-1",children:r}),s.jsx("div",{children:"No data"})]}):s.jsxs("div",{className:"font-mono text-xs",children:[r&&s.jsx("div",{className:"text-text-secondary mb-2",children:r}),s.jsxs("div",{className:"flex gap-3",children:[d&&s.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(m=>s.jsx("span",{children:u(m.value)},`${m.value}-${m.y}`))}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"relative h-[78px]",children:[s.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(m=>s.jsx("line",{x1:"0",x2:h.chartWidth,y1:m.y,y2:m.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${m.y}`)),h.points.map(m=>s.jsx("line",{x1:m.cx,x2:m.cx,y1:n-4,y2:m.cy,stroke:"currentColor",className:"text-border/40"},`guide-${m.cx}-${m.cy}`)),h.points.length>1&&s.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(m=>s.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${m.leftPercent}%`,top:`${m.topPercent}%`},title:`${c(m.x)} -> ${u(m.y)}`,children:s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${m.x}-${m.y}`))]})})]}),d&&s.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[s.jsx("span",{className:"w-12"}),s.jsxs("span",{className:"flex-1 flex justify-between",children:[s.jsx("span",{children:c(h.minX)}),s.jsx("span",{children:a}),s.jsx("span",{children:c(h.maxX)})]})]}),o&&d&&s.jsx("div",{className:"text-text-muted mt-1 text-center",children:o})]})}function M9({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:a=60}){const o=e.map(u=>({x:u.x,y:u.ppSpeed})),d=e.map(u=>({x:u.x,y:u.tgSpeed}));return s.jsxs("div",{className:"space-y-5",children:[s.jsx(zk,{data:o,width:a,label:t,xLabel:r}),s.jsx(zk,{data:d,width:a,label:n,xLabel:r})]})}function I9(e){const t=new Map;for(const n of e.callDataPoints){const r=t.get(n.messageId)??[];t.set(n.messageId,[...r,n])}return e.dataPoints.map(n=>{const r=[...t.get(n.messageId)??[]].sort((a,o)=>a.callIndex-o.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function P9(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 B9(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 $9(e){return e.callDataPoints.length>0?B9(e):P9(e)}function io(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function tu(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function F9(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${io(t)} ctx`:`${io(t)}-${io(n)} ctx`}function Cf(e){return`${tu(e)} t/s`}function gA(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function z9(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 H9({isOpen:e,onClose:t,stats:n}){const r=k.useRef(null),[a,o]=k.useState({}),[d,u]=k.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});k.useEffect(()=>{var w;n.modelGroups.some(C=>C.key===d)||u(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[d,n.modelGroups]);const c=k.useMemo(()=>n.modelGroups.find(w=>w.key===d)??n.modelGroups[0],[d,n.modelGroups]),h=k.useMemo(()=>c?I9(c):[],[c]),m=k.useMemo(()=>c?$9(c):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[c]),f=k.useCallback(w=>{o(C=>({...C,[w]:!C[w]}))},[]),g=k.useCallback(()=>{if(!c)return;const w=z9(c);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[c]),x=k.useCallback(async()=>{if(r.current)try{const w=(await ae(async()=>{const{default:S}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:S}},[])).default,C=await w(r.current,{backgroundColor:"#1a1a1a",scale:2}),v=document.createElement("a");v.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,v.href=C.toDataURL("image/png"),v.click()}catch(w){console.error("Failed to export PNG:",w),g()}},[g]);return s.jsx(Et,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:s.jsxs("div",{ref:r,className:"space-y-6",children:[s.jsx("section",{children:s.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>s.jsx("button",{onClick:()=>u(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.key===(c==null?void 0:c.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:w.label,children:w.label},w.key))})}),c&&s.jsxs("section",{children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[s.jsx(hi,{label:"AI Time",value:Bs(c.aiTime)}),s.jsx(hi,{label:"Total Time",value:Bs(c.totalTime)}),s.jsx(hi,{label:"Tool Time",value:Bs(c.toolTime)}),s.jsx(hi,{label:"Responses",value:c.responseCount.toString()}),s.jsx(hi,{label:"LLM Calls",value:c.llmCallCount.toString()})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[s.jsx(hi,{label:"Prefill Tokens",value:io(c.prefillTokens),subValue:`@ ${tu(c.avgPrefillSpeed)} tok/s`}),s.jsx(hi,{label:"Gen Tokens",value:io(c.generationTokens),subValue:`@ ${tu(c.avgGenerationSpeed)} tok/s`}),s.jsx(hi,{label:"Avg PP Speed",value:`${tu(c.avgPrefillSpeed)}`,subValue:"tok/s"}),s.jsx(hi,{label:"Avg TG Speed",value:`${tu(c.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),c&&m.points.length>1&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:g,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),s.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"})]})]}),s.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:s.jsx(M9,{data:m.points,width:50,prefillLabel:m.prefillLabel,generationLabel:m.generationLabel,xLabel:m.xLabel})})]}),c&&s.jsxs("section",{children:[s.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",c.responseCount," responses)"]}),s.jsx(mt,{className:"bg-bg-tertiary/30 rounded",children:s.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"w-[7%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[10%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[11%]"}),s.jsx("col",{className:"w-[2%]"})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[s.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),s.jsx("th",{className:"px-2 py-2"})]})}),s.jsx("tbody",{children:h.map((w,C)=>s.jsxs(k.Fragment,{children:[s.jsx(U9,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>f(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((v,S)=>s.jsx(V9,{dataPoint:v,index:S},`${v.messageId}-${v.callIndex}`))]},w.messageId))})]})})]})]})})}function hi({label:e,value:t,subValue:n}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),s.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&s.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function U9({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?F9(e.calls.map(o=>o.promptTokens)):`${io(e.prefillTokens)} ctx`;return s.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[s.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:gA(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Bs(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Cf(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Cf(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function V9({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[s.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]}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:gA(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Bs(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:io(e.promptTokens)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Cf(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Cf(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),s.jsx("td",{className:"px-2 py-2"})]}),n&&s.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:s.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:s.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&s.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&s.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&s.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&s.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const W9={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"}},xA=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function G9(e){return W9[e]??{icon:"○",color:"text-text-muted"}}function Tv(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Vl=k.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=G9(t);return s.jsx("span",{className:`${a} ${n}`,children:r})});function kf({entries:e,title:t}){const n=k.useMemo(()=>e.reduce((r,a)=>(r[a.status]=(r[a.status]??0)+1,r),{}),[e]);return s.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[s.jsx("span",{children:t}),Object.keys(n).length>0&&s.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:xA.map(r=>{const a=n[r];return a?s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(Vl,{status:r}),s.jsx("span",{children:a})]},r):null})})]})}const yA=k.memo(function({entries:t,title:n,onClearAll:r}){const[a,o]=k.useState(!1),d=k.useCallback(()=>{o(!1),r==null||r()},[r]);return t.length===0?null:s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&s.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),s.jsx("div",{className:"bg-primary",children:t.map((u,c)=>s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${c>0?"border-t border-border":""}`,children:[s.jsx(Vl,{status:u.status}),s.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[s.jsxs("span",{className:"text-text-muted",children:["[",u.id,"]"]})," ",Tv(u.description)]})]},u.id??c))}),r&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:s.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all",children:[s.jsx(Ci,{className:"w-3 h-3"}),"Clear all"]})}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:d,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>o(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),q9={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},K9=["pending","completed","failed","dismissed"];function Y9(e){return q9[e]??K9}function X9(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function bA({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:o}){const[d,u]=k.useState(e),[c,h]=k.useState(null),[m,f]=k.useState(""),[g,x]=k.useState(!1),[w,C]=k.useState(""),v=k.useRef(null),S=k.useRef(null),_=k.useCallback(()=>{const P=S.current;P&&(P.style.height="auto",P.style.height=P.scrollHeight+"px")},[]);k.useEffect(()=>{u(e)},[e]),k.useEffect(()=>{var P;c&&(_(),Wt()&&((P=S.current)==null||P.focus()))},[c,_]),k.useEffect(()=>{var P;g&&Wt()&&((P=v.current)==null||P.focus())},[g]);const b=k.useCallback(P=>{u(P),ye(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:P})}).catch(z=>console.error(`Failed to sync ${n}:`,z))},[t,n]),j=k.useCallback(P=>{const z=Y9(n),K=d.map(q=>q.id===P?{...q,status:X9(q.status,z)}:q);b(K)},[d,n,b]),E=k.useCallback((P,z)=>{h(P),f(z)},[]),N=k.useCallback((P,z,K)=>{var Z;const q=(z.trim()||((Z=K.find(Q=>Q.id===P))==null?void 0:Z.description))??"",W=K.map(Q=>Q.id===P?{...Q,description:q}:Q);b(W)},[b]),L=k.useCallback(()=>{c&&(N(c,m,d),h(null))},[c,m,d,N]),A=k.useCallback(P=>{P.key==="Enter"&&L(),P.key==="Escape"&&(P.stopPropagation(),h(null))},[L]),D=k.useCallback(P=>{b(d.filter(z=>z.id!==P))},[d,b]),O=k.useCallback(()=>{const P=w.trim();if(!P)return;const z=d.map(q=>Number(q.id)).filter(q=>Number.isInteger(q)&&q>=0),K=String(Math.max(-1,...z)+1);b([...d,{id:K,description:P,status:"pending"}]),C("")},[w,d,b]),F=k.useCallback(P=>{P.key==="Enter"&&(P.preventDefault(),O()),P.key==="Escape"&&(x(!1),C(""))},[O]);return s.jsxs(Et,{isOpen:a,onClose:o,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[s.jsxs("ul",{className:"space-y-1",children:[d.map((P,z)=>{const K=c===P.id,q=s.jsxs("button",{onClick:()=>E(P.id,P.description),className:"text-sm text-text-primary text-left hover:text-accent-primary transition-colors w-full cursor-pointer",title:"Click to edit",children:[s.jsxs("span",{className:"text-text-muted",children:["[",P.id,"]"]})," ",s.jsx("span",{children:Tv(P.description)})]}),W=K?s.jsx("textarea",{ref:S,value:m,onChange:Z=>{f(Z.target.value),_()},onBlur:L,onKeyDown:A,className:"w-full bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary resize-none",rows:1}):q;return s.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${z>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>j(P.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:s.jsx(Vl,{status:P.status})}),s.jsx("div",{className:"flex-1 min-w-0",children:W}),s.jsx("button",{onClick:()=>D(P.id),className:"flex-shrink-0 text-text-muted hover:text-accent-error transition-colors cursor-pointer mt-0.5 ml-auto",title:"Delete entry",children:s.jsx("span",{className:"flex",children:s.jsx(ws,{className:"w-4 h-4"})})})]},P.id)}),d.length===0&&s.jsx("p",{className:"text-sm text-text-muted italic text-center py-4",children:"No entries yet."})]}),s.jsx("div",{className:"mt-4 pt-3 border-t border-border",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight",children:"○"}),s.jsx("input",{ref:v,value:w,onChange:P=>C(P.target.value),onKeyDown:F,placeholder:"New entry...",className:"flex-1 bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"}),s.jsxs("button",{onClick:O,className:"flex items-center gap-1 text-sm text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add entry",children:[s.jsx(Fr,{className:"w-4 h-4"}),"Add"]})]})})]})}const Q9={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function J9(e,t){await ye(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function wh({id:e,agents:t}){const n=lo(t,e),r=t.find(a=>a.id===e);return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function Z9({id:e}){const t=Gt(d=>d.defaults),n=Gt(d=>d.userItems),a=k.useMemo(()=>[...t,...n],[t,n]).find(d=>d.id===e),o=(a==null?void 0:a.color)??"#3b82f6";return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${o}20`,color:o},children:(a==null?void 0:a.name)??e})}function vA({entries:e,sessionId:t}){const[n,r]=k.useState(e),[a,o]=k.useState(!1),[d,u]=k.useState(null),[c,h]=k.useState(""),[m,f]=k.useState(""),[g,x]=k.useState(!1),[w,C]=k.useState(!1),v=ft(Q=>Q.defaults),S=ft(Q=>Q.userItems),_=ft(Q=>Q.projectItems),b=k.useMemo(()=>[...v,...S,..._],[v,S,_]),j=k.useRef(null),E=k.useRef(null);k.useEffect(()=>{r(e)},[e]),k.useEffect(()=>{var Q;a&&Wt()&&((Q=j.current)==null||Q.focus())},[a]),k.useEffect(()=>{var Q;d&&Wt()&&((Q=E.current)==null||Q.focus())},[d]);const N=k.useCallback(Q=>{r(Q),J9(t,Q)},[t]),L=k.useCallback(Q=>{var $;const H=Q.map(ee=>ee.trim()).filter(Boolean);if(H.length===0)return;const I=n.map(ee=>Number(ee.id)).filter(ee=>Number.isInteger(ee)&&ee>=0),M=Math.max(-1,...I)+1,V=H.map((ee,Y)=>({id:String(M+Y),description:ee,status:"pending"}));N([...n,...V]),h(""),Wt()&&(($=j.current)==null||$.focus())},[n,N]),A=k.useCallback(()=>{L([c])},[L,c]),D=k.useCallback(Q=>{const H=Q.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);H.length<2||(Q.preventDefault(),L(H))},[L]),O=k.useCallback(()=>{o(!1),h("")},[]),F=k.useCallback((Q,H)=>{u(Q),f(H)},[]),P=k.useCallback(()=>{if(!d)return;const Q=m.trim(),H=n.map(I=>I.id===d?{...I,description:Q||I.description}:I);N(H),u(null)},[d,m,n,N]),z=k.useCallback(Q=>{const H=n.map(I=>I.id===Q?{...I,status:Q9[I.status]??"pending"}:I);N(H)},[n,N]),K=k.useCallback(Q=>{N(n.filter(H=>H.id!==Q))},[n,N]),q=k.useCallback(()=>{N([]),x(!1)},[N]),W=k.useCallback(Q=>{Q.key==="Enter"&&(Q.preventDefault(),A()),Q.key==="Escape"&&O()},[A,O]),Z=k.useCallback(Q=>{Q.key==="Enter"&&P(),Q.key==="Escape"&&u(null)},[P]);return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&s.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",s.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((Q,H)=>{const I=Q.status,M=d===Q.id;return s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${H>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>z(Q.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${Q.status} (click to cycle)`,children:s.jsx(Vl,{status:I})}),s.jsx("div",{className:"flex-1 min-w-0",children:M?s.jsx("input",{ref:E,value:m,onChange:V=>f(V.target.value),onBlur:P,onKeyDown:Z,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):s.jsxs("button",{onClick:()=>F(Q.id,Q.description),className:"text-xs text-text-primary text-left hover:text-accent-primary transition-colors w-full truncate cursor-pointer",title:"Click to edit",children:["[",Q.id,"] ",Tv(Q.description)]})}),s.jsx("button",{onClick:()=>K(Q.id),className:"flex-shrink-0 opacity-0 group-hover:opacity-100 text-text-muted hover:text-accent-error transition-all ml-0.5 cursor-pointer flex items-center self-center",title:"Delete criterion",children:s.jsx(ws,{className:"w-4 h-4"})})]},Q.id)})]}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),s.jsx("input",{ref:j,value:c,onChange:Q=>h(Q.target.value),onKeyDown:W,onPaste:D,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"})]})}),s.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:A,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[s.jsx(Fr,{className:"w-3 h-3"}),"Add"]}),s.jsx("button",{onClick:O,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):s.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[s.jsx(Fr,{className:"w-3 h-3"}),"Add"]}),n.length>0&&(g?s.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),s.jsx("button",{onClick:q,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>x(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]}):s.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:[s.jsx(Ci,{className:"w-3 h-3"}),"Clear all"]})),s.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:s.jsx(qf,{className:"w-3 h-3"})})]}),s.jsx(Et,{isOpen:w,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:s.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[s.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),s.jsxs("p",{children:["To use this feature, start in ",s.jsx(wh,{id:"planner",agents:b})," mode and",s.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",s.jsx(Z9,{id:"default"})," builtin workflow to launch the automation part."]}),s.jsx("p",{children:"This workflow will automatically:"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["Launch the ",s.jsx(wh,{id:"builder",agents:b}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),s.jsxs("li",{children:["Then launch the ",s.jsx(wh,{id:"verifier",agents:b})," 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."]}),s.jsxs("li",{children:["Launch a ",s.jsx(wh,{id:"code_reviewer",agents:b})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),s.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:s.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function _A({isOpen:e,onClose:t,workdir:n}){const{config:r}=Sb(n),a=ds(v=>v.saveConfig),[o,d]=k.useState(""),[u,c]=k.useState(""),[h,m]=k.useState(!1),[f,g]=k.useState(!1),[x,w]=k.useState(!1);k.useEffect(()=>{e&&(d((r==null?void 0:r.command)??""),c((r==null?void 0:r.url)??""),m((r==null?void 0:r.hotReload)??!1),g((r==null?void 0:r.disableInspect)??!1))},[e,r]);const C=async()=>{!n||!o.trim()||!u.trim()||(w(!0),await a(n,{command:o.trim(),url:u.trim(),hotReload:h,disableInspect:f}),w(!1),t())};return s.jsx(Et,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),s.jsx("input",{className:"input w-full",type:"text",value:o,onChange:v=>d(v.target.value),placeholder:"npm run dev"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),s.jsx("input",{className:"input w-full",type:"text",value:u,onChange:v=>c(v.target.value),placeholder:"http://localhost:3000"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"hotReload",checked:h,onChange:v=>m(v.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"disableInspect",checked:f,onChange:v=>g(v.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn btn-primary",onClick:C,disabled:x||!o.trim()||!u.trim(),children:x?"Saving...":"Save"})]})]})})}const Hk={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"},eV={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"},Uk={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},tV="text-text-primary";function nV(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",o;try{for(;(o=n.exec(e))!==null;){if(o.index>r){const h=e.slice(r,o.index);h&&t.push({text:h,className:a})}const d=o[1];if(!d)continue;const u=d.split(";").map(Number);if(u.length===0||u[0]===0){a="text-text-primary";continue}const c=[];for(const h of u)if(h>=30&&h<=37){const m=Hk[h];m&&c.push(m)}else if(h>=40&&h<=47){const m=eV[h];m&&c.push(m)}else if(h>=90&&h<=97){const m=Hk[h];m&&c.push(m)}else if(h in Uk){const m=Uk[h];m&&c.push(m)}else h===39?c.push(tV):h===49&&(a=a.split(" ").filter(m=>!m.startsWith("bg-")).join(" "));c.length>0&&(a=c.join(" ")),r=n.lastIndex}if(r<e.length){const d=e.slice(r);d&&t.push({text:d,className:a})}return t}catch(d){return console.warn("ANSI parsing failed, stripping codes:",d),[{text:rV(e),className:"text-text-primary"}]}}function rV(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function jf(e){const t=nV(e),n=[];return t.forEach((r,a)=>{const o=r.text.split(`
285
+ `);o.forEach((d,u)=>{n.push(ps.createElement("span",{key:`${a}-${u}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},d)),u<o.length-1&&n.push(ps.createElement("br",{key:`${a}-${u}-br`}))})}),n.length===1?n[0]:n}function SA({logs:e,preRef:t,preClassName:n="text-sm font-mono",scrollAreaRef:r,onScrollbarGesture:a}){return s.jsx(mt,{ref:r,options:{overflow:{x:"scroll",y:"scroll"}},className:n,onScrollbarGesture:a,children:s.jsx("pre",{ref:t,className:"contents",children:e.length===0?s.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((o,d)=>o.type==="marker"?s.jsx(k.Fragment,{children:s.jsx("hr",{className:"border-t border-border my-1"})},d):s.jsx("span",{className:o.stream==="stderr"?"text-accent-warning":"",children:jf(o.content)},d))})})}function Av({isActive:e,onToggle:t,className:n,style:r}){return s.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):s.jsx(gn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const sV=100,iV=6,aV=1500,wA=(e,t)=>e==="down"?!1:t!==null&&t<=iV,Fu=(e,t,n)=>{const r=k.useRef(!0),a=k.useRef(null),o=k.useRef(!1),d=k.useRef(0),u=k.useRef(!1),c=k.useRef(0),[h,m]=k.useState(!0),f=k.useCallback(()=>{if(n)return n();const b=e.current;return b instanceof HTMLElement?b:null},[n,e]),g=k.useCallback(b=>{b||(c.current+=1),r.current=b,m(b)},[]),x=k.useCallback(()=>{g(!1)},[g]),w=k.useCallback(()=>{if(!r.current)return;const b=f();b&&(u.current=!0,b.scrollTop=b.scrollHeight,requestAnimationFrame(()=>{requestAnimationFrame(()=>{u.current=!1})}),d.current=Date.now())},[f]),C=k.useCallback((b,j)=>{b==="down"&&(o.current=!0);const E=wA(b,j);g(E),E&&(d.current=Date.now()),b==="up"&&(o.current=!1)},[g]),v=k.useRef(null);k.useEffect(()=>{if(t!=null&&t.id)return v.current!==null&&(cancelAnimationFrame(v.current),v.current=null),g(!0),d.current=Date.now(),v.current=requestAnimationFrame(()=>{requestAnimationFrame(()=>{w(),v.current=null})}),()=>{v.current!==null&&(cancelAnimationFrame(v.current),v.current=null)}},[t==null?void 0:t.id,g,w]),k.useEffect(()=>{const b=f();if(!b)return;const j=()=>{const P=c.current;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(P!==c.current)return;b.scrollHeight-b.scrollTop-b.offsetHeight<sV&&(d.current=Date.now(),g(!0))})})},E=P=>{if(P.deltaY>0){j();return}x()},N=P=>{P.touches[0]&&(a.current=P.touches[0].clientY)},L=P=>{if(a.current===null)return;const z=P.touches[0];if(!z)return;if(z.clientY-a.current>0){x();return}j()},A=()=>{o.current||u.current||Date.now()-d.current<=aV||g(!1)},D=P=>{if(!(P.ctrlKey||P.metaKey||P.altKey)){if(P.key==="ArrowUp"||P.key==="PageUp"||P.key==="Home"){x();return}(P.key==="ArrowDown"||P.key==="PageDown"||P.key==="End")&&j()}},O=new MutationObserver(()=>{r.current&&requestAnimationFrame(w)}),F=setInterval(()=>{r.current&&w()},1e3);return b.addEventListener("wheel",E,{passive:!0}),b.addEventListener("touchstart",N,{passive:!0}),b.addEventListener("touchmove",L,{passive:!0}),b.addEventListener("scroll",A,{passive:!0}),b.addEventListener("keydown",D),b.tabIndex=-1,O.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("wheel",E),b.removeEventListener("touchstart",N),b.removeEventListener("touchmove",L),b.removeEventListener("scroll",A),b.removeEventListener("keydown",D),O.disconnect(),clearInterval(F)}},[t==null?void 0:t.id,f,w,g,x]);const S=k.useCallback(()=>{g(!0),w()},[g,w]),_=k.useCallback(b=>{g(b),b&&w()},[g,w]);return{force_scroll_to_bottom:S,isAutoScrollActive:h,setAutoScroll:_,handleScrollbarGesture:C}},zu=e=>k.useCallback(()=>{var t,n;return((n=(t=e.current)==null?void 0:t.osInstance())==null?void 0:n.elements().viewport)??null},[e]),Lv=k.memo(function({title:t,subtitle:n,logs:r,onClose:a,onClear:o,onInsertMarker:d,preClassName:u}){const c=k.useRef(null),h=zu(c),{isAutoScrollActive:m,setAutoScroll:f,handleScrollbarGesture:g}=Fu(c,null,h);return s.jsxs(Et,{isOpen:!0,onClose:a,title:t,size:"full",scrollable:!1,headerRight:s.jsx(Av,{isActive:m,onToggle:f,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),footer:s.jsxs("div",{className:"flex items-center gap-2",children:[d&&s.jsxs("button",{onClick:d,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Insert marker",children:[s.jsx(Fr,{className:"w-3.5 h-3.5"}),"Marker"]}),o&&s.jsxs("button",{onClick:o,className:"text-xs text-text-muted hover:text-accent-error flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Clear logs",children:[s.jsx(Ci,{className:"w-3.5 h-3.5"}),"Clear"]})]}),children:[n&&s.jsxs("div",{className:"subtitle-strip flex items-start gap-2 px-2 py-1.5 mb-2 bg-bg-tertiary rounded text-[11px] font-mono text-text-secondary whitespace-pre-wrap break-all border border-border",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0 select-none",children:"Command:"}),s.jsx("span",{children:n})]}),s.jsx(mt,{ref:c,className:"flex-1 -m-4 p-4",onScrollbarGesture:g,children:s.jsx(SA,{logs:r,preClassName:u})})]})}),oV=k.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:o}){const[d,u]=k.useState(null),c=k.useRef(null),h=k.useRef(o);h.current=o;const m=k.useCallback((g,x)=>{o(wA(g,x))},[o]),f=k.useCallback(()=>{var g,x;return((x=(g=c.current)==null?void 0:g.osInstance())==null?void 0:x.elements().viewport)??null},[]);return k.useEffect(()=>{var x;const g=(x=n.current)==null?void 0:x.getBoundingClientRect();g&&u({bottom:window.innerHeight-g.bottom,right:window.innerWidth-g.right,width:g.width,height:g.height})},[n]),k.useEffect(()=>{const g=f();if(!g)return;const x=w=>{if(w.deltaY<0){h.current(!1);return}w.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{g.scrollHeight-g.scrollTop-g.offsetHeight<100&&h.current(!0)}))};return g.addEventListener("wheel",x,{passive:!0}),()=>g.removeEventListener("wheel",x)},[f]),k.useEffect(()=>{const g=f();g&&a&&(g.scrollTop=g.scrollHeight)},[t,a,d,f]),s.jsx("div",{className:`relative ${d?"":"hidden"}`,children:s.jsx(mt,{ref:c,className:"fixed z-40 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border transition-all duration-150 ease-out select-text",onScrollbarGesture:m,style:d?{bottom:d.bottom,right:d.right,width:d.width*2,maxHeight:d.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:s.jsx("pre",{className:"text-sm font-mono",children:t.map((g,x)=>s.jsx("span",{className:g.stream==="stderr"?"text-accent-warning":"",children:jf(g.content)},x))})})})}),CA=k.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const{status:o,config:d,logs:u}=Sb(t),c=ds(I=>I.start),h=ds(I=>I.stop),m=ds(I=>I.fetchLogs),f=ds(I=>I.clearLogs),g=ds(I=>I.insertMarker),x=()=>{t&&window.confirm("Clear all dev server logs?")&&f(t)},[w,C]=k.useState(!1),[v,S]=k.useState(!1),[_,b]=k.useState(!1),[j,E]=k.useState(!1),N=k.useRef(null),L=k.useRef(null),A=k.useCallback(()=>{var I,M;return((M=(I=L.current)==null?void 0:I.osInstance())==null?void 0:M.elements().viewport)??null},[]),{isAutoScrollActive:D,setAutoScroll:O,handleScrollbarGesture:F}=Fu(L,null,A),P=k.useRef(null),z=k.useRef(null),K=k.useRef(null),q=()=>{const I=o==null?void 0:o.inspectProxyPort;if(!I){o!=null&&o.url&&window.open(o.url,"_blank");return}const M=`${window.location.protocol}//${window.location.hostname}:${I}`;window.open(M,"_blank")},W=(o==null?void 0:o.state)??"off",Z=d!==null,Q=W==="running"||W==="warning";k.useEffect(()=>{t&&(ds.getState().fetchStatus(t),ds.getState().fetchConfig(t))},[t]),k.useEffect(()=>{Q&&t&&m(t)},[Q,m,t]);const H=()=>{t&&(Q?h(t):c(t))};return s.jsxs("div",{className:`space-y-3 ${n?"":"mt-2 pt-3 border-t border-border"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${W==="running"?"bg-accent-success":W==="warning"?"bg-accent-warning":W==="error"?"bg-accent-error":"bg-text-muted"}`}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),s.jsx("button",{onClick:()=>{a?a():C(!0)},className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:s.jsx(OE,{})})]}),Z?s.jsx(s.Fragment,{children:W==="running"||W==="warning"?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:H,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:[s.jsx(Tb,{}),"Stop"]}),(o==null?void 0:o.url)&&s.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:o.url,children:[s.jsx(Nb,{}),"Open"]})]}):s.jsx("button",{onClick:H,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"})}):s.jsx("button",{onClick:()=>{a?a():C(!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"}),s.jsxs("div",{ref:K,className:`relative ${Z&&Q?"":"hidden"}`,onMouseEnter:()=>{!Z||!Q||n||(z.current&&clearTimeout(z.current),P.current=setTimeout(()=>{b(!0),E(!1)},500))},onMouseLeave:()=>{P.current&&clearTimeout(P.current),E(!0),z.current=setTimeout(()=>b(!1),150)},children:[s.jsx(SA,{logs:u,preRef:N,preClassName:"text-sm bg-bg-primary p-2 rounded max-h-[200px] border border-border",scrollAreaRef:L,onScrollbarGesture:F}),Z&&Q&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[!n&&(_||j)&&s.jsx(Av,{isActive:D,onToggle:O,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),s.jsx("button",{onClick:()=>n?r==null?void 0:r():S(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),!n&&(_||j)&&K.current&&Cs.createPortal(s.jsx(oV,{logs:u,anchorRef:K,isHiding:j,isAutoScrollActive:D,onSetAutoScroll:O}),document.body)]})]}),!a&&s.jsx(_A,{isOpen:w,onClose:()=>C(!1),workdir:t}),v&&s.jsx(Lv,{title:"Dev Server Logs",logs:u,onClose:()=>S(!1),onClear:x,onInsertMarker:()=>{t&&g(t)}})]})}),lV=k.memo(function({sessionId:t}){const n=nu(x=>x.processes),r=nu(x=>x.stopProcess),[a,o]=k.useState(null),[d,u]=k.useState([]),c=n.filter(x=>x.status!=="exited"),h=c.filter(x=>x.status==="running").length;if(n.length===0)return null;const m=x=>{switch(x){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"}},f=x=>{const w=nu.getState().logs[x]??[];u(w.map(C=>({content:C.content,stream:C.stream}))),o(x)},g=x=>{t&&r(x,t)};return s.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),s.jsx("div",{className:"space-y-2",children:c.map(x=>s.jsx("div",{className:"border border-border rounded p-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${m(x.status)}`}),s.jsx("span",{className:"text-sm text-text-primary truncate",title:x.name,children:x.name}),s.jsxs("span",{className:"text-xs text-text-muted",children:["[",x.status,"]"]})]}),s.jsxs("div",{className:"flex gap-1 ml-2",children:[s.jsx("button",{onClick:()=>f(x.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"}),s.jsx("button",{onClick:()=>g(x.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"})]})]})},x.id))}),a&&(()=>{const x=c.find(w=>w.id===a);return s.jsx(Lv,{title:(x==null?void 0:x.name)??"",subtitle:x==null?void 0:x.command,logs:d,onClose:()=>{o(null),u([])}})})()]})});function kA(){return an.getState().platform??null}function jA(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function EA(e,t,n){const r=kA(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,o=jA(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${o}`}:${t??1}`;const d=`vscode://file/${o}`;return t?`${d}:${t}`:d}function cV(e){const t=kA(),n=jA(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function uV({file:e,showEditorLink:t,workdir:n}){const r=Ob(e.path,28),a=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",o=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"",d=t&&n?EA(e.path,void 0,n):void 0,u=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),o&&s.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:o})]});return d?s.jsx("a",{href:d,className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0 hover:bg-bg-tertiary rounded px-1 transition-colors no-underline",title:`Open ${e.path} in VSCode`,children:u}):s.jsx("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:u})}function dV(){const{diff:e}=Nv(),t=Bt(a=>a.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",{currentSession:n}=Ul(),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?s.jsx("div",{className:"mt-3",children:s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[s.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),s.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?s.jsx("div",{className:"mt-3",children:s.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):s.jsx(mt,{className:"mt-3 max-h-[150px]",children:s.jsx("div",{className:"pr-1",children:e.files.map((a,o)=>s.jsx(uV,{file:a,showEditorLink:t,workdir:r},o))})})}function NA(e){const[t,n]=k.useState(!1),[r,a]=k.useState(null),[o,d]=k.useState(!1),[u,c]=k.useState(""),h=k.useCallback(()=>{t||e()},[t,e]),m=u.trim().length>0&&!t,f=k.useCallback(()=>{a(null),n(!1),c(""),d(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:o,setLoading:d,newName:u,setNewName:c,handleClose:h,canCreate:m,resetState:f}}function TA({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:o}){const d=s.jsx("div",{className:"flex gap-2 justify-end",children:s.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Cancel"})});return s.jsx(Et,{isOpen:e,onClose:t,title:n,size:"md",footer:d,children:a||r?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ma,{})}):o})}function AA({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:o,onCreate:d,canCreate:u,busy:c}){return s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:t}),s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded border border-border bg-bg-primary focus-within:border-accent-primary mb-3",children:[s.jsx("span",{className:"w-4 h-4 shrink-0 text-text-muted flex items-center",children:e}),s.jsx("input",{type:"text",value:a,onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Enter"&&u&&d()},placeholder:n,className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),s.jsx("button",{onClick:d,disabled:!u||c,className:"w-full px-4 py-2 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-50",children:r})]})}function LA({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:o}){const d=Le(z=>z.loadSession),{busy:u,setBusy:c,error:h,setError:m,loading:f,setLoading:g,newName:x,setNewName:w,handleClose:C,canCreate:v,resetState:S}=NA(t),[_,b]=k.useState([]),[j,E]=k.useState(null),[N,L]=k.useState(null),[A,D]=k.useState(!1);k.useEffect(()=>{e&&(S(),E(null),L(null),D(!1),ye(`/api/projects/${n}/workspaces`).then(z=>z.json()).then(z=>{b(z.workspaces),g(!1)}).catch(()=>{b([]),g(!1)}))},[e,n,S,g]);const O=k.useCallback(async z=>{m(null),c(!0);try{const K=await ye(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:z})});if(!K.ok){const q=await K.json().catch(()=>({error:"Failed to switch workspace"}));m(q.error),c(!1);return}await d(r,!0),t()}catch(K){m(K instanceof Error?K.message:"Failed to switch workspace"),c(!1)}},[r,d,t,m,c]),F=k.useCallback(async(z,K)=>{m(null),L(null),D((K==null?void 0:K.force)===!0),c(!0);try{const q=await ye(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:z,force:(K==null?void 0:K.force)===!0})});if(!q.ok){const Q=await q.json().catch(()=>({error:"Failed to delete workspace"}));m(Q.error),Q.conflictingSessionIds&&L(Q.conflictingSessionIds),D(!1),c(!1);return}E(null),D(!1),await d(r,!0);const Z=await(await ye(`/api/projects/${n}/workspaces`)).json();b(Z.workspaces),c(!1),g(!1)}catch(q){m(q instanceof Error?q.message:"Failed to delete workspace"),D(!1),c(!1)}},[r,n,d,m,c]),P=k.useCallback(async()=>{m(null),c(!0);try{const z=await ye(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:x.trim()})});if(!z.ok){const K=await z.json().catch(()=>({error:"Failed to create workspace"}));m(K.error),c(!1);return}await d(r),t()}catch(z){m(z instanceof Error?z.message:"Failed to create workspace"),c(!1)}},[x,r,d,t,m,c]);return s.jsx(TA,{isOpen:e,onClose:C,title:"Switch Workspace",busy:u,loading:f,children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),s.jsxs(mt,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[s.jsxs("button",{onClick:()=>O("original"),disabled:u,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${a?"hover:bg-bg-tertiary text-text-secondary":"bg-accent-primary/10 text-accent-primary cursor-default"}`,children:[s.jsx(wr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:"original"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:o??"unknown"}),!a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),_.slice().sort((z,K)=>z.name===a?-1:K.name===a?1:z.name.localeCompare(K.name)).map(z=>s.jsx("div",{className:"group relative",children:j===z.name?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[s.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",z.name,"?"]}),s.jsx("button",{onClick:()=>F(z.name),disabled:u,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),s.jsx("button",{onClick:()=>E(null),disabled:u,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>{!u&&z.name!==a&&O(z.name)},disabled:u||z.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${z.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${u?"opacity-70":""}`,children:[s.jsx(wr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:z.name}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:z.branch??"unknown"}),z.name===a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),z.name!==a&&!u&&s.jsx("button",{onClick:K=>{K.stopPropagation(),m(null),L(null),E(z.name)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 text-xs text-text-muted hover:text-accent-error transition-opacity px-1 py-0.5 rounded",title:"Delete workspace",children:"✕"})]})},z.path))]}),s.jsx(AA,{icon:s.jsx(wr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:x,onChange:w,onCreate:P,canCreate:v,busy:u}),h&&s.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[s.jsx("p",{className:"text-accent-error",children:h}),N&&N.length>0&&s.jsxs("div",{className:"mt-2 space-y-1",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),s.jsx("ul",{className:"space-y-0.5",children:N.map(z=>s.jsx("li",{children:s.jsx(er,{href:`/p/${n}/s/${z}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:z})},z))}),s.jsx("button",{onClick:()=>F(j??"",{force:!0}),disabled:u||!j,className:"mt-2 text-xs px-2 py-1 rounded bg-accent-warning text-black hover:opacity-90 disabled:opacity-50","aria-label":"Force delete workspace, switching other sessions to original",children:A?"Processing...":"Force Delete (switch other sessions to original)"})]})]})]})})}function RA({isOpen:e,onClose:t,sessionId:n}){const r=Le(L=>L.loadSession),{busy:a,setBusy:o,error:d,setError:u,loading:c,setLoading:h,newName:m,setNewName:f,handleClose:g,canCreate:x,resetState:w}=NA(t),[C,v]=k.useState([]),[S,_]=k.useState(""),[b,j]=k.useState("");k.useEffect(()=>{e&&(w(),_(""),v([]),j(""),ye(`/api/sessions/${n}/branches`).then(L=>L.json()).then(L=>{v(L.branches),j(L.defaultBranch??""),h(!1)}).catch(()=>{v([]),h(!1)}))},[e,n,w,h]);const E=k.useCallback(async L=>{u(null),o(!0);try{const A=await ye(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:L})});if(!A.ok){const D=await A.json().catch(()=>({error:"Failed to switch branch"}));u(D.error),o(!1);return}await r(n,!0),t()}catch(A){u(A instanceof Error?A.message:"Failed to switch branch"),o(!1)}},[n,r,t,u,o]),N=k.useCallback(async()=>{u(null),o(!0);try{const L={name:m.trim()};S&&(L.sourceBranch=S);const A=await ye(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});if(!A.ok){const D=await A.json().catch(()=>({error:"Failed to create branch"}));u(D.error),o(!1);return}await r(n),t()}catch(L){u(L instanceof Error?L.message:"Failed to create branch"),o(!1)}},[m,S,n,r,t,u,o]);return s.jsx(TA,{isOpen:e,onClose:g,title:"Switch Branch",busy:a,loading:c,children:s.jsxs("div",{children:[C.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Branches"}),s.jsx(mt,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(L=>s.jsxs("button",{onClick:()=>{L.current||E(L.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${L.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[s.jsx(to,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:L.name}),L.current&&s.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!L.current&&s.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},L.name))})]}),s.jsx(AA,{icon:s.jsx(to,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:m,onChange:f,onCreate:N,canCreate:x,busy:a}),m.trim()&&s.jsxs("div",{className:"mt-2",children:[s.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",b||"project default",")"]}),s.jsxs("div",{className:"relative",children:[s.jsx(to,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{type:"text",value:S,onChange:L=>_(L.target.value),placeholder:b||"main",className:"w-full text-sm bg-bg-primary border border-border-default rounded pl-8 pr-2 py-1.5 text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),d&&s.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:d})]})})}function DA({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:o,onEditWorkspace:d,onEditBranch:u}){const[c,h]=k.useState(!1),[m,f]=k.useState(!1);return t===null?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r&&n?s.jsxs("a",{href:cV(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[s.jsx(wr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary group-hover:text-accent-primary transition-colors",children:e})]}):s.jsxs(s.Fragment,{children:[s.jsx(wr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary",children:e})]}),s.jsx("button",{onClick:()=>{d?d():h(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]}),s.jsx("div",{className:"h-px bg-border"}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(to,{}),s.jsx("span",{className:"truncate text-text-secondary",children:t}),s.jsx("button",{onClick:()=>{u?u():f(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]})]}),s.jsx(dV,{}),!d&&s.jsx(LA,{isOpen:c,onClose:()=>h(!1),projectId:o,sessionId:a,currentWorkspace:e,currentBranch:t}),!u&&s.jsx(RA,{isOpen:m,onClose:()=>f(!1),sessionId:a})]})}function hV(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function fV(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function Rv({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",o=n==="sm"?"h-1":"h-1.5";return s.jsx("div",{className:`${o} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:s.jsx("div",{className:`h-full transition-all duration-300 ${fV(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function mV({dangerZone:e,size:t="md"}){return e?s.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function pV({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return s.jsx(n,{className:"language-",children:s.jsx("code",{className:"language-",children:e})})}const Rl=k.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:o=1}){const{showSyntaxHighlighting:d}=Hs(),[u,c]=k.useState(null),h=RT(),m=k.useRef(t);if(k.useEffect(()=>{d&&(m.current=t,LT(t,n,h).then(g=>{m.current===t&&c(g)}))},[t,n,h,d]),!d||!u)return s.jsx(pV,{code:t,variant:r});if(r==="inline")return s.jsx("span",{dangerouslySetInnerHTML:{__html:u}});const f=a?"":"shiki-plain";return s.jsx("div",{className:f,style:{"--shiki-start":o},dangerouslySetInnerHTML:{__html:u}})});function OA({src:e,alt:t,isOpen:n,onClose:r}){return n?s.jsx(Et,{isOpen:n,onClose:r,title:"",size:"full",children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const Ef=k.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",a=t==="removed"?"line-through decoration-red-400/30":"";return s.jsx("div",{className:`border-l-[3px] ${r}`,children:s.jsx("div",{className:`min-w-0 py-3 ${a}`,children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),gV=k.memo(function({oldString:t,newString:n,filePath:r}){const a=k.useMemo(()=>vm(r),[r]),o=t.length>0,d=n.length>0;return!o&&!d?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[o&&s.jsx(Ef,{type:"removed",children:s.jsx(Rl,{code:t,language:a,variant:"block",showLineNumbers:!0})}),d&&s.jsx(Ef,{type:"added",children:s.jsx(Rl,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),xV=k.memo(function({content:t,filePath:n}){const r=k.useMemo(()=>vm(n),[n]);return s.jsx(mn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(Ef,{type:"added",children:s.jsx(Rl,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),yV=k.memo(function({regions:t,filePath:n}){const r=k.useMemo(()=>vm(n),[n]);return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsx("div",{className:"space-y-2",children:t.map((a,o)=>s.jsx(vV,{region:a,language:r},o))})});function bV(e){const t=[];function n(r,a,o){const d=t[t.length-1];d&&d.type===r&&d.startLine+d.lines.length===a?d.lines.push(o):t.push({type:r,startLine:a,lines:[o]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const a=r.oldContent.split(`
286
+ `);for(let d=0;d<a.length;d++)n("removed",r.startLine+d,a[d]);const o=r.newContent.split(`
287
+ `);for(let d=0;d<o.length;d++)n("added",r.startLine+d,o[d])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const vV=k.memo(function({region:t,language:n}){const r=bV(t);return s.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,o)=>s.jsx(_V,{section:a,language:n},o))})}),_V=k.memo(function({section:t,language:n}){const r=t.lines.join(`
288
+ `);return t.type==="context"?s.jsx("div",{children:s.jsx("div",{className:"min-w-0 py-3",children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:s.jsx(Rl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):s.jsx(Ef,{type:t.type,children:s.jsx(Rl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function Vk(e){return e.split(`
289
+ `).filter(t=>!t.startsWith(`
290
+ [`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
291
+ `)}const SV=k.memo(function({result:t,metadata:n,filePath:r}){const[a,o]=k.useState(!1),d=k.useMemo(()=>vm(r),[r]),u=n==null?void 0:n.mimeType,c=n==null?void 0:n.base64Data;if(u!=null&&u.startsWith("image/")&&c){const w=`data:${u};base64,${c}`;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors",onClick:()=>o(!0),children:s.jsx("img",{src:w,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),s.jsx(OA,{src:w,alt:r,isOpen:a,onClose:()=>o(!1)})]})}if(!t)return s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const h=t;if(d==="markdown"){const w=Vk(h);return s.jsx(mn,{className:"rounded border border-border max-h-[45vh] p-2",children:s.jsx(Zn,{content:w})})}const m=Vk(h),f=h.split(`
292
+ `)[0],g=f==null?void 0:f.match(/^(\d+)\|/),x=g?parseInt(g[1],10):1;return s.jsx(mn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(Rl,{code:m,language:d,variant:"block",showLineNumbers:!0,startLine:x})})});function wV({type:e,content:t}){const n=e==="added"?"diff-added-bg":e==="removed"?"diff-removed-bg":"bg-transparent",r=e==="added"?"+":e==="removed"?"-":" ";return s.jsxs("div",{className:`${n} px-2`,children:[s.jsx("span",{className:"select-none text-text-muted w-6 inline-block",children:r}),s.jsx("span",{className:"whitespace-pre-wrap break-words",children:t||" "})]})}function CV({diff:e}){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!r||r.type==="unchanged"){n++;continue}if(r.type==="removed"){for(;n<e.length;){const a=e[n];if(!a||a.type!=="removed")break;t.push({type:"removed",content:a.content}),n++}for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}else if(r.type==="added")for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}return t.length===0?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"No changes detected."}):s.jsxs("div",{children:[s.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Changes:"}),s.jsx("div",{className:"font-mono text-xs leading-5",children:t.map((r,a)=>s.jsx(wV,{type:r.type,content:r.content},a))})]})}function Dv({isOpen:e,onClose:t,isRunning:n,onApply:r}){const a=jr(),[o,d]=k.useState(null),[u,c]=k.useState(!1),h=k.useRef(null),m=k.useCallback(()=>{c(!0);const f=zt.send("context.applyDynamic.preview",{...a?{sessionId:a}:{}});h.current=f;const g=zt.subscribe(x=>{if(x.id===f&&x.type==="context.preview"){const w=x.payload;d(w.diff??[]),c(!1),h.current=null,g()}});setTimeout(()=>{h.current===f&&(c(!1),h.current=null,g())},5e3)},[]);return k.useEffect(()=>{e&&(d(null),c(!0),m())},[e,m]),s.jsxs(Et,{isOpen:e,onClose:t,title:"Update system prompt",size:"lg",children:[s.jsxs("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.",n&&s.jsxs(s.Fragment,{children:[" ","Since the session is currently running, the update will be queued and applied at the start of the next turn."]})]}),u?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):o&&o.length>0?s.jsx(mt,{className:"max-h-[60vh] border border-border rounded-lg",children:s.jsx(CV,{diff:o})}):s.jsx("p",{className:"text-sm text-text-tertiary mb-4",children:"The system prompt hash has changed (e.g., due to tool or skill changes), but the actual prompt text appears identical. Applying the update will still rebuild the cached prompt to ensure consistency."}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:n?"Queue update":"Update"})]})]})}function MA({variant:e="popover",onUpdateSystemPrompt:t}){const{sessionId:n,contextState:r,currentSession:a}=Ul(),o=Le(A=>A.compactContext),d=mA(),[u,c]=k.useState(!1),[h,m]=k.useState(!1);if(!r||!a)return null;const{currentTokens:f,maxTokens:g,compactionCount:x,dangerZone:w,dynamicContextChanged:C}=r,v=Math.round(f/g*100),S=a.isRunning,_=()=>{d(S),c(!1)},b=e==="sidebar",j=s.jsxs("span",{className:hV(v,w),children:[Ll(f)," / ",Ll(g)," (",v,"%)"]}),E=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Rv,{percent:v,dangerZone:w,className:"flex-1"}),s.jsx(mV,{dangerZone:w}),x>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),N=s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>m(!h),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:s.jsx(ME,{})}),h&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>m(!1)}),s.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:[s.jsx("button",{onClick:()=>{!S&&n&&o(n),m(!1)},disabled:S,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:S?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:w?"text-accent-error":"",children:"Compact"})}),C&&s.jsx("button",{onClick:()=>{m(!1),t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]}),L=t?null:s.jsx(Dv,{isOpen:u,onClose:()=>c(!1),isRunning:S,onApply:_});return b?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[s.jsx("div",{className:"text-sm",children:j}),E]}),s.jsx("div",{className:"shrink-0 pt-0.5",children:N})]}),L]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("div",{className:"flex items-center justify-between text-sm",children:j}),E]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("button",{onClick:()=>{!S&&n&&o(n)},disabled:S,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 rounded",title:S?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:w?"text-accent-error":"",children:"Compact"})}),C&&s.jsx("button",{onClick:()=>{t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors rounded",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]}),L]})}function Wk({messages:e,workdir:t}){var _,b,j;const[n,r]=k.useState(!1),[a,o]=k.useState(!1),[d,u]=k.useState(null),c=A9(e),{branch:h}=Nv(),m=an(E=>E.version),{currentSession:f}=Ul(),g=Lu((f==null?void 0:f.workspace)??"")||null,x=Bt(E=>E.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",w=Si(E=>E.status),C=Si(E=>E.check),[v,S]=k.useState(!1);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(MA,{variant:"sidebar"}),c&&s.jsxs("div",{className:"mb-4",children:[s.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:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"text-text-secondary",children:Bs(c.aiTime)}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:Ik(c.avgPrefillSpeed)}),s.jsx("span",{children:"pp"}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:Ik(c.avgGenerationSpeed)}),s.jsx("span",{children:"tg"})]})}),s.jsx(H9,{isOpen:n,onClose:()=>r(!1),stats:c})]}),s.jsx(mt,{className:"flex flex-col flex-1 px-4 -mx-4 pb-4",children:s.jsxs("div",{children:[s.jsx("button",{onClick:()=>u("criteria"),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(kf,{entries:((_=f==null?void 0:f.metadataEntries)==null?void 0:_.criteria)??[],title:"Acceptance Criteria"})}),f&&s.jsx(vA,{entries:((b=f==null?void 0:f.metadataEntries)==null?void 0:b.criteria)??[],sessionId:f.id}),f&&(()=>{const E=["review_findings","todos"],N=f.metadataEntries??{},L=E.filter(D=>D in N),A=Object.keys(N).filter(D=>D!=="criteria"&&!E.includes(D)).sort();return[...L,...A].filter(D=>{var O;return(((O=N[D])==null?void 0:O.length)??0)>0}).map(D=>s.jsxs("div",{className:"mt-6",children:[s.jsx("button",{onClick:()=>u(D),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(kf,{entries:N[D],title:Sl(D)})}),s.jsx(yA,{entries:N[D],onClearAll:async()=>{try{await ye(`/api/sessions/${f.id}/metadata/${D}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(O){console.error(`Failed to clear ${D}:`,O)}}})]},D))})()]})}),s.jsx(DA,{workspaceName:g??"original",branch:h,workdir:t,showEditorLink:x,sessionId:(f==null?void 0:f.id)??"",projectId:(f==null?void 0:f.projectId)??""}),s.jsx(CA,{workdir:t}),s.jsx(lV,{sessionId:f==null?void 0:f.id}),m&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[s.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",s.jsxs("span",{className:"font-mono",children:["v",m]}),s.jsx("button",{onClick:()=>{S(!0),C(!0)},disabled:w==="checking",className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:s.jsx(Yf,{className:`w-3 h-3 ${w==="checking"?"animate-spin":""}`})})]}),w==="available"&&s.jsx("button",{onClick:()=>o(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),v&&w==="upToDate"&&s.jsx("div",{className:"mt-1",children:"Up to date"}),w==="error"&&s.jsx("div",{className:"mt-1",children:"Update check failed"})]}),s.jsx(eN,{isOpen:a,onClose:()=>o(!1),versionInfo:null}),s.jsx(bA,{isOpen:d!==null,onClose:()=>u(null),entries:((j=f==null?void 0:f.metadataEntries)==null?void 0:j[d??""])??[],sessionId:(f==null?void 0:f.id)??"",metadataKey:d??"",title:Sl(d??"")})]})}function kV({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r,sessionId:a}){const o=on(a,c=>c.session??null,c=>c.currentSession,null),{width:d,handleMouseDown:u}=cA({initialWidth:320,minWidth:240,maxWidth:600,direction:"right"});return s.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&s.jsx("div",{className:"absolute @md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),s.jsxs("div",{className:"flex h-full",children:[s.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?s.jsxs("aside",{className:"hidden @md:block shrink-0 border-l border-border bg-secondary relative",style:{width:d},children:[s.jsx(uA,{side:"left",onMouseDown:u}),s.jsx(mt,{className:"h-full p-4",children:s.jsx(Wk,{messages:r,workdir:(o==null?void 0:o.workspace)??(o==null?void 0:o.workdir)})})]}):s.jsx("aside",{className:"hidden @md:block w-0 shrink-0 overflow-hidden border-l-0"}),s.jsx("aside",{className:`
293
+ @md:hidden
294
+ bg-secondary
295
+ transition-all duration-300 ease-in-out
296
+ absolute right-0 top-0 h-full z-50
297
+ ${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
298
+ `,children:s.jsx("div",{className:"h-full p-4",children:s.jsx(mt,{className:"h-full",children:s.jsx(Wk,{messages:r,workdir:(o==null?void 0:o.workspace)??(o==null?void 0:o.workdir)})})})})]})]})}function jV(){const{sessionId:e,contextState:t,currentSession:n}=Ul(),r=Le(C=>C.pendingUpdate),a=Le(C=>C.triggerPendingUpdate),o=mA(),[d,u]=k.useState(!1),[c,h]=k.useState(!1),m=k.useRef(!1),f=k.useRef(!1);if(k.useEffect(()=>{t!=null&&t.dynamicContextChanged&&!m.current&&u(!1),m.current=(t==null?void 0:t.dynamicContextChanged)??!1},[t==null?void 0:t.dynamicContextChanged]),k.useEffect(()=>{const C=(n==null?void 0:n.isRunning)??!1;f.current&&!C&&r&&r===e&&a(),f.current=C},[n==null?void 0:n.isRunning,r,e,a]),!t||!n)return null;const{dynamicContextChanged:g}=t,x=n.isRunning,w=()=>{o(x),u(!0),h(!1)};return s.jsxs(s.Fragment,{children:[g&&!d&&s.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[s.jsx("span",{children:"System prompt has changed —"}),s.jsx("button",{onClick:()=>h(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),s.jsx("button",{onClick:()=>u(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:s.jsx(ws,{})})]})}),s.jsx(Dv,{isOpen:c,onClose:()=>h(!1),isRunning:x,onApply:w})]})}function EV({stats:e,onClose:t}){var u;const n=ft(c=>c.defaults),r=ft(c=>c.userItems),o=[...n,...r].find(c=>c.id===e.mode),d=(o==null?void 0:o.name)??e.mode;return s.jsx(Et,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",d]})}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[s.jsx(Ch,{label:"Total Time",value:Bs(e.totalTime)}),s.jsx(Ch,{label:"Prefill",value:Gk(e.prefillTokens)}),s.jsx(Ch,{label:"Generated",value:Gk(e.generationTokens)}),s.jsx(Ch,{label:"LLM Calls",value:String(((u=e.llmCalls)==null?void 0:u.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((c,h)=>s.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",h+1]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[c.ttft.toFixed(2),"s TTFT · ",c.completionTime.toFixed(2),"s gen"]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",s.jsxs("span",{className:"text-text-primary",children:[c.promptTokens," → ",c.completionTokens]})]}),s.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[c.temperature!==void 0&&s.jsx(kh,{label:"temp",value:c.temperature.toFixed(2)}),c.topP!==void 0&&s.jsx(kh,{label:"topP",value:c.topP.toFixed(2)}),c.topK!==void 0&&s.jsx(kh,{label:"topK",value:String(c.topK)}),c.maxTokens!==void 0&&s.jsx(kh,{label:"maxTok",value:String(c.maxTokens)})]})]})]},h))]})]})})}function Gk(e){return typeof e!="number"||!Number.isFinite(e)?"—":e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ch({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-xs text-text-muted",children:e}),s.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function kh({label:e,value:t}){return s.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const NV=k.memo(function({content:t,variant:n="default"}){return n==="labeled"?s.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[s.jsx("span",{className:"text-text-thinking",children:"thinking:"}),s.jsx(mn,{horizontal:!0,className:"ml-1.5 mt-0.5",children:s.jsx(Zn,{content:t})})]}):s.jsx(mn,{horizontal:!0,className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:s.jsx(Zn,{content:t,muted:!0})})});function IA({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e==="workspace"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 TV={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"}},qk=k.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(o=>o.severity==="error"),r=t.filter(o=>o.severity==="warning"),a=t.filter(o=>o.severity==="info"||o.severity==="hint");return s.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[s.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[s.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&s.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&s.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&s.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),s.jsx(mn,{className:"max-h-48",children:t.map((o,d)=>{const u=TV[o.severity];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${u.bg} border-b border-border last:border-b-0`,children:[s.jsx("span",{className:`${u.color} text-xs flex-shrink-0 w-4 text-center`,children:u.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",o.range.start.line+1,":",o.range.start.character+1]}),o.code&&s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",o.code,"]"]})]}),s.jsx("div",{className:"text-xs text-text-primary break-words",children:o.message})]})]},d)})})]})}),AV=k.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:o,result:d,error:u,durationMs:c}){const h=k.useRef(null),[m,f]=k.useState(0),g=zu(h),{setAutoScroll:x,force_scroll_to_bottom:w,handleScrollbarGesture:C}=Fu(h,null,g);k.useEffect(()=>{o==="pending"?x(!0):(w(),x(!1))},[o,x,w]),k.useEffect(()=>{if(o!=="pending"||!r)return;const b=setInterval(()=>{f(Date.now()-r)},100);return()=>clearInterval(b)},[o,r]);const v=n/1e3,S=o==="pending"?m/1e3:(c??0)/1e3,_=o==="pending"?(a==null?void 0:a.map(b=>b.content).join(""))??"":d??"";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),s.jsx("code",{className:"text-text-primary break-all",children:t})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[o==="pending"&&s.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),o==="interrupted"&&s.jsx("span",{className:"text-red-400",children:"interrupted"}),s.jsxs("span",{className:o==="pending"?"text-text-secondary":"text-text-muted",children:[S.toFixed(1),"s / ",v,"s"]})]})]}),o==="pending"&&s.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,m/n*100)}%`}})}),(_||o==="pending")&&s.jsx(mt,{ref:h,onScrollbarGesture:C,className:`text-xs bg-bg-primary p-2 rounded max-h-64 ${o==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:o==="pending"&&a?a.map((b,j)=>s.jsx("span",{className:b.stream==="stderr"?"text-accent-warning":"",children:jf(b.content)},j)):jf(_)}),o==="error"&&u&&s.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})}),Kc=k.memo(function({className:t=""}){return s.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})});function PA(e,t){try{return{success:!0,parsed:JSON.parse(e)}}catch{return console.warn(`${t}: failed to parse result JSON`,e.slice(0,200)),{success:!1,error:s.jsx(mt,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}}}const LV=k.memo(function({result:t,action:n}){const r=PA(t,"DevServerView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?RV(a):DV(a)});function RV(e){if(!e.logs)return s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
299
+ `);return s.jsxs("div",{className:"space-y-2",children:[s.jsx(mn,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((n,r)=>{const a=n.startsWith("[stderr] ");return s.jsx("div",{className:a?"text-accent-warning":"",children:a?n.slice(9):n},r)})}),e.hasMore&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function DV(e){const t=String(e.state??""),n=String(e.url??""),r=e.error?String(e.error):void 0,a=t==="running"?"text-accent-success":t==="stopped"?"text-text-muted":t==="error"?"text-accent-error":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"State:"}),s.jsx("span",{className:`font-medium ${a}`,children:t})]}),n&&n!=="undefined"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"URL:"}),s.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&s.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const OV=k.memo(function({result:t,action:n}){const r=PA(t,"BackgroundProcessView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?MV(a):n==="list"?IV(a):n==="status"?PV(a):n==="start"||n==="stop"?BV(a):s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})]})});function MV(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(mn,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((a,o)=>s.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},o))}),n&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function IV(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):s.jsxs("div",{className:"space-y-2",children:[t.map(a=>s.jsx(BA,{process:a},a.id)),n!=null&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function PV(e){const t=e.process,n=e.uptime;return t?s.jsxs("div",{className:"space-y-2",children:[s.jsx(BA,{process:t}),n!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",$V(n)]})]}):s.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function BV(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,o=a==="running"?"text-accent-success":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[n&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Name:"}),s.jsx("span",{className:"font-medium",children:n})]}),t&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"ID:"}),s.jsx("span",{className:"font-mono",children:t})]}),r!=null&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"PID:"}),s.jsx("span",{className:"font-mono",children:r})]}),a&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Status:"}),s.jsx("span",{className:`font-medium ${o}`,children:a})]})]})}function BA({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return s.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&s.jsxs("div",{className:"text-text-muted",children:["PID: ",s.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&s.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function $V(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m`:n>0?`${n}m ${t%60}s`:`${t}s`}const FV=k.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}switch(n){case"list":return zV(r);case"switch":case"delete":return HV(r);default:return s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}});function zV(e){const t=e.workspaces??[];return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No workspaces found"}):s.jsxs("div",{className:"space-y-1 text-xs",children:[s.jsx("div",{className:"text-text-muted mb-1",children:"Workspaces:"}),t.map(n=>s.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[s.jsx("span",{className:n.active?"text-accent-success":"text-text-muted",children:n.active?"●":"○"}),s.jsx("span",{className:n.active?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.branch&&s.jsxs("span",{className:"text-text-muted",children:["· ",n.branch]}),n.active&&s.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function zx({label:e,value:t,mono:n}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]}),s.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function HV(e){return s.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&s.jsx("div",{className:"text-text-primary",children:e.message}),e.workspace&&s.jsx(zx,{label:"Name",value:e.workspace,mono:!0}),e.path&&s.jsx(zx,{label:"Path",value:e.path,mono:!0}),e.branch&&s.jsx(zx,{label:"Branch",value:e.branch,mono:!0})]})}const UV={todo:{label:"To Do",className:"bg-accent-warning/10 text-accent-warning border-accent-warning/30"},in_progress:{label:"In Progress",className:"bg-accent-primary/10 text-accent-primary border-accent-primary/30"},done:{label:"Done",className:"bg-accent-success/10 text-accent-success border-accent-success/30"}},VV=new Set(["get","create","edit","move","set_gate_value","duplicate","reorder"]),WV=k.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(Hx,{result:t})}if(n==="list")return s.jsx(mn,{className:"max-h-[60vh]",children:s.jsx(GV,{data:r})});if(n==="set_gates"){const a=r.gates;return s.jsx(mn,{className:"max-h-[60vh]",children:s.jsx(qV,{gates:Array.isArray(a)?a:[]})})}if(n==="delete"){const a=r.message;return typeof a=="string"&&a.trim()!==""?s.jsx("div",{className:"text-xs text-text-primary",children:a}):s.jsx(Hx,{result:t})}return VV.has(n)?s.jsx(mn,{className:"max-h-[60vh]",children:s.jsx($A,{task:zA(r)})}):s.jsx(Hx,{result:t})});function Hx({result:e}){return s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}function GV({data:e}){const t=(e.tasks??[]).map(zA),n=e.gates??[],r=t.filter(u=>u.status==="todo"),a=t.filter(u=>u.status==="in_progress"),o=t.filter(u=>u.status==="done"),d=t.filter(u=>u.status!=="todo"&&u.status!=="in_progress"&&u.status!=="done");return s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-text-muted",children:["Task board · ",t.length," task",t.length===1?"":"s",n.length>0&&s.jsxs("span",{children:[" — Gates: ",n.map(u=>`${u.name} (${u.required?"required":"optional"})`).join(", ")]})]}),t.length===0?s.jsx("div",{className:"text-text-muted italic",children:"No tasks on the board"}):s.jsxs(s.Fragment,{children:[s.jsx(jh,{title:"To Do",tasks:r}),s.jsx(jh,{title:"In Progress",tasks:a}),s.jsx(jh,{title:"Done",tasks:o}),s.jsx(jh,{title:"Other",tasks:d})]})]})}function jh({title:e,tasks:t}){return t.length===0?null:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"text-text-muted",children:[e," · ",t.length]}),t.map(n=>s.jsx($A,{task:n},n.id))]})}function $A({task:e}){const t=UV[e.status]??{label:e.status,className:"bg-bg-tertiary text-text-secondary border-border"};return s.jsxs("div",{className:"rounded-md border border-border bg-bg-tertiary px-2.5 py-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:`inline-flex items-center rounded border px-1.5 py-0.5 text-[10px] font-medium ${t.className}`,children:t.label}),e.runState==="running"&&s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-success",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success animate-pulse"}),"Running"]}),e.runState==="queued"&&s.jsxs("span",{className:"inline-flex items-center rounded border border-accent-warning/40 bg-accent-warning/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-warning",children:["Queued · #",e.queuePosition??1]})]}),s.jsx("p",{className:"mt-1 text-sm text-text-primary leading-snug break-words whitespace-pre-wrap line-clamp-3",children:e.prompt}),s.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-text-muted",children:[e.boundSession&&s.jsxs("span",{children:["Bound: ",e.boundSession]}),e.model&&s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-secondary border border-border",children:e.model}),e.attachments!==void 0&&e.attachments>0&&s.jsxs("span",{children:[e.attachments," attachment",e.attachments===1?"":"s"]}),e.gates.map(n=>s.jsxs("span",{className:"font-mono px-1.5 py-0.5 rounded border border-border bg-bg-secondary",children:[n.gateId,": ",n.value]},n.gateId))]})]})}function qV({gates:e}){return s.jsxs("div",{className:"space-y-1 text-xs",children:[s.jsx("div",{className:"text-text-muted mb-1",children:"Gate configuration"}),e.length===0?s.jsx("div",{className:"text-text-muted italic",children:"No gates configured"}):e.map(t=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"font-mono text-accent-primary shrink-0",children:t.id}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"text-text-primary",children:[t.name," ",s.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-tertiary text-[10px]",children:t.required?"required":"optional"}),t.variant&&s.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-tertiary text-[10px]",children:t.variant})]}),t.description&&s.jsx("div",{className:"text-text-muted",children:t.description})]})]},t.id))]})}function FA(e){return typeof e=="object"&&e!==null?e:null}function Qi(e){return typeof e=="string"?e:""}function Kk(e){return typeof e=="number"?e:void 0}function KV(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=FA(n);if(!r)continue;const a=Object.keys(r).find(d=>d!=="actor"&&d!=="timestamp");if(!a)continue;const o=r[a];typeof o=="string"&&t.push({gateId:a,value:o})}return t}function zA(e){const t=FA(e)??{},n=Qi(t.runState),r=Kk(t.queuePosition),a=Kk(t.attachments);return{id:Qi(t.id),prompt:Qi(t.prompt),status:Qi(t.status),...n?{runState:n}:{},...r!==void 0?{queuePosition:r}:{},...Qi(t.boundSession)?{boundSession:Qi(t.boundSession)}:{},...Qi(t.model)?{model:Qi(t.model)}:{},...a!==void 0?{attachments:a}:{},gates:KV(t.gateValues)}}function YV(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 XV({confirmation:e}){const t=jr(),n=Le(f=>f.confirmPath),r=Le(f=>f.switchDangerLevel),{title:a,description:o}=YV(e.reason),d=e.reason==="sensitive_file"||e.reason==="both",u=d?"border-red-500/50":"border-amber-500/50",c=d?"bg-red-500/10":"bg-amber-500/10",h=e.reason==="git_no_verify",m=()=>{t&&(r(t,"dangerous"),n(t,e.callId,!0,!1))};return s.jsxs("div",{className:`border ${u} ${c} rounded p-3 my-2`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(fy,{}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm font-medium ${d?"text-red-400":"text-amber-400"}`,children:a}),s.jsx("div",{className:"text-xs text-text-muted",children:o})]})]}),s.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[s.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),s.jsx(mt,{className:"bg-bg-primary rounded p-2 mb-3 max-h-24",children:s.jsx("ul",{className:"space-y-0.5",children:e.paths.map((f,g)=>s.jsx("li",{className:`text-xs font-mono ${d?"text-red-300":"text-amber-300"} break-all`,children:f},g))})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>t&&n(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"}),s.jsx("button",{onClick:()=>t&&n(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"}),s.jsx("button",{onClick:m,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 QV(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,o=t.limit,d=[];return a!==void 0&&a!==1&&d.push(`offset=${a}`),o!==void 0&&d.push(`limit=${o}`),d.length>0?`${r} [${d.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}if(e==="call_sub_agent")return String(t.subAgentType??"");if(e==="load_skill")return String(t.skillId??"");if(e==="web_fetch")return String(t.url??"");if(e==="web_search"){const r=String(t.query??"");return r.length>60?r.slice(0,57)+"...":r}if(e==="dev_server")return String(t.action??"");if(e==="background_process"){const r=String(t.action??""),a=t.name?String(t.name):"";return a?`${r}: ${a}`:r}if(e==="mcp_config")return String(t.action??"");if(e==="project_tasks"){const r=String(t.action??""),a=t.taskId?String(t.taskId):"";let o=a?`${r}: ${a}`:r;return r==="move"&&t.to&&(o+=` → ${String(t.to)}`),r==="set_gate_value"&&t.gateId&&(o+=` (${String(t.gateId)})`),o}const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function Yk(e,t,n){var a;const r=QV(e,t);if(e==="read_file"&&n){const o=n.format,d=n.pageCount;if(o==="pdf"&&d!=null)return`${r} (PDF, ${d}p)`;if(o==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const o=n.contentType;if(o){const d=((a=o.split(";")[0])==null?void 0:a.trim())??"";if(d&&d!=="text/html")return`${r} (${d})`}}return r}function JV(e){return JSON.stringify(e,null,2)}const Xk={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},ZV=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),eW=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]),tW=new Set(["-p","-f","-d","-P"]);function Qk(e){return e.split(/[\\/]/).pop()??e}function nW(e){const t=[];let n=null,r=!1;for(let a=0;a<e.length;a+=1){const o=e[a];if(r){r=!1;continue}if(o==="\\"&&n!=="'"){r=!0;continue}if(o==="'"||o==='"'){n=n===o?null:n===null?o:n;continue}if(n)continue;if(o==="#"&&(a===0||/\s|[;&|(){}]/.test(e[a-1])))break;if(o!=="<"||e[a-1]==="<"||e[a+1]!=="<"||e[a+2]==="<")continue;let d=a+2;const u=e[d]==="-";for(u&&(d+=1);/\s/.test(e[d]??"");)d+=1;let c="",h=null,m=!1,f=!0;for(;d<e.length;){const g=e[d];if(!h&&/\s|[;&|(){}<>]/.test(g))break;if(g==="'"||g==='"'){f=!1,h===g?(h=null,m=!1):h===null&&(h=g),d+=1;continue}if(!h&&g==="$"&&e[d+1]==="'"){f=!1,m=!0,h="'",d+=2;continue}if(g==="\\"&&d+1<e.length){if(f=!1,m){const x=e.slice(d).match(/^\\(?:x([0-9A-Fa-f]{1,2})|([0-7]{1,3})|([abefnrtv\\'"?]))/);if(x){x[1]?c+=String.fromCharCode(Number.parseInt(x[1],16)):x[2]?c+=String.fromCharCode(Number.parseInt(x[2],8)):c+={a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
300
+ `,r:"\r",t:" ",v:"\v"}[x[3]]??x[3],d+=x[0].length;continue}}(h!=='"'||["$","`",'"',"\\",`
301
+ `].includes(e[d+1]))&&(d+=1)}c+=e[d],d+=1}c&&t.push({delimiter:c,stripTabs:u,expandable:f}),a=d}return t}function rW(e){const t=e.split(`
302
+ `),n=[],r=[],a=[];for(const o of t){if(a.length>0){const d=a[0],u=d.stripTabs?o.replace(/^\t+/,""):o;u===d.delimiter?a.shift():d.expandable&&r.push(u);continue}n.push(o),a.push(...nW(o))}return{command:n.join(`
303
+ `),expandableBodies:r}}function Jk(e,t=!0){const n=[];let r=null,a=!1,o=!1,d=!1;for(let u=0;u<e.length;u+=1){const c=e[u];if(o){(c===`
304
+ `||c==="\r")&&(o=!1);continue}if(a){a=!1;continue}if(c==="\\"&&r!=="'"){d=!0,a=!0;continue}if(c==="'"){d=!0,r=r==="'"?null:r===null?"'":r;continue}if(c==='"'){d=!0,r=r==='"'?null:r===null?'"':r;continue}if(r!=="'"){if(!r&&/\s|[;&|(){}]/.test(c)?d=!1:c!=="#"&&(d=!0),t&&c==="#"&&!d){o=!0;continue}if(c==="`"){const h=e.indexOf("`",u+1);h!==-1&&(n.push(e.slice(u+1,h)),u=h);continue}if(c==="$"&&e[u+1]==="("&&e[u+2]!=="("){let h=1,m=null,f=!1;for(let g=u+2;g<e.length;g+=1){const x=e[g];if(f){f=!1;continue}if(x==="\\"&&m!=="'"){f=!0;continue}if(x==="'"||x==='"'){m=m===x?null:m===null?x:m;continue}if(!m&&(x==="("&&(h+=1),x===")"&&(h-=1),h===0)){n.push(e.slice(u+2,g)),u=g;break}}}}}return n}function sW(e){const t=[];let n="",r=!1,a=null,o=!1,d=!1;const u=()=>{r&&t.push(n),n="",r=!1};for(let c=0;c<e.length;c+=1){const h=e[c];if(d){(h===`
305
+ `||h==="\r")&&(d=!1,t.at(-1)!==";"&&t.push(";"));continue}if(o){r=!0,n+=h,o=!1;continue}if(h==="\\"&&a!=="'"){o=!0;continue}if(a){h===a?a=null:n+=h;continue}if(h==="'"||h==='"'){r=!0,a=h;continue}if(h==="$"&&e.slice(c,c+3)==="$(("){let m=1;const f=c;for(let g=c+3;g<e.length-1;g+=1)if(e.slice(g,g+2)==="(("&&(m+=1),e.slice(g,g+2)==="))"&&(m-=1),m===0){r=!0,n+=e.slice(f,g+2),c=g+1;break}continue}if(h==="#"&&!r){d=!0;continue}if(/\s/.test(h)){u(),(h===`
306
+ `||h==="\r")&&t.push(";");continue}if(h===";"||h==="|"||h==="&"||h==="("||h===")"||h==="{"||h==="}"){u(),e[c+1]===h&&(c+=1),t.push(h);continue}r=!0,n+=h}return o&&(n+="\\"),u(),t}function rl(e,t,n){for(;t<e.length;){const r=e[t];if(r==="--")return t+1;if(!r.startsWith("-")||r==="-")return t;t+=1,!r.includes("=")&&n.has(r)&&(t+=1)}return t}function es(e,t=0){if(t>8)return null;let n=0;for(;n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;const r=Qk(e[n]??"").toLowerCase();if(r==="env"){for(let d=n+1;d<e.length;d+=1){const u=e[d];if(u==="-S"||u==="--split-string"){const h=e[d+1];return h?Ya(h,t+1):null}const c=u.match(/^--split-string=(.*)$/s);if(c)return Ya(c[1],t+1)}for(n=rl(e,n+1,eW);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return es(e.slice(n),t+1)}if(r==="sudo")return n=rl(e,n+1,ZV),es(e.slice(n),t+1);if(r==="sshpass")return n=rl(e,n+1,tW),es(e.slice(n),t+1);if(r==="nix"){const d=e[n+1];if(d==="shell"||d==="develop"){for(let u=n+2;u<e.length;u+=1)if(e[u]==="-c"||e[u]==="--command")return Ya(e.slice(u+1).join(" "),t+1);return null}if(d==="run"){for(let u=n+2;u<e.length;u+=1)if(e[u]==="--"){for(let c=n+2;c<u;c+=1){const h=e[c],m=h.indexOf("#");if(m!==-1){const f=Qk(h.slice(m+1).split("@")[0]),g=Xk[f.toLowerCase()];if(g)return g}}return null}return null}return null}const a=r,o=Xk[a];if(o)return o;if(a==="command"){if(e.slice(n+1).some(u=>u==="-v"||u==="-V"))return null;const d=rl(e,n+1,new Set);return es(e.slice(d),t+1)}if(a==="setsid"||a==="nohup"){const d=rl(e,n+1,new Set);return es(e.slice(d),t+1)}if(a==="timeout"){const d=rl(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return es(e.slice(d+1),t+1)}if(a==="bash"||a==="sh"||a==="zsh"||a==="fish")for(let d=n+1;d<e.length;d+=1){const u=e[d];if(u!=="--"){if(/^-[^-]*n/.test(u))return null;if(/^-[^-]*c/.test(u)){const c=e[d+1]==="--"?2:1,h=e[d+c];return h?Ya(h,t+1):null}if(!u.startsWith("-"))break}}return null}function Ya(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=rW(e),a=[...Jk(n),...r.flatMap(f=>Jk(f,!1))];for(const f of a){const g=Ya(f,t+1);if(g)return g}const o=sW(n);let d=[];const u=new Set([";","|","&","(",")","{","}"]),c=new Set(["then","do","else","elif","if","while","until"]);let h=!1,m=!1;for(const f of o){if(f==="for"||f==="select"){const g=es(d,t);if(g)return g;d=[],h=!0;continue}if(f==="case"){const g=es(d,t);if(g)return g;d=[],m=!0;continue}if(h){f==="do"&&(h=!1);continue}if(m&&f===")"){d=[];continue}if(u.has(f)){const g=es(d,t);if(g)return g;d=[]}else if(c.has(f)){const g=es(d,t);if(g)return g;d=[]}else if(f==="fi"||f==="done"||f==="esac"){const g=es(d,t);if(g)return g;d=[],f==="esac"&&(m=!1)}else d.push(f)}return es(d,t)}function iW(e,t){return e!=="run_command"||typeof t.command!="string"?null:Ya(t.command)}const aW=[],oW=600;function lW(e,t,n){let r=(e==null?void 0:e.length)??0;if(t)for(const o of t)r+=o.content.length;const a=n.content;return typeof a=="string"&&(r+=a.length),r}const cW={dev_server:LV,workspace:FV,project_tasks:WV,background_process:OV},uW={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-text-tool-error",animate:!1}},dW=k.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:o,result:d,error:u,durationMs:c,diagnostics:h,editContext:m,startedAt:f,streamingOutput:g,metadata:x,truncated:w,callId:C}){var F;const{collapseLargeToolCalls:v}=Hs(),S=!o&&(!v||r==="pending"||lW(d,g,n)<oW),[_,b]=k.useState(S),j=uW[r],E=iW(t,n),N=Bt(P=>P.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",L=t==="edit_file"?(F=m==null?void 0:m.regions[0])==null?void 0:F.startLine:t==="read_file"?(()=>{const P=d==null?void 0:d.split(`
307
+ `)[0],z=P==null?void 0:P.match(/^(\d+): /);return z?parseInt(z[1],10):void 0})():void 0,A=jr(),D=on(A,P=>P.pendingPathConfirmations,P=>P.pendingPathConfirmations,aW),O=C?D.find(P=>P.callId===C||P.callId.startsWith(C+"-"))??null:null;return t==="step_done"?s.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary border border-border rounded px-2 py-1.5 my-1",children:[s.jsx("span",{className:`${j.color} ${j.animate?"animate-pulse":""}`,children:j.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t})]}):a==="compact"?s.jsxs("div",{className:`flex items-center gap-1.5 text-xs rounded px-2 py-1.5 border ${E?"border-text-thinking/60 bg-text-thinking/10":"border-transparent bg-secondary"}`,children:[s.jsx(IA,{tool:t}),s.jsx("span",{className:"text-accent-primary font-medium",children:t}),s.jsx("span",{className:"text-text-muted truncate flex-1",children:Yk(t,n,x)}),s.jsx("span",{className:`${j.color} ${j.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):s.jsxs("div",{className:`border rounded overflow-hidden my-1 min-w-0 ${E?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:[s.jsxs("button",{className:`w-full flex items-center gap-1.5 p-2 text-left ${E?"bg-text-thinking/10 hover:bg-text-thinking/15":"bg-secondary hover:bg-secondary/80"}`,onClick:()=>b(!_),children:[s.jsx("span",{className:`${j.color} ${j.animate?"animate-pulse":""}`,children:j.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),s.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:Yk(t,n,x)}),s.jsx("span",{className:"text-text-muted text-xs",children:_?"▼":"▶"})]}),_&&s.jsxs("div",{className:`p-2 border-t space-y-2 min-w-0 ${E?"border-text-thinking/40 bg-text-thinking/5":"border-border bg-primary"}`,children:[t==="run_command"&&s.jsx(AV,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:f,streamingOutput:g,status:r,result:d,error:u,durationMs:c}),t==="edit_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[m&&m.regions.length>0?s.jsx(yV,{regions:m.regions,filePath:String(n.path??"")}):s.jsx(gV,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(qk,{diagnostics:h})]}),t==="write_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[s.jsx(xV,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(qk,{diagnostics:h})]}),t==="read_file"&&r==="success"&&s.jsx(SV,{result:d,metadata:x,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const P=(g==null?void 0:g.map(K=>K.content).join(""))??"",z=r==="pending"&&P?P:String(n.content??"");return s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),s.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(Zn,{content:z})})]})})(),t==="call_sub_agent"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Zn,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&s.jsxs("div",{children:[s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Zn,{content:d??""})}),w&&s.jsx(Kc,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Zn,{content:d??""})}),w&&s.jsx(Kc,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&s.jsxs("div",{className:"space-y-2",children:[!!(x!=null&&x.url)&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{children:"Source:"}),s.jsx("a",{href:String(x.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(x.url)}),!!(x!=null&&x.contentType)&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(x.contentType),")"]}),(x==null?void 0:x.pageCount)!=null&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(x.pageCount)," pages"]})]}),s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Zn,{content:d??""})}),w&&s.jsx(Kc,{})]}),(()=>{const P=cW[t];return!P||r!=="success"||!d?null:s.jsx(P,{result:d,action:String(n.action??"")})})(),t==="mcp_config"&&r==="success"&&s.jsxs("div",{children:[s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Zn,{content:d??""})}),w&&s.jsx(Kc,{className:"mt-1"})]}),t==="step_done"&&null,t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&t!=="call_sub_agent"&&t!=="web_search"&&t!=="load_skill"&&t!=="web_fetch"&&t!=="dev_server"&&t!=="workspace"&&t!=="project_tasks"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&s.jsxs(s.Fragment,{children:[Object.keys(n).length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),s.jsx(mn,{horizontal:!0,children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:JV(n)})})]}),r==="success"&&d!==void 0&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",c!==void 0&&` (${c}ms)`,":"]}),s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:d||"No output"})}),w&&s.jsx(Kc,{className:"mt-1"})]})]}),(E||r==="success"&&c!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file"))&&s.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[r==="success"&&c!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file")&&s.jsxs("span",{children:["Completed in ",(c/1e3).toFixed(2),"s"]}),s.jsx("span",{className:"flex-1"}),N&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((x==null?void 0:x.path)??n.path??"")&&s.jsx("a",{href:EA(String((x==null?void 0:x.path)??n.path),L),className:"text-accent-primary hover:underline",children:"Open in VSCode"}),E&&s.jsxs("span",{className:"shrink-0 rounded border border-text-thinking/50 bg-text-thinking/15 px-1.5 py-0.5 font-semibold tracking-wide text-text-thinking",children:["REMOTE · ",E]})]}),r==="error"&&u&&t!=="run_command"&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:u})]}),O&&s.jsx(XV,{confirmation:O})]})]})}),hW={read_file:"Reading file",write_file:"Writing file",edit_file:"Editing file",run_command:"Running command",glob:"Searching files",grep:"Searching content",ask_user:"Asking user",criterion:"Managing criterion",session_metadata:"Managing",todo_write:"Updating tasks"};function fW(e,t){const n=hW[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const o=L9(a);return`${n} ${o}`}}catch{}return n}function mW(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 pW=k.memo(function({name:t,arguments:n}){let a=fW(t,n)+"...",o=null;if(t==="run_command"&&n){const d=mW(n);d&&(a=d,o=Ya(d))}return s.jsx("div",{className:`border rounded overflow-hidden my-1 min-w-0 animate-pulse ${o?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:s.jsxs("div",{className:`flex items-center gap-1.5 p-2 ${o?"bg-text-thinking/10":"bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),s.jsx(IA,{tool:t}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?s.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):s.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),gW={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},xW=k.memo(function({todos:t}){return Array.isArray(t)?t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):s.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),s.jsx("div",{children:t.map((n,r)=>{const a=gW[n.status];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[s.jsx("span",{className:`${(a==null?void 0:a.color)??"text-text-muted"} ${a!=null&&a.animate?"animate-pulse":""} text-sm leading-tight`,children:(a==null?void 0:a.icon)??"○"}),s.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):s.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function yW(e){if(e==null)return;if(typeof e=="string"){const n=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?n.map(r=>({value:r,label:r})):void 0}if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n=="string"){const r=n.trim();r.length>0&&t.push({value:r,label:r});continue}if(n!=null&&typeof n=="object"){const r=n,a=r.label,o=r.value;if(typeof a=="string"&&a.trim().length>0){const d=a.trim(),u=typeof o=="string"&&o.length>0?o:d,c=r.description,h={value:u,label:d};typeof c=="string"&&c.length>0&&(h.description=c),t.push(h)}}}return t.length>0?t:void 0}function bW({toolCall:e}){var N;const t=jr(),n=q3(t),r=Le(L=>L.answerQuestion),[a,o]=k.useState(""),d=k.useRef(null),u=k.useRef(null),c=n.find(L=>L.callId===e.id),h=e.arguments.question??(c==null?void 0:c.question)??"",m=e.arguments.type??(c==null?void 0:c.type)??"text",f=e.arguments.options??(c==null?void 0:c.options)??void 0,g=yW(f),x=e.result!==void 0,w=c!==void 0&&!x,C=((N=e.result)==null?void 0:N.output)??"",v=C==="[user skipped]";k.useEffect(()=>{w&&Wt()&&d.current&&d.current.focus()},[w]),k.useEffect(()=>{w&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[w]);const S=k.useCallback(()=>{!c||!t||r(t,c.callId,a)},[c,a,r,t]),_=k.useCallback(()=>{!c||!t||r(t,c.callId,"",!0)},[c,r,t]),b=k.useCallback(L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),S()),L.key==="Escape"&&!L.shiftKey&&(L.preventDefault(),_())},[S,_]),j=k.useCallback(L=>{!c||!t||r(t,c.callId,L)},[c,r,t]),E="px-3 py-1.5 text-xs font-medium rounded transition-colors";return s.jsxs("div",{ref:u,className:"my-1",children:[s.jsx("div",{className:"text-sm",children:s.jsx(Zn,{content:h})}),w&&s.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:s.jsx("div",{className:"p-3 bg-primary space-y-2",children:m==="confirm"?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>j("yes"),className:`${E} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),s.jsx("button",{onClick:()=>j("no"),className:`${E} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),s.jsx("button",{onClick:_,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):m==="choice"&&g!==void 0&&g.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-col gap-1.5",children:g.map((L,A)=>s.jsxs("button",{onClick:()=>j(L.value),className:`${E} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:[s.jsx("span",{className:"block font-medium",children:L.label}),L.description!==void 0&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:L.description})]},A))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("textarea",{ref:d,value:a,onChange:L=>o(L.target.value),onKeyDown:b,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),s.jsx("button",{onClick:S,disabled:!a.trim(),className:`${E} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),s.jsx("button",{onClick:_,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:d,value:a,onChange:L=>o(L.target.value),onKeyDown:b,placeholder:"Type your answer here... (Enter to submit, Shift+Enter for new line)",className:"w-full min-h-[80px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:Wt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:_,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),s.jsx("button",{onClick:S,disabled:!a.trim(),className:`${E} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),x&&s.jsx("div",{className:"mt-1 flex items-center gap-2",children:s.jsx("span",{className:`text-xs ${v?"text-amber-400":"text-accent-success"}`,children:v?"Skipped":`Answered: ${C}`})})]})}const Zk={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"}},vW=new Set(["get","list","schema"]),_W=k.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(u=>[u.id,u]))??[]),a=t.some(u=>u.name==="session_metadata"),o=t.flatMap(u=>vW.has(String(u.arguments.action))?wW(u):[SW(u,r)]),d=(()=>{if(!a)return"Acceptance Criteria";const u=new Set(t.map(c=>c.arguments.key).filter(Boolean));if(u.size===1){const c=u.values().next().value;return c?Sl(c):"Session Data"}return"Session Data"})();return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:d})}),s.jsx("div",{className:"bg-primary",children:o.map((u,c)=>s.jsx("div",{className:`flex items-start gap-2 px-2 py-1.5 ${c>0?"border-t border-border":""}`,children:u.node},u.key))})]})});function SW(e,t){return{key:e.id,node:s.jsx(CW,{tc:e,criteriaMap:t})}}function wW(e){var n,r;const t=(n=e.result)==null?void 0:n.output;if(e.result&&!e.result.success)return[{key:`${e.id}-error`,node:s.jsx("span",{className:"text-text-muted text-sm",children:e.result.error??"Read failed."})}];if(!((r=e.result)!=null&&r.success)||!t)return[{key:`${e.id}-empty`,node:s.jsx("span",{className:"text-text-muted text-sm",children:"No output."})}];if(e.arguments.action==="get")try{const a=JSON.parse(t);if(Array.isArray(a))return a.map((o,d)=>({key:`${e.id}-${d}`,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(Zn,{content:`[${o.id}] ${o.description}`})})]})}))}catch{}if(e.arguments.action==="schema"){const a=e.arguments.key;return[{key:e.id,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-accent-success text-sm leading-tight flex-shrink-0",children:"✓"}),s.jsx("div",{className:"flex-1 min-w-0 text-sm",children:a?`Schema loaded for '${a}' metadata`:"Schema loaded."})]})}]}return[{key:e.id,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(Zn,{content:t})})]})}]}function CW({tc:e,criteriaMap:t}){const n=e.arguments.action,r=e.arguments,a=e.name==="session_metadata",o=n==="remove",d=r.id,u=r.description,c=d?t.get(d):void 0,m=a?`${(n&&{add:"Added",update:"Updated",remove:"Removed",complete:"Completed",pass:"Passed",fail:"Failed"}[n])??"Managed"} item`:"Criterion updated",f=u??(c==null?void 0:c.description)??(o&&d?`[${d}]`:m),g=r.reason,x=n==="fail";return s.jsxs(s.Fragment,{children:[a?s.jsx(Vl,{status:r.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const w=n&&Zk[n]?Zk[n]:{icon:"○",color:"text-text-muted"};return s.jsx("span",{className:`${w.color} text-sm leading-tight flex-shrink-0`,children:w.icon})})(),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:o?"line-through text-text-muted":"",children:s.jsx(Zn,{content:f})}),g&&s.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[s.jsx("span",{className:"text-text-muted",children:"└ "}),'"',g,'"']})]})]})}function kW(e){return e==="criterion"||e==="session_metadata"}const jW="[interrupted by user]";function EW(e){if(!e)return"pending";const t=e.output??"";return!e.success&&t.trimEnd().endsWith(jW)?"interrupted":e.success?"success":"error"}async function HA(e){if(navigator.clipboard){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function NW({items:e,position:t,onClose:n}){const r=k.useRef(null),[a,o]=k.useState(-1);if(k.useEffect(()=>{t&&o(-1)},[t]),k.useEffect(()=>{var m;if(!t)return;function c(f){r.current&&!r.current.contains(f.target)&&n()}function h(f){var g;switch(f.key){case"Escape":f.preventDefault(),n();break;case"ArrowDown":f.preventDefault(),o(x=>x<e.length-1?x+1:0);break;case"ArrowUp":f.preventDefault(),o(x=>x>0?x-1:e.length-1);break;case"Enter":f.preventDefault(),(g=e[a])==null||g.onClick(),n();break}}return document.addEventListener("mousedown",c),window.addEventListener("keydown",h,!0),window.addEventListener("blur",n),(m=r.current)==null||m.focus(),()=>{document.removeEventListener("mousedown",c),window.removeEventListener("keydown",h,!0),window.removeEventListener("blur",n)}},[t,e,a,n]),!t)return null;let d=Math.min(t.x,window.innerWidth-190),u=Math.min(t.y,window.innerHeight-100);return d=Math.max(8,d),u=Math.max(8,u),Cs.createPortal(s.jsx("div",{ref:r,tabIndex:-1,className:"fixed bg-bg-secondary border border-border rounded shadow-lg z-50 min-w-[160px] outline-none",style:{left:d,top:u},children:s.jsx(mt,{className:"max-h-[60vh]",onMouseLeave:()=>o(-1),children:e.map((c,h)=>s.jsxs("button",{onClick:()=>{c.onClick(),n()},onMouseEnter:()=>o(h),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${h<e.length-1?"border-b border-border":""} ${c.danger?"text-accent-error hover:bg-accent-error/10":h===a?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,children:[c.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:c.icon}),c.label]},h))})}),document.body)}function UA(){const[e,t]=k.useState(null);return{onContextMenu:k.useCallback((a,o)=>{var u;if(!o||(u=window.getSelection())!=null&&u.toString())return;const d=a.target instanceof Element?a.target:null;d!=null&&d.closest("a")||(a.preventDefault(),t({x:a.clientX,y:a.clientY}))},[]),contextMenu:a=>s.jsx(NW,{position:e,onClose:()=>t(null),items:a})}}function TW(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const a of e)a.type==="tool_call"&&kW(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function AW(e,t){if(e.segments&&e.segments.length>0)return LW(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 LW(e,t,n,r,a){const o=[],d=new Map(t.map(u=>[u.id,u]));for(const u of e)switch(u.type){case"text":o.push({type:"text",content:u.content});break;case"thinking":u.content&&u.content.trim().length>0&&o.push({type:"thinking",content:u.content});break;case"tool_call":{const c=d.get(u.toolCallId);c&&o.push({type:"tool_call",toolCall:c});break}}for(const u of n)o.push({type:"preparing_tool_call",preparing:u});return a&&r&&o.push({type:"stats",stats:r}),o}const Ov=k.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:o}){const d=Le(N=>{var L,A;return(A=(L=N.currentSession)==null?void 0:L.metadataEntries)==null?void 0:A.criteria}),u=ft(N=>N.defaults),c=ft(N=>N.userItems),h=[...u,...c],m=AW(t,n),f=r?m:m.filter(N=>N.type!=="thinking"),g=TW(f),[x,w]=k.useState(!1),[C,v]=k.useState(null),[,S]=Fn(),{onContextMenu:_,contextMenu:b}=UA();if(g.length===0)return null;const j=()=>{HA(t.content)},E=async()=>{if(!o||x)return;w(!0),v(null);const N=await vE(o,t.id);w(!1),N!=null&&N.session?S(`/p/${N.session.projectId}/s/${N.session.id}`):v("Failed to fork session")};return s.jsxs("div",{className:"feed-item",onContextMenu:N=>_(N,!!o),children:[s.jsxs("div",{className:"min-w-0",children:[C&&s.jsx("p",{className:"text-xs text-accent-error mb-1 ml-0.5",children:C}),g.map((N,L)=>{switch(N.type){case"thinking":return s.jsx(NV,{content:N.content},L);case"text":return s.jsx("div",{className:"prose prose-sm prose-invert max-w-none feed-item",children:s.jsx(Zn,{content:N.content,isStreaming:t.isStreaming})},L);case"preparing_tool_call":return s.jsx(pW,{name:N.preparing.name,arguments:N.preparing.arguments},`preparing-${N.preparing.index}`);case"tool_call":{const A=N.toolCall,D=A.result;if(A.name==="ask_user")return s.jsx(bW,{toolCall:A},L);if(A.name==="todo_write"){const F=A.arguments.todos,P=Array.isArray(F)?F:[];return s.jsx(xW,{todos:P},L)}const O=EW(D);return s.jsx(dW,{tool:A.name,args:A.arguments,status:O,variant:"expandable",forceCompact:!a,result:D==null?void 0:D.output,error:D==null?void 0:D.error,durationMs:D==null?void 0:D.durationMs,diagnostics:D==null?void 0:D.diagnostics,editContext:D==null?void 0:D.editContext,startedAt:A.startedAt,streamingOutput:A.streamingOutput,metadata:D==null?void 0:D.metadata,truncated:(D==null?void 0:D.truncated)??!1,callId:A.id},L)}case"criteria_group":return s.jsx(_W,{toolCalls:N.toolCalls,criteria:d},L);case"stats":{const A=N.stats;if(!A||"error"in A)return null;const D=A.model.split("/").pop()??A.model,O=lo(h,A.mode),F=h.find(W=>W.id===A.mode),P=(F==null?void 0:F.name)??A.mode,z=W=>typeof W!="number"||!Number.isFinite(W)?null:W>=1e3?`${(W/1e3).toFixed(1)}k`:W.toString(),K=W=>typeof W!="number"||!Number.isFinite(W)?null:W>=1e3?`${(W/1e3).toFixed(1)}k`:W.toFixed(1),q=(W,Z)=>{const Q=z(W),H=K(Z);return Q!==null&&H!==null?`${Q} @ ${H}`:"—"};return s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:"text-text-secondary",children:D}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{style:{color:O},children:P}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{children:Bs(A.totalTime)}),A.toolTime>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[Bs(A.toolTime)," tools"]})]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[q(A.prefillTokens,A.prefillSpeed)," pp"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[q(A.generationTokens,A.generationSpeed)," tg"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const W=new CustomEvent("open-turn-stats",{detail:{stats:A}});window.dispatchEvent(W)},children:s.jsx(qf,{className:"w-3 h-3"})}),s.jsx("span",{className:"flex-1 h-px bg-border"})]},L)}}}),t.partial&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[s.jsx(fy,{}),s.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-text-truncated mt-1",children:[s.jsx(fy,{}),s.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),b([{label:"Copy",icon:s.jsx(jl,{className:"w-4 h-4"}),onClick:()=>j()},{label:"Fork session from here",icon:s.jsx(to,{className:"w-4 h-4"}),onClick:()=>void E()}])]})});function Nf(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${a},${t})`}function RW(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const DW=k.memo(function({data:t}){var a;const n=$u(),r=(t.workflowId?(a=_f(n,t.workflowId))==null?void 0:a.color:void 0)??t.workflowColor??"#8b949e";return s.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:Nf(r,.3),backgroundColor:Nf(r,.08)},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(dO,{color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName??"Task Completed"})]}),s.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[s.jsx(Yc,{label:"Iterations",value:String(t.iterations)}),s.jsx(Yc,{label:"Total time",value:Bs(t.totalTimeSeconds)}),s.jsx(Yc,{label:"Tool calls",value:String(t.totalToolCalls)}),s.jsx(Yc,{label:"Tokens",value:RW(t.totalTokensGenerated)}),s.jsx(Yc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function Yc({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[s.jsx("div",{className:"text-sm text-text-muted",children:e}),s.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const OW=k.memo(function({data:t}){var a;const n=$u(),r=((a=_f(n,t.workflowId))==null?void 0:a.color)??t.workflowColor??"#6b7280";return s.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:Nf(r,.3),backgroundColor:Nf(r,.08)},children:[s.jsx(Kf,{className:"w-3 h-3 shrink-0",color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName}),s.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function MW({attachments:e,messageId:t}){const[n,r]=k.useState(null),a=Le(m=>m.visionFallbackByMessage),o=Le(m=>m.messages),d=k.useMemo(()=>{const m=o.findIndex(f=>f.id===t);if(m===-1)return null;for(let f=m+1;f<o.length;f++){const g=o[f];if(g&&g.role==="assistant")return g.id}return null},[o,t]),u=m=>{r(m)},c=()=>{r(null)},h=m=>{const f=`${t}-${m}`;if(a[f])return a[f];if(d){const g=`${d}-${m}`;return a[g]}return null};return e.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(m=>{const f=h(m.id);return XT(m.mimeType)?s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>u(m.data),className:"group relative inline-block",title:(f==null?void 0:f.type)==="done"&&f.description||m.description||m.filename,disabled:(f==null?void 0:f.type)==="start",children:[s.jsx("img",{src:m.data,alt:(f==null?void 0:f.type)==="done"&&f.description||m.description||m.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(f==null?void 0:f.type)==="start"&&s.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:s.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(f==null?void 0:f.type)==="done"&&f.description&&s.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[f.description.slice(0,200),f.description.length>200?"...":""]})]},m.id):s.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[s.jsx("div",{className:"w-10 h-10 flex items-center justify-center rounded-md bg-bg-secondary text-sm font-bold text-text-muted shrink-0",children:QT(m.filename)}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:m.filename,children:m.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:gl(m.size)}),_v(m.mimeType)&&m.data&&s.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[m.data.slice(0,200),m.data.length>200?"...":""]})]})]},m.id)})}),n&&s.jsx(OA,{src:n,alt:"Attached image",isOpen:!0,onClose:c})]})}function IW({message:e}){const[t,n]=k.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,a=(r==null?void 0:r.color)??"#6b7280",o=(r==null?void 0:r.type)??"agent",d=o==="workspace"?"Workspace":(r==null?void 0:r.name)??"Agent",c={agent:(r==null?void 0:r.kind)==="reminder"?"reminder":"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions",workspace:`${(r==null?void 0:r.workspaceName)??""} · ${(r==null?void 0:r.branchName)??""}`,branch:`🌿 ${(r==null?void 0:r.branchName)??""}`,task:"🗂 task"}[o]??"injected",h=o==="workflow"||o==="subagent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!h&&n(!0)}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!h&&n(!0),children:d}),s.jsx("span",{children:"·"}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:c}),s.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&s.jsx("div",{className:"flex justify-center feed-item mb-4",children:s.jsx(mt,{horizontal:!0,className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${a}`},children:s.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),s.jsx(Et,{isOpen:t,onClose:()=>n(!1),title:`${d} Prompt`,size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),s.jsx("span",{className:"text-sm text-text-primary font-medium",children:d}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",o,")"]})]}),s.jsx("div",{className:"h-full min-h-96",children:s.jsx(mt,{horizontal:!0,className:"h-full min-h-96",children:s.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap break-words bg-bg-tertiary rounded p-4 h-full min-h-96 font-mono",children:e.content})})})]})})]})}const Qy="openfox:feed-reveal",Tf="openfox:autoscroll-rearm";function PW({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",o=e.isSystemGenerated,d=Le(M=>M.loadSession),[,u]=Fn(),[c,h]=k.useState(!1),[m,f]=k.useState(!1),[g,x]=k.useState(!1),[w,C]=k.useState(e.content),[v,S]=k.useState(e.attachments??[]),[_,b]=k.useState(!1),[j,E]=k.useState(!1),[N,L]=k.useState(null),[A,D]=k.useState(null),O=k.useRef(null),{onContextMenu:F,contextMenu:P}=UA(),z=k.useCallback(()=>{const M=O.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]),K=async()=>{try{await HA(e.content),f(!0),window.setTimeout(()=>f(!1),1500)}catch{}},q=async()=>{if(!n||!t||j)return;E(!0),L(null);const M=await vE(n,t);if(E(!1),M!=null&&M.session){const V=M.session.projectId;u(`/p/${V}/s/${M.session.id}`)}else L("Failed to fork session")},W=async()=>{if(!n||!t||_)return;b(!0),D(null);const M=await f1(n,t);b(!1),M?(window.dispatchEvent(new CustomEvent(Tf)),d(n,!0)):D("Failed to replay")},Z=async()=>{if(!n||!t||!w.trim()||_)return;b(!0),D(null);const M=await f1(n,t,w,v);b(!1),M?(window.dispatchEvent(new CustomEvent(Tf)),d(n,!0),x(!1)):D("Failed to send")},Q=()=>{C(e.content),S(e.attachments??[]),x(!1),D(null)},I=`flex items-center gap-0.5 self-end transition-[visibility,opacity] focus-within:visible focus-within:opacity-100 ${c&&!g&&!_?"visible opacity-100":"invisible opacity-0"}`;return s.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onContextMenu:M=>F(M,!!n&&!!t),children:[!o&&s.jsxs("div",{className:I,children:[s.jsx("button",{onClick:()=>{K()},title:"Copy",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:m?s.jsx(Us,{className:"w-3.5 h-3.5 text-accent-success"}):s.jsx(jl,{className:"w-3.5 h-3.5"})}),n&&t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{D(null),C(e.content),S(e.attachments??[]),x(!0)},title:"Edit & resend",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(kb,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>{W()},title:"Replay",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(Yf,{className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:`max-w-[75%] ${g?"w-full":""} rounded p-2 ${o?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[o&&s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),g?s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("textarea",{ref:M=>{O.current=M,M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},className:"w-full bg-bg-primary border border-border rounded p-1.5 text-sm text-text-primary resize-none focus:outline-none focus:border-accent-primary min-h-[60px] overflow-hidden disabled:opacity-50",value:w,onChange:M=>{C(M.target.value),z()},onKeyDown:M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),Z()),M.key==="Escape"&&Q()},disabled:_,autoFocus:Wt()}),v.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(M=>s.jsx(Sv,{attachment:M,onRemove:V=>S($=>$.filter(ee=>ee.id!==V))},M.id))}),A&&s.jsx("p",{className:"text-xs text-accent-error",children:A}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:Q,disabled:_,className:"px-4 py-1.5 rounded text-sm bg-bg-tertiary/50 text-text-muted hover:bg-bg-tertiary hover:text-text-primary transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),s.jsx("button",{onClick:()=>{Z()},disabled:_||!w.trim(),className:"px-4 py-1.5 rounded text-sm bg-accent-primary/20 text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"Send"})]})]}):s.jsxs(s.Fragment,{children:[(A||N)&&s.jsx("p",{className:"text-xs text-accent-error mb-1",children:A??N}),s.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${o?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&s.jsx(MW,{attachments:e.attachments,messageId:e.id})]})]}),P([{label:"Copy",icon:s.jsx(jl,{className:"w-4 h-4"}),onClick:()=>void K()},{label:"Fork session from here",icon:s.jsx(to,{className:"w-4 h-4"}),onClick:()=>void q()}])]})}const VA=k.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const o=t.role==="user",d=t.role==="assistant",u=t.role==="system",c=t.role==="tool";if(d)return s.jsx(Ov,{message:t,showStats:n});if(u&&t.isCompacted)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[s.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),s.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
308
+ `,"")})]});if(c)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[s.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),s.jsx(mn,{horizontal:!0,className:"max-h-32",children:s.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap break-words",children:[t.content.slice(0,500),t.content.length>500&&"..."]})})]});if(t.messageKind==="workflow-started")try{const h=JSON.parse(t.content);return s.jsx(OW,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return s.jsx(DW,{data:h})}catch{}return t.messageKind==="context-reset"?s.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{children:t.content}),s.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?s.jsx(IW,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?s.jsx("div",{className:"flex justify-end feed-item",children:s.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),s.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):o?s.jsx(PW,{message:t,messageId:r,sessionId:a}):s.jsx("div",{className:"flex justify-start feed-item",children:s.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:s.jsx(Zn,{content:t.content})})})}),BW={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function $W(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function ej(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function FW({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,o=Math.round(t/n*100);return s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[s.jsxs("span",{className:ej(o,a),children:[Ll(t),"/",Ll(n)]}),s.jsxs("span",{className:ej(o,a),children:["(",o,"%)"]}),s.jsx(Rv,{percent:o,dangerZone:a,size:"sm"}),a&&s.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&s.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const zW=k.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const o=k.useRef(null),d=k.useRef(null),[u,c]=k.useState(!1),h=ft(D=>D.defaults),m=ft(D=>D.userItems),f=[...h,...m],g=Le(D=>D.subAgentContextStates[r]),{showThinking:x,showVerboseToolOutput:w}=Hs(),C=zu(d),{isAutoScrollActive:v,setAutoScroll:S,handleScrollbarGesture:_}=Fu(d,null,C),b=k.useCallback(()=>{const D=!u;c(D),D&&setTimeout(()=>{var O;(O=o.current)==null||O.scrollIntoView({block:"start",behavior:"smooth"})},220)},[u]),j=f.find(D=>D.id===n),E=(j==null?void 0:j.name)??BW[n]??n,N=lo(f,n),L=$W(N),A=t.filter(D=>D.role!=="tool");return s.jsxs("div",{ref:o,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[s.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:L,children:[s.jsx("span",{className:"text-xs font-medium",children:E}),s.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:g&&s.jsx(FW,{contextState:g})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>S(!v),children:[s.jsx("span",{className:`w-1 h-1 rounded-full ${v?"bg-accent-success":"border border-text-muted"}`}),"live"]}),s.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:b,children:[u?"▼":"▶"," Expand"]})]})]}),s.jsx(mt,{ref:d,className:`${u?"max-h-[calc(100vh-10rem)]":"max-h-80"} p-2 transition-[max-height] duration-200`,onScrollbarGesture:_,children:A.map(D=>D.role==="assistant"?s.jsx(Ov,{message:D,showStats:!0,showThinking:x,showVerboseToolOutput:w},D.id):s.jsx(VA,{message:D,isLastAssistantMessage:!1},D.id))})]})}),HW={contentVisibility:"auto",containIntrinsicSize:"auto 200px"},UW={contentVisibility:"auto",containIntrinsicSize:"160px",minHeight:"160px"},Eh=30,Ux=20,VW=10,WW=5;function Nh(e){var t;return e.type==="context-divider"?`ctx-${e.windowSequence}`:e.type==="subagent"?((t=e.messages[0])==null?void 0:t.id)??e.subAgentId:e.message.id}const WA=k.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,scrollContainerRef:a,showThinking:o=!0,showVerboseToolOutput:d=!0,showStats:u=!0,showAgentDefinitions:c=!0,showWorkflowBars:h=!0}){const m=t.length,{feedVirtualization:f}=Hs(),[g,x]=k.useState(()=>Math.max(0,m-Eh)),w=k.useRef(null),C=k.useRef(t.length),v=k.useRef(!1),S=f?g:0,_=f?HW:void 0;k.useEffect(()=>{f&&(x(Math.max(0,t.length-Eh)),v.current=!1)},[r]),k.useEffect(()=>{const E=C.current;C.current=t.length,f&&t.length-E>=WW&&!v.current&&x(Math.max(0,t.length-Eh))},[t.length,f]),k.useEffect(()=>{f&&g>0&&g>=t.length&&x(Math.max(0,t.length-Eh))},[t.length,g,f]),k.useEffect(()=>{if(!f||g<=0||typeof IntersectionObserver>"u")return;const E=w.current;if(!E)return;const N=new IntersectionObserver(L=>{L.some(A=>A.isIntersecting)&&x(A=>Math.max(0,A-Ux))},{rootMargin:"0px 0px 300px 0px"});return N.observe(E),()=>N.disconnect()},[g,f]);const b=k.useRef(g);b.current=g,k.useEffect(()=>{var A,D;if(!f)return;const E=a==null?void 0:a.current;if(!E)return;const N=(D=(A=E.osInstance)==null?void 0:A.call(E))==null?void 0:D.elements().viewport;if(!N)return;const L=()=>{if(N.scrollTop>4){v.current=!0;return}b.current>0&&x(O=>Math.max(0,O-Ux))};return N.addEventListener("scroll",L,{passive:!0}),()=>N.removeEventListener("scroll",L)},[a,f]),k.useEffect(()=>{var L,A;if(!f||g<=0||!v.current)return;const E=a==null?void 0:a.current,N=(A=(L=E==null?void 0:E.osInstance)==null?void 0:L.call(E))==null?void 0:A.elements().viewport;N&&N.scrollTop<=4&&x(D=>Math.max(0,D-Ux))},[g,a,f]),k.useEffect(()=>{if(!f)return;const E=N=>{var A;const L=(A=N.detail)==null?void 0:A.index;typeof L=="number"&&x(D=>Math.min(D,Math.max(0,L-VW)))};return window.addEventListener(Qy,E),()=>window.removeEventListener(Qy,E)},[f]);const j=t.slice(S);return s.jsxs(s.Fragment,{children:[S>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-xs text-text-muted","data-testid":"feed-unmounted-hint",children:["Scroll up to load ",S," older item",S!==1?"s":""]}),Array.from({length:S},(E,N)=>s.jsx("div",{"data-item-index":N,"data-placeholder":!0,style:UW},`ph-${N}`)),s.jsx("div",{ref:w,"data-testid":"feed-sentinel",style:{height:1}})]}),j.map((E,N)=>{const L=S+N;if(E.type==="context-divider")return s.jsxs("div",{"data-item-index":L,className:"flex items-center gap-2 feed-item px-2 @md:px-4",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),s.jsx("div",{className:"flex-1 border-t border-border"})]},Nh(E));if(E.type==="subagent"){const F=E.messages.some(P=>P.isStreaming);return s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:_,children:s.jsx(zW,{messages:E.messages,subAgentType:E.subAgentType,subAgentId:E.subAgentId,isStreaming:F})},Nh(E))}const A=E.message;if(A.role==="assistant")return s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:_,children:s.jsx(Ov,{message:A,showStats:u,showThinking:o,showVerboseToolOutput:d,sessionId:r??void 0})},Nh(E));const D=!c&&A.messageKind==="auto-prompt",O=!h&&(A.messageKind==="workflow-started"||A.messageKind==="task-completed");return D||O?null:s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:_,children:s.jsx("div",{"data-message-id":A.id,className:n===A.id?"rounded animate-highlight-fade":void 0,children:s.jsx(VA,{message:A,messageId:A.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},Nh(E))})]})});function wm(e,t,n=!0){k.useEffect(()=>{if(!n)return;const r=a=>{var o;(o=e.current)!=null&&o.contains(a.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const Vx=[];function GW({retry:e,onRetryNow:t}){const[n]=k.useState(Date.now()),[r,a]=k.useState(Date.now());k.useEffect(()=>{const u=setInterval(()=>a(Date.now()),250);return()=>clearInterval(u)},[]);const o=Math.max(0,Math.ceil((e.retryInMs-(r-n))/1e3)),d=o>0?` — next try in ${o}s`:"";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-bg-tertiary/60 border border-border text-xs text-text-secondary",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-primary animate-pulse"}),s.jsxs("span",{children:["LLM call failed — retrying (attempt ",e.attempt,")",d]}),s.jsx("button",{onClick:t,className:"ml-1 px-2 py-0.5 rounded-full bg-accent-primary/15 text-accent-primary border border-accent-primary/25 hover:bg-accent-primary/25 transition-colors",children:"Retry now"})]})}const qW=k.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:o,hiddenCount:d=0,onScrollbarGesture:u,emptyState:c}){const h=jr(),m=on(h,ie=>{var de,pe;return((pe=(de=ie.session)==null?void 0:de.metadataEntries)==null?void 0:pe.criteria)??Vx},ie=>{var de,pe;return((pe=(de=ie.currentSession)==null?void 0:de.metadataEntries)==null?void 0:pe.criteria)??Vx},Vx),f=on(h,ie=>{var de;return((de=ie.session)==null?void 0:de.id)??null},ie=>{var de;return((de=ie.currentSession)==null?void 0:de.id)??null},null),g=on(h,ie=>{var de;return((de=ie.session)==null?void 0:de.phase)??null},ie=>{var de;return((de=ie.currentSession)==null?void 0:de.phase)??null},null),x=on(h,ie=>ie.error??null,ie=>ie.error,null),w=Le(ie=>ie.clearError),C=Wf(h),v=on(h,ie=>ie.activeWorkflowExecution??null,ie=>ie.activeWorkflowExecution,null),S=Le(ie=>ie.continueWorkflow),_=on(h,ie=>ie.llmRetry??null,ie=>ie.llmRetry,null),b=Le(ie=>ie.retryLLMNow),j=Le(ie=>ie.retryLLM),{showThinking:E,showVerboseToolOutput:N,showStats:L,showAgentDefinitions:A,showWorkflowBars:D}=Hs(),O=$u(),F=m.some(ie=>ie.status==="pending"),P=g==="done",z=t.some(ie=>ie.type==="message"&&ie.message.role==="assistant"),K=(v==null?void 0:v.status)==="running"||(v==null?void 0:v.status)==="waiting",q=F&&!C&&z&&!P&&!K,W=(v==null?void 0:v.status)==="waiting"&&!C,Z=(v==null?void 0:v.status)==="blocked"&&!!v.currentStepId,Q=Z&&(_==null?void 0:_.status)!=="failed",H=on(h,ie=>{var de;return((de=ie.session)==null?void 0:de.projectId)??void 0},ie=>{var de;return(de=ie.currentSession)==null?void 0:de.projectId},void 0),[I,M]=k.useState(!1),[V,$]=k.useState(!1),[ee,Y]=k.useState(!1),X=zu(n);k.useLayoutEffect(()=>{const ie=X();ie&&$(ie.scrollHeight>ie.clientHeight+1)},[X,t]),k.useEffect(()=>{const ie=X();if(!ie)return;const de=()=>Y(ie.scrollTop>4);return de(),ie.addEventListener("scroll",de,{passive:!0}),()=>ie.removeEventListener("scroll",de)},[X]);const U=()=>{if(!H||!f)return;M(!1),window.open(`/p/${H}/s/${f}/readonly`,"_blank")||M(!0)},[B,J]=k.useState(!1),se=k.useCallback(ie=>{B||!h||(J(!0),S(h,ie),setTimeout(()=>J(!1),5e3))},[B,S,h]),ne=k.useCallback(()=>{var ie;o==null||o(),(ie=X())==null||ie.scrollTo({top:0,behavior:"smooth"})},[X,o]);return s.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[s.jsx(mt,{ref:n,"data-testid":"chat-scroll-container",className:"absolute inset-0 bg-primary",onScrollbarGesture:u,children:s.jsxs("div",{className:"flex min-h-full flex-col",children:[s.jsxs("div",{className:"pt-4",children:[d>0&&s.jsxs("div",{className:"px-2 @md:px-4 pb-2 space-y-1",children:[s.jsxs("button",{onClick:U,className:"w-full text-sm text-text-muted hover:text-text-primary bg-bg-tertiary/50 hover:bg-bg-tertiary border border-border rounded px-3 py-2 transition-colors text-center",children:[d," older item",d!==1?"s":""," hidden — View full history"]}),I&&s.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",s.jsx("a",{href:H&&f?`/p/${H}/s/${f}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),s.jsx(WA,{displayItems:t,highlightedMessageId:r,sessionId:f,scrollContainerRef:n,showThinking:E,showVerboseToolOutput:N,showStats:L,showAgentDefinitions:A,showWorkflowBars:D})]}),t.length===0&&c&&s.jsx("div",{className:"flex flex-1 items-center justify-center px-2 @md:px-4 py-4",children:c}),s.jsxs("div",{className:"px-2 @md:px-4 pb-4",children:[(_==null?void 0:_.status)==="retrying"&&C&&s.jsx("div",{className:"flex justify-center feed-item","data-testid":"llm-retry-indicator",children:s.jsx(GW,{retry:_,onRetryNow:()=>f&&b(f)},_.attempt)}),(_==null?void 0:_.status)==="failed"&&!C||Z?s.jsxs("div",{className:"flex flex-col items-center gap-2 feed-item flex-wrap",children:[(_==null?void 0:_.status)==="failed"&&s.jsxs("div",{className:"text-xs text-text-secondary max-w-md text-center",children:["The LLM call failed: ",_.error]}),Q&&s.jsx("div",{className:"text-xs text-text-secondary max-w-md text-center",children:v!=null&&v.currentStepName?`The "${v.currentStepName}" step stopped before finishing — retry to continue.`:"This workflow step stopped before finishing — retry to continue."}),s.jsx("button",{onClick:()=>f&&j(f),disabled:C,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/15 text-accent-primary border border-accent-primary/25 hover:bg-accent-primary/25 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:C?"Resuming…":Q?"↻ Retry step":"↻ Retry"})]}):null,x&&s.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:x.code}),s.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:x.message})]}),s.jsx(Bu,{onClick:w,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),W&&v&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:(v.pendingChoices&&v.pendingChoices.length>0?v.pendingChoices:[{id:void 0,label:`▶ Continue ${v.workflowName} (${v.currentStepName??"..."})`,goto:"",nextStepName:void 0}]).map(ie=>s.jsx("button",{onClick:()=>se(ie.id),disabled:B,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/15 text-accent-primary border border-accent-primary/25 hover:bg-accent-primary/25 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:B?"⏳ Continuing...":ie.id==="continue"?`▶ Continue ${v.workflowName} (${ie.nextStepName??v.currentStepName??"..."})`:ie.label},ie.id??"continue"))}),q&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:O.map(ie=>{const de=ie.color??"#3b82f6",pe=parseInt(de.slice(1,3),16),Oe=parseInt(de.slice(3,5),16),$e=parseInt(de.slice(5,7),16),Pe=`rgba(${pe},${Oe},${$e},0.12)`,Ve=`rgba(${pe},${Oe},${$e},0.22)`,Ye=`rgba(${pe},${Oe},${$e},0.25)`;return s.jsx(KW,{workflowName:ie.name,scope:ie.scope,color:de,bg:Pe,bgHover:Ve,border:Ye,subGroups:ie.subGroups,onLaunch:ot=>a(ie.id,ot,void 0,ie.scope)},`${ie.id}-${ie.scope}`)})})]})]})}),V&&ee&&s.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-10 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:s.jsxs("button",{type:"button",onClick:ne,className:"pointer-events-auto 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 backdrop-blur-sm bg-bg-secondary/60",children:[s.jsx(Cb,{className:"w-3 h-3"}),"scroll to top"]})})]})});function KW({workflowName:e,scope:t,color:n,bg:r,bgHover:a,border:o,subGroups:d,onLaunch:u}){const[c,h]=k.useState(!1),m=k.useRef(null);wm(m,()=>h(!1),c);const f=d&&d.length>0;return s.jsxs("div",{className:"relative flex",children:[s.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:`px-4 py-1.5 text-sm font-medium transition-colors ${f?"rounded-l":"rounded"}`,style:{backgroundColor:r,color:n,border:`1px solid ${o}`,...f?{borderRight:"none"}:{}},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:["▶ ",e," ",s.jsx("span",{className:"text-[10px] font-normal opacity-70 whitespace-nowrap",children:Cv[t]})]}),f&&s.jsxs("div",{ref:m,className:"relative flex",children:[s.jsx("button",{onClick:()=>h(!c),className:"px-2.5 py-1.5 rounded-r text-sm font-medium transition-colors flex items-center",style:{backgroundColor:r,color:n,border:`1px solid ${o}`},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:"⋮"}),c&&s.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:[s.jsx("button",{onClick:()=>{u(),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),s.jsx("div",{className:"border-t border-border/50"}),d.map(g=>s.jsx("button",{onClick:()=>{u(g),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:g},g))]})]})]})}function YW(){const e=Le(r=>r.connectionStatus),t=Le(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return s.jsxs("div",{className:`
309
+ flex items-center justify-between px-4 py-2
310
+ text-sm font-medium
311
+ ${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"}
312
+ `,children:[s.jsx("div",{className:"flex items-center gap-2",children:n?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),s.jsx("span",{children:"Reconnecting to server..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(fO,{}),s.jsx("span",{children:"Connection lost"})]})}),s.jsx("button",{onClick:()=>t(),disabled:n,className:`
313
+ px-3 py-1 rounded text-xs font-medium
314
+ transition-colors
315
+ ${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"}
316
+ `,children:n?"Reconnecting...":"Reconnect"})]})}function XW(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function QW({onClick:e}){return s.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:s.jsx(Eb,{})})}function GA({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=cn(me=>me.defaults),o=cn(me=>me.userItems),d=cn(me=>me.projectItems),u=cn(me=>me.loading),c=cn(me=>me.fetchCommands),h=cn(me=>me.fetchCommand),m=cn(me=>me.fetchDefaultContent),f=cn(me=>me.createCommand),g=cn(me=>me.updateCommand),x=cn(me=>me.deleteCommand),[w,C]=k.useState(null),[v,S]=k.useState(null),{view:_,editingId:b,formError:j,saving:E,formData:N,setView:L,setEditingId:A,setFormError:D,setFormData:O,setSaving:F}=WE(),{requestDelete:P,clearConfirm:z,isConfirming:K}=Au(),q=k.useRef(!1),W=ft(me=>me.defaults),Z=ft(me=>me.userItems),Q=ft(me=>me.fetchAgents),I=[...W,...Z].filter(me=>!me.subagent),M=k.useRef(c),V=k.useRef(Q),$=k.useRef(h),ee=k.useRef(m),Y=k.useRef(r),X=k.useRef(n),U=k.useRef(L),B=k.useRef(A),J=k.useRef(D),se=k.useRef(z);k.useEffect(()=>{M.current=c,V.current=Q,$.current=h,ee.current=m,Y.current=r,X.current=n,U.current=L,B.current=A,J.current=D,se.current=z}),k.useEffect(()=>{if(e)if(M.current(Y.current),V.current(Y.current),q.current||(se.current(),q.current=!0),X.current){const me=a.some(re=>re.id===X.current);U.current("edit"),B.current(X.current),J.current(""),me?ee.current(X.current).then(re=>{re&&O({name:re.metadata.name+" (copy)",id:`${X.current}-copy-${Date.now()}`,prompt:re.prompt,agentMode:re.metadata.agentMode??"",isDefault:!0,destination:"user"})}):$.current(X.current,Y.current).then(re=>{re&&O({name:re.metadata.name,id:re.metadata.id,prompt:re.prompt,agentMode:re.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else U.current("list"),B.current(null);else q.current=!1},[e]);const ne=async me=>{C(me);const re=await m(me);S((re==null?void 0:re.prompt)??null)},ie=async me=>{if(a.some(_e=>_e.id===me)){const _e=await m(me);_e&&(A(null),O({name:`${_e.metadata.name} (copy)`,id:`${me}-copy-${Date.now()}`,prompt:_e.prompt,agentMode:_e.metadata.agentMode??"",isDefault:!0,destination:"user"}),D(""),L("edit"))}else{const _e=await h(me,r);_e&&(A(null),O({name:`${_e.metadata.name} (copy)`,id:`${me}-copy-${Date.now()}`,prompt:_e.prompt,agentMode:_e.metadata.agentMode??"",isDefault:!1,destination:"user"}),D(""),L("edit"))}},de=()=>{O({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),A(null),L("edit")},pe=async me=>{const re=await h(me,r);re&&(A(me),O({name:re.metadata.name,id:re.metadata.id,prompt:re.prompt,agentMode:re.metadata.agentMode??"",isDefault:!1,destination:"user"}),D(""),L("edit"))},Oe=async me=>{await x(me,r),z()},$e=async()=>{const me=b??N.id;if(!me||!N.name||!N.prompt){D("Name and message are required.");return}F(!0),D("");const re={metadata:{id:me,name:N.name,...N.agentMode?{agentMode:N.agentMode}:{}},prompt:N.prompt},_e=b?await g(b,re,r):await f(re,N.destination,r);if(F(!1),!_e.success){D(_e.error??"Failed to save command.");return}n?t():L("list")},Pe=()=>{n?t():(L("list"),C(null),S(null))},Ve=me=>{O(re=>({...re,name:me})),(!b||N.isDefault)&&O(re=>({...re,id:XW(me)}))},Ye=()=>{C(null),S(null),L("list")},ot=()=>{w&&(C(null),L("edit"),A(w),m(w).then(me=>{me&&O({name:`${me.metadata.name} (copy)`,id:`${w}-copy-${Date.now()}`,prompt:me.prompt,agentMode:me.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(w){const me=a.find(re=>re.id===w);return s.jsx(Et,{isOpen:e,onClose:Ye,title:`Default: ${(me==null?void 0:me.name)??w}`,size:"xl",children:s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),s.jsx("span",{className:"font-mono",children:w})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:me==null?void 0:me.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(me==null?void 0:me.agentMode)||"None"})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value:v??"",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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[s.jsx(ct,{variant:"secondary",onClick:Ye,children:"Close"}),s.jsx(ct,{variant:"primary",onClick:ot,children:"Duplicate & Customize"})]})]})})}if(_==="edit")return s.jsx(Et,{isOpen:e,onClose:Pe,title:b?"Edit Command":"New Command",size:"xl",footer:s.jsx(FE,{onCancel:Pe,onSave:$e,saving:E,saveDisabled:!N.name||!N.prompt}),children:s.jsxs("div",{className:"flex flex-col h-full",children:[j&&s.jsx(vl,{message:j}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(VE,{name:N.name,id:N.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!b&&!N.isDefault,onNameChange:Ve,onIdChange:me=>O(re=>({...re,id:me}))}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsxs("select",{value:N.agentMode,onChange:me=>O(re=>({...re,agentMode:me.target.value})),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[s.jsx("option",{value:"",children:"None (keep current mode)"}),I.map(me=>s.jsx("option",{value:me.id,children:me.name},me.id))]})]}),!b&&s.jsx(Zf,{value:N.destination,onChange:me=>O(re=>({...re,destination:me}))})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value:N.prompt,onChange:me=>O(re=>({...re,prompt:me.target.value})),placeholder:"The message that will be sent when this command is triggered...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]})});const Ae=me=>me.map(re=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:re.name})})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(wi,{onClick:()=>pe(re.id)}),s.jsx(yu,{onClick:()=>ie(re.id)}),K(re.id,"delete")?s.jsx(tf,{onConfirm:()=>Oe(re.id),onCancel:z}):s.jsx(nf,{onClick:()=>P(re.id)})]})]},re.id));return s.jsxs(Et,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[s.jsx(UE,{description:"Commands are pre-defined messages you can send with a single click.",onNew:de}),s.jsxs(Db,{loading:u,hasItems:a.length>0||o.length>0||d.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[a.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:a.map(me=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:me.name})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(QW,{onClick:()=>ne(me.id)}),s.jsx(yu,{onClick:()=>ie(me.id)})]})]},me.id))})]}),o.length>0&&s.jsx(HE,{children:Ae(o)}),d.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:Ae(d)})]})]})]})}function JW({title:e,defaultOpen:t=!1,children:n,className:r=""}){return s.jsxs("details",{className:`group ${r}`,open:t,children:[s.jsxs("summary",{className:"text-[11px] text-text-secondary uppercase tracking-wider font-medium cursor-pointer select-none hover:text-text-primary transition-colors list-none flex items-center gap-1",children:[s.jsx(gn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),e]}),s.jsx("div",{className:"mt-2 space-y-2",children:n})]})}const Fa=150,fi=54,Th=80,us=30,sl=70,tj=100,za=50,Ah=50,nj=4,qA={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},KA=[{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)"}],ZW=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"},{value:"user",label:"User (pause)"}];function Mv(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.agentId);return{name:(n==null?void 0:n.name)??(e.agentId||"Agent"),color:(n==null?void 0:n.color)||"#3b82f6"}}if(e.type==="sub_agent"){const n=t.find(r=>r.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return e.type==="user"?{name:"User",color:"#f59e0b"}:{name:"Shell",color:"#22c55e"}}function eG(e,t,n,r){const a=Ah+za+Fa+tj+Fa+za+Ah,o=a/2,d=Ah+za+Fa/2,u=Ah+za+Fa+tj+Fa/2,c=[],h=[],m=new Map,f=e.filter(q=>q.type==="agent"||q.type==="shell"||q.type==="user"),g=e.filter(q=>q.type==="sub_agent"),x=g.length>0,w=x?d:o,C=f.length>0?u:o,v=za+us/2;c.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:v,w:Th,h:us}),m.set("$start",{cx:w,cy:v,w:Th,h:us});const S=q=>{c.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:q,w:Th,h:us}),m.set("$done",{cx:w,cy:q,w:Th,h:us})};if(e.length===0){const q=v+us/2+sl*2+us/2;return S(q),{nodes:c,edges:h,width:a,height:q+us/2+za,posMap:m}}const _=v+us/2+sl,b=(q,W)=>{q.forEach((Z,Q)=>{const H=_+Q*(fi+sl)+fi/2,{name:I,color:M}=Mv(Z,r);c.push({id:Z.id,type:"step",label:I,color:M,cx:W,cy:H,w:Fa,h:fi}),m.set(Z.id,{cx:W,cy:H,w:Fa,h:fi})})};b(f,w),b(g,C);const j=f.length>0?_+(f.length-1)*(fi+sl)+fi/2:v,E=x?_+(g.length-1)*(fi+sl)+fi/2:v,N=Math.max(j,E)+fi/2+sl+us/2;S(N);const L=[];t&&m.has(t)&&L.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let A=0;for(const q of e)q.transitions.forEach((W,Z)=>{var $;if(!W.goto||!m.has(W.goto))return;const Q=m.get(q.id),H=m.get(W.goto),I=W.when.type==="step_result"?`${W.when.result}`:W.when.type==="metadata_all_match"?`${W.when.key??"?"}=${W.when.value??"?"}`:W.when.type==="metadata_all_in"?`${W.when.key??"?"} in [${(($=W.when.values)==null?void 0:$.join(","))??"?"}]`:qA[W.when.type]??W.when.type,M=q.id===W.goto;let V;M?V="back":H.cy>Q.cy+1?V="down":H.cy<Q.cy-1?V="back":V="same",L.push({from:q.id,to:W.goto,label:I,edgeKey:`${q.id}:${Z}`,direction:V,backEdgeIndex:V==="back"?A++:0})});const D=new Map,O=new Map,F=new Map,P=new Map;for(const q of L)q.direction==="down"&&(D.set(q.from,(D.get(q.from)??0)+1),O.set(q.to,(O.get(q.to)??0)+1));const z=new Map,K=new Map;for(const q of L){if(q.direction!=="same")continue;const W=[q.from,q.to].sort().join("|");z.set(W,(z.get(W)??0)+1)}for(const q of L){if(q.direction==="back"||q.direction==="same"){let V=0;if(q.direction==="same"){const $=[q.from,q.to].sort().join("|");V=K.get($)??0,K.set($,V+1)}h.push({...q,fromPort:0,toPort:0,sameEdgeIndex:V});continue}const W=D.get(q.from)??1,Z=O.get(q.to)??1,Q=F.get(q.from)??0,H=P.get(q.to)??0;F.set(q.from,Q+1),P.set(q.to,H+1);const I=W===1?0:-.6+1.2*Q/(W-1),M=Z===1?0:-.6+1.2*H/(Z-1);h.push({...q,fromPort:I,toPort:M,sameEdgeIndex:0})}return{nodes:c,edges:h,width:a,height:N+us/2+za,posMap:m}}function tG({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:o,isReadOnly:d,onSelectNode:u,onSelectEdge:c,onRemoveStep:h,onCreateTransition:m,onReconnectTo:f,onReconnectFrom:g,onDeleteTransition:x}){const w=k.useRef(null),C=k.useRef(!1),[v,S]=k.useState(null),[_,b]=k.useState(null),[j,E]=k.useState(null),{nodes:N,edges:L,width:A,height:D,posMap:O}=k.useMemo(()=>eG(e,t,a,o),[e,t,a,o]),F=k.useCallback(Y=>{var se;const X=w.current;if(!X)return{x:0,y:0};const U=X.createSVGPoint();U.x=Y.clientX,U.y=Y.clientY;const B=(se=X.getScreenCTM())==null?void 0:se.inverse();if(!B)return{x:0,y:0};const J=U.matrixTransform(B);return{x:J.x,y:J.y}},[]),P=k.useCallback(Y=>!Y||!_||Y==="$start"?!1:_.type==="reconnect-from"?Y!=="$done":!0,[_]),z=k.useCallback((Y,X)=>{if(d)return;Y.stopPropagation(),Y.preventDefault();const U=F(Y);b({type:"new",fromNodeId:X,mouseX:U.x,mouseY:U.y})},[F,d]),K=k.useCallback((Y,X)=>{if(d)return;Y.stopPropagation(),Y.preventDefault();const U=F(Y);b({type:"reconnect-to",fromNodeId:X.from,edgeKey:X.edgeKey,mouseX:U.x,mouseY:U.y})},[F,d]),q=k.useCallback((Y,X)=>{if(d)return;Y.stopPropagation(),Y.preventDefault();const U=F(Y);b({type:"reconnect-from",fromNodeId:X.from,fixedTargetId:X.to,edgeKey:X.edgeKey,mouseX:U.x,mouseY:U.y})},[F,d]),W=k.useCallback(Y=>{if(!_)return;const X=F(Y);b(U=>U?{...U,mouseX:X.x,mouseY:X.y}:null)},[_,F]),Z=k.useCallback(()=>{_&&(C.current=!0,j&&P(j)&&(_.type==="new"?m(_.fromNodeId,j):_.type==="reconnect-to"?f(_.edgeKey,j):_.type==="reconnect-from"&&g(_.edgeKey,j)),b(null),E(null))},[_,j,P,m,f,g]),Q=k.useCallback(()=>{if(C.current){C.current=!1;return}u(null),c(null)},[u,c]);k.useEffect(()=>{if(d)return;const Y=X=>{X.target instanceof HTMLInputElement||X.target instanceof HTMLTextAreaElement||X.target instanceof HTMLSelectElement||(X.key==="Delete"||X.key==="Backspace")&&r&&r!=="start"&&(X.preventDefault(),x(r),c(null))};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[d,r,x,c]);const H=Y=>{const X=O.get(Y.from),U=O.get(Y.to);if(!X||!U)return null;let B,J,se,ne="middle",ie,de;if(Y.direction==="down"){const pe=X.cx+Y.fromPort*(X.w/2-10),Oe=X.cy+X.h/2,$e=U.cx+Y.toPort*(U.w/2-10),Pe=U.cy-U.h/2,Ve=Pe-Oe,Ye=$e-pe;B=`M ${pe} ${Oe} C ${pe} ${Oe+Ve*.4}, ${$e-Ye*.2} ${Pe-Ve*.1}, ${$e} ${Pe}`,J=pe+($e-pe)*.5,se=Oe+Ve*.6,ie={x:pe,y:Oe},de={x:$e,y:Pe}}else if(Y.direction==="back"){const pe=Y.from===Y.to,Oe=X.cx>=A/2,$e=Y.backEdgeIndex*16,Pe=Oe?A-20-$e:20+$e;if(pe){const Ve=X.cx>=A/2,Ye=30+Y.backEdgeIndex*14,ot=X.cy-X.h/2,Ae=Ve?X.cx+X.w/2:X.cx-X.w/2,me=Ve?Ae+Ye:Ae-Ye,re=X.cx+(Ve?X.w/4:-X.w/4),_e=ot-20-Y.backEdgeIndex*10;B=`M ${Ae} ${X.cy} C ${me} ${X.cy}, ${me} ${_e}, ${re} ${ot}`,J=me+10,se=_e+4,ne="middle",ie={x:Ae,y:X.cy},de={x:re,y:ot}}else{const Ve=Oe?X.cx+X.w/2:X.cx-X.w/2,Ye=U.cx+(Oe?U.w/4:-U.w/4),ot=Math.min(X.cy,U.cy)-U.h/2-18-Y.backEdgeIndex*14;B=`M ${Ve} ${X.cy} L ${Pe} ${X.cy} L ${Pe} ${ot} L ${Ye} ${ot} L ${Ye} ${U.cy-U.h/2}`,J=Pe,se=(X.cy+ot)/2,ne=Oe?"start":"end",ie={x:Ve,y:X.cy},de={x:Ye,y:U.cy-U.h/2}}}else{const pe=U.cx>X.cx,Oe=Y.sameEdgeIndex===0?-12:12,$e=pe?X.cx+X.w/2:X.cx-X.w/2,Pe=pe?U.cx-U.w/2:U.cx+U.w/2,Ve=X.cy+Oe,Ye=U.cy+Oe,ot=($e+Pe)/2;B=`M ${$e} ${Ve} C ${ot} ${Ve}, ${ot} ${Ye}, ${Pe} ${Ye}`,J=ot,se=(Ve+Ye)/2-6,ie={x:$e,y:Ve},de={x:Pe,y:Ye}}return{path:B,labelX:J,labelY:se,labelAnchor:ne,fromPt:ie,toPt:de}},I=(Y,X)=>{const U=H(Y);if(!U)return null;const{path:B,labelX:J,labelY:se,labelAnchor:ne}=U,ie=r===Y.edgeKey,de=Y.label&&Y.label!=="otherwise";return s.jsxs("g",{children:[s.jsx("path",{d:B,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:pe=>{pe.stopPropagation(),d||c(ie?null:Y.edgeKey)}}),s.jsx("path",{d:B,fill:"none",stroke:ie?"#58a6ff":"#484f58",strokeWidth:ie?2.2:1.2,markerEnd:ie?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),de&&s.jsx("text",{x:J+(ne==="start"?5:ne==="end"?-5:0),y:se+3,textAnchor:ne,className:"text-[8px]",fill:ie?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:Y.label})]},X)},M=()=>{if(!r||_)return null;const Y=L.find(se=>se.edgeKey===r);if(!Y)return null;const X=H(Y);if(!X)return null;const{fromPt:U,toPt:B}=X,J=6;return s.jsxs(s.Fragment,{children:[Y.edgeKey!=="start"&&s.jsx("circle",{cx:U.x,cy:U.y,r:J,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>q(se,Y)}),s.jsx("circle",{cx:B.x,cy:B.y,r:J,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>K(se,Y)})]})},V=()=>{if(!_)return null;let Y,X,U,B;if(_.type==="reconnect-from"){const ne=O.get(_.fixedTargetId);if(!ne)return null;Y=_.mouseX,X=_.mouseY,U=ne.cx,B=ne.cy-ne.h/2}else{const ne=O.get(_.fromNodeId);if(!ne)return null;Y=ne.cx,X=ne.cy+ne.h/2,U=_.mouseX,B=_.mouseY}const J=B-X,se=Math.abs(J)>10?`M ${Y} ${X} C ${Y} ${X+J*.4}, ${U} ${B-J*.4}, ${U} ${B}`:`M ${Y} ${X} L ${U} ${B}`;return s.jsx("path",{d:se,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},$=Y=>{const X=Y.cy+Y.h/2,U=(_==null?void 0:_.fromNodeId)===Y.id;return s.jsx("circle",{cx:Y.cx,cy:X,r:nj,fill:U?"#58a6ff":"#1c2128",stroke:U?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:U?1:.5,className:"cursor-crosshair",onMouseDown:B=>z(B,Y.id)})},ee=Y=>{const X=Y.cy-Y.h/2,U=_&&j===Y.id&&P(Y.id);return s.jsx("circle",{cx:Y.cx,cy:X,r:nj,fill:U?"#3fb950":"#1c2128",stroke:U?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:U?1:.5})};return s.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${D}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:W,onMouseUp:Z,onClick:Q,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),s.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),L.map((Y,X)=>I(Y,X)),N.map(Y=>{const X=n===Y.id,U=Y.cx-Y.w/2,B=Y.cy-Y.h/2,J=v===Y.id,se=_&&j===Y.id&&P(Y.id);if(Y.type==="terminal"){const ie=Y.id==="$start",de=ie?"#58a6ff":"#3fb950",pe=ie,Oe=!ie;return s.jsxs("g",{onClick:$e=>{$e.stopPropagation(),ie&&!d&&c("start")},className:ie&&!d?"cursor-pointer":void 0,children:[se&&s.jsx("rect",{x:U-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:Y.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ie&&r==="start"&&s.jsx("rect",{x:U-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:Y.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:U,y:B,width:Y.w,height:Y.h,rx:Y.h/2,fill:de,fillOpacity:.08,stroke:de,strokeOpacity:.4,strokeWidth:1.5}),s.jsx("text",{x:Y.cx,y:Y.cy+4,textAnchor:"middle",fill:de,className:"text-[10px] font-medium",pointerEvents:"none",children:Y.label}),pe&&$(Y),Oe&&ee(Y)]},Y.id)}const ne=Y.color??"#6b7280";return s.jsxs("g",{onClick:ie=>{ie.stopPropagation(),d||u(X?null:Y.id)},onMouseEnter:()=>S(Y.id),onMouseLeave:()=>S(null),className:d?void 0:"cursor-pointer",children:[se&&s.jsx("rect",{x:U-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),X&&s.jsx("rect",{x:U-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:U,y:B,width:Y.w,height:Y.h,rx:10,fill:ne,fillOpacity:.08,stroke:ne,strokeOpacity:.6,strokeWidth:X?2:1.5}),s.jsx("text",{x:Y.cx,y:Y.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:Y.label}),!d&&$(Y),!d&&ee(Y),J&&!_&&!d&&s.jsxs("g",{onClick:ie=>{ie.stopPropagation(),h(Y.id)},className:"cursor-pointer",children:[s.jsx("circle",{cx:U+Y.w-2,cy:B+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),s.jsx("line",{x1:U+Y.w-5,y1:B-1,x2:U+Y.w+1,y2:B+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),s.jsx("line",{x1:U+Y.w+1,y1:B-1,x2:U+Y.w-5,y2:B+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},Y.id)}),_&&N.map(Y=>P(Y.id)?s.jsx("rect",{x:Y.cx-Y.w/2-8,y:Y.cy-Y.h/2-8,width:Y.w+16,height:Y.h+16,fill:"transparent",rx:12,onMouseEnter:()=>E(Y.id),onMouseLeave:()=>E(null),onMouseUp:X=>{X.stopPropagation(),Z()}},`drop-${Y.id}`):null),V(),M()]})}const Lh="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",Xc="block text-[11px] text-text-secondary mb-0.5";function nG({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:o,onNameChange:d,onDescriptionChange:u,onMaxIterationsChange:c,onColorChange:h}){return s.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[s.jsxs("div",{className:"min-w-[140px]",children:[s.jsx("label",{className:Xc,children:"Name"}),s.jsx("input",{value:e,onChange:m=>d(m.target.value),placeholder:"Workflow name",className:`${Lh} ${o?"opacity-50":""}`,readOnly:o})]}),s.jsxs("div",{className:"min-w-[100px]",children:[s.jsx("label",{className:Xc,children:"ID"}),s.jsx("input",{value:t,readOnly:!0,className:`${Lh} font-mono opacity-50`})]}),s.jsxs("div",{className:"flex-1 min-w-[140px]",children:[s.jsx("label",{className:Xc,children:"Description"}),s.jsx("input",{value:n,onChange:m=>!o&&u(m.target.value),readOnly:o,placeholder:"What does this workflow do?",className:`${Lh} ${o?"opacity-50":""}`})]}),s.jsxs("div",{className:"w-20",children:[s.jsx("label",{className:Xc,children:"Max Iter."}),s.jsx("input",{type:"number",value:r,onChange:m=>!o&&c(Number(m.target.value)),readOnly:o,className:`${Lh} font-mono ${o?"opacity-50":""}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:Xc,children:"Color"}),s.jsx("input",{type:"color",value:a,onChange:m=>!o&&h(m.target.value),disabled:o,className:`w-8 h-8 rounded border border-border bg-transparent ${o?"opacity-50":"cursor-pointer"}`})]})]})}function rG({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:o}){return s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:o})]})}function Wx({title:e,items:t,renderActions:n}){return t.length===0?null:s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t.map(r=>s.jsx(rG,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const Ha="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Gx="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",As="block text-[11px] text-text-secondary mb-0.5";function qx({variables:e,onInsert:t}){return e.length===0?null:s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>s.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 sG({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:o,onRemove:d,onSetEntry:u}){const{color:c,name:h}=Mv(e,n);return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:c+"20",color:c},children:h}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[!t&&s.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),s.jsx("button",{onClick:d,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Name"}),s.jsx("input",{value:e.name,onChange:m=>o({...e,name:m.target.value}),placeholder:"Step name",className:Ha})]}),s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Type"}),s.jsx("select",{value:e.type,onChange:m=>{const f=m.target.value,g=f==="sub_agent"?"verification":"build";if(f==="agent"){const x=n.find(w=>!w.subagent);o({...e,type:f,phase:g,agentId:(x==null?void 0:x.id)??"builder",name:(x==null?void 0:x.name)??"Agent"})}else if(f==="sub_agent"){const x=n.find(w=>w.subagent);o({...e,type:f,phase:g,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else o(f==="user"?{...e,type:f,phase:g,name:"User"}:{...e,type:f,phase:g,name:"Shell"})},className:Gx,children:ZW.map(m=>s.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.type==="agent"&&s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Agent Type"}),s.jsx("select",{value:e.agentId??"builder",onChange:m=>{const f=n.find(g=>g.id===m.target.value);o({...e,agentId:m.target.value,name:(f==null?void 0:f.name)??m.target.value})},className:Gx,children:n.filter(m=>!m.subagent).map(m=>s.jsx("option",{value:m.id,children:m.name},m.id))})]}),e.type==="sub_agent"&&s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Sub-Agent Type"}),s.jsxs("select",{value:e.subAgentType??"",onChange:m=>{const f=n.find(g=>g.id===m.target.value);o({...e,subAgentType:m.target.value,name:(f==null?void 0:f.name)??m.target.value})},className:Gx,children:[s.jsx("option",{value:"",children:"— select —"}),n.filter(m=>m.subagent).map(m=>s.jsx("option",{value:m.id,children:m.name},m.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Prompt"}),s.jsx("textarea",{value:e.prompt??"",onChange:m=>o({...e,prompt:m.target.value||void 0}),rows:6,className:`${Ha} resize-y text-xs`,placeholder:"Injected on first entry..."}),s.jsx(qx,{variables:a,onInsert:m=>o({...e,prompt:(e.prompt??"")+`{{${m}}}`})})]}),s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Nudge Prompt"}),s.jsx("textarea",{value:e.nudgePrompt??"",onChange:m=>o({...e,nudgePrompt:m.target.value||void 0}),rows:6,className:`${Ha} resize-y text-xs`,placeholder:"Injected on re-entry..."}),s.jsx(qx,{variables:a,onInsert:m=>o({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${m}}}`})})]})]}),e.type==="shell"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Command"}),s.jsx("textarea",{value:e.command??"",onChange:m=>o({...e,command:m.target.value}),rows:3,className:`${Ha} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),s.jsx(qx,{variables:a,onInsert:m=>o({...e,command:(e.command??"")+`{{${m}}}`})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Timeout (ms)"}),s.jsx("input",{type:"number",value:e.timeout??6e4,onChange:m=>o({...e,timeout:Number(m.target.value)}),className:`${Ha} font-mono text-xs`})]}),s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Success Codes"}),s.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:m=>o({...e,successExitCodes:m.target.value.split(",").map(f=>Number(f.trim())).filter(f=>!isNaN(f))}),className:`${Ha} font-mono text-xs`})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:As,children:"Sub-group"}),s.jsx("input",{value:e.subGroup??"",onChange:m=>o({...e,subGroup:m.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Ha})]}),s.jsx("div",{className:"pt-1 border-t border-border/50",children:s.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const il="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",rj="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Ua="block text-[11px] text-text-secondary mb-0.5";function iG({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:o,transitionIndex:d,totalTransitions:u,onUpdateCondition:c,onUpdateSubGroup:h,onDelete:m,onMoveUp:f,onMoveDown:g}){var C;const x=a&&(a.type==="sub_agent"||a.type==="agent")?o.find(v=>v.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(x==null?void 0:x.results)&&x.results.length>0;return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",d+1]}),u>1&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsx("button",{onClick:f,disabled:d===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:s.jsx(gn,{className:"w-3 h-3",rotate:180})}),s.jsx("button",{onClick:g,disabled:d===u-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:s.jsx(gn,{className:"w-3 h-3"})})]})]}),s.jsx("button",{onClick:m,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:e}),s.jsx(Gf,{}),s.jsx("span",{className:"font-medium text-text-primary",children:t})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ua,children:"Condition"}),s.jsx("select",{value:n.type,onChange:v=>{c(v.target.value==="step_result"?{type:"step_result",result:"success"}:{type:v.target.value})},className:rj,children:KA.map(v=>s.jsx("option",{value:v.value,children:v.label},v.value))})]}),n.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:Ua,children:"Result"}),w?s.jsx("select",{value:n.result??x.results[0],onChange:v=>{c({type:"step_result",result:v.target.value})},className:rj,children:x.results.map(v=>s.jsx("option",{value:v,children:v},v))}):s.jsx("input",{type:"text",value:n.result??"success",onChange:v=>c({type:"step_result",result:v.target.value}),placeholder:"e.g. success, passed, failed",className:il})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Ua,children:"Metadata Key"}),s.jsx("input",{type:"text",value:n.key??"",onChange:v=>c({...n,key:v.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:il})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ua,children:"Field"}),s.jsx("input",{type:"text",value:n.field??"",onChange:v=>c({...n,field:v.target.value}),placeholder:"e.g. status",className:il})]}),n.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:Ua,children:"Value"}),s.jsx("input",{type:"text",value:n.value??"",onChange:v=>c({...n,value:v.target.value}),placeholder:"e.g. passed, resolved",className:il})]}):s.jsxs("div",{children:[s.jsx("label",{className:Ua,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:v=>c({...n,values:v.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:il})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ua,children:"Sub-group"}),s.jsx("input",{type:"text",value:r??"",onChange:v=>h(v.target.value||void 0),placeholder:"e.g. build, verify",className:il})]}),(a==null?void 0:a.type)==="user"&&s.jsxs("div",{className:"pt-1 border-t border-border/50 space-y-1",children:[s.jsx("p",{className:"text-text-muted text-[10px]",children:'On a user step, each "Step result is..." transition becomes a choice button; "Always" becomes a Continue button.'}),n.type==="step_result"&&a.transitions.filter(v=>v.when.type==="step_result"&&v.when.result===n.result).length>1&&s.jsxs("p",{className:"text-accent-warning text-[10px]",children:['Duplicate result "',n.result,'" — only the first matching transition is reachable.']}),n.type==="step_result"&&n.result==="continue"&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'"continue" is reserved for the "Always" Continue button — rename this result.'}),n.type==="always"&&a.transitions.some((v,S)=>S>d&&v.when.type==="step_result")&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'This "Always" transition comes before one or more choice transitions — those choice buttons are unreachable. Move it to the end.'}),n.type==="always"&&a.transitions.filter(v=>v.when.type==="always").length>1&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'Multiple "Always" transitions — only the first is reachable.'})]}),s.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function aG(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function oG(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Qc="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",sj="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",al="block text-[11px] text-text-secondary mb-0.5",ij=[];function YA({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){var xt,Mt;const a=Gt(ke=>ke.defaults),o=Gt(ke=>ke.userItems),d=Gt(ke=>ke.projectItems),u=Gt(ke=>ke.loading),c=Gt(ke=>ke.templateVariables),h=Gt(ke=>ke.fetchWorkflows),m=Gt(ke=>ke.fetchWorkflow),f=Gt(ke=>ke.fetchDefaultContent),g=Gt(ke=>ke.fetchTemplateVariables),x=Gt(ke=>ke.createWorkflow),w=Gt(ke=>ke.updateWorkflow),C=Gt(ke=>ke.deleteWorkflow),{requestDelete:v,clearConfirm:S,isConfirming:_}=Au(),[b,j]=k.useState("list"),[E,N]=k.useState(null),[L,A]=k.useState(void 0),[D,O]=k.useState(!1),[F,P]=k.useState(null),[z,K]=k.useState(null),[q,W]=k.useState(""),[Z,Q]=k.useState(""),[H,I]=k.useState(""),[M,V]=k.useState("1.0.0"),[$,ee]=k.useState("#3b82f6"),[Y,X]=k.useState(""),[U,B]=k.useState(50),[J,se]=k.useState(ij),[ne,ie]=k.useState({type:"always"}),[de,pe]=k.useState([]),[Oe,$e]=k.useState("user"),[Pe,Ve]=k.useState(""),[Ye,ot]=k.useState(!1),Ae=ft(ke=>ke.defaults),me=ft(ke=>ke.userItems),re=ft(ke=>ke.projectItems),_e=k.useMemo(()=>[...Ae,...me,...re],[Ae,me,re]),Me=ft(ke=>ke.fetchAgents),[ce]=k.useState(null);k.useEffect(()=>{e&&(h(r),g(),Me(),P(null),K(null),n?a.some(Ee=>Ee.id===n)?f(n,r).then(Ee=>{Ee&&Ne({...Ee,metadata:{...Ee.metadata,name:Ee.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):m(n,r).then(Ee=>{Ee&&Ne(Ee,{editingId:n,isReadOnly:!1})}):(j("list"),N(null),O(!1)))},[e,h,m,f,g,n,r]);const Ne=(ke,Ee)=>{W(ke.metadata.name),Q(ke.metadata.id),I(ke.metadata.description),V(ke.metadata.version),ee(ke.metadata.color??"#3b82f6"),X(ke.entryStep),B(ke.settings.maxIterations),se(ke.steps),ie(ke.startCondition??{type:"always"}),pe(ke.metadata.parameters??[]),Ve(""),(Ee==null?void 0:Ee.editingId)!==void 0&&N(Ee.editingId),(Ee==null?void 0:Ee.isReadOnly)!==void 0&&O(Ee.isReadOnly),(Ee==null?void 0:Ee.selectedNodeKey)!==void 0&&P(null),(Ee==null?void 0:Ee.selectedEdgeKey)!==void 0&&K(null),j("edit")},Xe=async(ke,Ee)=>{A(Ee);const Fe=await m(ke,r,Ee);Fe&&Ne(Fe,{editingId:ke,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},at=async()=>{var bt;const ke=E??Z;if(!ke||!q)return Ve("Name is required."),!1;if(J.length===0)return Ve("Add at least one step."),!1;const Ee=de.find(jt=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(jt.id));if(Ee)return Ve(`Invalid parameter ID "${Ee.id}". Use letters, digits, and underscores only.`),!1;let Fe=Y;if(!Fe||!J.some(jt=>jt.id===Fe)){if(Fe=((bt=J.find(jt=>jt.id))==null?void 0:bt.id)??"",!Fe)return Ve("All steps need an ID."),!1;X(Fe)}ot(!0),Ve("");const Je={metadata:{id:ke,name:q,description:H,version:M||"1.0.0",color:$,...de.length>0?{parameters:de}:{}},entryStep:Fe,settings:{maxIterations:U},steps:J,startCondition:ne},st=E?await w(E,Je,r,L):await x(Je,Oe,r);return ot(!1),st.success?(E||N(ke),!0):(Ve(st.error??"Failed to save."),!1)},fe=async()=>{await at()},We=async()=>{await at()&&(n?t():j("list"))},Ze=()=>{n?t():j("list")},it=ke=>{W(ke),E||Q(aG(ke))},nt=async(ke,Ee)=>a.some(Je=>Je.id===ke)?await f(ke,r):await m(ke,r,Ee),De=async(ke,Ee)=>{const Fe=await nt(ke,Ee);Fe&&Ne({...Fe,metadata:{...Fe.metadata,name:Fe.metadata.name+" (copy)",id:`${ke}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Re=()=>{N(null),A(void 0),W(""),Q(""),I(""),V("1.0.0"),ee("#3b82f6"),X(""),B(50),se(structuredClone(ij)),ie({type:"always"}),pe([]),$e("user"),Ve(""),P(null),K(null),O(!1),j("edit")},Se=async(ke,Ee)=>{await C(ke,Ee,r),S()},Ue=k.useCallback(ke=>{P(ke),K(null)},[]),ve=k.useCallback(ke=>{K(ke),P(null)},[]),tt=F!==null?Number(F):-1,et=tt>=0?J[tt]??null:null,dt=k.useCallback(ke=>{se(Ee=>Ee.map((Fe,Je)=>Je===tt?ke:Fe))},[tt]),Lt=ne.type==="step_result"?`${ne.result}`:ne.type==="metadata_all_match"?`${ne.key??"?"}=${ne.value??"?"}`:ne.type==="metadata_all_in"?`${ne.key??"?"} in [${((xt=ne.values)==null?void 0:xt.join(","))??"?"}]`:qA[ne.type]??ne.type,qt=()=>{const ke=J.length,Ee=oG(J),Fe=_e.find(Je=>!Je.subagent);se([...J,{id:Ee,name:(Fe==null?void 0:Fe.name)??"Agent",type:"agent",phase:"build",agentId:(Fe==null?void 0:Fe.id)??"builder",transitions:[]}]),Y||X(Ee),Ue(String(ke))},vn=k.useCallback((ke,Ee)=>{ke==="$start"?(X(Ee),ve("start")):se(Fe=>{const Je=Fe.find(bt=>bt.id===ke),st=Je?Je.transitions.length:0;return ve(`${ke}:${st}`),Fe.map(bt=>bt.id===ke?{...bt,transitions:[...bt.transitions,{when:{type:"always"},goto:Ee}]}:bt)})},[ve]),_n=ke=>{if(ke==="start")return null;const Ee=ke.lastIndexOf(":"),Fe=ke.slice(0,Ee),Je=parseInt(ke.slice(Ee+1));return{stepId:Fe,transIdx:Je}},xn=k.useCallback((ke,Ee)=>{const Fe=_n(ke);Fe&&se(Je=>Je.map(st=>st.id===Fe.stepId?{...st,transitions:st.transitions.map((bt,jt)=>jt===Fe.transIdx?Ee(bt):bt)}:st))},[]),hr=k.useCallback((ke,Ee)=>{if(ke==="start"){X(Ee);return}xn(ke,Fe=>({...Fe,goto:Ee}))},[xn]),be=k.useCallback((ke,Ee)=>{const Fe=_n(ke);Fe&&(se(Je=>{const st=Je.find(jt=>jt.id===Fe.stepId);if(!st)return Je;const bt=st.transitions[Fe.transIdx];return bt?Je.map(jt=>jt.id===Fe.stepId?{...jt,transitions:jt.transitions.filter((In,Cn)=>Cn!==Fe.transIdx)}:jt.id===Ee?{...jt,transitions:[...jt.transitions,bt]}:jt):Je}),K(null))},[]),rt=k.useCallback(ke=>{if(ke==="start"){X(""),K(null);return}const Ee=_n(ke);Ee&&(se(Fe=>Fe.map(Je=>Je.id===Ee.stepId?{...Je,transitions:Je.transitions.filter((st,bt)=>bt!==Ee.transIdx)}:Je)),K(null))},[]),Qe=k.useCallback((ke,Ee)=>{if(ke==="start"){ie(Ee);return}xn(ke,Fe=>({...Fe,when:Ee}))},[xn]),He=k.useCallback((ke,Ee)=>{ke!=="start"&&xn(ke,Fe=>({...Fe,subGroup:Ee||void 0}))},[xn]),le=ke=>Mv(ke,_e).name,Ke=()=>{if(!z)return null;if(z==="start"){const In=J.find(Cn=>Cn.id===Y);return{type:"start",fromLabel:"Start",toLabel:In?le(In):"(none)",condition:ne}}const ke=z.lastIndexOf(":"),Ee=z.slice(0,ke),Fe=parseInt(z.slice(ke+1)),Je=J.find(In=>In.id===Ee);if(!Je)return null;const st=Je.transitions[Fe];if(!st)return null;const bt=J.find(In=>In.id===st.goto),jt=st.goto==="$done"?"Done":bt?le(bt):st.goto;return{type:"step",fromLabel:le(Je),toLabel:jt,condition:st.when,subGroup:st.subGroup}};if(b==="edit"){const ke=Ke();return s.jsxs(Et,{isOpen:e,onClose:Ze,title:D?q:E?"Edit Workflow":"New Workflow",size:"full",children:[Pe&&s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:Pe}),s.jsx(nG,{formName:q,formId:Z,formDescription:H,formMaxIterations:U,formColor:$,isReadOnly:D,onNameChange:it,onDescriptionChange:I,onMaxIterationsChange:B,onColorChange:ee}),!D&&s.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:s.jsxs(JW,{title:`Parameters (${de.length})`,children:[de.map((Ee,Fe)=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{value:Ee.id,onChange:Je=>{const st=[...de];st[Fe]={...Ee,id:Je.target.value},pe(st)},placeholder:"ID",className:"w-28 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("input",{value:Ee.label,onChange:Je=>{const st=[...de];st[Fe]={...Ee,label:Je.target.value},pe(st)},placeholder:"Label",className:"w-36 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("input",{value:Ee.description??"",onChange:Je=>{const st=[...de];st[Fe]={...Ee,description:Je.target.value||void 0},pe(st)},placeholder:"Description",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[s.jsx("input",{type:"checkbox",checked:Ee.required??!1,onChange:Je=>{const st=[...de];st[Fe]={...Ee,required:Je.target.checked||void 0},pe(st)},className:"rounded border-border"}),"Req."]}),s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>{Fe!==0&&pe(de.map((Je,st)=>st===Fe?{...de[Fe-1],position:st}:st===Fe-1?{...de[Fe],position:st}:{...Je,position:st}))},disabled:Fe===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${Ee.label||Ee.id} up`,children:"▲"}),s.jsx("button",{onClick:()=>{Fe!==de.length-1&&pe(de.map((Je,st)=>st===Fe?{...de[Fe+1],position:st}:st===Fe+1?{...de[Fe],position:st}:{...Je,position:st}))},disabled:Fe===de.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${Ee.label||Ee.id} down`,children:"▼"})]}),s.jsx("button",{onClick:()=>pe(de.filter((Je,st)=>st!==Fe)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},Ee.id)),s.jsx("button",{onClick:()=>{const Ee=`param_${de.length+1}`;pe([...de,{id:Ee,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!E&&!D&&s.jsx(Zf,{value:Oe,onChange:$e}),s.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[s.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!D&&s.jsx("button",{onClick:qt,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),s.jsxs(mt,{className:"flex-1 min-h-0 p-2",children:[s.jsx(tG,{steps:J,entryStep:Y,selectedNodeId:(et==null?void 0:et.id)??null,selectedEdgeKey:z,startConditionLabel:Lt,agentTypes:_e,isReadOnly:D,onSelectNode:Ee=>{if(Ee===null){Ue(null);return}const Fe=J.findIndex(Je=>Je.id===Ee);Ue(Fe>=0?String(Fe):null)},onSelectEdge:ve,onRemoveStep:Ee=>{var Je;const Fe=J.findIndex(st=>st.id===Ee);if(se(st=>st.filter(bt=>bt.id!==Ee)),tt===Fe&&Ue(null),Y===Ee){const st=J.filter(bt=>bt.id!==Ee);X(((Je=st[0])==null?void 0:Je.id)??"")}},onCreateTransition:vn,onReconnectTo:hr,onReconnectFrom:be,onDeleteTransition:rt}),J.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[s.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),s.jsx("button",{onClick:qt,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"})]})]})]}),s.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[s.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),s.jsx(mt,{className:"p-3 flex-1 min-h-0",children:D&&(ke||et)?s.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):ke?ke.type==="start"?s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),Y&&s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),s.jsx(Gf,{}),s.jsx("span",{className:"text-text-primary font-medium",children:ke.toLabel})]}),s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Activation Condition"}),s.jsx("select",{value:ne.type,onChange:Ee=>ie(Ee.target.value==="step_result"?{type:"step_result",result:"success"}:Ee.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Ee.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Ee.target.value}),className:sj,children:KA.map(Ee=>s.jsx("option",{value:Ee.value,children:Ee.label},Ee.value))})]}),ne.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Result"}),Y&&(()=>{const Ee=J.find(bt=>bt.id===Y),Fe=Ee&&(Ee.type==="sub_agent"||Ee.type==="agent")?_e.find(bt=>bt.id===(Ee.type==="sub_agent"?Ee.subAgentType:Ee.agentId)):void 0,Je=(Fe==null?void 0:Fe.results)&&Fe.results.length>0,st=(Fe==null?void 0:Fe.results)??[];return Je?s.jsx("select",{value:ne.result??st[0],onChange:bt=>ie({type:"step_result",result:bt.target.value}),className:sj,children:st.map(bt=>s.jsx("option",{value:bt,children:bt},bt))}):s.jsx("input",{type:"text",value:ne.result??"success",onChange:bt=>ie({type:"step_result",result:bt.target.value}),placeholder:"e.g. success, passed, failed",className:Qc})})()]}),(ne.type==="metadata_all_match"||ne.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Metadata Key"}),s.jsx("input",{type:"text",value:ne.key??"",onChange:Ee=>ie({...ne,key:Ee.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Qc})]}),s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Field"}),s.jsx("input",{type:"text",value:ne.field??"",onChange:Ee=>ie({...ne,field:Ee.target.value}),placeholder:"e.g. status",className:Qc})]}),ne.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Value"}),s.jsx("input",{type:"text",value:ne.value??"",onChange:Ee=>ie({...ne,value:Ee.target.value}),placeholder:"e.g. passed, resolved",className:Qc})]}):s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((Mt=ne.values)==null?void 0:Mt.join(", "))??"",onChange:Ee=>ie({...ne,values:Ee.target.value.split(",").map(Fe=>Fe.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Qc})]})]}),s.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 Ee=_n(z),Fe=Ee==null?void 0:Ee.stepId,Je=(Ee==null?void 0:Ee.transIdx)??0,st=Fe?J.find(jt=>jt.id===Fe):void 0,bt=(st==null?void 0:st.transitions.length)??0;return s.jsx(iG,{fromLabel:ke.fromLabel,toLabel:ke.toLabel,condition:ke.condition,subGroup:"subGroup"in ke?ke.subGroup:void 0,fromStep:ke.type==="step"?J.find(jt=>jt.id===ke.fromLabel):void 0,agentTypes:_e,transitionIndex:Je,totalTransitions:bt,onUpdateCondition:jt=>Qe(z,jt),onUpdateSubGroup:jt=>He(z,jt),onDelete:()=>rt(z),onMoveUp:()=>{se(jt=>{const In=jt.find(Tn=>Tn.id===Fe);if(!In||Je===0)return jt;const Cn=[...In.transitions];return[Cn[Je-1],Cn[Je]]=[Cn[Je],Cn[Je-1]],jt.map(Tn=>Tn.id===Fe?{...Tn,transitions:Cn}:Tn)}),K(`${Fe}:${Je-1}`)},onMoveDown:()=>{se(jt=>{const In=jt.find(Tn=>Tn.id===Fe);if(!In||Je===In.transitions.length-1)return jt;const Cn=[...In.transitions];return[Cn[Je],Cn[Je+1]]=[Cn[Je+1],Cn[Je]],jt.map(Tn=>Tn.id===Fe?{...Tn,transitions:Cn}:Tn)}),K(`${Fe}:${Je+1}`)}})})():et?s.jsx(sG,{step:et,isEntry:et.id===Y,agentTypes:_e,transitionCount:et.transitions.length,templateVariables:c,onUpdate:dt,onRemove:()=>{var Ee;if(et&&(se(J.filter((Fe,Je)=>Je!==tt)),Ue(null),Y===et.id)){const Fe=J.filter((Je,st)=>st!==tt);X(((Ee=Fe[0])==null?void 0:Ee.id)??"")}},onSetEntry:()=>X(et.id)}):s.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",s.jsx("br",{}),"Drag from a port to connect."]})})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[s.jsx(ct,{variant:"secondary",onClick:Ze,children:"Close"}),D?s.jsx(ct,{variant:"primary",onClick:()=>{W(q+" (copy)"),Q(`${E}-copy-${Date.now()}`),N(null),O(!1)},children:"Duplicate & Customize"}):s.jsxs(s.Fragment,{children:[s.jsx(ct,{variant:"primary",onClick:fe,children:"Save"}),s.jsx(ct,{variant:"primary",onClick:We,children:"Save & Close"})]})]})]})}return s.jsx(Et,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:s.jsx(zE,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Re,loading:u,hasItems:a.length>0||o.length>0||d.length>0,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(Wx,{title:"Built-in",items:a,renderActions:ke=>s.jsx(s.Fragment,{children:s.jsx(wi,{onClick:()=>De(ke.id),children:s.jsx(Eb,{})})})}),s.jsx(Wx,{title:"Custom",items:o,renderActions:ke=>s.jsxs(s.Fragment,{children:[s.jsx(wi,{onClick:()=>Xe(ke.id,"user"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(yu,{onClick:()=>De(ke.id,"user")}),_(`user:${ke.id}`,"delete")?s.jsx(tf,{onConfirm:()=>Se(ke.id,"user"),onCancel:S}):s.jsx(nf,{onClick:()=>v(`user:${ke.id}`)})]})}),d.length>0&&s.jsx(Wx,{title:"Project",items:d,renderActions:ke=>s.jsxs(s.Fragment,{children:[s.jsx(wi,{onClick:()=>Xe(ke.id,"project"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(yu,{onClick:()=>De(ke.id,"project")}),_(`project:${ke.id}`,"delete")?s.jsx(tf,{onConfirm:()=>Se(ke.id,"project"),onCancel:S}):s.jsx(nf,{onClick:()=>v(`project:${ke.id}`)})]})})]})})})}function lG(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function cG({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:o,textareaContent:d,onSearchMessages:u,onToggleAutoScroll:c,isAutoScrollActive:h}){const[,m]=Fn(),f=cn(Y=>Y.fetchCommands),g=Gt(Y=>Y.fetchWorkflows),x=ft(Y=>Y.fetchAgents),w=cn(Y=>Y.defaults),C=cn(Y=>Y.userItems),v=cn(Y=>Y.projectItems),S=Gt(Y=>Y.defaults),_=Gt(Y=>Y.userItems),b=Gt(Y=>Y.projectItems),j=ft(Y=>Y.defaults),E=ft(Y=>Y.userItems),N=ft(Y=>Y.projectItems),L=jr(),A=on(L,Y=>{var X;return((X=Y.session)==null?void 0:X.mode)??null},Y=>{var X;return((X=Y.currentSession)==null?void 0:X.mode)??null},null),D=on(L,Y=>{var X;return((X=Y.session)==null?void 0:X.dangerLevel)??"normal"},Y=>{var X;return((X=Y.currentSession)==null?void 0:X.dangerLevel)??"normal"},"normal"),O=Le(Y=>Y.switchMode),F=Le(Y=>Y.switchDangerLevel),P=on(L,Y=>{var X;return((X=Y.session)==null?void 0:X.projectId)??null},Y=>{var X;return((X=Y.currentSession)==null?void 0:X.projectId)??null},null),z=on(L,Y=>{var X;return((X=Y.session)==null?void 0:X.workdir)??void 0},Y=>{var X;return(X=Y.currentSession)==null?void 0:X.workdir},void 0),K=k.useRef(void 0),[q,W]=k.useState(""),[Z,Q]=k.useState(0),H=k.useRef(null),I=k.useRef(!1);k.useEffect(()=>{e&&(I.current=!0)},[e]),k.useEffect(()=>{if(e){f(z),g(z),x(z),W(""),Q(0);const Y=setTimeout(()=>{var X;Wt()&&((X=H.current)==null||X.focus())},50);return()=>clearTimeout(Y)}},[e,f,g,x,z]),k.useEffect(()=>{var Y;!e&&I.current&&(n==null||n(),(Y=K.current)==null||Y.call(K),K.current=void 0)},[e,n]);const V=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const Y=P??lG(window.location.pathname);Y&&m(`/p/${Y}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{K.current=o,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),u==null||u()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),c==null||c(!h)}},...Gn(Gn(j,E),N).filter(Y=>!Y.subagent&&Y.id!==A).map(Y=>({id:Y.id,name:Y.name,prefix:"Agent > Switch to",action:()=>L&&O(L,Y.id)})),...Gn(Gn(w,C),v).map(Y=>({id:Y.id,name:Y.name,prefix:"Command > Launch",action:()=>r(Y.id,d)})),...Gn(Gn(S,_),b).map(Y=>({id:Y.id,name:Y.name,prefix:"Workflow > Run",action:()=>a(Y.id,Y.scope)})),...["normal","dangerous"].filter(Y=>Y!==D).map(Y=>({id:Y,name:Y.charAt(0).toUpperCase()+Y.slice(1),prefix:"Mode > Switch to",action:()=>L&&F(L,Y)}))].filter(Y=>oa(`${Y.prefix} ${Y.name}`,q)),$=V.length-1,ee=Y=>{jv(Y,$,Q,()=>{var X;(X=V[Z])==null||X.action(),t()},t)};return e?Cs.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx("input",{ref:H,type:"text",value:q,onChange:Y=>{W(Y.target.value),Q(0)},onKeyDown:ee,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx(Rb,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),s.jsx(mt,{className:"max-h-[60vh] p-2",children:V.length===0?s.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+_.length>0?"No matches":"No agents, commands, or workflows yet"}):V.map((Y,X)=>s.jsxs("button",{type:"button",onClick:()=>{Y.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${X===Z?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[s.jsxs("span",{className:"text-text-muted font-normal",children:[Y.prefix," "]}),s.jsx("span",{children:Y.name})]},Y.id))})]})]}),document.body):null}const XA="openfox-message-search-filters",uG=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function dG(){try{const e=localStorage.getItem(XA);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function hG(e){localStorage.setItem(XA,JSON.stringify([...e]))}function fG(e){var n,r;if(e.type!=="message")return null;const t=e.message;if(t.role==="user")return"user";if(t.role==="assistant"){if((n=t.content)!=null&&n.trim())return"response";if((r=t.thinkingContent)!=null&&r.trim())return"thinking"}return null}function mG(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),d=String(t.getDate()).padStart(2,"0"),u=String(t.getHours()).padStart(2,"0"),c=String(t.getMinutes()).padStart(2,"0");return`${a}/${o}/${d} ${u}:${c}`}function pG(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 gG(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const a=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!a?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function xG(e){var n,r;if(e.type!=="message")return s.jsx(L1,{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())?s.jsx(pO,{className:"w-3.5 h-3.5"}):s.jsx(L1,{className:"w-3.5 h-3.5"}):s.jsx(mO,{className:"w-3.5 h-3.5"})}function aj(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",a=r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(n.messageKind==="workflow-started")try{return`Workflow: ${JSON.parse(r).workflowName}`}catch{return"Workflow started"}if(n.messageKind==="task-completed")return"Task completed";if(n.messageKind==="auto-prompt")return"Auto-prompt";if(n.messageKind==="correction")return"Correction";if(n.messageKind==="context-reset")return"Context reset";if(n.messageKind==="command")return"Command executed";if(n.role==="assistant")return a?a.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const o=a.slice(0,200);return o.length<a.length?`${o}...`:o}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function yG({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,o]=k.useState(""),[d,u]=k.useState(0),[c,h]=k.useState(dG),m=k.useRef(null),f=k.useRef(null),g=k.useRef(null),x=E=>{h(N=>{const L=new Set(N);return L.has(E)?L.delete(E):L.add(E),hG(L),L})},w=k.useMemo(()=>n.filter(E=>{var N,L;return!(E.type==="context-divider"||E.type==="message"&&(E.message.messageKind==="auto-prompt"||E.message.role==="assistant"&&!((N=E.message.content)!=null&&N.trim())&&!((L=E.message.thinkingContent)!=null&&L.trim())))}),[n]),C=k.useMemo(()=>w.filter(E=>{const N=fG(E);return!(N&&!c.has(N))}),[w,c]),v=k.useMemo(()=>a?w.filter(E=>{const N=aj(E);return oa(N,a)}):C,[C,a]),S=v.length-1;k.useEffect(()=>{if(e){o(""),u(0);const E=setTimeout(()=>{var N;Wt()&&((N=m.current)==null||N.focus())},50);return()=>clearTimeout(E)}},[e]),k.useEffect(()=>{var E;if(e&&f.current){const N=(E=f.current.osInstance())==null?void 0:E.elements().viewport;N&&(N.scrollTop=N.scrollHeight)}},[e]),k.useEffect(()=>{g.current&&g.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[d]);const _=E=>{jv(E,S,u,()=>{const N=v[d];if(N){const L=n.indexOf(N);L>=0&&r(L),t()}},t)},b=E=>{const N=n.indexOf(E);N>=0&&r(N),t()},j=E=>n.indexOf(E);return e?Cs.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx(Fs,{}),s.jsx("input",{ref:m,type:"text",value:a,onChange:E=>{o(E.target.value),u(0)},onKeyDown:_,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.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:s.jsx(ws,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:uG.map(E=>{const N=c.has(E.key);return s.jsx("button",{type:"button",onClick:()=>x(E.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${N?"bg-accent-primary/20 text-accent-primary border border-accent-primary/40":"bg-bg-tertiary text-text-muted border border-border hover:text-text-secondary"}`,children:E.label},E.key)})}),s.jsx(mt,{ref:f,className:"max-h-[60vh] p-2",children:v.length===0?s.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:C.length>0?"No matches":"No messages yet"}):v.map((E,N)=>{const L=j(E),A=xG(E),D=aj(E),O=gG(E),F=pG(E),P=E.type==="message"&&E.message.role==="user";return s.jsx("button",{ref:N===d?g:null,type:"button",onClick:()=>b(E),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${N===d?"bg-accent-primary/20 text-text-primary":P?"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:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[s.jsx("span",{className:"flex-shrink-0",children:A}),s.jsx("span",{className:`truncate flex-1 ${O}`,children:D})]}),F&&s.jsx("span",{className:"text-text-muted text-xs shrink-0",children:mG(F)})]})},`${L}-${E.type}`)})})]})]}),document.body):null}function QA(e){const t=new Set,n=[],r=/\{\{(\w+)\}\}/g;let a;for(;(a=r.exec(e))!==null;){const o=a[1];t.has(o)||(t.add(o),n.push(o))}return n}function bG(e,t,n){const r=e.trim();if(!r.startsWith("/"))return null;const a=r.slice(1).split(/\s+/),o=a[0];if(!o)return null;const d=a.slice(1),u={},c=t.find(h=>h.id===o);return c?(c.parameters&&c.parameters.length>0?[...c.parameters].sort((m,f)=>(m.position??0)-(f.position??0)).forEach((m,f)=>{d[f]!==void 0&&(u[m.id]=d[f])}):d.forEach((h,m)=>{u[String(m)]=h}),{workflowId:o,params:u}):n&&n.find(m=>m.id===o)?(d.forEach((m,f)=>{u[String(f)]=m}),{commandId:o,params:u}):null}function vG({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const o=k.useRef(null),d=k.useRef(null);k.useEffect(()=>{var h;d.current&&((h=o.current)!=null&&h.getElement())&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const u=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(),a("up");break;case"ArrowDown":h.preventDefault(),a("down");break}},c=h=>{n(h)};return s.jsx(mt,{ref:o,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg max-h-64",onKeyDown:u,children:e.map((h,m)=>s.jsxs("div",{ref:m===t?d:null,role:"listitem",onClick:()=>c(h.content),className:`
317
+ p-2 rounded cursor-pointer transition-colors
318
+ ${m===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
319
+ `,children:[s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&s.jsxs(s.Fragment,{children:[" | ",s.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),s.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function _G(e){const{phase:t,isRunning:n,pendingQuestionsCount:r,pendingConfirmationsCount:a,activeWorkflow:o}=e;let d=null;t==="waiting"||r>0||a>0?d="waiting":t==="blocked"?d="blocked":t==="done"&&!n?d="completed":n&&(d="running");const u=r>0||a>0,c=(o==null?void 0:o.currentStepName)??null;return{state:d,waitingForUser:u,workflowStep:c,lastActivityAt:null}}function SG(e){const{currentSession:t,pendingQuestions:n,pendingPathConfirmations:r,activeWorkflowExecution:a}=e;return t?{..._G({phase:t.phase,isRunning:t.isRunning,pendingQuestionsCount:(n==null?void 0:n.length)??0,pendingConfirmationsCount:(r==null?void 0:r.length)??0,activeWorkflow:a}),lastActivityAt:t.updatedAt}:{state:null,waitingForUser:!1,workflowStep:null,lastActivityAt:null}}function oj(e){switch(e){case"plan":return"Plan";case"build":return"Build";case"verification":return"Verification";case"waiting":return"Waiting";case"blocked":return"Blocked";case"done":return"Done"}}function wG(e,t){switch(e){case"running":return`Running • ${oj(t)}`;case"waiting":return t==="waiting"?"Waiting for input":`Waiting for input • ${oj(t)}`;case"completed":return"Completed";case"blocked":return"Blocked";case null:return""}}function CG(){const e=Le(f=>f.abortInProgress),t=Le(f=>f.currentSession),n=Le(f=>f.pendingQuestions),r=Le(f=>f.pendingPathConfirmations),a=Le(f=>f.activeWorkflowExecution),o=SG({currentSession:t,pendingQuestions:n,pendingPathConfirmations:r,activeWorkflowExecution:a}),d=o.state;if(d===null)return null;const u=wG(d,(t==null?void 0:t.phase)??"plan"),c=e?"bg-amber-400":"bg-accent-primary",h=d==="running",m=o.lastActivityAt?kG(o.lastActivityAt):"";return s.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2","data-testid":"session-status-indicator","data-state":d,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[h&&s.jsxs("span",{className:"flex gap-0.5",children:[s.jsx("span",{className:`w-1 h-1 rounded-full ${e?"":"animate-bounce"} ${c}`,style:{animationDelay:"0ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full ${e?"":"animate-bounce"} ${c}`,style:{animationDelay:"150ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full ${e?"":"animate-bounce"} ${c}`,style:{animationDelay:"300ms"}})]}),s.jsx("span",{className:"text-text-secondary",children:e&&d==="running"?`${u} (abort in progress)`:u})]}),!e&&d==="running"&&s.jsx("span",{className:"text-text-muted hidden sm:inline",children:"esc to interrupt"}),m&&s.jsx("span",{className:"text-text-muted hidden sm:inline","aria-label":"last activity",children:m})]})}function kG(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function jG(){const e=jr(),t=on(e,u=>u.activeWorkflowExecution??null,u=>u.activeWorkflowExecution,null),n=Le(u=>u.exitWorkflow),[r,a]=k.useState(!1);k.useEffect(()=>{a(!1)},[t==null?void 0:t.id]);const o=k.useCallback(()=>{r||!e||(a(!0),n(e))},[r,n,e]);if(!t||t.status!=="running"&&t.status!=="waiting")return null;const d=t.workflowColor&&/^#[0-9a-fA-F]{6}$/.test(t.workflowColor)?t.workflowColor:"#3b82f6";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border",children:[s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:d}}),s.jsx("span",{className:"font-medium text-text-primary truncate",children:t.workflowName}),t.currentStepName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{className:"text-text-muted truncate",children:t.currentStepName})]}),s.jsx("div",{className:"ml-auto shrink-0",children:s.jsx("button",{onClick:o,disabled:r,className:"text-xs px-2 py-0.5 rounded text-text-tool-error hover:bg-text-tool-error/10 transition-colors disabled:opacity-50",children:r?"Exiting...":"✕ Exit"})})]})}function JA(e,t){const n=Le(d=>d.sendMessage),r=Le(d=>d.launchWorkflow),a=k.useCallback((d,u,c)=>{e(!0),t&&n(t,d,u,c)},[e,n,t]),o=k.useCallback((d,u,c,h,m,f="auto")=>{e(!0),t&&r(t,d,u,c,h,m,f)},[e,r,t]);return{sendMessage:a,launchWorkflow:o}}function EG({children:e}){return Cs.createPortal(e,document.body)}function NG(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 TG({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:o,textareaContent:d,attachments:u}){const[c,h]=k.useState(!1),[m,f]=k.useState("commands"),[g,x]=k.useState(""),[w,C]=k.useState(0),[v,S]=k.useState(null),[_,b]=k.useState(null),j=k.useRef(null),E=k.useRef(null),N=cn(V=>V.defaults),L=cn(V=>V.userItems),A=cn(V=>V.projectItems),D=cn(V=>V.fetchCommands),O=Gt(V=>V.fetchWorkflows),F=Le(V=>{var $;return($=V.currentSession)==null?void 0:$.workdir}),P=Gn(Gn(N,L),A),z=$u();k.useEffect(()=>{c&&(m==="commands"?D(F):m==="workflows"&&O(F))},[c,m,D,O,F]),k.useEffect(()=>{c&&(x(""),C(0),requestAnimationFrame(()=>{var V;Wt()&&((V=j.current)==null||V.focus())}))},[c,m]),k.useEffect(()=>{if(!c)return;const V=$=>{var ee;(ee=E.current)!=null&&ee.contains($.target)||h(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[c]);const K=V=>{switch(V.key){case"ArrowDown":V.preventDefault(),C($=>{const Y=(m==="commands"?P:z).filter(X=>{const U=g.toLowerCase();return!U||X.name.toLowerCase().includes(U)});return Math.min($+1,Y.length-1)});break;case"ArrowUp":V.preventDefault(),C($=>Math.max($-1,0));break;case"Enter":V.preventDefault();break;case"Escape":V.preventDefault(),h(!1);break}},q=V=>{x(V),C(0)},W=P.filter(V=>!g||V.name.toLowerCase().includes(g.toLowerCase())),Z=z.filter(V=>!g||V.name.toLowerCase().includes(g.toLowerCase())),Q=async V=>{const $=await cn.getState().fetchCommand(V,F);$&&e($.prompt,$.metadata.agentMode,d,u),h(!1)},H=(V,$)=>{t(V,$),h(!1)},I=(V,$)=>{$.stopPropagation(),h(!1),S(V)},M=(V,$)=>{$.stopPropagation(),h(!1),b(V)};return s.jsxs("div",{ref:E,className:"relative",children:[s.jsx("button",{type:"button",onClick:()=>h(!c),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:s.jsx(ME,{className:"w-4 h-4"})}),c&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 max-w-[calc(100vw-2rem)] bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[s.jsxs("div",{className:"flex border-b border-border",children:[s.jsx("button",{type:"button",onClick:()=>{f("commands"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),s.jsx("button",{type:"button",onClick:()=>{f("workflows"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),s.jsx("button",{type:"button",onClick:()=>f("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),m!=="attach"&&s.jsx("div",{className:"p-2 border-b border-border",children:s.jsx("input",{ref:j,value:g,onChange:V=>q(V.target.value),onKeyDown:K,placeholder:m==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),s.jsx(mt,{className:"max-h-64 p-1",children:m==="commands"?W.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:P.length===0?"No commands yet":"No matches"}):W.map((V,$)=>s.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${$===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsx("button",{type:"button",onClick:()=>Q(V.id),className:"flex-1 text-left",children:s.jsx("div",{className:"text-sm text-text-primary font-medium",children:V.name})}),s.jsx(wi,{className:"opacity-0 group-hover:opacity-100",onClick:ee=>I(V.id,ee)})]},V.id)):m==="workflows"?Z.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:z.length===0?"No workflows yet":"No matches"}):Z.map((V,$)=>{const ee=NG(V),Y=V.color??"#3b82f6";return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${$===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsxs("button",{type:"button",onClick:()=>H(V.id,V.scope),className:"flex-1 text-left flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:Y}}),s.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:V.name}),s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:Cv[V.scope]}),ee!==null&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:ee?"#22c55e":"#6b7280"},title:ee?"Entry condition met":"Entry condition not met"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[V.subGroups&&V.subGroups.length>0&&s.jsx(AG,{subGroups:V.subGroups,onSelect:X=>{h(!1),n(V.id,X,V.scope)}}),s.jsx(wi,{className:"opacity-0 group-hover:opacity-100",onClick:X=>M(V.id,X)})]})]},`${V.id}-${V.scope}`)}):s.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{o(),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:[s.jsx(DE,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),s.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),m!=="attach"&&s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{h(!1),m==="commands"?r():a()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:m==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),s.jsx(GA,{isOpen:!!v,onClose:()=>S(null),initialEditId:v,projectDir:F}),s.jsx(YA,{isOpen:!!_,onClose:()=>b(null),initialEditId:_})]})}function AG({subGroups:e,onSelect:t}){const[n,r]=k.useState(!1),[a,o]=k.useState({top:0,right:0}),d=k.useRef(null),u=k.useRef(null);wm(u,()=>r(!1),n);const c=h=>{if(h.stopPropagation(),!n&&d.current){const m=d.current.getBoundingClientRect();o({top:m.bottom+4,right:window.innerWidth-m.right})}r(!n)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:d,type:"button",onClick:c,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&s.jsx(EG,{children:s.jsx("div",{ref:u,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(h=>s.jsx("button",{type:"button",onClick:m=>{m.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 LG({messages:e,onCancel:t}){return e.length===0?null:s.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>s.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:[s.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),s.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),s.jsx(Bu,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function RG({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,model:a,onView:o,onEdit:d,onDuplicate:u,onDelete:c,onCancelDelete:h}){var g;const m=e.allowedTools.filter(x=>!(r!=null&&r.has(x))),f=a?(g=a.split("/").pop())==null?void 0:g.replace(/-/g," "):void 0;return s.jsxs(KE,{isBuiltIn:t,isConfirmingDelete:n,onView:o,onEdit:d,onDuplicate:u,onDelete:c,onCancelDelete:h,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"}),f&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent-primary/10 text-accent-primary",children:f})]}),e.description&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[m.slice(0,5).map(x=>s.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:x},x)),m.length>5&&s.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",m.length-5," more"]})]})]})}function lj({title:e,agentTitle:t="Agents",subagentTitle:n="Sub-agents",agents:r,subagents:a,isBuiltIn:o,alwaysAllowedNames:d,modelOverrides:u,onView:c,onDuplicate:h,onEdit:m,onDelete:f,onCancelDelete:g,isConfirmingDelete:x}){if(r.length===0&&a.length===0)return null;const w=C=>s.jsx(RG,{agent:C,model:u==null?void 0:u[C.id],isBuiltIn:o,isConfirmingDelete:(x==null?void 0:x(C.id))??!1,alwaysAllowedNames:d,onView:()=>c(C.id),onEdit:m?()=>m(C.id):void 0,onDuplicate:()=>h(C.id),onDelete:o?void 0:()=>f==null?void 0:f(C.id),onCancelDelete:o?void 0:()=>g==null?void 0:g(C.id)},C.id);return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),r.length>0&&s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:t}),s.jsxs("div",{className:"space-y-2",children:[r.map(w),a.length>0&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:n}),s.jsx("div",{className:"space-y-2",children:a.map(w)})]})]})]})}function DG(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const a=n.slice(0,r),d=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(d))}}return t}function Rh(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function OG({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:o,formModel:d,formPrompt:u,formError:c,isReadOnly:h,availableTools:m,providers:f,onNameChange:g,onIdChange:x,onDescriptionChange:w,onSubagentChange:C,onToolsChange:v,onColorChange:S,onModelChange:_,onPromptChange:b}){const j=DG(a),E=m.filter(O=>!(r&&O.topLevelOnly)&&!O.isMcp),N=m.filter(O=>O.isMcp&&!(r&&O.topLevelOnly)),L=new Map;for(const O of N){const F=O.mcpServer??O.name,P=L.get(F)??[];P.push(O),L.set(F,P)}const A=(O,F)=>{const P=new Map(j),z=P.get(O)||new Set,K=new Set(z);K.has(F)?K.delete(F):K.add(F),K.size===0?P.set(O,new Set):P.set(O,K),v(Rh(P))},D=O=>{const F=new Map(j);F.has(O)?F.delete(O):F.set(O,new Set),v(Rh(F))};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3",children:[c&&s.jsx(vl,{message:c}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(rs,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),s.jsx(rs,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(rs,{label:"Description",value:n,onChange:w,placeholder:"What this agent does",readOnly:h}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),s.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[s.jsx("button",{onClick:()=>!h&&C(!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:"Agent"}),s.jsx("button",{onClick:()=>!h&&C(!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"}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),s.jsx("input",{type:"color",value:o,onChange:O=>!h&&S(O.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),!h&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Model override"}),s.jsx(wv,{providers:f,value:d,onChange:_,defaultLabel:"Default (global model)"}),s.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"When set, this model will be used when this agent is active (overrides the session model)."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),s.jsx(mt,{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32",children:E.map(O=>{const F=j.has(O.name),P=O.actions.length>0,z=j.get(O.name)||new Set;return P?h?s.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:[s.jsx("span",{children:O.name}),s.jsx("span",{className:"text-[10px]",children:"*"})]},O.name):s.jsx(ho,{trigger:s.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${F?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} cursor-pointer`,children:[s.jsx("span",{children:O.name}),z.size>0&&s.jsx("span",{className:"text-[10px]",children:"*"})]}),minWidth:"160px",items:[...O.actions.map(K=>({label:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${O.name}-${K}`,children:[s.jsx("input",{type:"checkbox",id:`${O.name}-${K}`,checked:z.has(K),onChange:()=>A(O.name,K),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),s.jsx("span",{children:K})]}),closeOnClick:!1})),{label:F?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(F)D(O.name);else{const K=new Map(j);K.set(O.name,new Set(O.actions)),v(Rh(K))}}}]},O.name):s.jsx("button",{onClick:()=>!h&&D(O.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${F?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:s.jsx("span",{children:O.name})},O.name)})})]}),L.size>0&&(()=>{const O=new Set(N.map(q=>q.name)),F=j.has("__mcp_none__"),P=[...j.keys()].some(q=>O.has(q)),z=F?"none":P?"partial":"all",K=q=>{const W=new Map(j);for(const Z of W.keys())(Z==="__mcp_none__"||O.has(Z))&&W.delete(Z);if(q==="none"&&W.set("__mcp_none__",new Set),q==="partial")for(const Z of O)W.set(Z,new Set);v(Rh(W))};return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["MCP Tools ",s.jsx("span",{className:"text-text-muted font-normal",children:"— from connected MCP servers"})]}),s.jsxs("div",{className:"bg-bg-tertiary border border-border rounded overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-4 px-3 py-1.5",children:["all","none","partial"].map(q=>s.jsxs("label",{className:`flex items-center gap-1.5 text-xs cursor-pointer ${h?"pointer-events-none opacity-60":""}`,children:[s.jsx("input",{type:"radio",name:"mcp-mode",checked:z===q,onChange:()=>K(q),disabled:h,className:"w-3 h-3 accent-accent-primary"}),s.jsxs("span",{className:z===q?"text-text-primary font-medium":"text-text-muted",children:[q.charAt(0).toUpperCase()+q.slice(1),q==="partial"&&O.size>0&&s.jsxs("span",{className:"ml-1 text-text-muted font-normal",children:["(",[...j.keys()].filter(W=>O.has(W)).length,"/",O.size,")"]})]})]},q))}),z==="partial"&&(()=>{const[q,W]=k.useState(""),[Z,Q]=k.useState(0),H=k.useRef(null),I=$=>{var Y;const ee=(Y=H.current)==null?void 0:Y.querySelector(`[data-idx="${$}"]`);ee==null||ee.scrollIntoView({block:"nearest"})};k.useEffect(()=>{I(Z)},[Z]);const M=q?N.filter($=>$.name.toLowerCase().includes(q.toLowerCase())):N,V=$=>{$.key==="ArrowDown"?($.preventDefault(),Q(ee=>Math.min(ee+1,M.length-1))):$.key==="ArrowUp"?($.preventDefault(),Q(ee=>Math.max(ee-1,0))):$.key==="Enter"&&M[Z]&&($.preventDefault(),D(M[Z].name))};return s.jsxs("div",{children:[s.jsx("div",{className:"px-3 py-2 border-b border-border",children:s.jsx("input",{type:"text",value:q,onChange:$=>{W($.target.value),Q(0)},onKeyDown:V,placeholder:"Search MCP tools...",className:"w-full px-2 py-1 text-xs bg-bg-primary border border-border rounded font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),s.jsx(mt,{className:"max-h-60",children:s.jsxs("div",{ref:H,children:[M.map(($,ee)=>{const Y=j.has($.name),X=ee===Z;return s.jsxs("div",{"data-idx":ee,className:`flex items-center justify-between px-3 py-1.5 transition-colors ${X?"bg-bg-primary":"hover:bg-bg-primary/30"}`,onMouseEnter:()=>Q(ee),children:[s.jsx("span",{className:`text-xs font-mono ${Y?"text-text-primary":"text-text-muted"}`,children:$.name}),s.jsx(ys,{enabled:Y,onClick:()=>D($.name),label:$.name})]},$.name)}),M.length===0&&s.jsx("div",{className:"px-3 py-2 text-xs text-text-muted",children:"No MCP tools match your search."})]})})]})})()]})]})})()]}),s.jsxs("div",{className:"flex-1 min-h-[150px] pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:u,onChange:O=>!h&&b(O.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":""}`})]})]})}function MG(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function IG({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=ft(Se=>Se.defaults),o=ft(Se=>Se.userItems),d=ft(Se=>Se.projectItems),u=ft(Se=>Se.loading),c=ft(Se=>Se.fetchAgents),h=ft(Se=>Se.fetchAgent),m=ft(Se=>Se.fetchDefaultContent),f=ft(Se=>Se.createAgent),g=ft(Se=>Se.updateAgent),x=ft(Se=>Se.deleteAgent),[w,C]=k.useState("list"),[v,S]=k.useState(null),[_,b]=k.useState(!1),[j,E]=k.useState(""),[N,L]=k.useState(""),[A,D]=k.useState(""),[O,F]=k.useState(!1),[P,z]=k.useState([]),[K,q]=k.useState("#6b7280"),[W,Z]=k.useState(void 0),[Q,H]=k.useState(""),[I,M]=k.useState("user"),[V,$]=k.useState(""),[ee,Y]=k.useState(!1),[X,U]=k.useState(!1),[B,J]=k.useState(null),se=jr(),[ne,ie]=k.useState([]),[de,pe]=k.useState(new Set),{requestDelete:Oe,clearConfirm:$e,isConfirming:Pe}=Au(),Ve=Se=>{E(Se.metadata.name),L(Se.metadata.id),D(Se.metadata.description),F(Se.metadata.subagent),z(Se.metadata.allowedTools),q(Se.metadata.color??"#6b7280"),H(Se.prompt),$(""),U(!0),ye(`/api/agents/${Se.metadata.id}/model`).then(Ue=>Ue.json()).then(Ue=>{Ue.providerId&&Ue.model?Z(`${Ue.providerId}/${Ue.model}`):Z(void 0)}).catch(()=>Z(void 0)).finally(()=>U(!1))},Ye=(Se,Ue,ve)=>{E(Se.metadata.name+" (copy)"),L(`${Ue}-copy-${Date.now()}`),D(Se.metadata.description),F(Se.metadata.subagent),z(Se.metadata.allowedTools),q(Se.metadata.color??"#6b7280"),H(Se.prompt),$(""),S(null),b(!1),C("edit")},ot=(Se,Ue)=>{Ve(Se),S(Ue),b(!0),C("edit")};k.useEffect(()=>{e&&(c(r),ye("/api/tools").then(Se=>Se.json()).then(Se=>{const Ue=Se.tools||[];pe(new Set(Ue.filter(ve=>ve.alwaysAllowed).map(ve=>ve.name))),ie(Ue.filter(ve=>!ve.alwaysAllowed))}).catch(()=>{ie([]),pe(new Set)}),n?a.some(Ue=>Ue.id===n)?m(n).then(Ue=>{Ue&&Ye(Ue,n)}):h(n,r).then(Ue=>{Ue&&(Ve(Ue),S(n),b(!1),C("edit"))}):(C("list"),S(null),b(!1)))},[e,c,h,m,n,r]);const Ae=async Se=>{if(a.some(ve=>ve.id===Se)){const ve=await m(Se);if(!ve)return;ot(ve,Se)}else{const ve=await h(Se,r);if(!ve)return;ot(ve,Se)}},me=async Se=>{let Ue=await m(Se);Ue||(Ue=await h(Se,r)),Ue&&Ye(Ue,Se)},re=()=>{S(null),E(""),L(""),D(""),F(!1),z(["read_file"]),q("#6b7280"),H(""),M("user"),$(""),b(!1),C("edit")},_e=async Se=>{const Ue=await h(Se,r);Ue&&(Ve(Ue),S(Se),b(!1),C("edit"))},Me=Se=>{J(Se)},ce=async Se=>{await x(Se,r)},Ne=async()=>{var Lt;const Se=v??N;if(!Se||!j||!Q){$("Name and prompt are required.");return}Y(!0),$("");const Ue={metadata:{id:Se,name:j,description:A,subagent:O,allowedTools:P.filter(qt=>!de.has(qt)),color:K},prompt:Q},ve=v?await g(v,Ue,r):await f(Ue,I,r);if(!ve.success){Y(!1),$(ve.error??"Failed to save agent.");return}await ZA(v??N,W),await c(r);const tt=v??N,et=se,dt=et?((Lt=Le.getState().panes[et])==null?void 0:Lt.session)??null:Le.getState().currentSession;if((dt==null?void 0:dt.mode)===tt&&W&&et){const{providerId:qt,model:vn}=Iv(W);Le.getState().setSessionProvider(et,qt,vn)}Y(!1),n?t():C("list")},Xe=()=>{n?t():(C("list"),b(!1))},at=Se=>{E(Se),v||L(MG(Se))},fe=ft(Se=>Se.modelOverrides),We=a.filter(Se=>Se.subagent),Ze=a.filter(Se=>!Se.subagent),it=o.filter(Se=>Se.subagent),nt=o.filter(Se=>!Se.subagent),De=d.filter(Se=>Se.subagent),Re=d.filter(Se=>!Se.subagent);return w==="edit"?s.jsxs(s.Fragment,{children:[s.jsxs(Et,{isOpen:e,onClose:Xe,title:_?`${j}`:v?"Edit Agent":"New Agent",size:"xl",footer:_?s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{onClick:()=>{E(j+" (copy)"),L(`${v}-copy-${Date.now()}`),S(null),b(!1)},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"})}):s.jsx(FE,{onCancel:Xe,onSave:Ne,saving:ee,saveDisabled:!j||!Q||X}),children:[!v&&!_&&s.jsx(Zf,{value:I,onChange:M}),s.jsx(OG,{formName:j,formId:N,formDescription:A,formSubagent:O,formTools:P,formColor:K,formModel:W,formPrompt:Q,formError:V,isReadOnly:_,availableTools:ne,providers:an.getState().providers,onNameChange:at,onIdChange:L,onDescriptionChange:D,onSubagentChange:Se=>{F(Se),Se&&z(Ue=>Ue.filter(ve=>{var tt;return!((tt=ne.find(et=>et.name===ve))!=null&&tt.topLevelOnly)}))},onToolsChange:z,onColorChange:q,onModelChange:Z,onPromptChange:H})]}),s.jsx(cj,{agentId:B,onClose:()=>J(null),onSaved:()=>c(r)})]}):s.jsxs(s.Fragment,{children:[s.jsx(Et,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:s.jsx(zE,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:re,loading:u,hasItems:a.length>0||o.length>0||d.length>0,children:s.jsxs("div",{className:"space-y-4",children:[a.length>0&&s.jsx(lj,{title:"Built-in",agents:Ze,subagents:We,isBuiltIn:!0,alwaysAllowedNames:de,modelOverrides:fe,onView:Ae,onEdit:Me,onDuplicate:me}),(nt.length>0||it.length>0||Re.length>0||De.length>0)&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Custom"}),s.jsx("div",{className:"ml-3 space-y-3",children:[{title:"Global",agents:nt,subagents:it},{title:"Project",agents:Re,subagents:De}].map(Se=>(Se.agents.length>0||Se.subagents.length>0)&&s.jsx(lj,{title:Se.title,agents:Se.agents,subagents:Se.subagents,isBuiltIn:!1,alwaysAllowedNames:de,modelOverrides:fe,isConfirmingDelete:Ue=>Pe(Ue,"delete"),onView:Ae,onDuplicate:me,onEdit:_e,onDelete:Ue=>{Pe(Ue,"delete")?(ce(Ue),$e()):Oe(Ue)},onCancelDelete:$e},Se.title))})]})]})})}),s.jsx(cj,{agentId:B,onClose:()=>J(null),onSaved:()=>c(r)})]})}function Iv(e){const t=e.indexOf("/");return t>0?{providerId:e.substring(0,t),model:e.substring(t+1)}:{providerId:e,model:e}}async function ZA(e,t){if(t){const{providerId:n,model:r}=Iv(t);await ye(`/api/agents/${e}/model`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})})}else await ye(`/api/agents/${e}/model`,{method:"DELETE"})}function cj({agentId:e,onClose:t,onSaved:n}){const[r,a]=k.useState(void 0),[o,d]=k.useState(!1),[u,c]=k.useState(!1),[h,m]=k.useState(null),f=ft(b=>b.defaults),g=ft(b=>b.userItems),x=ft(b=>b.projectItems),w=[...f,...g,...x],C=e?w.find(b=>b.id===e):void 0,v=an(b=>b.providers),S=jr();k.useEffect(()=>{e&&(d(!0),ye(`/api/agents/${e}/model`).then(b=>b.json()).then(b=>{a(b.providerId&&b.model?`${b.providerId}/${b.model}`:void 0)}).catch(()=>a(void 0)).finally(()=>d(!1)))},[e]);const _=async()=>{var b;if(e){c(!0),m(null);try{await ZA(e,r);const j=S,E=j?((b=Le.getState().panes[j])==null?void 0:b.session)??null:Le.getState().currentSession;if((E==null?void 0:E.mode)===e&&r&&j){const{providerId:N,model:L}=Iv(r);Le.getState().setSessionProvider(j,N,L)}n(),t()}catch{m("Failed to save. Please try again.")}c(!1)}};return s.jsx(Et,{isOpen:!!e,onClose:t,title:`Model — ${(C==null?void 0:C.name)??e??""}`,size:"md",children:s.jsxs("div",{className:"space-y-4 p-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Choose which model to use when this agent is active. This overrides the session/global model."}),o?s.jsx("div",{className:"text-sm text-text-muted py-2",children:"Loading..."}):s.jsx(wv,{providers:v,value:r,onChange:a,defaultLabel:"Default (global model)"}),h&&s.jsx("p",{className:"text-xs text-red-500",children:h}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{onClick:t,className:"px-4 py-1.5 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),s.jsx("button",{onClick:_,disabled:u,className:"px-4 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-50 transition-colors",children:u?"Saving...":"Save"})]})]})})}function PG(){const e=jr(),t=on(e,E=>{var N;return((N=E.session)==null?void 0:N.mode)??null},E=>{var N;return((N=E.currentSession)==null?void 0:N.mode)??null},null),n=on(e,E=>{var N;return((N=E.session)==null?void 0:N.workdir)??void 0},E=>{var N;return(N=E.currentSession)==null?void 0:N.workdir},void 0),r=Le(E=>E.switchMode),a=ft(E=>E.defaults),o=ft(E=>E.userItems),d=ft(E=>E.projectItems),u=ft(E=>E.fetchAgents),c=[...a,...o,...d],[h,m]=k.useState(!1),[f,g]=k.useState(!1),[x,w]=k.useState(null),C=k.useRef(null);k.useEffect(()=>{u(n)},[u,n]),wm(C,()=>m(!1));const v=Tu();if(!t)return null;const S=c.filter(E=>!E.subagent),_=S.find(E=>E.id===t),b=(_==null?void 0:_.name)??t,j=lo(c,t);return s.jsxs("div",{className:"relative",ref:C,children:[s.jsxs("button",{type:"button",onClick:()=>m(!h),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[s.jsx("span",{className:"text-sm font-medium",style:{color:j},children:b}),s.jsx(gn,{className:`w-3 h-3 text-text-muted transition-transform ${h?"rotate-180":""}`})]}),h&&S.length>0&&s.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:[S.map((E,N)=>{const L=E.id===t,A=lo(c,E.id),D=v.agentSwitching[N],O=D?Lb(D):null;return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${L?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{!L&&e&&r(e,E.id),m(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",style:{color:A},children:E.name}),L&&s.jsx(Us,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),O&&s.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:O})]},E.id)}),s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{m(!1),g(!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..."})})]}),s.jsx(IG,{isOpen:f,onClose:()=>{g(!1),w(null)},initialEditId:x,projectDir:n})]})}function BG(){const e=jr(),t=on(e,r=>{var a;return((a=r.session)==null?void 0:a.dangerLevel)??"normal"},r=>{var a;return((a=r.currentSession)==null?void 0:a.dangerLevel)??"normal"},"normal"),n=Le(r=>r.switchDangerLevel);return e?s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[s.jsx("button",{type:"button",onClick:()=>n(e,"normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${t==="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"}),s.jsx("button",{type:"button",onClick:()=>n(e,"dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${t==="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"})]}):null}function uj({value:e,onChange:t}){return s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",s.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),s.jsx("input",{type:"text",value:e??"",onChange:n=>t(n.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]})}const $G=[8080,11434,8e3,1234];function Jy(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function eL(e){return{name:e.name,url:e.url,backend:e.backend,apiKey:e.apiKey,isLocal:e.isLocal,thinkingField:e.thinkingField,sendReasoningInMessages:e.sendReasoningInMessages,authAdapter:e.authAdapter,transportAdapter:e.transportAdapter,models:e.models}}function FG({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:o,onTestParams:d,onShowRaw:u}){var h,m,f,g,x,w,C,v,S,_,b,j,E,N,L,A,D,O,F,P,z,K,q,W,Z,Q,H,I,M,V,$,ee,Y,X,U,B,J,se;function c(ne,ie){var $e;const de=(($e=t[ne])==null?void 0:$e.omitParams)??[],Oe=de.includes(ie)?de.filter(Pe=>Pe!==ie):[...de,ie];a(ne,{omitParams:Oe.length>0?Oe:void 0})}return s.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>o(e.id),disabled:n.progress[e.id]==="probing",className:"px-4 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:n.progress[e.id]==="probing"?"Probing...":"Auto-config"}),n.progress[e.id]==="done"&&s.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&s.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),s.jsxs("div",{className:"flex gap-3 items-end",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),s.jsx("input",{type:"number",value:((h=t[e.id])==null?void 0:h.contextWindow)??e.contextWindow,onChange:ne=>a(e.id,{contextWindow:parseInt(ne.target.value)||e.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[s.jsx("input",{type:"checkbox",checked:((m=t[e.id])==null?void 0:m.supportsVision)??!1,onChange:ne=>a(e.id,{supportsVision:ne.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>d(e.id,"thinking"),disabled:(f=r[e.id+"-thinking"])==null?void 0:f.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(g=r[e.id+"-thinking"])!=null&&g.loading?"Testing...":"Test thinking"}),((x=r[e.id+"-thinking"])==null?void 0:x.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((w=r[e.id+"-thinking"])==null?void 0:w.error)&&s.jsx("span",{className:"text-xs text-red-500",title:(C=r[e.id+"-thinking"])==null?void 0:C.error,children:"Fail"}),((v=r[e.id+"-thinking"])==null?void 0:v.result)&&s.jsx("button",{onClick:()=>u(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>d(e.id,"non-thinking"),disabled:(S=r[e.id+"-non-thinking"])==null?void 0:S.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(_=r[e.id+"-non-thinking"])!=null&&_.loading?"Testing...":"Test non-thinking"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((j=r[e.id+"-non-thinking"])==null?void 0:j.error)&&s.jsx("span",{className:"text-xs text-red-500",title:(E=r[e.id+"-non-thinking"])==null?void 0:E.error,children:"Fail"}),((N=r[e.id+"-non-thinking"])==null?void 0:N.result)&&s.jsx("button",{onClick:()=>u(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),s.jsxs("details",{className:"group",children:[s.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[s.jsx(gn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((L=t[e.id])==null?void 0:L.thinkingEnabled)??!1,onChange:ne=>a(e.id,{thinkingEnabled:ne.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((A=t[e.id])==null?void 0:A.thinkingEnabled)&&s.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(D=e.reasoningEfforts)!=null&&D.length?s.jsx("select",{"aria-label":"Reasoning effort",value:((O=t[e.id])==null?void 0:O.thinkingLevel)??Jy(e.reasoningEfforts),onChange:ne=>a(e.id,{thinkingLevel:ne.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary",children:e.reasoningEfforts.map(ne=>s.jsx("option",{value:ne,children:ne},ne))}):s.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((F=t[e.id])==null?void 0:F.thinkingLevel)??"",onChange:ne=>a(e.id,{thinkingLevel:ne.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsx(uj,{value:(P=t[e.id])==null?void 0:P.thinkingQueryParams,onChange:ne=>a(e.id,{thinkingQueryParams:ne})})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((z=t[e.id])==null?void 0:z.nonThinkingEnabled)??!1,onChange:ne=>a(e.id,{nonThinkingEnabled:ne.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((K=t[e.id])==null?void 0:K.nonThinkingEnabled)&&s.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:s.jsx(uj,{value:(q=t[e.id])==null?void 0:q.nonThinkingQueryParams,onChange:ne=>a(e.id,{nonThinkingQueryParams:ne})})}),(((W=t[e.id])==null?void 0:W.omitParams)??[]).includes("reasoning_effort")&&s.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-warning cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox","data-testid":"re-enable-reasoning_effort",checked:!1,onChange:()=>c(e.id,"reasoning_effort"),className:"accent-accent-primary"}),"Re-enable reasoning_effort"]})]}),s.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Dh,{modelId:e.id,paramKey:"temperature",label:"Temperature",step:.1,value:(Z=t[e.id])==null?void 0:Z.temperature,defaultValue:(Q=t[e.id])==null?void 0:Q.defaultTemperature,omitParams:(H=t[e.id])==null?void 0:H.omitParams,onUpdateConfig:a,onToggleOmit:c,parseValue:ne=>ne?parseFloat(ne):void 0,valueField:"temperature"}),s.jsx(Dh,{modelId:e.id,paramKey:"top_p",label:"Top P",step:.05,value:(I=t[e.id])==null?void 0:I.topP,defaultValue:(M=t[e.id])==null?void 0:M.defaultTopP,omitParams:(V=t[e.id])==null?void 0:V.omitParams,onUpdateConfig:a,onToggleOmit:c,parseValue:ne=>ne?parseFloat(ne):void 0,valueField:"topP"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[s.jsx(Dh,{modelId:e.id,paramKey:"top_k",label:"Top K",value:($=t[e.id])==null?void 0:$.topK,defaultValue:(ee=t[e.id])==null?void 0:ee.defaultTopK,omitParams:(Y=t[e.id])==null?void 0:Y.omitParams,onUpdateConfig:a,onToggleOmit:c,parseValue:ne=>ne?parseInt(ne):void 0,valueField:"topK"}),s.jsx(Dh,{modelId:e.id,paramKey:"max_tokens",label:"Max tokens",value:(X=t[e.id])==null?void 0:X.maxTokens,defaultValue:(U=t[e.id])==null?void 0:U.defaultMaxTokens,omitParams:(B=t[e.id])==null?void 0:B.omitParams,onUpdateConfig:a,onToggleOmit:c,parseValue:ne=>ne?parseInt(ne):void 0,valueField:"maxTokens"})]})]}),s.jsx("div",{className:"pt-3 border-t border-border",children:s.jsx(zG,{value:(J=t[e.id])==null?void 0:J.compactionThreshold,maxTokens:((se=t[e.id])==null?void 0:se.contextWindow)??e.contextWindow,onChange:ne=>a(e.id,{compactionThreshold:ne})})})]})]})}function Dh({modelId:e,paramKey:t,label:n,value:r,defaultValue:a,omitParams:o,onUpdateConfig:d,onToggleOmit:u,parseValue:c,valueField:h,step:m}){const f=(o==null?void 0:o.includes(t))??!1;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:n}),s.jsxs("label",{className:"flex items-center gap-1 text-xs text-text-muted cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox","data-testid":`send-${t}`,checked:!f,onChange:()=>u(e,t),className:"accent-accent-primary"}),"Send"]})]}),s.jsx("input",{type:"number","data-testid":`param-${t}`,step:m,value:f?"":r??"",disabled:f,onChange:g=>d(e,{[h]:c(g.target.value)}),placeholder:f?"Not sent":(a==null?void 0:a.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary disabled:opacity-40"}),!f&&a!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",a]})]})}function zG({value:e,maxTokens:t,onChange:n}){const o=Math.min(95,Math.floor((t-5e3)/t*100)),d=Math.min(o,Math.ceil(15e3/t*100)),u=Math.min(e??.85,o/100),[c,h]=k.useState(Math.round(u*100));k.useEffect(()=>{const f=Math.min(e??.85,o/100);h(Math.round(f*100))},[e,o]);const m=Math.floor(t*(c/100));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Auto-compaction threshold"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono text-xs text-text-primary",children:[c,"% · ",Ll(m)]}),s.jsx("button",{type:"button",onClick:()=>{n(void 0),h(Math.round(.85*100))},disabled:e===void 0,className:"text-xs text-accent-primary hover:underline disabled:text-text-muted disabled:no-underline",children:"Default"})]})]}),s.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:d,max:o,step:"1",value:c,onChange:f=>h(Number(f.target.value)),onMouseUp:()=>n(c/100),onTouchEnd:()=>n(c/100),onBlur:()=>n(c/100),onKeyUp:()=>n(c/100),className:"w-full"}),s.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",Ll(15e3)," tokens · maximum ",o,"% · default 85%"]})]})}function tL({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:o}){const[d,u]=k.useState(r),[c,h]=k.useState(""),[m,f]=k.useState(""),[g,x]=k.useState("unknown"),[w,C]=k.useState(""),[v,S]=k.useState(!1),[_,b]=k.useState(),[j,E]=k.useState(),[N,L]=k.useState(!1),[A,D]=k.useState(null),[O,F]=k.useState([]),[P,z]=k.useState(null),[K,q]=k.useState(!1),[W,Z]=k.useState(""),[Q,H]=k.useState(!0),[I,M]=k.useState({}),[V,$]=k.useState({loading:!1,progress:{}}),[ee,Y]=k.useState({}),[X,U]=k.useState(null),[B,J]=k.useState(new Set),[se,ne]=k.useState(""),[ie,de]=k.useState(null),[pe,Oe]=k.useState("disconnected"),[$e,Pe]=k.useState(!1),[Ve,Ye]=k.useState(null),[ot,Ae]=k.useState([]),[me,re]=k.useState(!1),[_e,Me]=k.useState(!1),[ce,Ne]=k.useState(""),[Xe,at]=k.useState(null),fe=k.useRef(null),We=k.useRef(!1),Ze=k.useRef(null),it=k.useRef(null);k.useEffect(()=>{d===1&&e&&requestAnimationFrame(()=>{var be;Wt()&&((be=Ze.current)==null||be.focus())})},[d,e]),k.useEffect(()=>()=>{fe.current!==null&&window.clearTimeout(fe.current)},[]),k.useEffect(()=>{e&&ye("/api/provider-presets").then(async be=>be.ok?await be.json():{presets:[]}).then(be=>Ae(be.presets)).catch(()=>Ae([]))},[e]);function nt(be,rt){M(Qe=>({...Qe,[be]:{...Qe[be],...rt}}))}function De(be){J(rt=>new Set(rt).add(be.id)),M(rt=>({...rt,[be.id]:{contextWindow:be.contextWindow,...rt[be.id]}}))}function Re(be){if(!be.trim())return O;const rt=be.toLowerCase().split(/\s+/).filter(Boolean);return O.filter(Qe=>rt.every(He=>Qe.id.toLowerCase().includes(He)))}function Se(){const be=ce.trim();if(!be){at("Enter a model name");return}const rt=Ke=>Ke.toLowerCase().replace(/[-_\s:.]+/g,""),Qe=rt(be),He=O.find(Ke=>rt(Ke.id)===Qe);if(He){De(He),at(`"${He.id}" is already in the list`),Ne(""),!_&&V.progress[He.id]!=="probing"&&qt(He.id);return}const le={id:be,contextWindow:2e5};F(Ke=>[...Ke,le]),J(Ke=>new Set(Ke).add(le.id)),M(Ke=>({...Ke,[le.id]:{contextWindow:le.contextWindow,thinkingEnabled:!0}})),z(le.id),Ne(""),at(null),D(null)}k.useEffect(()=>{var be,rt;if(e)if(u(r),h((a==null?void 0:a.name)??""),f((a==null?void 0:a.url)??""),x((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),b(a==null?void 0:a.authAdapter),E(a==null?void 0:a.transportAdapter),D(null),Z((a==null?void 0:a.thinkingField)??""),H((a==null?void 0:a.sendReasoningInMessages)??!0),Y({}),U(null),de(null),Oe("disconnected"),Ye(null),re(!1),Me(!1),Ne(""),at(null),(be=a==null?void 0:a.models)!=null&&be.length){const Qe={},He=new Set;for(const le of a.models)Qe[le.id]={contextWindow:le.contextWindow,supportsVision:le.supportsVision,thinkingEnabled:le.thinkingEnabled,thinkingLevel:le.thinkingLevel??Jy(le.reasoningEfforts),nonThinkingEnabled:le.nonThinkingEnabled,thinkingQueryParams:le.thinkingQueryParams,nonThinkingQueryParams:le.nonThinkingQueryParams,omitParams:le.omitParams,defaultTemperature:le.defaultTemperature,defaultTopP:le.defaultTopP,defaultTopK:le.defaultTopK,defaultMaxTokens:le.defaultMaxTokens,temperature:le.temperature,topP:le.topP,topK:le.topK,maxTokens:le.maxTokens,compactionThreshold:le.compactionThreshold},le.selected&&He.add(le.id);if(He.size===0)for(const le of a.models)He.add(le.id);J(He),M(Qe),F(a.models),z(o??((rt=a.models[0])==null?void 0:rt.id)??null)}else F([]),M({}),z(null),J(new Set)},[e,r,a==null?void 0:a.id,o]),k.useEffect(()=>{const be=!!_;d===2&&m&&O.length===0&&!N&&!A&&(!be||pe==="connected")&&Lt(m)},[d,pe]),k.useEffect(()=>{!e||!_||!(a!=null&&a.id)||ve(a.id)},[e,j,a==null?void 0:a.id]),k.useEffect(()=>{if(!Ve)return;const be=(a==null?void 0:a.id)??ie;if(!be)return;let rt=!1;const Qe=async()=>{const le=await ve(be);rt||le!=="connected"||(Ye(null),re(!1),Me(!1),await Lt(m))};Qe();const He=window.setInterval(()=>void Qe(),2e3);return()=>{rt=!0,window.clearInterval(He)}},[Ve,ie,a==null?void 0:a.id]);async function Ue(){if(a!=null&&a.id)return a.id;if(ie)return ie;const be=await ye("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c||"Provider",url:m,backend:g,authAdapter:_,transportAdapter:j,isLocal:!1,models:[]})});if(!be.ok)throw new Error("Unable to create provider");const rt=await be.json();return de(rt.provider.id),rt.provider.id}async function ve(be){const rt=await ye(`/api/provider-auth/${be}/status`);if(!rt.ok)return"error";const Qe=await rt.json(),He=Qe.state==="connected"?"connected":Qe.state==="pending"?"pending":Qe.state==="error"?"error":"disconnected";return Oe(He),He}async function tt(){Pe(!0),Oe("pending");try{const be=await Ue(),rt=await ye(`/api/provider-auth/${be}/login`,{method:"POST"});if(!rt.ok)throw new Error("Unable to start provider sign-in");const Qe=await rt.json();Ye(Qe)}catch{Oe("error")}finally{Pe(!1)}}async function et(){var be;Ve!=null&&Ve.userCode&&(await((be=navigator.clipboard)==null?void 0:be.writeText(Ve.userCode)),fe.current!==null&&window.clearTimeout(fe.current),Me(!1),requestAnimationFrame(()=>Me(!0)),fe.current=window.setTimeout(()=>{Me(!1),fe.current=null},1500))}function dt(){Ve&&(window.open(Ve.directUrl??Ve.verificationUrl,"_blank","noopener,noreferrer"),re(!0))}async function Lt(be){var rt,Qe;L(!0),D(null),F([]);try{const He=new URLSearchParams({url:be});w&&He.set("apiKey",w),g&&He.set("backend",g);const le=j?await ye(`/api/providers/${await Ue()}/models`):await ye(`/api/providers/models?${He.toString()}`);if(le.ok){const Ke=await le.json();if((rt=Ke.models)!=null&&rt.length){F(Ke.models),z(((Qe=Ke.models[0])==null?void 0:Qe.id)??null);const xt={};for(const Mt of Ke.models)xt[Mt.id]={contextWindow:Mt.contextWindow,thinkingEnabled:!0,thinkingLevel:Jy(Mt.reasoningEfforts),defaultTemperature:Mt.defaultTemperature,defaultTopP:Mt.defaultTopP,defaultTopK:Mt.defaultTopK,defaultMaxTokens:Mt.defaultMaxTokens};M(xt),Ke.models.length===1&&(J(new Set([Ke.models[0].id])),z(Ke.models[0].id),qt(Ke.models[0].id))}}else{const Ke=await le.json();D(Ke.error??`Failed to fetch models from ${be}`)}}catch(He){D(`Failed to fetch models from ${be}: ${He instanceof Error?He.message:"Unknown error"}`)}L(!1)}async function qt(be){$(rt=>({loading:!0,progress:{...rt.progress,[be]:"probing"}}));try{const rt=await ye("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:m,apiKey:w||void 0,backend:g||"unknown",models:[{id:be}]})});if(!rt.ok){const He=await rt.json();throw new Error(He.error??"Auto-config failed")}const Qe=await rt.json();for(const He of Qe.models){const le={};He.contextSource!=="default"&&(le.contextWindow=He.contextWindow,le.supportsVision=He.supportsVision),He.thinkingConfig&&(le.thinkingEnabled=!0,le.thinkingQueryParams=JSON.stringify(He.thinkingConfig)),He.nonThinkingConfig&&(le.nonThinkingEnabled=!0,le.nonThinkingQueryParams=JSON.stringify(He.nonThinkingConfig)),He.sendReasoningInMessages===!1&&H(!1),He.rejectedParams&&He.rejectedParams.length>0&&(le.omitParams=He.rejectedParams),nt(He.id,le),$(Ke=>({...Ke,progress:{...Ke.progress,[He.id]:"done"}}))}}catch(rt){console.error("Auto-config error:",rt),$(Qe=>({...Qe,progress:{...Qe.progress,[be]:"error"}}))}finally{$(rt=>({...rt,loading:!1}))}}async function vn(be,rt){const Qe=be+"-"+rt;Y(He=>({...He,[Qe]:{loading:!0}}));try{const He=I[be],le=await ye("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:m,providerId:(a==null?void 0:a.id)??ie??void 0,transportAdapter:j,model:be,apiKey:w||void 0,backend:g||"unknown",thinkingField:W||void 0,mode:rt,modelConfig:{temperature:He==null?void 0:He.temperature,topP:He==null?void 0:He.topP,topK:He==null?void 0:He.topK,maxTokens:He==null?void 0:He.maxTokens,supportsVision:He==null?void 0:He.supportsVision,thinkingEnabled:He==null?void 0:He.thinkingEnabled,thinkingLevel:He==null?void 0:He.thinkingLevel,nonThinkingEnabled:He==null?void 0:He.nonThinkingEnabled,thinkingQueryParams:He==null?void 0:He.thinkingQueryParams,nonThinkingQueryParams:He==null?void 0:He.nonThinkingQueryParams,omitParams:He==null?void 0:He.omitParams}})}),Ke=await le.json();le.ok?Y(xt=>({...xt,[Qe]:{loading:!1,result:JSON.stringify(Ke,null,2),message:Ke.message}})):Y(xt=>({...xt,[Qe]:{loading:!1,error:Ke.error??"Test failed"}}))}catch(He){Y(le=>({...le,[Qe]:{loading:!1,error:He instanceof Error?He.message:"Request failed"}}))}}function _n(){F([]),M({}),$({loading:!1,progress:{}}),Y({}),U(null),J(new Set),ne(""),Ne(""),at(null)}function xn(){ie&&!We.current&&ye(`/api/providers/${ie}`,{method:"DELETE"}).catch(be=>{console.warn("Failed to clean up draft provider",be)}),t()}function hr(){const be=c||"Provider",rt=(a==null?void 0:a.id)??ie??`temp-${Date.now()}`;n({id:rt,name:be,url:m,backend:g||"unknown",apiKey:w||void 0,isLocal:v,thinkingField:W||void 0,sendReasoningInMessages:Q,authAdapter:_,transportAdapter:j,models:O.map(Qe=>{var He,le,Ke,xt,Mt,ke,Ee,Fe,Je,st,bt,jt,In,Cn,Tn,fo,Ws;return{id:Qe.id,name:Qe.name,apiModelId:Qe.apiModelId,requestBody:Qe.requestBody,reasoningEfforts:Qe.reasoningEfforts,contextWindow:((He=I[Qe.id])==null?void 0:He.contextWindow)??Qe.contextWindow,selected:B.has(Qe.id)||void 0,supportsVision:(le=I[Qe.id])==null?void 0:le.supportsVision,thinkingEnabled:(Ke=I[Qe.id])==null?void 0:Ke.thinkingEnabled,thinkingLevel:(xt=I[Qe.id])==null?void 0:xt.thinkingLevel,nonThinkingEnabled:(Mt=I[Qe.id])==null?void 0:Mt.nonThinkingEnabled,thinkingQueryParams:(ke=I[Qe.id])==null?void 0:ke.thinkingQueryParams,nonThinkingQueryParams:(Ee=I[Qe.id])==null?void 0:Ee.nonThinkingQueryParams,omitParams:(Fe=I[Qe.id])==null?void 0:Fe.omitParams,temperature:(Je=I[Qe.id])==null?void 0:Je.temperature,topP:(st=I[Qe.id])==null?void 0:st.topP,topK:(bt=I[Qe.id])==null?void 0:bt.topK,maxTokens:(jt=I[Qe.id])==null?void 0:jt.maxTokens,defaultMaxTokens:(In=I[Qe.id])==null?void 0:In.defaultMaxTokens,defaultTemperature:(Cn=I[Qe.id])==null?void 0:Cn.defaultTemperature,defaultTopP:(Tn=I[Qe.id])==null?void 0:Tn.defaultTopP,defaultTopK:(fo=I[Qe.id])==null?void 0:fo.defaultTopK,compactionThreshold:(Ws=I[Qe.id])==null?void 0:Ws.compactionThreshold}})}),We.current=!0,t()}return e?s.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[s.jsxs(mt,{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),s.jsx("button",{onClick:xn,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(be=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${be<d?"bg-accent-success":be===d?"bg-accent-primary":"bg-border"}`},be))}),d===1&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),s.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[ot.map(be=>s.jsx("button",{type:"button",onClick:()=>{h(be.defaults.name??be.name),f(be.defaults.url),x(be.defaults.backend),S(!1),C(""),b(be.authAdapter),E(be.transportAdapter),D(null),_n()},className:`p-2 rounded border text-center text-sm transition-colors ${j&&j===be.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:be.name},be.id)),s.jsx("button",{type:"button",onClick:()=>{x("unknown"),S(!1),b(void 0),E(void 0),D(null),_n()},className:`p-2 rounded border text-center text-sm transition-colors ${g==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),$G.map(be=>{const rt={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},Qe={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return s.jsx("button",{type:"button",onClick:()=>{h(He=>He||(Qe[be]??"")),f(He=>He||`http://localhost:${be}`),x(rt[be]??""),S(!0),b(void 0),E(void 0),D(null),_n()},className:`p-2 rounded border text-center text-sm transition-colors ${g===rt[be]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Qe[be]??`localhost:${be}`},be)})]})]}),!_&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),s.jsx("input",{ref:Ze,type:"text",value:m,"data-testid":"provider-modal-url",onChange:be=>{f(be.target.value),D(null),F([]),M({})},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),s.jsx("input",{type:"text",autoComplete:"off",value:c,onChange:be=>h(be.target.value),placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!_&&s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx("input",{type:"text",autoComplete:"off",value:w,onChange:be=>C(be.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!_&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:be=>S(be.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),d===2&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Test & Configure Models"}),s.jsx("button",{type:"button",onClick:()=>q(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:s.jsx(IE,{className:"w-4 h-4"})})]}),!!_&&s.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),pe==="connected"?s.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):s.jsx("button",{type:"button",onClick:()=>void tt(),disabled:$e||pe==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:$e||pe==="pending"?"Connecting...":pe==="error"?"Retry":"Connect"})]}),Ve&&s.jsx("div",{className:"mt-4 border-t border-border pt-4",children:Ve.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),s.jsx("button",{type:"button",onClick:()=>void et(),className:"mt-3 w-full rounded-lg border border-accent-primary/40 px-4 py-4 font-mono text-2xl font-semibold tracking-[0.2em] text-accent-primary",children:Ve.userCode??"Continue"}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>void et(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:_e?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:dt,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:me?"Reopen authorization":"Open authorization"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted mb-3",children:Ve.instructions}),s.jsx("button",{type:"button",onClick:dt,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:me?"Reopen authorization":"Open authorization"})]})})]}),N&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),A&&s.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[s.jsx("p",{children:A}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",m]}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>Lt(m),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),s.jsx("button",{onClick:()=>{_n(),u(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"}),!_&&s.jsx("button",{onClick:()=>{var be;return(be=it.current)==null?void 0:be.focus()},className:"text-xs text-accent-primary hover:underline",children:"Add model manually"})]})]}),g&&(!_||pe==="connected")&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Add model manually"}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:A?"Can't discover models automatically? Enter the model name to use:":"Enter a model name manually if it does not appear in the list above:"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:it,type:"text",value:ce,onChange:be=>{Ne(be.target.value),Xe&&at(null)},onKeyDown:be=>{be.key==="Enter"&&(be.preventDefault(),Se())},placeholder:"model-name","data-testid":"provider-modal-manual-model-input",className:"flex-1 px-3 py-1.5 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),s.jsx("button",{type:"button",onClick:Se,"data-testid":"provider-modal-manual-model-add",className:"px-3 py-1.5 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Add"})]}),Xe&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:Xe})]}),O.length>0&&g&&(!_||pe==="connected")&&s.jsxs(s.Fragment,{children:[B.size>0&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",B.size,")"]}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),s.jsx("div",{className:"space-y-2",children:O.filter(be=>B.has(be.id)).map(be=>{var rt;return s.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{onClick:()=>z(P===be.id?null:be.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:be.name??be.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((rt=I[be.id])==null?void 0:rt.contextWindow)??be.contextWindow).toLocaleString()," ctx"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[V.progress[be.id]==="probing"?s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):V.progress[be.id]==="done"?s.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):V.progress[be.id]==="error"?s.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):_?null:s.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),qt(be.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),O.length>1&&s.jsx("button",{onClick:Qe=>{Qe.stopPropagation();const He=new Set(B);He.delete(be.id),J(He),P===be.id&&z(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),s.jsx(gn,{className:`w-4 h-4 text-text-muted transition-transform ${P===be.id?"rotate-180":""}`})]})]}),P===be.id&&s.jsx(FG,{model:be,modelConfigs:I,autoConfigState:V,testResults:ee,onUpdateConfig:nt,onRunAutoConfig:qt,onTestParams:vn,onShowRaw:U})]},be.id)})})]}),O.length>1&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),B.size===0&&s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"This provider has many models available. Select the ones you want to use below."}),s.jsxs("div",{className:"relative mb-2",children:[s.jsx("input",{type:"text",value:se,onChange:be=>ne(be.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),se&&s.jsx("button",{onClick:()=>ne(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",Re(se).length," of ",O.length," models"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{const be=new Set(B),rt=Re(se);for(const Qe of rt)be.add(Qe.id);if(J(be),M(Qe=>{const He={...Qe};for(const le of rt)He[le.id]={contextWindow:le.contextWindow,...He[le.id]};return He}),!_)for(const Qe of rt)V.progress[Qe.id]!=="probing"&&V.progress[Qe.id]!=="done"&&qt(Qe.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),s.jsx("button",{onClick:()=>{const be=new Set(B),rt=Re(se);for(const Qe of rt)be.delete(Qe.id);J(be)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),s.jsxs(mt,{className:"space-y-1 max-h-48 border border-border rounded-lg bg-bg-primary",children:[Re(se).map(be=>{var Qe;const rt=B.has(be.id);return s.jsxs("div",{role:"checkbox","aria-checked":rt,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${rt?"bg-accent-primary/5":""}`,onClick:()=>{if(rt){const He=new Set(B);He.delete(be.id),J(He)}else De(be),_||qt(be.id)},onKeyDown:He=>{(He.key==="Enter"||He.key===" ")&&(He.preventDefault(),He.currentTarget.click())},children:[s.jsx("input",{type:"checkbox",checked:rt,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),s.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:be.name??be.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Qe=I[be.id])==null?void 0:Qe.contextWindow)??be.contextWindow).toLocaleString()," ctx"]}),V.progress[be.id]==="probing"&&s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),V.progress[be.id]==="done"&&s.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),V.progress[be.id]==="error"&&s.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},be.id)}),Re(se).length===0&&s.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",se,"”"]})]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[s.jsx("div",{children:d>1&&s.jsx("button",{onClick:()=>{d===2&&_n(),u(d-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:xn,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),d===1?s.jsx("button",{onClick:()=>u(2),disabled:!m,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):s.jsx("button",{onClick:hr,disabled:V.loading,"data-testid":"provider-modal-save",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:V.loading?"Configuring...":"Save Provider"})]})]})]}),K&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:be=>{be.target===be.currentTarget&&q(!1)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),s.jsx("button",{onClick:()=>q(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'reasoning_effort: "low"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",s.jsx("span",{className:"text-text-muted",children:"(override)"})]}),s.jsx("input",{type:"text",value:W,onChange:be=>Z(be.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Field name the backend uses for reasoning/thinking content (e.g. reasoning, reasoning_content, thinking)."})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Q,onChange:be=>H(be.target.checked),className:"rounded border-border bg-bg-primary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"Send reasoning in messages"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:"When disabled, strips reasoning/thinking content from assistant messages sent to this provider"})]})]}),s.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:s.jsx("button",{onClick:()=>q(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),X&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:be=>{be.target===be.currentTarget&&U(null)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),s.jsx("button",{onClick:()=>U(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx(mt,{horizontal:!0,children:s.jsx("pre",{className:"px-6 py-4 text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:X})})]})})]}):null}function dj({activeProvider:e,shortModelName:t,agentOverrideActive:n,agentColor:r,agentName:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-accent-primary flex items-center gap-1",children:[n&&s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 ring-1 ring-border",style:{backgroundColor:r??"#6b7280"},title:`Model set by agent "${a??"unknown"}". Change it in Settings > Agents.`}),e?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"hidden @sm:inline",children:[e.name," • "]}),t]}):t]}),s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${e!=null&&e.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:e!=null&&e.isLocal?"local":"api"})]})}function HG(){var He;const[,e]=Fn(),t=jr(),n=on(t,le=>le.session??null,le=>le.currentSession,null),r=Le(le=>le.setSessionProvider),[a,o]=k.useState(!1),[d,u]=k.useState([]),[c,h]=k.useState(null),m=k.useRef(null),[f,g]=k.useState(null),[x,w]=k.useState(!1),[C,v]=k.useState({}),[S,_]=k.useState(null),[b,j]=k.useState(null),[E,N]=k.useState(!1),L=k.useRef(null),[A,D]=k.useState(!1),O=k.useRef(new Set),F=an(le=>le.providers),P=an(le=>le.activeProviderId),z=an(le=>le.defaultModelSelection),K=an(le=>le.activating),q=an(le=>le.activateProvider),W=an(le=>le.refreshModel),Z=an(le=>le.refreshProviderModels),Q=an(le=>le.setDefaultModel),H=an(le=>le.fetchConfig),I=Tu();xu(I.modelSelector,()=>o(le=>!le));const M=(n==null?void 0:n.providerId)??null,V=(n==null?void 0:n.providerModel)??null,$=(z==null?void 0:z.split("/")[0])??null,ee=(z==null?void 0:z.split("/").slice(1).join("/"))??null,Y=ft(le=>le.defaults),X=ft(le=>le.userItems),U=ft(le=>le.modelOverrides),B=n==null?void 0:n.mode,J=B?Y.find(le=>le.id===B)??X.find(le=>le.id===B):void 0,se=B?U[B]??void 0:void 0,ne=se?se.split("/")[0]??null:null,ie=se?se.split("/").slice(1).join("/")??null:null,de=B?lo([...Y,...X],B):void 0,pe=!!se,Oe=ne??M??$,$e=ie??V??ee,Pe=$e?((He=$e.split("/").pop())==null?void 0:He.replace(/-/g," "))??$e:"No model",[Ve,Ye]=k.useState(!1);k.useEffect(()=>{function le(Ke){m.current&&!m.current.contains(Ke.target)&&(o(!1),u([]),O.current=new Set)}return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[]),k.useEffect(()=>()=>{L.current!==null&&window.clearTimeout(L.current)},[]),k.useEffect(()=>{a||(dt(""),qt(-1))},[a]),k.useEffect(()=>{var le;a&&Wt()&&((le=be.current)==null||le.focus())},[a]),k.useEffect(()=>{if(a){const le=F.map(Ke=>Ke.id);u(le),F.filter(Ke=>!!Ke.authAdapter).forEach(Ke=>void at(Ke.id)),le.forEach(Ke=>{O.current.has(Ke)||(O.current.add(Ke),_e(Ke))})}},[a,F]),k.useEffect(()=>{if(!b)return;let le=!1;const Ke=async()=>{const Mt=await at(b.providerId);le||Mt==="connected"&&(j(null),N(!1),D(!1),await H(),O.current.delete(b.providerId),await _e(b.providerId))};Ke();const xt=window.setInterval(()=>void Ke(),2e3);return()=>{le=!0,window.clearInterval(xt)}},[b]);const ot=F.find(le=>le.id===Oe),Ae=(ot==null?void 0:ot.status)==="disconnected",me=(le,Ke)=>n?n.providerId===le&&n.providerModel===Ke:!1,re=(le,Ke)=>z?z===`${le}/${Ke}`:!1,_e=async le=>{h(le);try{await Z(le)}catch{}finally{h(null)}},Me=le=>{d.includes(le.id)?u(d.filter(Ke=>Ke!==le.id)):(u([...d,le.id]),_e(le.id))},ce=async le=>{if(le.id===P){Me(le);return}n&&t?(r(t,le.id,void 0),o(!1),u([])):await q(le.id)&&(o(!1),u([]))},Ne=le=>{Me(le)},Xe=async(le,Ke)=>{le.stopPropagation(),O.current.delete(Ke),await _e(Ke)},at=async le=>{const Ke=await ye(`/api/provider-auth/${le}/status`);if(!Ke.ok)return"error";const xt=await Ke.json();return v(Mt=>({...Mt,[le]:xt.state})),xt.state},fe=async(le,Ke)=>{le.stopPropagation(),_(Ke),v(xt=>({...xt,[Ke]:"pending"})),N(!1),D(!1);try{const xt=await ye(`/api/provider-auth/${Ke}/login`,{method:"POST"});if(!xt.ok)throw new Error("Unable to start provider sign-in");const Mt=await xt.json();j({providerId:Ke,...Mt})}catch{v(xt=>({...xt,[Ke]:"error"}))}finally{_(null)}},We=async()=>{var le;b!=null&&b.userCode&&(await((le=navigator.clipboard)==null?void 0:le.writeText(b.userCode)),L.current!==null&&window.clearTimeout(L.current),N(!1),requestAnimationFrame(()=>N(!0)),L.current=window.setTimeout(()=>{N(!1),L.current=null},1500))},Ze=()=>{b&&(window.open(b.directUrl??b.verificationUrl,"_blank","noopener,noreferrer"),D(!0))},it=()=>{j(null),N(!1),D(!1)},nt=async(le,Ke)=>{le.stopPropagation(),_(Ke);try{if(!(await ye(`/api/provider-auth/${Ke}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");v(Mt=>({...Mt,[Ke]:"disconnected"})),await H()}finally{_(null)}},De=(le,Ke)=>{g({providerId:le,model:Ke}),w(!0)},Re=f?F.find(le=>le.id===f.providerId):void 0,Se=()=>{g(null),w(!1)},Ue=async le=>{try{if(!(await ye(`/api/providers/${le.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(eL(le))})).ok)throw new Error("Failed to update provider");await an.getState().fetchConfig()}catch{}g(null),w(!1)},ve=async(le,Ke)=>{if(B&&se&&se!==`${le}/${Ke}`&&(ye(`/api/agents/${B}/model`,{method:"DELETE"}).catch(()=>{}),ft.setState(Mt=>{const ke={...Mt.modelOverrides};return delete ke[B],{modelOverrides:ke}})),n&&t){Le.setState(Mt=>({...Mt,currentSession:Mt.currentSession?{...Mt.currentSession,providerId:le,providerModel:Ke}:null})),r(t,le,Ke),u([]),o(!1),ju();return}await q(le)&&(u([]),o(!1),ju())},tt=async(le,Ke,xt)=>{le.stopPropagation(),Ye(!0);try{await Q(Ke,xt)}catch{}finally{Ye(!1)}},{searchQuery:et,setSearchQuery:dt,highlightedIndex:Lt,setHighlightedIndex:qt,visibleGroups:vn,flatItems:_n,handleSearchKeyDown:xn,highlightedRef:hr,inputRef:be}=ZT({providers:F,onSelect:ve,onEscape:()=>o(!1),extraItemCount:1}),rt=Lt===_n.length,Qe=le=>{if(le.key==="Enter"&&Lt===_n.length){le.preventDefault(),e("/onboarding"),o(!1);return}xn(le)};return F.length===0?s.jsxs("button",{type:"button",onClick:()=>W(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:Ae?"LLM server is offline. Click to retry.":Pe??"Click to refresh model",children:[Ae?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):s.jsx(dj,{activeProvider:ot,shortModelName:Pe,agentOverrideActive:pe,agentColor:de,agentName:J==null?void 0:J.name}),s.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):s.jsxs("div",{className:"relative",ref:m,children:[s.jsxs("button",{type:"button",onClick:()=>o(!a),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:[Ae?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):s.jsx(dj,{activeProvider:ot,shortModelName:Pe,agentOverrideActive:pe,agentColor:de,agentName:J==null?void 0:J.name}),s.jsx(gn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(Fs,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:be,type:"text",value:et,onInput:le=>{dt(le.currentTarget.value),qt(-1)},onKeyDown:Qe,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsx(mt,{className:"flex-1 min-h-0",children:s.jsxs("div",{children:[vn.map(le=>{const Ke=et.trim().length>0||d.includes(le.provider.id);return s.jsxs("div",{children:[s.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${le.provider.id===Oe?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${K?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[s.jsxs("div",{onClick:()=>!K&&ce(le.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[s.jsx("span",{className:`text-sm font-medium truncate ${le.provider.id===Oe?"text-accent-primary":"text-text-primary"}`,children:le.provider.name}),s.jsx("span",{className:"text-xs text-text-muted truncate",children:le.provider.backend!=="unknown"&&_E(le.provider.backend)})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!le.provider.authAdapter&&(C[le.provider.id]==="connected"||le.provider.credentialRef?s.jsx("button",{type:"button",onClick:xt=>nt(xt,le.provider.id),disabled:S===le.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-success/40 text-accent-success hover:bg-accent-success/10 disabled:opacity-50",title:"Disconnect provider account",children:"Connected"}):s.jsx("button",{type:"button",onClick:xt=>fe(xt,le.provider.id),disabled:S===le.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-primary/40 text-accent-primary hover:bg-accent-primary/10 disabled:opacity-50",title:"Connect provider account",children:S===le.provider.id?"Starting…":C[le.provider.id]==="error"||C[le.provider.id]==="expired"?"Retry":"Connect"})),le.provider.id===Oe?s.jsx("span",{className:"text-accent-success",title:"Active provider",children:s.jsx(Us,{className:"w-4 h-4"})}):s.jsx("span",{className:"w-4"}),s.jsx("button",{type:"button",onClick:xt=>{xt.stopPropagation(),Xe(xt,le.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:s.jsx(Yf,{className:`w-4 h-4 ${c===le.provider.id?"animate-spin":""} ${le.provider.id===P?"text-accent-primary":"text-text-muted"}`})}),s.jsx("button",{type:"button",onClick:xt=>{xt.stopPropagation(),Ne(le.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:s.jsx(gn,{className:`w-4 h-4 transition-transform ${Ke?"rotate-180":""} ${le.provider.id===P?"text-accent-primary":"text-text-muted"}`})})]})]}),Ke&&s.jsx(mt,{className:"bg-bg-primary border-t border-border max-h-40",children:c===le.provider.id?s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):le.models.length>0?le.models.map(xt=>{const ke=_n.findIndex(Ee=>Ee.providerId===le.provider.id&&Ee.modelConfig.id===xt.id)===Lt;return s.jsx("div",{ref:ke?hr:void 0,children:s.jsx(JT,{providerId:le.provider.id,modelConfig:xt,isActive:me(le.provider.id,xt.id),isDefault:re(le.provider.id,xt.id),disabled:c==="activating",hasSession:!!n,settingDefault:Ve,highlighted:ke,onModelClick:ve,onSetDefault:tt,onEditModel:De})},`${le.provider.id}/${xt.id}`)}):s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},le.provider.id)}),vn.length===0&&et.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})}),s.jsx("div",{className:`border-t border-border px-3 py-2 ${rt?"bg-bg-tertiary":""} flex-shrink-0`,children:s.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),b&&s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 px-4",role:"dialog","aria-modal":"true","aria-labelledby":"provider-device-title",onMouseDown:le=>{le.target===le.currentTarget&&it()},children:s.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),s.jsx("button",{type:"button",onClick:it,className:"rounded px-2 py-1 text-xl leading-none text-text-muted hover:bg-bg-tertiary hover:text-text-primary","aria-label":"Close",children:"×"})]}),b.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:We,className:"mt-6 w-full select-all rounded-lg border border-accent-primary/40 bg-bg-primary px-4 py-5 font-mono text-3xl font-semibold tracking-[0.2em] text-accent-primary hover:bg-bg-tertiary",title:"Copy code",children:b.userCode??"Continue"}),s.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:E?"Copied to clipboard":"Click the code to copy it"}),s.jsxs("div",{className:"mt-6 flex gap-3",children:[s.jsx("button",{type:"button",onClick:We,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:E?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:Ze,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:A?"Reopen authorization":"Open authorization"})]}),s.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:A?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:b.instructions}),s.jsx("div",{className:"mt-6 flex gap-3",children:s.jsx("button",{type:"button",onClick:Ze,className:"w-full rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:A?"Reopen authorization":"Open authorization"})})]})]})}),f&&x&&s.jsx(tL,{isOpen:!0,onClose:Se,onSave:Ue,initialStep:2,editProvider:{id:f.providerId,name:(Re==null?void 0:Re.name)??"",url:(Re==null?void 0:Re.url)??"",backend:(Re==null?void 0:Re.backend)??"unknown",apiKey:Re==null?void 0:Re.apiKey,isLocal:Re==null?void 0:Re.isLocal,thinkingField:Re==null?void 0:Re.thinkingField,sendReasoningInMessages:Re==null?void 0:Re.sendReasoningInMessages,authAdapter:Re==null?void 0:Re.authAdapter,transportAdapter:Re==null?void 0:Re.transportAdapter,models:Re==null?void 0:Re.models},editModelId:f.model.id})]})}function UG(){const e=mu(j=>j.servers),t=mu(j=>j.fetchServers),n=Le(j=>j.currentSession),r=n==null?void 0:n.id,[a,o]=k.useState(!1),[d,u]=k.useState(null),[c,h]=k.useState(new Set),[m,f]=k.useState(new Set),g=k.useRef(null),x=k.useCallback(async()=>{if(r)try{const j=await ye(`/api/sessions/${r}/mcp/overrides`);if(j.ok){const E=await j.json();f(new Set(E.disabledServers??[]))}}catch{}},[r]),w=k.useCallback(async()=>{await t(),await x()},[t,x]);k.useEffect(()=>{const j=()=>w();return window.addEventListener("mcp-servers-changed",j),()=>window.removeEventListener("mcp-servers-changed",j)},[w]),k.useEffect(()=>{x()},[x]),k.useEffect(()=>{a&&x()},[a,x]),wm(g,()=>o(!1));const C=j=>m.has(j.name),v=e.filter(j=>j.status==="connected"&&!C(j)),S=v.length,_=v.reduce((j,E)=>j+E.estimatedTokens,0),b=async(j,E)=>{if(r){u(null),h(N=>new Set(N).add(j));try{const N=new Set(m);E?N.add(j):N.delete(j);const L=await ye(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(N)})});if(!L.ok){const A=await L.json().catch(()=>({}));throw new Error(A.error??"Toggle failed")}f(N),await t()}catch(N){u(N instanceof Error?N.message:String(N))}finally{h(N=>{const L=new Set(N);return L.delete(j),L})}}};return s.jsxs("div",{className:"relative",ref:g,children:[s.jsxs("button",{type:"button",onClick:()=>o(!a),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:S>0?`${S} MCP server(s) active`:"No MCP server active",children:[s.jsx("span",{className:"text-sm text-accent-primary whitespace-nowrap",children:S>0?`● ${S} MCP (${bf(_)})`:"MCP"}),s.jsx(gn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[s.jsx(mt,{className:"flex-1 min-h-0",children:e.length===0?s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No MCP servers configured"}):e.map(j=>{const E=C(j),N=c.has(j.name);return s.jsx("div",{children:s.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-bg-tertiary",children:[s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("span",{className:`text-sm ${bv(E?"disabled":j.status)}`,children:vv(E?"disabled":j.status)}),s.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:j.name})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted ml-3.5",children:[s.jsxs("span",{children:[j.tools.length," tools"]}),j.estimatedTokens>0&&s.jsxs("span",{children:[bf(j.estimatedTokens)," tokens"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[N&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"..."}),s.jsx(ys,{enabled:!E,onClick:()=>b(j.name,!E)})]})]})},j.name)})}),s.jsx("div",{className:"border-t border-border px-3 py-2 flex-shrink-0",children:d?s.jsx("div",{className:"text-xs text-accent-error",children:d}):s.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," server(s) configured"]})})]})]})}const hj=24,fj=200;function VG({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:o,errorMessage:d,setErrorMessage:u,scrollToBottom:c,sessionId:h,showHistory:m,history:f,selectedIndex:g,openHistory:x,closeHistory:w,navigateUp:C,navigateDown:v,selectCurrent:S,isAutoScrollActive:_,setAutoScroll:b,onOpenMessageSearch:j,onOpenCommandsModal:E,onOpenWorkflowsModal:N,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:A,onSendCommand:D,clearInput:O}){const F=k.useRef(null),P=k.useRef(null),z=k.useRef(0),K=k.useRef(0),q=k.useRef(null),W=k.useRef(null),Z=Wf(h),Q=Le(fe=>fe.stopGeneration),H=Le(fe=>fe.cancelQueued),I=G3(h),M=on(h,fe=>fe.restoredInput??null,fe=>fe.restoredInput,null),V=Le(fe=>fe.clearRestoredInput),$=on(h,fe=>{var We;return((We=fe.session)==null?void 0:We.workdir)??void 0},fe=>{var We;return(We=fe.currentSession)==null?void 0:We.workdir},void 0),ee=on(h,fe=>fe.session??null,fe=>fe.currentSession,null),Y=k.useRef(!1),X=k.useRef(void 0),U=k.useRef(!1),[B,J]=k.useState([]),se=k.useRef(null),{sendMessage:ne,launchWorkflow:ie}=JA(b,h);k.useEffect(()=>{X.current!==$&&(X.current=$,Gt.getState().fetchWorkflows($),cn.getState().fetchCommands($))},[$]),k.useEffect(()=>{e||J([])},[e]),k.useEffect(()=>{var fe;M!==null&&(t(M),V(h),Wt()&&((fe=F.current)==null||fe.focus()))},[M,t,V]);const de=k.useCallback((fe={})=>{const We=F.current;if(!We)return;if(!e){We.style.height=`${hj}px`;return}const Ze=e.length>=z.current;z.current=e.length,(fe.force||!Ze)&&(We.style.height="auto"),We.style.height=`${Math.min(fj,We.scrollHeight)}px`},[e]),pe=k.useRef(de);k.useEffect(()=>{pe.current=de},[de]),k.useEffect(()=>{if(!h)return;const fe=`openfox:draft:${h}`,We=localStorage.getItem(fe);We!==null&&t(We)},[h,t]),k.useEffect(()=>{var fe;Wt()&&((fe=F.current)==null||fe.focus()),de()},[h,de]),k.useEffect(()=>{if(!h)return;const fe=`openfox:draft:${h}`,We=setTimeout(()=>{e?localStorage.setItem(fe,e):localStorage.removeItem(fe)},500);return()=>clearTimeout(We)},[h,e]),k.useEffect(()=>{de()},[e,de]),k.useEffect(()=>{var it;const fe=(it=F.current)==null?void 0:it.parentElement;if(!fe||typeof ResizeObserver>"u")return;let We=fe.clientWidth;const Ze=new ResizeObserver(()=>{const nt=fe.clientWidth;nt!==We&&(We=nt,pe.current({force:!0}))});return Ze.observe(fe),()=>Ze.disconnect()},[]),k.useEffect(()=>{const fe=F.current;if(!fe)return;const We=async Ze=>{var De;if(document.activeElement!==fe)return;const it=(De=Ze.clipboardData)==null?void 0:De.items;if(!it)return;const nt=[];for(const Re of Array.from(it)){let Se=Re.getAsFile();if(Se&&BU(Se.type)){if(Ze.preventDefault(),!Se.name){const Ue=PU(Se.type);Se=new File([Se],`pasted-file.${Ue}`,{type:Se.type})}await Yy(Se,Ue=>nt.push(Ue),u)}}nt.length>0&&r(Re=>[...Re,...nt])};return fe.addEventListener("paste",We),()=>fe.removeEventListener("paste",We)},[r,u]);const Oe=fe=>{fe.preventDefault(),!(!e.trim()&&n.length===0)&&_e()},$e=fe=>{var We,Ze;if(!((We=W.current)!=null&&We.handleKeyDown(fe))&&!((Ze=q.current)!=null&&Ze.handleKeyDown(fe))){if(m)switch(fe.key){case"Enter":{fe.preventDefault();const it=S();it&&(t(it),w());return}case"Escape":fe.preventDefault(),w(),Z&&h&&Q(h);return;case"ArrowUp":fe.preventDefault(),C();return;case"ArrowDown":fe.preventDefault(),v();return}if(fe.key==="ArrowUp"&&e.trim()===""&&!m){fe.preventDefault(),x();return}fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),Oe(fe))}};async function Pe(fe,We,Ze){const it=[];for(const nt of Array.from(fe))await Yy(nt,De=>it.push(De),Ze);it.length>0&&We(nt=>[...nt,...it])}const Ve=k.useCallback(async fe=>{const We=fe.target.files;!We||We.length===0||(u(null),await Pe(We,r,u),P.current&&(P.current.value=""))},[r,u]),Ye=k.useCallback(fe=>{var We;(We=fe.dataTransfer.types)!=null&&We.includes("Files")&&(fe.preventDefault(),fe.stopPropagation(),o(!0))},[o]),ot=k.useCallback(fe=>{fe.preventDefault(),fe.stopPropagation(),o(!1)},[o]),Ae=k.useCallback(async fe=>{fe.preventDefault(),fe.stopPropagation(),o(!1),u(null);const We=fe.dataTransfer.files;!We||We.length===0||await Pe(We,r,u)},[r,o,u]),me=k.useCallback(fe=>{r(n.filter(We=>We.id!==fe))},[n,r]),re=k.useCallback(()=>{var fe;(fe=P.current)==null||fe.click()},[]),_e=()=>{if(U.current||!e.trim()&&n.length===0)return;if(U.current=!0,c==null||c(),e.trim().startsWith("/")){const We=Al(Gt.getState()),Ze=cn.getState(),it=Gn(Gn(Ze.defaults,Ze.userItems),Ze.projectItems),nt=bG(e,We,it);if(nt!=null&&nt.workflowId){const De=se.current,Re=De&&De.id===nt.workflowId?De.scope:"auto";se.current=null;const Se=qy(We,nt.workflowId,Re),Ue=((Se==null?void 0:Se.parameters)??[]).filter(ve=>ve.required&&!(ve.id in nt.params));if(Ue.length>0){const ve=Ue.map(tt=>tt.label||tt.id).join(", ");u(`Missing required parameter${Ue.length>1?"s":""}: ${ve}`),U.current=!1;return}ie(void 0,void 0,nt.workflowId,void 0,nt.params,Re),O(),U.current=!1;return}if(nt!=null&&nt.commandId){Ze.fetchCommand(nt.commandId,$).then(De=>{if(De){const Re=QA(De.prompt),Se={};for(const[ve,tt]of Object.entries(nt.params)){const et=parseInt(ve,10),dt=Re[et];dt&&(Se[dt]=tt)}let Ue=De.prompt;for(const[ve,tt]of Object.entries(Se))Ue=Ue.replaceAll(`{{${ve}}}`,tt);D(Ue,De.metadata.agentMode),O()}U.current=!1});return}}ne(e,n),O(),U.current=!1},Me=k.useCallback((fe,We)=>{const it=fe.type==="directory"?"/":" ",{newText:nt,newCursorPos:De}=Sf(e,K.current,We,`@${fe.path}${it}`);t(nt),K.current=De,wf(F.current,De)},[e,t]),ce=k.useCallback((fe,We)=>{const{newText:Ze,newCursorPos:it}=Sf(e,K.current,We,`/${fe.id} `);t(Ze),K.current=it,wf(F.current,it),fe.type==="workflow"&&(se.current={id:fe.id,scope:fe.scope}),J(rA(fe))},[e,t]),Ne=k.useCallback(fe=>{const We=fe.target.value;t(We),m&&w(),K.current=fe.target.selectionStart;const Ze=se.current;if(Ze){const it=We.match(/^\/(\S+)/),nt=it?it[1]:void 0;(!nt||nt!==Ze.id)&&(se.current=null)}B.length>0&&(!We.startsWith("/")||!We.includes(" "))&&J([]),!Y.current&&h&&We&&ee&&(ee.messageCount??0)===0&&(Y.current=!0,ye(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,m,w,h,ee,B]),Xe=k.useCallback(fe=>{K.current=fe.target.selectionStart},[]),at=k.useCallback(fe=>{K.current=fe.currentTarget.selectionStart},[]);return s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"absolute -top-8 left-2 @md:left-4 z-10",children:s.jsx(CG,{})}),s.jsxs("div",{className:`absolute -top-8 right-2 @md:right-4 z-10 flex items-center gap-2 border${_?" border-transparent":" rounded backdrop-blur-xl saturate-150 border-border"}`,children:[s.jsx(Av,{isActive:_,onToggle:b,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"}),s.jsxs("button",{type:"button",onClick:j,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[s.jsx(Fs,{}),"Browse history"]})]}),s.jsx(jG,{}),s.jsxs("form",{onSubmit:Oe,className:"p-2 @md:p-4 bg-secondary rounded-lg",children:[s.jsx("input",{ref:P,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:Ve,className:"hidden",multiple:!0}),d&&s.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:d}),n.length>0&&s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(fe=>s.jsx(Sv,{attachment:fe,onRemove:me},fe.id))}),m&&s.jsx(vG,{history:f,selectedIndex:g,onSelect:fe=>{t(fe),w()},onEscape:w,onNavigate:fe=>{fe==="up"?C():v()}}),s.jsx(LG,{messages:I,onCancel:fe=>h&&H(h,fe)}),s.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:Ye,onDragLeave:ot,onDrop:Ae,children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx("textarea",{id:FT,ref:F,value:e,onChange:Ne,onKeyDown:$e,onSelect:Xe,onKeyUp:at,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:`${hj}px`,maxHeight:`${fj}px`},spellCheck:!1}),s.jsx(nA,{ref:q,text:e,cursorPos:K.current,workdir:$,onSelect:Me}),s.jsx(tA,{ref:W,text:e,cursorPos:K.current,workflows:Al(Gt.getState()),commands:(()=>{const fe=cn.getState();return Gn(Gn(fe.defaults,fe.userItems),fe.projectItems)})(),onSelect:ce}),B.length>0&&(()=>{const fe=e.match(/\/(\w+)\s+(.*)$/),Ze=(fe?fe[2].trim().split(/\s+/):[]).filter(Boolean).length,it=B[Ze];return it?s.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[it,"=?"]}):null})()]}),s.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[Z&&s.jsxs("button",{type:"button",onClick:()=>h&&Q(h),"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:[s.jsx(Tb,{}),"Abort"]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button",onClick:_e,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"}),s.jsx(TG,{onSendCommand:D,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:A,onOpenCommandsManager:E,onOpenWorkflowsManager:N,onAttach:re,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(PG,{}),s.jsx(BG,{})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Bt(fe=>fe.settings)[je.FEATURES_PER_SESSION_MCP]==="true"&&s.jsx(UG,{}),s.jsx(HG,{})]})]})]})]})}const WG=4;function GG({projectId:e,sessionId:t}){const n=Ht(w=>w.tasks),r=Ht(w=>w.activeProjectId),a=Ht(w=>w.loadBoard),o=Ht(w=>w.moveTask),d=Ht(w=>w.lastError),[u,c]=k.useState(!1),[h,m]=k.useState(null);k.useEffect(()=>{r!==e&&a(e)},[r,e,a]);const f=k.useMemo(()=>n.filter(w=>w.status==="todo"&&w.sessionIds.length===0).sort((w,C)=>w.position-C.position).slice(0,WG),[n]),g=k.useMemo(()=>n.filter(w=>w.status==="in_progress"&&w.runState==="running").length,[n]);if(f.length===0)return null;const x=async w=>{var v;m(null);const C=await o(e,w.id,"in_progress",{sessionId:t});C!=null&&C.task&&C.task.status==="in_progress"&&C.task.runState==="queued"&&m({label:((v=w.prompt.split(`
320
+ `)[0])==null?void 0:v.slice(0,60))||"This task"})};return s.jsxs("div",{className:"mx-auto max-w-xl w-full",children:[s.jsxs("div",{className:"rounded-lg border border-border bg-bg-secondary/60 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-text-muted",children:[s.jsx(Qf,{className:"w-3.5 h-3.5"}),"Up next",g>0&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-xs font-medium normal-case tracking-normal text-emerald-400",title:`${g} task${g!==1?"s":""} currently running`,children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),g," running"]})]}),s.jsx(ct,{size:"sm",onClick:()=>c(!0),children:"Manage tasks"})]}),h&&s.jsx("div",{className:"mt-3 rounded-md border border-amber-400/40 bg-amber-400/10 p-2.5",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("p",{className:"text-xs text-text-primary",children:["“",h.label,"” is queued — it’ll start automatically when a slot frees."]}),s.jsx("button",{type:"button",onClick:()=>m(null),title:"Dismiss",className:"shrink-0 text-xs text-text-muted underline hover:text-text-primary transition-colors",children:"Dismiss"})]})}),s.jsx("ul",{className:"mt-3 space-y-2",children:f.map((w,C)=>s.jsxs("li",{className:"flex items-start justify-between gap-3 rounded-md border border-border bg-bg-secondary px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-text-primary font-medium leading-snug line-clamp-2 break-words whitespace-pre-wrap",children:w.prompt}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-text-muted",children:[w.attachments.length>0&&s.jsxs("span",{children:["📎 ",w.attachments.length]}),w.model&&s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary border border-border",children:w.model})]})]}),s.jsxs(ct,{variant:C===0?"primary":"secondary",size:"sm",onClick:()=>void x(w),className:"shrink-0 flex items-center gap-1",children:["Start ",s.jsx(Gf,{className:"w-3 h-3"})]})]},w.id))}),d&&s.jsx("div",{className:"mt-3 text-sm text-accent-error",children:d})]}),s.jsx(Sm,{isOpen:u,onClose:()=>c(!1),projectId:e})]})}function mj({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[o,d]=k.useState({}),u=[...t].sort((m,f)=>(m.position??0)-(f.position??0)),c=()=>{var f;const m={};for(const g of u){const x=(f=o[g.id])==null?void 0:f.trim();x&&(m[g.id]=x)}n(m)},h=u.every(m=>{var f;return!m.required||(((f=o[m.id])==null?void 0:f.trim())??"")!==""});return s.jsxs(Et,{isOpen:!0,onClose:r,title:`Run: ${e}`,size:"sm",closeOnEscape:!0,closeOnBackdropClick:!0,children:[s.jsx("div",{className:"space-y-3 py-2",children:u.map(m=>s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[m.label||m.id,m.required&&s.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),m.description&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:m.description}),s.jsx("input",{value:o[m.id]??"",onChange:f=>d(g=>({...g,[m.id]:f.target.value})),placeholder:m.label||m.id,className:"mt-1 w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:(m.position===0||m===u[0])&&Wt()})]},m.id))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border",children:[s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm text-text-muted hover:text-text-primary transition-colors",children:"Cancel"}),s.jsx("button",{onClick:c,disabled:!h,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a})]})]})}const pj=9999,Oh=k.forwardRef(function({trigger:t,children:n},r){const[a,o]=k.useState(!1),d=k.useRef(null),u=k.useRef(null),c=k.useRef(null),h=k.useCallback(()=>{o(!1)},[]);k.useImperativeHandle(r,()=>({close:h}),[h]);const m=k.useCallback(f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a?h():(c.current=document.activeElement,o(!0))),f.key==="Escape"&&a&&h()},[a,h]);return k.useEffect(()=>{var w;if(!a){Wt()&&((w=c.current)==null||w.focus()),c.current=null;return}const f=C=>{u.current&&!u.current.contains(C.target)&&d.current&&!d.current.contains(C.target)&&h()},g=C=>{C.key==="Escape"&&h()},x=()=>h();return document.addEventListener("mousedown",f),document.addEventListener("keydown",g),window.addEventListener("blur",x),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",g),window.removeEventListener("blur",x)}},[a,h]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:d,role:"button",tabIndex:0,"aria-expanded":a,className:"inline-flex cursor-pointer text-text-muted hover:text-text-primary transition-colors outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/50 rounded",onClick:()=>{a||(c.current=document.activeElement),o(f=>!f)},onKeyDown:m,children:t}),a&&Cs.createPortal(s.jsx("div",{ref:u,role:"dialog","aria-modal":"true",className:"fixed bg-bg-secondary border border-border rounded-lg shadow-xl p-3 w-[320px] max-w-[calc(100vw-16px)] max-h-[60vh]",style:(()=>{if(!d.current)return{zIndex:pj,top:0,left:0};const f=d.current.getBoundingClientRect(),g=320,x=8;let w=f.left;return w+g>window.innerWidth-x&&(w=f.right-g),w=Math.max(x,Math.min(w,window.innerWidth-g-x)),{zIndex:pj,top:f.bottom+4,left:w}})(),children:s.jsx(mt,{className:"max-h-full",children:n})}),document.body)]})});function qG({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=xA.filter(r=>(t.get(r)??0)>0);return n.length===0?s.jsx("span",{className:"text-text-muted text-sm",children:"None"}):s.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:n.map(r=>s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(Vl,{status:r}),s.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function KG({visible:e}){const{contextState:t,currentSession:n}=Ul(),r=Le(J=>J.queueUpdate),a=n?n.workspace??n.workdir:void 0,o=Sb(a),d=o.status,u=o.config,c=o.logs,h=ds(J=>J.start),{branch:m,diff:f}=Nv(),[g,x]=k.useState(!1),[w,C]=k.useState(!1),[v,S]=k.useState(!1),[_,b]=k.useState(null),[j,E]=k.useState(!1),[N,L]=k.useState(!1),A=k.useRef(null),D=k.useRef(null),O=k.useRef(null),F=k.useRef(null),P=Bt(J=>J.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!n)return null;const z=Lu(n.workspace??"")||"original",K=n.metadataEntries??{},q=K.criteria??[],W=["review_findings","todos"],Z=W.filter(J=>{var se;return J in K&&(((se=K[J])==null?void 0:se.length)??0)>0}),Q=Object.keys(K).filter(J=>J!=="criteria"&&!W.includes(J)).filter(J=>{var se;return(((se=K[J])==null?void 0:se.length)??0)>0}),H=[...Z,...Q].reduce((J,se)=>{var ne;return J+(((ne=K[se])==null?void 0:ne.length)??0)},0),I=[...Z,...Q].map(Sl),M=f.files,V=M.reduce((J,se)=>J+se.additions,0),$=M.reduce((J,se)=>J+se.deletions,0),ee=(d==null?void 0:d.state)??"off",Y=ee==="running"||ee==="warning",X=u!==null,U=J=>{J.stopPropagation(),a&&h(a)},B=J=>{J.stopPropagation(),d!=null&&d.url&&window.open(d.url,"_blank")};return s.jsxs("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:[s.jsxs("div",{className:"grid grid-cols-2 @sm:flex @sm:items-center @sm:justify-between gap-x-2 gap-y-1 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1 min-w-0 @sm:shrink-0",children:[s.jsx(wr,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:z}),s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx(to,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:m??"-"}),M.length>0?s.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",V," -",$]}):s.jsx("span",{className:"shrink-0"}),s.jsx(Oh,{ref:F,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(DA,{workspaceName:z,branch:m,workdir:a,showEditorLink:P,sessionId:n.id,projectId:n.projectId,onEditWorkspace:()=>{var J;(J=F.current)==null||J.close(),E(!0)},onEditBranch:()=>{var J;(J=F.current)==null||J.close(),L(!0)}})})]}),s.jsx("div",{className:"hidden @sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex-1 flex items-center @sm:justify-center justify-self-end gap-1 min-w-0",children:[s.jsx(qG,{entries:q}),H>0&&s.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:I.join(", "),children:["+",H]}),s.jsx(Oh,{ref:O,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var J;(J=O.current)==null||J.close(),b("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(kf,{entries:q,title:"Acceptance Criteria"})}),s.jsx(vA,{entries:q,sessionId:n.id})]}),[...Z,...Q].map(J=>{const se=K[J];return s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var ne;(ne=O.current)==null||ne.close(),b(J)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(kf,{entries:se,title:Sl(J)})}),s.jsx(yA,{entries:se})]},J)})]})})]}),s.jsx("div",{className:"hidden @sm:block w-px bg-border self-stretch mx-1"}),s.jsx("div",{className:"col-span-2 border-t border-border @sm:hidden -mx-4"}),s.jsx("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:t&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:t.currentTokens>=1e3?`${Math.round(t.currentTokens/1e3)}K`:t.currentTokens}),s.jsx(Rv,{percent:Math.round(t.currentTokens/t.maxTokens*100),dangerZone:t.dangerZone,size:"sm"}),s.jsx(Oh,{ref:D,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(MA,{onUpdateSystemPrompt:()=>{var J;(J=D.current)==null||J.close(),S(!0)}})})]})}),s.jsx("div",{className:"hidden @sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0 justify-self-end",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${ee==="running"?"bg-accent-success":ee==="warning"?"bg-accent-warning":ee==="error"?"bg-accent-error":"bg-text-muted"}`}),X?Y?s.jsx("button",{onClick:B,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Open dev server",children:s.jsx(Nb,{className:"w-3.5 h-3.5"})}):s.jsx("button",{onClick:U,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Start dev server",children:s.jsx(Kf,{className:"w-3.5 h-3.5"})}):s.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),s.jsx(Oh,{ref:A,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(CA,{workdir:a,compact:!0,onExpand:()=>x(!0),onConfigure:()=>{var J;(J=A.current)==null||J.close(),C(!0)}})})]})]}),g&&s.jsx(Lv,{title:"Dev Server Logs",logs:c,onClose:()=>x(!1)}),w&&s.jsx(_A,{isOpen:!0,onClose:()=>C(!1),workdir:a}),_&&n&&s.jsx(bA,{isOpen:!0,onClose:()=>b(null),entries:K[_]??[],sessionId:n.id,metadataKey:_,title:Sl(_)}),j&&s.jsx(LA,{isOpen:!0,onClose:()=>E(!1),projectId:n.projectId,sessionId:n.id,currentWorkspace:z,currentBranch:m}),N&&s.jsx(RA,{isOpen:!0,onClose:()=>L(!1),sessionId:n.id}),v&&t&&s.jsx(Dv,{isOpen:!0,onClose:()=>S(!1),isRunning:n.isRunning,onApply:()=>{n.isRunning?r(n.id):zt.send("context.applyDynamic",{sessionId:n.id}),S(!1)}})]})}function YG(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function nL(e,t=[]){const n=new Map,r=new Map;for(const h of t)h.type==="message"?n.set(h.message.id,h):h.type==="subagent"&&r.set(h.subAgentId,h);const a=[];let o,d=1,u=null;const c=()=>{if(!u||u.size===0)return;const h=new Map;let m=0;for(const g of e)g.role!=="tool"&&g.contextWindowId===o&&(g.subAgentId&&!h.has(g.subAgentId)&&h.set(g.subAgentId,m),m++);const f=[...u.entries()].sort((g,x)=>(h.get(g[0])??0)-(h.get(x[0])??0));for(const[g,x]of f){const w=r.get(g);(w==null?void 0:w.type)==="subagent"&&w.messages.length===x.messages.length&&w.messages.every((v,S)=>v===x.messages[S])?a.push(w):a.push({type:"subagent",subAgentId:g,subAgentType:x.subAgentType,messages:x.messages})}u=null};for(let h=0;h<e.length;h++){const m=e[h];if(m.role!=="tool")if(m.contextWindowId&&o&&m.contextWindowId!==o&&(c(),d++,a.push({type:"context-divider",windowSequence:d})),o=m.contextWindowId,m.subAgentId&&m.subAgentType){u||(u=new Map);let f=u.get(m.subAgentId);f||(f={subAgentType:m.subAgentType,messages:[]},u.set(m.subAgentId,f)),f.messages.push(m)}else{c();const f=n.get(m.id);(f==null?void 0:f.type)==="message"&&f.message===m?a.push(f):a.push({type:"message",message:m})}}return c(),a}const XG=10,QG=150;function JG(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 ZG(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,XG).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:jU(r.timestamp),trimmedContent:vf(r.content,QG),sessionId:r.sessionId,sessionName:r.sessionName}))}function eq(e,t,n){const r=[],a=e.filter(o=>o.role==="user"&&!o.isSystemGenerated&&o.messageKind!=="auto-prompt");for(const o of a)r.push({id:o.id,content:o.content,timestamp:o.timestamp,sessionId:n??"",sessionName:"This session"});for(const o of t)n&&o.id===n||r.push(...JG(o));return ZG(r)}function tq(e,t=[],n=null){const[r,a]=k.useState(0),[o,d]=k.useState(!1),u=k.useMemo(()=>eq(e,t,n),[e,t,n]),c=k.useCallback(()=>{u.length>0&&(a(u.length-1),d(!0))},[u.length]),h=k.useCallback(()=>{d(!1),a(0)},[]),m=k.useCallback(()=>{a(x=>u.length===0?x:x===0?u.length-1:x-1)},[u.length]),f=k.useCallback(()=>{a(x=>u.length===0?x:x===u.length-1?0:x+1)},[u.length]),g=k.useCallback(()=>{if(u.length===0||!o)return null;const x=u[r];return(x==null?void 0:x.content)??null},[u,r,o]);return{history:u,selectedIndex:r,showHistory:o,openHistory:c,closeHistory:h,navigateUp:m,navigateDown:f,selectCurrent:g}}k.memo(function({item:t}){const[n,r]=k.useState(!1);return t.type==="start"?s.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:[s.jsx("span",{className:"animate-pulse",children:"●"}),s.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&s.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):s.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[s.jsx("span",{className:"text-accent-success",children:"✓"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),s.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&&s.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(Zn,{content:t.description})})]})]})});function rL({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r,sessionId:a}={}){const o=e??!0,[d,u]=k.useState(""),[c,h]=k.useState([]),[m,f]=k.useState(!1),[g,x]=k.useState(null),[w,C]=k.useState(!1),[v,S]=k.useState(!1),[_,b]=k.useState(!1),[j,E]=k.useState(!1),[N,L]=k.useState(null),A=k.useRef(null),D=zu(A),O=Le(De=>{var Re;return De.focusedSessionId??((Re=De.currentSession)==null?void 0:Re.id)??null}),F=a??O,P=a!=null,z=!P||O===a,K=on(P?a:null,De=>De.session??null,De=>De.currentSession,null),q=on(P?a:null,De=>De.messages,De=>De.messages,[]),W=on(P?a:null,De=>De.hiddenCount??0,De=>De.hiddenCount,0),Z=Le(De=>De.sessions),Q=Wf(P?a:null),H=Le(De=>De.stopGeneration),I=n??q,{maxVisibleItems:M}=Hs(),V=ft(De=>De.defaults),$=ft(De=>De.userItems),ee=[...V,...$].filter(De=>!De.subagent),{history:Y,selectedIndex:X,showHistory:U,openHistory:B,closeHistory:J,navigateUp:se,navigateDown:ne,selectCurrent:ie}=tq(I,Z,K==null?void 0:K.id);k.useEffect(()=>{if(!z)return;const De=Re=>{L(Re.detail.stats)};return window.addEventListener("open-turn-stats",De),()=>window.removeEventListener("open-turn-stats",De)},[z]);const de=K==null?void 0:K.workdir;k.useEffect(()=>{Gt.getState().setWorkdir(de),de&&Gt.getState().fetchWorkflows()},[de]),k.useEffect(()=>{Gt.getState().fetchWorkflows()},[]),k.useEffect(()=>{if(!z)return;const De=Re=>{YG(Re)&&(Re.preventDefault(),E(!0))};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[z]);const pe=k.useRef([]),{displayItems:Oe,hiddenCount:$e}=k.useMemo(()=>{const De=nL(I,pe.current);return pe.current=De,M>0&&De.length>M?{displayItems:De.slice(-M),hiddenCount:De.length-M}:{displayItems:De,hiddenCount:0}},[I,M]),Pe=r??W??$e,{isAutoScrollActive:Ve,setAutoScroll:Ye,handleScrollbarGesture:ot}=Fu(A,K,D),{sendMessage:Ae,launchWorkflow:me}=JA(Ye,F);k.useEffect(()=>{const De=()=>Ye(!0);return window.addEventListener(Tf,De),()=>window.removeEventListener(Tf,De)},[Ye]);const[re,_e]=k.useState(null),[Me,ce]=k.useState(null),Ne=k.useCallback((De,Re,Se,Ue="auto")=>{const ve=Al(Gt.getState()),tt=qy(ve,De,Ue);((tt==null?void 0:tt.parameters)??[]).filter(dt=>dt.position!==void 0||dt.required).length>0?_e({id:De,name:(tt==null?void 0:tt.name)??De,subGroup:Re,scope:Ue}):me(void 0,void 0,De,Re,Se,Ue)},[me]),Xe=k.useCallback((De,Re,Se,Ue)=>{Ne(De,Re,Se,Ue)},[Ne]),at=k.useCallback(De=>{Ye(!1);const Re=document.querySelector(`[data-item-index="${De}"]`);Re&&(Re.hasAttribute("data-placeholder")?(window.dispatchEvent(new CustomEvent(Qy,{detail:{index:De}})),requestAnimationFrame(()=>requestAnimationFrame(()=>{var Se;(Se=document.querySelector(`[data-item-index="${De}"]`))==null||Se.scrollIntoView({behavior:"smooth",block:"center"})}))):Re.scrollIntoView({behavior:"smooth",block:"center"}))},[Ye]);k.useEffect(()=>{if(!z)return;const De=Re=>{const Se=_||w||v||j||N;Re.key==="Escape"&&Q&&!Se&&F&&H(F),Re.key==="ScrollLock"&&Ye(!Ve)};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[z,Q,H,Ve,_,w,v,j,N]);const fe=Tu();xu(z?fe.quickAction:null,()=>{b(!0)}),xu(z?fe.criteriaSidebar:null,()=>{t==null||t()}),vO(z?fe.agentSwitching:[],z?ee:[],De=>{F&&Le.getState().switchMode(F,De)});const We=(De,Re)=>{Ne(De,void 0,void 0,Re),it()},Ze=(De,Re,Se)=>{Ne(De,Re,void 0,Se),it()},it=()=>{u(""),h([]),K!=null&&K.id&&localStorage.removeItem(`openfox:draft:${K.id}`)},nt=k.useCallback(async(De,Re,Se,Ue)=>{const ve=QA(De);if(ve.length>0)ce({prompt:De,paramKeys:ve,agentMode:Re,textareaContent:Se,attachments:Ue});else{Re&&F&&(K==null?void 0:K.mode)!==Re&&await Le.getState().switchMode(F,Re);const tt=Se&&Se.trim()?`${Se.trim()}
321
+
322
+ ${De}`:De;Ae(tt,Ue!=null&&Ue.length?Ue:void 0,{messageKind:"command",isSystemGenerated:!0}),it()}},[Ae,it,K]);return s.jsxs(j9,{value:F,children:[s.jsxs(kV,{criteriaSidebarOpen:o,onCriteriaSidebarToggle:t,messages:I,sessionId:F,children:[s.jsx(KG,{visible:!o}),s.jsx(jV,{}),N&&s.jsx(EV,{stats:N,onClose:()=>L(null)}),s.jsx(YW,{}),s.jsx(qW,{displayItems:Oe,scrollContainerRef:A,highlightedMessageId:null,onLaunchWorkflow:Xe,onScrollToTop:()=>Ye(!1),hiddenCount:Pe,onScrollbarGesture:ot,emptyState:I.length===0&&(K!=null&&K.projectId)?s.jsx(GG,{projectId:K.projectId,sessionId:K.id}):void 0}),s.jsx(VG,{input:d,setInput:u,attachments:c,setAttachments:h,dragOver:m,setDragOver:f,errorMessage:g,setErrorMessage:x,scrollToBottom:()=>{var De,Re;return(Re=D())==null?void 0:Re.scrollTo({top:((De=D())==null?void 0:De.scrollHeight)??0,behavior:"smooth"})},sessionId:F,showHistory:U,history:Y,selectedIndex:X,openHistory:B,closeHistory:J,navigateUp:se,navigateDown:ne,selectCurrent:ie,isAutoScrollActive:Ve,setAutoScroll:Ye,onOpenMessageSearch:()=>E(!0),onOpenCommandsModal:()=>C(!0),onOpenWorkflowsModal:()=>S(!0),onSelectWorkflow:We,onSelectWorkflowWithSubGroup:Ze,onSendCommand:nt,clearInput:it}),s.jsx(GA,{isOpen:w,onClose:()=>C(!1),projectDir:K==null?void 0:K.workdir}),s.jsx(YA,{isOpen:v,onClose:()=>S(!1),projectDir:K==null?void 0:K.workdir}),s.jsx(cG,{isOpen:_,onClose:()=>b(!1),onSearchMessages:()=>E(!0),isAutoScrollActive:Ve,onToggleAutoScroll:Ye,textareaContent:d,onCloseComplete:ju,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(De,Re)=>{const Se=await cn.getState().fetchCommand(De,K==null?void 0:K.workdir);Se&&nt(Se.prompt,Se.metadata.agentMode,Re)},onSelectWorkflow:(De,Re)=>{Ne(De,void 0,void 0,Re),it()}}),re&&s.jsx(mj,{workflowName:re.name,parameters:(()=>{var Re;const De=Al(Gt.getState());return((Re=qy(De,re.id,re.scope))==null?void 0:Re.parameters)??[]})(),onConfirm:De=>{me(void 0,void 0,re.id,re.subGroup,De,re.scope),_e(null)},onCancel:()=>_e(null)}),Me&&s.jsx(mj,{workflowName:"Command",confirmLabel:"Launch command",parameters:Me.paramKeys.map((De,Re)=>({id:De,label:De,position:Re})),onConfirm:De=>{let Re=Me.prompt;for(const[et,dt]of Object.entries(De))Re=Re.replaceAll(`{{${et}}}`,dt);const{agentMode:Se,textareaContent:Ue,attachments:ve}=Me;Se&&F&&(K==null?void 0:K.mode)!==Se&&Le.getState().switchMode(F,Se);const tt=Ue&&Ue.trim()?`${Ue.trim()}
323
+
324
+ ${Re}`:Re;Ae(tt,ve!=null&&ve.length?ve:void 0,{messageKind:"command",isSystemGenerated:!0}),it(),ce(null)},onCancel:()=>ce(null)})]}),j&&s.jsx(yG,{isOpen:j,onClose:()=>{E(!1),ju(!0)},displayItems:Oe,onNavigate:at})]})}function nq(){var b;const[,e]=Ol("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=k.useState(null),[a,o]=k.useState([]),[d,u]=k.useState(0),[c,h]=k.useState(!0),[m,f]=k.useState(null),g=async()=>{if(t){h(!0),f(null);try{const j=await ye(`/api/sessions/${t}?full=true`);if(!j.ok){f(`Failed to load session (${j.status})`),h(!1);return}const E=await j.json();r(E.session??null),o(E.messages??[]),u(E.hiddenCount??0)}catch(j){f(j instanceof Error?j.message:"Unknown error")}finally{h(!1)}}};k.useEffect(()=>{Bt.getState().getSettings([...vb])},[]),k.useEffect(()=>{g()},[t]);const{showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S}=Hs(),_=k.useMemo(()=>nL(a),[a]);return c?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsx(ma,{})}):m?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx("div",{className:"text-red-400 text-sm",children:m}),s.jsx("button",{onClick:g,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):s.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((b=n==null?void 0:n.metadata)==null?void 0:b.title)??"Session"," — Read-only view"]}),s.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages",d>0?` (${d} older hidden)`:""]})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{onClick:g,disabled:c,className:"px-3 py-1 text-xs bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors disabled:opacity-50",children:c?"Refreshing...":"Refresh"})})]}),s.jsxs(mt,{className:"flex-1 print:overflow-visible",children:[s.jsx("div",{className:"pt-4",children:s.jsx(WA,{displayItems:_,showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S})}),s.jsx("div",{className:"h-8"})]})]})}const rq=788;function gj({sessionId:e,focused:t,onFocus:n,onClose:r,className:a}){var N,L,A,D;const o=k.useRef(null),[d,u]=k.useState(!1),c=k.useRef(!1),h=k.useRef(null);k.useEffect(()=>{const O=o.current;if(!O||typeof ResizeObserver>"u")return;const F=new ResizeObserver(()=>{const P=O.clientWidth>=rq;h.current!==null&&h.current!==P&&(c.current=!1),h.current=P,c.current||u(P)});return F.observe(O),()=>F.disconnect()},[]);const m=Le(O=>O.panes[e]),f=(N=m==null?void 0:m.session)==null?void 0:N.projectId,g=Pt(O=>f?O.projects.find(F=>F.id===f):void 0),x=((A=(L=m==null?void 0:m.session)==null?void 0:L.metadata)==null?void 0:A.title)??e.slice(0,8),w=((D=m==null?void 0:m.session)==null?void 0:D.isRunning)??!1,C=(m==null?void 0:m.pendingPathConfirmations.length)??0,v=(m==null?void 0:m.pendingQuestions.length)??0,[S,_]=k.useState(!1),[b,j]=k.useState(!1),E=k.useMemo(()=>{const O=[];return v>0&&O.push(`${v} question${v>1?"s":""}`),C>0&&O.push(`${C} confirmation${C>1?"s":""}`),O},[v,C]);return s.jsxs("div",{ref:o,"data-split-pane":e,"data-focused":t?"true":"false",className:`${a??""} @container relative flex flex-col min-w-0 min-h-0 overflow-hidden ${t?"ring-1 ring-inset ring-accent-primary/50":""}`,onClick:n,children:[s.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 border-b border-border bg-secondary shrink-0",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${w?"bg-emerald-400 animate-pulse":"bg-text-muted/40"}`,title:w?"Running":"Not running"}),g?s.jsx(ho,{items:[{label:"Manage tasks",icon:s.jsx(Qf,{className:"w-4 h-4"}),onClick:()=>_(!0)},{label:"Open project folder",icon:s.jsx(wr,{className:"w-4 h-4"}),onClick:()=>{ye(`/api/projects/${g.id}/open-folder`).catch(()=>{})}},{label:"Edit project settings",icon:s.jsx(OE,{className:"w-4 h-4"}),onClick:()=>j(!0)}],minWidth:"170px",trigger:s.jsxs("button",{type:"button",title:g.name,className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[110px] flex items-center gap-0.5 hover:underline",children:[s.jsx("span",{className:"truncate",children:g.name}),s.jsx(gn,{className:"w-3 h-3 shrink-0"})]})}):s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[80px] truncate",children:f?f.slice(0,10):"…"}),f?s.jsx(er,{href:`/p/${f}/s/${e}`,className:"text-xs text-text-primary truncate flex-1 min-w-0 hover:underline",title:x,onClick:O=>O.stopPropagation(),children:x}):s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",title:x,children:x}),E.length>0&&s.jsx("span",{className:"flex items-center gap-1 text-[10px] text-amber-400 shrink-0",title:E.join(" · "),children:E.join(" · ")}),s.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),c.current=!0,u(F=>!F)},className:`p-1 rounded hover:bg-bg-tertiary transition-colors shrink-0 ${d?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:d?"Hide criteria sidebar":"Show criteria sidebar","aria-label":d?"Hide criteria sidebar":"Show criteria sidebar",children:s.jsx(hy,{className:"w-3.5 h-3.5"})}),s.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),r()},className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors shrink-0",title:"Close pane","aria-label":"Close pane",children:s.jsx(ws,{className:"w-3.5 h-3.5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 bg-primary relative",children:s.jsx(rL,{sessionId:e,criteriaSidebarOpen:d,onCriteriaSidebarToggle:()=>{c.current=!0,u(O=>!O)}})}),g&&s.jsxs(s.Fragment,{children:[s.jsx(Sm,{isOpen:S,onClose:()=>_(!1),projectId:g.id}),s.jsx(lA,{isOpen:b,onClose:()=>j(!1),project:g})]})]})}function sq(e,t,n={}){const r=n.windowMinutes??30,a=n.bucketMinutes??3,o=r*6e4,d=a*6e4,u=Math.max(1,Math.floor(o/d)),c=t-o,h=new Array(u).fill(0);for(const m of e){const f=pA(m);if(!f)continue;const g=new Map;for(const x of f.dataPoints){const w=new Date(x.timestamp).getTime();if(Number.isNaN(w)||w<c||w>t)continue;const C=Math.min(u-1,Math.max(0,Math.floor((w-c)/d))),v=g.get(C)??[];g.set(C,[...v,x.generationSpeed])}for(const[x,w]of g){const C=w.reduce((v,S)=>v+S,0)/w.length;h[x]=(h[x]??0)+C}}return h.map((m,f)=>({x:c+f*d,y:m}))}const Zy=280,ea=44,Af=4;function iq(e,t){const n=e.map((a,o)=>{const d=o/Math.max(1,e.length-1)*Zy,u=ea-Af-a.y/t*(ea-Af*2);return{x:d,y:u}});if(n.length===0)return"";if(n.length===1)return`M ${n[0].x.toFixed(1)} ${n[0].y.toFixed(1)}`;let r=`M ${n[0].x.toFixed(1)} ${n[0].y.toFixed(1)}`;for(let a=0;a<n.length-1;a++){const o=n[Math.max(0,a-1)],d=n[a],u=n[a+1],c=n[Math.min(n.length-1,a+2)],h=d.x+(u.x-o.x)/6,m=d.y+(u.y-o.y)/6,f=u.x-(c.x-d.x)/6,g=u.y-(c.y-d.y)/6;r+=` C ${h.toFixed(1)} ${m.toFixed(1)}, ${f.toFixed(1)} ${g.toFixed(1)}, ${u.x.toFixed(1)} ${u.y.toFixed(1)}`}return r}function aq(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function oq(e,t,n){if(n<=0||t<=0)return Math.min(100,Math.max(0,e));const r=Math.min(t/2/n*100,50);return Math.min(Math.max(e,r),100-r)}function lq(){const e=Le(b=>b.openSessionIds),t=Le(kv(b=>Object.fromEntries(e.map(j=>{var E;return[j,(E=b.panes[j])==null?void 0:E.messages]})))),[n,r]=k.useState(()=>Date.now()),[a,o]=k.useState(null),[d,u]=k.useState(null),c=k.useRef(null),h=k.useRef(null);k.useEffect(()=>{const b=setInterval(()=>r(Date.now()),6e4);return()=>clearInterval(b)},[]),k.useEffect(()=>{const b=c.current,j=h.current;!b||!j||u({width:j.offsetWidth,container:b.clientWidth})},[a]);const m=k.useMemo(()=>Object.values(t).filter(b=>!!b),[t]),f=k.useMemo(()=>sq(m,n),[m,n]),g=k.useMemo(()=>f.reduce((b,j)=>Math.max(b,j.y),0),[f]),x=k.useMemo(()=>g>0?iq(f,g):"",[f,g]),w=f.length-1,C=b=>b/Math.max(1,w)*100,v=b=>(ea-Af-b/g*(ea-Af*2))/ea*100,S=a!==null?oq(C(a),(d==null?void 0:d.width)??0,(d==null?void 0:d.container)??0):0,_=b=>{const j=b.currentTarget.getBoundingClientRect();if(j.width<=0)return;const E=(b.clientX-j.left)/j.width;o(Math.min(w,Math.max(0,Math.round(E*w))))};return s.jsxs("div",{"data-testid":"aggregate-stats",title:"Combined generation speed across open panes, last 30 min (3-min buckets)",children:[s.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:"Generation"}),g>0&&s.jsxs("span",{className:"text-[10px] text-text-muted",title:"Peak combined generation speed in the window",children:[Math.round(g)," tok/s"]})]}),g>0?s.jsxs("div",{"data-testid":"aggregate-chart",ref:c,className:"relative",onMouseMove:_,onMouseLeave:()=>o(null),children:[s.jsxs("svg",{viewBox:`0 0 ${Zy} ${ea}`,className:"w-full h-9",preserveAspectRatio:"none","aria-label":"Generation speed over the last 30 minutes",role:"img",children:[s.jsx("path",{d:`${x} L ${Zy} ${ea} L 0 ${ea} Z`,fill:"currentColor",className:"text-accent-primary/15"}),s.jsx("path",{d:x,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",className:"text-accent-primary"})]}),a!==null&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pointer-events-none absolute w-1.5 h-1.5 rounded-full bg-accent-primary -translate-x-1/2 -translate-y-1/2",style:{left:`${C(a)}%`,top:`${v(f[a].y)}%`}}),s.jsxs("div",{ref:h,"data-testid":"aggregate-tooltip",className:"pointer-events-none absolute z-10 -translate-x-1/2 -translate-y-full whitespace-nowrap rounded bg-bg-tertiary px-1.5 py-0.5 text-[10px] text-text-secondary shadow",style:{left:`${S}%`,top:`${v(f[a].y)}%`},children:[aq(f[a].x)," · ",Math.round(f[a].y)," tok/s"]})]})]}):s.jsx("p",{className:"text-xs text-text-muted",children:"No generation in the last 30 min"})]})}function xj(e,t){return e.name.toLowerCase().localeCompare(t.name.toLowerCase())}function cq(e){const t=e.filter(r=>r.isStarred).sort(xj),n=e.filter(r=>!r.isStarred).sort(xj);return[...t,...n]}function uq(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.name.toLowerCase().includes(n)):e}function dq({isOpen:e,onClose:t}){const n=Pt(E=>E.projects),r=Pt(E=>E.listProjects),a=Le(E=>E.createSession),o=Le(E=>E.openPane),d=Le(E=>E.resetPendingSessionCreate),[u,c]=k.useState(!1),[h,m]=k.useState(null),[f,g]=k.useState(""),[x,w]=k.useState(0),C=k.useRef(null),v=k.useRef(null),S=k.useMemo(()=>cq(uq(n,f)),[n,f]),_=S[x]?`split-new-session-option-${S[x].id}`:void 0;k.useEffect(()=>{var E;e&&(c(!1),m(null),g(""),w(0),Wt()&&((E=C.current)==null||E.focus()),r())},[e,r]),k.useEffect(()=>{var E;!e||x<0||(E=v.current)==null||E.scrollIntoView({block:"nearest"})},[e,x,S]);const b=async E=>{if(!u){c(!0),m(null);try{const N=await a(E);if(!N){m("Could not create the session — please try again.");return}await o(N.id,{focus:!0}),d(),t()}catch{m("Could not create the session — please try again.")}finally{c(!1)}}},j=E=>{jv(E,S.length-1,w,()=>{const N=S[x];N&&b(N.id)},()=>{f?(g(""),w(0)):t()})};return s.jsxs(Et,{isOpen:e,onClose:t,title:"New session",size:"sm",scrollable:!1,footer:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.length>0&&s.jsx("p",{className:"text-[11px] text-text-muted",children:"↑ ↓ to navigate · Enter to select"}),s.jsx(ct,{variant:"secondary",onClick:t,children:"Close"})]}),children:[h&&s.jsx("div",{className:"mb-3 px-3 py-2 rounded bg-accent-error/10 border border-accent-error/30 text-sm text-accent-error",children:h}),n.length===0?s.jsx("p",{className:"text-sm text-text-muted",children:"No projects yet — create one from the home page first."}):s.jsxs("div",{className:"flex flex-col gap-3 flex-1 min-h-0",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx(Fs,{className:"w-4 h-4 text-text-muted absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none"}),s.jsx(xs,{ref:C,type:"text",value:f,onChange:E=>{g(E.target.value),w(0)},onKeyDown:j,placeholder:"Search projects…",className:"pl-9 w-full","aria-label":"Search projects",role:"combobox","aria-expanded":"true","aria-controls":"split-new-session-project-list","aria-activedescendant":_})]}),S.length===0?s.jsx("p",{className:"text-sm text-text-muted",children:"No projects match"}):s.jsx(mt,{className:"-mx-4 -mb-4 flex-1 min-h-0",children:s.jsx("div",{id:"split-new-session-project-list",role:"listbox","aria-label":"Projects",className:"flex flex-col gap-1 pl-4 pr-1",children:S.map((E,N)=>{const L=N===x;return s.jsxs("button",{ref:L?v:void 0,id:`split-new-session-option-${E.id}`,type:"button",role:"option","aria-selected":L,"data-project-row":!0,"data-project-active":L||void 0,"data-starred":E.isStarred||void 0,onMouseEnter:()=>w(N),onClick:()=>void b(E.id),disabled:u,className:`flex items-center gap-3 rounded px-3 py-2 text-left transition-colors disabled:opacity-50 ${L?"bg-accent-primary/10":"hover:bg-bg-tertiary/70"}`,children:[E.isStarred?s.jsx(El,{className:"w-4 h-4 text-yellow-500 shrink-0"}):s.jsx(wr,{className:"w-4 h-4 text-accent-primary shrink-0"}),s.jsx("span",{className:"font-medium truncate text-sm",children:E.name}),s.jsx("span",{className:"text-xs text-text-muted truncate ml-auto",children:Ob(E.workdir,24)})]},E.id)})})})]})]})}function yj(e,t){return t??e.slice(0,8)}function hq({collapsed:e=!1,layout:t,onLayoutChange:n}){const[r,a]=k.useState(!1),o=Le(_=>_.openSessionIds),d=Le(_=>{var b;return _.focusedSessionId??((b=_.currentSession)==null?void 0:b.id)}),u=Le(_=>_.panes),c=Le(_=>_.sessions),h=Le(_=>_.focusPane),m=Le(_=>_.closePane),f=Le(_=>_.reorderPane),g=Le(_=>_.openPane),x=Le(_=>_.isPaneOpen),w=Pt(_=>_.projects),C=k.useMemo(()=>new Map(w.map(_=>[_.id,_])),[w]),v=k.useMemo(()=>[...c].sort((_,b)=>_.isRunning!==b.isRunning?_.isRunning?-1:1:new Date(b.updatedAt).getTime()-new Date(_.updatedAt).getTime()),[c]),S=_=>{x(_.id)?h(_.id):g(_.id,{focus:!0})};return s.jsxs("aside",{"data-testid":"split-control-panel",className:`shrink-0 border-r border-border bg-secondary flex flex-col min-h-0 transition-[width] duration-200 ${e?"w-0 overflow-hidden border-r-0":"w-56"}`,"aria-hidden":e,children:[s.jsxs("div",{className:"flex items-center gap-1 px-2 h-9 border-b border-border shrink-0",children:[s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted whitespace-nowrap",children:"Split view"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:o.length}),s.jsxs("div",{className:"flex items-center rounded bg-bg-tertiary p-0.5 ml-1",role:"group","aria-label":"Pane layout",children:[s.jsx("button",{type:"button",onClick:()=>n("columns"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${t==="columns"?"bg-accent-primary/25 text-text-primary":"text-text-muted hover:text-text-primary"}`,title:"Stack panes as columns","aria-label":"Columns layout","aria-pressed":t==="columns",children:"Columns"}),s.jsx("button",{type:"button",onClick:()=>n("grid"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${t==="grid"?"bg-accent-primary/25 text-text-primary":"text-text-muted hover:text-text-primary"}`,title:"Arrange panes in a grid","aria-label":"Grid layout","aria-pressed":t==="grid",children:"Grid"})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[s.jsxs("div",{className:"px-3 pt-3 pb-2",children:[s.jsx("h2",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted mb-1",children:"Open panes"}),o.length===0?s.jsx("p",{className:"text-xs text-text-muted",children:"No panes open — pick a session below."}):s.jsx("ul",{className:"space-y-0.5",children:o.map((_,b)=>{var N,L,A;const j=_===d,E=yj(_,(A=(L=(N=u[_])==null?void 0:N.session)==null?void 0:L.metadata)==null?void 0:A.title);return s.jsxs("li",{className:`group flex items-center gap-1 rounded px-1.5 py-1 cursor-pointer ${j?"bg-bg-tertiary":"hover:bg-bg-tertiary/50"}`,onClick:()=>h(_),"data-open-pane":_,children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${j?"bg-accent-primary":"bg-text-muted/40"}`}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",title:E,children:E}),s.jsxs("div",{className:"flex items-center gap-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),f(_,-1)},disabled:b===0,className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary disabled:opacity-30 disabled:cursor-default",title:"Move pane left","aria-label":"Move pane left",children:s.jsx(Cb,{className:"w-3 h-3"})}),s.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),f(_,1)},disabled:b===o.length-1,className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary disabled:opacity-30 disabled:cursor-default",title:"Move pane right","aria-label":"Move pane right",children:s.jsx(gn,{className:"w-3 h-3"})}),s.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),m(_)},className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary",title:"Close pane","aria-label":"Close pane",children:s.jsx(ws,{className:"w-3 h-3"})})]})]},_)})})]}),s.jsx("div",{className:"px-3 pt-3 pb-4 border-t border-border",children:s.jsx(lq,{})}),s.jsxs("div",{className:"px-3 pt-3 pb-4 border-t border-border",children:[s.jsxs("div",{className:"flex items-center mb-1",children:[s.jsx("h2",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:"Sessions"}),s.jsx("button",{type:"button",onClick:()=>a(!0),className:"ml-auto p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New session","aria-label":"New session",children:s.jsx(Fr,{className:"w-3.5 h-3.5"})})]}),v.length===0?s.jsx("p",{className:"text-xs text-text-muted",children:"No sessions yet."}):s.jsx("ul",{className:"space-y-0.5",children:v.map(_=>{var j;const b=x(_.id);return s.jsxs("li",{className:"flex items-center gap-1.5 rounded px-1.5 py-1 cursor-pointer hover:bg-bg-tertiary/50",onClick:()=>S(_),"data-session-item":_.id,title:b?"Focus pane":"Open in split view",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${_.isRunning?"bg-emerald-400 animate-pulse":"bg-text-muted/40"}`}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",children:yj(_.id,_.title)}),s.jsx("span",{className:"text-[9px] text-accent-primary truncate max-w-[60px] shrink-0",children:((j=C.get(_.projectId))==null?void 0:j.name)??_.projectId.slice(0,8)})]},_.id)})})]})]}),s.jsx(dq,{isOpen:r,onClose:()=>a(!1)})]})}function fq({controlOpen:e=!0}){const t=Le(h=>h.openSessionIds),n=Le(h=>{var m;return h.focusedSessionId??((m=h.currentSession)==null?void 0:m.id)}),r=Le(h=>h.focusPane),a=Le(h=>h.closePane),o=Le(h=>h.listHomeSessions),[d,u]=k.useState(_3);k.useEffect(()=>{S3(d)},[d]),k.useEffect(()=>{o();const h=setInterval(()=>void o(),2e4),m=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",m),()=>{clearInterval(h),document.removeEventListener("visibilitychange",m)}},[o]);const c=t.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("p",{className:"text-sm text-text-muted px-4 text-center",children:"No panes open — pick a session on the left to open it in split view."})}):d==="columns"?s.jsx("div",{className:"flex gap-px bg-border flex-1 min-w-0 min-h-0",children:t.map(h=>{const m=h===n;return s.jsx(gj,{className:"flex-1",sessionId:h,focused:m,onFocus:()=>r(h),onClose:()=>a(h)},h)})}):s.jsx("div",{className:`grid gap-px bg-border flex-1 min-w-0 min-h-0 ${t.length<=1?"grid-cols-1":"grid-cols-2"}`,children:t.map(h=>{const m=h===n;return s.jsx(gj,{sessionId:h,focused:m,onFocus:()=>r(h),onClose:()=>a(h)},h)})});return s.jsxs("div",{className:"flex-1 min-w-0 flex h-full min-h-0 bg-primary",children:[s.jsx(hq,{collapsed:!e,layout:d,onLayoutChange:u}),c]})}function mq({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,o]=k.useState(""),d=k.useRef(null);k.useEffect(()=>{e&&(o(""),setTimeout(()=>{var c;Wt()&&((c=d.current)==null||c.focus())},100))},[e]);const u=c=>{c.preventDefault(),a.trim()&&n(a)};return s.jsx(Et,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.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."}),s.jsx(xs,{ref:d,type:"password",value:a,onChange:c=>o(c.target.value),placeholder:"Enter password",autoFocus:Wt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ct,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(ct,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function pq({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return s.jsx("div",{className:"flex justify-center py-6",children:s.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,o)=>{const d=o+1,u=d<e,c=d===e;return s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{onClick:()=>r==null?void 0:r(d),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${u?"bg-accent-primary text-text-primary hover:opacity-80":c?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:u?"✓":d}),s.jsx("button",{onClick:()=>r==null?void 0:r(d),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${c?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[o]}),o<t-1&&s.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${u?"bg-accent-primary":"bg-border"}`})]},o)})})})}function gq({onNext:e}){const[t,n]=k.useState([]),[r,a]=k.useState([]),[o,d]=k.useState(!1),[u,c]=k.useState(null),[h,m]=k.useState(null),[f,g]=k.useState(null);k.useEffect(()=>{x()},[]);async function x(){try{const E=await ye("/api/providers");if(E.ok){const L=(await E.json()).providers.map(A=>({id:A.id,name:A.name,url:A.url,backend:A.backend,model:null,apiKey:A.apiKey,isLocal:A.isLocal,thinkingField:A.thinkingField,sendReasoningInMessages:A.sendReasoningInMessages,models:A.models}));n(L),a(L)}}catch{}}async function w(E){const N=E.id.startsWith("temp-"),L=r.some(O=>O.id===E.id),A=r.length===0&&u===null,D=eL(E);try{let O;if(N){const P=await ye("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(!P.ok)throw new Error("Failed to create provider");const z=await P.json();O={...E,id:z.provider.id,model:null}}else{if(!(await ye(`/api/providers/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)})).ok)throw new Error("Failed to update provider");O={...E,model:null}}const F=P=>P.some(z=>z.id===O.id)?P.map(z=>z.id===O.id?O:z):[...P,O];a(F),n(F),A&&!L&&e({providers:[O]})}catch{if(N){const O={...E,model:null};a(F=>[...F,O])}}}function C(){c(null),d(!0)}function v(E){c(E),d(!0)}function S(){d(!1),c(null)}function _(E){m(E),t.some(L=>L.id===E)?ye(`/api/providers/${E}`,{method:"DELETE"}).then(()=>{a(r.filter(L=>L.id!==E)),n(t.filter(L=>L.id!==E)),m(null)}).catch(()=>m(null)):(a(r.filter(L=>L.id!==E)),m(null))}function b(){const E=r.filter(N=>!N.id.startsWith("temp-"));e({providers:E})}const j=r.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),s.jsxs("div",{className:"space-y-4",children:[r.length>0?s.jsx("div",{className:"space-y-2",children:r.map(E=>s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:_E(E.backend)}),s.jsx("span",{className:"text-text-primary font-medium",children:E.name}),s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${E.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:E.isLocal?"local":"api"})]}),s.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:E.url}),E.model&&s.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",E.model]})]}),s.jsx("div",{className:"flex items-center gap-1",children:f===E.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>_(E.id),disabled:h===E.id,className:"px-2 py-1 text-xs text-red-500 hover:text-red-400 bg-red-500/10 rounded transition-colors disabled:opacity-50",children:h===E.id?"Deleting...":"Confirm"}),s.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>v(E),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),s.jsx("button",{onClick:()=>g(E.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:s.jsx(Ci,{})})]})})]},E.id))}):s.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:s.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),s.jsxs("button",{onClick:C,"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[s.jsx(Fr,{className:"w-4 h-4"}),"Add Provider"]}),s.jsx("button",{onClick:b,disabled:!j,"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"})]}),s.jsx(tL,{isOpen:o,onClose:S,onSave:w,initialStep:1,editProvider:u??void 0})]})}function xq({onNext:e}){const[t,n]=k.useState(""),[r,a]=k.useState(!1);return k.useEffect(()=>{ye("/api/config").then(o=>o.json()).then(o=>{o.workdir?n(o.workdir):fetch(_s("/api/directories?path=")+encodeURIComponent("/home")).then(d=>d.json()).then(d=>{d.current&&n(d.current)}).catch(()=>{})}).catch(()=>{fetch(_s("/api/directories?path=")+encodeURIComponent("/home")).then(o=>o.json()).then(o=>{o.current&&n(o.current)}).catch(()=>{})})},[]),s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),s.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&s.jsx(em,{initialPath:t||void 0,onSelect:o=>{n(o),a(!1)},onClose:()=>a(!1)}),s.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 yq(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function bq(e){return k.useMemo(()=>{const t=[];for(const n of e)for(const r of n.models)r.supportsVision&&t.push({providerId:n.id,providerName:n.name,modelId:r.id,modelName:r.name??yq(r.id)});return t},[e])}function vq({value:e,options:t,onChange:n,className:r}){return s.jsxs("select",{value:e,onChange:a=>n(a.target.value),className:r??"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"",children:"Manual configuration..."}),t.map(a=>s.jsxs("option",{value:`${a.providerId}/${a.modelId}`,children:[a.providerName," • ",a.modelName]},`${a.providerId}/${a.modelId}`))]})}function _q({backend:e,url:t,model:n,apiKey:r,onBackendChange:a,onUrlChange:o,onModelChange:d,onApiKeyChange:u}){return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),s.jsxs("select",{value:e,onChange:c=>a(c.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"ollama",children:"Ollama"}),s.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),s.jsx("input",{type:"text",value:t,onChange:c=>o(c.target.value),placeholder:e==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),s.jsx("input",{type:"text",value:n,onChange:c=>d(c.target.value),placeholder:e==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),e==="openai"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),s.jsx("input",{type:"password",value:r,onChange:c=>u(c.target.value),placeholder:"Leave empty for a local server that needs no auth",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"})]})]})}function Sq(e,t,n,r){return a=>{e(a),t(""),a==="ollama"?(n("http://localhost:11434"),r("qwen3.5:0.8b")):(n("http://localhost:8000/v1"),r("qwen3.5-27b"))}}function wq(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function Cq({enabled:e,hasOptions:t,selectedRef:n,visionModelOptions:r,onProviderModelSelect:a,noOptionsMessage:o,children:d,...u}){return e?s.jsxs("div",{className:"space-y-4 pl-8",children:[t?s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model from your providers"}),s.jsx(vq,{value:n,options:r,onChange:a})]}):s.jsx("p",{className:"text-sm text-text-muted italic",children:o}),s.jsx(_q,{...u}),d]}):null}function kq({onNext:e}){const[t,n]=k.useState(!1),[r,a]=k.useState("http://localhost:11434"),[o,d]=k.useState("qwen3.5:0.8b"),[u,c]=k.useState(""),[h,m]=k.useState("ollama"),[f,g]=k.useState([]),[x,w]=k.useState(""),{copied:C,copy:v}=DT();k.useEffect(()=>{ye("/api/config").then(L=>L.json()).then(L=>{L.visionFallback&&(n(L.visionFallback.enabled),L.visionFallback.providerModelRef?w(L.visionFallback.providerModelRef):(a(L.visionFallback.url??"http://localhost:11434"),d(L.visionFallback.model??"qwen3.5:0.8b"),c(L.visionFallback.apiKey??""),L.visionFallback.backend&&m(L.visionFallback.backend))),L.providers&&g(L.providers)}).catch(()=>{})},[]);const S=bq(f),_=wq(w,a,d),b=Sq(m,w,a,d);function j(L){if(L){e({});return}e(t&&x?{visionFallback:{enabled:t,providerModelRef:x,timeout:120}}:{visionFallback:{enabled:t,url:r,model:o,timeout:120,backend:h,providerModelRef:"",apiKey:h==="openai"?u:""}})}const E=S.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),s.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),s.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[s.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),s.jsx("button",{onClick:()=>v("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:C?s.jsx(Us,{className:"w-4 h-4 text-accent-primary"}):s.jsx(iO,{className:"w-4 h-4"})})]}),s.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",s.jsx("strong",{children:"OpenAI"})," backend type."]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:L=>n(L.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),s.jsx(Cq,{enabled:t,hasOptions:E,selectedRef:x,visionModelOptions:S,onProviderModelSelect:_,backend:h,url:r,model:o,apiKey:u,onBackendChange:b,onUrlChange:a,onModelChange:d,onApiKeyChange:c,noOptionsMessage:"No vision-capable models found in your providers. You can manually enter a model below."}),s.jsxs("div",{className:"flex items-center justify-between pt-4",children:[s.jsx("button",{onClick:()=>j(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),s.jsx("button",{onClick:()=>j(!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 jq({onComplete:e}){const[t,n]=k.useState(1),[r,a]=k.useState(!1),[o,d]=k.useState({});async function u(f){d(g=>({...g,providers:f.providers})),n(2)}async function c(f){d(g=>({...g,...f})),n(3)}async function h(f){a(!0);try{if(!(await ye("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:o.workdir,visionFallback:f.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(g){console.error("Failed to save onboarding data:",g),a(!1)}}const m=f=>{n(f)};return s.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[s.jsx(Bu,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),s.jsx(pq,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:m}),s.jsx("div",{className:"max-w-xl mx-auto",children:r?s.jsxs("div",{className:"text-center",children:[s.jsx(Fr,{className:"w-6 h-6"}),s.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):s.jsxs(s.Fragment,{children:[t===1&&s.jsx(gq,{onNext:u}),t===2&&s.jsx(xq,{onNext:c}),t===3&&s.jsx(kq,{onNext:h})]})})]})}function Eq({projectId:e}){var m;const[,t]=Fn(),n=Le(f=>f.sessionsWithPendingConfirmations),r=Le(f=>{var g;return(g=f.currentSession)==null?void 0:g.id}),a=Le(f=>f.crossSessionConfirmations),o=Le(f=>f.sessions),d=n.find(f=>f!==r);if(!d)return null;const u=o.find(f=>f.id===d),c=(u==null?void 0:u.title)??d.slice(0,6),h=((m=a[d])==null?void 0:m.length)??0;return s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 cursor-pointer hover:bg-amber-500/20 transition-colors",onClick:()=>t(e?`/p/${e}/s/${d}`:`/s/${d}`),role:"button",tabIndex:0,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&t(e?`/p/${e}/s/${d}`:`/s/${d}`)},children:[s.jsx(qf,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-amber-300 flex-1 truncate",children:[h," confirmation",h>1?"s":"",' pending in session "',c,'"']}),s.jsx("span",{className:"text-xs text-amber-400 font-medium flex-shrink-0",children:"View session →"})]})}const Kx="openfox_updated_to",Yx="update_pending";function Nq(){const[e,t]=k.useState(!1),n=localStorage.getItem(Kx),r=localStorage.getItem(Yx);k.useEffect(()=>{if(!n||!r)return;const o=setTimeout(()=>{localStorage.removeItem(Kx),localStorage.removeItem(Yx),t(!0)},8e3);return()=>clearTimeout(o)},[n,r]);const a=()=>{localStorage.removeItem(Kx),localStorage.removeItem(Yx),t(!0)};return e||r!=="true"||!n?null:s.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:[s.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:s.jsx(Us,{className:"w-3 h-3 text-accent-primary"})}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),s.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:s.jsx(Ab,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Zt.getState().loadUserPresets(),Zt.getState().applySavedTheme());function Pv(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function Bv(){return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ma,{})})}function Tq({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Ol("/p/:projectId"),r=n==null?void 0:n.projectId,a=Le(c=>c.connectionStatus),o=Pt(c=>c.currentProject),d=Pv();return eO({canLoad:a==="connected"||d,projectId:r,currentProjectId:o==null?void 0:o.id}),!o||o.id!==r?s.jsx(Bv,{}):s.jsxs(s.Fragment,{children:[s.jsx(dA,{projectId:r,isOpen:e,onClose:t}),s.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:s.jsx(k9,{})})]})}function Aq({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=Ol("/p/:projectId/s/:sessionId"),o=a==null?void 0:a.projectId,d=a==null?void 0:a.sessionId,[,u]=Fn(),c=Le(C=>C.connectionStatus),h=Le(C=>C.currentSession),m=Le(C=>C.error),f=Le(C=>C.clearError),g=Pt(C=>C.currentProject),x=Pv();return tO({canLoad:c==="connected"||x,projectId:o,sessionId:d,currentProjectId:g==null?void 0:g.id,currentSessionId:h==null?void 0:h.id}),k.useEffect(()=>{(m==null?void 0:m.code)==="NOT_FOUND"&&o&&(f(),u(`/p/${o}`))},[m,o,f,u]),!g||g.id!==o?s.jsx(Bv,{}):s.jsxs(s.Fragment,{children:[s.jsx(dA,{projectId:o,isOpen:e,onClose:t}),s.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[s.jsx(Eq,{projectId:o}),s.jsx(rL,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function Lq(){const e=an(r=>r.fetchConfig),[,t]=Fn();async function n(){await e(),t("/")}return s.jsx(mt,{className:"flex-1",children:s.jsx(jq,{onComplete:n})})}function Rq(){const{connectionStatus:e}=K3(),t=an(X=>X.fetchConfig),n=an(X=>X.refreshProviderModels),r=an(X=>X.providers),a=an(X=>X.activeProviderId),[,o]=Fn(),d=Pv(),[u,c]=k.useState(!1);k.useEffect(()=>{(e==="connected"||d)&&t().then(()=>{c(!0),Bt.getState().getSettings([...vb,je.DISPLAY_THEME,je.DISPLAY_USER_PRESETS,je.DISPLAY_CUSTOM_CSS,je.KEYBINDINGS,je.FEATURES_PER_SESSION_MCP]),mu.getState().fetchServers()})},[e,d,t]),k.useEffect(()=>{u&&a&&n(a).then(()=>{const X=an.getState().defaultModelSelection;(X?X.split("/")[0]:null)!==a&&t()})},[u,a,n,t]);const h=Bt(X=>X.settings);k.useEffect(()=>{u&&r.length===0&&o("/onboarding")},[u,r.length]),k.useEffect(()=>{const{applyPreset:X,applyTokens:U,setFollowSystemTheme:B,initSystemThemeListener:J}=Zt.getState(),se=h[je.DISPLAY_THEME],ne=h[je.DISPLAY_USER_PRESETS],ie=h[je.DISPLAY_FOLLOW_SYSTEM_THEME];if(ne&&localStorage.setItem("openfox:userPresets",ne),se){localStorage.setItem("openfox:theme",se);try{const pe=JSON.parse(se);pe.preset&&pe.tokens?(X(pe.preset),Zt.setState({basePreset:pe.preset}),U(pe.tokens)):pe.preset?X(pe.preset):pe.tokens&&U(pe.tokens)}catch{X("dark")}}else X("system");ie!==void 0&&Zt.getState().followSystemTheme!==(ie==="true")&&B(ie==="true");const de=J();return()=>de()},[h[je.DISPLAY_THEME],h[je.DISPLAY_USER_PRESETS]]),k.useEffect(()=>{const X=h[je.DISPLAY_CUSTOM_CSS]??"";let U=document.getElementById("custom-css");U||(U=document.createElement("style"),U.id="custom-css",document.head.appendChild(U)),U.textContent=X},[h[je.DISPLAY_CUSTOM_CSS]]);const[m,f]=k.useState(!1);k.useEffect(()=>{const X=Bt.getState().settings[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(X===void 0||X==="false")return;let U=!1;if(localStorage.getItem("update_pending")==="true"&&(U=!0,localStorage.removeItem("update_pending")),u){const J=an.getState().version,se=Ib();sM(J,se)&&(U=!0),rM(J)}U&&f(!0)},[h[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],u]);const g=()=>{const X=localStorage.getItem("openfox:leftSidebar");return X!==null?X==="true":!0},x=()=>{const X=localStorage.getItem("openfox:rightSidebar");return X!==null?X==="true":!0},[w,C]=k.useState(g),[v,S]=k.useState(x),[_,b]=k.useState(!1),[j,E]=k.useState(!1),[N,L]=k.useState(!1),A=d3();k.useEffect(()=>{const X=()=>{L(window.innerWidth<768)};return X(),window.addEventListener("resize",X),()=>window.removeEventListener("resize",X)},[]);const[D]=Fn(),O=/^\/p\/[^/]+$/.test(D),F=kE(),[P,z]=k.useState(!1),K=k.useRef(!1);k.useEffect(()=>{K.current&&!F&&Le.getState().exitSplitView(),K.current=F},[F]),k.useEffect(()=>{if(!F){z(!1);return}let X=!1;const U=w3();return(U&&U.openSessionIds.length>0?Le.getState().enterSplitView(U.openSessionIds,U.focusedSessionId??void 0):Promise.resolve()).then(()=>{X||z(!0)}),()=>{X=!0}},[F]);const q=N?_:O?!0:w,W=N?j:v,Z=Le(X=>X.openSessionIds.length),Q=F&&Z===0?!0:q,H=()=>{N?b(!_):C(!w)},I=()=>{N?E(!j):S(!v)};k.useEffect(()=>{N||localStorage.setItem("openfox:leftSidebar",String(w))},[w,N]),k.useEffect(()=>{N||localStorage.setItem("openfox:rightSidebar",String(v))},[v,N]),k.useEffect(()=>{(e==="connected"||d)&&t()},[e,t,d]);const M=Le(X=>X.showPasswordModal),V=Le(X=>X.passwordModalRetry),$=Le(X=>X.submitPassword),ee=Le(X=>X.cancelPassword),[Y]=Ol("/p/:projectId/s/:sessionId/readonly");return!Y&&e!=="connected"&&!M&&!d?s.jsx("div",{className:"h-screen flex items-center justify-center",children:s.jsx(EO,{text:"Connecting to server..."})}):Y?s.jsx(nq,{}):s.jsxs(s.Fragment,{children:[s.jsx(mq,{isOpen:M,isRetry:V,onSubmit:$,onCancel:ee}),s.jsxs("div",{className:"flex flex-col",style:{height:N?`calc(${A.offsetTop}px + ${A.height}px)`:"100vh"},children:[s.jsx(x9,{}),s.jsx(d9,{onMenuClick:H,onCriteriaToggle:I}),s.jsx("div",{className:"@container flex-1 flex overflow-hidden",children:s.jsxs(YD,{children:[s.jsx(Xo,{path:"/onboarding",children:s.jsx(Lq,{})}),s.jsx(Xo,{path:"/split-view",children:P?s.jsx(fq,{controlOpen:Q}):s.jsx(Bv,{})}),s.jsx(Xo,{path:"/p/:projectId/s/:sessionId",children:s.jsx(Aq,{sidebarOpen:q,onSidebarToggle:H,rightSidebarOpen:W,onRightSidebarToggle:I})}),s.jsx(Xo,{path:"/p/:projectId/new",children:s.jsx(C9,{})}),s.jsx(Xo,{path:"/p/:projectId",children:s.jsx(Tq,{sidebarOpen:q,onSidebarToggle:H})}),s.jsx(Xo,{path:"/",children:s.jsx(w9,{})})]})})]}),s.jsx(Nq,{}),s.jsx(IT,{isOpen:m,onClose:()=>f(!1),since:nM()??void 0})]})}const Mh=window.location.pathname.match(/\/p\/[^/]+\/s\/([0-9a-fA-F-]+)/);Mh!=null&&Mh[1]&&f3(Mh[1]);ND.createRoot(document.getElementById("root")).render(s.jsx(ps.StrictMode,{children:s.jsx(Ej,{base:bE,children:s.jsx(Rq,{})})}));