openfox 2.0.65 → 2.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/agent-defaults/builder.agent.md +1 -1
- package/dist/agent-defaults/code-reviewer.agent.md +0 -1
- package/dist/agent-defaults/explorer.agent.md +0 -1
- package/dist/agent-defaults/planner.agent.md +1 -1
- package/dist/{branch.api-LAN42BA5.js → branch.api-3YJSWOZG.js} +5 -1
- package/dist/{chat-handler-MC3XZ3OV.js → chat-handler-72DFHK5K.js} +16 -13
- package/dist/{chunk-Z6H7SFQR.js → chunk-2GRUQN2B.js} +435 -170
- package/dist/{chunk-LBGHZLLH.js → chunk-4QBDV6LX.js} +17 -14
- package/dist/{chunk-RYIREJAW.js → chunk-5EO6SEGV.js} +2 -2
- package/dist/{chunk-N4K3PNOS.js → chunk-B6JUWVTK.js} +95 -29
- package/dist/{chunk-QBYQ7KDX.js → chunk-B7WGOK7G.js} +16 -15
- package/dist/{chunk-Z6W4YHJB.js → chunk-BL5LOLVA.js} +17 -1
- package/dist/{chunk-TMUBLQFC.js → chunk-C3VLGVSQ.js} +3 -3
- package/dist/{chunk-ZPIZLTWU.js → chunk-GMXKJGJ2.js} +5 -1
- package/dist/{chunk-YQ3SOPBI.js → chunk-KXVFHMSM.js} +2 -2
- package/dist/{chunk-4UYKN6JU.js → chunk-MQHMT5WF.js} +3 -3
- package/dist/{chunk-VWPY2KWH.js → chunk-PYRH4G2J.js} +9 -35
- package/dist/{chunk-BGTEIA2S.js → chunk-TFCHWMOJ.js} +23 -30
- package/dist/{chunk-AIJE3RYH.js → chunk-TFDK6VSG.js} +33 -7
- package/dist/{chunk-X5YCWKNS.js → chunk-TJO4QFDQ.js} +59 -86
- package/dist/{chunk-QJ5FH5DP.js → chunk-TMHWQYWE.js} +4 -4
- package/dist/chunk-VLV3XWZS.js +191 -0
- package/dist/chunk-WGMJCFCE.js +14 -0
- package/dist/chunk-X5DOUA3Z.js +66 -0
- package/dist/{chunk-PXJ4NOP4.js → chunk-XUPKS5FL.js} +6 -4
- package/dist/{chunk-UEIQKG5P.js → chunk-YU6DZAVA.js} +303 -360
- package/dist/{chunk-OESYKZCM.js → chunk-ZLON3JTI.js} +3 -3
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-LAKW7TA5.js → client-BUX62J2K.js} +3 -3
- package/dist/{client-pure-DO3S675T.js → client-pure-U6ZYUPJQ.js} +6 -4
- package/dist/{compactor-I3N56PSJ.js → compactor-74CZVUWI.js} +9 -7
- package/dist/{events-52XADT6Y.js → events-CDQ4HASP.js} +4 -4
- package/dist/{folding-2BGFLV5J.js → folding-V2K34EGN.js} +2 -2
- package/dist/{inspect-proxy-BV25JERQ.js → inspect-proxy-OVEFBJ26.js} +4 -4
- package/dist/{manager-344C5JLZ.js → manager-JXYRGR6B.js} +6 -2
- package/dist/{orchestrator-IYJRQQKB.js → orchestrator-FEMPJOZD.js} +15 -14
- package/dist/package.json +2 -1
- package/dist/platform-AB3GIEGO.js +21 -0
- package/dist/{processor-LUXKVIED.js → processor-QB3NMRMO.js} +16 -13
- package/dist/{project-creator-IDW7RACH.js → project-creator-EMGRSPYS.js} +18 -5
- package/dist/{projects-BY227WT2.js → projects-7HSBZY2D.js} +3 -3
- package/dist/{protocol-Cq66hdDX.d.ts → protocol-42f_Png6.d.ts} +1 -1
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-GYOW4OWQ.js → provider-BDH6JGZB.js} +4 -4
- package/dist/{provider-manager-HRHNF73A.js → provider-manager-D3KIOD5E.js} +4 -4
- package/dist/{serve-ZRTWVOL2.js → serve-32FAA4FX.js} +20 -17
- package/dist/server/index.d.ts +26 -8
- package/dist/server/index.js +19 -16
- package/dist/server-OYE7GERR.js +37 -0
- package/dist/{settings-JA4XUR3W.js → settings-6ZPWOBWL.js} +3 -3
- package/dist/shared/index.d.ts +3 -3
- package/dist/{tools-ZZM36DAZ.js → tools-INWP6FGV.js} +14 -11
- package/dist/{types-CDZakn7f.d.ts → types-apiMd7Df.d.ts} +1 -1
- package/dist/{types-akHmgvBk.d.ts → types-vezAEt_y.d.ts} +3 -1
- package/dist/web/assets/{index-Dc05znz4.css → index-BELeAs12.css} +1 -1
- package/dist/web/assets/index-C3n65CNu.js +303 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/worktree-6U45P63P.js +30 -0
- package/package.json +2 -1
- package/dist/server-PXXGMFBT.js +0 -34
- package/dist/web/assets/index-Bsi_le80.js +0 -303
|
@@ -0,0 +1,303 @@
|
|
|
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 k2=Object.defineProperty;var E2=Object.getPrototypeOf;var j2=Reflect.get;var pb=e=>{throw TypeError(e)};var N2=(e,t,n)=>t in e?k2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _e=(e,t,n)=>N2(e,typeof t!="symbol"?t+"":t,n),Bf=(e,t,n)=>t.has(e)||pb("Cannot "+n);var Rn=(e,t,n)=>(Bf(e,t,"read from private field"),n?n.call(e):t.get(e)),vi=(e,t,n)=>t.has(e)?pb("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Nr=(e,t,n,r)=>(Bf(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),$f=(e,t,n)=>(Bf(e,t,"access private method"),n);var gb=(e,t,n)=>j2(E2(e),n,t);function T2(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const l=Object.getOwnPropertyDescriptor(r,o);l&&Object.defineProperty(e,o,l.get?l:{enumerable:!0,get:()=>r[o]})}}}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 o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function Xu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zf={exports:{}},qo={};/**
|
|
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 xb;function A2(){if(xb)return qo;xb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var u=null;if(l!==void 0&&(u=""+l),o.key!==void 0&&(u=""+o.key),"key"in o){l={};for(var c in o)c!=="key"&&(l[c]=o[c])}else l=o;return o=l.ref,{$$typeof:e,type:r,key:u,ref:o!==void 0?o:null,props:l}}return qo.Fragment=t,qo.jsx=n,qo.jsxs=n,qo}var yb;function L2(){return yb||(yb=1,zf.exports=A2()),zf.exports}var a=L2(),Hf={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 _b;function D2(){if(_b)return st;_b=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),x=Symbol.iterator;function y(I){return I===null||typeof I!="object"?null:(I=x&&I[x]||I["@@iterator"],typeof I=="function"?I:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,v={};function S(I,G,B){this.props=I,this.context=G,this.refs=v,this.updater=B||w}S.prototype.isReactComponent={},S.prototype.setState=function(I,G){if(typeof I!="object"&&typeof I!="function"&&I!=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,I,G,"setState")},S.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function b(){}b.prototype=S.prototype;function _(I,G,B){this.props=I,this.context=G,this.refs=v,this.updater=B||w}var j=_.prototype=new b;j.constructor=_,C(j,S.prototype),j.isPureReactComponent=!0;var E=Array.isArray;function T(){}var D={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function O(I,G,B){var ee=B.ref;return{$$typeof:e,type:I,key:G,ref:ee!==void 0?ee:null,props:B}}function P(I,G){return O(I.type,G,I.props)}function q(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function W(I){var G={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(B){return G[B]})}var M=/\/+/g;function H(I,G){return typeof I=="object"&&I!==null&&I.key!=null?W(""+I.key):G.toString(36)}function V(I){switch(I.status){case"fulfilled":return I.value;case"rejected":throw I.reason;default:switch(typeof I.status=="string"?I.then(T,T):(I.status="pending",I.then(function(G){I.status==="pending"&&(I.status="fulfilled",I.value=G)},function(G){I.status==="pending"&&(I.status="rejected",I.reason=G)})),I.status){case"fulfilled":return I.value;case"rejected":throw I.reason}}throw I}function U(I,G,B,ee,J){var ne=typeof I;(ne==="undefined"||ne==="boolean")&&(I=null);var K=!1;if(I===null)K=!0;else switch(ne){case"bigint":case"string":case"number":K=!0;break;case"object":switch(I.$$typeof){case e:case t:K=!0;break;case p:return K=I._init,U(K(I._payload),G,B,ee,J)}}if(K)return J=J(I),K=ee===""?"."+H(I,0):ee,E(J)?(B="",K!=null&&(B=K.replace(M,"$&/")+"/"),U(J,G,B,"",function(re){return re})):J!=null&&(q(J)&&(J=P(J,B+(J.key==null||I&&I.key===J.key?"":(""+J.key).replace(M,"$&/")+"/")+K)),G.push(J)),1;K=0;var F=ee===""?".":ee+":";if(E(I))for(var te=0;te<I.length;te++)ee=I[te],ne=F+H(ee,te),K+=U(ee,G,B,ne,J);else if(te=y(I),typeof te=="function")for(I=te.call(I),te=0;!(ee=I.next()).done;)ee=ee.value,ne=F+H(ee,te++),K+=U(ee,G,B,ne,J);else if(ne==="object"){if(typeof I.then=="function")return U(V(I),G,B,ee,J);throw G=String(I),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return K}function Q(I,G,B){if(I==null)return I;var ee=[],J=0;return U(I,ee,"","",function(ne){return G.call(B,ne,J++)}),ee}function X(I){if(I._status===-1){var G=I._result;G=G(),G.then(function(B){(I._status===0||I._status===-1)&&(I._status=1,I._result=B)},function(B){(I._status===0||I._status===-1)&&(I._status=2,I._result=B)}),I._status===-1&&(I._status=0,I._result=G)}if(I._status===1)return I._result.default;throw I._result}var z=typeof reportError=="function"?reportError:function(I){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=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(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",I);return}console.error(I)},R={map:Q,forEach:function(I,G,B){Q(I,function(){G.apply(this,arguments)},B)},count:function(I){var G=0;return Q(I,function(){G++}),G},toArray:function(I){return Q(I,function(G){return G})||[]},only:function(I){if(!q(I))throw Error("React.Children.only expected to receive a single React element child.");return I}};return st.Activity=m,st.Children=R,st.Component=S,st.Fragment=n,st.Profiler=o,st.PureComponent=_,st.StrictMode=r,st.Suspense=d,st.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,st.__COMPILER_RUNTIME={__proto__:null,c:function(I){return D.H.useMemoCache(I)}},st.cache=function(I){return function(){return I.apply(null,arguments)}},st.cacheSignal=function(){return null},st.cloneElement=function(I,G,B){if(I==null)throw Error("The argument must be a React element, but you passed "+I+".");var ee=C({},I.props),J=I.key;if(G!=null)for(ne in G.key!==void 0&&(J=""+G.key),G)!L.call(G,ne)||ne==="key"||ne==="__self"||ne==="__source"||ne==="ref"&&G.ref===void 0||(ee[ne]=G[ne]);var ne=arguments.length-2;if(ne===1)ee.children=B;else if(1<ne){for(var K=Array(ne),F=0;F<ne;F++)K[F]=arguments[F+2];ee.children=K}return O(I.type,J,ee)},st.createContext=function(I){return I={$$typeof:u,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null},I.Provider=I,I.Consumer={$$typeof:l,_context:I},I},st.createElement=function(I,G,B){var ee,J={},ne=null;if(G!=null)for(ee in G.key!==void 0&&(ne=""+G.key),G)L.call(G,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(J[ee]=G[ee]);var K=arguments.length-2;if(K===1)J.children=B;else if(1<K){for(var F=Array(K),te=0;te<K;te++)F[te]=arguments[te+2];J.children=F}if(I&&I.defaultProps)for(ee in K=I.defaultProps,K)J[ee]===void 0&&(J[ee]=K[ee]);return O(I,ne,J)},st.createRef=function(){return{current:null}},st.forwardRef=function(I){return{$$typeof:c,render:I}},st.isValidElement=q,st.lazy=function(I){return{$$typeof:p,_payload:{_status:-1,_result:I},_init:X}},st.memo=function(I,G){return{$$typeof:f,type:I,compare:G===void 0?null:G}},st.startTransition=function(I){var G=D.T,B={};D.T=B;try{var ee=I(),J=D.S;J!==null&&J(B,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(T,z)}catch(ne){z(ne)}finally{G!==null&&B.types!==null&&(G.types=B.types),D.T=G}},st.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},st.use=function(I){return D.H.use(I)},st.useActionState=function(I,G,B){return D.H.useActionState(I,G,B)},st.useCallback=function(I,G){return D.H.useCallback(I,G)},st.useContext=function(I){return D.H.useContext(I)},st.useDebugValue=function(){},st.useDeferredValue=function(I,G){return D.H.useDeferredValue(I,G)},st.useEffect=function(I,G){return D.H.useEffect(I,G)},st.useEffectEvent=function(I){return D.H.useEffectEvent(I)},st.useId=function(){return D.H.useId()},st.useImperativeHandle=function(I,G,B){return D.H.useImperativeHandle(I,G,B)},st.useInsertionEffect=function(I,G){return D.H.useInsertionEffect(I,G)},st.useLayoutEffect=function(I,G){return D.H.useLayoutEffect(I,G)},st.useMemo=function(I,G){return D.H.useMemo(I,G)},st.useOptimistic=function(I,G){return D.H.useOptimistic(I,G)},st.useReducer=function(I,G,B){return D.H.useReducer(I,G,B)},st.useRef=function(I){return D.H.useRef(I)},st.useState=function(I){return D.H.useState(I)},st.useSyncExternalStore=function(I,G,B){return D.H.useSyncExternalStore(I,G,B)},st.useTransition=function(){return D.H.useTransition()},st.version="19.2.4",st}var bb;function Qu(){return bb||(bb=1,Hf.exports=D2()),Hf.exports}var A=Qu();const Ys=Xu(A),R2=T2({__proto__:null,default:Ys},[A]);var Uf={exports:{}},Ko={},Ff={exports:{}},Vf={};/**
|
|
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 vb;function O2(){return vb||(vb=1,(function(e){function t(U,Q){var X=U.length;U.push(Q);e:for(;0<X;){var z=X-1>>>1,R=U[z];if(0<o(R,Q))U[z]=Q,U[X]=R,X=z;else break e}}function n(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var Q=U[0],X=U.pop();if(X!==Q){U[0]=X;e:for(var z=0,R=U.length,I=R>>>1;z<I;){var G=2*(z+1)-1,B=U[G],ee=G+1,J=U[ee];if(0>o(B,X))ee<R&&0>o(J,B)?(U[z]=J,U[ee]=X,z=ee):(U[z]=B,U[G]=X,z=G);else if(ee<R&&0>o(J,X))U[z]=J,U[ee]=X,z=ee;else break e}}return Q}function o(U,Q){var X=U.sortIndex-Q.sortIndex;return X!==0?X:U.id-Q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,x=3,y=!1,w=!1,C=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function j(U){for(var Q=n(f);Q!==null;){if(Q.callback===null)r(f);else if(Q.startTime<=U)r(f),Q.sortIndex=Q.expirationTime,t(d,Q);else break;Q=n(f)}}function E(U){if(C=!1,j(U),!w)if(n(d)!==null)w=!0,T||(T=!0,W());else{var Q=n(f);Q!==null&&V(E,Q.startTime-U)}}var T=!1,D=-1,L=5,O=-1;function P(){return v?!0:!(e.unstable_now()-O<L)}function q(){if(v=!1,T){var U=e.unstable_now();O=U;var Q=!0;try{e:{w=!1,C&&(C=!1,b(D),D=-1),y=!0;var X=x;try{t:{for(j(U),m=n(d);m!==null&&!(m.expirationTime>U&&P());){var z=m.callback;if(typeof z=="function"){m.callback=null,x=m.priorityLevel;var R=z(m.expirationTime<=U);if(U=e.unstable_now(),typeof R=="function"){m.callback=R,j(U),Q=!0;break t}m===n(d)&&r(d),j(U)}else r(d);m=n(d)}if(m!==null)Q=!0;else{var I=n(f);I!==null&&V(E,I.startTime-U),Q=!1}}break e}finally{m=null,x=X,y=!1}Q=void 0}}finally{Q?W():T=!1}}}var W;if(typeof _=="function")W=function(){_(q)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,H=M.port2;M.port1.onmessage=q,W=function(){H.postMessage(null)}}else W=function(){S(q,0)};function V(U,Q){D=S(function(){U(e.unstable_now())},Q)}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(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(U){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var X=x;x=Q;try{return U()}finally{x=X}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(U,Q){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var X=x;x=U;try{return Q()}finally{x=X}},e.unstable_scheduleCallback=function(U,Q,X){var z=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?z+X:z):X=z,U){case 1:var R=-1;break;case 2:R=250;break;case 5:R=1073741823;break;case 4:R=1e4;break;default:R=5e3}return R=X+R,U={id:p++,callback:Q,priorityLevel:U,startTime:X,expirationTime:R,sortIndex:-1},X>z?(U.sortIndex=X,t(f,U),n(d)===null&&U===n(f)&&(C?(b(D),D=-1):C=!0,V(E,X-z))):(U.sortIndex=R,t(d,U),w||y||(w=!0,T||(T=!0,W()))),U},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(U){var Q=x;return function(){var X=x;x=Q;try{return U.apply(this,arguments)}finally{x=X}}}})(Vf)),Vf}var Sb;function M2(){return Sb||(Sb=1,Ff.exports=O2()),Ff.exports}var Gf={exports:{}},jn={};/**
|
|
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 wb;function I2(){if(wb)return jn;wb=1;var e=Qu();function t(d){var f="https://react.dev/errors/"+d;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+d+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function l(d,f,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:m==null?null:""+m,children:d,containerInfo:f,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(d,f){if(d==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return jn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,jn.createPortal=function(d,f){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return l(d,f,null,p)},jn.flushSync=function(d){var f=u.T,p=r.p;try{if(u.T=null,r.p=2,d)return d()}finally{u.T=f,r.p=p,r.d.f()}},jn.preconnect=function(d,f){typeof d=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,r.d.C(d,f))},jn.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},jn.preinit=function(d,f){if(typeof d=="string"&&f&&typeof f.as=="string"){var p=f.as,m=c(p,f.crossOrigin),x=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?r.d.S(d,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:m,integrity:x,fetchPriority:y}):p==="script"&&r.d.X(d,{crossOrigin:m,integrity:x,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},jn.preinitModule=function(d,f){if(typeof d=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var p=c(f.as,f.crossOrigin);r.d.M(d,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&r.d.M(d)},jn.preload=function(d,f){if(typeof d=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,m=c(p,f.crossOrigin);r.d.L(d,p,{crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},jn.preloadModule=function(d,f){if(typeof d=="string")if(f){var p=c(f.as,f.crossOrigin);r.d.m(d,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else r.d.m(d)},jn.requestFormReset=function(d){r.d.r(d)},jn.unstable_batchedUpdates=function(d,f){return d(f)},jn.useFormState=function(d,f,p){return u.H.useFormState(d,f,p)},jn.useFormStatus=function(){return u.H.useHostTransitionStatus()},jn.version="19.2.4",jn}var Cb;function gS(){if(Cb)return Gf.exports;Cb=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(),Gf.exports=I2(),Gf.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 kb;function P2(){if(kb)return Ko;kb=1;var e=M2(),t=Qu(),n=gS();function r(s){var i="https://react.dev/errors/"+s;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)i+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+s+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function l(s){var i=s,h=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,(i.flags&4098)!==0&&(h=i.return),s=i.return;while(s)}return i.tag===3?h:null}function u(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null}function c(s){if(s.tag===31){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null}function d(s){if(l(s)!==s)throw Error(r(188))}function f(s){var i=s.alternate;if(!i){if(i=l(s),i===null)throw Error(r(188));return i!==s?null:s}for(var h=s,g=i;;){var k=h.return;if(k===null)break;var N=k.alternate;if(N===null){if(g=k.return,g!==null){h=g;continue}break}if(k.child===N.child){for(N=k.child;N;){if(N===h)return d(k),s;if(N===g)return d(k),i;N=N.sibling}throw Error(r(188))}if(h.return!==g.return)h=k,g=N;else{for(var $=!1,Y=k.child;Y;){if(Y===h){$=!0,h=k,g=N;break}if(Y===g){$=!0,g=k,h=N;break}Y=Y.sibling}if(!$){for(Y=N.child;Y;){if(Y===h){$=!0,h=N,g=k;break}if(Y===g){$=!0,g=N,h=k;break}Y=Y.sibling}if(!$)throw Error(r(189))}}if(h.alternate!==g)throw Error(r(190))}if(h.tag!==3)throw Error(r(188));return h.stateNode.current===h?s:i}function p(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(i=p(s),i!==null)return i;s=s.sibling}return null}var m=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),_=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),q=Symbol.iterator;function W(s){return s===null||typeof s!="object"?null:(s=q&&s[q]||s["@@iterator"],typeof s=="function"?s:null)}var M=Symbol.for("react.client.reference");function H(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===M?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case C:return"Fragment";case S:return"Profiler";case v:return"StrictMode";case E:return"Suspense";case T:return"SuspenseList";case O:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case w:return"Portal";case _:return s.displayName||"Context";case b:return(s._context.displayName||"Context")+".Consumer";case j:var i=s.render;return s=s.displayName,s||(s=i.displayName||i.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case D:return i=s.displayName||null,i!==null?i:H(s.type)||"Memo";case L:i=s._payload,s=s._init;try{return H(s(i))}catch{}}return null}var V=Array.isArray,U=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},z=[],R=-1;function I(s){return{current:s}}function G(s){0>R||(s.current=z[R],z[R]=null,R--)}function B(s,i){R++,z[R]=s.current,s.current=i}var ee=I(null),J=I(null),ne=I(null),K=I(null);function F(s,i){switch(B(ne,i),B(J,s),B(ee,null),i.nodeType){case 9:case 11:s=(s=i.documentElement)&&(s=s.namespaceURI)?B_(s):0;break;default:if(s=i.tagName,i=i.namespaceURI)i=B_(i),s=$_(i,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}G(ee),B(ee,s)}function te(){G(ee),G(J),G(ne)}function re(s){s.memoizedState!==null&&B(K,s);var i=ee.current,h=$_(i,s.type);i!==h&&(B(J,s),B(ee,h))}function pe(s){J.current===s&&(G(ee),G(J)),K.current===s&&(G(K),Fo._currentValue=X)}var be,Pe;function $e(s){if(be===void 0)try{throw Error()}catch(h){var i=h.stack.trim().match(/\n( *(at )?)/);be=i&&i[1]||"",Pe=-1<h.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+be+s+Pe}var Ne=!1;function je(s,i){if(!s||Ne)return"";Ne=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(i){var Ee=function(){throw Error()};if(Object.defineProperty(Ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ee,[])}catch(ge){var fe=ge}Reflect.construct(s,[],Ee)}else{try{Ee.call()}catch(ge){fe=ge}s.call(Ee.prototype)}}else{try{throw Error()}catch(ge){fe=ge}(Ee=s())&&typeof Ee.catch=="function"&&Ee.catch(function(){})}}catch(ge){if(ge&&fe&&typeof ge.stack=="string")return[ge.stack,fe.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var N=g.DetermineComponentFrameRoot(),$=N[0],Y=N[1];if($&&Y){var ie=$.split(`
|
|
45
|
+
`),de=Y.split(`
|
|
46
|
+
`);for(k=g=0;g<ie.length&&!ie[g].includes("DetermineComponentFrameRoot");)g++;for(;k<de.length&&!de[k].includes("DetermineComponentFrameRoot");)k++;if(g===ie.length||k===de.length)for(g=ie.length-1,k=de.length-1;1<=g&&0<=k&&ie[g]!==de[k];)k--;for(;1<=g&&0<=k;g--,k--)if(ie[g]!==de[k]){if(g!==1||k!==1)do if(g--,k--,0>k||ie[g]!==de[k]){var Se=`
|
|
47
|
+
`+ie[g].replace(" at new "," at ");return s.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",s.displayName)),Se}while(1<=g&&0<=k);break}}}finally{Ne=!1,Error.prepareStackTrace=h}return(h=s?s.displayName||s.name:"")?$e(h):""}function oe(s,i){switch(s.tag){case 26:case 27:case 5:return $e(s.type);case 16:return $e("Lazy");case 13:return s.child!==i&&i!==null?$e("Suspense Fallback"):$e("Suspense");case 19:return $e("SuspenseList");case 0:case 15:return je(s.type,!1);case 11:return je(s.type.render,!1);case 1:return je(s.type,!0);case 31:return $e("Activity");default:return""}}function Be(s){try{var i="",h=null;do i+=oe(s,h),h=s,s=s.return;while(s);return i}catch(g){return`
|
|
48
|
+
Error generating stack: `+g.message+`
|
|
49
|
+
`+g.stack}}var he=Object.prototype.hasOwnProperty,se=e.unstable_scheduleCallback,xe=e.unstable_cancelCallback,Ve=e.unstable_shouldYield,Ze=e.unstable_requestPaint,it=e.unstable_now,Et=e.unstable_getCurrentPriorityLevel,ce=e.unstable_ImmediatePriority,Te=e.unstable_UserBlockingPriority,Fe=e.unstable_NormalPriority,Ye=e.unstable_LowPriority,tt=e.unstable_IdlePriority,kt=e.log,at=e.unstable_setDisableYieldValue,me=null,Oe=null;function We(s){if(typeof kt=="function"&&at(s),Oe&&typeof Oe.setStrictMode=="function")try{Oe.setStrictMode(me,s)}catch{}}var et=Math.clz32?Math.clz32:Xn,En=Math.log,Wt=Math.LN2;function Xn(s){return s>>>=0,s===0?32:31-(En(s)/Wt|0)|0}var Qn=256,ye=262144,He=4194304;function Me(s){var i=s&42;if(i!==0)return i;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ae(s,i,h){var g=s.pendingLanes;if(g===0)return 0;var k=0,N=s.suspendedLanes,$=s.pingedLanes;s=s.warmLanes;var Y=g&134217727;return Y!==0?(g=Y&~N,g!==0?k=Me(g):($&=Y,$!==0?k=Me($):h||(h=Y&~s,h!==0&&(k=Me(h))))):(Y=g&~N,Y!==0?k=Me(Y):$!==0?k=Me($):h||(h=g&~s,h!==0&&(k=Me(h)))),k===0?0:i!==0&&i!==k&&(i&N)===0&&(N=k&-k,h=i&-i,N>=h||N===32&&(h&4194048)!==0)?i:k}function Qe(s,i){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&i)===0}function Bt(s,i){switch(s){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Mn(){var s=He;return He<<=1,(He&62914560)===0&&(He=4194304),s}function bn(s){for(var i=[],h=0;31>h;h++)i.push(s);return i}function Cr(s,i){s.pendingLanes|=i,i!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function ve(s,i,h,g,k,N){var $=s.pendingLanes;s.pendingLanes=h,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=h,s.entangledLanes&=h,s.errorRecoveryDisabledLanes&=h,s.shellSuspendCounter=0;var Y=s.entanglements,ie=s.expirationTimes,de=s.hiddenUpdates;for(h=$&~h;0<h;){var Se=31-et(h),Ee=1<<Se;Y[Se]=0,ie[Se]=-1;var fe=de[Se];if(fe!==null)for(de[Se]=null,Se=0;Se<fe.length;Se++){var ge=fe[Se];ge!==null&&(ge.lane&=-536870913)}h&=~Ee}g!==0&&we(s,g,0),N!==0&&k===0&&s.tag!==0&&(s.suspendedLanes|=N&~($&~i))}function we(s,i,h){s.pendingLanes|=i,s.suspendedLanes&=~i;var g=31-et(i);s.entangledLanes|=i,s.entanglements[g]=s.entanglements[g]|1073741824|h&261930}function ze(s,i){var h=s.entangledLanes|=i;for(s=s.entanglements;h;){var g=31-et(h),k=1<<g;k&i|s[g]&i&&(s[g]|=i),h&=~k}}function qe(s,i){var h=i&-i;return h=(h&42)!==0?1:lt(h),(h&(s.suspendedLanes|i))!==0?0:h}function lt(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function nt(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function yt(){var s=Q.p;return s!==0?s:(s=window.event,s===void 0?32:lb(s.type))}function nn(s,i){var h=Q.p;try{return Q.p=s,i()}finally{Q.p=h}}var Mt=Math.random().toString(36).slice(2),jt="__reactFiber$"+Mt,In="__reactProps$"+Mt,Fi="__reactContainer$"+Mt,Nd="__reactEvents$"+Mt,mk="__reactListeners$"+Mt,pk="__reactHandles$"+Mt,kg="__reactResources$"+Mt,ro="__reactMarker$"+Mt;function Td(s){delete s[jt],delete s[In],delete s[Nd],delete s[mk],delete s[pk]}function Vi(s){var i=s[jt];if(i)return i;for(var h=s.parentNode;h;){if(i=h[Fi]||h[jt]){if(h=i.alternate,i.child!==null||h!==null&&h.child!==null)for(s=W_(s);s!==null;){if(h=s[jt])return h;s=W_(s)}return i}s=h,h=s.parentNode}return null}function Gi(s){if(s=s[jt]||s[Fi]){var i=s.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return s}return null}function so(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s.stateNode;throw Error(r(33))}function Wi(s){var i=s[kg];return i||(i=s[kg]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function gn(s){s[ro]=!0}var Eg=new Set,jg={};function si(s,i){qi(s,i),qi(s+"Capture",i)}function qi(s,i){for(jg[s]=i,s=0;s<i.length;s++)Eg.add(i[s])}var gk=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]*$"),Ng={},Tg={};function xk(s){return he.call(Tg,s)?!0:he.call(Ng,s)?!1:gk.test(s)?Tg[s]=!0:(Ng[s]=!0,!1)}function $l(s,i,h){if(xk(i))if(h===null)s.removeAttribute(i);else{switch(typeof h){case"undefined":case"function":case"symbol":s.removeAttribute(i);return;case"boolean":var g=i.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){s.removeAttribute(i);return}}s.setAttribute(i,""+h)}}function zl(s,i,h){if(h===null)s.removeAttribute(i);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(i);return}s.setAttribute(i,""+h)}}function Kr(s,i,h,g){if(g===null)s.removeAttribute(h);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(h);return}s.setAttributeNS(i,h,""+g)}}function cr(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Ag(s){var i=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function yk(s,i,h){var g=Object.getOwnPropertyDescriptor(s.constructor.prototype,i);if(!s.hasOwnProperty(i)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var k=g.get,N=g.set;return Object.defineProperty(s,i,{configurable:!0,get:function(){return k.call(this)},set:function($){h=""+$,N.call(this,$)}}),Object.defineProperty(s,i,{enumerable:g.enumerable}),{getValue:function(){return h},setValue:function($){h=""+$},stopTracking:function(){s._valueTracker=null,delete s[i]}}}}function Ad(s){if(!s._valueTracker){var i=Ag(s)?"checked":"value";s._valueTracker=yk(s,i,""+s[i])}}function Lg(s){if(!s)return!1;var i=s._valueTracker;if(!i)return!0;var h=i.getValue(),g="";return s&&(g=Ag(s)?s.checked?"true":"false":s.value),s=g,s!==h?(i.setValue(s),!0):!1}function Hl(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var _k=/[\n"\\]/g;function ur(s){return s.replace(_k,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Ld(s,i,h,g,k,N,$,Y){s.name="",$!=null&&typeof $!="function"&&typeof $!="symbol"&&typeof $!="boolean"?s.type=$:s.removeAttribute("type"),i!=null?$==="number"?(i===0&&s.value===""||s.value!=i)&&(s.value=""+cr(i)):s.value!==""+cr(i)&&(s.value=""+cr(i)):$!=="submit"&&$!=="reset"||s.removeAttribute("value"),i!=null?Dd(s,$,cr(i)):h!=null?Dd(s,$,cr(h)):g!=null&&s.removeAttribute("value"),k==null&&N!=null&&(s.defaultChecked=!!N),k!=null&&(s.checked=k&&typeof k!="function"&&typeof k!="symbol"),Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?s.name=""+cr(Y):s.removeAttribute("name")}function Dg(s,i,h,g,k,N,$,Y){if(N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(s.type=N),i!=null||h!=null){if(!(N!=="submit"&&N!=="reset"||i!=null)){Ad(s);return}h=h!=null?""+cr(h):"",i=i!=null?""+cr(i):h,Y||i===s.value||(s.value=i),s.defaultValue=i}g=g??k,g=typeof g!="function"&&typeof g!="symbol"&&!!g,s.checked=Y?s.checked:!!g,s.defaultChecked=!!g,$!=null&&typeof $!="function"&&typeof $!="symbol"&&typeof $!="boolean"&&(s.name=$),Ad(s)}function Dd(s,i,h){i==="number"&&Hl(s.ownerDocument)===s||s.defaultValue===""+h||(s.defaultValue=""+h)}function Ki(s,i,h,g){if(s=s.options,i){i={};for(var k=0;k<h.length;k++)i["$"+h[k]]=!0;for(h=0;h<s.length;h++)k=i.hasOwnProperty("$"+s[h].value),s[h].selected!==k&&(s[h].selected=k),k&&g&&(s[h].defaultSelected=!0)}else{for(h=""+cr(h),i=null,k=0;k<s.length;k++){if(s[k].value===h){s[k].selected=!0,g&&(s[k].defaultSelected=!0);return}i!==null||s[k].disabled||(i=s[k])}i!==null&&(i.selected=!0)}}function Rg(s,i,h){if(i!=null&&(i=""+cr(i),i!==s.value&&(s.value=i),h==null)){s.defaultValue!==i&&(s.defaultValue=i);return}s.defaultValue=h!=null?""+cr(h):""}function Og(s,i,h,g){if(i==null){if(g!=null){if(h!=null)throw Error(r(92));if(V(g)){if(1<g.length)throw Error(r(93));g=g[0]}h=g}h==null&&(h=""),i=h}h=cr(i),s.defaultValue=h,g=s.textContent,g===h&&g!==""&&g!==null&&(s.value=g),Ad(s)}function Yi(s,i){if(i){var h=s.firstChild;if(h&&h===s.lastChild&&h.nodeType===3){h.nodeValue=i;return}}s.textContent=i}var bk=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 Mg(s,i,h){var g=i.indexOf("--")===0;h==null||typeof h=="boolean"||h===""?g?s.setProperty(i,""):i==="float"?s.cssFloat="":s[i]="":g?s.setProperty(i,h):typeof h!="number"||h===0||bk.has(i)?i==="float"?s.cssFloat=h:s[i]=(""+h).trim():s[i]=h+"px"}function Ig(s,i,h){if(i!=null&&typeof i!="object")throw Error(r(62));if(s=s.style,h!=null){for(var g in h)!h.hasOwnProperty(g)||i!=null&&i.hasOwnProperty(g)||(g.indexOf("--")===0?s.setProperty(g,""):g==="float"?s.cssFloat="":s[g]="");for(var k in i)g=i[k],i.hasOwnProperty(k)&&h[k]!==g&&Mg(s,k,g)}else for(var N in i)i.hasOwnProperty(N)&&Mg(s,N,i[N])}function Rd(s){if(s.indexOf("-")===-1)return!1;switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var vk=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"]]),Sk=/^[\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 Ul(s){return Sk.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function Yr(){}var Od=null;function Md(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Xi=null,Qi=null;function Pg(s){var i=Gi(s);if(i&&(s=i.stateNode)){var h=s[In]||null;e:switch(s=i.stateNode,i.type){case"input":if(Ld(s,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name),i=h.name,h.type==="radio"&&i!=null){for(h=s;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll('input[name="'+ur(""+i)+'"][type="radio"]'),i=0;i<h.length;i++){var g=h[i];if(g!==s&&g.form===s.form){var k=g[In]||null;if(!k)throw Error(r(90));Ld(g,k.value,k.defaultValue,k.defaultValue,k.checked,k.defaultChecked,k.type,k.name)}}for(i=0;i<h.length;i++)g=h[i],g.form===s.form&&Lg(g)}break e;case"textarea":Rg(s,h.value,h.defaultValue);break e;case"select":i=h.value,i!=null&&Ki(s,!!h.multiple,i,!1)}}}var Id=!1;function Bg(s,i,h){if(Id)return s(i,h);Id=!0;try{var g=s(i);return g}finally{if(Id=!1,(Xi!==null||Qi!==null)&&(Tc(),Xi&&(i=Xi,s=Qi,Qi=Xi=null,Pg(i),s)))for(i=0;i<s.length;i++)Pg(s[i])}}function io(s,i){var h=s.stateNode;if(h===null)return null;var g=h[In]||null;if(g===null)return null;h=g[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(s=s.type,g=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!g;break e;default:s=!1}if(s)return null;if(h&&typeof h!="function")throw Error(r(231,i,typeof h));return h}var Xr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Pd=!1;if(Xr)try{var ao={};Object.defineProperty(ao,"passive",{get:function(){Pd=!0}}),window.addEventListener("test",ao,ao),window.removeEventListener("test",ao,ao)}catch{Pd=!1}var vs=null,Bd=null,Fl=null;function $g(){if(Fl)return Fl;var s,i=Bd,h=i.length,g,k="value"in vs?vs.value:vs.textContent,N=k.length;for(s=0;s<h&&i[s]===k[s];s++);var $=h-s;for(g=1;g<=$&&i[h-g]===k[N-g];g++);return Fl=k.slice(s,1<g?1-g:void 0)}function Vl(s){var i=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&i===13&&(s=13)):s=i,s===10&&(s=13),32<=s||s===13?s:0}function Gl(){return!0}function zg(){return!1}function Pn(s){function i(h,g,k,N,$){this._reactName=h,this._targetInst=k,this.type=g,this.nativeEvent=N,this.target=$,this.currentTarget=null;for(var Y in s)s.hasOwnProperty(Y)&&(h=s[Y],this[Y]=h?h(N):N[Y]);return this.isDefaultPrevented=(N.defaultPrevented!=null?N.defaultPrevented:N.returnValue===!1)?Gl:zg,this.isPropagationStopped=zg,this}return m(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=Gl)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=Gl)},persist:function(){},isPersistent:Gl}),i}var ii={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Wl=Pn(ii),oo=m({},ii,{view:0,detail:0}),wk=Pn(oo),$d,zd,lo,ql=m({},oo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ud,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==lo&&(lo&&s.type==="mousemove"?($d=s.screenX-lo.screenX,zd=s.screenY-lo.screenY):zd=$d=0,lo=s),$d)},movementY:function(s){return"movementY"in s?s.movementY:zd}}),Hg=Pn(ql),Ck=m({},ql,{dataTransfer:0}),kk=Pn(Ck),Ek=m({},oo,{relatedTarget:0}),Hd=Pn(Ek),jk=m({},ii,{animationName:0,elapsedTime:0,pseudoElement:0}),Nk=Pn(jk),Tk=m({},ii,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Ak=Pn(Tk),Lk=m({},ii,{data:0}),Ug=Pn(Lk),Dk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Rk={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"},Ok={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mk(s){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(s):(s=Ok[s])?!!i[s]:!1}function Ud(){return Mk}var Ik=m({},oo,{key:function(s){if(s.key){var i=Dk[s.key]||s.key;if(i!=="Unidentified")return i}return s.type==="keypress"?(s=Vl(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Rk[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ud,charCode:function(s){return s.type==="keypress"?Vl(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Vl(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Pk=Pn(Ik),Bk=m({},ql,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Fg=Pn(Bk),$k=m({},oo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ud}),zk=Pn($k),Hk=m({},ii,{propertyName:0,elapsedTime:0,pseudoElement:0}),Uk=Pn(Hk),Fk=m({},ql,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),Vk=Pn(Fk),Gk=m({},ii,{newState:0,oldState:0}),Wk=Pn(Gk),qk=[9,13,27,32],Fd=Xr&&"CompositionEvent"in window,co=null;Xr&&"documentMode"in document&&(co=document.documentMode);var Kk=Xr&&"TextEvent"in window&&!co,Vg=Xr&&(!Fd||co&&8<co&&11>=co),Gg=" ",Wg=!1;function qg(s,i){switch(s){case"keyup":return qk.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kg(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Ji=!1;function Yk(s,i){switch(s){case"compositionend":return Kg(i);case"keypress":return i.which!==32?null:(Wg=!0,Gg);case"textInput":return s=i.data,s===Gg&&Wg?null:s;default:return null}}function Xk(s,i){if(Ji)return s==="compositionend"||!Fd&&qg(s,i)?(s=$g(),Fl=Bd=vs=null,Ji=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Vg&&i.locale!=="ko"?null:i.data;default:return null}}var Qk={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 Yg(s){var i=s&&s.nodeName&&s.nodeName.toLowerCase();return i==="input"?!!Qk[s.type]:i==="textarea"}function Xg(s,i,h,g){Xi?Qi?Qi.push(g):Qi=[g]:Xi=g,i=Ic(i,"onChange"),0<i.length&&(h=new Wl("onChange","change",null,h,g),s.push({event:h,listeners:i}))}var uo=null,ho=null;function Jk(s){D_(s,0)}function Kl(s){var i=so(s);if(Lg(i))return s}function Qg(s,i){if(s==="change")return i}var Jg=!1;if(Xr){var Vd;if(Xr){var Gd="oninput"in document;if(!Gd){var Zg=document.createElement("div");Zg.setAttribute("oninput","return;"),Gd=typeof Zg.oninput=="function"}Vd=Gd}else Vd=!1;Jg=Vd&&(!document.documentMode||9<document.documentMode)}function ex(){uo&&(uo.detachEvent("onpropertychange",tx),ho=uo=null)}function tx(s){if(s.propertyName==="value"&&Kl(ho)){var i=[];Xg(i,ho,s,Md(s)),Bg(Jk,i)}}function Zk(s,i,h){s==="focusin"?(ex(),uo=i,ho=h,uo.attachEvent("onpropertychange",tx)):s==="focusout"&&ex()}function eE(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Kl(ho)}function tE(s,i){if(s==="click")return Kl(i)}function nE(s,i){if(s==="input"||s==="change")return Kl(i)}function rE(s,i){return s===i&&(s!==0||1/s===1/i)||s!==s&&i!==i}var Jn=typeof Object.is=="function"?Object.is:rE;function fo(s,i){if(Jn(s,i))return!0;if(typeof s!="object"||s===null||typeof i!="object"||i===null)return!1;var h=Object.keys(s),g=Object.keys(i);if(h.length!==g.length)return!1;for(g=0;g<h.length;g++){var k=h[g];if(!he.call(i,k)||!Jn(s[k],i[k]))return!1}return!0}function nx(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function rx(s,i){var h=nx(s);s=0;for(var g;h;){if(h.nodeType===3){if(g=s+h.textContent.length,s<=i&&g>=i)return{node:h,offset:i-s};s=g}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=nx(h)}}function sx(s,i){return s&&i?s===i?!0:s&&s.nodeType===3?!1:i&&i.nodeType===3?sx(s,i.parentNode):"contains"in s?s.contains(i):s.compareDocumentPosition?!!(s.compareDocumentPosition(i)&16):!1:!1}function ix(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var i=Hl(s.document);i instanceof s.HTMLIFrameElement;){try{var h=typeof i.contentWindow.location.href=="string"}catch{h=!1}if(h)s=i.contentWindow;else break;i=Hl(s.document)}return i}function Wd(s){var i=s&&s.nodeName&&s.nodeName.toLowerCase();return i&&(i==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||i==="textarea"||s.contentEditable==="true")}var sE=Xr&&"documentMode"in document&&11>=document.documentMode,Zi=null,qd=null,mo=null,Kd=!1;function ax(s,i,h){var g=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Kd||Zi==null||Zi!==Hl(g)||(g=Zi,"selectionStart"in g&&Wd(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),mo&&fo(mo,g)||(mo=g,g=Ic(qd,"onSelect"),0<g.length&&(i=new Wl("onSelect","select",null,i,h),s.push({event:i,listeners:g}),i.target=Zi)))}function ai(s,i){var h={};return h[s.toLowerCase()]=i.toLowerCase(),h["Webkit"+s]="webkit"+i,h["Moz"+s]="moz"+i,h}var ea={animationend:ai("Animation","AnimationEnd"),animationiteration:ai("Animation","AnimationIteration"),animationstart:ai("Animation","AnimationStart"),transitionrun:ai("Transition","TransitionRun"),transitionstart:ai("Transition","TransitionStart"),transitioncancel:ai("Transition","TransitionCancel"),transitionend:ai("Transition","TransitionEnd")},Yd={},ox={};Xr&&(ox=document.createElement("div").style,"AnimationEvent"in window||(delete ea.animationend.animation,delete ea.animationiteration.animation,delete ea.animationstart.animation),"TransitionEvent"in window||delete ea.transitionend.transition);function oi(s){if(Yd[s])return Yd[s];if(!ea[s])return s;var i=ea[s],h;for(h in i)if(i.hasOwnProperty(h)&&h in ox)return Yd[s]=i[h];return s}var lx=oi("animationend"),cx=oi("animationiteration"),ux=oi("animationstart"),iE=oi("transitionrun"),aE=oi("transitionstart"),oE=oi("transitioncancel"),dx=oi("transitionend"),hx=new Map,Xd="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(" ");Xd.push("scrollEnd");function kr(s,i){hx.set(s,i),si(i,[s])}var Yl=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},dr=[],ta=0,Qd=0;function Xl(){for(var s=ta,i=Qd=ta=0;i<s;){var h=dr[i];dr[i++]=null;var g=dr[i];dr[i++]=null;var k=dr[i];dr[i++]=null;var N=dr[i];if(dr[i++]=null,g!==null&&k!==null){var $=g.pending;$===null?k.next=k:(k.next=$.next,$.next=k),g.pending=k}N!==0&&fx(h,k,N)}}function Ql(s,i,h,g){dr[ta++]=s,dr[ta++]=i,dr[ta++]=h,dr[ta++]=g,Qd|=g,s.lanes|=g,s=s.alternate,s!==null&&(s.lanes|=g)}function Jd(s,i,h,g){return Ql(s,i,h,g),Jl(s)}function li(s,i){return Ql(s,null,null,i),Jl(s)}function fx(s,i,h){s.lanes|=h;var g=s.alternate;g!==null&&(g.lanes|=h);for(var k=!1,N=s.return;N!==null;)N.childLanes|=h,g=N.alternate,g!==null&&(g.childLanes|=h),N.tag===22&&(s=N.stateNode,s===null||s._visibility&1||(k=!0)),s=N,N=N.return;return s.tag===3?(N=s.stateNode,k&&i!==null&&(k=31-et(h),s=N.hiddenUpdates,g=s[k],g===null?s[k]=[i]:g.push(i),i.lane=h|536870912),N):null}function Jl(s){if(50<Io)throw Io=0,lf=null,Error(r(185));for(var i=s.return;i!==null;)s=i,i=s.return;return s.tag===3?s.stateNode:null}var na={};function lE(s,i,h,g){this.tag=s,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zn(s,i,h,g){return new lE(s,i,h,g)}function Zd(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Qr(s,i){var h=s.alternate;return h===null?(h=Zn(s.tag,i,s.key,s.mode),h.elementType=s.elementType,h.type=s.type,h.stateNode=s.stateNode,h.alternate=s,s.alternate=h):(h.pendingProps=i,h.type=s.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=s.flags&65011712,h.childLanes=s.childLanes,h.lanes=s.lanes,h.child=s.child,h.memoizedProps=s.memoizedProps,h.memoizedState=s.memoizedState,h.updateQueue=s.updateQueue,i=s.dependencies,h.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},h.sibling=s.sibling,h.index=s.index,h.ref=s.ref,h.refCleanup=s.refCleanup,h}function mx(s,i){s.flags&=65011714;var h=s.alternate;return h===null?(s.childLanes=0,s.lanes=i,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=h.childLanes,s.lanes=h.lanes,s.child=h.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=h.memoizedProps,s.memoizedState=h.memoizedState,s.updateQueue=h.updateQueue,s.type=h.type,i=h.dependencies,s.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),s}function Zl(s,i,h,g,k,N){var $=0;if(g=s,typeof s=="function")Zd(s)&&($=1);else if(typeof s=="string")$=f2(s,h,ee.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case O:return s=Zn(31,h,i,k),s.elementType=O,s.lanes=N,s;case C:return ci(h.children,k,N,i);case v:$=8,k|=24;break;case S:return s=Zn(12,h,i,k|2),s.elementType=S,s.lanes=N,s;case E:return s=Zn(13,h,i,k),s.elementType=E,s.lanes=N,s;case T:return s=Zn(19,h,i,k),s.elementType=T,s.lanes=N,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case _:$=10;break e;case b:$=9;break e;case j:$=11;break e;case D:$=14;break e;case L:$=16,g=null;break e}$=29,h=Error(r(130,s===null?"null":typeof s,"")),g=null}return i=Zn($,h,i,k),i.elementType=s,i.type=g,i.lanes=N,i}function ci(s,i,h,g){return s=Zn(7,s,g,i),s.lanes=h,s}function eh(s,i,h){return s=Zn(6,s,null,i),s.lanes=h,s}function px(s){var i=Zn(18,null,null,0);return i.stateNode=s,i}function th(s,i,h){return i=Zn(4,s.children!==null?s.children:[],s.key,i),i.lanes=h,i.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},i}var gx=new WeakMap;function hr(s,i){if(typeof s=="object"&&s!==null){var h=gx.get(s);return h!==void 0?h:(i={value:s,source:i,stack:Be(i)},gx.set(s,i),i)}return{value:s,source:i,stack:Be(i)}}var ra=[],sa=0,ec=null,po=0,fr=[],mr=0,Ss=null,Mr=1,Ir="";function Jr(s,i){ra[sa++]=po,ra[sa++]=ec,ec=s,po=i}function xx(s,i,h){fr[mr++]=Mr,fr[mr++]=Ir,fr[mr++]=Ss,Ss=s;var g=Mr;s=Ir;var k=32-et(g)-1;g&=~(1<<k),h+=1;var N=32-et(i)+k;if(30<N){var $=k-k%5;N=(g&(1<<$)-1).toString(32),g>>=$,k-=$,Mr=1<<32-et(i)+k|h<<k|g,Ir=N+s}else Mr=1<<N|h<<k|g,Ir=s}function nh(s){s.return!==null&&(Jr(s,1),xx(s,1,0))}function rh(s){for(;s===ec;)ec=ra[--sa],ra[sa]=null,po=ra[--sa],ra[sa]=null;for(;s===Ss;)Ss=fr[--mr],fr[mr]=null,Ir=fr[--mr],fr[mr]=null,Mr=fr[--mr],fr[mr]=null}function yx(s,i){fr[mr++]=Mr,fr[mr++]=Ir,fr[mr++]=Ss,Mr=i.id,Ir=i.overflow,Ss=s}var vn=null,Ft=null,_t=!1,ws=null,pr=!1,sh=Error(r(519));function Cs(s){var i=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw go(hr(i,s)),sh}function _x(s){var i=s.stateNode,h=s.type,g=s.memoizedProps;switch(i[jt]=s,i[In]=g,h){case"dialog":mt("cancel",i),mt("close",i);break;case"iframe":case"object":case"embed":mt("load",i);break;case"video":case"audio":for(h=0;h<Bo.length;h++)mt(Bo[h],i);break;case"source":mt("error",i);break;case"img":case"image":case"link":mt("error",i),mt("load",i);break;case"details":mt("toggle",i);break;case"input":mt("invalid",i),Dg(i,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":mt("invalid",i);break;case"textarea":mt("invalid",i),Og(i,g.value,g.defaultValue,g.children)}h=g.children,typeof h!="string"&&typeof h!="number"&&typeof h!="bigint"||i.textContent===""+h||g.suppressHydrationWarning===!0||I_(i.textContent,h)?(g.popover!=null&&(mt("beforetoggle",i),mt("toggle",i)),g.onScroll!=null&&mt("scroll",i),g.onScrollEnd!=null&&mt("scrollend",i),g.onClick!=null&&(i.onclick=Yr),i=!0):i=!1,i||Cs(s,!0)}function bx(s){for(vn=s.return;vn;)switch(vn.tag){case 5:case 31:case 13:pr=!1;return;case 27:case 3:pr=!0;return;default:vn=vn.return}}function ia(s){if(s!==vn)return!1;if(!_t)return bx(s),_t=!0,!1;var i=s.tag,h;if((h=i!==3&&i!==27)&&((h=i===5)&&(h=s.type,h=!(h!=="form"&&h!=="button")||wf(s.type,s.memoizedProps)),h=!h),h&&Ft&&Cs(s),bx(s),i===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Ft=G_(s)}else if(i===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Ft=G_(s)}else i===27?(i=Ft,Bs(s.type)?(s=Nf,Nf=null,Ft=s):Ft=i):Ft=vn?xr(s.stateNode.nextSibling):null;return!0}function ui(){Ft=vn=null,_t=!1}function ih(){var s=ws;return s!==null&&(Hn===null?Hn=s:Hn.push.apply(Hn,s),ws=null),s}function go(s){ws===null?ws=[s]:ws.push(s)}var ah=I(null),di=null,Zr=null;function ks(s,i,h){B(ah,i._currentValue),i._currentValue=h}function es(s){s._currentValue=ah.current,G(ah)}function oh(s,i,h){for(;s!==null;){var g=s.alternate;if((s.childLanes&i)!==i?(s.childLanes|=i,g!==null&&(g.childLanes|=i)):g!==null&&(g.childLanes&i)!==i&&(g.childLanes|=i),s===h)break;s=s.return}}function lh(s,i,h,g){var k=s.child;for(k!==null&&(k.return=s);k!==null;){var N=k.dependencies;if(N!==null){var $=k.child;N=N.firstContext;e:for(;N!==null;){var Y=N;N=k;for(var ie=0;ie<i.length;ie++)if(Y.context===i[ie]){N.lanes|=h,Y=N.alternate,Y!==null&&(Y.lanes|=h),oh(N.return,h,s),g||($=null);break e}N=Y.next}}else if(k.tag===18){if($=k.return,$===null)throw Error(r(341));$.lanes|=h,N=$.alternate,N!==null&&(N.lanes|=h),oh($,h,s),$=null}else $=k.child;if($!==null)$.return=k;else for($=k;$!==null;){if($===s){$=null;break}if(k=$.sibling,k!==null){k.return=$.return,$=k;break}$=$.return}k=$}}function aa(s,i,h,g){s=null;for(var k=i,N=!1;k!==null;){if(!N){if((k.flags&524288)!==0)N=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var $=k.alternate;if($===null)throw Error(r(387));if($=$.memoizedProps,$!==null){var Y=k.type;Jn(k.pendingProps.value,$.value)||(s!==null?s.push(Y):s=[Y])}}else if(k===K.current){if($=k.alternate,$===null)throw Error(r(387));$.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(s!==null?s.push(Fo):s=[Fo])}k=k.return}s!==null&&lh(i,s,h,g),i.flags|=262144}function tc(s){for(s=s.firstContext;s!==null;){if(!Jn(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function hi(s){di=s,Zr=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Sn(s){return vx(di,s)}function nc(s,i){return di===null&&hi(s),vx(s,i)}function vx(s,i){var h=i._currentValue;if(i={context:i,memoizedValue:h,next:null},Zr===null){if(s===null)throw Error(r(308));Zr=i,s.dependencies={lanes:0,firstContext:i},s.flags|=524288}else Zr=Zr.next=i;return h}var cE=typeof AbortController<"u"?AbortController:function(){var s=[],i=this.signal={aborted:!1,addEventListener:function(h,g){s.push(g)}};this.abort=function(){i.aborted=!0,s.forEach(function(h){return h()})}},uE=e.unstable_scheduleCallback,dE=e.unstable_NormalPriority,rn={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ch(){return{controller:new cE,data:new Map,refCount:0}}function xo(s){s.refCount--,s.refCount===0&&uE(dE,function(){s.controller.abort()})}var yo=null,uh=0,oa=0,la=null;function hE(s,i){if(yo===null){var h=yo=[];uh=0,oa=mf(),la={status:"pending",value:void 0,then:function(g){h.push(g)}}}return uh++,i.then(Sx,Sx),i}function Sx(){if(--uh===0&&yo!==null){la!==null&&(la.status="fulfilled");var s=yo;yo=null,oa=0,la=null;for(var i=0;i<s.length;i++)(0,s[i])()}}function fE(s,i){var h=[],g={status:"pending",value:null,reason:null,then:function(k){h.push(k)}};return s.then(function(){g.status="fulfilled",g.value=i;for(var k=0;k<h.length;k++)(0,h[k])(i)},function(k){for(g.status="rejected",g.reason=k,k=0;k<h.length;k++)(0,h[k])(void 0)}),g}var wx=U.S;U.S=function(s,i){a_=it(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&hE(s,i),wx!==null&&wx(s,i)};var fi=I(null);function dh(){var s=fi.current;return s!==null?s:It.pooledCache}function rc(s,i){i===null?B(fi,fi.current):B(fi,i.pool)}function Cx(){var s=dh();return s===null?null:{parent:rn._currentValue,pool:s}}var ca=Error(r(460)),hh=Error(r(474)),sc=Error(r(542)),ic={then:function(){}};function kx(s){return s=s.status,s==="fulfilled"||s==="rejected"}function Ex(s,i,h){switch(h=s[h],h===void 0?s.push(i):h!==i&&(i.then(Yr,Yr),i=h),i.status){case"fulfilled":return i.value;case"rejected":throw s=i.reason,Nx(s),s;default:if(typeof i.status=="string")i.then(Yr,Yr);else{if(s=It,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=i,s.status="pending",s.then(function(g){if(i.status==="pending"){var k=i;k.status="fulfilled",k.value=g}},function(g){if(i.status==="pending"){var k=i;k.status="rejected",k.reason=g}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw s=i.reason,Nx(s),s}throw pi=i,ca}}function mi(s){try{var i=s._init;return i(s._payload)}catch(h){throw h!==null&&typeof h=="object"&&typeof h.then=="function"?(pi=h,ca):h}}var pi=null;function jx(){if(pi===null)throw Error(r(459));var s=pi;return pi=null,s}function Nx(s){if(s===ca||s===sc)throw Error(r(483))}var ua=null,_o=0;function ac(s){var i=_o;return _o+=1,ua===null&&(ua=[]),Ex(ua,s,i)}function bo(s,i){i=i.props.ref,s.ref=i!==void 0?i:null}function oc(s,i){throw i.$$typeof===x?Error(r(525)):(s=Object.prototype.toString.call(i),Error(r(31,s==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":s)))}function Tx(s){function i(le,ae){if(s){var ue=le.deletions;ue===null?(le.deletions=[ae],le.flags|=16):ue.push(ae)}}function h(le,ae){if(!s)return null;for(;ae!==null;)i(le,ae),ae=ae.sibling;return null}function g(le){for(var ae=new Map;le!==null;)le.key!==null?ae.set(le.key,le):ae.set(le.index,le),le=le.sibling;return ae}function k(le,ae){return le=Qr(le,ae),le.index=0,le.sibling=null,le}function N(le,ae,ue){return le.index=ue,s?(ue=le.alternate,ue!==null?(ue=ue.index,ue<ae?(le.flags|=67108866,ae):ue):(le.flags|=67108866,ae)):(le.flags|=1048576,ae)}function $(le){return s&&le.alternate===null&&(le.flags|=67108866),le}function Y(le,ae,ue,Ce){return ae===null||ae.tag!==6?(ae=eh(ue,le.mode,Ce),ae.return=le,ae):(ae=k(ae,ue),ae.return=le,ae)}function ie(le,ae,ue,Ce){var Ke=ue.type;return Ke===C?Se(le,ae,ue.props.children,Ce,ue.key):ae!==null&&(ae.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===L&&mi(Ke)===ae.type)?(ae=k(ae,ue.props),bo(ae,ue),ae.return=le,ae):(ae=Zl(ue.type,ue.key,ue.props,null,le.mode,Ce),bo(ae,ue),ae.return=le,ae)}function de(le,ae,ue,Ce){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==ue.containerInfo||ae.stateNode.implementation!==ue.implementation?(ae=th(ue,le.mode,Ce),ae.return=le,ae):(ae=k(ae,ue.children||[]),ae.return=le,ae)}function Se(le,ae,ue,Ce,Ke){return ae===null||ae.tag!==7?(ae=ci(ue,le.mode,Ce,Ke),ae.return=le,ae):(ae=k(ae,ue),ae.return=le,ae)}function Ee(le,ae,ue){if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return ae=eh(""+ae,le.mode,ue),ae.return=le,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case y:return ue=Zl(ae.type,ae.key,ae.props,null,le.mode,ue),bo(ue,ae),ue.return=le,ue;case w:return ae=th(ae,le.mode,ue),ae.return=le,ae;case L:return ae=mi(ae),Ee(le,ae,ue)}if(V(ae)||W(ae))return ae=ci(ae,le.mode,ue,null),ae.return=le,ae;if(typeof ae.then=="function")return Ee(le,ac(ae),ue);if(ae.$$typeof===_)return Ee(le,nc(le,ae),ue);oc(le,ae)}return null}function fe(le,ae,ue,Ce){var Ke=ae!==null?ae.key:null;if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return Ke!==null?null:Y(le,ae,""+ue,Ce);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case y:return ue.key===Ke?ie(le,ae,ue,Ce):null;case w:return ue.key===Ke?de(le,ae,ue,Ce):null;case L:return ue=mi(ue),fe(le,ae,ue,Ce)}if(V(ue)||W(ue))return Ke!==null?null:Se(le,ae,ue,Ce,null);if(typeof ue.then=="function")return fe(le,ae,ac(ue),Ce);if(ue.$$typeof===_)return fe(le,ae,nc(le,ue),Ce);oc(le,ue)}return null}function ge(le,ae,ue,Ce,Ke){if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number"||typeof Ce=="bigint")return le=le.get(ue)||null,Y(ae,le,""+Ce,Ke);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case y:return le=le.get(Ce.key===null?ue:Ce.key)||null,ie(ae,le,Ce,Ke);case w:return le=le.get(Ce.key===null?ue:Ce.key)||null,de(ae,le,Ce,Ke);case L:return Ce=mi(Ce),ge(le,ae,ue,Ce,Ke)}if(V(Ce)||W(Ce))return le=le.get(ue)||null,Se(ae,le,Ce,Ke,null);if(typeof Ce.then=="function")return ge(le,ae,ue,ac(Ce),Ke);if(Ce.$$typeof===_)return ge(le,ae,ue,nc(ae,Ce),Ke);oc(ae,Ce)}return null}function Ue(le,ae,ue,Ce){for(var Ke=null,vt=null,Ge=ae,ut=ae=0,xt=null;Ge!==null&&ut<ue.length;ut++){Ge.index>ut?(xt=Ge,Ge=null):xt=Ge.sibling;var St=fe(le,Ge,ue[ut],Ce);if(St===null){Ge===null&&(Ge=xt);break}s&&Ge&&St.alternate===null&&i(le,Ge),ae=N(St,ae,ut),vt===null?Ke=St:vt.sibling=St,vt=St,Ge=xt}if(ut===ue.length)return h(le,Ge),_t&&Jr(le,ut),Ke;if(Ge===null){for(;ut<ue.length;ut++)Ge=Ee(le,ue[ut],Ce),Ge!==null&&(ae=N(Ge,ae,ut),vt===null?Ke=Ge:vt.sibling=Ge,vt=Ge);return _t&&Jr(le,ut),Ke}for(Ge=g(Ge);ut<ue.length;ut++)xt=ge(Ge,le,ut,ue[ut],Ce),xt!==null&&(s&&xt.alternate!==null&&Ge.delete(xt.key===null?ut:xt.key),ae=N(xt,ae,ut),vt===null?Ke=xt:vt.sibling=xt,vt=xt);return s&&Ge.forEach(function(Fs){return i(le,Fs)}),_t&&Jr(le,ut),Ke}function Je(le,ae,ue,Ce){if(ue==null)throw Error(r(151));for(var Ke=null,vt=null,Ge=ae,ut=ae=0,xt=null,St=ue.next();Ge!==null&&!St.done;ut++,St=ue.next()){Ge.index>ut?(xt=Ge,Ge=null):xt=Ge.sibling;var Fs=fe(le,Ge,St.value,Ce);if(Fs===null){Ge===null&&(Ge=xt);break}s&&Ge&&Fs.alternate===null&&i(le,Ge),ae=N(Fs,ae,ut),vt===null?Ke=Fs:vt.sibling=Fs,vt=Fs,Ge=xt}if(St.done)return h(le,Ge),_t&&Jr(le,ut),Ke;if(Ge===null){for(;!St.done;ut++,St=ue.next())St=Ee(le,St.value,Ce),St!==null&&(ae=N(St,ae,ut),vt===null?Ke=St:vt.sibling=St,vt=St);return _t&&Jr(le,ut),Ke}for(Ge=g(Ge);!St.done;ut++,St=ue.next())St=ge(Ge,le,ut,St.value,Ce),St!==null&&(s&&St.alternate!==null&&Ge.delete(St.key===null?ut:St.key),ae=N(St,ae,ut),vt===null?Ke=St:vt.sibling=St,vt=St);return s&&Ge.forEach(function(C2){return i(le,C2)}),_t&&Jr(le,ut),Ke}function Dt(le,ae,ue,Ce){if(typeof ue=="object"&&ue!==null&&ue.type===C&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case y:e:{for(var Ke=ue.key;ae!==null;){if(ae.key===Ke){if(Ke=ue.type,Ke===C){if(ae.tag===7){h(le,ae.sibling),Ce=k(ae,ue.props.children),Ce.return=le,le=Ce;break e}}else if(ae.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===L&&mi(Ke)===ae.type){h(le,ae.sibling),Ce=k(ae,ue.props),bo(Ce,ue),Ce.return=le,le=Ce;break e}h(le,ae);break}else i(le,ae);ae=ae.sibling}ue.type===C?(Ce=ci(ue.props.children,le.mode,Ce,ue.key),Ce.return=le,le=Ce):(Ce=Zl(ue.type,ue.key,ue.props,null,le.mode,Ce),bo(Ce,ue),Ce.return=le,le=Ce)}return $(le);case w:e:{for(Ke=ue.key;ae!==null;){if(ae.key===Ke)if(ae.tag===4&&ae.stateNode.containerInfo===ue.containerInfo&&ae.stateNode.implementation===ue.implementation){h(le,ae.sibling),Ce=k(ae,ue.children||[]),Ce.return=le,le=Ce;break e}else{h(le,ae);break}else i(le,ae);ae=ae.sibling}Ce=th(ue,le.mode,Ce),Ce.return=le,le=Ce}return $(le);case L:return ue=mi(ue),Dt(le,ae,ue,Ce)}if(V(ue))return Ue(le,ae,ue,Ce);if(W(ue)){if(Ke=W(ue),typeof Ke!="function")throw Error(r(150));return ue=Ke.call(ue),Je(le,ae,ue,Ce)}if(typeof ue.then=="function")return Dt(le,ae,ac(ue),Ce);if(ue.$$typeof===_)return Dt(le,ae,nc(le,ue),Ce);oc(le,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint"?(ue=""+ue,ae!==null&&ae.tag===6?(h(le,ae.sibling),Ce=k(ae,ue),Ce.return=le,le=Ce):(h(le,ae),Ce=eh(ue,le.mode,Ce),Ce.return=le,le=Ce),$(le)):h(le,ae)}return function(le,ae,ue,Ce){try{_o=0;var Ke=Dt(le,ae,ue,Ce);return ua=null,Ke}catch(Ge){if(Ge===ca||Ge===sc)throw Ge;var vt=Zn(29,Ge,null,le.mode);return vt.lanes=Ce,vt.return=le,vt}finally{}}}var gi=Tx(!0),Ax=Tx(!1),Es=!1;function fh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mh(s,i){s=s.updateQueue,i.updateQueue===s&&(i.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function js(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Ns(s,i,h){var g=s.updateQueue;if(g===null)return null;if(g=g.shared,(Ct&2)!==0){var k=g.pending;return k===null?i.next=i:(i.next=k.next,k.next=i),g.pending=i,i=Jl(s),fx(s,null,h),i}return Ql(s,g,i,h),Jl(s)}function vo(s,i,h){if(i=i.updateQueue,i!==null&&(i=i.shared,(h&4194048)!==0)){var g=i.lanes;g&=s.pendingLanes,h|=g,i.lanes=h,ze(s,h)}}function ph(s,i){var h=s.updateQueue,g=s.alternate;if(g!==null&&(g=g.updateQueue,h===g)){var k=null,N=null;if(h=h.firstBaseUpdate,h!==null){do{var $={lane:h.lane,tag:h.tag,payload:h.payload,callback:null,next:null};N===null?k=N=$:N=N.next=$,h=h.next}while(h!==null);N===null?k=N=i:N=N.next=i}else k=N=i;h={baseState:g.baseState,firstBaseUpdate:k,lastBaseUpdate:N,shared:g.shared,callbacks:g.callbacks},s.updateQueue=h;return}s=h.lastBaseUpdate,s===null?h.firstBaseUpdate=i:s.next=i,h.lastBaseUpdate=i}var gh=!1;function So(){if(gh){var s=la;if(s!==null)throw s}}function wo(s,i,h,g){gh=!1;var k=s.updateQueue;Es=!1;var N=k.firstBaseUpdate,$=k.lastBaseUpdate,Y=k.shared.pending;if(Y!==null){k.shared.pending=null;var ie=Y,de=ie.next;ie.next=null,$===null?N=de:$.next=de,$=ie;var Se=s.alternate;Se!==null&&(Se=Se.updateQueue,Y=Se.lastBaseUpdate,Y!==$&&(Y===null?Se.firstBaseUpdate=de:Y.next=de,Se.lastBaseUpdate=ie))}if(N!==null){var Ee=k.baseState;$=0,Se=de=ie=null,Y=N;do{var fe=Y.lane&-536870913,ge=fe!==Y.lane;if(ge?(gt&fe)===fe:(g&fe)===fe){fe!==0&&fe===oa&&(gh=!0),Se!==null&&(Se=Se.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var Ue=s,Je=Y;fe=i;var Dt=h;switch(Je.tag){case 1:if(Ue=Je.payload,typeof Ue=="function"){Ee=Ue.call(Dt,Ee,fe);break e}Ee=Ue;break e;case 3:Ue.flags=Ue.flags&-65537|128;case 0:if(Ue=Je.payload,fe=typeof Ue=="function"?Ue.call(Dt,Ee,fe):Ue,fe==null)break e;Ee=m({},Ee,fe);break e;case 2:Es=!0}}fe=Y.callback,fe!==null&&(s.flags|=64,ge&&(s.flags|=8192),ge=k.callbacks,ge===null?k.callbacks=[fe]:ge.push(fe))}else ge={lane:fe,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},Se===null?(de=Se=ge,ie=Ee):Se=Se.next=ge,$|=fe;if(Y=Y.next,Y===null){if(Y=k.shared.pending,Y===null)break;ge=Y,Y=ge.next,ge.next=null,k.lastBaseUpdate=ge,k.shared.pending=null}}while(!0);Se===null&&(ie=Ee),k.baseState=ie,k.firstBaseUpdate=de,k.lastBaseUpdate=Se,N===null&&(k.shared.lanes=0),Rs|=$,s.lanes=$,s.memoizedState=Ee}}function Lx(s,i){if(typeof s!="function")throw Error(r(191,s));s.call(i)}function Dx(s,i){var h=s.callbacks;if(h!==null)for(s.callbacks=null,s=0;s<h.length;s++)Lx(h[s],i)}var da=I(null),lc=I(0);function Rx(s,i){s=cs,B(lc,s),B(da,i),cs=s|i.baseLanes}function xh(){B(lc,cs),B(da,da.current)}function yh(){cs=lc.current,G(da),G(lc)}var er=I(null),gr=null;function Ts(s){var i=s.alternate;B(Qt,Qt.current&1),B(er,s),gr===null&&(i===null||da.current!==null||i.memoizedState!==null)&&(gr=s)}function _h(s){B(Qt,Qt.current),B(er,s),gr===null&&(gr=s)}function Ox(s){s.tag===22?(B(Qt,Qt.current),B(er,s),gr===null&&(gr=s)):As()}function As(){B(Qt,Qt.current),B(er,er.current)}function tr(s){G(er),gr===s&&(gr=null),G(Qt)}var Qt=I(0);function cc(s){for(var i=s;i!==null;){if(i.tag===13){var h=i.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||Ef(h)||jf(h)))return i}else if(i.tag===19&&(i.memoizedProps.revealOrder==="forwards"||i.memoizedProps.revealOrder==="backwards"||i.memoizedProps.revealOrder==="unstable_legacy-backwards"||i.memoizedProps.revealOrder==="together")){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break;for(;i.sibling===null;){if(i.return===null||i.return===s)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var ts=0,ct=null,At=null,sn=null,uc=!1,ha=!1,xi=!1,dc=0,Co=0,fa=null,mE=0;function qt(){throw Error(r(321))}function bh(s,i){if(i===null)return!1;for(var h=0;h<i.length&&h<s.length;h++)if(!Jn(s[h],i[h]))return!1;return!0}function vh(s,i,h,g,k,N){return ts=N,ct=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,U.H=s===null||s.memoizedState===null?xy:Ih,xi=!1,N=h(g,k),xi=!1,ha&&(N=Ix(i,h,g,k)),Mx(s),N}function Mx(s){U.H=jo;var i=At!==null&&At.next!==null;if(ts=0,sn=At=ct=null,uc=!1,Co=0,fa=null,i)throw Error(r(300));s===null||an||(s=s.dependencies,s!==null&&tc(s)&&(an=!0))}function Ix(s,i,h,g){ct=s;var k=0;do{if(ha&&(fa=null),Co=0,ha=!1,25<=k)throw Error(r(301));if(k+=1,sn=At=null,s.updateQueue!=null){var N=s.updateQueue;N.lastEffect=null,N.events=null,N.stores=null,N.memoCache!=null&&(N.memoCache.index=0)}U.H=yy,N=i(h,g)}while(ha);return N}function pE(){var s=U.H,i=s.useState()[0];return i=typeof i.then=="function"?ko(i):i,s=s.useState()[0],(At!==null?At.memoizedState:null)!==s&&(ct.flags|=1024),i}function Sh(){var s=dc!==0;return dc=0,s}function wh(s,i,h){i.updateQueue=s.updateQueue,i.flags&=-2053,s.lanes&=~h}function Ch(s){if(uc){for(s=s.memoizedState;s!==null;){var i=s.queue;i!==null&&(i.pending=null),s=s.next}uc=!1}ts=0,sn=At=ct=null,ha=!1,Co=dc=0,fa=null}function Dn(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return sn===null?ct.memoizedState=sn=s:sn=sn.next=s,sn}function Jt(){if(At===null){var s=ct.alternate;s=s!==null?s.memoizedState:null}else s=At.next;var i=sn===null?ct.memoizedState:sn.next;if(i!==null)sn=i,At=s;else{if(s===null)throw ct.alternate===null?Error(r(467)):Error(r(310));At=s,s={memoizedState:At.memoizedState,baseState:At.baseState,baseQueue:At.baseQueue,queue:At.queue,next:null},sn===null?ct.memoizedState=sn=s:sn=sn.next=s}return sn}function hc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ko(s){var i=Co;return Co+=1,fa===null&&(fa=[]),s=Ex(fa,s,i),i=ct,(sn===null?i.memoizedState:sn.next)===null&&(i=i.alternate,U.H=i===null||i.memoizedState===null?xy:Ih),s}function fc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return ko(s);if(s.$$typeof===_)return Sn(s)}throw Error(r(438,String(s)))}function kh(s){var i=null,h=ct.updateQueue;if(h!==null&&(i=h.memoCache),i==null){var g=ct.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(i={data:g.data.map(function(k){return k.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),h===null&&(h=hc(),ct.updateQueue=h),h.memoCache=i,h=i.data[i.index],h===void 0)for(h=i.data[i.index]=Array(s),g=0;g<s;g++)h[g]=P;return i.index++,h}function ns(s,i){return typeof i=="function"?i(s):i}function mc(s){var i=Jt();return Eh(i,At,s)}function Eh(s,i,h){var g=s.queue;if(g===null)throw Error(r(311));g.lastRenderedReducer=h;var k=s.baseQueue,N=g.pending;if(N!==null){if(k!==null){var $=k.next;k.next=N.next,N.next=$}i.baseQueue=k=N,g.pending=null}if(N=s.baseState,k===null)s.memoizedState=N;else{i=k.next;var Y=$=null,ie=null,de=i,Se=!1;do{var Ee=de.lane&-536870913;if(Ee!==de.lane?(gt&Ee)===Ee:(ts&Ee)===Ee){var fe=de.revertLane;if(fe===0)ie!==null&&(ie=ie.next={lane:0,revertLane:0,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),Ee===oa&&(Se=!0);else if((ts&fe)===fe){de=de.next,fe===oa&&(Se=!0);continue}else Ee={lane:0,revertLane:de.revertLane,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},ie===null?(Y=ie=Ee,$=N):ie=ie.next=Ee,ct.lanes|=fe,Rs|=fe;Ee=de.action,xi&&h(N,Ee),N=de.hasEagerState?de.eagerState:h(N,Ee)}else fe={lane:Ee,revertLane:de.revertLane,gesture:de.gesture,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},ie===null?(Y=ie=fe,$=N):ie=ie.next=fe,ct.lanes|=Ee,Rs|=Ee;de=de.next}while(de!==null&&de!==i);if(ie===null?$=N:ie.next=Y,!Jn(N,s.memoizedState)&&(an=!0,Se&&(h=la,h!==null)))throw h;s.memoizedState=N,s.baseState=$,s.baseQueue=ie,g.lastRenderedState=N}return k===null&&(g.lanes=0),[s.memoizedState,g.dispatch]}function jh(s){var i=Jt(),h=i.queue;if(h===null)throw Error(r(311));h.lastRenderedReducer=s;var g=h.dispatch,k=h.pending,N=i.memoizedState;if(k!==null){h.pending=null;var $=k=k.next;do N=s(N,$.action),$=$.next;while($!==k);Jn(N,i.memoizedState)||(an=!0),i.memoizedState=N,i.baseQueue===null&&(i.baseState=N),h.lastRenderedState=N}return[N,g]}function Px(s,i,h){var g=ct,k=Jt(),N=_t;if(N){if(h===void 0)throw Error(r(407));h=h()}else h=i();var $=!Jn((At||k).memoizedState,h);if($&&(k.memoizedState=h,an=!0),k=k.queue,Ah(zx.bind(null,g,k,s),[s]),k.getSnapshot!==i||$||sn!==null&&sn.memoizedState.tag&1){if(g.flags|=2048,ma(9,{destroy:void 0},$x.bind(null,g,k,h,i),null),It===null)throw Error(r(349));N||(ts&127)!==0||Bx(g,i,h)}return h}function Bx(s,i,h){s.flags|=16384,s={getSnapshot:i,value:h},i=ct.updateQueue,i===null?(i=hc(),ct.updateQueue=i,i.stores=[s]):(h=i.stores,h===null?i.stores=[s]:h.push(s))}function $x(s,i,h,g){i.value=h,i.getSnapshot=g,Hx(i)&&Ux(s)}function zx(s,i,h){return h(function(){Hx(i)&&Ux(s)})}function Hx(s){var i=s.getSnapshot;s=s.value;try{var h=i();return!Jn(s,h)}catch{return!0}}function Ux(s){var i=li(s,2);i!==null&&Un(i,s,2)}function Nh(s){var i=Dn();if(typeof s=="function"){var h=s;if(s=h(),xi){We(!0);try{h()}finally{We(!1)}}}return i.memoizedState=i.baseState=s,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:s},i}function Fx(s,i,h,g){return s.baseState=h,Eh(s,At,typeof g=="function"?g:ns)}function gE(s,i,h,g,k){if(xc(s))throw Error(r(485));if(s=i.action,s!==null){var N={payload:k,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function($){N.listeners.push($)}};U.T!==null?h(!0):N.isTransition=!1,g(N),h=i.pending,h===null?(N.next=i.pending=N,Vx(i,N)):(N.next=h.next,i.pending=h.next=N)}}function Vx(s,i){var h=i.action,g=i.payload,k=s.state;if(i.isTransition){var N=U.T,$={};U.T=$;try{var Y=h(k,g),ie=U.S;ie!==null&&ie($,Y),Gx(s,i,Y)}catch(de){Th(s,i,de)}finally{N!==null&&$.types!==null&&(N.types=$.types),U.T=N}}else try{N=h(k,g),Gx(s,i,N)}catch(de){Th(s,i,de)}}function Gx(s,i,h){h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(function(g){Wx(s,i,g)},function(g){return Th(s,i,g)}):Wx(s,i,h)}function Wx(s,i,h){i.status="fulfilled",i.value=h,qx(i),s.state=h,i=s.pending,i!==null&&(h=i.next,h===i?s.pending=null:(h=h.next,i.next=h,Vx(s,h)))}function Th(s,i,h){var g=s.pending;if(s.pending=null,g!==null){g=g.next;do i.status="rejected",i.reason=h,qx(i),i=i.next;while(i!==g)}s.action=null}function qx(s){s=s.listeners;for(var i=0;i<s.length;i++)(0,s[i])()}function Kx(s,i){return i}function Yx(s,i){if(_t){var h=It.formState;if(h!==null){e:{var g=ct;if(_t){if(Ft){t:{for(var k=Ft,N=pr;k.nodeType!==8;){if(!N){k=null;break t}if(k=xr(k.nextSibling),k===null){k=null;break t}}N=k.data,k=N==="F!"||N==="F"?k:null}if(k){Ft=xr(k.nextSibling),g=k.data==="F!";break e}}Cs(g)}g=!1}g&&(i=h[0])}}return h=Dn(),h.memoizedState=h.baseState=i,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kx,lastRenderedState:i},h.queue=g,h=my.bind(null,ct,g),g.dispatch=h,g=Nh(!1),N=Mh.bind(null,ct,!1,g.queue),g=Dn(),k={state:i,dispatch:null,action:s,pending:null},g.queue=k,h=gE.bind(null,ct,k,N,h),k.dispatch=h,g.memoizedState=s,[i,h,!1]}function Xx(s){var i=Jt();return Qx(i,At,s)}function Qx(s,i,h){if(i=Eh(s,i,Kx)[0],s=mc(ns)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var g=ko(i)}catch($){throw $===ca?sc:$}else g=i;i=Jt();var k=i.queue,N=k.dispatch;return h!==i.memoizedState&&(ct.flags|=2048,ma(9,{destroy:void 0},xE.bind(null,k,h),null)),[g,N,s]}function xE(s,i){s.action=i}function Jx(s){var i=Jt(),h=At;if(h!==null)return Qx(i,h,s);Jt(),i=i.memoizedState,h=Jt();var g=h.queue.dispatch;return h.memoizedState=s,[i,g,!1]}function ma(s,i,h,g){return s={tag:s,create:h,deps:g,inst:i,next:null},i=ct.updateQueue,i===null&&(i=hc(),ct.updateQueue=i),h=i.lastEffect,h===null?i.lastEffect=s.next=s:(g=h.next,h.next=s,s.next=g,i.lastEffect=s),s}function Zx(){return Jt().memoizedState}function pc(s,i,h,g){var k=Dn();ct.flags|=s,k.memoizedState=ma(1|i,{destroy:void 0},h,g===void 0?null:g)}function gc(s,i,h,g){var k=Jt();g=g===void 0?null:g;var N=k.memoizedState.inst;At!==null&&g!==null&&bh(g,At.memoizedState.deps)?k.memoizedState=ma(i,N,h,g):(ct.flags|=s,k.memoizedState=ma(1|i,N,h,g))}function ey(s,i){pc(8390656,8,s,i)}function Ah(s,i){gc(2048,8,s,i)}function yE(s){ct.flags|=4;var i=ct.updateQueue;if(i===null)i=hc(),ct.updateQueue=i,i.events=[s];else{var h=i.events;h===null?i.events=[s]:h.push(s)}}function ty(s){var i=Jt().memoizedState;return yE({ref:i,nextImpl:s}),function(){if((Ct&2)!==0)throw Error(r(440));return i.impl.apply(void 0,arguments)}}function ny(s,i){return gc(4,2,s,i)}function ry(s,i){return gc(4,4,s,i)}function sy(s,i){if(typeof i=="function"){s=s();var h=i(s);return function(){typeof h=="function"?h():i(null)}}if(i!=null)return s=s(),i.current=s,function(){i.current=null}}function iy(s,i,h){h=h!=null?h.concat([s]):null,gc(4,4,sy.bind(null,i,s),h)}function Lh(){}function ay(s,i){var h=Jt();i=i===void 0?null:i;var g=h.memoizedState;return i!==null&&bh(i,g[1])?g[0]:(h.memoizedState=[s,i],s)}function oy(s,i){var h=Jt();i=i===void 0?null:i;var g=h.memoizedState;if(i!==null&&bh(i,g[1]))return g[0];if(g=s(),xi){We(!0);try{s()}finally{We(!1)}}return h.memoizedState=[g,i],g}function Dh(s,i,h){return h===void 0||(ts&1073741824)!==0&&(gt&261930)===0?s.memoizedState=i:(s.memoizedState=h,s=l_(),ct.lanes|=s,Rs|=s,h)}function ly(s,i,h,g){return Jn(h,i)?h:da.current!==null?(s=Dh(s,h,g),Jn(s,i)||(an=!0),s):(ts&42)===0||(ts&1073741824)!==0&&(gt&261930)===0?(an=!0,s.memoizedState=h):(s=l_(),ct.lanes|=s,Rs|=s,i)}function cy(s,i,h,g,k){var N=Q.p;Q.p=N!==0&&8>N?N:8;var $=U.T,Y={};U.T=Y,Mh(s,!1,i,h);try{var ie=k(),de=U.S;if(de!==null&&de(Y,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var Se=fE(ie,g);Eo(s,i,Se,sr(s))}else Eo(s,i,g,sr(s))}catch(Ee){Eo(s,i,{then:function(){},status:"rejected",reason:Ee},sr())}finally{Q.p=N,$!==null&&Y.types!==null&&($.types=Y.types),U.T=$}}function _E(){}function Rh(s,i,h,g){if(s.tag!==5)throw Error(r(476));var k=uy(s).queue;cy(s,k,i,X,h===null?_E:function(){return dy(s),h(g)})}function uy(s){var i=s.memoizedState;if(i!==null)return i;i={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:X},next:null};var h={};return i.next={memoizedState:h,baseState:h,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:h},next:null},s.memoizedState=i,s=s.alternate,s!==null&&(s.memoizedState=i),i}function dy(s){var i=uy(s);i.next===null&&(i=s.alternate.memoizedState),Eo(s,i.next.queue,{},sr())}function Oh(){return Sn(Fo)}function hy(){return Jt().memoizedState}function fy(){return Jt().memoizedState}function bE(s){for(var i=s.return;i!==null;){switch(i.tag){case 24:case 3:var h=sr();s=js(h);var g=Ns(i,s,h);g!==null&&(Un(g,i,h),vo(g,i,h)),i={cache:ch()},s.payload=i;return}i=i.return}}function vE(s,i,h){var g=sr();h={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},xc(s)?py(i,h):(h=Jd(s,i,h,g),h!==null&&(Un(h,s,g),gy(h,i,g)))}function my(s,i,h){var g=sr();Eo(s,i,h,g)}function Eo(s,i,h,g){var k={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null};if(xc(s))py(i,k);else{var N=s.alternate;if(s.lanes===0&&(N===null||N.lanes===0)&&(N=i.lastRenderedReducer,N!==null))try{var $=i.lastRenderedState,Y=N($,h);if(k.hasEagerState=!0,k.eagerState=Y,Jn(Y,$))return Ql(s,i,k,0),It===null&&Xl(),!1}catch{}finally{}if(h=Jd(s,i,k,g),h!==null)return Un(h,s,g),gy(h,i,g),!0}return!1}function Mh(s,i,h,g){if(g={lane:2,revertLane:mf(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},xc(s)){if(i)throw Error(r(479))}else i=Jd(s,h,g,2),i!==null&&Un(i,s,2)}function xc(s){var i=s.alternate;return s===ct||i!==null&&i===ct}function py(s,i){ha=uc=!0;var h=s.pending;h===null?i.next=i:(i.next=h.next,h.next=i),s.pending=i}function gy(s,i,h){if((h&4194048)!==0){var g=i.lanes;g&=s.pendingLanes,h|=g,i.lanes=h,ze(s,h)}}var jo={readContext:Sn,use:fc,useCallback:qt,useContext:qt,useEffect:qt,useImperativeHandle:qt,useLayoutEffect:qt,useInsertionEffect:qt,useMemo:qt,useReducer:qt,useRef:qt,useState:qt,useDebugValue:qt,useDeferredValue:qt,useTransition:qt,useSyncExternalStore:qt,useId:qt,useHostTransitionStatus:qt,useFormState:qt,useActionState:qt,useOptimistic:qt,useMemoCache:qt,useCacheRefresh:qt};jo.useEffectEvent=qt;var xy={readContext:Sn,use:fc,useCallback:function(s,i){return Dn().memoizedState=[s,i===void 0?null:i],s},useContext:Sn,useEffect:ey,useImperativeHandle:function(s,i,h){h=h!=null?h.concat([s]):null,pc(4194308,4,sy.bind(null,i,s),h)},useLayoutEffect:function(s,i){return pc(4194308,4,s,i)},useInsertionEffect:function(s,i){pc(4,2,s,i)},useMemo:function(s,i){var h=Dn();i=i===void 0?null:i;var g=s();if(xi){We(!0);try{s()}finally{We(!1)}}return h.memoizedState=[g,i],g},useReducer:function(s,i,h){var g=Dn();if(h!==void 0){var k=h(i);if(xi){We(!0);try{h(i)}finally{We(!1)}}}else k=i;return g.memoizedState=g.baseState=k,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:k},g.queue=s,s=s.dispatch=vE.bind(null,ct,s),[g.memoizedState,s]},useRef:function(s){var i=Dn();return s={current:s},i.memoizedState=s},useState:function(s){s=Nh(s);var i=s.queue,h=my.bind(null,ct,i);return i.dispatch=h,[s.memoizedState,h]},useDebugValue:Lh,useDeferredValue:function(s,i){var h=Dn();return Dh(h,s,i)},useTransition:function(){var s=Nh(!1);return s=cy.bind(null,ct,s.queue,!0,!1),Dn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,i,h){var g=ct,k=Dn();if(_t){if(h===void 0)throw Error(r(407));h=h()}else{if(h=i(),It===null)throw Error(r(349));(gt&127)!==0||Bx(g,i,h)}k.memoizedState=h;var N={value:h,getSnapshot:i};return k.queue=N,ey(zx.bind(null,g,N,s),[s]),g.flags|=2048,ma(9,{destroy:void 0},$x.bind(null,g,N,h,i),null),h},useId:function(){var s=Dn(),i=It.identifierPrefix;if(_t){var h=Ir,g=Mr;h=(g&~(1<<32-et(g)-1)).toString(32)+h,i="_"+i+"R_"+h,h=dc++,0<h&&(i+="H"+h.toString(32)),i+="_"}else h=mE++,i="_"+i+"r_"+h.toString(32)+"_";return s.memoizedState=i},useHostTransitionStatus:Oh,useFormState:Yx,useActionState:Yx,useOptimistic:function(s){var i=Dn();i.memoizedState=i.baseState=s;var h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=h,i=Mh.bind(null,ct,!0,h),h.dispatch=i,[s,i]},useMemoCache:kh,useCacheRefresh:function(){return Dn().memoizedState=bE.bind(null,ct)},useEffectEvent:function(s){var i=Dn(),h={impl:s};return i.memoizedState=h,function(){if((Ct&2)!==0)throw Error(r(440));return h.impl.apply(void 0,arguments)}}},Ih={readContext:Sn,use:fc,useCallback:ay,useContext:Sn,useEffect:Ah,useImperativeHandle:iy,useInsertionEffect:ny,useLayoutEffect:ry,useMemo:oy,useReducer:mc,useRef:Zx,useState:function(){return mc(ns)},useDebugValue:Lh,useDeferredValue:function(s,i){var h=Jt();return ly(h,At.memoizedState,s,i)},useTransition:function(){var s=mc(ns)[0],i=Jt().memoizedState;return[typeof s=="boolean"?s:ko(s),i]},useSyncExternalStore:Px,useId:hy,useHostTransitionStatus:Oh,useFormState:Xx,useActionState:Xx,useOptimistic:function(s,i){var h=Jt();return Fx(h,At,s,i)},useMemoCache:kh,useCacheRefresh:fy};Ih.useEffectEvent=ty;var yy={readContext:Sn,use:fc,useCallback:ay,useContext:Sn,useEffect:Ah,useImperativeHandle:iy,useInsertionEffect:ny,useLayoutEffect:ry,useMemo:oy,useReducer:jh,useRef:Zx,useState:function(){return jh(ns)},useDebugValue:Lh,useDeferredValue:function(s,i){var h=Jt();return At===null?Dh(h,s,i):ly(h,At.memoizedState,s,i)},useTransition:function(){var s=jh(ns)[0],i=Jt().memoizedState;return[typeof s=="boolean"?s:ko(s),i]},useSyncExternalStore:Px,useId:hy,useHostTransitionStatus:Oh,useFormState:Jx,useActionState:Jx,useOptimistic:function(s,i){var h=Jt();return At!==null?Fx(h,At,s,i):(h.baseState=s,[s,h.queue.dispatch])},useMemoCache:kh,useCacheRefresh:fy};yy.useEffectEvent=ty;function Ph(s,i,h,g){i=s.memoizedState,h=h(g,i),h=h==null?i:m({},i,h),s.memoizedState=h,s.lanes===0&&(s.updateQueue.baseState=h)}var Bh={enqueueSetState:function(s,i,h){s=s._reactInternals;var g=sr(),k=js(g);k.payload=i,h!=null&&(k.callback=h),i=Ns(s,k,g),i!==null&&(Un(i,s,g),vo(i,s,g))},enqueueReplaceState:function(s,i,h){s=s._reactInternals;var g=sr(),k=js(g);k.tag=1,k.payload=i,h!=null&&(k.callback=h),i=Ns(s,k,g),i!==null&&(Un(i,s,g),vo(i,s,g))},enqueueForceUpdate:function(s,i){s=s._reactInternals;var h=sr(),g=js(h);g.tag=2,i!=null&&(g.callback=i),i=Ns(s,g,h),i!==null&&(Un(i,s,h),vo(i,s,h))}};function _y(s,i,h,g,k,N,$){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(g,N,$):i.prototype&&i.prototype.isPureReactComponent?!fo(h,g)||!fo(k,N):!0}function by(s,i,h,g){s=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(h,g),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(h,g),i.state!==s&&Bh.enqueueReplaceState(i,i.state,null)}function yi(s,i){var h=i;if("ref"in i){h={};for(var g in i)g!=="ref"&&(h[g]=i[g])}if(s=s.defaultProps){h===i&&(h=m({},h));for(var k in s)h[k]===void 0&&(h[k]=s[k])}return h}function vy(s){Yl(s)}function Sy(s){console.error(s)}function wy(s){Yl(s)}function yc(s,i){try{var h=s.onUncaughtError;h(i.value,{componentStack:i.stack})}catch(g){setTimeout(function(){throw g})}}function Cy(s,i,h){try{var g=s.onCaughtError;g(h.value,{componentStack:h.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(k){setTimeout(function(){throw k})}}function $h(s,i,h){return h=js(h),h.tag=3,h.payload={element:null},h.callback=function(){yc(s,i)},h}function ky(s){return s=js(s),s.tag=3,s}function Ey(s,i,h,g){var k=h.type.getDerivedStateFromError;if(typeof k=="function"){var N=g.value;s.payload=function(){return k(N)},s.callback=function(){Cy(i,h,g)}}var $=h.stateNode;$!==null&&typeof $.componentDidCatch=="function"&&(s.callback=function(){Cy(i,h,g),typeof k!="function"&&(Os===null?Os=new Set([this]):Os.add(this));var Y=g.stack;this.componentDidCatch(g.value,{componentStack:Y!==null?Y:""})})}function SE(s,i,h,g,k){if(h.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(i=h.alternate,i!==null&&aa(i,h,k,!0),h=er.current,h!==null){switch(h.tag){case 31:case 13:return gr===null?Ac():h.alternate===null&&Kt===0&&(Kt=3),h.flags&=-257,h.flags|=65536,h.lanes=k,g===ic?h.flags|=16384:(i=h.updateQueue,i===null?h.updateQueue=new Set([g]):i.add(g),df(s,g,k)),!1;case 22:return h.flags|=65536,g===ic?h.flags|=16384:(i=h.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([g])},h.updateQueue=i):(h=i.retryQueue,h===null?i.retryQueue=new Set([g]):h.add(g)),df(s,g,k)),!1}throw Error(r(435,h.tag))}return df(s,g,k),Ac(),!1}if(_t)return i=er.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=k,g!==sh&&(s=Error(r(422),{cause:g}),go(hr(s,h)))):(g!==sh&&(i=Error(r(423),{cause:g}),go(hr(i,h))),s=s.current.alternate,s.flags|=65536,k&=-k,s.lanes|=k,g=hr(g,h),k=$h(s.stateNode,g,k),ph(s,k),Kt!==4&&(Kt=2)),!1;var N=Error(r(520),{cause:g});if(N=hr(N,h),Mo===null?Mo=[N]:Mo.push(N),Kt!==4&&(Kt=2),i===null)return!0;g=hr(g,h),h=i;do{switch(h.tag){case 3:return h.flags|=65536,s=k&-k,h.lanes|=s,s=$h(h.stateNode,g,s),ph(h,s),!1;case 1:if(i=h.type,N=h.stateNode,(h.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||N!==null&&typeof N.componentDidCatch=="function"&&(Os===null||!Os.has(N))))return h.flags|=65536,k&=-k,h.lanes|=k,k=ky(k),Ey(k,s,h,g),ph(h,k),!1}h=h.return}while(h!==null);return!1}var zh=Error(r(461)),an=!1;function wn(s,i,h,g){i.child=s===null?Ax(i,null,h,g):gi(i,s.child,h,g)}function jy(s,i,h,g,k){h=h.render;var N=i.ref;if("ref"in g){var $={};for(var Y in g)Y!=="ref"&&($[Y]=g[Y])}else $=g;return hi(i),g=vh(s,i,h,$,N,k),Y=Sh(),s!==null&&!an?(wh(s,i,k),rs(s,i,k)):(_t&&Y&&nh(i),i.flags|=1,wn(s,i,g,k),i.child)}function Ny(s,i,h,g,k){if(s===null){var N=h.type;return typeof N=="function"&&!Zd(N)&&N.defaultProps===void 0&&h.compare===null?(i.tag=15,i.type=N,Ty(s,i,N,g,k)):(s=Zl(h.type,null,g,i,i.mode,k),s.ref=i.ref,s.return=i,i.child=s)}if(N=s.child,!Kh(s,k)){var $=N.memoizedProps;if(h=h.compare,h=h!==null?h:fo,h($,g)&&s.ref===i.ref)return rs(s,i,k)}return i.flags|=1,s=Qr(N,g),s.ref=i.ref,s.return=i,i.child=s}function Ty(s,i,h,g,k){if(s!==null){var N=s.memoizedProps;if(fo(N,g)&&s.ref===i.ref)if(an=!1,i.pendingProps=g=N,Kh(s,k))(s.flags&131072)!==0&&(an=!0);else return i.lanes=s.lanes,rs(s,i,k)}return Hh(s,i,h,g,k)}function Ay(s,i,h,g){var k=g.children,N=s!==null?s.memoizedState:null;if(s===null&&i.stateNode===null&&(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((i.flags&128)!==0){if(N=N!==null?N.baseLanes|h:h,s!==null){for(g=i.child=s.child,k=0;g!==null;)k=k|g.lanes|g.childLanes,g=g.sibling;g=k&~N}else g=0,i.child=null;return Ly(s,i,N,h,g)}if((h&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},s!==null&&rc(i,N!==null?N.cachePool:null),N!==null?Rx(i,N):xh(),Ox(i);else return g=i.lanes=536870912,Ly(s,i,N!==null?N.baseLanes|h:h,h,g)}else N!==null?(rc(i,N.cachePool),Rx(i,N),As(),i.memoizedState=null):(s!==null&&rc(i,null),xh(),As());return wn(s,i,k,h),i.child}function No(s,i){return s!==null&&s.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function Ly(s,i,h,g,k){var N=dh();return N=N===null?null:{parent:rn._currentValue,pool:N},i.memoizedState={baseLanes:h,cachePool:N},s!==null&&rc(i,null),xh(),Ox(i),s!==null&&aa(s,i,g,!0),i.childLanes=k,null}function _c(s,i){return i=vc({mode:i.mode,children:i.children},s.mode),i.ref=s.ref,s.child=i,i.return=s,i}function Dy(s,i,h){return gi(i,s.child,null,h),s=_c(i,i.pendingProps),s.flags|=2,tr(i),i.memoizedState=null,s}function wE(s,i,h){var g=i.pendingProps,k=(i.flags&128)!==0;if(i.flags&=-129,s===null){if(_t){if(g.mode==="hidden")return s=_c(i,g),i.lanes=536870912,No(null,s);if(_h(i),(s=Ft)?(s=V_(s,pr),s=s!==null&&s.data==="&"?s:null,s!==null&&(i.memoizedState={dehydrated:s,treeContext:Ss!==null?{id:Mr,overflow:Ir}:null,retryLane:536870912,hydrationErrors:null},h=px(s),h.return=i,i.child=h,vn=i,Ft=null)):s=null,s===null)throw Cs(i);return i.lanes=536870912,null}return _c(i,g)}var N=s.memoizedState;if(N!==null){var $=N.dehydrated;if(_h(i),k)if(i.flags&256)i.flags&=-257,i=Dy(s,i,h);else if(i.memoizedState!==null)i.child=s.child,i.flags|=128,i=null;else throw Error(r(558));else if(an||aa(s,i,h,!1),k=(h&s.childLanes)!==0,an||k){if(g=It,g!==null&&($=qe(g,h),$!==0&&$!==N.retryLane))throw N.retryLane=$,li(s,$),Un(g,s,$),zh;Ac(),i=Dy(s,i,h)}else s=N.treeContext,Ft=xr($.nextSibling),vn=i,_t=!0,ws=null,pr=!1,s!==null&&yx(i,s),i=_c(i,g),i.flags|=4096;return i}return s=Qr(s.child,{mode:g.mode,children:g.children}),s.ref=i.ref,i.child=s,s.return=i,s}function bc(s,i){var h=i.ref;if(h===null)s!==null&&s.ref!==null&&(i.flags|=4194816);else{if(typeof h!="function"&&typeof h!="object")throw Error(r(284));(s===null||s.ref!==h)&&(i.flags|=4194816)}}function Hh(s,i,h,g,k){return hi(i),h=vh(s,i,h,g,void 0,k),g=Sh(),s!==null&&!an?(wh(s,i,k),rs(s,i,k)):(_t&&g&&nh(i),i.flags|=1,wn(s,i,h,k),i.child)}function Ry(s,i,h,g,k,N){return hi(i),i.updateQueue=null,h=Ix(i,g,h,k),Mx(s),g=Sh(),s!==null&&!an?(wh(s,i,N),rs(s,i,N)):(_t&&g&&nh(i),i.flags|=1,wn(s,i,h,N),i.child)}function Oy(s,i,h,g,k){if(hi(i),i.stateNode===null){var N=na,$=h.contextType;typeof $=="object"&&$!==null&&(N=Sn($)),N=new h(g,N),i.memoizedState=N.state!==null&&N.state!==void 0?N.state:null,N.updater=Bh,i.stateNode=N,N._reactInternals=i,N=i.stateNode,N.props=g,N.state=i.memoizedState,N.refs={},fh(i),$=h.contextType,N.context=typeof $=="object"&&$!==null?Sn($):na,N.state=i.memoizedState,$=h.getDerivedStateFromProps,typeof $=="function"&&(Ph(i,h,$,g),N.state=i.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof N.getSnapshotBeforeUpdate=="function"||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||($=N.state,typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount(),$!==N.state&&Bh.enqueueReplaceState(N,N.state,null),wo(i,g,N,k),So(),N.state=i.memoizedState),typeof N.componentDidMount=="function"&&(i.flags|=4194308),g=!0}else if(s===null){N=i.stateNode;var Y=i.memoizedProps,ie=yi(h,Y);N.props=ie;var de=N.context,Se=h.contextType;$=na,typeof Se=="object"&&Se!==null&&($=Sn(Se));var Ee=h.getDerivedStateFromProps;Se=typeof Ee=="function"||typeof N.getSnapshotBeforeUpdate=="function",Y=i.pendingProps!==Y,Se||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||(Y||de!==$)&&by(i,N,g,$),Es=!1;var fe=i.memoizedState;N.state=fe,wo(i,g,N,k),So(),de=i.memoizedState,Y||fe!==de||Es?(typeof Ee=="function"&&(Ph(i,h,Ee,g),de=i.memoizedState),(ie=Es||_y(i,h,ie,g,fe,de,$))?(Se||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount()),typeof N.componentDidMount=="function"&&(i.flags|=4194308)):(typeof N.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=g,i.memoizedState=de),N.props=g,N.state=de,N.context=$,g=ie):(typeof N.componentDidMount=="function"&&(i.flags|=4194308),g=!1)}else{N=i.stateNode,mh(s,i),$=i.memoizedProps,Se=yi(h,$),N.props=Se,Ee=i.pendingProps,fe=N.context,de=h.contextType,ie=na,typeof de=="object"&&de!==null&&(ie=Sn(de)),Y=h.getDerivedStateFromProps,(de=typeof Y=="function"||typeof N.getSnapshotBeforeUpdate=="function")||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||($!==Ee||fe!==ie)&&by(i,N,g,ie),Es=!1,fe=i.memoizedState,N.state=fe,wo(i,g,N,k),So();var ge=i.memoizedState;$!==Ee||fe!==ge||Es||s!==null&&s.dependencies!==null&&tc(s.dependencies)?(typeof Y=="function"&&(Ph(i,h,Y,g),ge=i.memoizedState),(Se=Es||_y(i,h,Se,g,fe,ge,ie)||s!==null&&s.dependencies!==null&&tc(s.dependencies))?(de||typeof N.UNSAFE_componentWillUpdate!="function"&&typeof N.componentWillUpdate!="function"||(typeof N.componentWillUpdate=="function"&&N.componentWillUpdate(g,ge,ie),typeof N.UNSAFE_componentWillUpdate=="function"&&N.UNSAFE_componentWillUpdate(g,ge,ie)),typeof N.componentDidUpdate=="function"&&(i.flags|=4),typeof N.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof N.componentDidUpdate!="function"||$===s.memoizedProps&&fe===s.memoizedState||(i.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||$===s.memoizedProps&&fe===s.memoizedState||(i.flags|=1024),i.memoizedProps=g,i.memoizedState=ge),N.props=g,N.state=ge,N.context=ie,g=Se):(typeof N.componentDidUpdate!="function"||$===s.memoizedProps&&fe===s.memoizedState||(i.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||$===s.memoizedProps&&fe===s.memoizedState||(i.flags|=1024),g=!1)}return N=g,bc(s,i),g=(i.flags&128)!==0,N||g?(N=i.stateNode,h=g&&typeof h.getDerivedStateFromError!="function"?null:N.render(),i.flags|=1,s!==null&&g?(i.child=gi(i,s.child,null,k),i.child=gi(i,null,h,k)):wn(s,i,h,k),i.memoizedState=N.state,s=i.child):s=rs(s,i,k),s}function My(s,i,h,g){return ui(),i.flags|=256,wn(s,i,h,g),i.child}var Uh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Fh(s){return{baseLanes:s,cachePool:Cx()}}function Vh(s,i,h){return s=s!==null?s.childLanes&~h:0,i&&(s|=rr),s}function Iy(s,i,h){var g=i.pendingProps,k=!1,N=(i.flags&128)!==0,$;if(($=N)||($=s!==null&&s.memoizedState===null?!1:(Qt.current&2)!==0),$&&(k=!0,i.flags&=-129),$=(i.flags&32)!==0,i.flags&=-33,s===null){if(_t){if(k?Ts(i):As(),(s=Ft)?(s=V_(s,pr),s=s!==null&&s.data!=="&"?s:null,s!==null&&(i.memoizedState={dehydrated:s,treeContext:Ss!==null?{id:Mr,overflow:Ir}:null,retryLane:536870912,hydrationErrors:null},h=px(s),h.return=i,i.child=h,vn=i,Ft=null)):s=null,s===null)throw Cs(i);return jf(s)?i.lanes=32:i.lanes=536870912,null}var Y=g.children;return g=g.fallback,k?(As(),k=i.mode,Y=vc({mode:"hidden",children:Y},k),g=ci(g,k,h,null),Y.return=i,g.return=i,Y.sibling=g,i.child=Y,g=i.child,g.memoizedState=Fh(h),g.childLanes=Vh(s,$,h),i.memoizedState=Uh,No(null,g)):(Ts(i),Gh(i,Y))}var ie=s.memoizedState;if(ie!==null&&(Y=ie.dehydrated,Y!==null)){if(N)i.flags&256?(Ts(i),i.flags&=-257,i=Wh(s,i,h)):i.memoizedState!==null?(As(),i.child=s.child,i.flags|=128,i=null):(As(),Y=g.fallback,k=i.mode,g=vc({mode:"visible",children:g.children},k),Y=ci(Y,k,h,null),Y.flags|=2,g.return=i,Y.return=i,g.sibling=Y,i.child=g,gi(i,s.child,null,h),g=i.child,g.memoizedState=Fh(h),g.childLanes=Vh(s,$,h),i.memoizedState=Uh,i=No(null,g));else if(Ts(i),jf(Y)){if($=Y.nextSibling&&Y.nextSibling.dataset,$)var de=$.dgst;$=de,g=Error(r(419)),g.stack="",g.digest=$,go({value:g,source:null,stack:null}),i=Wh(s,i,h)}else if(an||aa(s,i,h,!1),$=(h&s.childLanes)!==0,an||$){if($=It,$!==null&&(g=qe($,h),g!==0&&g!==ie.retryLane))throw ie.retryLane=g,li(s,g),Un($,s,g),zh;Ef(Y)||Ac(),i=Wh(s,i,h)}else Ef(Y)?(i.flags|=192,i.child=s.child,i=null):(s=ie.treeContext,Ft=xr(Y.nextSibling),vn=i,_t=!0,ws=null,pr=!1,s!==null&&yx(i,s),i=Gh(i,g.children),i.flags|=4096);return i}return k?(As(),Y=g.fallback,k=i.mode,ie=s.child,de=ie.sibling,g=Qr(ie,{mode:"hidden",children:g.children}),g.subtreeFlags=ie.subtreeFlags&65011712,de!==null?Y=Qr(de,Y):(Y=ci(Y,k,h,null),Y.flags|=2),Y.return=i,g.return=i,g.sibling=Y,i.child=g,No(null,g),g=i.child,Y=s.child.memoizedState,Y===null?Y=Fh(h):(k=Y.cachePool,k!==null?(ie=rn._currentValue,k=k.parent!==ie?{parent:ie,pool:ie}:k):k=Cx(),Y={baseLanes:Y.baseLanes|h,cachePool:k}),g.memoizedState=Y,g.childLanes=Vh(s,$,h),i.memoizedState=Uh,No(s.child,g)):(Ts(i),h=s.child,s=h.sibling,h=Qr(h,{mode:"visible",children:g.children}),h.return=i,h.sibling=null,s!==null&&($=i.deletions,$===null?(i.deletions=[s],i.flags|=16):$.push(s)),i.child=h,i.memoizedState=null,h)}function Gh(s,i){return i=vc({mode:"visible",children:i},s.mode),i.return=s,s.child=i}function vc(s,i){return s=Zn(22,s,null,i),s.lanes=0,s}function Wh(s,i,h){return gi(i,s.child,null,h),s=Gh(i,i.pendingProps.children),s.flags|=2,i.memoizedState=null,s}function Py(s,i,h){s.lanes|=i;var g=s.alternate;g!==null&&(g.lanes|=i),oh(s.return,i,h)}function qh(s,i,h,g,k,N){var $=s.memoizedState;$===null?s.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:g,tail:h,tailMode:k,treeForkCount:N}:($.isBackwards=i,$.rendering=null,$.renderingStartTime=0,$.last=g,$.tail=h,$.tailMode=k,$.treeForkCount=N)}function By(s,i,h){var g=i.pendingProps,k=g.revealOrder,N=g.tail;g=g.children;var $=Qt.current,Y=($&2)!==0;if(Y?($=$&1|2,i.flags|=128):$&=1,B(Qt,$),wn(s,i,g,h),g=_t?po:0,!Y&&s!==null&&(s.flags&128)!==0)e:for(s=i.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Py(s,h,i);else if(s.tag===19)Py(s,h,i);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(k){case"forwards":for(h=i.child,k=null;h!==null;)s=h.alternate,s!==null&&cc(s)===null&&(k=h),h=h.sibling;h=k,h===null?(k=i.child,i.child=null):(k=h.sibling,h.sibling=null),qh(i,!1,k,h,N,g);break;case"backwards":case"unstable_legacy-backwards":for(h=null,k=i.child,i.child=null;k!==null;){if(s=k.alternate,s!==null&&cc(s)===null){i.child=k;break}s=k.sibling,k.sibling=h,h=k,k=s}qh(i,!0,h,null,N,g);break;case"together":qh(i,!1,null,null,void 0,g);break;default:i.memoizedState=null}return i.child}function rs(s,i,h){if(s!==null&&(i.dependencies=s.dependencies),Rs|=i.lanes,(h&i.childLanes)===0)if(s!==null){if(aa(s,i,h,!1),(h&i.childLanes)===0)return null}else return null;if(s!==null&&i.child!==s.child)throw Error(r(153));if(i.child!==null){for(s=i.child,h=Qr(s,s.pendingProps),i.child=h,h.return=i;s.sibling!==null;)s=s.sibling,h=h.sibling=Qr(s,s.pendingProps),h.return=i;h.sibling=null}return i.child}function Kh(s,i){return(s.lanes&i)!==0?!0:(s=s.dependencies,!!(s!==null&&tc(s)))}function CE(s,i,h){switch(i.tag){case 3:F(i,i.stateNode.containerInfo),ks(i,rn,s.memoizedState.cache),ui();break;case 27:case 5:re(i);break;case 4:F(i,i.stateNode.containerInfo);break;case 10:ks(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,_h(i),null;break;case 13:var g=i.memoizedState;if(g!==null)return g.dehydrated!==null?(Ts(i),i.flags|=128,null):(h&i.child.childLanes)!==0?Iy(s,i,h):(Ts(i),s=rs(s,i,h),s!==null?s.sibling:null);Ts(i);break;case 19:var k=(s.flags&128)!==0;if(g=(h&i.childLanes)!==0,g||(aa(s,i,h,!1),g=(h&i.childLanes)!==0),k){if(g)return By(s,i,h);i.flags|=128}if(k=i.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),B(Qt,Qt.current),g)break;return null;case 22:return i.lanes=0,Ay(s,i,h,i.pendingProps);case 24:ks(i,rn,s.memoizedState.cache)}return rs(s,i,h)}function $y(s,i,h){if(s!==null)if(s.memoizedProps!==i.pendingProps)an=!0;else{if(!Kh(s,h)&&(i.flags&128)===0)return an=!1,CE(s,i,h);an=(s.flags&131072)!==0}else an=!1,_t&&(i.flags&1048576)!==0&&xx(i,po,i.index);switch(i.lanes=0,i.tag){case 16:e:{var g=i.pendingProps;if(s=mi(i.elementType),i.type=s,typeof s=="function")Zd(s)?(g=yi(s,g),i.tag=1,i=Oy(null,i,s,g,h)):(i.tag=0,i=Hh(null,i,s,g,h));else{if(s!=null){var k=s.$$typeof;if(k===j){i.tag=11,i=jy(null,i,s,g,h);break e}else if(k===D){i.tag=14,i=Ny(null,i,s,g,h);break e}}throw i=H(s)||s,Error(r(306,i,""))}}return i;case 0:return Hh(s,i,i.type,i.pendingProps,h);case 1:return g=i.type,k=yi(g,i.pendingProps),Oy(s,i,g,k,h);case 3:e:{if(F(i,i.stateNode.containerInfo),s===null)throw Error(r(387));g=i.pendingProps;var N=i.memoizedState;k=N.element,mh(s,i),wo(i,g,null,h);var $=i.memoizedState;if(g=$.cache,ks(i,rn,g),g!==N.cache&&lh(i,[rn],h,!0),So(),g=$.element,N.isDehydrated)if(N={element:g,isDehydrated:!1,cache:$.cache},i.updateQueue.baseState=N,i.memoizedState=N,i.flags&256){i=My(s,i,g,h);break e}else if(g!==k){k=hr(Error(r(424)),i),go(k),i=My(s,i,g,h);break e}else{switch(s=i.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(Ft=xr(s.firstChild),vn=i,_t=!0,ws=null,pr=!0,h=Ax(i,null,g,h),i.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling}else{if(ui(),g===k){i=rs(s,i,h);break e}wn(s,i,g,h)}i=i.child}return i;case 26:return bc(s,i),s===null?(h=X_(i.type,null,i.pendingProps,null))?i.memoizedState=h:_t||(h=i.type,s=i.pendingProps,g=Pc(ne.current).createElement(h),g[jt]=i,g[In]=s,Cn(g,h,s),gn(g),i.stateNode=g):i.memoizedState=X_(i.type,s.memoizedProps,i.pendingProps,s.memoizedState),null;case 27:return re(i),s===null&&_t&&(g=i.stateNode=q_(i.type,i.pendingProps,ne.current),vn=i,pr=!0,k=Ft,Bs(i.type)?(Nf=k,Ft=xr(g.firstChild)):Ft=k),wn(s,i,i.pendingProps.children,h),bc(s,i),s===null&&(i.flags|=4194304),i.child;case 5:return s===null&&_t&&((k=g=Ft)&&(g=e2(g,i.type,i.pendingProps,pr),g!==null?(i.stateNode=g,vn=i,Ft=xr(g.firstChild),pr=!1,k=!0):k=!1),k||Cs(i)),re(i),k=i.type,N=i.pendingProps,$=s!==null?s.memoizedProps:null,g=N.children,wf(k,N)?g=null:$!==null&&wf(k,$)&&(i.flags|=32),i.memoizedState!==null&&(k=vh(s,i,pE,null,null,h),Fo._currentValue=k),bc(s,i),wn(s,i,g,h),i.child;case 6:return s===null&&_t&&((s=h=Ft)&&(h=t2(h,i.pendingProps,pr),h!==null?(i.stateNode=h,vn=i,Ft=null,s=!0):s=!1),s||Cs(i)),null;case 13:return Iy(s,i,h);case 4:return F(i,i.stateNode.containerInfo),g=i.pendingProps,s===null?i.child=gi(i,null,g,h):wn(s,i,g,h),i.child;case 11:return jy(s,i,i.type,i.pendingProps,h);case 7:return wn(s,i,i.pendingProps,h),i.child;case 8:return wn(s,i,i.pendingProps.children,h),i.child;case 12:return wn(s,i,i.pendingProps.children,h),i.child;case 10:return g=i.pendingProps,ks(i,i.type,g.value),wn(s,i,g.children,h),i.child;case 9:return k=i.type._context,g=i.pendingProps.children,hi(i),k=Sn(k),g=g(k),i.flags|=1,wn(s,i,g,h),i.child;case 14:return Ny(s,i,i.type,i.pendingProps,h);case 15:return Ty(s,i,i.type,i.pendingProps,h);case 19:return By(s,i,h);case 31:return wE(s,i,h);case 22:return Ay(s,i,h,i.pendingProps);case 24:return hi(i),g=Sn(rn),s===null?(k=dh(),k===null&&(k=It,N=ch(),k.pooledCache=N,N.refCount++,N!==null&&(k.pooledCacheLanes|=h),k=N),i.memoizedState={parent:g,cache:k},fh(i),ks(i,rn,k)):((s.lanes&h)!==0&&(mh(s,i),wo(i,null,null,h),So()),k=s.memoizedState,N=i.memoizedState,k.parent!==g?(k={parent:g,cache:g},i.memoizedState=k,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=k),ks(i,rn,g)):(g=N.cache,ks(i,rn,g),g!==k.cache&&lh(i,[rn],h,!0))),wn(s,i,i.pendingProps.children,h),i.child;case 29:throw i.pendingProps}throw Error(r(156,i.tag))}function ss(s){s.flags|=4}function Yh(s,i,h,g,k){if((i=(s.mode&32)!==0)&&(i=!1),i){if(s.flags|=16777216,(k&335544128)===k)if(s.stateNode.complete)s.flags|=8192;else if(h_())s.flags|=8192;else throw pi=ic,hh}else s.flags&=-16777217}function zy(s,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!tb(i))if(h_())s.flags|=8192;else throw pi=ic,hh}function Sc(s,i){i!==null&&(s.flags|=4),s.flags&16384&&(i=s.tag!==22?Mn():536870912,s.lanes|=i,ya|=i)}function To(s,i){if(!_t)switch(s.tailMode){case"hidden":i=s.tail;for(var h=null;i!==null;)i.alternate!==null&&(h=i),i=i.sibling;h===null?s.tail=null:h.sibling=null;break;case"collapsed":h=s.tail;for(var g=null;h!==null;)h.alternate!==null&&(g=h),h=h.sibling;g===null?i||s.tail===null?s.tail=null:s.tail.sibling=null:g.sibling=null}}function Vt(s){var i=s.alternate!==null&&s.alternate.child===s.child,h=0,g=0;if(i)for(var k=s.child;k!==null;)h|=k.lanes|k.childLanes,g|=k.subtreeFlags&65011712,g|=k.flags&65011712,k.return=s,k=k.sibling;else for(k=s.child;k!==null;)h|=k.lanes|k.childLanes,g|=k.subtreeFlags,g|=k.flags,k.return=s,k=k.sibling;return s.subtreeFlags|=g,s.childLanes=h,i}function kE(s,i,h){var g=i.pendingProps;switch(rh(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vt(i),null;case 1:return Vt(i),null;case 3:return h=i.stateNode,g=null,s!==null&&(g=s.memoizedState.cache),i.memoizedState.cache!==g&&(i.flags|=2048),es(rn),te(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(s===null||s.child===null)&&(ia(i)?ss(i):s===null||s.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,ih())),Vt(i),null;case 26:var k=i.type,N=i.memoizedState;return s===null?(ss(i),N!==null?(Vt(i),zy(i,N)):(Vt(i),Yh(i,k,null,g,h))):N?N!==s.memoizedState?(ss(i),Vt(i),zy(i,N)):(Vt(i),i.flags&=-16777217):(s=s.memoizedProps,s!==g&&ss(i),Vt(i),Yh(i,k,s,g,h)),null;case 27:if(pe(i),h=ne.current,k=i.type,s!==null&&i.stateNode!=null)s.memoizedProps!==g&&ss(i);else{if(!g){if(i.stateNode===null)throw Error(r(166));return Vt(i),null}s=ee.current,ia(i)?_x(i):(s=q_(k,g,h),i.stateNode=s,ss(i))}return Vt(i),null;case 5:if(pe(i),k=i.type,s!==null&&i.stateNode!=null)s.memoizedProps!==g&&ss(i);else{if(!g){if(i.stateNode===null)throw Error(r(166));return Vt(i),null}if(N=ee.current,ia(i))_x(i);else{var $=Pc(ne.current);switch(N){case 1:N=$.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:N=$.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":N=$.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":N=$.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":N=$.createElement("div"),N.innerHTML="<script><\/script>",N=N.removeChild(N.firstChild);break;case"select":N=typeof g.is=="string"?$.createElement("select",{is:g.is}):$.createElement("select"),g.multiple?N.multiple=!0:g.size&&(N.size=g.size);break;default:N=typeof g.is=="string"?$.createElement(k,{is:g.is}):$.createElement(k)}}N[jt]=i,N[In]=g;e:for($=i.child;$!==null;){if($.tag===5||$.tag===6)N.appendChild($.stateNode);else if($.tag!==4&&$.tag!==27&&$.child!==null){$.child.return=$,$=$.child;continue}if($===i)break e;for(;$.sibling===null;){if($.return===null||$.return===i)break e;$=$.return}$.sibling.return=$.return,$=$.sibling}i.stateNode=N;e:switch(Cn(N,k,g),k){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&ss(i)}}return Vt(i),Yh(i,i.type,s===null?null:s.memoizedProps,i.pendingProps,h),null;case 6:if(s&&i.stateNode!=null)s.memoizedProps!==g&&ss(i);else{if(typeof g!="string"&&i.stateNode===null)throw Error(r(166));if(s=ne.current,ia(i)){if(s=i.stateNode,h=i.memoizedProps,g=null,k=vn,k!==null)switch(k.tag){case 27:case 5:g=k.memoizedProps}s[jt]=i,s=!!(s.nodeValue===h||g!==null&&g.suppressHydrationWarning===!0||I_(s.nodeValue,h)),s||Cs(i,!0)}else s=Pc(s).createTextNode(g),s[jt]=i,i.stateNode=s}return Vt(i),null;case 31:if(h=i.memoizedState,s===null||s.memoizedState!==null){if(g=ia(i),h!==null){if(s===null){if(!g)throw Error(r(318));if(s=i.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[jt]=i}else ui(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Vt(i),s=!1}else h=ih(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=h),s=!0;if(!s)return i.flags&256?(tr(i),i):(tr(i),null);if((i.flags&128)!==0)throw Error(r(558))}return Vt(i),null;case 13:if(g=i.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(k=ia(i),g!==null&&g.dehydrated!==null){if(s===null){if(!k)throw Error(r(318));if(k=i.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(r(317));k[jt]=i}else ui(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Vt(i),k=!1}else k=ih(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=k),k=!0;if(!k)return i.flags&256?(tr(i),i):(tr(i),null)}return tr(i),(i.flags&128)!==0?(i.lanes=h,i):(h=g!==null,s=s!==null&&s.memoizedState!==null,h&&(g=i.child,k=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(k=g.alternate.memoizedState.cachePool.pool),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==k&&(g.flags|=2048)),h!==s&&h&&(i.child.flags|=8192),Sc(i,i.updateQueue),Vt(i),null);case 4:return te(),s===null&&yf(i.stateNode.containerInfo),Vt(i),null;case 10:return es(i.type),Vt(i),null;case 19:if(G(Qt),g=i.memoizedState,g===null)return Vt(i),null;if(k=(i.flags&128)!==0,N=g.rendering,N===null)if(k)To(g,!1);else{if(Kt!==0||s!==null&&(s.flags&128)!==0)for(s=i.child;s!==null;){if(N=cc(s),N!==null){for(i.flags|=128,To(g,!1),s=N.updateQueue,i.updateQueue=s,Sc(i,s),i.subtreeFlags=0,s=h,h=i.child;h!==null;)mx(h,s),h=h.sibling;return B(Qt,Qt.current&1|2),_t&&Jr(i,g.treeForkCount),i.child}s=s.sibling}g.tail!==null&&it()>jc&&(i.flags|=128,k=!0,To(g,!1),i.lanes=4194304)}else{if(!k)if(s=cc(N),s!==null){if(i.flags|=128,k=!0,s=s.updateQueue,i.updateQueue=s,Sc(i,s),To(g,!0),g.tail===null&&g.tailMode==="hidden"&&!N.alternate&&!_t)return Vt(i),null}else 2*it()-g.renderingStartTime>jc&&h!==536870912&&(i.flags|=128,k=!0,To(g,!1),i.lanes=4194304);g.isBackwards?(N.sibling=i.child,i.child=N):(s=g.last,s!==null?s.sibling=N:i.child=N,g.last=N)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=it(),s.sibling=null,h=Qt.current,B(Qt,k?h&1|2:h&1),_t&&Jr(i,g.treeForkCount),s):(Vt(i),null);case 22:case 23:return tr(i),yh(),g=i.memoizedState!==null,s!==null?s.memoizedState!==null!==g&&(i.flags|=8192):g&&(i.flags|=8192),g?(h&536870912)!==0&&(i.flags&128)===0&&(Vt(i),i.subtreeFlags&6&&(i.flags|=8192)):Vt(i),h=i.updateQueue,h!==null&&Sc(i,h.retryQueue),h=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),g=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(g=i.memoizedState.cachePool.pool),g!==h&&(i.flags|=2048),s!==null&&G(fi),null;case 24:return h=null,s!==null&&(h=s.memoizedState.cache),i.memoizedState.cache!==h&&(i.flags|=2048),es(rn),Vt(i),null;case 25:return null;case 30:return null}throw Error(r(156,i.tag))}function EE(s,i){switch(rh(i),i.tag){case 1:return s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 3:return es(rn),te(),s=i.flags,(s&65536)!==0&&(s&128)===0?(i.flags=s&-65537|128,i):null;case 26:case 27:case 5:return pe(i),null;case 31:if(i.memoizedState!==null){if(tr(i),i.alternate===null)throw Error(r(340));ui()}return s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 13:if(tr(i),s=i.memoizedState,s!==null&&s.dehydrated!==null){if(i.alternate===null)throw Error(r(340));ui()}return s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 19:return G(Qt),null;case 4:return te(),null;case 10:return es(i.type),null;case 22:case 23:return tr(i),yh(),s!==null&&G(fi),s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 24:return es(rn),null;case 25:return null;default:return null}}function Hy(s,i){switch(rh(i),i.tag){case 3:es(rn),te();break;case 26:case 27:case 5:pe(i);break;case 4:te();break;case 31:i.memoizedState!==null&&tr(i);break;case 13:tr(i);break;case 19:G(Qt);break;case 10:es(i.type);break;case 22:case 23:tr(i),yh(),s!==null&&G(fi);break;case 24:es(rn)}}function Ao(s,i){try{var h=i.updateQueue,g=h!==null?h.lastEffect:null;if(g!==null){var k=g.next;h=k;do{if((h.tag&s)===s){g=void 0;var N=h.create,$=h.inst;g=N(),$.destroy=g}h=h.next}while(h!==k)}}catch(Y){Tt(i,i.return,Y)}}function Ls(s,i,h){try{var g=i.updateQueue,k=g!==null?g.lastEffect:null;if(k!==null){var N=k.next;g=N;do{if((g.tag&s)===s){var $=g.inst,Y=$.destroy;if(Y!==void 0){$.destroy=void 0,k=i;var ie=h,de=Y;try{de()}catch(Se){Tt(k,ie,Se)}}}g=g.next}while(g!==N)}}catch(Se){Tt(i,i.return,Se)}}function Uy(s){var i=s.updateQueue;if(i!==null){var h=s.stateNode;try{Dx(i,h)}catch(g){Tt(s,s.return,g)}}}function Fy(s,i,h){h.props=yi(s.type,s.memoizedProps),h.state=s.memoizedState;try{h.componentWillUnmount()}catch(g){Tt(s,i,g)}}function Lo(s,i){try{var h=s.ref;if(h!==null){switch(s.tag){case 26:case 27:case 5:var g=s.stateNode;break;case 30:g=s.stateNode;break;default:g=s.stateNode}typeof h=="function"?s.refCleanup=h(g):h.current=g}}catch(k){Tt(s,i,k)}}function Pr(s,i){var h=s.ref,g=s.refCleanup;if(h!==null)if(typeof g=="function")try{g()}catch(k){Tt(s,i,k)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof h=="function")try{h(null)}catch(k){Tt(s,i,k)}else h.current=null}function Vy(s){var i=s.type,h=s.memoizedProps,g=s.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":h.autoFocus&&g.focus();break e;case"img":h.src?g.src=h.src:h.srcSet&&(g.srcset=h.srcSet)}}catch(k){Tt(s,s.return,k)}}function Xh(s,i,h){try{var g=s.stateNode;KE(g,s.type,h,i),g[In]=i}catch(k){Tt(s,s.return,k)}}function Gy(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Bs(s.type)||s.tag===4}function Qh(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Gy(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Bs(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Jh(s,i,h){var g=s.tag;if(g===5||g===6)s=s.stateNode,i?(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h).insertBefore(s,i):(i=h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,i.appendChild(s),h=h._reactRootContainer,h!=null||i.onclick!==null||(i.onclick=Yr));else if(g!==4&&(g===27&&Bs(s.type)&&(h=s.stateNode,i=null),s=s.child,s!==null))for(Jh(s,i,h),s=s.sibling;s!==null;)Jh(s,i,h),s=s.sibling}function wc(s,i,h){var g=s.tag;if(g===5||g===6)s=s.stateNode,i?h.insertBefore(s,i):h.appendChild(s);else if(g!==4&&(g===27&&Bs(s.type)&&(h=s.stateNode),s=s.child,s!==null))for(wc(s,i,h),s=s.sibling;s!==null;)wc(s,i,h),s=s.sibling}function Wy(s){var i=s.stateNode,h=s.memoizedProps;try{for(var g=s.type,k=i.attributes;k.length;)i.removeAttributeNode(k[0]);Cn(i,g,h),i[jt]=s,i[In]=h}catch(N){Tt(s,s.return,N)}}var is=!1,on=!1,Zh=!1,qy=typeof WeakSet=="function"?WeakSet:Set,xn=null;function jE(s,i){if(s=s.containerInfo,vf=Vc,s=ix(s),Wd(s)){if("selectionStart"in s)var h={start:s.selectionStart,end:s.selectionEnd};else e:{h=(h=s.ownerDocument)&&h.defaultView||window;var g=h.getSelection&&h.getSelection();if(g&&g.rangeCount!==0){h=g.anchorNode;var k=g.anchorOffset,N=g.focusNode;g=g.focusOffset;try{h.nodeType,N.nodeType}catch{h=null;break e}var $=0,Y=-1,ie=-1,de=0,Se=0,Ee=s,fe=null;t:for(;;){for(var ge;Ee!==h||k!==0&&Ee.nodeType!==3||(Y=$+k),Ee!==N||g!==0&&Ee.nodeType!==3||(ie=$+g),Ee.nodeType===3&&($+=Ee.nodeValue.length),(ge=Ee.firstChild)!==null;)fe=Ee,Ee=ge;for(;;){if(Ee===s)break t;if(fe===h&&++de===k&&(Y=$),fe===N&&++Se===g&&(ie=$),(ge=Ee.nextSibling)!==null)break;Ee=fe,fe=Ee.parentNode}Ee=ge}h=Y===-1||ie===-1?null:{start:Y,end:ie}}else h=null}h=h||{start:0,end:0}}else h=null;for(Sf={focusedElem:s,selectionRange:h},Vc=!1,xn=i;xn!==null;)if(i=xn,s=i.child,(i.subtreeFlags&1028)!==0&&s!==null)s.return=i,xn=s;else for(;xn!==null;){switch(i=xn,N=i.alternate,s=i.flags,i.tag){case 0:if((s&4)!==0&&(s=i.updateQueue,s=s!==null?s.events:null,s!==null))for(h=0;h<s.length;h++)k=s[h],k.ref.impl=k.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&N!==null){s=void 0,h=i,k=N.memoizedProps,N=N.memoizedState,g=h.stateNode;try{var Ue=yi(h.type,k);s=g.getSnapshotBeforeUpdate(Ue,N),g.__reactInternalSnapshotBeforeUpdate=s}catch(Je){Tt(h,h.return,Je)}}break;case 3:if((s&1024)!==0){if(s=i.stateNode.containerInfo,h=s.nodeType,h===9)kf(s);else if(h===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":kf(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(r(163))}if(s=i.sibling,s!==null){s.return=i.return,xn=s;break}xn=i.return}}function Ky(s,i,h){var g=h.flags;switch(h.tag){case 0:case 11:case 15:os(s,h),g&4&&Ao(5,h);break;case 1:if(os(s,h),g&4)if(s=h.stateNode,i===null)try{s.componentDidMount()}catch($){Tt(h,h.return,$)}else{var k=yi(h.type,i.memoizedProps);i=i.memoizedState;try{s.componentDidUpdate(k,i,s.__reactInternalSnapshotBeforeUpdate)}catch($){Tt(h,h.return,$)}}g&64&&Uy(h),g&512&&Lo(h,h.return);break;case 3:if(os(s,h),g&64&&(s=h.updateQueue,s!==null)){if(i=null,h.child!==null)switch(h.child.tag){case 27:case 5:i=h.child.stateNode;break;case 1:i=h.child.stateNode}try{Dx(s,i)}catch($){Tt(h,h.return,$)}}break;case 27:i===null&&g&4&&Wy(h);case 26:case 5:os(s,h),i===null&&g&4&&Vy(h),g&512&&Lo(h,h.return);break;case 12:os(s,h);break;case 31:os(s,h),g&4&&Qy(s,h);break;case 13:os(s,h),g&4&&Jy(s,h),g&64&&(s=h.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(h=IE.bind(null,h),n2(s,h))));break;case 22:if(g=h.memoizedState!==null||is,!g){i=i!==null&&i.memoizedState!==null||on,k=is;var N=on;is=g,(on=i)&&!N?ls(s,h,(h.subtreeFlags&8772)!==0):os(s,h),is=k,on=N}break;case 30:break;default:os(s,h)}}function Yy(s){var i=s.alternate;i!==null&&(s.alternate=null,Yy(i)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(i=s.stateNode,i!==null&&Td(i)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var Gt=null,Bn=!1;function as(s,i,h){for(h=h.child;h!==null;)Xy(s,i,h),h=h.sibling}function Xy(s,i,h){if(Oe&&typeof Oe.onCommitFiberUnmount=="function")try{Oe.onCommitFiberUnmount(me,h)}catch{}switch(h.tag){case 26:on||Pr(h,i),as(s,i,h),h.memoizedState?h.memoizedState.count--:h.stateNode&&(h=h.stateNode,h.parentNode.removeChild(h));break;case 27:on||Pr(h,i);var g=Gt,k=Bn;Bs(h.type)&&(Gt=h.stateNode,Bn=!1),as(s,i,h),zo(h.stateNode),Gt=g,Bn=k;break;case 5:on||Pr(h,i);case 6:if(g=Gt,k=Bn,Gt=null,as(s,i,h),Gt=g,Bn=k,Gt!==null)if(Bn)try{(Gt.nodeType===9?Gt.body:Gt.nodeName==="HTML"?Gt.ownerDocument.body:Gt).removeChild(h.stateNode)}catch(N){Tt(h,i,N)}else try{Gt.removeChild(h.stateNode)}catch(N){Tt(h,i,N)}break;case 18:Gt!==null&&(Bn?(s=Gt,U_(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,h.stateNode),Ea(s)):U_(Gt,h.stateNode));break;case 4:g=Gt,k=Bn,Gt=h.stateNode.containerInfo,Bn=!0,as(s,i,h),Gt=g,Bn=k;break;case 0:case 11:case 14:case 15:Ls(2,h,i),on||Ls(4,h,i),as(s,i,h);break;case 1:on||(Pr(h,i),g=h.stateNode,typeof g.componentWillUnmount=="function"&&Fy(h,i,g)),as(s,i,h);break;case 21:as(s,i,h);break;case 22:on=(g=on)||h.memoizedState!==null,as(s,i,h),on=g;break;default:as(s,i,h)}}function Qy(s,i){if(i.memoizedState===null&&(s=i.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Ea(s)}catch(h){Tt(i,i.return,h)}}}function Jy(s,i){if(i.memoizedState===null&&(s=i.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Ea(s)}catch(h){Tt(i,i.return,h)}}function NE(s){switch(s.tag){case 31:case 13:case 19:var i=s.stateNode;return i===null&&(i=s.stateNode=new qy),i;case 22:return s=s.stateNode,i=s._retryCache,i===null&&(i=s._retryCache=new qy),i;default:throw Error(r(435,s.tag))}}function Cc(s,i){var h=NE(s);i.forEach(function(g){if(!h.has(g)){h.add(g);var k=PE.bind(null,s,g);g.then(k,k)}})}function $n(s,i){var h=i.deletions;if(h!==null)for(var g=0;g<h.length;g++){var k=h[g],N=s,$=i,Y=$;e:for(;Y!==null;){switch(Y.tag){case 27:if(Bs(Y.type)){Gt=Y.stateNode,Bn=!1;break e}break;case 5:Gt=Y.stateNode,Bn=!1;break e;case 3:case 4:Gt=Y.stateNode.containerInfo,Bn=!0;break e}Y=Y.return}if(Gt===null)throw Error(r(160));Xy(N,$,k),Gt=null,Bn=!1,N=k.alternate,N!==null&&(N.return=null),k.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)Zy(i,s),i=i.sibling}var Er=null;function Zy(s,i){var h=s.alternate,g=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:$n(i,s),zn(s),g&4&&(Ls(3,s,s.return),Ao(3,s),Ls(5,s,s.return));break;case 1:$n(i,s),zn(s),g&512&&(on||h===null||Pr(h,h.return)),g&64&&is&&(s=s.updateQueue,s!==null&&(g=s.callbacks,g!==null&&(h=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=h===null?g:h.concat(g))));break;case 26:var k=Er;if($n(i,s),zn(s),g&512&&(on||h===null||Pr(h,h.return)),g&4){var N=h!==null?h.memoizedState:null;if(g=s.memoizedState,h===null)if(g===null)if(s.stateNode===null){e:{g=s.type,h=s.memoizedProps,k=k.ownerDocument||k;t:switch(g){case"title":N=k.getElementsByTagName("title")[0],(!N||N[ro]||N[jt]||N.namespaceURI==="http://www.w3.org/2000/svg"||N.hasAttribute("itemprop"))&&(N=k.createElement(g),k.head.insertBefore(N,k.querySelector("head > title"))),Cn(N,g,h),N[jt]=s,gn(N),g=N;break e;case"link":var $=Z_("link","href",k).get(g+(h.href||""));if($){for(var Y=0;Y<$.length;Y++)if(N=$[Y],N.getAttribute("href")===(h.href==null||h.href===""?null:h.href)&&N.getAttribute("rel")===(h.rel==null?null:h.rel)&&N.getAttribute("title")===(h.title==null?null:h.title)&&N.getAttribute("crossorigin")===(h.crossOrigin==null?null:h.crossOrigin)){$.splice(Y,1);break t}}N=k.createElement(g),Cn(N,g,h),k.head.appendChild(N);break;case"meta":if($=Z_("meta","content",k).get(g+(h.content||""))){for(Y=0;Y<$.length;Y++)if(N=$[Y],N.getAttribute("content")===(h.content==null?null:""+h.content)&&N.getAttribute("name")===(h.name==null?null:h.name)&&N.getAttribute("property")===(h.property==null?null:h.property)&&N.getAttribute("http-equiv")===(h.httpEquiv==null?null:h.httpEquiv)&&N.getAttribute("charset")===(h.charSet==null?null:h.charSet)){$.splice(Y,1);break t}}N=k.createElement(g),Cn(N,g,h),k.head.appendChild(N);break;default:throw Error(r(468,g))}N[jt]=s,gn(N),g=N}s.stateNode=g}else eb(k,s.type,s.stateNode);else s.stateNode=J_(k,g,s.memoizedProps);else N!==g?(N===null?h.stateNode!==null&&(h=h.stateNode,h.parentNode.removeChild(h)):N.count--,g===null?eb(k,s.type,s.stateNode):J_(k,g,s.memoizedProps)):g===null&&s.stateNode!==null&&Xh(s,s.memoizedProps,h.memoizedProps)}break;case 27:$n(i,s),zn(s),g&512&&(on||h===null||Pr(h,h.return)),h!==null&&g&4&&Xh(s,s.memoizedProps,h.memoizedProps);break;case 5:if($n(i,s),zn(s),g&512&&(on||h===null||Pr(h,h.return)),s.flags&32){k=s.stateNode;try{Yi(k,"")}catch(Ue){Tt(s,s.return,Ue)}}g&4&&s.stateNode!=null&&(k=s.memoizedProps,Xh(s,k,h!==null?h.memoizedProps:k)),g&1024&&(Zh=!0);break;case 6:if($n(i,s),zn(s),g&4){if(s.stateNode===null)throw Error(r(162));g=s.memoizedProps,h=s.stateNode;try{h.nodeValue=g}catch(Ue){Tt(s,s.return,Ue)}}break;case 3:if(zc=null,k=Er,Er=Bc(i.containerInfo),$n(i,s),Er=k,zn(s),g&4&&h!==null&&h.memoizedState.isDehydrated)try{Ea(i.containerInfo)}catch(Ue){Tt(s,s.return,Ue)}Zh&&(Zh=!1,e_(s));break;case 4:g=Er,Er=Bc(s.stateNode.containerInfo),$n(i,s),zn(s),Er=g;break;case 12:$n(i,s),zn(s);break;case 31:$n(i,s),zn(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Cc(s,g)));break;case 13:$n(i,s),zn(s),s.child.flags&8192&&s.memoizedState!==null!=(h!==null&&h.memoizedState!==null)&&(Ec=it()),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Cc(s,g)));break;case 22:k=s.memoizedState!==null;var ie=h!==null&&h.memoizedState!==null,de=is,Se=on;if(is=de||k,on=Se||ie,$n(i,s),on=Se,is=de,zn(s),g&8192)e:for(i=s.stateNode,i._visibility=k?i._visibility&-2:i._visibility|1,k&&(h===null||ie||is||on||_i(s)),h=null,i=s;;){if(i.tag===5||i.tag===26){if(h===null){ie=h=i;try{if(N=ie.stateNode,k)$=N.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none";else{Y=ie.stateNode;var Ee=ie.memoizedProps.style,fe=Ee!=null&&Ee.hasOwnProperty("display")?Ee.display:null;Y.style.display=fe==null||typeof fe=="boolean"?"":(""+fe).trim()}}catch(Ue){Tt(ie,ie.return,Ue)}}}else if(i.tag===6){if(h===null){ie=i;try{ie.stateNode.nodeValue=k?"":ie.memoizedProps}catch(Ue){Tt(ie,ie.return,Ue)}}}else if(i.tag===18){if(h===null){ie=i;try{var ge=ie.stateNode;k?F_(ge,!0):F_(ie.stateNode,!1)}catch(Ue){Tt(ie,ie.return,Ue)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===s)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;h===i&&(h=null),i=i.return}h===i&&(h=null),i.sibling.return=i.return,i=i.sibling}g&4&&(g=s.updateQueue,g!==null&&(h=g.retryQueue,h!==null&&(g.retryQueue=null,Cc(s,h))));break;case 19:$n(i,s),zn(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Cc(s,g)));break;case 30:break;case 21:break;default:$n(i,s),zn(s)}}function zn(s){var i=s.flags;if(i&2){try{for(var h,g=s.return;g!==null;){if(Gy(g)){h=g;break}g=g.return}if(h==null)throw Error(r(160));switch(h.tag){case 27:var k=h.stateNode,N=Qh(s);wc(s,N,k);break;case 5:var $=h.stateNode;h.flags&32&&(Yi($,""),h.flags&=-33);var Y=Qh(s);wc(s,Y,$);break;case 3:case 4:var ie=h.stateNode.containerInfo,de=Qh(s);Jh(s,de,ie);break;default:throw Error(r(161))}}catch(Se){Tt(s,s.return,Se)}s.flags&=-3}i&4096&&(s.flags&=-4097)}function e_(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var i=s;e_(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),s=s.sibling}}function os(s,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)Ky(s,i.alternate,i),i=i.sibling}function _i(s){for(s=s.child;s!==null;){var i=s;switch(i.tag){case 0:case 11:case 14:case 15:Ls(4,i,i.return),_i(i);break;case 1:Pr(i,i.return);var h=i.stateNode;typeof h.componentWillUnmount=="function"&&Fy(i,i.return,h),_i(i);break;case 27:zo(i.stateNode);case 26:case 5:Pr(i,i.return),_i(i);break;case 22:i.memoizedState===null&&_i(i);break;case 30:_i(i);break;default:_i(i)}s=s.sibling}}function ls(s,i,h){for(h=h&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var g=i.alternate,k=s,N=i,$=N.flags;switch(N.tag){case 0:case 11:case 15:ls(k,N,h),Ao(4,N);break;case 1:if(ls(k,N,h),g=N,k=g.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(de){Tt(g,g.return,de)}if(g=N,k=g.updateQueue,k!==null){var Y=g.stateNode;try{var ie=k.shared.hiddenCallbacks;if(ie!==null)for(k.shared.hiddenCallbacks=null,k=0;k<ie.length;k++)Lx(ie[k],Y)}catch(de){Tt(g,g.return,de)}}h&&$&64&&Uy(N),Lo(N,N.return);break;case 27:Wy(N);case 26:case 5:ls(k,N,h),h&&g===null&&$&4&&Vy(N),Lo(N,N.return);break;case 12:ls(k,N,h);break;case 31:ls(k,N,h),h&&$&4&&Qy(k,N);break;case 13:ls(k,N,h),h&&$&4&&Jy(k,N);break;case 22:N.memoizedState===null&&ls(k,N,h),Lo(N,N.return);break;case 30:break;default:ls(k,N,h)}i=i.sibling}}function ef(s,i){var h=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),s=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(s=i.memoizedState.cachePool.pool),s!==h&&(s!=null&&s.refCount++,h!=null&&xo(h))}function tf(s,i){s=null,i.alternate!==null&&(s=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==s&&(i.refCount++,s!=null&&xo(s))}function jr(s,i,h,g){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)t_(s,i,h,g),i=i.sibling}function t_(s,i,h,g){var k=i.flags;switch(i.tag){case 0:case 11:case 15:jr(s,i,h,g),k&2048&&Ao(9,i);break;case 1:jr(s,i,h,g);break;case 3:jr(s,i,h,g),k&2048&&(s=null,i.alternate!==null&&(s=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==s&&(i.refCount++,s!=null&&xo(s)));break;case 12:if(k&2048){jr(s,i,h,g),s=i.stateNode;try{var N=i.memoizedProps,$=N.id,Y=N.onPostCommit;typeof Y=="function"&&Y($,i.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(ie){Tt(i,i.return,ie)}}else jr(s,i,h,g);break;case 31:jr(s,i,h,g);break;case 13:jr(s,i,h,g);break;case 23:break;case 22:N=i.stateNode,$=i.alternate,i.memoizedState!==null?N._visibility&2?jr(s,i,h,g):Do(s,i):N._visibility&2?jr(s,i,h,g):(N._visibility|=2,pa(s,i,h,g,(i.subtreeFlags&10256)!==0||!1)),k&2048&&ef($,i);break;case 24:jr(s,i,h,g),k&2048&&tf(i.alternate,i);break;default:jr(s,i,h,g)}}function pa(s,i,h,g,k){for(k=k&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var N=s,$=i,Y=h,ie=g,de=$.flags;switch($.tag){case 0:case 11:case 15:pa(N,$,Y,ie,k),Ao(8,$);break;case 23:break;case 22:var Se=$.stateNode;$.memoizedState!==null?Se._visibility&2?pa(N,$,Y,ie,k):Do(N,$):(Se._visibility|=2,pa(N,$,Y,ie,k)),k&&de&2048&&ef($.alternate,$);break;case 24:pa(N,$,Y,ie,k),k&&de&2048&&tf($.alternate,$);break;default:pa(N,$,Y,ie,k)}i=i.sibling}}function Do(s,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var h=s,g=i,k=g.flags;switch(g.tag){case 22:Do(h,g),k&2048&&ef(g.alternate,g);break;case 24:Do(h,g),k&2048&&tf(g.alternate,g);break;default:Do(h,g)}i=i.sibling}}var Ro=8192;function ga(s,i,h){if(s.subtreeFlags&Ro)for(s=s.child;s!==null;)n_(s,i,h),s=s.sibling}function n_(s,i,h){switch(s.tag){case 26:ga(s,i,h),s.flags&Ro&&s.memoizedState!==null&&m2(h,Er,s.memoizedState,s.memoizedProps);break;case 5:ga(s,i,h);break;case 3:case 4:var g=Er;Er=Bc(s.stateNode.containerInfo),ga(s,i,h),Er=g;break;case 22:s.memoizedState===null&&(g=s.alternate,g!==null&&g.memoizedState!==null?(g=Ro,Ro=16777216,ga(s,i,h),Ro=g):ga(s,i,h));break;default:ga(s,i,h)}}function r_(s){var i=s.alternate;if(i!==null&&(s=i.child,s!==null)){i.child=null;do i=s.sibling,s.sibling=null,s=i;while(s!==null)}}function Oo(s){var i=s.deletions;if((s.flags&16)!==0){if(i!==null)for(var h=0;h<i.length;h++){var g=i[h];xn=g,i_(g,s)}r_(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)s_(s),s=s.sibling}function s_(s){switch(s.tag){case 0:case 11:case 15:Oo(s),s.flags&2048&&Ls(9,s,s.return);break;case 3:Oo(s);break;case 12:Oo(s);break;case 22:var i=s.stateNode;s.memoizedState!==null&&i._visibility&2&&(s.return===null||s.return.tag!==13)?(i._visibility&=-3,kc(s)):Oo(s);break;default:Oo(s)}}function kc(s){var i=s.deletions;if((s.flags&16)!==0){if(i!==null)for(var h=0;h<i.length;h++){var g=i[h];xn=g,i_(g,s)}r_(s)}for(s=s.child;s!==null;){switch(i=s,i.tag){case 0:case 11:case 15:Ls(8,i,i.return),kc(i);break;case 22:h=i.stateNode,h._visibility&2&&(h._visibility&=-3,kc(i));break;default:kc(i)}s=s.sibling}}function i_(s,i){for(;xn!==null;){var h=xn;switch(h.tag){case 0:case 11:case 15:Ls(8,h,i);break;case 23:case 22:if(h.memoizedState!==null&&h.memoizedState.cachePool!==null){var g=h.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:xo(h.memoizedState.cache)}if(g=h.child,g!==null)g.return=h,xn=g;else e:for(h=s;xn!==null;){g=xn;var k=g.sibling,N=g.return;if(Yy(g),g===h){xn=null;break e}if(k!==null){k.return=N,xn=k;break e}xn=N}}}var TE={getCacheForType:function(s){var i=Sn(rn),h=i.data.get(s);return h===void 0&&(h=s(),i.data.set(s,h)),h},cacheSignal:function(){return Sn(rn).controller.signal}},AE=typeof WeakMap=="function"?WeakMap:Map,Ct=0,It=null,ft=null,gt=0,Nt=0,nr=null,Ds=!1,xa=!1,nf=!1,cs=0,Kt=0,Rs=0,bi=0,rf=0,rr=0,ya=0,Mo=null,Hn=null,sf=!1,Ec=0,a_=0,jc=1/0,Nc=null,Os=null,hn=0,Ms=null,_a=null,us=0,af=0,of=null,o_=null,Io=0,lf=null;function sr(){return(Ct&2)!==0&>!==0?gt&-gt:U.T!==null?mf():yt()}function l_(){if(rr===0)if((gt&536870912)===0||_t){var s=ye;ye<<=1,(ye&3932160)===0&&(ye=262144),rr=s}else rr=536870912;return s=er.current,s!==null&&(s.flags|=32),rr}function Un(s,i,h){(s===It&&(Nt===2||Nt===9)||s.cancelPendingCommit!==null)&&(ba(s,0),Is(s,gt,rr,!1)),Cr(s,h),((Ct&2)===0||s!==It)&&(s===It&&((Ct&2)===0&&(bi|=h),Kt===4&&Is(s,gt,rr,!1)),Br(s))}function c_(s,i,h){if((Ct&6)!==0)throw Error(r(327));var g=!h&&(i&127)===0&&(i&s.expiredLanes)===0||Qe(s,i),k=g?RE(s,i):uf(s,i,!0),N=g;do{if(k===0){xa&&!g&&Is(s,i,0,!1);break}else{if(h=s.current.alternate,N&&!LE(h)){k=uf(s,i,!1),N=!1;continue}if(k===2){if(N=i,s.errorRecoveryDisabledLanes&N)var $=0;else $=s.pendingLanes&-536870913,$=$!==0?$:$&536870912?536870912:0;if($!==0){i=$;e:{var Y=s;k=Mo;var ie=Y.current.memoizedState.isDehydrated;if(ie&&(ba(Y,$).flags|=256),$=uf(Y,$,!1),$!==2){if(nf&&!ie){Y.errorRecoveryDisabledLanes|=N,bi|=N,k=4;break e}N=Hn,Hn=k,N!==null&&(Hn===null?Hn=N:Hn.push.apply(Hn,N))}k=$}if(N=!1,k!==2)continue}}if(k===1){ba(s,0),Is(s,i,0,!0);break}e:{switch(g=s,N=k,N){case 0:case 1:throw Error(r(345));case 4:if((i&4194048)!==i)break;case 6:Is(g,i,rr,!Ds);break e;case 2:Hn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((i&62914560)===i&&(k=Ec+300-it(),10<k)){if(Is(g,i,rr,!Ds),Ae(g,0,!0)!==0)break e;us=i,g.timeoutHandle=z_(u_.bind(null,g,h,Hn,Nc,sf,i,rr,bi,ya,Ds,N,"Throttled",-0,0),k);break e}u_(g,h,Hn,Nc,sf,i,rr,bi,ya,Ds,N,null,-0,0)}}break}while(!0);Br(s)}function u_(s,i,h,g,k,N,$,Y,ie,de,Se,Ee,fe,ge){if(s.timeoutHandle=-1,Ee=i.subtreeFlags,Ee&8192||(Ee&16785408)===16785408){Ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Yr},n_(i,N,Ee);var Ue=(N&62914560)===N?Ec-it():(N&4194048)===N?a_-it():0;if(Ue=p2(Ee,Ue),Ue!==null){us=N,s.cancelPendingCommit=Ue(y_.bind(null,s,i,N,h,g,k,$,Y,ie,Se,Ee,null,fe,ge)),Is(s,N,$,!de);return}}y_(s,i,N,h,g,k,$,Y,ie)}function LE(s){for(var i=s;;){var h=i.tag;if((h===0||h===11||h===15)&&i.flags&16384&&(h=i.updateQueue,h!==null&&(h=h.stores,h!==null)))for(var g=0;g<h.length;g++){var k=h[g],N=k.getSnapshot;k=k.value;try{if(!Jn(N(),k))return!1}catch{return!1}}if(h=i.child,i.subtreeFlags&16384&&h!==null)h.return=i,i=h;else{if(i===s)break;for(;i.sibling===null;){if(i.return===null||i.return===s)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Is(s,i,h,g){i&=~rf,i&=~bi,s.suspendedLanes|=i,s.pingedLanes&=~i,g&&(s.warmLanes|=i),g=s.expirationTimes;for(var k=i;0<k;){var N=31-et(k),$=1<<N;g[N]=-1,k&=~$}h!==0&&we(s,h,i)}function Tc(){return(Ct&6)===0?(Po(0),!1):!0}function cf(){if(ft!==null){if(Nt===0)var s=ft.return;else s=ft,Zr=di=null,Ch(s),ua=null,_o=0,s=ft;for(;s!==null;)Hy(s.alternate,s),s=s.return;ft=null}}function ba(s,i){var h=s.timeoutHandle;h!==-1&&(s.timeoutHandle=-1,QE(h)),h=s.cancelPendingCommit,h!==null&&(s.cancelPendingCommit=null,h()),us=0,cf(),It=s,ft=h=Qr(s.current,null),gt=i,Nt=0,nr=null,Ds=!1,xa=Qe(s,i),nf=!1,ya=rr=rf=bi=Rs=Kt=0,Hn=Mo=null,sf=!1,(i&8)!==0&&(i|=i&32);var g=s.entangledLanes;if(g!==0)for(s=s.entanglements,g&=i;0<g;){var k=31-et(g),N=1<<k;i|=s[k],g&=~N}return cs=i,Xl(),h}function d_(s,i){ct=null,U.H=jo,i===ca||i===sc?(i=jx(),Nt=3):i===hh?(i=jx(),Nt=4):Nt=i===zh?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,nr=i,ft===null&&(Kt=1,yc(s,hr(i,s.current)))}function h_(){var s=er.current;return s===null?!0:(gt&4194048)===gt?gr===null:(gt&62914560)===gt||(gt&536870912)!==0?s===gr:!1}function f_(){var s=U.H;return U.H=jo,s===null?jo:s}function m_(){var s=U.A;return U.A=TE,s}function Ac(){Kt=4,Ds||(gt&4194048)!==gt&&er.current!==null||(xa=!0),(Rs&134217727)===0&&(bi&134217727)===0||It===null||Is(It,gt,rr,!1)}function uf(s,i,h){var g=Ct;Ct|=2;var k=f_(),N=m_();(It!==s||gt!==i)&&(Nc=null,ba(s,i)),i=!1;var $=Kt;e:do try{if(Nt!==0&&ft!==null){var Y=ft,ie=nr;switch(Nt){case 8:cf(),$=6;break e;case 3:case 2:case 9:case 6:er.current===null&&(i=!0);var de=Nt;if(Nt=0,nr=null,va(s,Y,ie,de),h&&xa){$=0;break e}break;default:de=Nt,Nt=0,nr=null,va(s,Y,ie,de)}}DE(),$=Kt;break}catch(Se){d_(s,Se)}while(!0);return i&&s.shellSuspendCounter++,Zr=di=null,Ct=g,U.H=k,U.A=N,ft===null&&(It=null,gt=0,Xl()),$}function DE(){for(;ft!==null;)p_(ft)}function RE(s,i){var h=Ct;Ct|=2;var g=f_(),k=m_();It!==s||gt!==i?(Nc=null,jc=it()+500,ba(s,i)):xa=Qe(s,i);e:do try{if(Nt!==0&&ft!==null){i=ft;var N=nr;t:switch(Nt){case 1:Nt=0,nr=null,va(s,i,N,1);break;case 2:case 9:if(kx(N)){Nt=0,nr=null,g_(i);break}i=function(){Nt!==2&&Nt!==9||It!==s||(Nt=7),Br(s)},N.then(i,i);break e;case 3:Nt=7;break e;case 4:Nt=5;break e;case 7:kx(N)?(Nt=0,nr=null,g_(i)):(Nt=0,nr=null,va(s,i,N,7));break;case 5:var $=null;switch(ft.tag){case 26:$=ft.memoizedState;case 5:case 27:var Y=ft;if($?tb($):Y.stateNode.complete){Nt=0,nr=null;var ie=Y.sibling;if(ie!==null)ft=ie;else{var de=Y.return;de!==null?(ft=de,Lc(de)):ft=null}break t}}Nt=0,nr=null,va(s,i,N,5);break;case 6:Nt=0,nr=null,va(s,i,N,6);break;case 8:cf(),Kt=6;break e;default:throw Error(r(462))}}OE();break}catch(Se){d_(s,Se)}while(!0);return Zr=di=null,U.H=g,U.A=k,Ct=h,ft!==null?0:(It=null,gt=0,Xl(),Kt)}function OE(){for(;ft!==null&&!Ve();)p_(ft)}function p_(s){var i=$y(s.alternate,s,cs);s.memoizedProps=s.pendingProps,i===null?Lc(s):ft=i}function g_(s){var i=s,h=i.alternate;switch(i.tag){case 15:case 0:i=Ry(h,i,i.pendingProps,i.type,void 0,gt);break;case 11:i=Ry(h,i,i.pendingProps,i.type.render,i.ref,gt);break;case 5:Ch(i);default:Hy(h,i),i=ft=mx(i,cs),i=$y(h,i,cs)}s.memoizedProps=s.pendingProps,i===null?Lc(s):ft=i}function va(s,i,h,g){Zr=di=null,Ch(i),ua=null,_o=0;var k=i.return;try{if(SE(s,k,i,h,gt)){Kt=1,yc(s,hr(h,s.current)),ft=null;return}}catch(N){if(k!==null)throw ft=k,N;Kt=1,yc(s,hr(h,s.current)),ft=null;return}i.flags&32768?(_t||g===1?s=!0:xa||(gt&536870912)!==0?s=!1:(Ds=s=!0,(g===2||g===9||g===3||g===6)&&(g=er.current,g!==null&&g.tag===13&&(g.flags|=16384))),x_(i,s)):Lc(i)}function Lc(s){var i=s;do{if((i.flags&32768)!==0){x_(i,Ds);return}s=i.return;var h=kE(i.alternate,i,cs);if(h!==null){ft=h;return}if(i=i.sibling,i!==null){ft=i;return}ft=i=s}while(i!==null);Kt===0&&(Kt=5)}function x_(s,i){do{var h=EE(s.alternate,s);if(h!==null){h.flags&=32767,ft=h;return}if(h=s.return,h!==null&&(h.flags|=32768,h.subtreeFlags=0,h.deletions=null),!i&&(s=s.sibling,s!==null)){ft=s;return}ft=s=h}while(s!==null);Kt=6,ft=null}function y_(s,i,h,g,k,N,$,Y,ie){s.cancelPendingCommit=null;do Dc();while(hn!==0);if((Ct&6)!==0)throw Error(r(327));if(i!==null){if(i===s.current)throw Error(r(177));if(N=i.lanes|i.childLanes,N|=Qd,ve(s,h,N,$,Y,ie),s===It&&(ft=It=null,gt=0),_a=i,Ms=s,us=h,af=N,of=k,o_=g,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,BE(Fe,function(){return w_(),null})):(s.callbackNode=null,s.callbackPriority=0),g=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||g){g=U.T,U.T=null,k=Q.p,Q.p=2,$=Ct,Ct|=4;try{jE(s,i,h)}finally{Ct=$,Q.p=k,U.T=g}}hn=1,__(),b_(),v_()}}function __(){if(hn===1){hn=0;var s=Ms,i=_a,h=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||h){h=U.T,U.T=null;var g=Q.p;Q.p=2;var k=Ct;Ct|=4;try{Zy(i,s);var N=Sf,$=ix(s.containerInfo),Y=N.focusedElem,ie=N.selectionRange;if($!==Y&&Y&&Y.ownerDocument&&sx(Y.ownerDocument.documentElement,Y)){if(ie!==null&&Wd(Y)){var de=ie.start,Se=ie.end;if(Se===void 0&&(Se=de),"selectionStart"in Y)Y.selectionStart=de,Y.selectionEnd=Math.min(Se,Y.value.length);else{var Ee=Y.ownerDocument||document,fe=Ee&&Ee.defaultView||window;if(fe.getSelection){var ge=fe.getSelection(),Ue=Y.textContent.length,Je=Math.min(ie.start,Ue),Dt=ie.end===void 0?Je:Math.min(ie.end,Ue);!ge.extend&&Je>Dt&&($=Dt,Dt=Je,Je=$);var le=rx(Y,Je),ae=rx(Y,Dt);if(le&&ae&&(ge.rangeCount!==1||ge.anchorNode!==le.node||ge.anchorOffset!==le.offset||ge.focusNode!==ae.node||ge.focusOffset!==ae.offset)){var ue=Ee.createRange();ue.setStart(le.node,le.offset),ge.removeAllRanges(),Je>Dt?(ge.addRange(ue),ge.extend(ae.node,ae.offset)):(ue.setEnd(ae.node,ae.offset),ge.addRange(ue))}}}}for(Ee=[],ge=Y;ge=ge.parentNode;)ge.nodeType===1&&Ee.push({element:ge,left:ge.scrollLeft,top:ge.scrollTop});for(typeof Y.focus=="function"&&Y.focus(),Y=0;Y<Ee.length;Y++){var Ce=Ee[Y];Ce.element.scrollLeft=Ce.left,Ce.element.scrollTop=Ce.top}}Vc=!!vf,Sf=vf=null}finally{Ct=k,Q.p=g,U.T=h}}s.current=i,hn=2}}function b_(){if(hn===2){hn=0;var s=Ms,i=_a,h=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||h){h=U.T,U.T=null;var g=Q.p;Q.p=2;var k=Ct;Ct|=4;try{Ky(s,i.alternate,i)}finally{Ct=k,Q.p=g,U.T=h}}hn=3}}function v_(){if(hn===4||hn===3){hn=0,Ze();var s=Ms,i=_a,h=us,g=o_;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?hn=5:(hn=0,_a=Ms=null,S_(s,s.pendingLanes));var k=s.pendingLanes;if(k===0&&(Os=null),nt(h),i=i.stateNode,Oe&&typeof Oe.onCommitFiberRoot=="function")try{Oe.onCommitFiberRoot(me,i,void 0,(i.current.flags&128)===128)}catch{}if(g!==null){i=U.T,k=Q.p,Q.p=2,U.T=null;try{for(var N=s.onRecoverableError,$=0;$<g.length;$++){var Y=g[$];N(Y.value,{componentStack:Y.stack})}}finally{U.T=i,Q.p=k}}(us&3)!==0&&Dc(),Br(s),k=s.pendingLanes,(h&261930)!==0&&(k&42)!==0?s===lf?Io++:(Io=0,lf=s):Io=0,Po(0)}}function S_(s,i){(s.pooledCacheLanes&=i)===0&&(i=s.pooledCache,i!=null&&(s.pooledCache=null,xo(i)))}function Dc(){return __(),b_(),v_(),w_()}function w_(){if(hn!==5)return!1;var s=Ms,i=af;af=0;var h=nt(us),g=U.T,k=Q.p;try{Q.p=32>h?32:h,U.T=null,h=of,of=null;var N=Ms,$=us;if(hn=0,_a=Ms=null,us=0,(Ct&6)!==0)throw Error(r(331));var Y=Ct;if(Ct|=4,s_(N.current),t_(N,N.current,$,h),Ct=Y,Po(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot=="function")try{Oe.onPostCommitFiberRoot(me,N)}catch{}return!0}finally{Q.p=k,U.T=g,S_(s,i)}}function C_(s,i,h){i=hr(h,i),i=$h(s.stateNode,i,2),s=Ns(s,i,2),s!==null&&(Cr(s,2),Br(s))}function Tt(s,i,h){if(s.tag===3)C_(s,s,h);else for(;i!==null;){if(i.tag===3){C_(i,s,h);break}else if(i.tag===1){var g=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Os===null||!Os.has(g))){s=hr(h,s),h=ky(2),g=Ns(i,h,2),g!==null&&(Ey(h,g,i,s),Cr(g,2),Br(g));break}}i=i.return}}function df(s,i,h){var g=s.pingCache;if(g===null){g=s.pingCache=new AE;var k=new Set;g.set(i,k)}else k=g.get(i),k===void 0&&(k=new Set,g.set(i,k));k.has(h)||(nf=!0,k.add(h),s=ME.bind(null,s,i,h),i.then(s,s))}function ME(s,i,h){var g=s.pingCache;g!==null&&g.delete(i),s.pingedLanes|=s.suspendedLanes&h,s.warmLanes&=~h,It===s&&(gt&h)===h&&(Kt===4||Kt===3&&(gt&62914560)===gt&&300>it()-Ec?(Ct&2)===0&&ba(s,0):rf|=h,ya===gt&&(ya=0)),Br(s)}function k_(s,i){i===0&&(i=Mn()),s=li(s,i),s!==null&&(Cr(s,i),Br(s))}function IE(s){var i=s.memoizedState,h=0;i!==null&&(h=i.retryLane),k_(s,h)}function PE(s,i){var h=0;switch(s.tag){case 31:case 13:var g=s.stateNode,k=s.memoizedState;k!==null&&(h=k.retryLane);break;case 19:g=s.stateNode;break;case 22:g=s.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(i),k_(s,h)}function BE(s,i){return se(s,i)}var Rc=null,Sa=null,hf=!1,Oc=!1,ff=!1,Ps=0;function Br(s){s!==Sa&&s.next===null&&(Sa===null?Rc=Sa=s:Sa=Sa.next=s),Oc=!0,hf||(hf=!0,zE())}function Po(s,i){if(!ff&&Oc){ff=!0;do for(var h=!1,g=Rc;g!==null;){if(s!==0){var k=g.pendingLanes;if(k===0)var N=0;else{var $=g.suspendedLanes,Y=g.pingedLanes;N=(1<<31-et(42|s)+1)-1,N&=k&~($&~Y),N=N&201326741?N&201326741|1:N?N|2:0}N!==0&&(h=!0,T_(g,N))}else N=gt,N=Ae(g,g===It?N:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(N&3)===0||Qe(g,N)||(h=!0,T_(g,N));g=g.next}while(h);ff=!1}}function $E(){E_()}function E_(){Oc=hf=!1;var s=0;Ps!==0&&XE()&&(s=Ps);for(var i=it(),h=null,g=Rc;g!==null;){var k=g.next,N=j_(g,i);N===0?(g.next=null,h===null?Rc=k:h.next=k,k===null&&(Sa=h)):(h=g,(s!==0||(N&3)!==0)&&(Oc=!0)),g=k}hn!==0&&hn!==5||Po(s),Ps!==0&&(Ps=0)}function j_(s,i){for(var h=s.suspendedLanes,g=s.pingedLanes,k=s.expirationTimes,N=s.pendingLanes&-62914561;0<N;){var $=31-et(N),Y=1<<$,ie=k[$];ie===-1?((Y&h)===0||(Y&g)!==0)&&(k[$]=Bt(Y,i)):ie<=i&&(s.expiredLanes|=Y),N&=~Y}if(i=It,h=gt,h=Ae(s,s===i?h:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g=s.callbackNode,h===0||s===i&&(Nt===2||Nt===9)||s.cancelPendingCommit!==null)return g!==null&&g!==null&&xe(g),s.callbackNode=null,s.callbackPriority=0;if((h&3)===0||Qe(s,h)){if(i=h&-h,i===s.callbackPriority)return i;switch(g!==null&&xe(g),nt(h)){case 2:case 8:h=Te;break;case 32:h=Fe;break;case 268435456:h=tt;break;default:h=Fe}return g=N_.bind(null,s),h=se(h,g),s.callbackPriority=i,s.callbackNode=h,i}return g!==null&&g!==null&&xe(g),s.callbackPriority=2,s.callbackNode=null,2}function N_(s,i){if(hn!==0&&hn!==5)return s.callbackNode=null,s.callbackPriority=0,null;var h=s.callbackNode;if(Dc()&&s.callbackNode!==h)return null;var g=gt;return g=Ae(s,s===It?g:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g===0?null:(c_(s,g,i),j_(s,it()),s.callbackNode!=null&&s.callbackNode===h?N_.bind(null,s):null)}function T_(s,i){if(Dc())return null;c_(s,i,!0)}function zE(){JE(function(){(Ct&6)!==0?se(ce,$E):E_()})}function mf(){if(Ps===0){var s=oa;s===0&&(s=Qn,Qn<<=1,(Qn&261888)===0&&(Qn=256)),Ps=s}return Ps}function A_(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:Ul(""+s)}function L_(s,i){var h=i.ownerDocument.createElement("input");return h.name=i.name,h.value=i.value,s.id&&h.setAttribute("form",s.id),i.parentNode.insertBefore(h,i),s=new FormData(s),h.parentNode.removeChild(h),s}function HE(s,i,h,g,k){if(i==="submit"&&h&&h.stateNode===k){var N=A_((k[In]||null).action),$=g.submitter;$&&(i=(i=$[In]||null)?A_(i.formAction):$.getAttribute("formAction"),i!==null&&(N=i,$=null));var Y=new Wl("action","action",null,g,k);s.push({event:Y,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(Ps!==0){var ie=$?L_(k,$):new FormData(k);Rh(h,{pending:!0,data:ie,method:k.method,action:N},null,ie)}}else typeof N=="function"&&(Y.preventDefault(),ie=$?L_(k,$):new FormData(k),Rh(h,{pending:!0,data:ie,method:k.method,action:N},N,ie))},currentTarget:k}]})}}for(var pf=0;pf<Xd.length;pf++){var gf=Xd[pf],UE=gf.toLowerCase(),FE=gf[0].toUpperCase()+gf.slice(1);kr(UE,"on"+FE)}kr(lx,"onAnimationEnd"),kr(cx,"onAnimationIteration"),kr(ux,"onAnimationStart"),kr("dblclick","onDoubleClick"),kr("focusin","onFocus"),kr("focusout","onBlur"),kr(iE,"onTransitionRun"),kr(aE,"onTransitionStart"),kr(oE,"onTransitionCancel"),kr(dx,"onTransitionEnd"),qi("onMouseEnter",["mouseout","mouseover"]),qi("onMouseLeave",["mouseout","mouseover"]),qi("onPointerEnter",["pointerout","pointerover"]),qi("onPointerLeave",["pointerout","pointerover"]),si("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),si("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),si("onBeforeInput",["compositionend","keypress","textInput","paste"]),si("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bo="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(" "),VE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Bo));function D_(s,i){i=(i&4)!==0;for(var h=0;h<s.length;h++){var g=s[h],k=g.event;g=g.listeners;e:{var N=void 0;if(i)for(var $=g.length-1;0<=$;$--){var Y=g[$],ie=Y.instance,de=Y.currentTarget;if(Y=Y.listener,ie!==N&&k.isPropagationStopped())break e;N=Y,k.currentTarget=de;try{N(k)}catch(Se){Yl(Se)}k.currentTarget=null,N=ie}else for($=0;$<g.length;$++){if(Y=g[$],ie=Y.instance,de=Y.currentTarget,Y=Y.listener,ie!==N&&k.isPropagationStopped())break e;N=Y,k.currentTarget=de;try{N(k)}catch(Se){Yl(Se)}k.currentTarget=null,N=ie}}}}function mt(s,i){var h=i[Nd];h===void 0&&(h=i[Nd]=new Set);var g=s+"__bubble";h.has(g)||(R_(i,s,2,!1),h.add(g))}function xf(s,i,h){var g=0;i&&(g|=4),R_(h,s,g,i)}var Mc="_reactListening"+Math.random().toString(36).slice(2);function yf(s){if(!s[Mc]){s[Mc]=!0,Eg.forEach(function(h){h!=="selectionchange"&&(VE.has(h)||xf(h,!1,s),xf(h,!0,s))});var i=s.nodeType===9?s:s.ownerDocument;i===null||i[Mc]||(i[Mc]=!0,xf("selectionchange",!1,i))}}function R_(s,i,h,g){switch(lb(i)){case 2:var k=y2;break;case 8:k=_2;break;default:k=Rf}h=k.bind(null,i,h,s),k=void 0,!Pd||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(k=!0),g?k!==void 0?s.addEventListener(i,h,{capture:!0,passive:k}):s.addEventListener(i,h,!0):k!==void 0?s.addEventListener(i,h,{passive:k}):s.addEventListener(i,h,!1)}function _f(s,i,h,g,k){var N=g;if((i&1)===0&&(i&2)===0&&g!==null)e:for(;;){if(g===null)return;var $=g.tag;if($===3||$===4){var Y=g.stateNode.containerInfo;if(Y===k)break;if($===4)for($=g.return;$!==null;){var ie=$.tag;if((ie===3||ie===4)&&$.stateNode.containerInfo===k)return;$=$.return}for(;Y!==null;){if($=Vi(Y),$===null)return;if(ie=$.tag,ie===5||ie===6||ie===26||ie===27){g=N=$;continue e}Y=Y.parentNode}}g=g.return}Bg(function(){var de=N,Se=Md(h),Ee=[];e:{var fe=hx.get(s);if(fe!==void 0){var ge=Wl,Ue=s;switch(s){case"keypress":if(Vl(h)===0)break e;case"keydown":case"keyup":ge=Pk;break;case"focusin":Ue="focus",ge=Hd;break;case"focusout":Ue="blur",ge=Hd;break;case"beforeblur":case"afterblur":ge=Hd;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ge=Hg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ge=kk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ge=zk;break;case lx:case cx:case ux:ge=Nk;break;case dx:ge=Uk;break;case"scroll":case"scrollend":ge=wk;break;case"wheel":ge=Vk;break;case"copy":case"cut":case"paste":ge=Ak;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ge=Fg;break;case"toggle":case"beforetoggle":ge=Wk}var Je=(i&4)!==0,Dt=!Je&&(s==="scroll"||s==="scrollend"),le=Je?fe!==null?fe+"Capture":null:fe;Je=[];for(var ae=de,ue;ae!==null;){var Ce=ae;if(ue=Ce.stateNode,Ce=Ce.tag,Ce!==5&&Ce!==26&&Ce!==27||ue===null||le===null||(Ce=io(ae,le),Ce!=null&&Je.push($o(ae,Ce,ue))),Dt)break;ae=ae.return}0<Je.length&&(fe=new ge(fe,Ue,null,h,Se),Ee.push({event:fe,listeners:Je}))}}if((i&7)===0){e:{if(fe=s==="mouseover"||s==="pointerover",ge=s==="mouseout"||s==="pointerout",fe&&h!==Od&&(Ue=h.relatedTarget||h.fromElement)&&(Vi(Ue)||Ue[Fi]))break e;if((ge||fe)&&(fe=Se.window===Se?Se:(fe=Se.ownerDocument)?fe.defaultView||fe.parentWindow:window,ge?(Ue=h.relatedTarget||h.toElement,ge=de,Ue=Ue?Vi(Ue):null,Ue!==null&&(Dt=l(Ue),Je=Ue.tag,Ue!==Dt||Je!==5&&Je!==27&&Je!==6)&&(Ue=null)):(ge=null,Ue=de),ge!==Ue)){if(Je=Hg,Ce="onMouseLeave",le="onMouseEnter",ae="mouse",(s==="pointerout"||s==="pointerover")&&(Je=Fg,Ce="onPointerLeave",le="onPointerEnter",ae="pointer"),Dt=ge==null?fe:so(ge),ue=Ue==null?fe:so(Ue),fe=new Je(Ce,ae+"leave",ge,h,Se),fe.target=Dt,fe.relatedTarget=ue,Ce=null,Vi(Se)===de&&(Je=new Je(le,ae+"enter",Ue,h,Se),Je.target=ue,Je.relatedTarget=Dt,Ce=Je),Dt=Ce,ge&&Ue)t:{for(Je=GE,le=ge,ae=Ue,ue=0,Ce=le;Ce;Ce=Je(Ce))ue++;Ce=0;for(var Ke=ae;Ke;Ke=Je(Ke))Ce++;for(;0<ue-Ce;)le=Je(le),ue--;for(;0<Ce-ue;)ae=Je(ae),Ce--;for(;ue--;){if(le===ae||ae!==null&&le===ae.alternate){Je=le;break t}le=Je(le),ae=Je(ae)}Je=null}else Je=null;ge!==null&&O_(Ee,fe,ge,Je,!1),Ue!==null&&Dt!==null&&O_(Ee,Dt,Ue,Je,!0)}}e:{if(fe=de?so(de):window,ge=fe.nodeName&&fe.nodeName.toLowerCase(),ge==="select"||ge==="input"&&fe.type==="file")var vt=Qg;else if(Yg(fe))if(Jg)vt=nE;else{vt=eE;var Ge=Zk}else ge=fe.nodeName,!ge||ge.toLowerCase()!=="input"||fe.type!=="checkbox"&&fe.type!=="radio"?de&&Rd(de.elementType)&&(vt=Qg):vt=tE;if(vt&&(vt=vt(s,de))){Xg(Ee,vt,h,Se);break e}Ge&&Ge(s,fe,de),s==="focusout"&&de&&fe.type==="number"&&de.memoizedProps.value!=null&&Dd(fe,"number",fe.value)}switch(Ge=de?so(de):window,s){case"focusin":(Yg(Ge)||Ge.contentEditable==="true")&&(Zi=Ge,qd=de,mo=null);break;case"focusout":mo=qd=Zi=null;break;case"mousedown":Kd=!0;break;case"contextmenu":case"mouseup":case"dragend":Kd=!1,ax(Ee,h,Se);break;case"selectionchange":if(sE)break;case"keydown":case"keyup":ax(Ee,h,Se)}var ut;if(Fd)e:{switch(s){case"compositionstart":var xt="onCompositionStart";break e;case"compositionend":xt="onCompositionEnd";break e;case"compositionupdate":xt="onCompositionUpdate";break e}xt=void 0}else Ji?qg(s,h)&&(xt="onCompositionEnd"):s==="keydown"&&h.keyCode===229&&(xt="onCompositionStart");xt&&(Vg&&h.locale!=="ko"&&(Ji||xt!=="onCompositionStart"?xt==="onCompositionEnd"&&Ji&&(ut=$g()):(vs=Se,Bd="value"in vs?vs.value:vs.textContent,Ji=!0)),Ge=Ic(de,xt),0<Ge.length&&(xt=new Ug(xt,s,null,h,Se),Ee.push({event:xt,listeners:Ge}),ut?xt.data=ut:(ut=Kg(h),ut!==null&&(xt.data=ut)))),(ut=Kk?Yk(s,h):Xk(s,h))&&(xt=Ic(de,"onBeforeInput"),0<xt.length&&(Ge=new Ug("onBeforeInput","beforeinput",null,h,Se),Ee.push({event:Ge,listeners:xt}),Ge.data=ut)),HE(Ee,s,de,h,Se)}D_(Ee,i)})}function $o(s,i,h){return{instance:s,listener:i,currentTarget:h}}function Ic(s,i){for(var h=i+"Capture",g=[];s!==null;){var k=s,N=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||N===null||(k=io(s,h),k!=null&&g.unshift($o(s,k,N)),k=io(s,i),k!=null&&g.push($o(s,k,N))),s.tag===3)return g;s=s.return}return[]}function GE(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function O_(s,i,h,g,k){for(var N=i._reactName,$=[];h!==null&&h!==g;){var Y=h,ie=Y.alternate,de=Y.stateNode;if(Y=Y.tag,ie!==null&&ie===g)break;Y!==5&&Y!==26&&Y!==27||de===null||(ie=de,k?(de=io(h,N),de!=null&&$.unshift($o(h,de,ie))):k||(de=io(h,N),de!=null&&$.push($o(h,de,ie)))),h=h.return}$.length!==0&&s.push({event:i,listeners:$})}var WE=/\r\n?/g,qE=/\u0000|\uFFFD/g;function M_(s){return(typeof s=="string"?s:""+s).replace(WE,`
|
|
50
|
+
`).replace(qE,"")}function I_(s,i){return i=M_(i),M_(s)===i}function Lt(s,i,h,g,k,N){switch(h){case"children":typeof g=="string"?i==="body"||i==="textarea"&&g===""||Yi(s,g):(typeof g=="number"||typeof g=="bigint")&&i!=="body"&&Yi(s,""+g);break;case"className":zl(s,"class",g);break;case"tabIndex":zl(s,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":zl(s,h,g);break;case"style":Ig(s,g,N);break;case"data":if(i!=="object"){zl(s,"data",g);break}case"src":case"href":if(g===""&&(i!=="a"||h!=="href")){s.removeAttribute(h);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(h);break}g=Ul(""+g),s.setAttribute(h,g);break;case"action":case"formAction":if(typeof g=="function"){s.setAttribute(h,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof N=="function"&&(h==="formAction"?(i!=="input"&&Lt(s,i,"name",k.name,k,null),Lt(s,i,"formEncType",k.formEncType,k,null),Lt(s,i,"formMethod",k.formMethod,k,null),Lt(s,i,"formTarget",k.formTarget,k,null)):(Lt(s,i,"encType",k.encType,k,null),Lt(s,i,"method",k.method,k,null),Lt(s,i,"target",k.target,k,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(h);break}g=Ul(""+g),s.setAttribute(h,g);break;case"onClick":g!=null&&(s.onclick=Yr);break;case"onScroll":g!=null&&mt("scroll",s);break;case"onScrollEnd":g!=null&&mt("scrollend",s);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(h=g.__html,h!=null){if(k.children!=null)throw Error(r(60));s.innerHTML=h}}break;case"multiple":s.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":s.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){s.removeAttribute("xlink:href");break}h=Ul(""+g),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",h);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(h,""+g):s.removeAttribute(h);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":g&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(h,""):s.removeAttribute(h);break;case"capture":case"download":g===!0?s.setAttribute(h,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(h,g):s.removeAttribute(h);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?s.setAttribute(h,g):s.removeAttribute(h);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?s.removeAttribute(h):s.setAttribute(h,g);break;case"popover":mt("beforetoggle",s),mt("toggle",s),$l(s,"popover",g);break;case"xlinkActuate":Kr(s,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Kr(s,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Kr(s,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Kr(s,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Kr(s,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Kr(s,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Kr(s,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Kr(s,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Kr(s,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":$l(s,"is",g);break;case"innerText":case"textContent":break;default:(!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(h=vk.get(h)||h,$l(s,h,g))}}function bf(s,i,h,g,k,N){switch(h){case"style":Ig(s,g,N);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(h=g.__html,h!=null){if(k.children!=null)throw Error(r(60));s.innerHTML=h}}break;case"children":typeof g=="string"?Yi(s,g):(typeof g=="number"||typeof g=="bigint")&&Yi(s,""+g);break;case"onScroll":g!=null&&mt("scroll",s);break;case"onScrollEnd":g!=null&&mt("scrollend",s);break;case"onClick":g!=null&&(s.onclick=Yr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!jg.hasOwnProperty(h))e:{if(h[0]==="o"&&h[1]==="n"&&(k=h.endsWith("Capture"),i=h.slice(2,k?h.length-7:void 0),N=s[In]||null,N=N!=null?N[h]:null,typeof N=="function"&&s.removeEventListener(i,N,k),typeof g=="function")){typeof N!="function"&&N!==null&&(h in s?s[h]=null:s.hasAttribute(h)&&s.removeAttribute(h)),s.addEventListener(i,g,k);break e}h in s?s[h]=g:g===!0?s.setAttribute(h,""):$l(s,h,g)}}}function Cn(s,i,h){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mt("error",s),mt("load",s);var g=!1,k=!1,N;for(N in h)if(h.hasOwnProperty(N)){var $=h[N];if($!=null)switch(N){case"src":g=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,i));default:Lt(s,i,N,$,h,null)}}k&&Lt(s,i,"srcSet",h.srcSet,h,null),g&&Lt(s,i,"src",h.src,h,null);return;case"input":mt("invalid",s);var Y=N=$=k=null,ie=null,de=null;for(g in h)if(h.hasOwnProperty(g)){var Se=h[g];if(Se!=null)switch(g){case"name":k=Se;break;case"type":$=Se;break;case"checked":ie=Se;break;case"defaultChecked":de=Se;break;case"value":N=Se;break;case"defaultValue":Y=Se;break;case"children":case"dangerouslySetInnerHTML":if(Se!=null)throw Error(r(137,i));break;default:Lt(s,i,g,Se,h,null)}}Dg(s,N,Y,ie,de,$,k,!1);return;case"select":mt("invalid",s),g=$=N=null;for(k in h)if(h.hasOwnProperty(k)&&(Y=h[k],Y!=null))switch(k){case"value":N=Y;break;case"defaultValue":$=Y;break;case"multiple":g=Y;default:Lt(s,i,k,Y,h,null)}i=N,h=$,s.multiple=!!g,i!=null?Ki(s,!!g,i,!1):h!=null&&Ki(s,!!g,h,!0);return;case"textarea":mt("invalid",s),N=k=g=null;for($ in h)if(h.hasOwnProperty($)&&(Y=h[$],Y!=null))switch($){case"value":g=Y;break;case"defaultValue":k=Y;break;case"children":N=Y;break;case"dangerouslySetInnerHTML":if(Y!=null)throw Error(r(91));break;default:Lt(s,i,$,Y,h,null)}Og(s,g,k,N);return;case"option":for(ie in h)if(h.hasOwnProperty(ie)&&(g=h[ie],g!=null))switch(ie){case"selected":s.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:Lt(s,i,ie,g,h,null)}return;case"dialog":mt("beforetoggle",s),mt("toggle",s),mt("cancel",s),mt("close",s);break;case"iframe":case"object":mt("load",s);break;case"video":case"audio":for(g=0;g<Bo.length;g++)mt(Bo[g],s);break;case"image":mt("error",s),mt("load",s);break;case"details":mt("toggle",s);break;case"embed":case"source":case"link":mt("error",s),mt("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(de in h)if(h.hasOwnProperty(de)&&(g=h[de],g!=null))switch(de){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,i));default:Lt(s,i,de,g,h,null)}return;default:if(Rd(i)){for(Se in h)h.hasOwnProperty(Se)&&(g=h[Se],g!==void 0&&bf(s,i,Se,g,h,void 0));return}}for(Y in h)h.hasOwnProperty(Y)&&(g=h[Y],g!=null&&Lt(s,i,Y,g,h,null))}function KE(s,i,h,g){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var k=null,N=null,$=null,Y=null,ie=null,de=null,Se=null;for(ge in h){var Ee=h[ge];if(h.hasOwnProperty(ge)&&Ee!=null)switch(ge){case"checked":break;case"value":break;case"defaultValue":ie=Ee;default:g.hasOwnProperty(ge)||Lt(s,i,ge,null,g,Ee)}}for(var fe in g){var ge=g[fe];if(Ee=h[fe],g.hasOwnProperty(fe)&&(ge!=null||Ee!=null))switch(fe){case"type":N=ge;break;case"name":k=ge;break;case"checked":de=ge;break;case"defaultChecked":Se=ge;break;case"value":$=ge;break;case"defaultValue":Y=ge;break;case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(r(137,i));break;default:ge!==Ee&&Lt(s,i,fe,ge,g,Ee)}}Ld(s,$,Y,ie,de,Se,N,k);return;case"select":ge=$=Y=fe=null;for(N in h)if(ie=h[N],h.hasOwnProperty(N)&&ie!=null)switch(N){case"value":break;case"multiple":ge=ie;default:g.hasOwnProperty(N)||Lt(s,i,N,null,g,ie)}for(k in g)if(N=g[k],ie=h[k],g.hasOwnProperty(k)&&(N!=null||ie!=null))switch(k){case"value":fe=N;break;case"defaultValue":Y=N;break;case"multiple":$=N;default:N!==ie&&Lt(s,i,k,N,g,ie)}i=Y,h=$,g=ge,fe!=null?Ki(s,!!h,fe,!1):!!g!=!!h&&(i!=null?Ki(s,!!h,i,!0):Ki(s,!!h,h?[]:"",!1));return;case"textarea":ge=fe=null;for(Y in h)if(k=h[Y],h.hasOwnProperty(Y)&&k!=null&&!g.hasOwnProperty(Y))switch(Y){case"value":break;case"children":break;default:Lt(s,i,Y,null,g,k)}for($ in g)if(k=g[$],N=h[$],g.hasOwnProperty($)&&(k!=null||N!=null))switch($){case"value":fe=k;break;case"defaultValue":ge=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(r(91));break;default:k!==N&&Lt(s,i,$,k,g,N)}Rg(s,fe,ge);return;case"option":for(var Ue in h)if(fe=h[Ue],h.hasOwnProperty(Ue)&&fe!=null&&!g.hasOwnProperty(Ue))switch(Ue){case"selected":s.selected=!1;break;default:Lt(s,i,Ue,null,g,fe)}for(ie in g)if(fe=g[ie],ge=h[ie],g.hasOwnProperty(ie)&&fe!==ge&&(fe!=null||ge!=null))switch(ie){case"selected":s.selected=fe&&typeof fe!="function"&&typeof fe!="symbol";break;default:Lt(s,i,ie,fe,g,ge)}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 Je in h)fe=h[Je],h.hasOwnProperty(Je)&&fe!=null&&!g.hasOwnProperty(Je)&&Lt(s,i,Je,null,g,fe);for(de in g)if(fe=g[de],ge=h[de],g.hasOwnProperty(de)&&fe!==ge&&(fe!=null||ge!=null))switch(de){case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(137,i));break;default:Lt(s,i,de,fe,g,ge)}return;default:if(Rd(i)){for(var Dt in h)fe=h[Dt],h.hasOwnProperty(Dt)&&fe!==void 0&&!g.hasOwnProperty(Dt)&&bf(s,i,Dt,void 0,g,fe);for(Se in g)fe=g[Se],ge=h[Se],!g.hasOwnProperty(Se)||fe===ge||fe===void 0&&ge===void 0||bf(s,i,Se,fe,g,ge);return}}for(var le in h)fe=h[le],h.hasOwnProperty(le)&&fe!=null&&!g.hasOwnProperty(le)&&Lt(s,i,le,null,g,fe);for(Ee in g)fe=g[Ee],ge=h[Ee],!g.hasOwnProperty(Ee)||fe===ge||fe==null&&ge==null||Lt(s,i,Ee,fe,g,ge)}function P_(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function YE(){if(typeof performance.getEntriesByType=="function"){for(var s=0,i=0,h=performance.getEntriesByType("resource"),g=0;g<h.length;g++){var k=h[g],N=k.transferSize,$=k.initiatorType,Y=k.duration;if(N&&Y&&P_($)){for($=0,Y=k.responseEnd,g+=1;g<h.length;g++){var ie=h[g],de=ie.startTime;if(de>Y)break;var Se=ie.transferSize,Ee=ie.initiatorType;Se&&P_(Ee)&&(ie=ie.responseEnd,$+=Se*(ie<Y?1:(Y-de)/(ie-de)))}if(--g,i+=8*(N+$)/(k.duration/1e3),s++,10<s)break}}if(0<s)return i/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var vf=null,Sf=null;function Pc(s){return s.nodeType===9?s:s.ownerDocument}function B_(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function $_(s,i){if(s===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&i==="foreignObject"?0:s}function wf(s,i){return s==="textarea"||s==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Cf=null;function XE(){var s=window.event;return s&&s.type==="popstate"?s===Cf?!1:(Cf=s,!0):(Cf=null,!1)}var z_=typeof setTimeout=="function"?setTimeout:void 0,QE=typeof clearTimeout=="function"?clearTimeout:void 0,H_=typeof Promise=="function"?Promise:void 0,JE=typeof queueMicrotask=="function"?queueMicrotask:typeof H_<"u"?function(s){return H_.resolve(null).then(s).catch(ZE)}:z_;function ZE(s){setTimeout(function(){throw s})}function Bs(s){return s==="head"}function U_(s,i){var h=i,g=0;do{var k=h.nextSibling;if(s.removeChild(h),k&&k.nodeType===8)if(h=k.data,h==="/$"||h==="/&"){if(g===0){s.removeChild(k),Ea(i);return}g--}else if(h==="$"||h==="$?"||h==="$~"||h==="$!"||h==="&")g++;else if(h==="html")zo(s.ownerDocument.documentElement);else if(h==="head"){h=s.ownerDocument.head,zo(h);for(var N=h.firstChild;N;){var $=N.nextSibling,Y=N.nodeName;N[ro]||Y==="SCRIPT"||Y==="STYLE"||Y==="LINK"&&N.rel.toLowerCase()==="stylesheet"||h.removeChild(N),N=$}}else h==="body"&&zo(s.ownerDocument.body);h=k}while(h);Ea(i)}function F_(s,i){var h=s;s=0;do{var g=h.nextSibling;if(h.nodeType===1?i?(h._stashedDisplay=h.style.display,h.style.display="none"):(h.style.display=h._stashedDisplay||"",h.getAttribute("style")===""&&h.removeAttribute("style")):h.nodeType===3&&(i?(h._stashedText=h.nodeValue,h.nodeValue=""):h.nodeValue=h._stashedText||""),g&&g.nodeType===8)if(h=g.data,h==="/$"){if(s===0)break;s--}else h!=="$"&&h!=="$?"&&h!=="$~"&&h!=="$!"||s++;h=g}while(h)}function kf(s){var i=s.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var h=i;switch(i=i.nextSibling,h.nodeName){case"HTML":case"HEAD":case"BODY":kf(h),Td(h);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(h.rel.toLowerCase()==="stylesheet")continue}s.removeChild(h)}}function e2(s,i,h,g){for(;s.nodeType===1;){var k=h;if(s.nodeName.toLowerCase()!==i.toLowerCase()){if(!g&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(g){if(!s[ro])switch(i){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(N=s.getAttribute("rel"),N==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(N!==k.rel||s.getAttribute("href")!==(k.href==null||k.href===""?null:k.href)||s.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin)||s.getAttribute("title")!==(k.title==null?null:k.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(N=s.getAttribute("src"),(N!==(k.src==null?null:k.src)||s.getAttribute("type")!==(k.type==null?null:k.type)||s.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&N&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(i==="input"&&s.type==="hidden"){var N=k.name==null?null:""+k.name;if(k.type==="hidden"&&s.getAttribute("name")===N)return s}else return s;if(s=xr(s.nextSibling),s===null)break}return null}function t2(s,i,h){if(i==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!h||(s=xr(s.nextSibling),s===null))return null;return s}function V_(s,i){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!i||(s=xr(s.nextSibling),s===null))return null;return s}function Ef(s){return s.data==="$?"||s.data==="$~"}function jf(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function n2(s,i){var h=s.ownerDocument;if(s.data==="$~")s._reactRetry=i;else if(s.data!=="$?"||h.readyState!=="loading")i();else{var g=function(){i(),h.removeEventListener("DOMContentLoaded",g)};h.addEventListener("DOMContentLoaded",g),s._reactRetry=g}}function xr(s){for(;s!=null;s=s.nextSibling){var i=s.nodeType;if(i===1||i===3)break;if(i===8){if(i=s.data,i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"||i==="F!"||i==="F")break;if(i==="/$"||i==="/&")return null}}return s}var Nf=null;function G_(s){s=s.nextSibling;for(var i=0;s;){if(s.nodeType===8){var h=s.data;if(h==="/$"||h==="/&"){if(i===0)return xr(s.nextSibling);i--}else h!=="$"&&h!=="$!"&&h!=="$?"&&h!=="$~"&&h!=="&"||i++}s=s.nextSibling}return null}function W_(s){s=s.previousSibling;for(var i=0;s;){if(s.nodeType===8){var h=s.data;if(h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"){if(i===0)return s;i--}else h!=="/$"&&h!=="/&"||i++}s=s.previousSibling}return null}function q_(s,i,h){switch(i=Pc(h),s){case"html":if(s=i.documentElement,!s)throw Error(r(452));return s;case"head":if(s=i.head,!s)throw Error(r(453));return s;case"body":if(s=i.body,!s)throw Error(r(454));return s;default:throw Error(r(451))}}function zo(s){for(var i=s.attributes;i.length;)s.removeAttributeNode(i[0]);Td(s)}var yr=new Map,K_=new Set;function Bc(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var ds=Q.d;Q.d={f:r2,r:s2,D:i2,C:a2,L:o2,m:l2,X:u2,S:c2,M:d2};function r2(){var s=ds.f(),i=Tc();return s||i}function s2(s){var i=Gi(s);i!==null&&i.tag===5&&i.type==="form"?dy(i):ds.r(s)}var wa=typeof document>"u"?null:document;function Y_(s,i,h){var g=wa;if(g&&typeof i=="string"&&i){var k=ur(i);k='link[rel="'+s+'"][href="'+k+'"]',typeof h=="string"&&(k+='[crossorigin="'+h+'"]'),K_.has(k)||(K_.add(k),s={rel:s,crossOrigin:h,href:i},g.querySelector(k)===null&&(i=g.createElement("link"),Cn(i,"link",s),gn(i),g.head.appendChild(i)))}}function i2(s){ds.D(s),Y_("dns-prefetch",s,null)}function a2(s,i){ds.C(s,i),Y_("preconnect",s,i)}function o2(s,i,h){ds.L(s,i,h);var g=wa;if(g&&s&&i){var k='link[rel="preload"][as="'+ur(i)+'"]';i==="image"&&h&&h.imageSrcSet?(k+='[imagesrcset="'+ur(h.imageSrcSet)+'"]',typeof h.imageSizes=="string"&&(k+='[imagesizes="'+ur(h.imageSizes)+'"]')):k+='[href="'+ur(s)+'"]';var N=k;switch(i){case"style":N=Ca(s);break;case"script":N=ka(s)}yr.has(N)||(s=m({rel:"preload",href:i==="image"&&h&&h.imageSrcSet?void 0:s,as:i},h),yr.set(N,s),g.querySelector(k)!==null||i==="style"&&g.querySelector(Ho(N))||i==="script"&&g.querySelector(Uo(N))||(i=g.createElement("link"),Cn(i,"link",s),gn(i),g.head.appendChild(i)))}}function l2(s,i){ds.m(s,i);var h=wa;if(h&&s){var g=i&&typeof i.as=="string"?i.as:"script",k='link[rel="modulepreload"][as="'+ur(g)+'"][href="'+ur(s)+'"]',N=k;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":N=ka(s)}if(!yr.has(N)&&(s=m({rel:"modulepreload",href:s},i),yr.set(N,s),h.querySelector(k)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(h.querySelector(Uo(N)))return}g=h.createElement("link"),Cn(g,"link",s),gn(g),h.head.appendChild(g)}}}function c2(s,i,h){ds.S(s,i,h);var g=wa;if(g&&s){var k=Wi(g).hoistableStyles,N=Ca(s);i=i||"default";var $=k.get(N);if(!$){var Y={loading:0,preload:null};if($=g.querySelector(Ho(N)))Y.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":i},h),(h=yr.get(N))&&Tf(s,h);var ie=$=g.createElement("link");gn(ie),Cn(ie,"link",s),ie._p=new Promise(function(de,Se){ie.onload=de,ie.onerror=Se}),ie.addEventListener("load",function(){Y.loading|=1}),ie.addEventListener("error",function(){Y.loading|=2}),Y.loading|=4,$c($,i,g)}$={type:"stylesheet",instance:$,count:1,state:Y},k.set(N,$)}}}function u2(s,i){ds.X(s,i);var h=wa;if(h&&s){var g=Wi(h).hoistableScripts,k=ka(s),N=g.get(k);N||(N=h.querySelector(Uo(k)),N||(s=m({src:s,async:!0},i),(i=yr.get(k))&&Af(s,i),N=h.createElement("script"),gn(N),Cn(N,"link",s),h.head.appendChild(N)),N={type:"script",instance:N,count:1,state:null},g.set(k,N))}}function d2(s,i){ds.M(s,i);var h=wa;if(h&&s){var g=Wi(h).hoistableScripts,k=ka(s),N=g.get(k);N||(N=h.querySelector(Uo(k)),N||(s=m({src:s,async:!0,type:"module"},i),(i=yr.get(k))&&Af(s,i),N=h.createElement("script"),gn(N),Cn(N,"link",s),h.head.appendChild(N)),N={type:"script",instance:N,count:1,state:null},g.set(k,N))}}function X_(s,i,h,g){var k=(k=ne.current)?Bc(k):null;if(!k)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof h.precedence=="string"&&typeof h.href=="string"?(i=Ca(h.href),h=Wi(k).hoistableStyles,g=h.get(i),g||(g={type:"style",instance:null,count:0,state:null},h.set(i,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(h.rel==="stylesheet"&&typeof h.href=="string"&&typeof h.precedence=="string"){s=Ca(h.href);var N=Wi(k).hoistableStyles,$=N.get(s);if($||(k=k.ownerDocument||k,$={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},N.set(s,$),(N=k.querySelector(Ho(s)))&&!N._p&&($.instance=N,$.state.loading=5),yr.has(s)||(h={rel:"preload",as:"style",href:h.href,crossOrigin:h.crossOrigin,integrity:h.integrity,media:h.media,hrefLang:h.hrefLang,referrerPolicy:h.referrerPolicy},yr.set(s,h),N||h2(k,s,h,$.state))),i&&g===null)throw Error(r(528,""));return $}if(i&&g!==null)throw Error(r(529,""));return null;case"script":return i=h.async,h=h.src,typeof h=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=ka(h),h=Wi(k).hoistableScripts,g=h.get(i),g||(g={type:"script",instance:null,count:0,state:null},h.set(i,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function Ca(s){return'href="'+ur(s)+'"'}function Ho(s){return'link[rel="stylesheet"]['+s+"]"}function Q_(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function h2(s,i,h,g){s.querySelector('link[rel="preload"][as="style"]['+i+"]")?g.loading=1:(i=s.createElement("link"),g.preload=i,i.addEventListener("load",function(){return g.loading|=1}),i.addEventListener("error",function(){return g.loading|=2}),Cn(i,"link",h),gn(i),s.head.appendChild(i))}function ka(s){return'[src="'+ur(s)+'"]'}function Uo(s){return"script[async]"+s}function J_(s,i,h){if(i.count++,i.instance===null)switch(i.type){case"style":var g=s.querySelector('style[data-href~="'+ur(h.href)+'"]');if(g)return i.instance=g,gn(g),g;var k=m({},h,{"data-href":h.href,"data-precedence":h.precedence,href:null,precedence:null});return g=(s.ownerDocument||s).createElement("style"),gn(g),Cn(g,"style",k),$c(g,h.precedence,s),i.instance=g;case"stylesheet":k=Ca(h.href);var N=s.querySelector(Ho(k));if(N)return i.state.loading|=4,i.instance=N,gn(N),N;g=Q_(h),(k=yr.get(k))&&Tf(g,k),N=(s.ownerDocument||s).createElement("link"),gn(N);var $=N;return $._p=new Promise(function(Y,ie){$.onload=Y,$.onerror=ie}),Cn(N,"link",g),i.state.loading|=4,$c(N,h.precedence,s),i.instance=N;case"script":return N=ka(h.src),(k=s.querySelector(Uo(N)))?(i.instance=k,gn(k),k):(g=h,(k=yr.get(N))&&(g=m({},h),Af(g,k)),s=s.ownerDocument||s,k=s.createElement("script"),gn(k),Cn(k,"link",g),s.head.appendChild(k),i.instance=k);case"void":return null;default:throw Error(r(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(g=i.instance,i.state.loading|=4,$c(g,h.precedence,s));return i.instance}function $c(s,i,h){for(var g=h.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=g.length?g[g.length-1]:null,N=k,$=0;$<g.length;$++){var Y=g[$];if(Y.dataset.precedence===i)N=Y;else if(N!==k)break}N?N.parentNode.insertBefore(s,N.nextSibling):(i=h.nodeType===9?h.head:h,i.insertBefore(s,i.firstChild))}function Tf(s,i){s.crossOrigin==null&&(s.crossOrigin=i.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=i.referrerPolicy),s.title==null&&(s.title=i.title)}function Af(s,i){s.crossOrigin==null&&(s.crossOrigin=i.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=i.referrerPolicy),s.integrity==null&&(s.integrity=i.integrity)}var zc=null;function Z_(s,i,h){if(zc===null){var g=new Map,k=zc=new Map;k.set(h,g)}else k=zc,g=k.get(h),g||(g=new Map,k.set(h,g));if(g.has(s))return g;for(g.set(s,null),h=h.getElementsByTagName(s),k=0;k<h.length;k++){var N=h[k];if(!(N[ro]||N[jt]||s==="link"&&N.getAttribute("rel")==="stylesheet")&&N.namespaceURI!=="http://www.w3.org/2000/svg"){var $=N.getAttribute(i)||"";$=s+$;var Y=g.get($);Y?Y.push(N):g.set($,[N])}}return g}function eb(s,i,h){s=s.ownerDocument||s,s.head.insertBefore(h,i==="title"?s.querySelector("head > title"):null)}function f2(s,i,h){if(h===1||i.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return s=i.disabled,typeof i.precedence=="string"&&s==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function tb(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function m2(s,i,h,g){if(h.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(h.state.loading&4)===0){if(h.instance===null){var k=Ca(g.href),N=i.querySelector(Ho(k));if(N){i=N._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(s.count++,s=Hc.bind(s),i.then(s,s)),h.state.loading|=4,h.instance=N,gn(N);return}N=i.ownerDocument||i,g=Q_(g),(k=yr.get(k))&&Tf(g,k),N=N.createElement("link"),gn(N);var $=N;$._p=new Promise(function(Y,ie){$.onload=Y,$.onerror=ie}),Cn(N,"link",g),h.instance=N}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(h,i),(i=h.state.preload)&&(h.state.loading&3)===0&&(s.count++,h=Hc.bind(s),i.addEventListener("load",h),i.addEventListener("error",h))}}var Lf=0;function p2(s,i){return s.stylesheets&&s.count===0&&Fc(s,s.stylesheets),0<s.count||0<s.imgCount?function(h){var g=setTimeout(function(){if(s.stylesheets&&Fc(s,s.stylesheets),s.unsuspend){var N=s.unsuspend;s.unsuspend=null,N()}},6e4+i);0<s.imgBytes&&Lf===0&&(Lf=62500*YE());var k=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&Fc(s,s.stylesheets),s.unsuspend)){var N=s.unsuspend;s.unsuspend=null,N()}},(s.imgBytes>Lf?50:800)+i);return s.unsuspend=h,function(){s.unsuspend=null,clearTimeout(g),clearTimeout(k)}}:null}function Hc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fc(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var Uc=null;function Fc(s,i){s.stylesheets=null,s.unsuspend!==null&&(s.count++,Uc=new Map,i.forEach(g2,s),Uc=null,Hc.call(s))}function g2(s,i){if(!(i.state.loading&4)){var h=Uc.get(s);if(h)var g=h.get(null);else{h=new Map,Uc.set(s,h);for(var k=s.querySelectorAll("link[data-precedence],style[data-precedence]"),N=0;N<k.length;N++){var $=k[N];($.nodeName==="LINK"||$.getAttribute("media")!=="not all")&&(h.set($.dataset.precedence,$),g=$)}g&&h.set(null,g)}k=i.instance,$=k.getAttribute("data-precedence"),N=h.get($)||g,N===g&&h.set(null,k),h.set($,k),this.count++,g=Hc.bind(this),k.addEventListener("load",g),k.addEventListener("error",g),N?N.parentNode.insertBefore(k,N.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(k,s.firstChild)),i.state.loading|=4}}var Fo={$$typeof:_,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function x2(s,i,h,g,k,N,$,Y,ie){this.tag=1,this.containerInfo=s,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=bn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bn(0),this.hiddenUpdates=bn(null),this.identifierPrefix=g,this.onUncaughtError=k,this.onCaughtError=N,this.onRecoverableError=$,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function nb(s,i,h,g,k,N,$,Y,ie,de,Se,Ee){return s=new x2(s,i,h,$,ie,de,Se,Ee,Y),i=1,N===!0&&(i|=24),N=Zn(3,null,null,i),s.current=N,N.stateNode=s,i=ch(),i.refCount++,s.pooledCache=i,i.refCount++,N.memoizedState={element:g,isDehydrated:h,cache:i},fh(N),s}function rb(s){return s?(s=na,s):na}function sb(s,i,h,g,k,N){k=rb(k),g.context===null?g.context=k:g.pendingContext=k,g=js(i),g.payload={element:h},N=N===void 0?null:N,N!==null&&(g.callback=N),h=Ns(s,g,i),h!==null&&(Un(h,s,i),vo(h,s,i))}function ib(s,i){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var h=s.retryLane;s.retryLane=h!==0&&h<i?h:i}}function Df(s,i){ib(s,i),(s=s.alternate)&&ib(s,i)}function ab(s){if(s.tag===13||s.tag===31){var i=li(s,67108864);i!==null&&Un(i,s,67108864),Df(s,67108864)}}function ob(s){if(s.tag===13||s.tag===31){var i=sr();i=lt(i);var h=li(s,i);h!==null&&Un(h,s,i),Df(s,i)}}var Vc=!0;function y2(s,i,h,g){var k=U.T;U.T=null;var N=Q.p;try{Q.p=2,Rf(s,i,h,g)}finally{Q.p=N,U.T=k}}function _2(s,i,h,g){var k=U.T;U.T=null;var N=Q.p;try{Q.p=8,Rf(s,i,h,g)}finally{Q.p=N,U.T=k}}function Rf(s,i,h,g){if(Vc){var k=Of(g);if(k===null)_f(s,i,g,Gc,h),cb(s,g);else if(v2(k,s,i,h,g))g.stopPropagation();else if(cb(s,g),i&4&&-1<b2.indexOf(s)){for(;k!==null;){var N=Gi(k);if(N!==null)switch(N.tag){case 3:if(N=N.stateNode,N.current.memoizedState.isDehydrated){var $=Me(N.pendingLanes);if($!==0){var Y=N;for(Y.pendingLanes|=2,Y.entangledLanes|=2;$;){var ie=1<<31-et($);Y.entanglements[1]|=ie,$&=~ie}Br(N),(Ct&6)===0&&(jc=it()+500,Po(0))}}break;case 31:case 13:Y=li(N,2),Y!==null&&Un(Y,N,2),Tc(),Df(N,2)}if(N=Of(g),N===null&&_f(s,i,g,Gc,h),N===k)break;k=N}k!==null&&g.stopPropagation()}else _f(s,i,g,null,h)}}function Of(s){return s=Md(s),Mf(s)}var Gc=null;function Mf(s){if(Gc=null,s=Vi(s),s!==null){var i=l(s);if(i===null)s=null;else{var h=i.tag;if(h===13){if(s=u(i),s!==null)return s;s=null}else if(h===31){if(s=c(i),s!==null)return s;s=null}else if(h===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;s=null}else i!==s&&(s=null)}}return Gc=s,null}function lb(s){switch(s){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Et()){case ce:return 2;case Te:return 8;case Fe:case Ye:return 32;case tt:return 268435456;default:return 32}default:return 32}}var If=!1,$s=null,zs=null,Hs=null,Vo=new Map,Go=new Map,Us=[],b2="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 cb(s,i){switch(s){case"focusin":case"focusout":$s=null;break;case"dragenter":case"dragleave":zs=null;break;case"mouseover":case"mouseout":Hs=null;break;case"pointerover":case"pointerout":Vo.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Go.delete(i.pointerId)}}function Wo(s,i,h,g,k,N){return s===null||s.nativeEvent!==N?(s={blockedOn:i,domEventName:h,eventSystemFlags:g,nativeEvent:N,targetContainers:[k]},i!==null&&(i=Gi(i),i!==null&&ab(i)),s):(s.eventSystemFlags|=g,i=s.targetContainers,k!==null&&i.indexOf(k)===-1&&i.push(k),s)}function v2(s,i,h,g,k){switch(i){case"focusin":return $s=Wo($s,s,i,h,g,k),!0;case"dragenter":return zs=Wo(zs,s,i,h,g,k),!0;case"mouseover":return Hs=Wo(Hs,s,i,h,g,k),!0;case"pointerover":var N=k.pointerId;return Vo.set(N,Wo(Vo.get(N)||null,s,i,h,g,k)),!0;case"gotpointercapture":return N=k.pointerId,Go.set(N,Wo(Go.get(N)||null,s,i,h,g,k)),!0}return!1}function ub(s){var i=Vi(s.target);if(i!==null){var h=l(i);if(h!==null){if(i=h.tag,i===13){if(i=u(h),i!==null){s.blockedOn=i,nn(s.priority,function(){ob(h)});return}}else if(i===31){if(i=c(h),i!==null){s.blockedOn=i,nn(s.priority,function(){ob(h)});return}}else if(i===3&&h.stateNode.current.memoizedState.isDehydrated){s.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Wc(s){if(s.blockedOn!==null)return!1;for(var i=s.targetContainers;0<i.length;){var h=Of(s.nativeEvent);if(h===null){h=s.nativeEvent;var g=new h.constructor(h.type,h);Od=g,h.target.dispatchEvent(g),Od=null}else return i=Gi(h),i!==null&&ab(i),s.blockedOn=h,!1;i.shift()}return!0}function db(s,i,h){Wc(s)&&h.delete(i)}function S2(){If=!1,$s!==null&&Wc($s)&&($s=null),zs!==null&&Wc(zs)&&(zs=null),Hs!==null&&Wc(Hs)&&(Hs=null),Vo.forEach(db),Go.forEach(db)}function qc(s,i){s.blockedOn===i&&(s.blockedOn=null,If||(If=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,S2)))}var Kc=null;function hb(s){Kc!==s&&(Kc=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Kc===s&&(Kc=null);for(var i=0;i<s.length;i+=3){var h=s[i],g=s[i+1],k=s[i+2];if(typeof g!="function"){if(Mf(g||h)===null)continue;break}var N=Gi(h);N!==null&&(s.splice(i,3),i-=3,Rh(N,{pending:!0,data:k,method:h.method,action:g},g,k))}}))}function Ea(s){function i(ie){return qc(ie,s)}$s!==null&&qc($s,s),zs!==null&&qc(zs,s),Hs!==null&&qc(Hs,s),Vo.forEach(i),Go.forEach(i);for(var h=0;h<Us.length;h++){var g=Us[h];g.blockedOn===s&&(g.blockedOn=null)}for(;0<Us.length&&(h=Us[0],h.blockedOn===null);)ub(h),h.blockedOn===null&&Us.shift();if(h=(s.ownerDocument||s).$$reactFormReplay,h!=null)for(g=0;g<h.length;g+=3){var k=h[g],N=h[g+1],$=k[In]||null;if(typeof N=="function")$||hb(h);else if($){var Y=null;if(N&&N.hasAttribute("formAction")){if(k=N,$=N[In]||null)Y=$.formAction;else if(Mf(k)!==null)continue}else Y=$.action;typeof Y=="function"?h[g+1]=Y:(h.splice(g,3),g-=3),hb(h)}}}function fb(){function s(N){N.canIntercept&&N.info==="react-transition"&&N.intercept({handler:function(){return new Promise(function($){return k=$})},focusReset:"manual",scroll:"manual"})}function i(){k!==null&&(k(),k=null),g||setTimeout(h,20)}function h(){if(!g&&!navigation.transition){var N=navigation.currentEntry;N&&N.url!=null&&navigation.navigate(N.url,{state:N.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,k=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(h,100),function(){g=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),k!==null&&(k(),k=null)}}}function Pf(s){this._internalRoot=s}Yc.prototype.render=Pf.prototype.render=function(s){var i=this._internalRoot;if(i===null)throw Error(r(409));var h=i.current,g=sr();sb(h,g,s,i,null,null)},Yc.prototype.unmount=Pf.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var i=s.containerInfo;sb(s.current,2,null,s,null,null),Tc(),i[Fi]=null}};function Yc(s){this._internalRoot=s}Yc.prototype.unstable_scheduleHydration=function(s){if(s){var i=yt();s={blockedOn:null,target:s,priority:i};for(var h=0;h<Us.length&&i!==0&&i<Us[h].priority;h++);Us.splice(h,0,s),h===0&&ub(s)}};var mb=t.version;if(mb!=="19.2.4")throw Error(r(527,mb,"19.2.4"));Q.findDOMNode=function(s){var i=s._reactInternals;if(i===void 0)throw typeof s.render=="function"?Error(r(188)):(s=Object.keys(s).join(","),Error(r(268,s)));return s=f(i),s=s!==null?p(s):null,s=s===null?null:s.stateNode,s};var w2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:U,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xc.isDisabled&&Xc.supportsFiber)try{me=Xc.inject(w2),Oe=Xc}catch{}}return Ko.createRoot=function(s,i){if(!o(s))throw Error(r(299));var h=!1,g="",k=vy,N=Sy,$=wy;return i!=null&&(i.unstable_strictMode===!0&&(h=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onUncaughtError!==void 0&&(k=i.onUncaughtError),i.onCaughtError!==void 0&&(N=i.onCaughtError),i.onRecoverableError!==void 0&&($=i.onRecoverableError)),i=nb(s,1,!1,null,null,h,g,null,k,N,$,fb),s[Fi]=i.current,yf(s),new Pf(i)},Ko.hydrateRoot=function(s,i,h){if(!o(s))throw Error(r(299));var g=!1,k="",N=vy,$=Sy,Y=wy,ie=null;return h!=null&&(h.unstable_strictMode===!0&&(g=!0),h.identifierPrefix!==void 0&&(k=h.identifierPrefix),h.onUncaughtError!==void 0&&(N=h.onUncaughtError),h.onCaughtError!==void 0&&($=h.onCaughtError),h.onRecoverableError!==void 0&&(Y=h.onRecoverableError),h.formState!==void 0&&(ie=h.formState)),i=nb(s,1,!0,i,h??null,g,k,ie,N,$,Y,fb),i.context=rb(null),h=i.current,g=sr(),g=lt(g),k=js(g),k.callback=null,Ns(h,k,g),h=g,i.current.lanes=h,Cr(i,h),Br(i),s[Fi]=i.current,yf(s),new Yc(i)},Ko.version="19.2.4",Ko}var Eb;function B2(){if(Eb)return Uf.exports;Eb=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(),Uf.exports=P2(),Uf.exports}var $2=B2();const z2=Xu($2),jb=e=>{let t;const n=new Set,r=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const x=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,x))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f))},d=t=e(r,o,c);return c},H2=(e=>e?jb(e):jb),U2=e=>e;function F2(e,t=U2){const n=Ys.useSyncExternalStore(e.subscribe,Ys.useCallback(()=>t(e.getState()),[e,t]),Ys.useCallback(()=>t(e.getInitialState()),[e,t]));return Ys.useDebugValue(n),n}const Nb=e=>{const t=H2(e),n=r=>F2(t,r);return Object.assign(n,t),n},qn=(e=>e?Nb(e):Nb);async function ke(e,t={}){const n=localStorage.getItem("openfox_token"),r={...t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers,...n?{"x-session-token":n}:{}};return fetch(e,{...t,headers:r})}async function V2(e,t){try{return(await ke(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t})})).ok}catch{return!1}}const Ie={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey",TOOLS_USE_RTK:"tools.useRtk",TOOLS_SHELL:"tools.shell"};function Qc(e,t){return n=>({loading:{...n.loading,[e]:t}})}function Tb(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const Ep=[Ie.DISPLAY_SHOW_THINKING,Ie.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Ie.DISPLAY_SHOW_STATS,Ie.DISPLAY_SHOW_AGENT_DEFINITIONS,Ie.DISPLAY_SHOW_WORKFLOW_BARS,Ie.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Ie.DISPLAY_FOLLOW_SYSTEM_THEME,Ie.DISPLAY_SHOW_OPEN_IN_EDITOR,Ie.DISPLAY_MAX_VISIBLE_ITEMS];function zi(){return{showThinking:tn(e=>e.settings[Ie.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:tn(e=>e.settings[Ie.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:tn(e=>e.settings[Ie.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:tn(e=>e.settings[Ie.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:tn(e=>e.settings[Ie.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:tn(e=>e.settings[Ie.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(tn(e=>e.settings[Ie.DISPLAY_MAX_VISIBLE_ITEMS]??"300"))}}const tn=qn(e=>({settings:{},loading:{},getSetting:async t=>{e(Qc(t,!0));try{const r=await(await ke(`/api/settings/${t}`)).json();return e(Tb(t,r.value??"")),r.value}catch{return e(Qc(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await ke(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(o=>[o,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(Qc(t,!0));try{const o=await(await ke(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(Tb(t,o.value??""))}catch{e(Qc(t,!1))}}})),Wf=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:Ep,SETTINGS_KEYS:Ie,useDisplaySettings:zi,useSettingsStore:tn},Symbol.toStringTag,{value:"Module"}));function G2(){const[e,t]=A.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=A.useRef(window.innerHeight);return A.useEffect(()=>{const r=window.visualViewport;if(!r)return;const o=()=>{const l=r.offsetTop,u=r.height,c=n.current-u>100;t({offsetTop:l,height:u,keyboardVisible:c})};return o(),r.addEventListener("resize",o),r.addEventListener("scroll",o),()=>{r.removeEventListener("resize",o),r.removeEventListener("scroll",o)}},[]),e}function W2(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,o,l,u=[],c="",d=e.split("/");for(d[0]||d.shift();o=d.shift();)n=o[0],n==="*"?(u.push(n),c+=o[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=o.indexOf("?",1),l=o.indexOf(".",1),u.push(o.substring(1,~r?r:~l?l:o.length)),c+=~r&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(c+=(~r?"?":"")+"\\"+o.substring(l))):c+="/"+o;return{keys:u,pattern:new RegExp("^"+c+(t?"(?=$|/)":"/?$"),"i")}}var qf={exports:{}},Kf={};/**
|
|
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 Ab;function q2(){if(Ab)return Kf;Ab=1;var e=Qu();function t(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(m,x){var y=x(),w=r({inst:{value:y,getSnapshot:x}}),C=w[0].inst,v=w[1];return l(function(){C.value=y,C.getSnapshot=x,d(C)&&v({inst:C})},[m,y,x]),o(function(){return d(C)&&v({inst:C}),m(function(){d(C)&&v({inst:C})})},[m]),u(y),y}function d(m){var x=m.getSnapshot;m=m.value;try{var y=x();return!n(m,y)}catch{return!0}}function f(m,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Kf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Kf}var Lb;function K2(){return Lb||(Lb=1,qf.exports=q2()),qf.exports}var Y2=K2();const X2=R2.useInsertionEffect,Q2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",J2=Q2?A.useLayoutEffect:A.useEffect,Z2=X2||J2,xS=e=>{const t=A.useRef([e,(...n)=>t[0](...n)]).current;return Z2(()=>{t[0]=e}),t[1]},ej="popstate",jp="pushState",Np="replaceState",tj="hashchange",Db=[ej,jp,Np,tj],nj=e=>{for(const t of Db)addEventListener(t,e);return()=>{for(const t of Db)removeEventListener(t,e)}},yS=(e,t)=>Y2.useSyncExternalStore(nj,e,t),Rb=()=>location.search,rj=({ssrSearch:e}={})=>yS(Rb,e!=null?()=>e:Rb),Ob=()=>location.pathname,sj=({ssrPath:e}={})=>yS(Ob,e!=null?()=>e:Ob),ij=(e,{replace:t=!1,state:n=null}={})=>history[t?Np:jp](n,"",e),aj=(e={})=>[sj(e),ij],Mb=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[Mb]>"u"){for(const e of[jp,Np]){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,Mb,{value:!0})}const oj=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",_S=(e="")=>e==="/"?"":e,lj=(e,t)=>e[0]==="~"?e.slice(1):_S(t)+e,cj=(e="",t)=>oj(Ib(_S(e)),Ib(t)),Ib=e=>{try{return decodeURI(e)}catch{return e}},bS={hook:aj,searchHook:rj,parser:W2,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},vS=A.createContext(bS),qa=()=>A.useContext(vS),SS={},wS=A.createContext(SS),uj=()=>A.useContext(wS),Ju=e=>{const[t,n]=e.hook(e);return[cj(e.base,t),xS((r,o)=>e.aroundNav(n,lj(r,e.base),o))]},Gn=()=>Ju(qa()),Tp=(e,t,n,r)=>{const{pattern:o,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),u=o.exec(n)||[],[c,...d]=u;return c!==void 0?[!0,(()=>{const f=l!==!1?Object.fromEntries(l.map((m,x)=>[m,d[x]])):u.groups;let p={...d};return f&&Object.assign(p,f),p})(),...r?[c]:[]]:[!1,null]},Ka=e=>Tp(qa().parser,e,Gn()[0]),dj=({children:e,...t})=>{var p,m,x;const n=qa(),r=t.hook?bS:n;let o=r;const[l,u=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];l&&(t.ssrSearch=u,t.ssrPath=l),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let c=A.useRef({}),d=c.current,f=d;for(let y in r){const w=y==="base"?r[y]+(t[y]??""):t[y]??r[y];d===f&&w!==f[y]&&(c.current=f={...f}),f[y]=w,(w!==r[y]||w!==o[y])&&(o=f)}return A.createElement(vS.Provider,{value:o,children:e})},Pb=({children:e,component:t},n)=>t?A.createElement(t,{params:n}):typeof e=="function"?e(n):e,hj=e=>{let t=A.useRef(SS);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,o])=>o!==n[r])?e:n},Yo=({path:e,nest:t,match:n,...r})=>{const o=qa(),[l]=Ju(o),[u,c,d]=n??Tp(o.parser,e,l,t),f=hj({...uj(),...c});if(!u)return null;const p=d?A.createElement(dj,{base:d},Pb(r,f)):Pb(r,f);return A.createElement(wS.Provider,{value:f,children:p})},or=A.forwardRef((e,t)=>{const n=qa(),[r,o]=Ju(n),{to:l="",href:u=l,onClick:c,asChild:d,children:f,className:p,replace:m,state:x,transition:y,...w}=e,C=xS(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(c==null||c(S),S.defaultPrevented||(S.preventDefault(),o(u,e)))}),v=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return d&&A.isValidElement(f)?A.cloneElement(f,{onClick:C,href:v}):A.createElement("a",{...w,onClick:C,href:v,className:p!=null&&p.call?p(r===u):p,children:f,ref:t})}),CS=e=>Array.isArray(e)?e.flatMap(t=>CS(t&&t.type===A.Fragment?t.props.children:t)):[e],fj=({children:e,location:t})=>{const n=qa(),[r]=Ju(n);for(const o of CS(e)){let l=0;if(A.isValidElement(o)&&(l=Tp(n.parser,o.props.path,t||r,o.props.nest))[0])return A.cloneElement(o,{match:l})}return null};function mj(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function kS(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class pj{constructor(t){_e(this,"ws",null);_e(this,"handlers",new Set);_e(this,"statusHandler",null);_e(this,"baseUrl");_e(this,"isReconnecting",!1);_e(this,"connectingPromise",null);_e(this,"lastCloseCode",0);_e(this,"reconnectAttempts",0);_e(this,"manualReconnectScheduled",!1);_e(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((o,l)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const c=setTimeout(()=>{var d;((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var d;clearTimeout(c),this.isReconnecting=!1,this.reconnectAttempts=0,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),o()},this.ws.onclose=d=>{var f,p,m;clearTimeout(c),this.lastCloseCode=d.code,((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),l(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(c),console.error("WebSocket error:",d),this.connectingPromise=null,l(d)},this.ws.onmessage=d=>{try{const f=JSON.parse(d.data);mj(f)&&this.handlers.forEach(p=>p(f))}catch(f){console.error("Failed to parse WebSocket message:",f)}}}catch(u){this.connectingPromise=null,l(u)}}),this.connectingPromise)))}async recoverPwaStuckConnection(){if(this.pwaRecoveryAttempted||!window.matchMedia("(display-mode: standalone)").matches||!("serviceWorker"in navigator))return;this.pwaRecoveryAttempted=!0;const n=await navigator.serviceWorker.getRegistrations();n.length!==0&&(console.warn("[WS] PWA mode detected with stale service worker — unregistering and reloading"),await Promise.all(n.map(r=>r.unregister())),window.location.reload())}attemptReconnect(){var r;if(this.lastCloseCode===4e3&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(r=this.statusHandler)==null||r.call(this,"reconnecting");const n=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{this.reconnectAttempts>=3&&this.recoverPwaStuckConnection()})},n)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{this.recoverPwaStuckConnection()})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const r=kS(),o={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(o)),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 gj=window.location.protocol==="https:"?"wss:":"ws:";let Um=window.location.port;Um||(Um=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const xj=`${gj}//${window.location.hostname}:${Um}/ws`,Xt=new pj(xj),yj=3e4;function ES(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}const un=qn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const n=await ke("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json();e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await ke("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json();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:o}=t();if(n===r)return!0;e({activating:!0,error:null});try{const l=await ke(`/api/providers/${n}/activate`,{method:"POST"});if(!l.ok){const c=await l.json();throw new Error(c.error??"Failed to activate provider")}const u=await l.json();return e({activeProviderId:u.activeProviderId,model:u.model,backend:u.backend,providers:o.map(c=>({...c,isActive:c.id===u.activeProviderId})),activating:!1}),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,r)=>{const{providers:o}=t();try{const l=await ke("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!l.ok)return!1;const u=await l.json();return e({activeProviderId:n,model:r,defaultModelSelection:u.defaultModelSelection,providers:o.map(c=>({...c,isActive:c.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await ke(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const u=await r.json();throw new Error(u.error??"Failed to refresh models")}const o=await r.json(),{providers:l}=t();return e({providers:l.map(u=>u.id===n?{...u,models:o.models,status:o.status}:u),activating:!1}),!0}catch(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const o=setInterval(()=>{r()},yj);e({autoRefreshInterval:o})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(o=>o.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:o}=t(),l=r.find(c=>c.id===o);if(!l)return 2e5;const u=l.models.find(c=>c.id===n);return(u==null?void 0:u.contextWindow)??2e5}})),Ut=qn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await ke("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const o=await ke("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!o.ok){const u=await o.json().catch(()=>({}));return{error:{code:u.code||"UNKNOWN",path:u.path,message:u.error}}}const l=await o.json();return await t().listProjects(),l.project}catch{return null}},loadProject:async n=>{try{const r=await ke(`/api/projects/${n}`);if(!r.ok)return null;const o=await r.json();return e({currentProject:o.project}),t().projects.length===0&&await t().listProjects(),o.project}catch{return null}},updateProject:async(n,r)=>{var o;try{const l=await ke(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!l.ok)return null;const u=await l.json();return((o=t().currentProject)==null?void 0:o.id)===n&&e({currentProject:u.project}),await t().listProjects(),u.project}catch{return null}},deleteProject:async n=>{var r;try{return(await ke(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var o;try{const l=await ke(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!l.ok)return!1;if(((o=t().currentProject)==null?void 0:o.id)===n){const u=await l.json();e({currentProject:u.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),ei=async(e,t,n)=>{try{const r=await ke(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?{success:!0}:{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}},Zu=async(e,t,n)=>{try{const r=await ke(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),o=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:o.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function jS(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Jc=[];const dl=qn()((e,t)=>{function n(){if(Jc.length===0)return;const o=Jc;Jc=[],e(l=>{const u={...l.logs};for(const c of o){const d=u[c.processId]??[];u[c.processId]=[...d,{offset:d.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:u}})}const r=jS(n);return{processes:[],logs:{},loading:!1,setProcesses:o=>e({processes:o}),addProcess:o=>e(l=>({processes:[...l.processes,o]})),updateProcess:(o,l)=>e(u=>({processes:u.processes.map(c=>c.id===o?{...c,...l}:c)})),removeProcess:o=>e(l=>({processes:l.processes.filter(u=>u.id!==o),logs:Object.fromEntries(Object.entries(l.logs).filter(([u])=>u!==o))})),stopProcess:async(o,l)=>{try{(await ke(`/api/sessions/${l}/background-process/${o}/stop`,{method:"POST"})).ok&&t().removeProcess(o)}catch{}},appendLog:(o,l,u)=>{Jc.push({processId:o,stream:l,content:u}),r()},setLogs:(o,l)=>e(u=>({logs:{...u.logs,[o]:l}})),clearLogs:o=>e(l=>({logs:{...l.logs,[o]:[]}})),handleMessage:(o,l)=>{switch(o){case"backgroundProcess.started":{const{processId:u,name:c,pid:d,status:f}=l;e(p=>({processes:[...p.processes,{id:u,sessionId:"",name:c,command:"",cwd:"",pid:d,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const u=l.processId,c=l.stream,d=l.content;t().appendLog(u,c,d);break}case"backgroundProcess.exited":{const u=l.processId,c=l.exitCode;e(d=>({processes:d.processes.map(f=>f.id===u?{...f,status:"exited",exitCode:c}:f)}));break}case"backgroundProcess.removed":{const u=l.processId;t().removeProcess(u);break}}}}}),_j={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let vu=null;function bj(e){vu=e}function Ni(){return _j}function Yf(){vu==null||vu()}let Zc=[];const Fr=qn()((e,t)=>{function n(){if(Zc.length===0)return;const o=Zc;Zc=[],e(l=>({logs:[...l.logs,...o]}))}const r=jS(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:o=>{t().workdir!==o&&(e({workdir:o,status:null,logs:[],config:null,loading:!0}),o&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const o=t().workdir;if(o)try{const u=await(await ke(`/api/dev-server?workdir=${encodeURIComponent(o)}`)).json();e({status:u,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const o=t().workdir;if(o)try{const u=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(o)}`)).json();e({config:u.config??null})}catch{}},fetchLogs:async()=>{const o=t().workdir;if(o)try{const c=(await(await ke(`/api/dev-server/logs?workdir=${encodeURIComponent(o)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content}));e({logs:c})}catch{}},start:async()=>{const o=t().workdir;if(o)try{const u=await(await ke(`/api/dev-server/start?workdir=${encodeURIComponent(o)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},stop:async()=>{const o=t().workdir;if(o)try{const u=await(await ke(`/api/dev-server/stop?workdir=${encodeURIComponent(o)}`,{method:"POST"})).json();e({status:u})}catch{}},restart:async()=>{const o=t().workdir;if(o)try{const u=await(await ke(`/api/dev-server/restart?workdir=${encodeURIComponent(o)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},saveConfig:async o=>{const l=t().workdir;if(l)try{const c=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).json();e({config:c.config??o}),t().fetchStatus()}catch{}},handleMessage:o=>{const l=t().workdir;if(l)switch(o.type){case"devServer.output":{const u=o.payload;if(u.workdir!==l)return;Zc.push({stream:u.stream,content:u.content}),r();break}case"devServer.state":{const u=o.payload;if(u.workdir!==l)return;e(c=>({status:c.status?{...c.status,state:u.state,errorMessage:u.errorMessage}:c.status}));break}}}}}),vj=[{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"}],Sj=[{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"}],NS={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"},Xs={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},TS={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Fm={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Xs},waiting_for_user:{...Xs},phase_done:{...Xs},phase_blocked:{...Xs},new_message:{...TS}},agentOverrides:{}};function AS(e,t,n){var l;const r=e.events[t];if(!n)return r;const o=(l=e.agentOverrides[n])==null?void 0:l[t];return o?{soundEnabled:o.soundEnabled??r.soundEnabled,browserNotification:o.browserNotification??r.browserNotification,customSoundUrl:o.customSoundUrl!==void 0?o.customSoundUrl:r.customSoundUrl}:r}const Ai=qn((e,t)=>({settings:Fm,loaded:!1,load:()=>{tn.getState().getSetting(Ie.NOTIFICATION_SETTINGS);const r=tn.subscribe(l=>{const u=l.settings[Ie.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:Bb(c),loaded:!0})}catch{e({loaded:!0})}}),o=tn.getState().settings[Ie.NOTIFICATION_SETTINGS];if(o)try{const l=JSON.parse(o);e({settings:Bb(l),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Xf(n)},updateEvent:(n,r)=>{const o=t().settings,l={...o,events:{...o.events,[n]:{...o.events[n],...r}}};e({settings:l}),Xf(l)},updateAgentOverride:(n,r,o)=>{var d;const l=t().settings,u={...l.agentOverrides};if(o===null){if(u[n]){const f={...u[n]};delete f[r],Object.keys(f).length===0?delete u[n]:u[n]=f}}else u[n]={...u[n],[r]:{...((d=u[n])==null?void 0:d[r])??{},...o}};const c={...l,agentOverrides:u};e({settings:c}),Xf(c)}}));function Xf(e){tn.getState().setSetting(Ie.NOTIFICATION_SETTINGS,JSON.stringify(e))}function Bb(e){var t,n,r,o,l;return{soundEnabled:e.soundEnabled??Fm.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Fm.browserNotificationEnabled,events:{complete:{...Xs,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Xs,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Xs,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...Xs,...(o=e.events)==null?void 0:o.phase_blocked},new_message:{...TS,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const $b=new Map;function wj(e){let t=$b.get(e);return t||(t=new Audio(e),t.volume=.5,$b.set(e,t)),t}let LS=typeof Notification<"u"?Notification.permission:"denied";function Cj(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(LS=e,e))}const kj={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},Ej={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 jj(e){typeof Notification>"u"||LS==="granted"&&(document.hasFocus()||new Notification(kj[e],{body:Ej[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function Nl(e,t){const{settings:n}=Ai.getState(),r=AS(n,e,t);if(n.soundEnabled&&r.soundEnabled){const o=r.customSoundUrl??NS[e],l=wj(o);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&jj(e)}const Nj=e=>Nl("complete",e),Tj=e=>Nl("phase_done",e),Aj=e=>Nl("phase_blocked",e),zb=e=>Nl("waiting_for_user",e),Lj=e=>Nl("new_message",e),Hb=new Map;function ll(e,t){var l;const n=t===((l=e.currentSession)==null?void 0:l.id)?e.currentSession:null,r=e.sessions.find(u=>u.id===t),o=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return o==="planner"?"planner":o==="builder"?"build":"planner"}function Dj(e,t){if(e.type==="chat.done"){const n=e.payload,r=ll(t,e.sessionId),o=n.agentType??r;n.reason==="complete"&&Nj(o),n.reason==="waiting_for_user"&&zb(o);return}if(e.type==="chat.path_confirmation"){const n=ll(t,e.sessionId);zb(n);return}if(e.type==="task.completed"){const n=ll(t,e.sessionId);Tj(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=Hb.get(e.sessionId)??null;if(Hb.set(e.sessionId,n.phase),r===n.phase)return;const o=ll(t,e.sessionId);n.phase==="blocked"&&Aj(o)}}const Qf=new Set;function Zt(e,t){return t!==null&&e.sessionId===t}function Rj(e,t,n){return e.id!==void 0||Zt(e,t)||n===!0&&e.sessionId!==void 0}function Oj(e,t){return e.includes(t)?e:[...e,t]}function Ub(e,t){return e.filter(n=>n!==t)}function Mj(e,t){const n=e.find(l=>l.id===t.id),r=t.messageCount??t.messages.length,o=n?{...n,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length,messageCount:r};return n?e.map(l=>l.id===t.id?o:l):[o,...e]}function Ij(e,t,n){return e.map(r=>{const o=(n==null?void 0:n.id)===r.id?n:null,l=t.find(u=>u.id===r.id);return{...r,title:r.title??(l==null?void 0:l.title),mode:(o==null?void 0:o.mode)??(l==null?void 0:l.mode)??r.mode,phase:(o==null?void 0:o.phase)??(l==null?void 0:l.phase)??r.phase,isRunning:r.isRunning&&(l==null?void 0:l.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function Fb(e,t,n,r){var c;const o=e.sessionId,l=(c=n().currentSession)==null?void 0:c.id,u=o&&o!==l;if(t(d=>({sessions:d.sessions.map(f=>f.id===o?r(f):f)})),!u){const d=n().currentSession;if(d){const f=r(d);t(()=>({currentSession:f}))}}}function Vb(e,t,n){var c,d,f,p,m,x,y,w,C,v,S,b,_,j,E,T,D,L,O,P,q,W;const r=n();Dj(e,r);const o=((c=r.currentSession)==null?void 0:c.id)??null,l=()=>{const M=e.sessionId;!M||M===o||t(H=>({unreadSessionIds:Oj(H.unreadSessionIds,M)}))},u=(M,H,V)=>({messages:M.messages.map(U=>U.id===H?V(U):U)});switch(e.type){case"session.state":{const M=e.payload;if(!Rj(e,o,r.pendingSessionCreate))break;const H=n().pendingSessionCreate===!0;t({currentSession:M.session,sessions:Mj(n().sessions,M.session),unreadSessionIds:Ub(n().unreadSessionIds,M.session.id),messages:M.messages,currentTodos:[],pendingPathConfirmations:M.pendingConfirmations??[],pendingQuestions:M.pendingQuestions??[],error:null,...H?{pendingSessionCreate:M.session.id}:{}});break}case"session.list":{const M=e.payload;t(H=>({sessions:Ij(M.sessions,H.sessions,H.currentSession)}));break}case"session.deleted":{const M=e.payload;t(H=>({unreadSessionIds:Ub(H.unreadSessionIds,M.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const M=e.payload;Fb(e,t,n,H=>({...H,isRunning:M.isRunning})),M.isRunning||t({abortInProgress:!1,queuedMessages:[]}),M.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!Zt(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const M=e.payload;t(H=>{if(H.messages.some(U=>U.id===M.message.id))return H;const V=M.message.role==="user";return{messages:[...H.messages,M.message],sessions:H.sessions.map(U=>U.id===e.sessionId&&V?{...U,messageCount:U.messageCount+1}:U)}});break}case"chat.message_updated":{if(!Zt(e,((f=n().currentSession)==null?void 0:f.id)??null)){l();break}const M=e.payload,H=n().messages.find(V=>V.id===M.messageId);M.updates.isStreaming===!1&&(H==null||H.isStreaming),t(V=>({messages:V.messages.map(U=>U.id===M.messageId?{...U,...M.updates}:U)}));break}case"chat.delta":{if(!Zt(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const M=e.payload;if(!Qf.has(M.messageId)){Qf.add(M.messageId);const V=M.subAgentType?"sub-agent":ll(n(),e.sessionId);Lj(V)}const H=Ni();H.messageId=M.messageId,H.deltaContent+=M.content,Yf();break}case"chat.thinking":{if(!Zt(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const M=e.payload,H=Ni();H.messageId=M.messageId,H.thinkingContent+=M.content,Yf();break}case"chat.tool_preparing":{if(!Zt(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const M=e.payload;t(H=>{var R;const V=H.messages.find(I=>I.id===M.messageId);if(!V)return{};if((R=V.toolCalls)==null?void 0:R.find((I,G)=>G===M.index))return{};const Q=V.preparingToolCalls??[],X=Q.findIndex(I=>I.index===M.index);let z;return X>=0?z=Q.map((I,G)=>G===X?{...I,arguments:M.arguments}:I):z=[...Q,{index:M.index,name:M.name,...M.arguments?{arguments:M.arguments}:{}}],{messages:H.messages.map(I=>I.id===M.messageId?{...I,preparingToolCalls:z}:I)}});break}case"chat.tool_call":{if(!Zt(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const M=e.payload,H=V=>{var z;const U=(z=V.preparingToolCalls)==null?void 0:z.filter((R,I)=>{var G;return R.name===M.tool?(G=V.preparingToolCalls)==null?void 0:G.slice(0,I).some(ee=>ee.name===M.tool):!0}),Q=Ni(),X=Q.toolOutput.filter(R=>R.callId===M.callId);return X.length>0&&(Q.toolOutput=Q.toolOutput.filter(R=>R.callId!==M.callId)),{...V,toolCalls:[...V.toolCalls??[],{id:M.callId,name:M.tool,arguments:M.args,startedAt:Date.now(),...X.length>0?{streamingOutput:X.map(R=>({stream:R.stream,content:R.content,timestamp:Date.now()}))}:{}}],...U&&U.length>0?{preparingToolCalls:U}:{preparingToolCalls:void 0}}};t(V=>u(V,M.messageId,H));break}case"chat.tool_output":{if(!Zt(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const M=e.payload,H=Ni();H.messageId=M.messageId,H.toolOutput.push({messageId:M.messageId,callId:M.callId,stream:M.stream,content:M.output}),Yf();break}case"chat.tool_result":{if(!Zt(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const M=e.payload,H=V=>{var Q;const U=(Q=V.toolCalls)==null?void 0:Q.map(X=>X.id===M.callId?{...X,result:M.result}:X);return{...V,toolCalls:U}};t(V=>u(V,M.messageId,H));break}case"chat.vision_fallback":{if(!Zt(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const M=e.payload;t(H=>{const V=`${M.messageId}-${M.attachmentId}`,U={...H.visionFallbackByMessage};return U[V]={type:M.type,attachmentId:M.attachmentId,filename:M.filename,description:M.description},{visionFallbackByMessage:U}});break}case"chat.todo":{if(!Zt(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const M=e.payload;t({currentTodos:M.todos});break}case"chat.progress":{if(!Zt(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const M=e.payload;console.warn("Progress:",M.message,M.phase);break}case"chat.format_retry":{if(!Zt(e,((_=n().currentSession)==null?void 0:_.id)??null)){l();break}const M=e.payload;console.warn("Format retry:",M.attempt,"/",M.maxAttempts);break}case"chat.done":{if(!Zt(e,((j=n().currentSession)==null?void 0:j.id)??null)){l();break}const M=Ni();M.messageId=null,M.deltaContent="",M.thinkingContent="",M.toolOutput=[],Qf.delete(e.payload.messageId);const H=e.payload,V=H.stats;t(U=>({messages:U.messages.map(Q=>Q.id===H.messageId?{...Q,isStreaming:!1,stats:V??Q.stats,completeReason:H.reason,preparingToolCalls:void 0}:Q),visionFallbackByMessage:{}}));break}case"chat.error":{if(!Zt(e,((E=n().currentSession)==null?void 0:E.id)??null)){l();break}const M=Ni(),H=e.payload;console.error("Chat error:",H.error,"recoverable:",H.recoverable),H.recoverable||(M.messageId=null,M.deltaContent="",M.thinkingContent="",M.toolOutput=[]),t(V=>({error:{code:"CHAT_ERROR",message:H.error},...H.recoverable?{}:{messages:V.messages}}));break}case"chat.path_confirmation":{if(!Zt(e,((T=n().currentSession)==null?void 0:T.id)??null)){l();break}const M=e.payload,H={callId:M.callId,tool:M.tool,paths:M.paths,workdir:M.workdir,reason:M.reason};t(V=>({pendingPathConfirmations:[...V.pendingPathConfirmations,H]}));break}case"chat.ask_user":{if(!Zt(e,((D=n().currentSession)==null?void 0:D.id)??null)){l();return}const M=e.payload,H={callId:M.callId,question:M.question,type:M.type??"text",options:M.options??void 0};t(V=>({pendingQuestions:[...V.pendingQuestions.filter(U=>U.callId!==M.callId),H]}));break}case"mode.changed":{if(!Zt(e,((L=n().currentSession)==null?void 0:L.id)??null)){l();break}const M=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,mode:M.mode}:null}));break}case"phase.changed":{const M=e.payload;Fb(e,t,n,H=>({...H,phase:M.phase}));break}case"criteria.updated":{if(!Zt(e,((O=n().currentSession)==null?void 0:O.id)??null)){l();break}const M=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,criteria:M.criteria}:null}));break}case"metadata.updated":{if(!Zt(e,((P=n().currentSession)==null?void 0:P.id)??null)){l();break}const M=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,metadataEntries:{...H.currentSession.metadataEntries,[M.key]:M.entries}}:null}));break}case"context.state":{const M=e.payload,H=Zt(e,((q=n().currentSession)==null?void 0:q.id)??null);M.subAgentId?H&&n().updateSubAgentContextState(M.subAgentId,M.context):H?t({contextState:M.context}):l();break}case"session.name_generated":{const M=e.payload,H=e.sessionId,V=(W=n().currentSession)==null?void 0:W.id;t(U=>{const Q=U.sessions.map(z=>z.id===H?{...z,title:M.name,updatedAt:new Date().toISOString()}:z),X=V===H?U.currentSession?{...U.currentSession,title:M.name,updatedAt:new Date().toISOString()}:null:U.currentSession;return{sessions:Q,currentSession:X}});break}case"queue.state":{const M=e.payload;t({queuedMessages:M.messages??[]});break}case"mcp.servers.changed":{window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const M=e.payload;t({gitStatus:{branch:M.branch,diff:M.diff}});break}case"devServer.output":case"devServer.state":{Fr.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{dl.getState().handleMessage(e.type,e.payload);break}case"error":{const M=e.payload;console.error("Server error:",M),t({error:{code:M.code,message:M.message}});break}}}let Xo=!1,$r=null;const Jf=new Set,eu=new Map;function Gb(e,t,n){return e==null?void 0:e.map(r=>{const o=t.filter(l=>l.callId===r.id);return o.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...o.map(l=>({stream:l.stream,content:l.content,timestamp:Date.now()}))]})})}async function Wb(e,t,n,r,o){try{const u=await(await ke(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();u.queueState&&o({queuedMessages:u.queueState})}catch(l){console.error("Error queueing message:",l)}}const Le=qn((e,t)=>(bj(()=>{const n=Ni();if(!n.messageId)return;const r=n.deltaContent.length>0,o=n.thinkingContent.length>0,l=n.toolOutput.length>0;if(!r&&!o&&!l)return;const u=n.deltaContent,c=n.thinkingContent,d=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(f=>{const p=f.messages.find(m=>m.id===n.messageId);if(p){const m={...p};if(r&&(m.content=m.content+u),o&&(m.thinkingContent=(m.thinkingContent??"")+c),l){const x=new Set;m.toolCalls=Gb(m.toolCalls,d,x);const y=d.filter(w=>!x.has(w.callId));y.length>0&&n.toolOutput.push(...y)}return{messages:f.messages.map(x=>x.id===n.messageId?m:x)}}if(l){const m=new Set,x=f.messages.map(w=>w.id!==n.messageId?w:{...w,toolCalls:Gb(w.toolCalls,d,m)}),y=d.filter(w=>!m.has(w.callId));return y.length>0&&n.toolOutput.push(...y),{messages:x}}return f})}),{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let r=!1;try{r=(await(await ke("/api/auth")).json()).requiresAuth}catch{}if(r&&!Xt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Xt.onStatusChange(o=>{var l;if(e({connectionStatus:o}),o==="connected"){t().listSessions(void 0),Ut.getState().listProjects();const u=(l=t().currentSession)==null?void 0:l.id;u&&t().loadSession(u)}});try{await Xt.connect(),Xo||(Xo=!0,$r=Xt.subscribe(o=>{Vb(o,e,t)}))}catch(o){console.error("Failed to connect:",o);const l=Xt.getLastCloseCode();if(!Xt.hasToken()&&(l===1006||l===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}$r&&($r(),$r=null),Xo=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Xt.disconnect(),$r&&($r(),$r=null),Xo=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Xt.disconnect(),$r&&($r(),$r=null),Xo=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async n=>{try{const r=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:n})});if(!r.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:o}=await r.json();Xt.setToken(o),e({showPasswordModal:!1}),t().connect();const{listProjects:l}=Ut.getState(),{fetchConfig:u}=un.getState();l(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Xt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,r)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const l=await ke("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:r})});if(!l.ok)return e({pendingSessionCreate:!1}),null;const u=await l.json();try{Xt.send("session.load",{sessionId:u.session.id})}catch{}return u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!Jf.has(n)){Jf.add(n);try{const r=t().currentSession;!r||r.id!==n?e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(c=>c!==n),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,pendingSessionCreate:!1}):e({unreadSessionIds:t().unreadSessionIds.filter(c=>c!==n)});const o=await ke(`/api/sessions/${n}`);if(!o.ok)return;const l=await o.json(),u=l.messages??[];e({currentSession:l.session,messages:u,contextState:l.contextState,queuedMessages:l.queueState??[],pendingQuestions:l.pendingQuestions??[]}),Xt.send("session.load",{sessionId:n});try{const c=await ke(`/api/sessions/${n}/background-processes`);if(c.ok){const d=await c.json();dl.getState().setProcesses(d.processes??[])}}catch{}}catch{}finally{Jf.delete(n)}}},listSessions:async(n,r=20)=>{const o=n??"global";if(eu.has(o))return eu.get(o);const l=(async()=>{try{const u=new URLSearchParams;u.set("limit",String(r)),n&&u.set("projectId",n);const d=await(await ke(`/api/sessions?${u.toString()}`)).json(),f=d.sessions??[];e(p=>({sessions:f.map(m=>{var y,w;const x=p.sessions.find(C=>C.id===m.id);return{...m,title:m.title??(x==null?void 0:x.title),mode:((y=p.currentSession)==null?void 0:y.id)===m.id?p.currentSession.mode:(x==null?void 0:x.mode)??m.mode,phase:((w=p.currentSession)==null?void 0:w.id)===m.id?p.currentSession.phase:(x==null?void 0:x.phase)??m.phase,isRunning:m.isRunning&&(x==null?void 0:x.isRunning)!==!1,messageCount:m.messageCount,recentUserPrompts:m.recentUserPrompts}}),sessionsHasMore:n?d.hasMore??!1:!0}))}catch{}finally{eu.delete(o)}})();return eu.set(o,l),l},loadMoreSessions:async n=>{const r=t();if(!(r.sessionsPaginationLoading||!r.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const o=new URLSearchParams;o.set("limit","20"),o.set("offset",String(r.sessions.length)),o.set("projectId",n);const u=await(await ke(`/api/sessions?${o.toString()}`)).json(),c=u.sessions??[];e(d=>({sessions:[...d.sessions,...c.map(f=>{const p=d.sessions.find(m=>m.id===f.id);return(p==null?void 0:p.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:u.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var r;try{return(await ke(`/api/sessions/${n}`,{method:"DELETE"})).ok?(await t().listSessions(),((r=t().currentSession)==null?void 0:r.id)===n&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(n,r)=>{var o;try{const l=await ke(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r})});if(!l.ok)return!1;if(await t().listSessions(),((o=t().currentSession)==null?void 0:o.id)===n){const c=await l.json();c.session&&e({currentSession:c.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await ke(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{e(n=>({currentSession:null,messages:[],currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?n.unreadSessionIds.filter(r=>r!==n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,r,o)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l)try{const c=n==null?void 0:n.trim(),d=r&&r.length>0,f={};c&&(f.content=n),d&&(f.attachments=r),o!=null&&o.messageKind&&(f.messageKind=o.messageKind);const m=await(await ke(`/api/sessions/${l}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json();m.queueState&&e({queuedMessages:m.queueState})}catch(c){console.error("Error sending message:",c)}},stopGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n&&!t().abortInProgress){e({abortInProgress:!0});try{const l=await(await ke(`/api/sessions/${n}/stop`,{method:"POST"})).json();if(l.queuedMessages&&l.queuedMessages.length>0){const u=l.queuedMessages.map(c=>c.content).join(`
|
|
59
|
+
`);e({restoredInput:u})}}catch(o){console.error("Error stopping generation:",o)}}},continueGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n)try{await ke(`/api/sessions/${n}/continue`,{method:"POST"})}catch(o){console.error("Error continuing generation:",o)}},launchWorkflow:(n,r,o,l)=>{const u={};n!=null&&n.trim()&&(u.content=n),r&&r.length>0&&(u.attachments=r),o&&(u.workflowId=o),l&&(u.subGroup=l),Xt.send("runner.launch",u)},switchMode:async n=>{var o;const r=(o=t().currentSession)==null?void 0:o.id;if(r)try{const l=await ke(`/api/sessions/${r}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!l.ok){console.error("Failed to switch mode:",await l.json());return}const u=await l.json();u.session&&e({currentSession:u.session})}catch(l){console.error("Error switching mode:",l)}},switchDangerLevel:async n=>{var o;const r=(o=t().currentSession)==null?void 0:o.id;if(r)try{const l=await ke(`/api/sessions/${r}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!l.ok){console.error("Failed to switch danger level:",await l.json());return}const u=await l.json();u.session&&e({currentSession:u.session})}catch(l){console.error("Error switching danger level:",l)}},editCriteria:async n=>{var o;const r=(o=t().currentSession)==null?void 0:o.id;if(r)try{const l=await ke(`/api/sessions/${r}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});l.ok||console.error("Failed to update criteria:",await l.json())}catch(l){console.error("Error updating criteria:",l)}},compactContext:()=>{Xt.send("context.compact",{})},setSessionProvider:async(n,r)=>{var o;try{const l=(o=t().currentSession)==null?void 0:o.id;if(!l)return null;const u=await ke(`/api/sessions/${l}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...r?{model:r}:{}})});if(!u.ok)return null;const c=await u.json();return e({currentSession:c.session,messages:c.messages??[],contextState:c.contextState}),c.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,r)=>{e(o=>({subAgentContextStates:{...o.subAgentContextStates,[n]:r}}))},clearSubAgentContextState:n=>{e(r=>{const o={...r.subAgentContextStates};return delete o[n],{subAgentContextStates:o}})},confirmPath:async(n,r,o=!1)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l)try{await ke(`/api/sessions/${l}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:r,alwaysAllow:o})})}catch(c){console.error("Error confirming path:",c)}},answerQuestion:async(n,r,o)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l){try{await ke(`/api/sessions/${l}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:r,skip:o})})}catch(c){console.error("Error answering question:",c)}e(c=>({pendingQuestions:c.pendingQuestions.filter(d=>d.callId!==n)}))}},queueAsap:async(n,r,o)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await Wb(l,n,r,o,e)},queueCompletion:async(n,r,o)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await Wb(l,n,r,o,e)},cancelQueued:async n=>{var o;const r=(o=t().currentSession)==null?void 0:o.id;if(r)try{const u=await(await ke(`/api/sessions/${r}/queue/${n}`,{method:"DELETE"})).json();u.queueState&&e({queuedMessages:u.queueState})}catch(l){console.error("Error canceling queued message:",l)}},clearError:()=>{e({error:null})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{Vb(n,e,t)}}));function ed(){return Le(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function Pj(){return Le(e=>e.abortInProgress)}function Bj(){const e=Le(o=>o.connect),t=Le(o=>o.connectionStatus),n=Ai(o=>o.load),r=Ka("/p/:projectId/s/:sessionId/readonly")[0];return A.useEffect(()=>{r||e()},[e,r]),A.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const $j="modulepreload",zj=function(e){return"/"+e},qb={},Z=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));o=u(n.map(f=>{if(f=zj(f),f in qb)return;qb[f]=!0;const p=f.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":$j,p||(x.as="script"),x.crossOrigin="",x.href=f,d&&x.setAttribute("nonce",d),document.head.appendChild(x),p)return new Promise((y,w)=>{x.addEventListener("load",y),x.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function l(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return o.then(u=>{for(const c of u||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})},Hj=[{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"}],Uj=[{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"}},{id:"light",name:"Light",tokens:{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225"}},{id:"monokai",name:"Monokai",tokens:{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62"}},{id:"dracula",name:"Dracula",tokens:{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90"}},{id:"nord",name:"Nord",tokens:{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"76 86 106","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"76 86 106"}}],DS={tokens:Hj,presets:Uj},RS=DS.tokens,Gr=DS.presets;function Kb(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Yt=qn((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:Kb(),followSystemTheme:!0,isSystem:!1,applySavedTheme:()=>{const{getSavedTheme:n,applyPreset:r,applyTokens:o}=t(),l=n();if(l)try{const u=JSON.parse(l);u.preset&&u.tokens?(r(u.preset),e({basePreset:u.preset}),o(u.tokens)):u.preset?r(u.preset):u.tokens&&o(u.tokens)}catch{r("dark")}else r("dark")},applyPreset:n=>{if(Gr.find(o=>o.id===n))if(n==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";e({basePreset:"system",currentPreset:l,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0}),t().applyTheme()}else e({currentPreset:n,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1}),t().applyTheme()},startCustomizing:()=>{var o;const{currentPreset:n}=t(),r=((o=Gr.find(l=>l.id===n))==null?void 0:o.tokens)??{};e({basePreset:n,customTokens:{...r},isCustom:!0,isCustomizing:!0})},setCustomToken:(n,r)=>{e(o=>({customTokens:{...o.customTokens,[n]:r}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:n}=t();t().saveTheme(JSON.stringify({tokens:n})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:n=>{e({customTokens:n,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var u,c;const{basePreset:n,customTokens:r,isCustom:o}=t();if(o&&n)return{...((u=Gr.find(f=>f.id===n))==null?void 0:u.tokens)??{},...r};if(o)return{...RS.reduce((d,f)=>({...d,[f.key]:f.defaultValue}),{}),...r};const l=Gr.find(d=>d.id===t().currentPreset);return(l==null?void 0:l.tokens)??((c=Gr[0])==null?void 0:c.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const n=t().getActiveTheme(),r=document.documentElement;Object.entries(n).forEach(([o,l])=>{r.style.setProperty(`--${o}`,l)})},getSavedTheme:()=>{try{const n=localStorage.getItem("openfox:theme");if(!n)return null;if(n[0]!=="{")return JSON.stringify({preset:n});const r=JSON.parse(n);if(r.preset)return JSON.stringify({preset:r.preset});if(r.tokens)return JSON.stringify({tokens:r.tokens})}catch{return null}return null},saveTheme:async n=>{localStorage.setItem("openfox:theme",n);const{useSettingsStore:r}=await Z(async()=>{const{useSettingsStore:o}=await Promise.resolve().then(()=>Wf);return{useSettingsStore:o}},void 0);await r.getState().setSetting(Ie.DISPLAY_THEME,n)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:n=>{e({followSystemTheme:n}),Z(async()=>{const{useSettingsStore:r,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Wf);return{useSettingsStore:r,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:r,SETTINGS_KEYS:o})=>{r.getState().setSetting(o.DISPLAY_FOLLOW_SYSTEM_THEME,String(n))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const n=window.matchMedia("(prefers-color-scheme: dark)"),r=l=>{const{followSystemTheme:u}=t();u&&(t().applyPreset(l?"dark":"light"),t().saveTheme(JSON.stringify({preset:l?"dark":"light"})))},o=l=>r(l.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0})},addUserPreset:n=>{const{basePreset:r,customTokens:o,currentPreset:l}=t(),u={id:"custom-"+Date.now(),name:n,basePreset:r||l,tokens:{...o}},c=[...t().userPresets,u];e({userPresets:c}),t().saveUserPresets()},applyUserPreset:n=>{const r=t().userPresets[n];r&&(e({currentPreset:r.basePreset,basePreset:r.basePreset,customTokens:{...r.tokens},isCustom:!0,isCustomizing:!1}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:r.basePreset,tokens:r.tokens})).catch(()=>{}))},deleteUserPreset:n=>{const r=t().userPresets.filter((o,l)=>l!==n);e({userPresets:r}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:Kb()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),Z(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>Wf);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting(Ie.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function Fj({canLoad:e,projectId:t,currentProjectId:n}){const r=Ut(u=>u.loadProject),o=Le(u=>u.listSessions),l=Le(u=>u.clearSession);A.useEffect(()=>{e&&t&&(n!==t&&r(t),o(t),l())},[e,t,n,r,o,l])}function Vj({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:o}){const l=Le(f=>f.loadSession),u=Ut(f=>f.loadProject),c=Le(f=>f.listSessions),d=Le(f=>f.pendingSessionCreate);A.useEffect(()=>{e&&t&&r!==t&&u(t)},[e,t,r,u]),A.useEffect(()=>{e&&n&&o!==n&&l(n),e&&t&&c(t)},[e,n,o,l,c,d,t])}function Gj({className:e="w-5 h-5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function OS({className:e="w-3.5 h-3.5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function Wj({className:e="w-5 h-5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 qj({className:e="w-3 h-3 text-text-muted"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Ma({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:a.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 Wr({className:e="w-3.5 h-3.5 text-text-muted"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Wn({className:e="w-3 h-3 text-text-muted",rotate:t}){return a.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:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Kj({className:e="w-4 h-4"}){return a.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Ap({className:e="w-3.5 h-3.5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Yj({className:e="w-3 h-3"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Lp({className:e="w-4 h-4"}){return a.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[a.jsx("circle",{cx:"12",cy:"5",r:"2"}),a.jsx("circle",{cx:"12",cy:"12",r:"2"}),a.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Eu({className:e="w-3.5 h-3.5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Tl({className:e="w-5 h-5 text-accent-primary"}){return a.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:a.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 Xj({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Qj({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Jj({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:a.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 MS({className:e="w-3 h-3"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Zj({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Yb({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function IS({className:e="w-[18px] h-[18px]"}){return a.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[a.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),a.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function eN({className:e="w-4 h-4"}){return a.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.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"}),a.jsx("path",{d:"M9.5 2h4.5v4.5"}),a.jsx("path",{d:"M14 2L7.5 8.5"})]})}function tN({className:e="w-3 h-3",color:t}){return a.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{d:"M8 5v14l11-7z"})})}function ti({className:e="w-3 h-3 text-accent-primary"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function nN({className:e="w-5 h-5"}){return a.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:a.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 Dp({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 rN({className:e="w-4 h-4"}){return a.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[a.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"}),a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function sN({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return a.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[a.jsx("title",{children:"Running"}),a.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),a.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function PS({className:e="w-3.5 h-3.5 text-text-muted"}){return a.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:a.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 BS({className:e="w-3.5 h-3.5 text-text-muted"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 $S({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:a.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function iN({className:e="w-3.5 h-3.5 shrink-0",color:t}){return a.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:a.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 aN({className:e="w-4 h-4"}){return a.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"4 17 10 11 4 5"}),a.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Ya({className:e="w-3.5 h-3.5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 yl({className:e="w-3.5 h-3.5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 oN({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Vm({className:e="w-2.5 h-2.5"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Xa({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:a.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 zS({className:e="w-4 h-4"}){return a.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:a.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 lN({className:e="w-3.5 h-3.5 text-text-muted"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 cN({className:e="w-3.5 h-3.5 text-text-muted"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Xb({className:e="w-3.5 h-3.5 text-text-muted"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 Gm(){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 Qb(e,t){const n=Xt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Gm(),type:e,payload:t}))}const Ar=qn((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const r=await ke(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const o=await r.json();e({sessions:o});const l=Xt.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of o)l.send(JSON.stringify({id:Gm(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const o=await ke("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(o.ok){const l=await o.json();e(c=>({sessions:[...c.sessions,l]}));const u=Xt.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:Gm(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(o){console.error("Failed to create terminal:",o)}},writeSession:(n,r)=>{Qb("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,o)=>{Qb("terminal.resize",{sessionId:n,cols:r,rows:o})},killSession:async n=>{try{(await ke(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(o=>({sessions:o.sessions.filter(l=>l.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(o=>{const l=o.sessions.filter(u=>u.id!==r);return l.length===0&&o.isOpen?{sessions:[],isOpen:!1}:{sessions:l}});break}}}}));Xt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&Ar.getState().handleMessage(e)});const Ia={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function Wm(e){if(!e)return structuredClone(Ia);try{const t=JSON.parse(e);return{terminalToggle:t.terminalToggle??structuredClone(Ia.terminalToggle),quickAction:t.quickAction??structuredClone(Ia.quickAction),agentSwitching:t.agentSwitching??structuredClone(Ia.agentSwitching)}}catch{return structuredClone(Ia)}}function Jb(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function HS(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 uN(e){return e.type==="double-press"}function US(e){return e.type==="chord"}function dN(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.code===`Key${t.toUpperCase()}`:t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function FS(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),o=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return dN(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===o&&e.shiftKey===l}function Rp(){const e=tn(t=>t.settings[Ie.KEYBINDINGS]);return Wm(e)}function hN(e,t,n){const r=A.useRef(0),o=A.useRef(t);o.current=t,A.useEffect(()=>{if(!e)return;const l=e.threshold??300,u=c=>{if(c.key!==e.key)return;const d=e.key==="Control",f=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!d&&c.ctrlKey||!f&&c.shiftKey||!p&&c.altKey||!m&&c.metaKey)return;const x=Date.now();x-r.current<l?(c.preventDefault(),c.stopPropagation(),o.current(),r.current=0):r.current=x};return window.addEventListener("keydown",u,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",u,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function fN(e,t){const n=A.useRef(t);n.current=t,A.useEffect(()=>{if(!e)return;const r=o=>{FS(o,e)&&(o.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function VS(e,t,n){hN(e&&uN(e)?e:void 0,t,n),fN(e&&US(e)?e:void 0,t)}function mN(e,t,n){const r=A.useRef(n);r.current=n,A.useEffect(()=>{const o=l=>{for(let u=0;u<e.length;u++){const c=e[u];if(!c)continue;const d=t[u];if(d&&US(c)&&FS(l,c)){l.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,t])}var Qa=gS();const td=A.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},o)=>a.jsx("button",{ref:o,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:a.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));td.displayName="IconButton";const pN="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",Qs=A.forwardRef((e,t)=>a.jsx(td,{ref:t,icon:pN,title:"Edit",...e}));Qs.displayName="EditButton";const gN="M6 18L18 6M6 6l12 12",Op=A.forwardRef((e,t)=>a.jsx(td,{ref:t,icon:gN,...e}));Op.displayName="CloseButton";const xN={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 Ot({label:e,title:t,headerRight:n,size:r="md",minHeight:o,children:l,footer:u,className:c,onClose:d,isOpen:f,closeOnBackdropClick:p=!0,closeOnEscape:m=!0,showCloseButton:x=!0,scrollable:y=!0}){const[w,C]=A.useState(!1),v=f!==void 0,S=v?f:w,b=A.useCallback(()=>{v||C(!0)},[v]),_=A.useCallback(()=>{v||C(!1),d==null||d()},[v,d]);A.useEffect(()=>{if(!S||!m)return;const E=T=>{T.key==="Escape"&&(T.stopPropagation(),_())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[S,_,m]);const j=e&&(typeof e=="string"?a.jsx("button",{type:"button",onClick:b,className:c,children:e}):a.jsx("span",{onClick:b,className:c,style:{cursor:"pointer"},children:e}));return a.jsxs(a.Fragment,{children:[j,S&&(typeof document<"u"?Qa.createPortal(a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p?_:void 0}),a.jsxs("div",{className:`relative w-full ${xN[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||x)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&a.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[n,x&&a.jsx(Op,{onClick:_,"aria-label":"Close"})]})]}),a.jsx("div",{className:`p-4 flex-1 min-h-0${y?" overflow-y-auto":" overflow-hidden flex flex-col"}`,style:o?{minHeight:o}:void 0,children:l}),u&&a.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}function yN({value:e,defaultUrl:t,disabled:n,onChange:r}){const o=e??t;return a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:o,disabled:n,onChange:l=>{const u=l.target.value;r(u===t?null:u)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:Sj.map(({url:l,label:u})=>a.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),a.jsx(Wn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const Zb=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function _N(){const e=Ai(d=>d.settings),t=Ai(d=>d.update),n=Ai(d=>d.updateEvent),r=Ai(d=>d.updateAgentOverride),o=Ai(d=>d.load);A.useEffect(()=>{o()},[o]);const l=async()=>{await Cj()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(d,f,p,m)=>{d==="general"?n(f,{[p]:m}):r(d,f,{[p]:m})},c=(d,f,p)=>{d==="general"?n(f,{customSoundUrl:p}):r(d,f,{customSoundUrl:p})};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-3",children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),a.jsx(ev,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),a.jsx(ev,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:d=>{d&&typeof Notification<"u"&&Notification.permission!=="granted"?l():t({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&a.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),a.jsx("div",{className:"border border-border rounded overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:a.jsxs("tr",{className:"border-b border-border",children:[a.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),Zb.map(d=>a.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),a.jsx("tbody",{children:vj.map(d=>a.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),Zb.map(f=>{const p=AS(e,d.key,f.key==="general"?void 0:f.key),m=NS[d.key];return a.jsx("td",{className:"px-2 py-2 align-top",children:a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:a.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:x=>u(f.key,d.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),a.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:a.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>u(f.key,d.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&a.jsx(yN,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:x=>c(f.key,d.key,x)})]})},f.key)})]},d.key))})]})})]})]})}function ev({label:e,description:t,checked:n,onChange:r}){return a.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),a.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),a.jsx("div",{className:"flex-shrink-0 pt-0.5",children:a.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:o=>{o.preventDefault(),r(!n)},children:a.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 rt=A.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...o},l)=>{const u="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},d={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return a.jsx("button",{ref:l,className:`${u} ${c[e]} ${d[t]} ${n}`,...o,children:r})});rt.displayName="Button";async function tv(e,t,n){try{const r=await ke(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}const kn=qn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,fetchSkills:async()=>{e({loading:!0});try{const r=await(await ke("/api/skills")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],items:r.items??[],selectedDirectory:r.selectedDirectory??null,diagnostics:r.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const o=await(await ke(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(l=>({defaults:l.defaults.map(u=>u.id===n?{...u,enabled:o.enabled}:u),userItems:l.userItems.map(u=>u.id===n?{...u,enabled:o.enabled}:u),projectItems:l.projectItems.map(u=>u.id===n?{...u,enabled:o.enabled}:u),items:l.items.map(u=>u.id===n?{...u,enabled:o.enabled}:u)}))}catch{}},fetchSkill:async n=>{try{const r=await ke(`/api/skills/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const o=await ei("POST","/api/skills",{...n,destination:r});return o.success&&await t().fetchSkills(),o},updateSkill:async(n,r)=>{const o=await ei("PUT",`/api/skills/${n}`,r);return o.success&&await t().fetchSkills(),o},deleteSkill:async n=>{try{const r=await ke(`/api/skills/${n}`,{method:"DELETE"}),o=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>Zu(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),r),selectDirectory:async n=>tv("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await ke("/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(o=>o.path)));for(const o of n.files)r.append("files",o.file,o.file.name);return tv("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function nd(){const[e,t]=A.useState({id:null,type:null}),n=A.useCallback(l=>t({id:l,type:"delete"}),[]),r=A.useCallback(()=>t({id:null,type:null}),[]),o=A.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:o}}function Mp({onConfirm:e,onCancel:t}){return a.jsxs("div",{className:"flex items-center gap-1",children:[a.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"}),a.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 Ip({onClick:e}){return a.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:a.jsx(Ya,{})})}function ju({onClick:e}){return a.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:a.jsx(Ap,{})})}function Dr({label:e,value:t,onChange:n,placeholder:r,readOnly:o,hint:l,mono:u}){return a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,l&&a.jsx("span",{className:"text-text-muted ml-1",children:l})]}),a.jsx("input",{value:t,onChange:c=>n(c.target.value),readOnly:o,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${u?"font-mono":""} ${o?"opacity-60":""}`})]})}function bN({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return a.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[a.jsx(rt,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(rt,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function rd({message:e}){return a.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function GS({description:e,onNew:t,loading:n,hasItems:r,children:o}){return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("p",{className:"text-text-secondary text-sm",children:e}),a.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:a.jsx(rt,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?a.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?o:a.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function WS({label:e="Custom",children:t}){return a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),a.jsx("div",{className:"space-y-2",children:t})]})}function qS({description:e,onNew:t,newLabel:n="+ New"}){return a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("p",{className:"text-text-secondary text-sm",children:e}),a.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:a.jsx(rt,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function Pp({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:o}){return e&&!t?a.jsx("div",{className:"text-text-muted text-sm",children:n}):t?a.jsx("div",{className:"space-y-4",children:o}):r?a.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function KS({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:o="My Item",idPlaceholder:l="my-item",nameHint:u,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:f,onIdChange:p}){return a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Dr,{label:n,value:e,onChange:f,placeholder:o,hint:u}),a.jsx(Dr,{label:r,value:t,onChange:p,readOnly:c,placeholder:l,hint:c?d:void 0,mono:!0})]})}function YS(e={}){const{initialData:t={}}=e,[n,r]=A.useState("list"),[o,l]=A.useState(null),[u,c]=A.useState(""),[d,f]=A.useState(!1),[p,m]=A.useState(t),x=A.useCallback(()=>{m(t),c(""),l(null)},[t]),y=A.useCallback(S=>{r(S),S==="list"&&x()},[x]),w=A.useCallback(S=>{m(b=>typeof S=="function"?S(b):S)},[]),C=A.useCallback((S,b={})=>{l(S),r("edit"),m({...b}),c("")},[]),v=A.useCallback(()=>{l(null),r("edit"),m(t),c("")},[t]);return{view:n,editingId:o,formError:u,saving:d,formData:p,setView:y,setEditingId:l,setFormError:c,setFormData:w,setSaving:f,resetForm:x,startEditing:C,startNew:v}}const vN={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function ni({size:e="md",className:t=""}){return a.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${vN[e]} ${t}`})}function SN({text:e,...t}){return a.jsxs("div",{className:"text-center",children:[a.jsx(ni,{...t,className:"mx-auto mb-4"}),e&&a.jsx("div",{className:"text-text-secondary",children:e})]})}function XS(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function wN(e){const t=e.includes("\\")?"\\":"/";return e.split(/[\\/]/).filter(Boolean).map((n,r,o)=>({name:n,path:t==="/"?"/"+o.slice(0,r+1).join("/"):o.slice(0,r+1).join("\\")+(r===0?"\\":"")}))}function QS(e,t=28){if(e.length<=t)return e;const n=e.split("/").filter(Boolean);if(n.length<=2)return e;const r=n[0],o=n[n.length-1],l=n.slice(1,-1).join("/"),u=t-r.length-o.length-3;if(u<0)return e;const c=l.slice(0,Math.floor(u/2)),d=l.slice(-Math.ceil(u/2));return`/${r}/${c}...${d}/${o}`}const Ii=A.forwardRef(({className:e="",...t},n)=>a.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}));Ii.displayName="Input";function sd({onSelect:e,onClose:t,initialPath:n}){const[r,o]=A.useState(null),[l,u]=A.useState(!0),[c,d]=A.useState(""),[f,p]=A.useState(-1),m=A.useRef(null),x=A.useRef(null),y=A.useCallback(async _=>{u(!0),d(""),p(-1);try{const j=_?`/api/directories?path=${encodeURIComponent(_)}`:"/api/directories",T=await(await ke(j)).json();o(T)}catch(j){console.error("Failed to load directories:",j)}finally{u(!1)}},[]);A.useEffect(()=>{y(n)},[n,y]);const w=wN((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(_=>c===""||_.name.toLowerCase().includes(c.toLowerCase())))??[],v=[...!c&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(_=>({type:"dir",path:_.path,name:_.name}))];A.useEffect(()=>{p(c?0:-1)},[c,C.length]),A.useEffect(()=>{if(f>=0&&x.current){const _=x.current.querySelector(`[data-index="${f}"]`);_==null||_.scrollIntoView({block:"nearest"})}},[f]);const S=_=>{var j;if(_.key==="ArrowDown")_.preventDefault(),p(E=>Math.min(E+1,v.length-1));else if(_.key==="ArrowUp")_.preventDefault(),p(E=>Math.max(E-1,0));else if(_.key==="Enter"){if(f<0||!v[f]||_.target instanceof HTMLElement&&_.target.dataset.select==="true")return;_.preventDefault(),_.shiftKey?y(v[f].path):e(v[f].path)}else _.key==="Escape"&&(d(""),(j=m.current)==null||j.focus())},b=a.jsx("div",{className:"flex flex-col gap-2",children:a.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return a.jsx(Ot,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:b,scrollable:!1,children:a.jsxs("div",{ref:x,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[a.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&a.jsx("div",{className:"px-3 pt-3 pb-1",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((_,j)=>a.jsxs("span",{className:"flex items-center shrink-0",children:[a.jsx("span",{className:"text-text-muted",children:"/"}),a.jsx("button",{onClick:()=>y(_.path),className:`px-1 ${j===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:_.name})]},_.path)),w.length===0&&a.jsx("button",{onClick:()=>y("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&a.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"})]})}),a.jsx("div",{className:"px-4 py-2",children:a.jsxs("div",{className:"relative",children:[a.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:a.jsx(yl,{})}),a.jsx(Ii,{autoFocus:!0,ref:m,value:c,onChange:_=>d(_.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:l?a.jsx("div",{className:"p-8 text-center",children:a.jsx(ni,{size:"sm"})}):v.length===0?a.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:c?"No matching directories":"No subdirectories"}):a.jsx("div",{className:"divide-y divide-border",children:v.map((_,j)=>a.jsxs("div",{"data-index":j,className:`group flex items-center ${j===f?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[a.jsxs("button",{onClick:()=>{y(_.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[_.type==="parent"?a.jsx(Gj,{className:"w-5 h-5 text-text-muted shrink-0"}):a.jsx(Tl,{className:"w-5 h-5 shrink-0"}),a.jsx("span",{className:"truncate",children:_.name}),_.type==="dir"&&a.jsx(Wn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${j===f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),_.type==="dir"&&a.jsx("button",{"data-select":"true",tabIndex:j===f?0:-1,onClick:E=>{E.stopPropagation(),e(_.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===f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${_.name}`,children:"Select"})]},_.path))})})]})})}function JS(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 CN(e){const t=[...e];if(!t.length)throw new Error("Choose one skill folder.");const n=new Set(t.map(o=>o.webkitRelativePath.split("/")[0]).filter(Boolean));if(n.size!==1)throw new Error("Choose exactly one skill folder.");const r=[...n][0];return JS(r,t.map(o=>({path:o.webkitRelativePath.slice(r.length+1),file:o})))}function kN(e){return new Promise((t,n)=>e.file(t,n))}async function ZS(e,t=""){const n=e.createReader(),r=[];for(;;){const l=await new Promise((u,c)=>n.readEntries(u,c));if(!l.length)break;r.push(...l)}return(await Promise.all(r.map(async l=>{const u=t?`${t}/${l.name}`:l.name;return l.isDirectory?ZS(l,u):[{path:u,file:await kN(l)}]}))).flat()}async function EN(e){const t=[...e.items].filter(r=>r.kind==="file").map(r=>{var o;return((o=r.webkitGetAsEntry)==null?void 0:o.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 JS(n.name,await ZS(n))}function jN({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:o}){const[l,u]=A.useState(!1),[c,d]=A.useState(!1),[f,p]=A.useState(""),m=A.useRef(null);A.useEffect(()=>{var C;(C=m.current)==null||C.setAttribute("webkitdirectory","")},[]);const x=async C=>{if(!window.confirm("Skills may contain instructions and scripts. Select this folder for discovery without executing package content?"))return;const S=await t(C);if(S&&!S.success){p(S.error??"Cannot use selected folder.");return}u(!1)},y=async C=>{d(!0),p("");const v=await o(C);d(!1),v.success||p(v.error??"Failed to install skill package.")},w=async C=>{if(C.preventDefault(),!(!(e!=null&&e.available)||c))try{await y(await EN(C.dataTransfer))}catch(v){p(v instanceof Error?v.message:"Invalid skill folder.")}};return a.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),a.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),a.jsxs("div",{className:"flex shrink-0 gap-2",children:[a.jsx(rt,{variant:"secondary",onClick:()=>u(!0),children:"Change folder"}),e&&a.jsxs(a.Fragment,{children:[a.jsx(rt,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&a.jsx(rt,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),a.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||c,onClick:()=>{var C;return(C=m.current)==null?void 0:C.click()},onDragOver:C=>C.preventDefault(),onDrop:w,className:"mt-3 w-full rounded border border-dashed border-border px-4 py-5 text-center text-xs text-text-secondary disabled:cursor-not-allowed disabled:opacity-50",children:e!=null&&e.available?c?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),a.jsx("input",{ref:m,hidden:!0,type:"file",multiple:!0,onChange:C=>{var v;if((v=C.target.files)!=null&&v.length)try{y(CN(C.target.files))}catch(S){p(S instanceof Error?S.message:"Invalid skill folder.")}finally{C.target.value=""}}}),f&&a.jsx("p",{className:"mt-2 text-xs text-error",children:f}),l&&a.jsx(sd,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:x,onClose:()=>u(!1)})]})}function Nu({enabled:e,onClick:t,label:n}){return a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function e1({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:o,onDelete:l,actions:u,children:c}){return a.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[a.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c}),a.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&a.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:a.jsx(Eu,{})}),a.jsx(ju,{onClick:o}),!e&&r&&a.jsx(Qs,{onClick:r}),!e&&l&&(t?a.jsx(Mp,{onConfirm:()=>{l==null||l()},onCancel:()=>{}}):a.jsx(Ip,{onClick:()=>l==null?void 0:l()})),u]})]})}function NN({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:o,onView:l,onEdit:u,onDuplicate:c,onDelete:d,actions:f}){return a.jsxs(e1,{isBuiltIn:r,isConfirmingDelete:o,onView:l,onEdit:u,onDuplicate:c,onDelete:d,actions:f,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),a.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&a.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function nv({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:o,onDuplicate:l,onDelete:u,onToggle:c,readOnly:d=!1}){return a.jsx(NN,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:d?void 0:o,onDuplicate:l,onDelete:d?void 0:u,actions:a.jsx(Nu,{enabled:e.enabled,onClick:c,label:`Activation for ${e.name}`})})}function TN({skill:e,deleting:t,error:n,onClose:r,onConfirm:o}){return a.jsxs(Ot,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(rt,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),a.jsx(rt,{variant:"danger",onClick:o,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[a.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),a.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&a.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&a.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function AN({isOpen:e}){const t=kn(te=>te.defaults),n=kn(te=>te.userItems),r=kn(te=>te.projectItems),o=kn(te=>te.items),l=kn(te=>te.selectedDirectory),u=kn(te=>te.diagnostics),c=kn(te=>te.loading),d=kn(te=>te.fetchSkills),f=kn(te=>te.fetchSkill),p=kn(te=>te.fetchDefaultContent),m=kn(te=>te.createSkill),x=kn(te=>te.updateSkill),y=kn(te=>te.deleteSkill),w=kn(te=>te.selectDirectory),C=kn(te=>te.removeDirectory),v=kn(te=>te.installSkill),S=kn(te=>te.toggleSkill),[b,_]=A.useState(null),[j,E]=A.useState(!1),[T,D]=A.useState(""),{view:L,editingId:O,formError:P,saving:q,formData:W,setView:M,setEditingId:H,setFormError:V,setFormData:U,setSaving:Q}=YS(),{clearConfirm:X}=nd();A.useEffect(()=>{e&&(d(),M("list"),H(null),X())},[e,d,X]);const z=(te,re,pe,be)=>{U({name:be??te.metadata.name,id:pe??te.metadata.id,description:te.metadata.description??"",version:te.metadata.version??"1.0.0",prompt:te.prompt,isReadOnly:re,destination:"user"})},R=async te=>{if(t.some(pe=>pe.id===te)){const pe=await p(te);if(!pe)return;z(pe,!0),H(te),V(""),M("edit")}else{const pe=await f(te);if(!pe)return;z(pe,!0),H(te),V(""),M("edit")}},I=async te=>{const pe=t.some(Pe=>Pe.id===te)?await p(te):await f(te);if(!pe)return;const be=`${te}-copy-${Date.now()}`;z(pe,!1,be,`${pe.metadata.name} (copy)`),H(null),V(""),M("edit")},G=()=>{U({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),M("edit")},B=async te=>{const re=await f(te);re&&(z(re,!1),H(te),V(""),M("edit"))},ee=async()=>{if(!b)return;E(!0),D("");const te=await y(b.id);if(E(!1),!te.success){D(te.error??"Failed to delete skill.");return}await d(),_(null),X()},J=async()=>{const te=O??W.id;if(!te||!W.name||!W.prompt){V("Name, ID, and prompt are required.");return}Q(!0),V("");const re={metadata:{id:te,name:W.name,description:W.description,version:W.version},prompt:W.prompt},pe=O?await x(O,re):await m(re,W.destination);if(Q(!1),!pe.success){V(pe.error??"Failed to save skill.");return}M("list")},ne=te=>{U(re=>({...re,name:te})),O||U(re=>({...re,id:te.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},K=W.isReadOnly;if(L==="edit")return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"flex justify-between items-center mb-3",children:[a.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:K?W.name:O?"Edit Skill":"New Skill"}),a.jsx("button",{onClick:()=>M("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),P&&a.jsx(rd,{message:P}),a.jsxs("div",{className:"space-y-3 mb-3",children:[a.jsx(KS,{name:W.name,id:W.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:ne,onIdChange:()=>{}}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Dr,{label:"Description",value:W.description,onChange:te=>U(re=>({...re,description:te})),placeholder:"What this skill does...",readOnly:K}),a.jsx(Dr,{label:"Version",value:W.version,onChange:te=>U(re=>({...re,version:te})),placeholder:"1.0.0",readOnly:K})]})]}),a.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),a.jsx("textarea",{value:W.prompt,onChange:te=>U(re=>({...re,prompt:te.target.value})),readOnly:K,placeholder:"The system prompt for this skill...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!O&&a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),a.jsxs("select",{value:W.destination,onChange:te=>U(re=>({...re,destination:te.target.value})),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[a.jsx("option",{value:"user",children:"Global config"}),a.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[a.jsx(rt,{variant:"secondary",onClick:()=>M("list"),children:"Cancel"}),K?a.jsx(rt,{variant:"primary",onClick:()=>{U(te=>({...te,name:te.name+" (copy)",id:`${O}-copy-${Date.now()}`,isReadOnly:!1})),H(null)},children:"Duplicate & Customize"}):a.jsx(rt,{variant:"primary",onClick:J,disabled:q||!W.name||!W.id||!W.prompt,children:q?"Saving...":"Save"})]})]});function F({items:te}){return te.map(re=>a.jsx(nv,{skill:re,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>R(re.id),onEdit:()=>B(re.id),onDuplicate:()=>I(re.id),onDelete:()=>{D(""),_(re)},onToggle:()=>S(re.id),readOnly:re.readOnly},re.id))}return a.jsxs("div",{children:[a.jsx(TN,{skill:b,deleting:j,error:T,onClose:()=>{j||_(null)},onConfirm:ee}),a.jsx(jN,{selectedDirectory:l,onSelect:w,onRemove:C,onRefresh:d,onInstall:v}),u.length>0&&a.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:u.map((te,re)=>a.jsx("p",{children:te},`${te}-${re}`))}),a.jsx(qS,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:G}),a.jsxs(Pp,{loading:c,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),a.jsx("div",{className:"space-y-2",children:t.map(te=>a.jsx(nv,{skill:te,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>R(te.id),onDuplicate:()=>I(te.id),onToggle:()=>S(te.id)},te.id))})]}),n.length>0&&a.jsx(WS,{children:a.jsx(F,{items:n})}),o.some(te=>["global-shared","selected","project-shared"].includes(te.source))&&a.jsxs("div",{className:"mt-4",children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),a.jsx("div",{className:"space-y-2",children:a.jsx(F,{items:o.filter(te=>["global-shared","selected","project-shared"].includes(te.source))})})]}),r.length>0&&a.jsxs("div",{className:"mt-4",children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),a.jsx("div",{className:"space-y-2",children:a.jsx(F,{items:r})})]})]})]})}function Al(){const e=tn(o=>o.settings),t=tn(o=>o.loading),n=tn(o=>o.getSetting),r=tn(o=>o.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function LN({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:o}=Al(),l=t[Ie.GLOBAL_INSTRUCTIONS]??"",u=n[Ie.GLOBAL_INSTRUCTIONS]??!1,[c,d]=A.useState(l),[f,p]=A.useState(!1),[m,x]=A.useState(!1);A.useEffect(()=>{e&&r(Ie.GLOBAL_INSTRUCTIONS)},[e,r]),A.useEffect(()=>{d(l),p(!1)},[l]);const y=async()=>{x(!0),await o(Ie.GLOBAL_INSTRUCTIONS,c),x(!1),p(!1)},w=()=>{d(l),p(!1)},C=u||m;return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),a.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),a.jsx("textarea",{value:c,onChange:v=>{d(v.target.value),p(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(rt,{variant:"secondary",onClick:w,disabled:!f,children:"Discard"}),a.jsx(rt,{variant:"primary",onClick:y,disabled:!f||C,children:m?"Saving...":"Save"})]})]})}function DN(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),o=parseInt(t[3]??"0",16);return`${n} ${r} ${o}`}return e}function Ti(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 RN({isOpen:e,isNew:t,basePresetId:n,presetName:r,initialTokens:o,onClose:l,onSave:u}){const[c,d]=A.useState(o),[f,p]=A.useState(r);A.useEffect(()=>{d(o),p(r)},[o,r]);const m=(v,S)=>{const b=S.startsWith("#")?DN(S):S;d(_=>({..._,[v]:b}))},x=()=>{u(f.trim()||"Untitled",{...c})},y=RS.reduce((v,S)=>{const b=S.category;return v[b]||(v[b]=[]),v[b].push(S),v},{}),w={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},C=Gr.find(v=>v.id===n);return a.jsx(Ot,{isOpen:e,onClose:l,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{type:"button",onClick:l,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),a.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),a.jsx("input",{type:"text",value:f,onChange:v=>p(v.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!t&&a.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",a.jsx("span",{className:"text-text-primary",children:C==null?void 0:C.name})]}),Object.entries(y).map(([v,S])=>a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:w[v]??v}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:S.map(b=>a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("label",{htmlFor:b.key,className:"text-xs text-text-muted",children:b.label}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"color",id:b.key,value:Ti(c[b.key]??b.defaultValue),onChange:_=>m(b.key,_.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),a.jsx("input",{type:"text",value:c[b.key]??b.defaultValue,onChange:_=>m(b.key,_.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"})]})]},b.key))})]},v))]})})}function ON(){const[e,t]=A.useState(null),n=Yt(_=>_.currentPreset),r=Yt(_=>_.isCustom),o=Yt(_=>_.basePreset),l=Yt(_=>_.isSystem),u=Yt(_=>_.applyPreset),c=Yt(_=>_.applyUserPreset),d=Yt(_=>_.deleteUserPreset),f=Yt(_=>_.saveTheme),p=Yt(_=>_.userPresets),m=_=>{_==="system"?(u(_),f(JSON.stringify({preset:"system"})).catch(()=>{})):(u(_),f(JSON.stringify({preset:_})).catch(()=>{}))},x=_=>{c(_)},y=_=>{const j=Gr.find(E=>E.id===_);j&&t({type:"new",presetIndex:p.length,basePresetId:_,presetName:j.name+" Copy",tokens:{...j.tokens}})},w=_=>{const j=p[_];if(!j)return;const E=Gr.find(D=>D.id===j.basePreset),T=E?{...E.tokens,...j.tokens}:j.tokens;t({type:"edit",presetIndex:_,basePresetId:j.basePreset,presetName:j.name,tokens:T})},C=(_,j)=>{if(!e)return;const E=[...p];if(e.type==="new"){const T={id:"custom-"+Date.now(),name:_,basePreset:e.basePresetId,tokens:j};E.push(T);const D=E.length-1;Yt.setState({userPresets:E}),Yt.getState().saveUserPresets(),Yt.getState().applyUserPreset(D)}else{const T=E[e.presetIndex];T&&(E[e.presetIndex]={...T,name:_,tokens:j}),Yt.setState({userPresets:E}),Yt.getState().saveUserPresets(),Yt.getState().applyUserPreset(e.presetIndex)}t(null)},v=()=>{t(null)},S=(_,j)=>{_.stopPropagation(),d(j)},b=l?"system":r?o:n;return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),a.jsx("div",{className:"flex flex-wrap gap-2 pb-2",children:Gr.map(_=>{const j=_.id===b&&!r;return a.jsxs("div",{className:"relative group",children:[a.jsxs("button",{type:"button",onClick:()=>m(_.id),className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${j?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[a.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:_.id==="system"?"transparent":Ti(_.tokens["color-bg-primary"]??"#000"),borderColor:Ti(_.tokens["color-border"]??"#000")},children:_.id==="system"?a.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ti(_.tokens["color-text-primary"]??"#fff")}})}),a.jsx("span",{className:"text-xs",children:_.name})]}),_.id!=="system"&&a.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),y(_.id)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:a.jsx("span",{className:"text-xs",children:"✎"})})]},_.id)})}),p.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),a.jsx("div",{className:"grid grid-cols-5 gap-2",children:p.map((_,j)=>{const E=Gr.find(D=>D.id===_.basePreset),T=E?{...E.tokens,..._.tokens}:_.tokens;return a.jsxs("div",{className:"relative group",children:[a.jsxs("button",{type:"button",onClick:()=>x(j),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${r&&o===_.basePreset&&b===_.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[a.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:Ti(T["color-bg-primary"]??"#000"),borderColor:Ti(T["color-border"]??"#000")},children:a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ti(T["color-text-primary"]??"#fff")}})}),a.jsx("span",{className:"text-xs truncate w-full text-center",children:_.name})]}),a.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),w(j)},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:a.jsx("span",{className:"text-xs",children:"✎"})}),a.jsx("button",{type:"button",onClick:D=>S(D,j),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:a.jsx(Xa,{className:"w-3 h-3"})})]},_.id)})})]}),e&&a.jsx(RN,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:v,onSave:C})]})}function MN(){return a.jsx(ON,{})}function IN(){const{settings:e,loading:t,getSetting:n,setSetting:r}=Al(),o=t[Ie.DISPLAY_SHOW_THINKING]??!1,l=e[Ie.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[u,c]=A.useState(l);A.useEffect(()=>{n(Ie.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),A.useEffect(()=>{c(l)},[l]);const d=()=>{const w=parseInt(u,10),C=isNaN(w)||w<0?0:Math.min(w,9999);c(String(C)),r(Ie.DISPLAY_MAX_VISIBLE_ITEMS,String(C))},f=[{key:Ie.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Ie.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Ie.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Ie.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Ie.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:Ie.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews"}],p=Object.fromEntries(f.map(w=>[w.key,e[w.key]??"true"])),[m,x]=A.useState(()=>Object.fromEntries(f.map(w=>[w.key,p[w.key]==="true"])));A.useEffect(()=>{f.forEach(w=>n(w.key))},[n]),A.useEffect(()=>{x(Object.fromEntries(f.map(w=>[w.key,p[w.key]==="true"])))},[JSON.stringify(p)]);const y=async w=>{const C=String(!m[w]);x(v=>({...v,[w]:!v[w]})),await r(w,C)};return o?a.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):a.jsxs("div",{className:"space-y-6",children:[a.jsx(MN,{}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),a.jsx("div",{className:"space-y-4",children:f.map(({key:w,label:C,description:v})=>a.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm text-text-primary font-medium",children:C}),a.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:v})]}),a.jsx("button",{type:"button",onClick:()=>y(w),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${m[w]?"bg-accent-primary":"bg-bg-tertiary"}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${m[w]?"translate-x-6":"translate-x-1"}`})})]},w))})]}),a.jsx("div",{className:"border-t border-border pt-4",children:a.jsxs("label",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),a.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."})]}),a.jsx("input",{type:"number",min:0,max:9999,value:u,onChange:w=>{const C=w.target.value.replace(/[^0-9]/g,"");c(C)},onBlur:d,onKeyDown:w=>{w.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})})]})}function PN(e){try{return new RegExp(e),!0}catch{return!1}}function BN({value:e,onChange:t}){const[n,r]=A.useState({}),o=(d,f)=>{const p=e.patterns.map((m,x)=>x===d?{...m,...f}:m);t({...e,patterns:p})},l=d=>{const f=e.patterns.filter((p,m)=>m!==d);t({...e,patterns:f})},u=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},c=(d,f)=>{r(p=>({...p,[d]:f.length>0&&!PN(f)})),o(d,{pattern:f})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),a.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:d=>{const f=parseInt(d.target.value,10),p=isNaN(f)?10:Math.max(1,Math.min(100,f));t({...e,maxRetriesPerTurn:p})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?a.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[a.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),a.jsx("th",{className:"pb-2 pr-2",children:"Field"}),a.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),a.jsx("th",{className:"pb-2 pr-2",children:"Action"}),a.jsx("th",{className:"pb-2 w-8"})]})}),a.jsx("tbody",{children:e.patterns.map((d,f)=>a.jsxs("tr",{className:"border-b border-border",children:[a.jsx("td",{className:"py-2 pr-2",children:a.jsx("input",{type:"checkbox",checked:d.active,onChange:()=>o(f,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${f+1}`})}),a.jsx("td",{className:"py-2 pr-2",children:a.jsxs("select",{value:d.field,onChange:p=>o(f,{field:p.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[a.jsx("option",{value:"content",children:"content"}),a.jsx("option",{value:"thinking",children:"thinking"}),a.jsx("option",{value:"both",children:"both"})]})}),a.jsx("td",{className:"py-2 pr-2",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("input",{type:"text",value:d.pattern,onChange:p=>c(f,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),d.pattern.length>0&&a.jsx("span",{className:`text-sm ${n[f]?"text-red-500":"text-green-500"}`,children:n[f]?"✗":"✓"})]})}),a.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),a.jsx("td",{className:"py-2",children:a.jsx("button",{onClick:()=>l(f),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},f))})]}),a.jsx(rt,{variant:"secondary",onClick:u,children:"Add Pattern"})]})}function $N({onClose:e}){const[,t]=Gn(),{settings:n,getSetting:r,setSetting:o}=Al(),l=n[Ie.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[Ie.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",c=n[Ie.CACHE_WARMING]==="true",[d,f]=A.useState({openInEditor:l,dynamicPrompt:u,cacheWarming:c}),[p,m]=A.useState({patterns:[],maxRetriesPerTurn:10});A.useEffect(()=>{f({openInEditor:l,dynamicPrompt:u,cacheWarming:c})},[l,u,c]),A.useEffect(()=>{r(Ie.DISPLAY_SHOW_OPEN_IN_EDITOR),r(Ie.LLM_DYNAMIC_SYSTEM_PROMPT),r(Ie.CACHE_WARMING),r(Ie.RETRY_PATTERNS)},[r]),A.useEffect(()=>{const S=n[Ie.RETRY_PATTERNS];if(S)try{m(JSON.parse(S))}catch{}},[n]);const x=A.useCallback(S=>{m(S),o(Ie.RETRY_PATTERNS,JSON.stringify(S))},[o]),y=()=>{const S=!d.openInEditor;f(b=>({...b,openInEditor:S})),o(Ie.DISPLAY_SHOW_OPEN_IN_EDITOR,String(S))},w=()=>{const S=!d.dynamicPrompt;f(b=>({...b,dynamicPrompt:S})),o(Ie.LLM_DYNAMIC_SYSTEM_PROMPT,String(S))},C=()=>{const S=!d.cacheWarming;f(b=>({...b,cacheWarming:S})),o(Ie.CACHE_WARMING,String(S))};function v(){e(),t("/onboarding")}return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),a.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),a.jsx(rt,{variant:"secondary",onClick:v,children:"Launch Onboarding"})]}),a.jsx("hr",{className:"border-border"}),a.jsx("div",{children:a.jsx(Zf,{title:'Show "Open in VSCode" links',description:"Display a link on file reads to open the file directly in VS Code.",enabled:d.openInEditor,onToggle:y})}),a.jsx("hr",{className:"border-border"}),a.jsx(Zf,{title:"Speculative Cache Warming",description:"On first keystroke in an empty session, prefill the LLM KV cache to reduce time-to-first-token.",enabled:d.cacheWarming,onToggle:C,boldTitle:!0}),a.jsx("hr",{className:"border-border"}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),a.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.'}),a.jsx(BN,{value:p,onChange:x})]}),a.jsx("hr",{className:"border-border"}),a.jsx(Zf,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:w,boldTitle:!0})]})}function Zf({title:e,description:t,enabled:n,onToggle:r,boldTitle:o}){return a.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:`text-sm ${o?"font-medium":""} text-text-primary`,children:e}),a.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(Nu,{enabled:n,onClick:r})})]})}function zN({label:e,binding:t,isRecording:n,onStartRecording:r,onBindingRecorded:o,onCancelRecording:l}){const u=A.useRef(null),c=A.useRef(0),d=A.useRef("");return A.useEffect(()=>{if(!n)return;const f=new Set(["Control","Shift","Alt","Meta"]);let p=[];const m=y=>{if(y.preventDefault(),y.stopPropagation(),y.key==="Escape"){l();return}if(f.has(y.key)){y.ctrlKey&&!p.includes("ctrl")&&p.push("ctrl"),y.metaKey&&!p.includes("meta")&&p.push("meta"),y.altKey&&!p.includes("alt")&&p.push("alt"),y.shiftKey&&!p.includes("shift")&&p.push("shift");return}if(p.length>0||y.ctrlKey||y.metaKey||y.altKey||y.shiftKey){const v=[...p];y.ctrlKey&&!v.includes("ctrl")&&v.push("ctrl"),y.metaKey&&!v.includes("meta")&&v.push("meta"),y.altKey&&!v.includes("alt")&&v.push("alt"),y.shiftKey&&!v.includes("shift")&&v.push("shift"),o({type:"chord",key:Jb(y),modifiers:v});return}const w=Date.now(),C=Jb(y);if(C===d.current&&w-c.current<400){o({type:"double-press",key:C,threshold:300});return}c.current=w,d.current=C},x=y=>{y.key==="Control"&&(p=p.filter(w=>w!=="ctrl")),y.key==="Shift"&&(p=p.filter(w=>w!=="shift")),y.key==="Alt"&&(p=p.filter(w=>w!=="alt")),y.key==="Meta"&&(p=p.filter(w=>w!=="meta"))};return window.addEventListener("keydown",m,!0),window.addEventListener("keyup",x,!0),()=>{window.removeEventListener("keydown",m,!0),window.removeEventListener("keyup",x,!0)}},[n,o,l]),a.jsxs("div",{ref:u,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${n?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[a.jsx("span",{className:"text-sm text-text-primary",children:e}),a.jsx("div",{className:"flex items-center gap-2",children:n?a.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):a.jsx("button",{type:"button",onClick:r,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:HS(t)})})]})}function HN(){const{settings:e,loading:t,setSetting:n}=Al(),r=e[Ie.KEYBINDINGS],o=t[Ie.KEYBINDINGS]??!1,l=Wm(r),[u,c]=A.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction},...l.agentSwitching.map((x,y)=>({id:`agentSwitching.${y}`,label:`Switch to Agent ${y+1}`,binding:x}))],f=x=>{c(x)},p=A.useCallback(x=>{if(!u)return;const y=Wm(r),w=structuredClone(y);if(u.startsWith("agentSwitching.")){const C=parseInt(u.split(".")[1],10);w.agentSwitching[C]=x}else u==="terminalToggle"?w.terminalToggle=x:u==="quickAction"&&(w.quickAction=x);c(null),n(Ie.KEYBINDINGS,JSON.stringify(w))},[u,r,n]),m=()=>{n(Ie.KEYBINDINGS,JSON.stringify(Ia))};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),a.jsx("button",{type:"button",onClick:m,disabled:o,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"})]}),o?a.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):a.jsx("div",{className:"space-y-1",children:d.map(x=>a.jsx(zN,{label:x.label,binding:x.binding,isRecording:u===x.id,onStartRecording:()=>f(x.id),onBindingRecorded:p,onCancelRecording:()=>c(null)},x.id))})]})}function rv(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function em(e,t,n,r=250){const o=A.useRef(!0);A.useEffect(()=>{if(o.current){o.current=!1;return}const l=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(l)},[e,t,r,n])}function sv(){const[e,t]=A.useState("Test"),[n,r]=A.useState(""),[o,l]=A.useState(!1),u=A.useCallback(async c=>{t("Testing..."),r(""),l(!1);try{const d=await c();d.success?(t("Success"),l(!0),setTimeout(()=>{t("Test"),l(!1)},3e3)):(r(d.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,o,u]}function UN(){const{settings:e,getSetting:t,setSetting:n}=Al(),[r,o]=A.useState(""),[l,u]=A.useState(""),[c,d]=A.useState(""),[f,p]=A.useState("");em(l,Ie.SEARCH_TAVILY_API_KEY,n),em(c,Ie.SEARCH_SEARXNG_URL,n),em(f,Ie.SEARCH_SEARXNG_API_KEY,n);const[m,x,y,w]=sv(),[C,v,S,b]=sv();A.useEffect(()=>{t(Ie.SEARCH_ENGINE),t(Ie.SEARCH_TAVILY_API_KEY),t(Ie.SEARCH_SEARXNG_URL),t(Ie.SEARCH_SEARXNG_API_KEY),t(Ie.TOOLS_USE_RTK)},[t]),A.useEffect(()=>{e[Ie.SEARCH_ENGINE]!==void 0&&(o(e[Ie.SEARCH_ENGINE]??""),u(e[Ie.SEARCH_TAVILY_API_KEY]??""),d(e[Ie.SEARCH_SEARXNG_URL]??""),p(e[Ie.SEARCH_SEARXNG_API_KEY]??""))},[e]);function _(oe){o(oe),n(Ie.SEARCH_ENGINE,oe)}function j(){w(async()=>(await ke("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:l||void 0})})).json())}function E(){b(async()=>(await ke("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:c||void 0,searxngApiKey:f||void 0})})).json())}const[T,D]=A.useState("checking");A.useEffect(()=>{ke("/api/tools/rtk-check").then(oe=>oe.json()).then(oe=>D(oe.available?"available":"unavailable")).catch(()=>D("unavailable"))},[]);const[L,O]=A.useState([]);A.useEffect(()=>{t(Ie.TOOLS_SHELL),ke("/api/tools/shells").then(oe=>oe.json()).then(oe=>O(oe.shells??[])).catch(()=>O([]))},[t]);const P=e[Ie.TOOLS_SHELL]||"cmd",[q,W]=A.useState([]),[M,H]=A.useState(!0),[V,U]=A.useState(!1),[Q,X]=A.useState(new Set),[z,R]=A.useState(new Set),[I,G]=A.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""}),[B,ee]=A.useState(""),[J,ne]=A.useState(!1),{requestDelete:K,clearConfirm:F,isConfirming:te}=nd(),re=A.useCallback(async()=>{try{const Be=await(await ke("/api/mcp/servers")).json();W(Be.servers??[])}catch{}H(!1)},[]);A.useEffect(()=>{re()},[re]),A.useEffect(()=>{const oe=()=>re();return window.addEventListener("mcp-servers-changed",oe),()=>window.removeEventListener("mcp-servers-changed",oe)},[re]);const pe=oe=>{X(Be=>{const he=new Set(Be);return he.has(oe)?he.delete(oe):he.add(oe),he})},be=async()=>{if(ee(""),!I.name){ee("Name is required");return}if(I.transport==="stdio"&&!I.command){ee("Command is required for stdio transport");return}if(I.transport==="http"&&!I.url){ee("URL is required for HTTP transport");return}ne(!0);try{const oe=se=>{const xe={};return se.split(`
|
|
60
|
+
`).filter(Boolean).forEach(Ve=>{const Ze=Ve.indexOf("=");Ze>0&&(xe[Ve.slice(0,Ze).trim()]=Ve.slice(Ze+1).trim())}),xe},Be={name:I.name,transport:I.transport};if(I.transport==="stdio"){Be.command=I.command;const se=I.args?I.args.split(" ").filter(Boolean):void 0;se&&se.length>0&&(Be.args=se);const xe=oe(I.env);Object.keys(xe).length>0&&(Be.env=xe)}else{Be.url=I.url;const se=oe(I.headers);Object.keys(se).length>0&&(Be.headers=se)}const he=await ke("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Be)});if(!he.ok){const se=await he.json();throw new Error(se.error??"Failed to add server")}U(!1),G({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""}),await re()}catch(oe){ee(oe instanceof Error?oe.message:String(oe))}finally{ne(!1)}},Pe=async oe=>{try{const Be=await ke(`/api/mcp/servers/${encodeURIComponent(oe)}`,{method:"DELETE"});if(!Be.ok){const he=await Be.json();console.error("Failed to remove MCP server:",he.error)}F(),await re()}catch(Be){console.error("Failed to remove MCP server:",Be)}},$e=async(oe,Be,he)=>{try{const se=await ke(`/api/mcp/servers/${encodeURIComponent(oe)}/tools/${encodeURIComponent(Be)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:he})});if(!se.ok){const xe=await se.json();console.error("Failed to toggle tool:",xe.error)}await re()}catch(se){console.error("Failed to toggle tool:",se)}},Ne=oe=>{switch(oe){case"connected":return"text-accent-success";case"error":return"text-accent-error";default:return"text-text-muted"}},je=oe=>{switch(oe){case"connected":return"●";case"error":return"●";default:return"○"}};return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),a.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),a.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(oe=>a.jsx("button",{onClick:()=>_(oe),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===oe?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:oe||"Off"},oe))})]}),r==="tavily"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx(Ii,{type:"password",value:l,onChange:oe=>u(oe.target.value),placeholder:"tvly-...",className:"flex-1"}),a.jsx(rt,{variant:"secondary",onClick:j,style:y?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),x&&a.jsx("p",{className:"text-xs text-red-500 mt-1",children:x}),a.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",a.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),a.jsx(Ii,{type:"url",value:c,onChange:oe=>d(oe.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",a.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),a.jsx(Ii,{type:"password",value:f,onChange:oe=>p(oe.target.value),placeholder:"Optional API key",className:"w-full"})]}),a.jsx(rt,{variant:"secondary",onClick:E,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),v&&a.jsx("p",{className:"text-xs text-red-500",children:v})]})]})]}),L.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("hr",{className:"border-border"}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),a.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."}),a.jsx("div",{className:"flex gap-2",children:L.map(oe=>a.jsxs("button",{onClick:()=>n(Ie.TOOLS_SHELL,oe.id),disabled:!oe.available,title:oe.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${P===oe.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":oe.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[oe.label,!oe.available&&" (not found)"]},oe.id))}),a.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."})]})]}),a.jsx("hr",{className:"border-border"}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),a.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",a.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),a.jsxs("div",{className:"flex items-center justify-between py-2",children:[a.jsx("div",{className:"flex-1",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),T==="checking"&&a.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),T==="available"&&a.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),T==="unavailable"&&a.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),a.jsx(Nu,{enabled:e[Ie.TOOLS_USE_RTK]==="true",onClick:()=>n(Ie.TOOLS_USE_RTK,e[Ie.TOOLS_USE_RTK]==="true"?"false":"true")})]})]}),a.jsx("hr",{className:"border-border"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"MCP Servers"}),a.jsx(rt,{variant:"primary",size:"sm",onClick:()=>U(!0),children:"+ Add Server"})]}),a.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),a.jsx(Pp,{loading:M,hasItems:q.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:q.map(oe=>{var Be;return a.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-bg-primary/50 transition-colors",onClick:()=>pe(oe.name),children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:`text-sm ${Ne(oe.status)}`,children:je(oe.status)}),a.jsx("span",{className:"text-sm font-medium text-text-primary",children:oe.name}),a.jsx("span",{className:"text-xs text-text-muted",children:oe.config.transport}),a.jsxs("span",{className:"text-xs text-text-muted",children:["(",oe.tools.length," tools)"]}),a.jsxs("span",{className:"text-xs text-text-muted",children:[rv(oe.estimatedTokens)," tokens"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[oe.status==="error"&&oe.error&&a.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:oe.error,children:oe.error}),a.jsx("span",{className:"text-xs text-text-muted",children:Q.has(oe.name)?"▲":"▼"})]})]}),Q.has(oe.name)&&a.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[oe.config.command&&a.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[oe.config.command," ",((Be=oe.config.args)==null?void 0:Be.join(" "))??""]}),oe.config.url&&a.jsx("div",{className:"text-xs text-text-muted font-mono",children:oe.config.url}),oe.tools.length===0?a.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):a.jsx("div",{className:"space-y-1",children:oe.tools.map(he=>a.jsxs("div",{className:"py-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[a.jsx("span",{className:"text-xs text-text-primary font-mono",children:he.name}),he.description&&he.description.length>80?a.jsxs("button",{onClick:()=>{const se=`${oe.name}:${he.name}`;R(xe=>{const Ve=new Set(xe);return Ve.has(se)?Ve.delete(se):Ve.add(se),Ve})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[a.jsx("span",{className:"truncate max-w-[300px]",children:he.description}),a.jsx(Wn,{rotate:z.has(`${oe.name}:${he.name}`)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):he.description?a.jsx("span",{className:"text-xs text-text-muted ml-2",children:he.description}):null]}),a.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:rv(he.estimatedTokens)}),a.jsx(Nu,{enabled:he.enabled,onClick:()=>$e(oe.name,he.name,!he.enabled)})]}),he.description&&he.description.length>80&&z.has(`${oe.name}:${he.name}`)&&a.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:he.description})]},he.name))}),a.jsx("div",{className:"pt-2 flex items-center justify-end gap-2",children:te(oe.name,"delete")?a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:he=>{he.stopPropagation(),Pe(oe.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"}),a.jsx("button",{onClick:he=>{he.stopPropagation(),F()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):a.jsx("button",{onClick:he=>{he.stopPropagation(),K(oe.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 server"})})]})]},oe.name)})}),V&&a.jsx(Ot,{isOpen:V,onClose:()=>{U(!1),ee("")},title:"Add MCP Server",size:"sm",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(Dr,{label:"Name",value:I.name,onChange:oe=>G({...I,name:oe}),placeholder:"e.g. filesystem"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>G({...I,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${I.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),a.jsx("button",{onClick:()=>G({...I,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${I.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),I.transport==="stdio"?a.jsxs(a.Fragment,{children:[a.jsx(Dr,{label:"Command",value:I.command,onChange:oe=>G({...I,command:oe}),placeholder:"e.g. npx"}),a.jsx(Dr,{label:"Arguments",value:I.args,onChange:oe=>G({...I,args:oe}),placeholder:"space-separated args"}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",a.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),a.jsx("textarea",{value:I.env,onChange:oe=>G({...I,env:oe.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})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(Dr,{label:"URL",value:I.url,onChange:oe=>G({...I,url:oe}),placeholder:"e.g. https://mcp.example.com/mcp"}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",a.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),a.jsx("textarea",{value:I.headers,onChange:oe=>G({...I,headers:oe.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})]})]}),B&&a.jsx(rd,{message:B}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[a.jsx(rt,{variant:"secondary",onClick:()=>{U(!1),ee(""),ne(!1),G({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""})},disabled:J,children:"Cancel"}),a.jsx(rt,{variant:"primary",onClick:be,disabled:J,children:J?"Adding...":"Add"})]})]})})]})]})}function FN({isOpen:e,onClose:t}){const[n,r]=A.useState("instructions"),o=()=>{try{Xt.send("context.checkDynamic",{})}catch{}t()};return a.jsx(Ot,{isOpen:e,onClose:o,title:"Settings",size:"xl",minHeight:"500px",children:a.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full",children:[a.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1 overflow-x-auto scrollbar-hide",children:[a.jsx(Si,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),a.jsx(Si,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),a.jsx(Si,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),a.jsx(Si,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),a.jsx(Si,{label:"Display",active:n==="display",onClick:()=>r("display")}),a.jsx(Si,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),a.jsx(Si,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced")})]}),n==="instructions"&&a.jsx(LN,{isOpen:e}),n==="skills"&&a.jsx(AN,{isOpen:e}),n==="notifications"&&a.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:a.jsx(_N,{})}),n==="display"&&a.jsx(IN,{}),n==="keybindings"&&a.jsx(HN,{}),n==="tools"&&a.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:a.jsx(UN,{})}),n==="advanced"&&a.jsx($N,{onClose:t})]})})}function Si({label:e,active:t,onClick:n}){return a.jsx("button",{onClick:n,className:`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})}var tm={exports:{}},iv;function VN(){return iv||(iv=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(u,c,d){var f=this&&this.__decorate||function(b,_,j,E){var T,D=arguments.length,L=D<3?_:E===null?E=Object.getOwnPropertyDescriptor(_,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,_,j,E);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(_,j,L):T(_,j))||L);return D>3&&L&&Object.defineProperty(_,j,L),L},p=this&&this.__param||function(b,_){return function(j,E){_(j,E,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),x=d(9924),y=d(844),w=d(4725),C=d(2585),v=d(3656);let S=c.AccessibilityManager=class extends y.Disposable{constructor(b,_,j,E){super(),this._terminal=b,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 T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
61
|
+
`)))),this.register(this._terminal.onA11yTab((T=>this._handleTab(T)))),this.register(this._terminal.onKey((T=>this._handleKey(T.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,v.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(b){for(let _=0;_<b;_++)this._handleChar(" ")}_handleChar(b){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==b&&(this._charsToAnnounce+=b):this._charsToAnnounce+=b,b===`
|
|
62
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(b){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(b)||this._charsToConsume.push(b)}_refreshRows(b,_){this._liveRegionDebouncer.refresh(b,_,this._terminal.rows)}_renderRows(b,_){const j=this._terminal.buffer,E=j.lines.length.toString();for(let T=b;T<=_;T++){const D=j.lines.get(j.ydisp+T),L=[],O=(D==null?void 0:D.translateToString(!0,void 0,void 0,L))||"",P=(j.ydisp+T+1).toString(),q=this._rowElements[T];q&&(O.length===0?(q.innerText=" ",this._rowColumns.set(q,[0,1])):(q.textContent=O,this._rowColumns.set(q,L)),q.setAttribute("aria-posinset",P),q.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(b,_){const j=b.target,E=this._rowElements[_===0?1:this._rowElements.length-2];if(j.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||b.relatedTarget!==E)return;let T,D;if(_===0?(T=j,D=this._rowElements.pop(),this._rowContainer.removeChild(D)):(T=this._rowElements.shift(),D=j,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),D.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const L=this._createAccessibilityTreeNode();this._rowElements.unshift(L),this._rowContainer.insertAdjacentElement("afterbegin",L)}else{const L=this._createAccessibilityTreeNode();this._rowElements.push(L),this._rowContainer.appendChild(L)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),b.preventDefault(),b.stopImmediatePropagation()}_handleSelectionChange(){var O;if(this._rowElements.length===0)return;const b=document.getSelection();if(!b)return;if(b.isCollapsed)return void(this._rowContainer.contains(b.anchorNode)&&this._terminal.clearSelection());if(!b.anchorNode||!b.focusNode)return void console.error("anchorNode and/or focusNode are null");let _={node:b.anchorNode,offset:b.anchorOffset},j={node:b.focusNode,offset:b.focusOffset};if((_.node.compareDocumentPosition(j.node)&Node.DOCUMENT_POSITION_PRECEDING||_.node===j.node&&_.offset>j.offset)&&([_,j]=[j,_]),_.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(_={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(_.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:((O=E.textContent)==null?void 0:O.length)??0}),!this._rowContainer.contains(j.node))return;const T=({node:P,offset:q})=>{const W=P instanceof Text?P.parentNode:P;let M=parseInt(W==null?void 0:W.getAttribute("aria-posinset"),10)-1;if(isNaN(M))return console.warn("row is invalid. Race condition?"),null;const H=this._rowColumns.get(W);if(!H)return console.warn("columns is null. Race condition?"),null;let V=q<H.length?H[q]:H.slice(-1)[0]+1;return V>=this._terminal.cols&&(++M,V=0),{row:M,column:V}},D=T(_),L=T(j);if(D&&L){if(D.row>L.row||D.row===L.row&&D.column>=L.column)throw new Error("invalid range");this._terminal.select(D.column,D.row,(L.row-D.row)*this._terminal.cols-D.column+L.column)}}_handleResize(b){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>b;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const b=this._coreBrowserService.mainDocument.createElement("div");return b.setAttribute("role","listitem"),b.tabIndex=-1,this._refreshRowDimensions(b),b}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let b=0;b<this._terminal.rows;b++)this._refreshRowDimensions(this._rowElements[b])}}_refreshRowDimensions(b){b.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=S=f([p(1,C.IInstantiationService),p(2,w.ICoreBrowserService),p(3,w.IRenderService)],S)},3614:(u,c)=>{function d(x){return x.replace(/\r?\n/g,"\r")}function f(x,y){return y?"\x1B[200~"+x+"\x1B[201~":x}function p(x,y,w,C){x=f(x=d(x),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(x,!0),y.value=""}function m(x,y,w){const C=w.getBoundingClientRect(),v=x.clientX-C.left-10,S=x.clientY-C.top-10;y.style.width="20px",y.style.height="20px",y.style.left=`${v}px`,y.style.top=`${S}px`,y.style.zIndex="1000",y.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=d,c.bracketTextForPaste=f,c.copyHandler=function(x,y){x.clipboardData&&x.clipboardData.setData("text/plain",y.selectionText),x.preventDefault()},c.handlePasteEvent=function(x,y,w,C){x.stopPropagation(),x.clipboardData&&p(x.clipboardData.getData("text/plain"),y,w,C)},c.paste=p,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(x,y,w,C,v){m(x,y,w),v&&C.rightClickSelect(x),y.value=C.selectionText,y.select()}},7239:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const f=d(1505);c.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(p,m,x){this._css.set(p,m,x)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,x){this._color.set(p,m,x)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(d,f,p,m){d.addEventListener(f,p,m);let x=!1;return{dispose:()=>{x||(x=!0,d.removeEventListener(f,p,m))}}}},3551:function(u,c,d){var f=this&&this.__decorate||function(S,b,_,j){var E,T=arguments.length,D=T<3?b:j===null?j=Object.getOwnPropertyDescriptor(b,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,b,_,j);else for(var L=S.length-1;L>=0;L--)(E=S[L])&&(D=(T<3?E(D):T>3?E(b,_,D):E(b,_))||D);return T>3&&D&&Object.defineProperty(b,_,D),D},p=this&&this.__param||function(S,b){return function(_,j){b(_,j,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const m=d(3656),x=d(8460),y=d(844),w=d(2585),C=d(4725);let v=c.Linkifier=class extends y.Disposable{get currentLink(){return this._currentLink}constructor(S,b,_,j,E){super(),this._element=S,this._mouseService=b,this._renderService=_,this._bufferService=j,this._linkProviderService=E,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new x.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new x.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,y.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,y.toDisposable)((()=>{var T;this._lastMouseEvent=void 0,(T=this._activeProviderReplies)==null||T.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(S){this._lastMouseEvent=S;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!b)return;this._isMouseOut=!1;const _=S.composedPath();for(let j=0;j<_.length;j++){const E=_[j];if(E.classList.contains("xterm"))break;if(E.classList.contains("xterm-hover"))return}this._lastBufferCell&&b.x===this._lastBufferCell.x&&b.y===this._lastBufferCell.y||(this._handleHover(b),this._lastBufferCell=b)}_handleHover(S){if(this._activeLine!==S.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(S,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,S)||(this._clearCurrentLink(),this._askForLink(S,!0))}_askForLink(S,b){var j,E;this._activeProviderReplies&&b||((j=this._activeProviderReplies)==null||j.forEach((T=>{T==null||T.forEach((D=>{D.link.dispose&&D.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let _=!1;for(const[T,D]of this._linkProviderService.linkProviders.entries())b?(E=this._activeProviderReplies)!=null&&E.get(T)&&(_=this._checkLinkProviderResult(T,S,_)):D.provideLinks(S.y,(L=>{var P,q;if(this._isMouseOut)return;const O=L==null?void 0:L.map((W=>({link:W})));(P=this._activeProviderReplies)==null||P.set(T,O),_=this._checkLinkProviderResult(T,S,_),((q=this._activeProviderReplies)==null?void 0:q.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,b){const _=new Set;for(let j=0;j<b.size;j++){const E=b.get(j);if(E)for(let T=0;T<E.length;T++){const D=E[T],L=D.link.range.start.y<S?0:D.link.range.start.x,O=D.link.range.end.y>S?this._bufferService.cols:D.link.range.end.x;for(let P=L;P<=O;P++){if(_.has(P)){E.splice(T--,1);break}_.add(P)}}}}_checkLinkProviderResult(S,b,_){var T;if(!this._activeProviderReplies)return _;const j=this._activeProviderReplies.get(S);let E=!1;for(let D=0;D<S;D++)this._activeProviderReplies.has(D)&&!this._activeProviderReplies.get(D)||(E=!0);if(!E&&j){const D=j.find((L=>this._linkAtPosition(L.link,b)));D&&(_=!0,this._handleNewLink(D))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!_)for(let D=0;D<this._activeProviderReplies.size;D++){const L=(T=this._activeProviderReplies.get(D))==null?void 0:T.find((O=>this._linkAtPosition(O.link,b)));if(L){_=!0,this._handleNewLink(L);break}}return _}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);b&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,b)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,b){this._currentLink&&this._lastMouseEvent&&(!S||!b||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=b)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,y.disposeArray)(this._linkCacheDisposables))}_handleNewLink(S){if(!this._lastMouseEvent)return;const b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._linkAtPosition(S.link,b)&&(this._currentLink=S,this._currentLink.state={decorations:{underline:S.link.decorations===void 0||S.link.decorations.underline,pointerCursor:S.link.decorations===void 0||S.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,S.link,this._lastMouseEvent),S.link.decorations={},Object.defineProperties(S.link.decorations,{pointerCursor:{get:()=>{var _,j;return(j=(_=this._currentLink)==null?void 0:_.state)==null?void 0:j.decorations.pointerCursor},set:_=>{var j;(j=this._currentLink)!=null&&j.state&&this._currentLink.state.decorations.pointerCursor!==_&&(this._currentLink.state.decorations.pointerCursor=_,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",_))}},underline:{get:()=>{var _,j;return(j=(_=this._currentLink)==null?void 0:_.state)==null?void 0:j.decorations.underline},set:_=>{var j,E,T;(j=this._currentLink)!=null&&j.state&&((T=(E=this._currentLink)==null?void 0:E.state)==null?void 0:T.decorations.underline)!==_&&(this._currentLink.state.decorations.underline=_,this._currentLink.state.isHovered&&this._fireUnderlineEvent(S.link,_))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((_=>{if(!this._currentLink)return;const j=_.start===0?0:_.start+1+this._bufferService.buffer.ydisp,E=this._bufferService.buffer.ydisp+1+_.end;if(this._currentLink.link.range.start.y>=j&&this._currentLink.link.range.end.y<=E&&(this._clearCurrentLink(j,E),this._lastMouseEvent)){const T=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);T&&this._askForLink(T,!1)}}))))}_linkHover(S,b,_){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),b.hover&&b.hover(_,b.text)}_fireUnderlineEvent(S,b){const _=S.range,j=this._bufferService.buffer.ydisp,E=this._createLinkUnderlineEvent(_.start.x-1,_.start.y-j-1,_.end.x,_.end.y-j-1,void 0);(b?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(b,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),b.leave&&b.leave(_,b.text)}_linkAtPosition(S,b){const _=S.range.start.y*this._bufferService.cols+S.range.start.x,j=S.range.end.y*this._bufferService.cols+S.range.end.x,E=b.y*this._bufferService.cols+b.x;return _<=E&&E<=j}_positionFromMouseEvent(S,b,_){const j=_.getCoords(S,b,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:b,x2:_,y2:j,cols:this._bufferService.cols,fg:E}}};c.Linkifier=v=f([p(1,C.IMouseService),p(2,C.IRenderService),p(3,w.IBufferService),p(4,C.ILinkProviderService)],v)},9042:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(u,c,d){var f=this&&this.__decorate||function(C,v,S,b){var _,j=arguments.length,E=j<3?v:b===null?b=Object.getOwnPropertyDescriptor(v,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,b);else for(var T=C.length-1;T>=0;T--)(_=C[T])&&(E=(j<3?_(E):j>3?_(v,S,E):_(v,S))||E);return j>3&&E&&Object.defineProperty(v,S,E),E},p=this&&this.__param||function(C,v){return function(S,b){v(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=d(511),x=d(2585);let y=c.OscLinkProvider=class{constructor(C,v,S){this._bufferService=C,this._optionsService=v,this._oscLinkService=S}provideLinks(C,v){var O;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void v(void 0);const b=[],_=this._optionsService.rawOptions.linkHandler,j=new m.CellData,E=S.getTrimmedLength();let T=-1,D=-1,L=!1;for(let P=0;P<E;P++)if(D!==-1||S.hasContent(P)){if(S.loadCell(P,j),j.hasExtendedAttrs()&&j.extended.urlId){if(D===-1){D=P,T=j.extended.urlId;continue}L=j.extended.urlId!==T}else D!==-1&&(L=!0);if(L||D!==-1&&P===E-1){const q=(O=this._oscLinkService.getLinkData(T))==null?void 0:O.uri;if(q){const W={start:{x:D+1,y:C},end:{x:P+(L||P!==E-1?0:1),y:C}};let M=!1;if(!(_!=null&&_.allowNonHttpProtocols))try{const H=new URL(q);["http:","https:"].includes(H.protocol)||(M=!0)}catch{M=!0}M||b.push({text:q,range:W,activate:(H,V)=>_?_.activate(H,V,W):w(0,V),hover:(H,V)=>{var U;return(U=_==null?void 0:_.hover)==null?void 0:U.call(_,H,V,W)},leave:(H,V)=>{var U;return(U=_==null?void 0:_.leave)==null?void 0:U.call(_,H,V,W)}})}L=!1,j.hasExtendedAttrs()&&j.extended.urlId?(D=P,T=j.extended.urlId):(D=-1,T=-1)}}v(b)}};function w(C,v){if(confirm(`Do you want to navigate to ${v}?
|
|
63
|
+
|
|
64
|
+
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")}}c.OscLinkProvider=y=f([p(0,x.IBufferService),p(1,x.IOptionsService),p(2,x.IOscLinkService)],y)},6193:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.RenderDebouncer=void 0,c.RenderDebouncer=class{constructor(d,f){this._renderCallback=d,this._coreBrowserService=f,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(d){return this._refreshCallbacks.push(d),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(d,f,p){this._rowCount=p,d=d!==void 0?d:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,f):f,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const d=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,f),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const d of this._refreshCallbacks)d(0);this._refreshCallbacks=[]}}},3236:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const f=d(3614),p=d(3656),m=d(3551),x=d(9042),y=d(3730),w=d(1680),C=d(3107),v=d(5744),S=d(2950),b=d(1296),_=d(428),j=d(4269),E=d(5114),T=d(8934),D=d(3230),L=d(9312),O=d(4725),P=d(6731),q=d(8055),W=d(8969),M=d(8460),H=d(844),V=d(6114),U=d(8437),Q=d(2584),X=d(7399),z=d(5941),R=d(9074),I=d(2585),G=d(5435),B=d(4567),ee=d(779);class J extends W.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(K={}){super(K),this.browser=V,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new H.MutableDisposable),this._onCursorMove=this.register(new M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(R.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ee.LinkProviderService),this._instantiationService.setService(O.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(y.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,te)=>this.refresh(F,te)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),this.register((0,M.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,M.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((F=>this._afterResize(F.cols,F.rows)))),this.register((0,H.toDisposable)((()=>{var F,te;this._customKeyEventHandler=void 0,(te=(F=this.element)==null?void 0:F.parentNode)==null||te.removeChild(this.element)})))}_handleColorEvent(K){if(this._themeService)for(const F of K){let te,re="";switch(F.index){case 256:te="foreground",re="10";break;case 257:te="background",re="11";break;case 258:te="cursor",re="12";break;default:te="ansi",re="4;"+F.index}switch(F.type){case 0:const pe=q.color.toColorRGB(te==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[te]);this.coreService.triggerDataEvent(`${Q.C0.ESC}]${re};${(0,z.toRgbString)(pe)}${Q.C1_ESCAPED.ST}`);break;case 1:if(te==="ansi")this._themeService.modifyColors((be=>be.ansi[F.index]=q.channels.toColor(...F.color)));else{const be=te;this._themeService.modifyColors((Pe=>Pe[be]=q.channels.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(K){K?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(B.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(K){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var K;return(K=this.textarea)==null?void 0:K.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const K=this.buffer.ybase+this.buffer.y,F=this.buffer.lines.get(K);if(!F)return;const te=Math.min(this.buffer.x,this.cols-1),re=this._renderService.dimensions.css.cell.height,pe=F.getWidth(te),be=this._renderService.dimensions.css.cell.width*pe,Pe=this.buffer.y*this._renderService.dimensions.css.cell.height,$e=te*this._renderService.dimensions.css.cell.width;this.textarea.style.left=$e+"px",this.textarea.style.top=Pe+"px",this.textarea.style.width=be+"px",this.textarea.style.height=re+"px",this.textarea.style.lineHeight=re+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,f.copyHandler)(F,this._selectionService)})));const K=F=>(0,f.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",K)),this.register((0,p.addDisposableDomListener)(this.element,"paste",K)),V.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,f.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,f.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),V.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,f.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(K=>this._keyUp(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(K=>this._keyDown(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(K=>this._keyPress(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(K=>this._compositionHelper.compositionupdate(K)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(K=>this._inputEvent(K)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(K){var te;if(!K)throw new Error("Terminal requires a parent element.");if(K.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((te=this.element)==null?void 0:te.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=K.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),K.appendChild(this.element);const F=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),F.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,p.addDisposableDomListener)(this.screenElement,"mousemove",(re=>this.updateCursorStyle(re)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),F.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",x.promptLabel),V.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(E.CoreBrowserService,this.textarea,K.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(O.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(re=>this._handleTextAreaFocus(re)))),this.register((0,p.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(_.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(O.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(P.ThemeService),this._instantiationService.setService(O.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(j.CharacterJoinerService),this._instantiationService.setService(O.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(D.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(O.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((re=>this._onRender.fire(re)))),this.onResize((re=>this._renderService.resize(re.cols,re.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(S.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(T.MouseService),this._instantiationService.setService(O.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(F);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((re=>this.scrollLines(re.amount,re.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(L.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(O.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((re=>this.scrollLines(re.amount,re.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((re=>this._renderService.handleSelectionChanged(re.start,re.end,re.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((re=>{this.textarea.value=re,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((re=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(re=>this._selectionService.handleMouseDown(re)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(B.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(re=>this._handleScreenReaderModeOptionChange(re)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(re=>{!this._overviewRulerRenderer&&re&&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(b.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const K=this,F=this.element;function te(be){const Pe=K._mouseService.getMouseReportCoords(be,K.screenElement);if(!Pe)return!1;let $e,Ne;switch(be.overrideType||be.type){case"mousemove":Ne=32,be.buttons===void 0?($e=3,be.button!==void 0&&($e=be.button<3?be.button:3)):$e=1&be.buttons?0:4&be.buttons?1:2&be.buttons?2:3;break;case"mouseup":Ne=0,$e=be.button<3?be.button:3;break;case"mousedown":Ne=1,$e=be.button<3?be.button:3;break;case"wheel":if(K._customWheelEventHandler&&K._customWheelEventHandler(be)===!1||K.viewport.getLinesScrolled(be)===0)return!1;Ne=be.deltaY<0?0:1,$e=4;break;default:return!1}return!(Ne===void 0||$e===void 0||$e>4)&&K.coreMouseService.triggerMouseEvent({col:Pe.col,row:Pe.row,x:Pe.x,y:Pe.y,button:$e,action:Ne,ctrl:be.ctrlKey,alt:be.altKey,shift:be.shiftKey})}const re={mouseup:null,wheel:null,mousedrag:null,mousemove:null},pe={mouseup:be=>(te(be),be.buttons||(this._document.removeEventListener("mouseup",re.mouseup),re.mousedrag&&this._document.removeEventListener("mousemove",re.mousedrag)),this.cancel(be)),wheel:be=>(te(be),this.cancel(be,!0)),mousedrag:be=>{be.buttons&&te(be)},mousemove:be=>{be.buttons||te(be)}};this.register(this.coreMouseService.onProtocolChange((be=>{be?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(be)),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&be?re.mousemove||(F.addEventListener("mousemove",pe.mousemove),re.mousemove=pe.mousemove):(F.removeEventListener("mousemove",re.mousemove),re.mousemove=null),16&be?re.wheel||(F.addEventListener("wheel",pe.wheel,{passive:!1}),re.wheel=pe.wheel):(F.removeEventListener("wheel",re.wheel),re.wheel=null),2&be?re.mouseup||(re.mouseup=pe.mouseup):(this._document.removeEventListener("mouseup",re.mouseup),re.mouseup=null),4&be?re.mousedrag||(re.mousedrag=pe.mousedrag):(this._document.removeEventListener("mousemove",re.mousedrag),re.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(F,"mousedown",(be=>{if(be.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(be))return te(be),re.mouseup&&this._document.addEventListener("mouseup",re.mouseup),re.mousedrag&&this._document.addEventListener("mousemove",re.mousedrag),this.cancel(be)}))),this.register((0,p.addDisposableDomListener)(F,"wheel",(be=>{if(!re.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(be)===!1)return!1;if(!this.buffer.hasScrollback){const Pe=this.viewport.getLinesScrolled(be);if(Pe===0)return;const $e=Q.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(be.deltaY<0?"A":"B");let Ne="";for(let je=0;je<Math.abs(Pe);je++)Ne+=$e;return this.coreService.triggerDataEvent(Ne,!0),this.cancel(be,!0)}return this.viewport.handleWheel(be)?this.cancel(be):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(F,"touchstart",(be=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(be),this.cancel(be)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(F,"touchmove",(be=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(be)?void 0:this.cancel(be)}),{passive:!1}))}refresh(K,F){var te;(te=this._renderService)==null||te.refreshRows(K,F)}updateCursorStyle(K){var F;(F=this._selectionService)!=null&&F.shouldColumnSelect(K)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(K,F,te=0){var re;te===1?(super.scrollLines(K,F,te),this.refresh(0,this.rows-1)):(re=this.viewport)==null||re.scrollLines(K)}paste(K){(0,f.paste)(K,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(K){this._customKeyEventHandler=K}attachCustomWheelEventHandler(K){this._customWheelEventHandler=K}registerLinkProvider(K){return this._linkProviderService.registerLinkProvider(K)}registerCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const F=this._characterJoinerService.register(K);return this.refresh(0,this.rows-1),F}deregisterCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(K)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(K){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+K)}registerDecoration(K){return this._decorationService.registerDecoration(K)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(K,F,te){this._selectionService.setSelection(K,F,te)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var K;(K=this._selectionService)==null||K.clearSelection()}selectAll(){var K;(K=this._selectionService)==null||K.selectAll()}selectLines(K,F){var te;(te=this._selectionService)==null||te.selectLines(K,F)}_keyDown(K){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&K.altKey;if(!F&&!this._compositionHelper.keydown(K))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||K.key!=="Dead"&&K.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const te=(0,X.evaluateKeyboardEvent)(K,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(K),te.type===3||te.type===2){const re=this.rows-1;return this.scrollLines(te.type===2?-re:re),this.cancel(K,!0)}return te.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,K)||(te.cancel&&this.cancel(K,!0),!te.key||!!(K.key&&!K.ctrlKey&&!K.altKey&&!K.metaKey&&K.key.length===1&&K.key.charCodeAt(0)>=65&&K.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(te.key!==Q.C0.ETX&&te.key!==Q.C0.CR||(this.textarea.value=""),this._onKey.fire({key:te.key,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(te.key,!0),!this.optionsService.rawOptions.screenReaderMode||K.altKey||K.ctrlKey?this.cancel(K,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(K,F){const te=K.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||K.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||K.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?te:te&&(!F.keyCode||F.keyCode>47)}_keyUp(K){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(K)||this.focus(),this.updateCursorStyle(K),this._keyPressHandled=!1)}_keyPress(K){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;if(this.cancel(K),K.charCode)F=K.charCode;else if(K.which===null||K.which===void 0)F=K.keyCode;else{if(K.which===0||K.charCode===0)return!1;F=K.which}return!(!F||(K.altKey||K.ctrlKey||K.metaKey)&&!this._isThirdLevelShift(this.browser,K)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(F,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(K){if(K.data&&K.inputType==="insertText"&&(!K.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const F=K.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(K),!0}return!1}resize(K,F){K!==this.cols||F!==this.rows?super.resize(K,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(K,F){var te,re;(te=this._charSizeService)==null||te.measure(),(re=this.viewport)==null||re.syncScrollArea(!0)}clear(){var K;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(U.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(K=this.viewport)==null||K.reset(),this.refresh(0,this.rows-1)}}reset(){var F,te;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(F=this._selectionService)==null||F.reset(),this._decorationService.reset(),(te=this.viewport)==null||te.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var K;(K=this._renderService)==null||K.clearTextureAtlas()}_reportFocus(){var K;(K=this.element)!=null&&K.classList.contains("focus")?this.coreService.triggerDataEvent(Q.C0.ESC+"[I"):this.coreService.triggerDataEvent(Q.C0.ESC+"[O")}_reportWindowsOptions(K){if(this._renderService)switch(K){case G.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),te=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[4;${te};${F}t`);break;case G.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const re=this._renderService.dimensions.css.cell.width.toFixed(0),pe=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[6;${pe};${re}t`)}}cancel(K,F){if(this.options.cancelEvents||F)return K.preventDefault(),K.stopPropagation(),!1}}c.Terminal=J},9924:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TimeBasedDebouncer=void 0,c.TimeBasedDebouncer=class{constructor(d,f=1e3){this._renderCallback=d,this._debounceThresholdMS=f,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(d,f,p){this._rowCount=p,d=d!==void 0?d:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,f):f;const m=Date.now();if(m-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=m,this._innerRefresh();else if(!this._additionalRefreshRequested){const x=m-this._lastRefreshMs,y=this._debounceThresholdMS-x;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),y)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const d=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,f)}}},1680:function(u,c,d){var f=this&&this.__decorate||function(S,b,_,j){var E,T=arguments.length,D=T<3?b:j===null?j=Object.getOwnPropertyDescriptor(b,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,b,_,j);else for(var L=S.length-1;L>=0;L--)(E=S[L])&&(D=(T<3?E(D):T>3?E(b,_,D):E(b,_))||D);return T>3&&D&&Object.defineProperty(b,_,D),D},p=this&&this.__param||function(S,b){return function(_,j){b(_,j,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Viewport=void 0;const m=d(3656),x=d(4725),y=d(8460),w=d(844),C=d(2585);let v=c.Viewport=class extends w.Disposable{constructor(S,b,_,j,E,T,D,L){super(),this._viewportElement=S,this._scrollArea=b,this._bufferService=_,this._optionsService=j,this._charSizeService=E,this._renderService=T,this._coreBrowserService=D,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new y.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((O=>this._activeBuffer=O.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((O=>this._renderDimensions=O))),this._handleThemeChange(L.colors),this.register(L.onChangeColors((O=>this._handleThemeChange(O)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(S){if(S)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const b=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==b&&(this._lastRecordedBufferHeight=b,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const S=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==S&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=S),this._refreshAnimationFrame=null}syncScrollArea(S=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(S);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(S)}_handleScroll(S){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const b=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:b,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const S=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(S*(this._smoothScrollState.target-this._smoothScrollState.origin)),S<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(S,b){const _=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(b<0&&this._viewportElement.scrollTop!==0||b>0&&_<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const b=this._getPixelsScrolled(S);return b!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+b:this._smoothScrollState.target+=b,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const b=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+b,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:S,suppressScrollEvent:!1})}_getPixelsScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?b*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._currentRowHeight*this._bufferService.rows),b}getBufferElements(S,b){var L;let _,j="";const E=[],T=b??this._bufferService.buffer.lines.length,D=this._bufferService.buffer.lines;for(let O=S;O<T;O++){const P=D.get(O);if(!P)continue;const q=(L=D.get(O+1))==null?void 0:L.isWrapped;if(j+=P.translateToString(!q),!q||O===D.length-1){const W=document.createElement("div");W.textContent=j,E.push(W),j.length>0&&(_=W),j=""}}return{bufferElements:E,cursorElement:_}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(b/=this._currentRowHeight+0,this._wheelPartialScroll+=b,b=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._bufferService.rows),b}_applyScrollModifier(S,b){const _=this._optionsService.rawOptions.fastScrollModifier;return _==="alt"&&b.altKey||_==="ctrl"&&b.ctrlKey||_==="shift"&&b.shiftKey?S*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:S*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(S){this._lastTouchY=S.touches[0].pageY}handleTouchMove(S){const b=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,b!==0&&(this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}};c.Viewport=v=f([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,x.ICharSizeService),p(5,x.IRenderService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],v)},3107:function(u,c,d){var f=this&&this.__decorate||function(C,v,S,b){var _,j=arguments.length,E=j<3?v:b===null?b=Object.getOwnPropertyDescriptor(v,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,b);else for(var T=C.length-1;T>=0;T--)(_=C[T])&&(E=(j<3?_(E):j>3?_(v,S,E):_(v,S))||E);return j>3&&E&&Object.defineProperty(v,S,E),E},p=this&&this.__param||function(C,v){return function(S,b){v(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const m=d(4725),x=d(844),y=d(2585);let w=c.BufferDecorationRenderer=class extends x.Disposable{constructor(C,v,S,b,_){super(),this._screenElement=C,this._bufferService=v,this._coreBrowserService=S,this._decorationService=b,this._renderService=_,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,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var b;const v=this._coreBrowserService.mainDocument.createElement("div");v.classList.add("xterm-decoration"),v.classList.toggle("xterm-decoration-top-layer",((b=C==null?void 0:C.options)==null?void 0:b.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()}};c.BufferDecorationRenderer=w=f([p(1,y.IBufferService),p(2,m.ICoreBrowserService),p(3,y.IDecorationService),p(4,m.IRenderService)],w)},5871:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorZoneStore=void 0,c.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(d){if(d.options.overviewRulerOptions){for(const f of this._zones)if(f.color===d.options.overviewRulerOptions.color&&f.position===d.options.overviewRulerOptions.position){if(this._lineIntersectsZone(f,d.marker.line))return;if(this._lineAdjacentToZone(f,d.marker.line,d.options.overviewRulerOptions.position))return void this._addLineToZone(f,d.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=d.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=d.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=d.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=d.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:d.options.overviewRulerOptions.color,position:d.options.overviewRulerOptions.position,startBufferLine:d.marker.line,endBufferLine:d.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(d){this._linePadding=d}_lineIntersectsZone(d,f){return f>=d.startBufferLine&&f<=d.endBufferLine}_lineAdjacentToZone(d,f,p){return f>=d.startBufferLine-this._linePadding[p||"full"]&&f<=d.endBufferLine+this._linePadding[p||"full"]}_addLineToZone(d,f){d.startBufferLine=Math.min(d.startBufferLine,f),d.endBufferLine=Math.max(d.endBufferLine,f)}}},5744:function(u,c,d){var f=this&&this.__decorate||function(_,j,E,T){var D,L=arguments.length,O=L<3?j:T===null?T=Object.getOwnPropertyDescriptor(j,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(_,j,E,T);else for(var P=_.length-1;P>=0;P--)(D=_[P])&&(O=(L<3?D(O):L>3?D(j,E,O):D(j,E))||O);return L>3&&O&&Object.defineProperty(j,E,O),O},p=this&&this.__param||function(_,j){return function(E,T){j(E,T,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const m=d(5871),x=d(4725),y=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},v={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let b=c.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(_,j,E,T,D,L,O){var q;super(),this._viewportElement=_,this._screenElement=j,this._bufferService=E,this._decorationService=T,this._renderService=D,this._optionsService=L,this._coreBrowserService=O,this._colorZoneStore=new m.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(q=this._viewportElement.parentElement)==null||q.insertBefore(this._canvas,this._viewportElement);const P=this._canvas.getContext("2d");if(!P)throw new Error("Ctx cannot be null");this._ctx=P,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var W;(W=this._canvas)==null||W.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 _=Math.floor(this._canvas.width/3),j=Math.ceil(this._canvas.width/3);v.full=this._canvas.width,v.left=_,v.center=j,v.right=_,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 _=this._canvas.height/this._bufferService.buffer.lines.length,j=Math.round(Math.max(Math.min(_,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 _=this._colorZoneStore.zones;for(const j of _)j.position!=="full"&&this._renderColorZone(j);for(const j of _)j.position==="full"&&this._renderColorZone(j);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(S[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-C[_.position||"full"]/2),v[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[_.position||"full"]))}_queueRefresh(_,j){this._shouldUpdateDimensions=_||this._shouldUpdateDimensions,this._shouldUpdateAnchor=j||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};c.OverviewRulerRenderer=b=f([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,x.IRenderService),p(5,w.IOptionsService),p(6,x.ICoreBrowserService)],b)},2950:function(u,c,d){var f=this&&this.__decorate||function(C,v,S,b){var _,j=arguments.length,E=j<3?v:b===null?b=Object.getOwnPropertyDescriptor(v,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,b);else for(var T=C.length-1;T>=0;T--)(_=C[T])&&(E=(j<3?_(E):j>3?_(v,S,E):_(v,S))||E);return j>3&&E&&Object.defineProperty(v,S,E),E},p=this&&this.__param||function(C,v){return function(S,b){v(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const m=d(4725),x=d(2585),y=d(2584);let w=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,v,S,b,_,j){this._textarea=C,this._compositionView=v,this._bufferService=S,this._optionsService=b,this._coreService=_,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(`${y.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,b=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,_=v*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=_+"px",this._compositionView.style.top=b+"px",this._compositionView.style.height=S+"px",this._compositionView.style.lineHeight=S+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const j=this._compositionView.getBoundingClientRect();this._textarea.style.left=_+"px",this._textarea.style.top=b+"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)}}};c.CompositionHelper=w=f([p(2,x.IBufferService),p(3,x.IOptionsService),p(4,x.ICoreService),p(5,m.IRenderService)],w)},9806:(u,c)=>{function d(f,p,m){const x=m.getBoundingClientRect(),y=f.getComputedStyle(m),w=parseInt(y.getPropertyValue("padding-left")),C=parseInt(y.getPropertyValue("padding-top"));return[p.clientX-x.left-w,p.clientY-x.top-C]}Object.defineProperty(c,"__esModule",{value:!0}),c.getCoords=c.getCoordsRelativeToElement=void 0,c.getCoordsRelativeToElement=d,c.getCoords=function(f,p,m,x,y,w,C,v,S){if(!w)return;const b=d(f,p,m);return b?(b[0]=Math.ceil((b[0]+(S?C/2:0))/C),b[1]=Math.ceil(b[1]/v),b[0]=Math.min(Math.max(b[0],1),x+(S?1:0)),b[1]=Math.min(Math.max(b[1],1),y),b):void 0}},9504:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const f=d(2584);function p(v,S,b,_){const j=v-m(v,b),E=S-m(S,b),T=Math.abs(j-E)-(function(D,L,O){let P=0;const q=D-m(D,O),W=L-m(L,O);for(let M=0;M<Math.abs(q-W);M++){const H=x(D,L)==="A"?-1:1,V=O.buffer.lines.get(q+H*M);V!=null&&V.isWrapped&&P++}return P})(v,S,b);return C(T,w(x(v,S),_))}function m(v,S){let b=0,_=S.buffer.lines.get(v),j=_==null?void 0:_.isWrapped;for(;j&&v>=0&&v<S.rows;)b++,_=S.buffer.lines.get(--v),j=_==null?void 0:_.isWrapped;return b}function x(v,S){return v>S?"A":"B"}function y(v,S,b,_,j,E){let T=v,D=S,L="";for(;T!==b||D!==_;)T+=j?1:-1,j&&T>E.cols-1?(L+=E.buffer.translateBufferLineToString(D,!1,v,T),T=0,v=0,D++):!j&&T<0&&(L+=E.buffer.translateBufferLineToString(D,!1,0,v+1),T=E.cols-1,v=T,D--);return L+E.buffer.translateBufferLineToString(D,!1,v,T)}function w(v,S){const b=S?"O":"[";return f.C0.ESC+b+v}function C(v,S){v=Math.floor(v);let b="";for(let _=0;_<v;_++)b+=S;return b}c.moveToCellSequence=function(v,S,b,_){const j=b.buffer.x,E=b.buffer.y;if(!b.buffer.hasScrollback)return(function(L,O,P,q,W,M){return p(O,q,W,M).length===0?"":C(y(L,O,L,O-m(O,W),!1,W).length,w("D",M))})(j,E,0,S,b,_)+p(E,S,b,_)+(function(L,O,P,q,W,M){let H;H=p(O,q,W,M).length>0?q-m(q,W):O;const V=q,U=(function(Q,X,z,R,I,G){let B;return B=p(z,R,I,G).length>0?R-m(R,I):X,Q<z&&B<=R||Q>=z&&B<R?"C":"D"})(L,O,P,q,W,M);return C(y(L,H,P,V,U==="C",W).length,w(U,M))})(j,E,v,S,b,_);let T;if(E===S)return T=j>v?"D":"C",C(Math.abs(j-v),w(T,_));T=E>S?"D":"C";const D=Math.abs(E-S);return C((function(L,O){return O.cols-L})(E>S?v:j,b)+(D-1)*b.cols+1+((E>S?j:v)-1),w(T,_))}},1296:function(u,c,d){var f=this&&this.__decorate||function(M,H,V,U){var Q,X=arguments.length,z=X<3?H:U===null?U=Object.getOwnPropertyDescriptor(H,V):U;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(M,H,V,U);else for(var R=M.length-1;R>=0;R--)(Q=M[R])&&(z=(X<3?Q(z):X>3?Q(H,V,z):Q(H,V))||z);return X>3&&z&&Object.defineProperty(H,V,z),z},p=this&&this.__param||function(M,H){return function(V,U){H(V,U,M)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const m=d(3787),x=d(2550),y=d(2223),w=d(6171),C=d(6052),v=d(4725),S=d(8055),b=d(8460),_=d(844),j=d(2585),E="xterm-dom-renderer-owner-",T="xterm-rows",D="xterm-fg-",L="xterm-bg-",O="xterm-focus",P="xterm-selection";let q=1,W=c.DomRenderer=class extends _.Disposable{constructor(M,H,V,U,Q,X,z,R,I,G,B,ee,J){super(),this._terminal=M,this._document=H,this._element=V,this._screenElement=U,this._viewportElement=Q,this._helperContainer=X,this._linkifier2=z,this._charSizeService=I,this._optionsService=G,this._bufferService=B,this._coreBrowserService=ee,this._themeService=J,this._terminalClass=q++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new b.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(T),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(P),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((ne=>this._injectCss(ne)))),this._injectCss(this._themeService.colors),this._rowFactory=R.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(E+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((ne=>this._handleLinkHover(ne)))),this.register(this._linkifier2.onHideLinkUnderline((ne=>this._handleLinkLeave(ne)))),this.register((0,_.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 x.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const M=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*M,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*M),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/M),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/M),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const V of this._rowElements)V.style.width=`${this.dimensions.css.canvas.width}px`,V.style.height=`${this.dimensions.css.cell.height}px`,V.style.lineHeight=`${this.dimensions.css.cell.height}px`,V.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const H=`${this._terminalSelector} .${T} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=H,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(M){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let H=`${this._terminalSelector} .${T} { color: ${M.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;H+=`${this._terminalSelector} .${T} .xterm-dim { color: ${S.color.multiplyOpacity(M.foreground,.5).css};}`,H+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;const V=`blink_underline_${this._terminalClass}`,U=`blink_bar_${this._terminalClass}`,Q=`blink_block_${this._terminalClass}`;H+=`@keyframes ${V} { 50% { border-bottom-style: hidden; }}`,H+=`@keyframes ${U} { 50% { box-shadow: none; }}`,H+=`@keyframes ${Q} { 0% { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,H+=`${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${U} 1s step-end infinite;}${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Q} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${M.cursor.css} !important; color: ${M.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${M.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${M.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${M.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,H+=`${this._terminalSelector} .${P} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${P} div { position: absolute; background-color: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${P} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[X,z]of M.ansi.entries())H+=`${this._terminalSelector} .${D}${X} { color: ${z.css}; }${this._terminalSelector} .${D}${X}.xterm-dim { color: ${S.color.multiplyOpacity(z,.5).css}; }${this._terminalSelector} .${L}${X} { background-color: ${z.css}; }`;H+=`${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(M.background).css}; }${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(M.background),.5).css}; }${this._terminalSelector} .${L}${y.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=H}_setDefaultSpacing(){const M=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${M}px`,this._rowFactory.defaultSpacing=M}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(M,H){for(let V=this._rowElements.length;V<=H;V++){const U=this._document.createElement("div");this._rowContainer.appendChild(U),this._rowElements.push(U)}for(;this._rowElements.length>H;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,H){this._refreshRowElements(M,H),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(O),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(O),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(M,H,V){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,H,V),this.renderRows(0,this._bufferService.rows-1),!M||!H)return;this._selectionRenderModel.update(this._terminal,M,H,V);const U=this._selectionRenderModel.viewportStartRow,Q=this._selectionRenderModel.viewportEndRow,X=this._selectionRenderModel.viewportCappedStartRow,z=this._selectionRenderModel.viewportCappedEndRow;if(X>=this._bufferService.rows||z<0)return;const R=this._document.createDocumentFragment();if(V){const I=M[0]>H[0];R.appendChild(this._createSelectionElement(X,I?H[0]:M[0],I?M[0]:H[0],z-X+1))}else{const I=U===X?M[0]:0,G=X===Q?H[0]:this._bufferService.cols;R.appendChild(this._createSelectionElement(X,I,G));const B=z-X-1;if(R.appendChild(this._createSelectionElement(X+1,0,this._bufferService.cols,B)),X!==z){const ee=Q===z?H[0]:this._bufferService.cols;R.appendChild(this._createSelectionElement(z,0,ee))}}this._selectionContainer.appendChild(R)}_createSelectionElement(M,H,V,U=1){const Q=this._document.createElement("div"),X=H*this.dimensions.css.cell.width;let z=this.dimensions.css.cell.width*(V-H);return X+z>this.dimensions.css.canvas.width&&(z=this.dimensions.css.canvas.width-X),Q.style.height=U*this.dimensions.css.cell.height+"px",Q.style.top=M*this.dimensions.css.cell.height+"px",Q.style.left=`${X}px`,Q.style.width=`${z}px`,Q}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 M of this._rowElements)M.replaceChildren()}renderRows(M,H){const V=this._bufferService.buffer,U=V.ybase+V.y,Q=Math.min(V.x,this._bufferService.cols-1),X=this._optionsService.rawOptions.cursorBlink,z=this._optionsService.rawOptions.cursorStyle,R=this._optionsService.rawOptions.cursorInactiveStyle;for(let I=M;I<=H;I++){const G=I+V.ydisp,B=this._rowElements[I],ee=V.lines.get(G);if(!B||!ee)break;B.replaceChildren(...this._rowFactory.createRow(ee,G,G===U,z,R,Q,X,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${E}${this._terminalClass}`}_handleLinkHover(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!0)}_handleLinkLeave(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!1)}_setCellUnderline(M,H,V,U,Q,X){V<0&&(M=0),U<0&&(H=0);const z=this._bufferService.rows-1;V=Math.max(Math.min(V,z),0),U=Math.max(Math.min(U,z),0),Q=Math.min(Q,this._bufferService.cols);const R=this._bufferService.buffer,I=R.ybase+R.y,G=Math.min(R.x,Q-1),B=this._optionsService.rawOptions.cursorBlink,ee=this._optionsService.rawOptions.cursorStyle,J=this._optionsService.rawOptions.cursorInactiveStyle;for(let ne=V;ne<=U;++ne){const K=ne+R.ydisp,F=this._rowElements[ne],te=R.lines.get(K);if(!F||!te)break;F.replaceChildren(...this._rowFactory.createRow(te,K,K===I,ee,J,G,B,this.dimensions.css.cell.width,this._widthCache,X?ne===V?M:0:-1,X?(ne===U?H:Q)-1:-1))}}};c.DomRenderer=W=f([p(7,j.IInstantiationService),p(8,v.ICharSizeService),p(9,j.IOptionsService),p(10,j.IBufferService),p(11,v.ICoreBrowserService),p(12,v.IThemeService)],W)},3787:function(u,c,d){var f=this&&this.__decorate||function(T,D,L,O){var P,q=arguments.length,W=q<3?D:O===null?O=Object.getOwnPropertyDescriptor(D,L):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(T,D,L,O);else for(var M=T.length-1;M>=0;M--)(P=T[M])&&(W=(q<3?P(W):q>3?P(D,L,W):P(D,L))||W);return q>3&&W&&Object.defineProperty(D,L,W),W},p=this&&this.__param||function(T,D){return function(L,O){D(L,O,T)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const m=d(2223),x=d(643),y=d(511),w=d(2585),C=d(8055),v=d(4725),S=d(4269),b=d(6171),_=d(3734);let j=c.DomRendererRowFactory=class{constructor(T,D,L,O,P,q,W){this._document=T,this._characterJoinerService=D,this._optionsService=L,this._coreBrowserService=O,this._coreService=P,this._decorationService=q,this._themeService=W,this._workCell=new y.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(T,D,L){this._selectionStart=T,this._selectionEnd=D,this._columnSelectMode=L}createRow(T,D,L,O,P,q,W,M,H,V,U){const Q=[],X=this._characterJoinerService.getJoinedCharacters(D),z=this._themeService.colors;let R,I=T.getNoBgTrimmedLength();L&&I<q+1&&(I=q+1);let G=0,B="",ee=0,J=0,ne=0,K=!1,F=0,te=!1,re=0;const pe=[],be=V!==-1&&U!==-1;for(let Pe=0;Pe<I;Pe++){T.loadCell(Pe,this._workCell);let $e=this._workCell.getWidth();if($e===0)continue;let Ne=!1,je=Pe,oe=this._workCell;if(X.length>0&&Pe===X[0][0]){Ne=!0;const at=X.shift();oe=new S.JoinedCellData(this._workCell,T.translateToString(!0,at[0],at[1]),at[1]-at[0]),je=at[1]-1,$e=oe.getWidth()}const Be=this._isCellInSelection(Pe,D),he=L&&Pe===q,se=be&&Pe>=V&&Pe<=U;let xe=!1;this._decorationService.forEachDecorationAtCell(Pe,D,void 0,(at=>{xe=!0}));let Ve=oe.getChars()||x.WHITESPACE_CELL_CHAR;if(Ve===" "&&(oe.isUnderline()||oe.isOverline())&&(Ve=" "),re=$e*M-H.get(Ve,oe.isBold(),oe.isItalic()),R){if(G&&(Be&&te||!Be&&!te&&oe.bg===ee)&&(Be&&te&&z.selectionForeground||oe.fg===J)&&oe.extended.ext===ne&&se===K&&re===F&&!he&&!Ne&&!xe){oe.isInvisible()?B+=x.WHITESPACE_CELL_CHAR:B+=Ve,G++;continue}G&&(R.textContent=B),R=this._document.createElement("span"),G=0,B=""}else R=this._document.createElement("span");if(ee=oe.bg,J=oe.fg,ne=oe.extended.ext,K=se,F=re,te=Be,Ne&&q>=Pe&&q<=je&&(q=Pe),!this._coreService.isCursorHidden&&he&&this._coreService.isCursorInitialized){if(pe.push("xterm-cursor"),this._coreBrowserService.isFocused)W&&pe.push("xterm-cursor-blink"),pe.push(O==="bar"?"xterm-cursor-bar":O==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(P)switch(P){case"outline":pe.push("xterm-cursor-outline");break;case"block":pe.push("xterm-cursor-block");break;case"bar":pe.push("xterm-cursor-bar");break;case"underline":pe.push("xterm-cursor-underline")}}if(oe.isBold()&&pe.push("xterm-bold"),oe.isItalic()&&pe.push("xterm-italic"),oe.isDim()&&pe.push("xterm-dim"),B=oe.isInvisible()?x.WHITESPACE_CELL_CHAR:oe.getChars()||x.WHITESPACE_CELL_CHAR,oe.isUnderline()&&(pe.push(`xterm-underline-${oe.extended.underlineStyle}`),B===" "&&(B=" "),!oe.isUnderlineColorDefault()))if(oe.isUnderlineColorRGB())R.style.textDecorationColor=`rgb(${_.AttributeData.toColorRGB(oe.getUnderlineColor()).join(",")})`;else{let at=oe.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&oe.isBold()&&at<8&&(at+=8),R.style.textDecorationColor=z.ansi[at].css}oe.isOverline()&&(pe.push("xterm-overline"),B===" "&&(B=" ")),oe.isStrikethrough()&&pe.push("xterm-strikethrough"),se&&(R.style.textDecoration="underline");let Ze=oe.getFgColor(),it=oe.getFgColorMode(),Et=oe.getBgColor(),ce=oe.getBgColorMode();const Te=!!oe.isInverse();if(Te){const at=Ze;Ze=Et,Et=at;const me=it;it=ce,ce=me}let Fe,Ye,tt,kt=!1;switch(this._decorationService.forEachDecorationAtCell(Pe,D,void 0,(at=>{at.options.layer!=="top"&&kt||(at.backgroundColorRGB&&(ce=50331648,Et=at.backgroundColorRGB.rgba>>8&16777215,Fe=at.backgroundColorRGB),at.foregroundColorRGB&&(it=50331648,Ze=at.foregroundColorRGB.rgba>>8&16777215,Ye=at.foregroundColorRGB),kt=at.options.layer==="top")})),!kt&&Be&&(Fe=this._coreBrowserService.isFocused?z.selectionBackgroundOpaque:z.selectionInactiveBackgroundOpaque,Et=Fe.rgba>>8&16777215,ce=50331648,kt=!0,z.selectionForeground&&(it=50331648,Ze=z.selectionForeground.rgba>>8&16777215,Ye=z.selectionForeground)),kt&&pe.push("xterm-decoration-top"),ce){case 16777216:case 33554432:tt=z.ansi[Et],pe.push(`xterm-bg-${Et}`);break;case 50331648:tt=C.channels.toColor(Et>>16,Et>>8&255,255&Et),this._addStyle(R,`background-color:#${E((Et>>>0).toString(16),"0",6)}`);break;default:Te?(tt=z.foreground,pe.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):tt=z.background}switch(Fe||oe.isDim()&&(Fe=C.color.multiplyOpacity(tt,.5)),it){case 16777216:case 33554432:oe.isBold()&&Ze<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ze+=8),this._applyMinimumContrast(R,tt,z.ansi[Ze],oe,Fe,void 0)||pe.push(`xterm-fg-${Ze}`);break;case 50331648:const at=C.channels.toColor(Ze>>16&255,Ze>>8&255,255&Ze);this._applyMinimumContrast(R,tt,at,oe,Fe,Ye)||this._addStyle(R,`color:#${E(Ze.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(R,tt,z.foreground,oe,Fe,Ye)||Te&&pe.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}pe.length&&(R.className=pe.join(" "),pe.length=0),he||Ne||xe?R.textContent=B:G++,re!==this.defaultSpacing&&(R.style.letterSpacing=`${re}px`),Q.push(R),Pe=je}return R&&G&&(R.textContent=B),Q}_applyMinimumContrast(T,D,L,O,P,q){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,b.treatGlyphAsBackgroundColor)(O.getCode()))return!1;const W=this._getContrastCache(O);let M;if(P||q||(M=W.getColor(D.rgba,L.rgba)),M===void 0){const H=this._optionsService.rawOptions.minimumContrastRatio/(O.isDim()?2:1);M=C.color.ensureContrastRatio(P||D,q||L,H),W.setColor((P||D).rgba,(q||L).rgba,M??null)}return!!M&&(this._addStyle(T,`color:${M.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,D){T.setAttribute("style",`${T.getAttribute("style")||""}${D};`)}_isCellInSelection(T,D){const L=this._selectionStart,O=this._selectionEnd;return!(!L||!O)&&(this._columnSelectMode?L[0]<=O[0]?T>=L[0]&&D>=L[1]&&T<O[0]&&D<=O[1]:T<L[0]&&D>=L[1]&&T>=O[0]&&D<=O[1]:D>L[1]&&D<O[1]||L[1]===O[1]&&D===L[1]&&T>=L[0]&&T<O[0]||L[1]<O[1]&&D===O[1]&&T<O[0]||L[1]<O[1]&&D===L[1]&&T>=L[0])}};function E(T,D,L){for(;T.length<L;)T=D+T;return T}c.DomRendererRowFactory=j=f([p(1,v.ICharacterJoinerService),p(2,w.IOptionsService),p(3,v.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(6,v.IThemeService)],j)},2550:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WidthCache=void 0,c.WidthCache=class{constructor(d,f){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=d.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const p=d.createElement("span");p.classList.add("xterm-char-measure-element");const m=d.createElement("span");m.classList.add("xterm-char-measure-element"),m.style.fontWeight="bold";const x=d.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontStyle="italic";const y=d.createElement("span");y.classList.add("xterm-char-measure-element"),y.style.fontWeight="bold",y.style.fontStyle="italic",this._measureElements=[p,m,x,y],this._container.appendChild(p),this._container.appendChild(m),this._container.appendChild(x),this._container.appendChild(y),f.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(d,f,p,m){d===this._font&&f===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=d,this._fontSize=f,this._weight=p,this._weightBold=m,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${p}`,this._measureElements[1].style.fontWeight=`${m}`,this._measureElements[2].style.fontWeight=`${p}`,this._measureElements[3].style.fontWeight=`${m}`,this.clear())}get(d,f,p){let m=0;if(!f&&!p&&d.length===1&&(m=d.charCodeAt(0))<256){if(this._flat[m]!==-9999)return this._flat[m];const w=this._measure(d,0);return w>0&&(this._flat[m]=w),w}let x=d;f&&(x+="B"),p&&(x+="I");let y=this._holey.get(x);if(y===void 0){let w=0;f&&(w|=1),p&&(w|=2),y=this._measure(d,w),y>0&&this._holey.set(x,y)}return y}_measure(d,f){const p=this._measureElements[f];return p.textContent=d.repeat(32),p.offsetWidth/32}}},2223:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TEXT_BASELINE=c.DIM_OPACITY=c.INVERTED_DEFAULT_COLOR=void 0;const f=d(6114);c.INVERTED_DEFAULT_COLOR=257,c.DIM_OPACITY=.5,c.TEXT_BASELINE=f.isFirefox||f.isLegacyEdge?"bottom":"ideographic"},6171:(u,c)=>{function d(p){return 57508<=p&&p<=57558}function f(p){return p>=128512&&p<=128591||p>=127744&&p<=128511||p>=128640&&p<=128767||p>=9728&&p<=9983||p>=9984&&p<=10175||p>=65024&&p<=65039||p>=129280&&p<=129535||p>=127462&&p<=127487}Object.defineProperty(c,"__esModule",{value:!0}),c.computeNextVariantOffset=c.createRenderDimensions=c.treatGlyphAsBackgroundColor=c.allowRescaling=c.isEmoji=c.isRestrictedPowerlineGlyph=c.isPowerlineGlyph=c.throwIfFalsy=void 0,c.throwIfFalsy=function(p){if(!p)throw new Error("value must not be falsy");return p},c.isPowerlineGlyph=d,c.isRestrictedPowerlineGlyph=function(p){return 57520<=p&&p<=57527},c.isEmoji=f,c.allowRescaling=function(p,m,x,y){return m===1&&x>Math.ceil(1.5*y)&&p!==void 0&&p>255&&!f(p)&&!d(p)&&!(function(w){return 57344<=w&&w<=63743})(p)},c.treatGlyphAsBackgroundColor=function(p){return d(p)||(function(m){return 9472<=m&&m<=9631})(p)},c.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},c.computeNextVariantOffset=function(p,m,x=0){return(p-(2*Math.round(m)-x))%(2*Math.round(m))}},6052:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createSelectionRenderModel=void 0;class d{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(p,m,x,y=!1){if(this.selectionStart=m,this.selectionEnd=x,!m||!x||m[0]===x[0]&&m[1]===x[1])return void this.clear();const w=p.buffers.active.ydisp,C=m[1]-w,v=x[1]-w,S=Math.max(C,0),b=Math.min(v,p.rows-1);S>=p.rows||b<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=y,this.viewportStartRow=C,this.viewportEndRow=v,this.viewportCappedStartRow=S,this.viewportCappedEndRow=b,this.startCol=m[0],this.endCol=x[0])}isCellSelected(p,m,x){return!!this.hasSelection&&(x-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&x>=this.viewportCappedStartRow&&m<this.endCol&&x<=this.viewportCappedEndRow:m<this.startCol&&x>=this.viewportCappedStartRow&&m>=this.endCol&&x<=this.viewportCappedEndRow:x>this.viewportStartRow&&x<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol)}}c.createSelectionRenderModel=function(){return new d}},456:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionModel=void 0,c.SelectionModel=class{constructor(d){this._bufferService=d,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?d%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)-1]:[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[d,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[Math.max(d,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const d=this.selectionStart,f=this.selectionEnd;return!(!d||!f)&&(d[1]>f[1]||d[1]===f[1]&&d[0]>f[0])}handleTrim(d){return this.selectionStart&&(this.selectionStart[1]-=d),this.selectionEnd&&(this.selectionEnd[1]-=d),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(u,c,d){var f=this&&this.__decorate||function(b,_,j,E){var T,D=arguments.length,L=D<3?_:E===null?E=Object.getOwnPropertyDescriptor(_,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,_,j,E);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(_,j,L):T(_,j))||L);return D>3&&L&&Object.defineProperty(_,j,L),L},p=this&&this.__param||function(b,_){return function(j,E){_(j,E,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharSizeService=void 0;const m=d(2585),x=d(8460),y=d(844);let w=c.CharSizeService=class extends y.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(b,_,j){super(),this._optionsService=j,this.width=0,this.height=0,this._onCharSizeChange=this.register(new x.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(this._optionsService))}catch{this._measureStrategy=this.register(new v(b,_,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const b=this._measureStrategy.measure();b.width===this.width&&b.height===this.height||(this.width=b.width,this.height=b.height,this._onCharSizeChange.fire())}};c.CharSizeService=w=f([p(2,m.IOptionsService)],w);class C extends y.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(_,j){_!==void 0&&_>0&&j!==void 0&&j>0&&(this._result.width=_,this._result.height=j)}}class v extends C{constructor(_,j,E){super(),this._document=_,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(_){super(),this._optionsService=_,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 _=this._ctx.measureText("W");return this._validateAndSet(_.width,_.fontBoundingBoxAscent+_.fontBoundingBoxDescent),this._result}}},4269:function(u,c,d){var f=this&&this.__decorate||function(S,b,_,j){var E,T=arguments.length,D=T<3?b:j===null?j=Object.getOwnPropertyDescriptor(b,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,b,_,j);else for(var L=S.length-1;L>=0;L--)(E=S[L])&&(D=(T<3?E(D):T>3?E(b,_,D):E(b,_))||D);return T>3&&D&&Object.defineProperty(b,_,D),D},p=this&&this.__param||function(S,b){return function(_,j){b(_,j,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharacterJoinerService=c.JoinedCellData=void 0;const m=d(3734),x=d(643),y=d(511),w=d(2585);class C extends m.AttributeData{constructor(b,_,j){super(),this.content=0,this.combinedData="",this.fg=b.fg,this.bg=b.bg,this.combinedData=_,this._width=j}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(b){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=C;let v=c.CharacterJoinerService=class t1{constructor(b){this._bufferService=b,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new y.CellData}register(b){const _={id:this._nextCharacterJoinerId++,handler:b};return this._characterJoiners.push(_),_.id}deregister(b){for(let _=0;_<this._characterJoiners.length;_++)if(this._characterJoiners[_].id===b)return this._characterJoiners.splice(_,1),!0;return!1}getJoinedCharacters(b){if(this._characterJoiners.length===0)return[];const _=this._bufferService.buffer.lines.get(b);if(!_||_.length===0)return[];const j=[],E=_.translateToString(!0);let T=0,D=0,L=0,O=_.getFg(0),P=_.getBg(0);for(let q=0;q<_.getTrimmedLength();q++)if(_.loadCell(q,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==O||this._workCell.bg!==P){if(q-T>1){const W=this._getJoinedRanges(E,L,D,_,T);for(let M=0;M<W.length;M++)j.push(W[M])}T=q,L=D,O=this._workCell.fg,P=this._workCell.bg}D+=this._workCell.getChars().length||x.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const q=this._getJoinedRanges(E,L,D,_,T);for(let W=0;W<q.length;W++)j.push(q[W])}return j}_getJoinedRanges(b,_,j,E,T){const D=b.substring(_,j);let L=[];try{L=this._characterJoiners[0].handler(D)}catch(O){console.error(O)}for(let O=1;O<this._characterJoiners.length;O++)try{const P=this._characterJoiners[O].handler(D);for(let q=0;q<P.length;q++)t1._mergeRanges(L,P[q])}catch(P){console.error(P)}return this._stringRangesToCellRanges(L,E,T),L}_stringRangesToCellRanges(b,_,j){let E=0,T=!1,D=0,L=b[E];if(L){for(let O=j;O<this._bufferService.cols;O++){const P=_.getWidth(O),q=_.getString(O).length||x.WHITESPACE_CELL_CHAR.length;if(P!==0){if(!T&&L[0]<=D&&(L[0]=O,T=!0),L[1]<=D){if(L[1]=O,L=b[++E],!L)break;L[0]<=D?(L[0]=O,T=!0):T=!1}D+=q}}L&&(L[1]=this._bufferService.cols)}}static _mergeRanges(b,_){let j=!1;for(let E=0;E<b.length;E++){const T=b[E];if(j){if(_[1]<=T[0])return b[E-1][1]=_[1],b;if(_[1]<=T[1])return b[E-1][1]=Math.max(_[1],T[1]),b.splice(E,1),b;b.splice(E,1),E--}else{if(_[1]<=T[0])return b.splice(E,0,_),b;if(_[1]<=T[1])return T[0]=Math.min(_[0],T[0]),b;_[0]<T[1]&&(T[0]=Math.min(_[0],T[0]),j=!0)}}return j?b[b.length-1][1]=_[1]:b.push(_),b}};c.CharacterJoinerService=v=f([p(0,w.IBufferService)],v)},5114:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const f=d(844),p=d(8460),m=d(3656);class x extends f.Disposable{constructor(C,v,S){super(),this._textarea=C,this._window=v,this.mainDocument=S,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new y(this._window),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new p.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((b=>this._screenDprMonitor.setWindow(b)))),this.register((0,p.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}c.CoreBrowserService=x;class y extends f.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new f.MutableDisposable),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,f.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,m.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.LinkProviderService=void 0;const f=d(844);class p extends f.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,f.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(x){return this.linkProviders.push(x),{dispose:()=>{const y=this.linkProviders.indexOf(x);y!==-1&&this.linkProviders.splice(y,1)}}}}c.LinkProviderService=p},8934:function(u,c,d){var f=this&&this.__decorate||function(w,C,v,S){var b,_=arguments.length,j=_<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--)(b=w[E])&&(j=(_<3?b(j):_>3?b(C,v,j):b(C,v))||j);return _>3&&j&&Object.defineProperty(C,v,j),j},p=this&&this.__param||function(w,C){return function(v,S){C(v,S,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const m=d(4725),x=d(9806);let y=c.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,v,S,b){return(0,x.getCoords)(window,w,C,v,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,b)}getMouseReportCoords(w,C){const v=(0,x.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])}}};c.MouseService=y=f([p(0,m.IRenderService),p(1,m.ICharSizeService)],y)},3230:function(u,c,d){var f=this&&this.__decorate||function(b,_,j,E){var T,D=arguments.length,L=D<3?_:E===null?E=Object.getOwnPropertyDescriptor(_,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,_,j,E);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(_,j,L):T(_,j))||L);return D>3&&L&&Object.defineProperty(_,j,L),L},p=this&&this.__param||function(b,_){return function(j,E){_(j,E,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const m=d(6193),x=d(4725),y=d(8460),w=d(844),C=d(7226),v=d(2585);let S=c.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,_,j,E,T,D,L,O){super(),this._rowCount=b,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 y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(((P,q)=>this._renderRows(P,q)),L),this.register(this._renderDebouncer),this.register(L.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(D.onResize((()=>this._fullRefresh()))),this.register(D.buffers.onBufferActivate((()=>{var P;return(P=this._renderer.value)==null?void 0:P.clear()}))),this.register(j.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(T.onDecorationRegistered((()=>this._fullRefresh()))),this.register(T.onDecorationRemoved((()=>this._fullRefresh()))),this.register(j.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(D.cols,D.rows),this._fullRefresh()}))),this.register(j.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(D.buffer.y,D.buffer.y,!0)))),this.register(O.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(L.window,_),this.register(L.onWindowChange((P=>this._registerIntersectionObserver(P,_))))}_registerIntersectionObserver(b,_){if("IntersectionObserver"in b){const j=new b.IntersectionObserver((E=>this._handleIntersectionChange(E[E.length-1])),{threshold:0});j.observe(_),this._observerDisposable.value=(0,w.toDisposable)((()=>j.disconnect()))}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,_,j=!1){this._isPaused?this._needsFullRefresh=!0:(j||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,_,this._rowCount))}_renderRows(b,_){this._renderer.value&&(b=Math.min(b,this._rowCount-1),_=Math.min(_,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:b,end:_}),this._onRender.fire({start:b,end:_}),this._isNextRenderRedrawOnly=!0)}resize(b,_){this._rowCount=_,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value&&(this._renderer.value.onRequestRedraw((_=>this.refreshRows(_.start,_.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,_;this._renderer.value&&((_=(b=this._renderer.value).clearTextureAtlas)==null||_.call(b),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 b;(b=this._renderer.value)==null||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)==null||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)==null||b.handleFocus()}handleSelectionChanged(b,_,j){var E;this._selectionState.start=b,this._selectionState.end=_,this._selectionState.columnSelectMode=j,(E=this._renderer.value)==null||E.handleSelectionChanged(b,_,j)}handleCursorMove(){var b;(b=this._renderer.value)==null||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)==null||b.clear()}};c.RenderService=S=f([p(2,v.IOptionsService),p(3,x.ICharSizeService),p(4,v.IDecorationService),p(5,v.IBufferService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],S)},9312:function(u,c,d){var f=this&&this.__decorate||function(L,O,P,q){var W,M=arguments.length,H=M<3?O:q===null?q=Object.getOwnPropertyDescriptor(O,P):q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(L,O,P,q);else for(var V=L.length-1;V>=0;V--)(W=L[V])&&(H=(M<3?W(H):M>3?W(O,P,H):W(O,P))||H);return M>3&&H&&Object.defineProperty(O,P,H),H},p=this&&this.__param||function(L,O){return function(P,q){O(P,q,L)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const m=d(9806),x=d(9504),y=d(456),w=d(4725),C=d(8460),v=d(844),S=d(6114),b=d(4841),_=d(511),j=d(2585),E=" ",T=new RegExp(E,"g");let D=c.SelectionService=class extends v.Disposable{constructor(L,O,P,q,W,M,H,V,U){super(),this._element=L,this._screenElement=O,this._linkifier=P,this._bufferService=q,this._coreService=W,this._mouseService=M,this._optionsService=H,this._renderService=V,this._coreBrowserService=U,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new _.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=Q=>this._handleMouseMove(Q),this._mouseUpListener=Q=>this._handleMouseUp(Q),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((Q=>this._handleTrim(Q))),this.register(this._bufferService.buffers.onBufferActivate((Q=>this._handleBufferActivate(Q)))),this.enable(),this._model=new y.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 L=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;return!(!L||!O||L[0]===O[0]&&L[1]===O[1])}get selectionText(){const L=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;if(!L||!O)return"";const P=this._bufferService.buffer,q=[];if(this._activeSelectionMode===3){if(L[0]===O[0])return"";const W=L[0]<O[0]?L[0]:O[0],M=L[0]<O[0]?O[0]:L[0];for(let H=L[1];H<=O[1];H++){const V=P.translateBufferLineToString(H,!0,W,M);q.push(V)}}else{const W=L[1]===O[1]?O[0]:void 0;q.push(P.translateBufferLineToString(L[1],!0,L[0],W));for(let M=L[1]+1;M<=O[1]-1;M++){const H=P.lines.get(M),V=P.translateBufferLineToString(M,!0);H!=null&&H.isWrapped?q[q.length-1]+=V:q.push(V)}if(L[1]!==O[1]){const M=P.lines.get(O[1]),H=P.translateBufferLineToString(O[1],!0,0,O[0]);M&&M.isWrapped?q[q.length-1]+=H:q.push(H)}}return q.map((W=>W.replace(T," "))).join(S.isWindows?`\r
|
|
65
|
+
`:`
|
|
66
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(L){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),S.isLinux&&L&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(L){const O=this._getMouseBufferCoords(L),P=this._model.finalSelectionStart,q=this._model.finalSelectionEnd;return!!(P&&q&&O)&&this._areCoordsInSelection(O,P,q)}isCellInSelection(L,O){const P=this._model.finalSelectionStart,q=this._model.finalSelectionEnd;return!(!P||!q)&&this._areCoordsInSelection([L,O],P,q)}_areCoordsInSelection(L,O,P){return L[1]>O[1]&&L[1]<P[1]||O[1]===P[1]&&L[1]===O[1]&&L[0]>=O[0]&&L[0]<P[0]||O[1]<P[1]&&L[1]===P[1]&&L[0]<P[0]||O[1]<P[1]&&L[1]===O[1]&&L[0]>=O[0]}_selectWordAtCursor(L,O){var W,M;const P=(M=(W=this._linkifier.currentLink)==null?void 0:W.link)==null?void 0:M.range;if(P)return this._model.selectionStart=[P.start.x-1,P.start.y-1],this._model.selectionStartLength=(0,b.getRangeLength)(P,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const q=this._getMouseBufferCoords(L);return!!q&&(this._selectWordAt(q,O),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(L,O){this._model.clearSelection(),L=Math.max(L,0),O=Math.min(O,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,L],this._model.selectionEnd=[this._bufferService.cols,O],this.refresh(),this._onSelectionChange.fire()}_handleTrim(L){this._model.handleTrim(L)&&this.refresh()}_getMouseBufferCoords(L){const O=this._mouseService.getCoords(L,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(O)return O[0]--,O[1]--,O[1]+=this._bufferService.buffer.ydisp,O}_getMouseEventScrollAmount(L){let O=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,L,this._screenElement)[1];const P=this._renderService.dimensions.css.canvas.height;return O>=0&&O<=P?0:(O>P&&(O-=P),O=Math.min(Math.max(O,-50),50),O/=50,O/Math.abs(O)+Math.round(14*O))}shouldForceSelection(L){return S.isMac?L.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:L.shiftKey}handleMouseDown(L){if(this._mouseDownTimeStamp=L.timeStamp,(L.button!==2||!this.hasSelection)&&L.button===0){if(!this._enabled){if(!this.shouldForceSelection(L))return;L.stopPropagation()}L.preventDefault(),this._dragScrollAmount=0,this._enabled&&L.shiftKey?this._handleIncrementalClick(L):L.detail===1?this._handleSingleClick(L):L.detail===2?this._handleDoubleClick(L):L.detail===3&&this._handleTripleClick(L),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(L){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(L))}_handleSingleClick(L){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(L)?3:0,this._model.selectionStart=this._getMouseBufferCoords(L),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const O=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);O&&O.length!==this._model.selectionStart[0]&&O.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(L){this._selectWordAtCursor(L,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(L){const O=this._getMouseBufferCoords(L);O&&(this._activeSelectionMode=2,this._selectLineAt(O[1]))}shouldColumnSelect(L){return L.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(L){if(L.stopImmediatePropagation(),!this._model.selectionStart)return;const O=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(L),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(L),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const P=this._bufferService.buffer;if(this._model.selectionEnd[1]<P.lines.length){const q=P.lines.get(this._model.selectionEnd[1]);q&&q.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}O&&O[0]===this._model.selectionEnd[0]&&O[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const L=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(L.ydisp+this._bufferService.rows,L.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=L.ydisp),this.refresh()}}_handleMouseUp(L){const O=L.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&O<500&&L.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const P=this._mouseService.getCoords(L,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(P&&P[0]!==void 0&&P[1]!==void 0){const q=(0,x.moveToCellSequence)(P[0]-1,P[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(q,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const L=this._model.finalSelectionStart,O=this._model.finalSelectionEnd,P=!(!L||!O||L[0]===O[0]&&L[1]===O[1]);P?L&&O&&(this._oldSelectionStart&&this._oldSelectionEnd&&L[0]===this._oldSelectionStart[0]&&L[1]===this._oldSelectionStart[1]&&O[0]===this._oldSelectionEnd[0]&&O[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(L,O,P)):this._oldHasSelection&&this._fireOnSelectionChange(L,O,P)}_fireOnSelectionChange(L,O,P){this._oldSelectionStart=L,this._oldSelectionEnd=O,this._oldHasSelection=P,this._onSelectionChange.fire()}_handleBufferActivate(L){this.clearSelection(),this._trimListener.dispose(),this._trimListener=L.activeBuffer.lines.onTrim((O=>this._handleTrim(O)))}_convertViewportColToCharacterIndex(L,O){let P=O;for(let q=0;O>=q;q++){const W=L.loadCell(q,this._workCell).getChars().length;this._workCell.getWidth()===0?P--:W>1&&O!==q&&(P+=W-1)}return P}setSelection(L,O,P){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[L,O],this._model.selectionStartLength=P,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(L){this._isClickInSelection(L)||(this._selectWordAtCursor(L,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(L,O,P=!0,q=!0){if(L[0]>=this._bufferService.cols)return;const W=this._bufferService.buffer,M=W.lines.get(L[1]);if(!M)return;const H=W.translateBufferLineToString(L[1],!1);let V=this._convertViewportColToCharacterIndex(M,L[0]),U=V;const Q=L[0]-V;let X=0,z=0,R=0,I=0;if(H.charAt(V)===" "){for(;V>0&&H.charAt(V-1)===" ";)V--;for(;U<H.length&&H.charAt(U+1)===" ";)U++}else{let ee=L[0],J=L[0];M.getWidth(ee)===0&&(X++,ee--),M.getWidth(J)===2&&(z++,J++);const ne=M.getString(J).length;for(ne>1&&(I+=ne-1,U+=ne-1);ee>0&&V>0&&!this._isCharWordSeparator(M.loadCell(ee-1,this._workCell));){M.loadCell(ee-1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===0?(X++,ee--):K>1&&(R+=K-1,V-=K-1),V--,ee--}for(;J<M.length&&U+1<H.length&&!this._isCharWordSeparator(M.loadCell(J+1,this._workCell));){M.loadCell(J+1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===2?(z++,J++):K>1&&(I+=K-1,U+=K-1),U++,J++}}U++;let G=V+Q-X+R,B=Math.min(this._bufferService.cols,U-V+X+z-R-I);if(O||H.slice(V,U).trim()!==""){if(P&&G===0&&M.getCodePoint(0)!==32){const ee=W.lines.get(L[1]-1);if(ee&&M.isWrapped&&ee.getCodePoint(this._bufferService.cols-1)!==32){const J=this._getWordAt([this._bufferService.cols-1,L[1]-1],!1,!0,!1);if(J){const ne=this._bufferService.cols-J.start;G-=ne,B+=ne}}}if(q&&G+B===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const ee=W.lines.get(L[1]+1);if(ee!=null&&ee.isWrapped&&ee.getCodePoint(0)!==32){const J=this._getWordAt([0,L[1]+1],!1,!1,!0);J&&(B+=J.length)}}return{start:G,length:B}}}_selectWordAt(L,O){const P=this._getWordAt(L,O);if(P){for(;P.start<0;)P.start+=this._bufferService.cols,L[1]--;this._model.selectionStart=[P.start,L[1]],this._model.selectionStartLength=P.length}}_selectToWordAt(L){const O=this._getWordAt(L,!0);if(O){let P=L[1];for(;O.start<0;)O.start+=this._bufferService.cols,P--;if(!this._model.areSelectionValuesReversed())for(;O.start+O.length>this._bufferService.cols;)O.length-=this._bufferService.cols,P++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?O.start:O.start+O.length,P]}}_isCharWordSeparator(L){return L.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(L.getChars())>=0}_selectLineAt(L){const O=this._bufferService.buffer.getWrappedRangeForLine(L),P={start:{x:0,y:O.first},end:{x:this._bufferService.cols-1,y:O.last}};this._model.selectionStart=[0,O.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,b.getRangeLength)(P,this._bufferService.cols)}};c.SelectionService=D=f([p(3,j.IBufferService),p(4,j.ICoreService),p(5,w.IMouseService),p(6,j.IOptionsService),p(7,w.IRenderService),p(8,w.ICoreBrowserService)],D)},4725:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ILinkProviderService=c.IThemeService=c.ICharacterJoinerService=c.ISelectionService=c.IRenderService=c.IMouseService=c.ICoreBrowserService=c.ICharSizeService=void 0;const f=d(8343);c.ICharSizeService=(0,f.createDecorator)("CharSizeService"),c.ICoreBrowserService=(0,f.createDecorator)("CoreBrowserService"),c.IMouseService=(0,f.createDecorator)("MouseService"),c.IRenderService=(0,f.createDecorator)("RenderService"),c.ISelectionService=(0,f.createDecorator)("SelectionService"),c.ICharacterJoinerService=(0,f.createDecorator)("CharacterJoinerService"),c.IThemeService=(0,f.createDecorator)("ThemeService"),c.ILinkProviderService=(0,f.createDecorator)("LinkProviderService")},6731:function(u,c,d){var f=this&&this.__decorate||function(D,L,O,P){var q,W=arguments.length,M=W<3?L:P===null?P=Object.getOwnPropertyDescriptor(L,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(D,L,O,P);else for(var H=D.length-1;H>=0;H--)(q=D[H])&&(M=(W<3?q(M):W>3?q(L,O,M):q(L,O))||M);return W>3&&M&&Object.defineProperty(L,O,M),M},p=this&&this.__param||function(D,L){return function(O,P){L(O,P,D)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const m=d(7239),x=d(8055),y=d(8460),w=d(844),C=d(2585),v=x.css.toColor("#ffffff"),S=x.css.toColor("#000000"),b=x.css.toColor("#ffffff"),_=x.css.toColor("#000000"),j={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};c.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const D=[x.css.toColor("#2e3436"),x.css.toColor("#cc0000"),x.css.toColor("#4e9a06"),x.css.toColor("#c4a000"),x.css.toColor("#3465a4"),x.css.toColor("#75507b"),x.css.toColor("#06989a"),x.css.toColor("#d3d7cf"),x.css.toColor("#555753"),x.css.toColor("#ef2929"),x.css.toColor("#8ae234"),x.css.toColor("#fce94f"),x.css.toColor("#729fcf"),x.css.toColor("#ad7fa8"),x.css.toColor("#34e2e2"),x.css.toColor("#eeeeec")],L=[0,95,135,175,215,255];for(let O=0;O<216;O++){const P=L[O/36%6|0],q=L[O/6%6|0],W=L[O%6];D.push({css:x.channels.toCss(P,q,W),rgba:x.channels.toRgba(P,q,W)})}for(let O=0;O<24;O++){const P=8+10*O;D.push({css:x.channels.toCss(P,P,P),rgba:x.channels.toRgba(P,P,P)})}return D})());let E=c.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(D){super(),this._optionsService=D,this._contrastCache=new m.ColorContrastCache,this._halfContrastCache=new m.ColorContrastCache,this._onChangeColors=this.register(new y.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:v,background:S,cursor:b,cursorAccent:_,selectionForeground:void 0,selectionBackgroundTransparent:j,selectionBackgroundOpaque:x.color.blend(S,j),selectionInactiveBackgroundTransparent:j,selectionInactiveBackgroundOpaque:x.color.blend(S,j),ansi:c.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(D={}){const L=this._colors;if(L.foreground=T(D.foreground,v),L.background=T(D.background,S),L.cursor=T(D.cursor,b),L.cursorAccent=T(D.cursorAccent,_),L.selectionBackgroundTransparent=T(D.selectionBackground,j),L.selectionBackgroundOpaque=x.color.blend(L.background,L.selectionBackgroundTransparent),L.selectionInactiveBackgroundTransparent=T(D.selectionInactiveBackground,L.selectionBackgroundTransparent),L.selectionInactiveBackgroundOpaque=x.color.blend(L.background,L.selectionInactiveBackgroundTransparent),L.selectionForeground=D.selectionForeground?T(D.selectionForeground,x.NULL_COLOR):void 0,L.selectionForeground===x.NULL_COLOR&&(L.selectionForeground=void 0),x.color.isOpaque(L.selectionBackgroundTransparent)&&(L.selectionBackgroundTransparent=x.color.opacity(L.selectionBackgroundTransparent,.3)),x.color.isOpaque(L.selectionInactiveBackgroundTransparent)&&(L.selectionInactiveBackgroundTransparent=x.color.opacity(L.selectionInactiveBackgroundTransparent,.3)),L.ansi=c.DEFAULT_ANSI_COLORS.slice(),L.ansi[0]=T(D.black,c.DEFAULT_ANSI_COLORS[0]),L.ansi[1]=T(D.red,c.DEFAULT_ANSI_COLORS[1]),L.ansi[2]=T(D.green,c.DEFAULT_ANSI_COLORS[2]),L.ansi[3]=T(D.yellow,c.DEFAULT_ANSI_COLORS[3]),L.ansi[4]=T(D.blue,c.DEFAULT_ANSI_COLORS[4]),L.ansi[5]=T(D.magenta,c.DEFAULT_ANSI_COLORS[5]),L.ansi[6]=T(D.cyan,c.DEFAULT_ANSI_COLORS[6]),L.ansi[7]=T(D.white,c.DEFAULT_ANSI_COLORS[7]),L.ansi[8]=T(D.brightBlack,c.DEFAULT_ANSI_COLORS[8]),L.ansi[9]=T(D.brightRed,c.DEFAULT_ANSI_COLORS[9]),L.ansi[10]=T(D.brightGreen,c.DEFAULT_ANSI_COLORS[10]),L.ansi[11]=T(D.brightYellow,c.DEFAULT_ANSI_COLORS[11]),L.ansi[12]=T(D.brightBlue,c.DEFAULT_ANSI_COLORS[12]),L.ansi[13]=T(D.brightMagenta,c.DEFAULT_ANSI_COLORS[13]),L.ansi[14]=T(D.brightCyan,c.DEFAULT_ANSI_COLORS[14]),L.ansi[15]=T(D.brightWhite,c.DEFAULT_ANSI_COLORS[15]),D.extendedAnsi){const O=Math.min(L.ansi.length-16,D.extendedAnsi.length);for(let P=0;P<O;P++)L.ansi[P+16]=T(D.extendedAnsi[P],c.DEFAULT_ANSI_COLORS[P+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(D){this._restoreColor(D),this._onChangeColors.fire(this.colors)}_restoreColor(D){if(D!==void 0)switch(D){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[D]=this._restoreColors.ansi[D]}else for(let L=0;L<this._restoreColors.ansi.length;++L)this._colors.ansi[L]=this._restoreColors.ansi[L]}modifyColors(D){D(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function T(D,L){if(D!==void 0)try{return x.css.toColor(D)}catch{}return L}c.ThemeService=E=f([p(0,C.IOptionsService)],E)},6349:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const f=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._maxLength=y,this.onDeleteEmitter=this.register(new f.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new f.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new f.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(y){if(this._maxLength===y)return;const w=new Array(y);for(let C=0;C<Math.min(y,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=y,this._startIndex=0}get length(){return this._length}set length(y){if(y>this._length)for(let w=this._length;w<y;w++)this._array[w]=void 0;this._length=y}get(y){return this._array[this._getCyclicIndex(y)]}set(y,w){this._array[this._getCyclicIndex(y)]=w}push(y){this._array[this._getCyclicIndex(this._length)]=y,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(y,w,...C){if(w){for(let v=y;v<this._length-w;v++)this._array[this._getCyclicIndex(v)]=this._array[this._getCyclicIndex(v+w)];this._length-=w,this.onDeleteEmitter.fire({index:y,amount:w})}for(let v=this._length-1;v>=y;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(y+v)]=C[v];if(C.length&&this.onInsertEmitter.fire({index:y,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(y){y>this._length&&(y=this._length),this._startIndex+=y,this._length-=y,this.onTrimEmitter.fire(y)}shiftElements(y,w,C){if(!(w<=0)){if(y<0||y>=this._length)throw new Error("start argument out of range");if(y+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(y+S+C,this.get(y+S));const v=y+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(y+v+C,this.get(y+v))}}_getCyclicIndex(y){return(this._startIndex+y)%this._maxLength}}c.CircularList=m},1439:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.clone=void 0,c.clone=function d(f,p=5){if(typeof f!="object")return f;const m=Array.isArray(f)?[]:{};for(const x in f)m[x]=p<=1?f[x]:f[x]&&d(f[x],p-1);return m}},8055:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.contrastRatio=c.toPaddedHex=c.rgba=c.rgb=c.css=c.color=c.channels=c.NULL_COLOR=void 0;let d=0,f=0,p=0,m=0;var x,y,w,C,v;function S(_){const j=_.toString(16);return j.length<2?"0"+j:j}function b(_,j){return _<j?(j+.05)/(_+.05):(_+.05)/(j+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(_){_.toCss=function(j,E,T,D){return D!==void 0?`#${S(j)}${S(E)}${S(T)}${S(D)}`:`#${S(j)}${S(E)}${S(T)}`},_.toRgba=function(j,E,T,D=255){return(j<<24|E<<16|T<<8|D)>>>0},_.toColor=function(j,E,T,D){return{css:_.toCss(j,E,T,D),rgba:_.toRgba(j,E,T,D)}}})(x||(c.channels=x={})),(function(_){function j(E,T){return m=Math.round(255*T),[d,f,p]=v.toChannels(E.rgba),{css:x.toCss(d,f,p,m),rgba:x.toRgba(d,f,p,m)}}_.blend=function(E,T){if(m=(255&T.rgba)/255,m===1)return{css:T.css,rgba:T.rgba};const D=T.rgba>>24&255,L=T.rgba>>16&255,O=T.rgba>>8&255,P=E.rgba>>24&255,q=E.rgba>>16&255,W=E.rgba>>8&255;return d=P+Math.round((D-P)*m),f=q+Math.round((L-q)*m),p=W+Math.round((O-W)*m),{css:x.toCss(d,f,p),rgba:x.toRgba(d,f,p)}},_.isOpaque=function(E){return(255&E.rgba)==255},_.ensureContrastRatio=function(E,T,D){const L=v.ensureContrastRatio(E.rgba,T.rgba,D);if(L)return x.toColor(L>>24&255,L>>16&255,L>>8&255)},_.opaque=function(E){const T=(255|E.rgba)>>>0;return[d,f,p]=v.toChannels(T),{css:x.toCss(d,f,p),rgba:T}},_.opacity=j,_.multiplyOpacity=function(E,T){return m=255&E.rgba,j(E,m*T/255)},_.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(y||(c.color=y={})),(function(_){let j,E;try{const T=document.createElement("canvas");T.width=1,T.height=1;const D=T.getContext("2d",{willReadFrequently:!0});D&&(j=D,j.globalCompositeOperation="copy",E=j.createLinearGradient(0,0,1,1))}catch{}_.toColor=function(T){if(T.match(/#[\da-f]{3,8}/i))switch(T.length){case 4:return d=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),x.toColor(d,f,p);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),m=parseInt(T.slice(4,5).repeat(2),16),x.toColor(d,f,p,m);case 7:return{css:T,rgba:(parseInt(T.slice(1),16)<<8|255)>>>0};case 9:return{css:T,rgba:parseInt(T.slice(1),16)>>>0}}const D=T.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(D)return d=parseInt(D[1]),f=parseInt(D[2]),p=parseInt(D[3]),m=Math.round(255*(D[5]===void 0?1:parseFloat(D[5]))),x.toColor(d,f,p,m);if(!j||!E)throw new Error("css.toColor: Unsupported css format");if(j.fillStyle=E,j.fillStyle=T,typeof j.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(j.fillRect(0,0,1,1),[d,f,p,m]=j.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:x.toRgba(d,f,p,m),css:T}}})(w||(c.css=w={})),(function(_){function j(E,T,D){const L=E/255,O=T/255,P=D/255;return .2126*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.7152*(O<=.03928?O/12.92:Math.pow((O+.055)/1.055,2.4))+.0722*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))}_.relativeLuminance=function(E){return j(E>>16&255,E>>8&255,255&E)},_.relativeLuminance2=j})(C||(c.rgb=C={})),(function(_){function j(T,D,L){const O=T>>24&255,P=T>>16&255,q=T>>8&255;let W=D>>24&255,M=D>>16&255,H=D>>8&255,V=b(C.relativeLuminance2(W,M,H),C.relativeLuminance2(O,P,q));for(;V<L&&(W>0||M>0||H>0);)W-=Math.max(0,Math.ceil(.1*W)),M-=Math.max(0,Math.ceil(.1*M)),H-=Math.max(0,Math.ceil(.1*H)),V=b(C.relativeLuminance2(W,M,H),C.relativeLuminance2(O,P,q));return(W<<24|M<<16|H<<8|255)>>>0}function E(T,D,L){const O=T>>24&255,P=T>>16&255,q=T>>8&255;let W=D>>24&255,M=D>>16&255,H=D>>8&255,V=b(C.relativeLuminance2(W,M,H),C.relativeLuminance2(O,P,q));for(;V<L&&(W<255||M<255||H<255);)W=Math.min(255,W+Math.ceil(.1*(255-W))),M=Math.min(255,M+Math.ceil(.1*(255-M))),H=Math.min(255,H+Math.ceil(.1*(255-H))),V=b(C.relativeLuminance2(W,M,H),C.relativeLuminance2(O,P,q));return(W<<24|M<<16|H<<8|255)>>>0}_.blend=function(T,D){if(m=(255&D)/255,m===1)return D;const L=D>>24&255,O=D>>16&255,P=D>>8&255,q=T>>24&255,W=T>>16&255,M=T>>8&255;return d=q+Math.round((L-q)*m),f=W+Math.round((O-W)*m),p=M+Math.round((P-M)*m),x.toRgba(d,f,p)},_.ensureContrastRatio=function(T,D,L){const O=C.relativeLuminance(T>>8),P=C.relativeLuminance(D>>8);if(b(O,P)<L){if(P<O){const M=j(T,D,L),H=b(O,C.relativeLuminance(M>>8));if(H<L){const V=E(T,D,L);return H>b(O,C.relativeLuminance(V>>8))?M:V}return M}const q=E(T,D,L),W=b(O,C.relativeLuminance(q>>8));if(W<L){const M=j(T,D,L);return W>b(O,C.relativeLuminance(M>>8))?q:M}return q}},_.reduceLuminance=j,_.increaseLuminance=E,_.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(v||(c.rgba=v={})),c.toPaddedHex=S,c.contrastRatio=b},8969:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const f=d(844),p=d(2585),m=d(4348),x=d(7866),y=d(744),w=d(7302),C=d(6975),v=d(8460),S=d(1753),b=d(1480),_=d(7994),j=d(9282),E=d(5435),T=d(5981),D=d(2660);let L=!1;class O extends f.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new v.EventEmitter),this._onScroll.event((q=>{var W;(W=this._onScrollApi)==null||W.fire(q.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(q){for(const W in q)this.optionsService.options[W]=q[W]}constructor(q){super(),this._windowsWrappingHeuristics=this.register(new f.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 m.InstantiationService,this.optionsService=this.register(new w.OptionsService(q)),this._instantiationService.setService(p.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(y.BufferService)),this._instantiationService.setService(p.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(x.LogService)),this._instantiationService.setService(p.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(p.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(p.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(b.UnicodeService)),this._instantiationService.setService(p.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(_.CharsetService),this._instantiationService.setService(p.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(D.OscLinkService),this._instantiationService.setService(p.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new 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((W=>{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((W=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new T.WriteBuffer(((W,M)=>this._inputHandler.parse(W,M)))),this.register((0,v.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(q,W){this._writeBuffer.write(q,W)}writeSync(q,W){this._logService.logLevel<=p.LogLevelEnum.WARN&&!L&&(this._logService.warn("writeSync is unreliable and will be removed soon."),L=!0),this._writeBuffer.writeSync(q,W)}input(q,W=!0){this.coreService.triggerDataEvent(q,W)}resize(q,W){isNaN(q)||isNaN(W)||(q=Math.max(q,y.MINIMUM_COLS),W=Math.max(W,y.MINIMUM_ROWS),this._bufferService.resize(q,W))}scroll(q,W=!1){this._bufferService.scroll(q,W)}scrollLines(q,W,M){this._bufferService.scrollLines(q,W,M)}scrollPages(q){this.scrollLines(q*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(q){const W=q-this._bufferService.buffer.ydisp;W!==0&&this.scrollLines(W)}registerEscHandler(q,W){return this._inputHandler.registerEscHandler(q,W)}registerDcsHandler(q,W){return this._inputHandler.registerDcsHandler(q,W)}registerCsiHandler(q,W){return this._inputHandler.registerCsiHandler(q,W)}registerOscHandler(q,W){return this._inputHandler.registerOscHandler(q,W)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let q=!1;const W=this.optionsService.rawOptions.windowsPty;W&&W.buildNumber!==void 0&&W.buildNumber!==void 0?q=W.backend==="conpty"&&W.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(q=!0),q?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const q=[];q.push(this.onLineFeed(j.updateWindowsModeWrappedState.bind(null,this._bufferService))),q.push(this.registerCsiHandler({final:"H"},(()=>((0,j.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,f.toDisposable)((()=>{for(const W of q)W.dispose()}))}}}c.CoreTerminal=O},8460:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.runAndSubscribe=c.forwardEvent=c.EventEmitter=void 0,c.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=d=>(this._listeners.push(d),{dispose:()=>{if(!this._disposed){for(let f=0;f<this._listeners.length;f++)if(this._listeners[f]===d)return void this._listeners.splice(f,1)}}})),this._event}fire(d,f){const p=[];for(let m=0;m<this._listeners.length;m++)p.push(this._listeners[m]);for(let m=0;m<p.length;m++)p[m].call(void 0,d,f)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(d,f){return d((p=>f.fire(p)))},c.runAndSubscribe=function(d,f){return f(void 0),d((p=>f(p)))}},5435:function(u,c,d){var f=this&&this.__decorate||function(X,z,R,I){var G,B=arguments.length,ee=B<3?z:I===null?I=Object.getOwnPropertyDescriptor(z,R):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ee=Reflect.decorate(X,z,R,I);else for(var J=X.length-1;J>=0;J--)(G=X[J])&&(ee=(B<3?G(ee):B>3?G(z,R,ee):G(z,R))||ee);return B>3&&ee&&Object.defineProperty(z,R,ee),ee},p=this&&this.__param||function(X,z){return function(R,I){z(R,I,X)}};Object.defineProperty(c,"__esModule",{value:!0}),c.InputHandler=c.WindowsOptionsReportType=void 0;const m=d(2584),x=d(7116),y=d(2015),w=d(844),C=d(482),v=d(8437),S=d(8460),b=d(643),_=d(511),j=d(3734),E=d(2585),T=d(1480),D=d(6242),L=d(6351),O=d(5941),P={"(":0,")":1,"*":2,"+":3,"-":1,".":2},q=131072;function W(X,z){if(X>24)return z.setWinLines||!1;switch(X){case 1:return!!z.restoreWin;case 2:return!!z.minimizeWin;case 3:return!!z.setWinPosition;case 4:return!!z.setWinSizePixels;case 5:return!!z.raiseWin;case 6:return!!z.lowerWin;case 7:return!!z.refreshWin;case 8:return!!z.setWinSizeChars;case 9:return!!z.maximizeWin;case 10:return!!z.fullscreenWin;case 11:return!!z.getWinState;case 13:return!!z.getWinPosition;case 14:return!!z.getWinSizePixels;case 15:return!!z.getScreenSizePixels;case 16:return!!z.getCellSizePixels;case 18:return!!z.getWinSizeChars;case 19:return!!z.getScreenSizeChars;case 20:return!!z.getIconTitle;case 21:return!!z.getWinTitle;case 22:return!!z.pushTitle;case 23:return!!z.popTitle;case 24:return!!z.setWinLines}return!1}var M;(function(X){X[X.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",X[X.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(c.WindowsOptionsReportType=M={}));let H=0;class V extends w.Disposable{getAttrData(){return this._curAttrData}constructor(z,R,I,G,B,ee,J,ne,K=new y.EscapeSequenceParser){super(),this._bufferService=z,this._charsetService=R,this._coreService=I,this._logService=G,this._optionsService=B,this._oscLinkService=ee,this._coreMouseService=J,this._unicodeService=ne,this._parser=K,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new _.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 U(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((F=>this._activeBuffer=F.activeBuffer))),this._parser.setCsiHandlerFallback(((F,te)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(F),params:te.toArray()})})),this._parser.setEscHandlerFallback((F=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(F)})})),this._parser.setExecuteHandlerFallback((F=>{this._logService.debug("Unknown EXECUTE code: ",{code:F})})),this._parser.setOscHandlerFallback(((F,te,re)=>{this._logService.debug("Unknown OSC code: ",{identifier:F,action:te,data:re})})),this._parser.setDcsHandlerFallback(((F,te,re)=>{te==="HOOK"&&(re=re.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(F),action:te,payload:re})})),this._parser.setPrintHandler(((F,te,re)=>this.print(F,te,re))),this._parser.registerCsiHandler({final:"@"},(F=>this.insertChars(F))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(F=>this.scrollLeft(F))),this._parser.registerCsiHandler({final:"A"},(F=>this.cursorUp(F))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(F=>this.scrollRight(F))),this._parser.registerCsiHandler({final:"B"},(F=>this.cursorDown(F))),this._parser.registerCsiHandler({final:"C"},(F=>this.cursorForward(F))),this._parser.registerCsiHandler({final:"D"},(F=>this.cursorBackward(F))),this._parser.registerCsiHandler({final:"E"},(F=>this.cursorNextLine(F))),this._parser.registerCsiHandler({final:"F"},(F=>this.cursorPrecedingLine(F))),this._parser.registerCsiHandler({final:"G"},(F=>this.cursorCharAbsolute(F))),this._parser.registerCsiHandler({final:"H"},(F=>this.cursorPosition(F))),this._parser.registerCsiHandler({final:"I"},(F=>this.cursorForwardTab(F))),this._parser.registerCsiHandler({final:"J"},(F=>this.eraseInDisplay(F,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(F=>this.eraseInDisplay(F,!0))),this._parser.registerCsiHandler({final:"K"},(F=>this.eraseInLine(F,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(F=>this.eraseInLine(F,!0))),this._parser.registerCsiHandler({final:"L"},(F=>this.insertLines(F))),this._parser.registerCsiHandler({final:"M"},(F=>this.deleteLines(F))),this._parser.registerCsiHandler({final:"P"},(F=>this.deleteChars(F))),this._parser.registerCsiHandler({final:"S"},(F=>this.scrollUp(F))),this._parser.registerCsiHandler({final:"T"},(F=>this.scrollDown(F))),this._parser.registerCsiHandler({final:"X"},(F=>this.eraseChars(F))),this._parser.registerCsiHandler({final:"Z"},(F=>this.cursorBackwardTab(F))),this._parser.registerCsiHandler({final:"`"},(F=>this.charPosAbsolute(F))),this._parser.registerCsiHandler({final:"a"},(F=>this.hPositionRelative(F))),this._parser.registerCsiHandler({final:"b"},(F=>this.repeatPrecedingCharacter(F))),this._parser.registerCsiHandler({final:"c"},(F=>this.sendDeviceAttributesPrimary(F))),this._parser.registerCsiHandler({prefix:">",final:"c"},(F=>this.sendDeviceAttributesSecondary(F))),this._parser.registerCsiHandler({final:"d"},(F=>this.linePosAbsolute(F))),this._parser.registerCsiHandler({final:"e"},(F=>this.vPositionRelative(F))),this._parser.registerCsiHandler({final:"f"},(F=>this.hVPosition(F))),this._parser.registerCsiHandler({final:"g"},(F=>this.tabClear(F))),this._parser.registerCsiHandler({final:"h"},(F=>this.setMode(F))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(F=>this.setModePrivate(F))),this._parser.registerCsiHandler({final:"l"},(F=>this.resetMode(F))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(F=>this.resetModePrivate(F))),this._parser.registerCsiHandler({final:"m"},(F=>this.charAttributes(F))),this._parser.registerCsiHandler({final:"n"},(F=>this.deviceStatus(F))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(F=>this.deviceStatusPrivate(F))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(F=>this.softReset(F))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(F=>this.setCursorStyle(F))),this._parser.registerCsiHandler({final:"r"},(F=>this.setScrollRegion(F))),this._parser.registerCsiHandler({final:"s"},(F=>this.saveCursor(F))),this._parser.registerCsiHandler({final:"t"},(F=>this.windowOptions(F))),this._parser.registerCsiHandler({final:"u"},(F=>this.restoreCursor(F))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(F=>this.insertColumns(F))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(F=>this.deleteColumns(F))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(F=>this.selectProtected(F))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(F=>this.requestMode(F,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(F=>this.requestMode(F,!1))),this._parser.setExecuteHandler(m.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(m.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(m.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(m.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(m.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(m.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(m.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(m.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(m.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new D.OscHandler((F=>(this.setTitle(F),this.setIconName(F),!0)))),this._parser.registerOscHandler(1,new D.OscHandler((F=>this.setIconName(F)))),this._parser.registerOscHandler(2,new D.OscHandler((F=>this.setTitle(F)))),this._parser.registerOscHandler(4,new D.OscHandler((F=>this.setOrReportIndexedColor(F)))),this._parser.registerOscHandler(8,new D.OscHandler((F=>this.setHyperlink(F)))),this._parser.registerOscHandler(10,new D.OscHandler((F=>this.setOrReportFgColor(F)))),this._parser.registerOscHandler(11,new D.OscHandler((F=>this.setOrReportBgColor(F)))),this._parser.registerOscHandler(12,new D.OscHandler((F=>this.setOrReportCursorColor(F)))),this._parser.registerOscHandler(104,new D.OscHandler((F=>this.restoreIndexedColor(F)))),this._parser.registerOscHandler(110,new D.OscHandler((F=>this.restoreFgColor(F)))),this._parser.registerOscHandler(111,new D.OscHandler((F=>this.restoreBgColor(F)))),this._parser.registerOscHandler(112,new D.OscHandler((F=>this.restoreCursorColor(F)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const F in x.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:F},(()=>this.selectCharset("("+F))),this._parser.registerEscHandler({intermediates:")",final:F},(()=>this.selectCharset(")"+F))),this._parser.registerEscHandler({intermediates:"*",final:F},(()=>this.selectCharset("*"+F))),this._parser.registerEscHandler({intermediates:"+",final:F},(()=>this.selectCharset("+"+F))),this._parser.registerEscHandler({intermediates:"-",final:F},(()=>this.selectCharset("-"+F))),this._parser.registerEscHandler({intermediates:".",final:F},(()=>this.selectCharset("."+F))),this._parser.registerEscHandler({intermediates:"/",final:F},(()=>this.selectCharset("/"+F)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((F=>(this._logService.error("Parsing error: ",F),F))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new L.DcsHandler(((F,te)=>this.requestStatusString(F,te))))}_preserveStack(z,R,I,G){this._parseStack.paused=!0,this._parseStack.cursorStartX=z,this._parseStack.cursorStartY=R,this._parseStack.decodedLength=I,this._parseStack.position=G}_logSlowResolvingAsync(z){this._logService.logLevel<=E.LogLevelEnum.WARN&&Promise.race([z,new Promise(((R,I)=>setTimeout((()=>I("#SLOW_TIMEOUT")),5e3)))]).catch((R=>{if(R!=="#SLOW_TIMEOUT")throw R;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(z,R){let I,G=this._activeBuffer.x,B=this._activeBuffer.y,ee=0;const J=this._parseStack.paused;if(J){if(I=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,R))return this._logSlowResolvingAsync(I),I;G=this._parseStack.cursorStartX,B=this._parseStack.cursorStartY,this._parseStack.paused=!1,z.length>q&&(ee=this._parseStack.position+q)}if(this._logService.logLevel<=E.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof z=="string"?` "${z}"`:` "${Array.prototype.map.call(z,(F=>String.fromCharCode(F))).join("")}"`),typeof z=="string"?z.split("").map((F=>F.charCodeAt(0))):z),this._parseBuffer.length<z.length&&this._parseBuffer.length<q&&(this._parseBuffer=new Uint32Array(Math.min(z.length,q))),J||this._dirtyRowTracker.clearRange(),z.length>q)for(let F=ee;F<z.length;F+=q){const te=F+q<z.length?F+q:z.length,re=typeof z=="string"?this._stringDecoder.decode(z.substring(F,te),this._parseBuffer):this._utf8Decoder.decode(z.subarray(F,te),this._parseBuffer);if(I=this._parser.parse(this._parseBuffer,re))return this._preserveStack(G,B,re,F),this._logSlowResolvingAsync(I),I}else if(!J){const F=typeof z=="string"?this._stringDecoder.decode(z,this._parseBuffer):this._utf8Decoder.decode(z,this._parseBuffer);if(I=this._parser.parse(this._parseBuffer,F))return this._preserveStack(G,B,F,0),this._logSlowResolvingAsync(I),I}this._activeBuffer.x===G&&this._activeBuffer.y===B||this._onCursorMove.fire();const ne=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),K=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);K<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(K,this._bufferService.rows-1),Math.min(ne,this._bufferService.rows-1))}print(z,R,I){let G,B;const ee=this._charsetService.charset,J=this._optionsService.rawOptions.screenReaderMode,ne=this._bufferService.cols,K=this._coreService.decPrivateModes.wraparound,F=this._coreService.modes.insertMode,te=this._curAttrData;let re=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&I-R>0&&re.getWidth(this._activeBuffer.x-1)===2&&re.setCellFromCodepoint(this._activeBuffer.x-1,0,1,te);let pe=this._parser.precedingJoinState;for(let be=R;be<I;++be){if(G=z[be],G<127&&ee){const je=ee[String.fromCharCode(G)];je&&(G=je.charCodeAt(0))}const Pe=this._unicodeService.charProperties(G,pe);B=T.UnicodeService.extractWidth(Pe);const $e=T.UnicodeService.extractShouldJoin(Pe),Ne=$e?T.UnicodeService.extractWidth(pe):0;if(pe=Pe,J&&this._onA11yChar.fire((0,C.stringFromCodePoint)(G)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+B-Ne>ne){if(K){const je=re;let oe=this._activeBuffer.x-Ne;for(this._activeBuffer.x=Ne,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),re=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Ne>0&&re instanceof v.BufferLine&&re.copyCellsFrom(je,oe,0,Ne,!1);oe<ne;)je.setCellFromCodepoint(oe++,0,1,te)}else if(this._activeBuffer.x=ne-1,B===2)continue}if($e&&this._activeBuffer.x){const je=re.getWidth(this._activeBuffer.x-1)?1:2;re.addCodepointToCell(this._activeBuffer.x-je,G,B);for(let oe=B-Ne;--oe>=0;)re.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}else if(F&&(re.insertCells(this._activeBuffer.x,B-Ne,this._activeBuffer.getNullCell(te)),re.getWidth(ne-1)===2&&re.setCellFromCodepoint(ne-1,b.NULL_CELL_CODE,b.NULL_CELL_WIDTH,te)),re.setCellFromCodepoint(this._activeBuffer.x++,G,B,te),B>0)for(;--B;)re.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}this._parser.precedingJoinState=pe,this._activeBuffer.x<ne&&I-R>0&&re.getWidth(this._activeBuffer.x)===0&&!re.hasContent(this._activeBuffer.x)&&re.setCellFromCodepoint(this._activeBuffer.x,0,1,te),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(z,R){return z.final!=="t"||z.prefix||z.intermediates?this._parser.registerCsiHandler(z,R):this._parser.registerCsiHandler(z,(I=>!W(I.params[0],this._optionsService.rawOptions.windowOptions)||R(I)))}registerDcsHandler(z,R){return this._parser.registerDcsHandler(z,new L.DcsHandler(R))}registerEscHandler(z,R){return this._parser.registerEscHandler(z,R)}registerOscHandler(z,R){return this._parser.registerOscHandler(z,new D.OscHandler(R))}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 z;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&&((z=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&z.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);R.hasWidth(this._activeBuffer.x)&&!R.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const z=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-z),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(z=this._bufferService.cols-1){this._activeBuffer.x=Math.min(z,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(z,R){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=z,this._activeBuffer.y=this._activeBuffer.scrollTop+R):(this._activeBuffer.x=z,this._activeBuffer.y=R),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(z,R){this._restrictCursor(),this._setCursor(this._activeBuffer.x+z,this._activeBuffer.y+R)}cursorUp(z){const R=this._activeBuffer.y-this._activeBuffer.scrollTop;return R>=0?this._moveCursor(0,-Math.min(R,z.params[0]||1)):this._moveCursor(0,-(z.params[0]||1)),!0}cursorDown(z){const R=this._activeBuffer.scrollBottom-this._activeBuffer.y;return R>=0?this._moveCursor(0,Math.min(R,z.params[0]||1)):this._moveCursor(0,z.params[0]||1),!0}cursorForward(z){return this._moveCursor(z.params[0]||1,0),!0}cursorBackward(z){return this._moveCursor(-(z.params[0]||1),0),!0}cursorNextLine(z){return this.cursorDown(z),this._activeBuffer.x=0,!0}cursorPrecedingLine(z){return this.cursorUp(z),this._activeBuffer.x=0,!0}cursorCharAbsolute(z){return this._setCursor((z.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(z){return this._setCursor(z.length>=2?(z.params[1]||1)-1:0,(z.params[0]||1)-1),!0}charPosAbsolute(z){return this._setCursor((z.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(z){return this._moveCursor(z.params[0]||1,0),!0}linePosAbsolute(z){return this._setCursor(this._activeBuffer.x,(z.params[0]||1)-1),!0}vPositionRelative(z){return this._moveCursor(0,z.params[0]||1),!0}hVPosition(z){return this.cursorPosition(z),!0}tabClear(z){const R=z.params[0];return R===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:R===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(z){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let R=z.params[0]||1;for(;R--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(z){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let R=z.params[0]||1;for(;R--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(z){const R=z.params[0];return R===1&&(this._curAttrData.bg|=536870912),R!==2&&R!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(z,R,I,G=!1,B=!1){const ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);ee.replaceCells(R,I,this._activeBuffer.getNullCell(this._eraseAttrData()),B),G&&(ee.isWrapped=!1)}_resetBufferLine(z,R=!1){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);I&&(I.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),R),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+z),I.isWrapped=!1)}eraseInDisplay(z,R=!1){let I;switch(this._restrictCursor(this._bufferService.cols),z.params[0]){case 0:for(I=this._activeBuffer.y,this._dirtyRowTracker.markDirty(I),this._eraseInBufferLine(I++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,R);I<this._bufferService.rows;I++)this._resetBufferLine(I,R);this._dirtyRowTracker.markDirty(I);break;case 1:for(I=this._activeBuffer.y,this._dirtyRowTracker.markDirty(I),this._eraseInBufferLine(I,0,this._activeBuffer.x+1,!0,R),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(I+1).isWrapped=!1);I--;)this._resetBufferLine(I,R);this._dirtyRowTracker.markDirty(0);break;case 2:for(I=this._bufferService.rows,this._dirtyRowTracker.markDirty(I-1);I--;)this._resetBufferLine(I,R);this._dirtyRowTracker.markDirty(0);break;case 3:const G=this._activeBuffer.lines.length-this._bufferService.rows;G>0&&(this._activeBuffer.lines.trimStart(G),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-G,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-G,0),this._onScroll.fire(0))}return!0}eraseInLine(z,R=!1){switch(this._restrictCursor(this._bufferService.cols),z.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,R);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,R);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,R)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(z){this._restrictCursor();let R=z.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=this._activeBuffer.ybase+this._activeBuffer.y,G=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-G+1;for(;R--;)this._activeBuffer.lines.splice(B-1,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(z){this._restrictCursor();let R=z.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=this._activeBuffer.ybase+this._activeBuffer.y;let G;for(G=this._bufferService.rows-1-this._activeBuffer.scrollBottom,G=this._bufferService.rows-1+this._activeBuffer.ybase-G;R--;)this._activeBuffer.lines.splice(I,1),this._activeBuffer.lines.splice(G,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(z){this._restrictCursor();const R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return R&&(R.insertCells(this._activeBuffer.x,z.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(z){this._restrictCursor();const R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return R&&(R.deleteCells(this._activeBuffer.x,z.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(z){let R=z.params[0]||1;for(;R--;)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(z){let R=z.params[0]||1;for(;R--;)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(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=z.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const G=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);G.deleteCells(0,R,this._activeBuffer.getNullCell(this._eraseAttrData())),G.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=z.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const G=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);G.insertCells(0,R,this._activeBuffer.getNullCell(this._eraseAttrData())),G.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=z.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const G=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);G.insertCells(this._activeBuffer.x,R,this._activeBuffer.getNullCell(this._eraseAttrData())),G.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=z.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const G=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);G.deleteCells(this._activeBuffer.x,R,this._activeBuffer.getNullCell(this._eraseAttrData())),G.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(z){this._restrictCursor();const R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return R&&(R.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(z.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(z){const R=this._parser.precedingJoinState;if(!R)return!0;const I=z.params[0]||1,G=T.UnicodeService.extractWidth(R),B=this._activeBuffer.x-G,ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(B),J=new Uint32Array(ee.length*I);let ne=0;for(let F=0;F<ee.length;){const te=ee.codePointAt(F)||0;J[ne++]=te,F+=te>65535?2:1}let K=ne;for(let F=1;F<I;++F)J.copyWithin(K,0,ne),K+=ne;return this.print(J,0,K),!0}sendDeviceAttributesPrimary(z){return z.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(m.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(m.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(z){return z.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(m.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(m.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(z.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is(z){return(this._optionsService.rawOptions.termName+"").indexOf(z)===0}setMode(z){for(let R=0;R<z.length;R++)switch(z.params[R]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(z){for(let R=0;R<z.length;R++)switch(z.params[R]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,x.DEFAULT_CHARSET),this._charsetService.setgCharset(1,x.DEFAULT_CHARSET),this._charsetService.setgCharset(2,x.DEFAULT_CHARSET),this._charsetService.setgCharset(3,x.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(z){for(let R=0;R<z.length;R++)switch(z.params[R]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(z){for(let R=0;R<z.length;R++)switch(z.params[R]){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(),z.params[R]===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(z,R){const I=this._coreService.decPrivateModes,{activeProtocol:G,activeEncoding:B}=this._coreMouseService,ee=this._coreService,{buffers:J,cols:ne}=this._bufferService,{active:K,alt:F}=J,te=this._optionsService.rawOptions,re=$e=>$e?1:2,pe=z.params[0];return be=pe,Pe=R?pe===2?4:pe===4?re(ee.modes.insertMode):pe===12?3:pe===20?re(te.convertEol):0:pe===1?re(I.applicationCursorKeys):pe===3?te.windowOptions.setWinLines?ne===80?2:ne===132?1:0:0:pe===6?re(I.origin):pe===7?re(I.wraparound):pe===8?3:pe===9?re(G==="X10"):pe===12?re(te.cursorBlink):pe===25?re(!ee.isCursorHidden):pe===45?re(I.reverseWraparound):pe===66?re(I.applicationKeypad):pe===67?4:pe===1e3?re(G==="VT200"):pe===1002?re(G==="DRAG"):pe===1003?re(G==="ANY"):pe===1004?re(I.sendFocus):pe===1005?4:pe===1006?re(B==="SGR"):pe===1015?4:pe===1016?re(B==="SGR_PIXELS"):pe===1048?1:pe===47||pe===1047||pe===1049?re(K===F):pe===2004?re(I.bracketedPasteMode):0,ee.triggerDataEvent(`${m.C0.ESC}[${R?"":"?"}${be};${Pe}$y`),!0;var be,Pe}_updateAttrColor(z,R,I,G,B){return R===2?(z|=50331648,z&=-16777216,z|=j.AttributeData.fromColorRGB([I,G,B])):R===5&&(z&=-50331904,z|=33554432|255&I),z}_extractColor(z,R,I){const G=[0,0,-1,0,0,0];let B=0,ee=0;do{if(G[ee+B]=z.params[R+ee],z.hasSubParams(R+ee)){const J=z.getSubParams(R+ee);let ne=0;do G[1]===5&&(B=1),G[ee+ne+1+B]=J[ne];while(++ne<J.length&&ne+ee+1+B<G.length);break}if(G[1]===5&&ee+B>=2||G[1]===2&&ee+B>=5)break;G[1]&&(B=1)}while(++ee+R<z.length&&ee+B<G.length);for(let J=2;J<G.length;++J)G[J]===-1&&(G[J]=0);switch(G[0]){case 38:I.fg=this._updateAttrColor(I.fg,G[1],G[3],G[4],G[5]);break;case 48:I.bg=this._updateAttrColor(I.bg,G[1],G[3],G[4],G[5]);break;case 58:I.extended=I.extended.clone(),I.extended.underlineColor=this._updateAttrColor(I.extended.underlineColor,G[1],G[3],G[4],G[5])}return ee}_processUnderline(z,R){R.extended=R.extended.clone(),(!~z||z>5)&&(z=1),R.extended.underlineStyle=z,R.fg|=268435456,z===0&&(R.fg&=-268435457),R.updateExtended()}_processSGR0(z){z.fg=v.DEFAULT_ATTR_DATA.fg,z.bg=v.DEFAULT_ATTR_DATA.bg,z.extended=z.extended.clone(),z.extended.underlineStyle=0,z.extended.underlineColor&=-67108864,z.updateExtended()}charAttributes(z){if(z.length===1&&z.params[0]===0)return this._processSGR0(this._curAttrData),!0;const R=z.length;let I;const G=this._curAttrData;for(let B=0;B<R;B++)I=z.params[B],I>=30&&I<=37?(G.fg&=-50331904,G.fg|=16777216|I-30):I>=40&&I<=47?(G.bg&=-50331904,G.bg|=16777216|I-40):I>=90&&I<=97?(G.fg&=-50331904,G.fg|=16777224|I-90):I>=100&&I<=107?(G.bg&=-50331904,G.bg|=16777224|I-100):I===0?this._processSGR0(G):I===1?G.fg|=134217728:I===3?G.bg|=67108864:I===4?(G.fg|=268435456,this._processUnderline(z.hasSubParams(B)?z.getSubParams(B)[0]:1,G)):I===5?G.fg|=536870912:I===7?G.fg|=67108864:I===8?G.fg|=1073741824:I===9?G.fg|=2147483648:I===2?G.bg|=134217728:I===21?this._processUnderline(2,G):I===22?(G.fg&=-134217729,G.bg&=-134217729):I===23?G.bg&=-67108865:I===24?(G.fg&=-268435457,this._processUnderline(0,G)):I===25?G.fg&=-536870913:I===27?G.fg&=-67108865:I===28?G.fg&=-1073741825:I===29?G.fg&=2147483647:I===39?(G.fg&=-67108864,G.fg|=16777215&v.DEFAULT_ATTR_DATA.fg):I===49?(G.bg&=-67108864,G.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):I===38||I===48||I===58?B+=this._extractColor(z,B,G):I===53?G.bg|=1073741824:I===55?G.bg&=-1073741825:I===59?(G.extended=G.extended.clone(),G.extended.underlineColor=-1,G.updateExtended()):I===100?(G.fg&=-67108864,G.fg|=16777215&v.DEFAULT_ATTR_DATA.fg,G.bg&=-67108864,G.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",I);return!0}deviceStatus(z){switch(z.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const R=this._activeBuffer.y+1,I=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${R};${I}R`)}return!0}deviceStatusPrivate(z){if(z.params[0]===6){const R=this._activeBuffer.y+1,I=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${R};${I}R`)}return!0}softReset(z){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(z){const R=z.params[0]||1;switch(R){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const I=R%2==1;return this._optionsService.options.cursorBlink=I,!0}setScrollRegion(z){const R=z.params[0]||1;let I;return(z.length<2||(I=z.params[1])>this._bufferService.rows||I===0)&&(I=this._bufferService.rows),I>R&&(this._activeBuffer.scrollTop=R-1,this._activeBuffer.scrollBottom=I-1,this._setCursor(0,0)),!0}windowOptions(z){if(!W(z.params[0],this._optionsService.rawOptions.windowOptions))return!0;const R=z.length>1?z.params[1]:0;switch(z.params[0]){case 14:R!==2&&this._onRequestWindowsOptionsReport.fire(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:R!==0&&R!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),R!==0&&R!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:R!==0&&R!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),R!==0&&R!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(z){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(z){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(z){return this._windowTitle=z,this._onTitleChange.fire(z),!0}setIconName(z){return this._iconName=z,!0}setOrReportIndexedColor(z){const R=[],I=z.split(";");for(;I.length>1;){const G=I.shift(),B=I.shift();if(/^\d+$/.exec(G)){const ee=parseInt(G);if(Q(ee))if(B==="?")R.push({type:0,index:ee});else{const J=(0,O.parseColor)(B);J&&R.push({type:1,index:ee,color:J})}}}return R.length&&this._onColor.fire(R),!0}setHyperlink(z){const R=z.split(";");return!(R.length<2)&&(R[1]?this._createHyperlink(R[0],R[1]):!R[0]&&this._finishHyperlink())}_createHyperlink(z,R){this._getCurrentLinkId()&&this._finishHyperlink();const I=z.split(":");let G;const B=I.findIndex((ee=>ee.startsWith("id=")));return B!==-1&&(G=I[B].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:G,uri:R}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(z,R){const I=z.split(";");for(let G=0;G<I.length&&!(R>=this._specialColors.length);++G,++R)if(I[G]==="?")this._onColor.fire([{type:0,index:this._specialColors[R]}]);else{const B=(0,O.parseColor)(I[G]);B&&this._onColor.fire([{type:1,index:this._specialColors[R],color:B}])}return!0}setOrReportFgColor(z){return this._setOrReportSpecialColor(z,0)}setOrReportBgColor(z){return this._setOrReportSpecialColor(z,1)}setOrReportCursorColor(z){return this._setOrReportSpecialColor(z,2)}restoreIndexedColor(z){if(!z)return this._onColor.fire([{type:2}]),!0;const R=[],I=z.split(";");for(let G=0;G<I.length;++G)if(/^\d+$/.exec(I[G])){const B=parseInt(I[G]);Q(B)&&R.push({type:2,index:B})}return R.length&&this._onColor.fire(R),!0}restoreFgColor(z){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(z){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(z){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,x.DEFAULT_CHARSET),!0}selectCharset(z){return z.length!==2?(this.selectDefaultCharset(),!0):(z[0]==="/"||this._charsetService.setgCharset(P[z[0]],x.CHARSETS[z[1]]||x.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const z=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,z,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(z){return this._charsetService.setgLevel(z),!0}screenAlignmentPattern(){const z=new _.CellData;z.content=4194373,z.fg=this._curAttrData.fg,z.bg=this._curAttrData.bg,this._setCursor(0,0);for(let R=0;R<this._bufferService.rows;++R){const I=this._activeBuffer.ybase+this._activeBuffer.y+R,G=this._activeBuffer.lines.get(I);G&&(G.fill(z),G.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(z,R){const I=this._bufferService.buffer,G=this._optionsService.rawOptions;return(B=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${B}${m.C0.ESC}\\`),!0))(z==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:z==='"p'?'P1$r61;1"p':z==="r"?`P1$r${I.scrollTop+1};${I.scrollBottom+1}r`:z==="m"?"P1$r0m":z===" q"?`P1$r${{block:2,underline:4,bar:6}[G.cursorStyle]-(G.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(z,R){this._dirtyRowTracker.markRangeDirty(z,R)}}c.InputHandler=V;let U=class{constructor(X){this._bufferService=X,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(X){X<this.start?this.start=X:X>this.end&&(this.end=X)}markRangeDirty(X,z){X>z&&(H=X,X=z,z=H),X<this.start&&(this.start=X),z>this.end&&(this.end=z)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Q(X){return 0<=X&&X<256}U=f([p(0,E.IBufferService)],U)},844:(u,c)=>{function d(f){for(const p of f)p.dispose();f.length=0}Object.defineProperty(c,"__esModule",{value:!0}),c.getDisposeArrayDisposable=c.disposeArray=c.toDisposable=c.MutableDisposable=c.Disposable=void 0,c.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const f of this._disposables)f.dispose();this._disposables.length=0}register(f){return this._disposables.push(f),f}unregister(f){const p=this._disposables.indexOf(f);p!==-1&&this._disposables.splice(p,1)}},c.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(f){var p;this._isDisposed||f===this._value||((p=this._value)==null||p.dispose(),this._value=f)}clear(){this.value=void 0}dispose(){var f;this._isDisposed=!0,(f=this._value)==null||f.dispose(),this._value=void 0}},c.toDisposable=function(f){return{dispose:f}},c.disposeArray=d,c.getDisposeArrayDisposable=function(f){return{dispose:()=>d(f)}}},1505:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.FourKeyMap=c.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(p,m,x){this._data[p]||(this._data[p]={}),this._data[p][m]=x}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}c.TwoKeyMap=d,c.FourKeyMap=class{constructor(){this._data=new d}set(f,p,m,x,y){this._data.get(f,p)||this._data.set(f,p,new d),this._data.get(f,p).set(m,x,y)}get(f,p,m,x){var y;return(y=this._data.get(f,p))==null?void 0:y.get(m,x)}clear(){this._data.clear()}}},6114:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.isChromeOS=c.isLinux=c.isWindows=c.isIphone=c.isIpad=c.isMac=c.getSafariVersion=c.isSafari=c.isLegacyEdge=c.isFirefox=c.isNode=void 0,c.isNode=typeof process<"u"&&"title"in process;const d=c.isNode?"node":navigator.userAgent,f=c.isNode?"node":navigator.platform;c.isFirefox=d.includes("Firefox"),c.isLegacyEdge=d.includes("Edge"),c.isSafari=/^((?!chrome|android).)*safari/i.test(d),c.getSafariVersion=function(){if(!c.isSafari)return 0;const p=d.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},c.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(f),c.isIpad=f==="iPad",c.isIphone=f==="iPhone",c.isWindows=["Windows","Win16","Win32","WinCE"].includes(f),c.isLinux=f.indexOf("Linux")>=0,c.isChromeOS=/\bCrOS\b/.test(d)},6106:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SortedList=void 0;let d=0;c.SortedList=class{constructor(f){this._getKey=f,this._array=[]}clear(){this._array.length=0}insert(f){this._array.length!==0?(d=this._search(this._getKey(f)),this._array.splice(d,0,f)):this._array.push(f)}delete(f){if(this._array.length===0)return!1;const p=this._getKey(f);if(p===void 0||(d=this._search(p),d===-1)||this._getKey(this._array[d])!==p)return!1;do if(this._array[d]===f)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===p);return!1}*getKeyIterator(f){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===f)}forEachByKey(f,p){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do p(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===f)}values(){return[...this._array].values()}_search(f){let p=0,m=this._array.length-1;for(;m>=p;){let x=p+m>>1;const y=this._getKey(this._array[x]);if(y>f)m=x-1;else{if(!(y<f)){for(;x>0&&this._getKey(this._array[x-1])===f;)x--;return x}p=x+1}}return p}}},7226:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DebouncedIdleTask=c.IdleTaskQueue=c.PriorityTaskQueue=void 0;const f=d(6114);class p{constructor(){this._tasks=[],this._i=0}enqueue(y){this._tasks.push(y),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(y){this._idleCallback=void 0;let w=0,C=0,v=y.timeRemaining(),S=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),S=y.timeRemaining(),1.5*C>S)return 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 m extends p{_requestCallback(y){return setTimeout((()=>y(this._createDeadline(16))))}_cancelCallback(y){clearTimeout(y)}_createDeadline(y){const w=Date.now()+y;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}c.PriorityTaskQueue=m,c.IdleTaskQueue=!f.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(x){return requestIdleCallback(x)}_cancelCallback(x){cancelIdleCallback(x)}}:m,c.DebouncedIdleTask=class{constructor(){this._queue=new c.IdleTaskQueue}set(x){this._queue.clear(),this._queue.enqueue(x)}flush(){this._queue.flush()}}},9282:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.updateWindowsModeWrappedState=void 0;const f=d(643);c.updateWindowsModeWrappedState=function(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),x=m==null?void 0:m.get(p.cols-1),y=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);y&&x&&(y.isWrapped=x[f.CHAR_DATA_CODE_INDEX]!==f.NULL_CELL_CODE&&x[f.CHAR_DATA_CODE_INDEX]!==f.WHITESPACE_CELL_CODE)}},3734:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ExtendedAttrs=c.AttributeData=void 0;class d{constructor(){this.fg=0,this.bg=0,this.extended=new f}static toColorRGB(m){return[m>>>16&255,m>>>8&255,255&m]}static fromColorRGB(m){return(255&m[0])<<16|(255&m[1])<<8|255&m[2]}clone(){const m=new d;return m.fg=this.fg,m.bg=this.bg,m.extended=this.extended.clone(),m}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}c.AttributeData=d;class f{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(m){this._ext=m}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(m){this._ext&=-469762049,this._ext|=m<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(m){this._ext&=-67108864,this._ext|=67108863&m}get urlId(){return this._urlId}set urlId(m){this._urlId=m}get underlineVariantOffset(){const m=(3758096384&this._ext)>>29;return m<0?4294967288^m:m}set underlineVariantOffset(m){this._ext&=536870911,this._ext|=m<<29&3758096384}constructor(m=0,x=0){this._ext=0,this._urlId=0,this._ext=m,this._urlId=x}clone(){return new f(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}c.ExtendedAttrs=f},9092:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Buffer=c.MAX_BUFFER_SIZE=void 0;const f=d(6349),p=d(7226),m=d(3734),x=d(8437),y=d(4634),w=d(511),C=d(643),v=d(4863),S=d(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(b,_,j){this._hasScrollback=b,this._optionsService=_,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=x.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(b){return b?(this._nullCell.fg=b.fg,this._nullCell.bg=b.bg,this._nullCell.extended=b.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(b){return b?(this._whitespaceCell.fg=b.fg,this._whitespaceCell.bg=b.bg,this._whitespaceCell.extended=b.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(b,_){return new x.BufferLine(this._bufferService.cols,this.getNullCell(b),_)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const b=this.ybase+this.y-this.ydisp;return b>=0&&b<this._rows}_getCorrectBufferLength(b){if(!this._hasScrollback)return b;const _=b+this._optionsService.rawOptions.scrollback;return _>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:_}fillViewportRows(b){if(this.lines.length===0){b===void 0&&(b=x.DEFAULT_ATTR_DATA);let _=this._rows;for(;_--;)this.lines.push(this.getBlankLine(b))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(b,_){const j=this.getNullCell(x.DEFAULT_ATTR_DATA);let E=0;const T=this._getCorrectBufferLength(_);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<b)for(let L=0;L<this.lines.length;L++)E+=+this.lines.get(L).resize(b,j);let D=0;if(this._rows<_)for(let L=this._rows;L<_;L++)this.lines.length<_+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new x.BufferLine(b,j)):this.ybase>0&&this.lines.length<=this.ybase+this.y+D+1?(this.ybase--,D++,this.ydisp>0&&this.ydisp--):this.lines.push(new x.BufferLine(b,j)));else for(let L=this._rows;L>_;L--)this.lines.length>_+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(T<this.lines.maxLength){const L=this.lines.length-T;L>0&&(this.lines.trimStart(L),this.ybase=Math.max(this.ybase-L,0),this.ydisp=Math.max(this.ydisp-L,0),this.savedY=Math.max(this.savedY-L,0)),this.lines.maxLength=T}this.x=Math.min(this.x,b-1),this.y=Math.min(this.y,_-1),D&&(this.y+=D),this.savedX=Math.min(this.savedX,b-1),this.scrollTop=0}if(this.scrollBottom=_-1,this._isReflowEnabled&&(this._reflow(b,_),this._cols>b))for(let D=0;D<this.lines.length;D++)E+=+this.lines.get(D).resize(b,j);this._cols=b,this._rows=_,this._memoryCleanupQueue.clear(),E>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let b=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,b=!1);let _=0;for(;this._memoryCleanupPosition<this.lines.length;)if(_+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),_>100)return!0;return b}get _isReflowEnabled(){const b=this._optionsService.rawOptions.windowsPty;return b&&b.buildNumber?this._hasScrollback&&b.backend==="conpty"&&b.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(b,_){this._cols!==b&&(b>this._cols?this._reflowLarger(b,_):this._reflowSmaller(b,_))}_reflowLarger(b,_){const j=(0,y.reflowLargerGetLinesToRemove)(this.lines,this._cols,b,this.ybase+this.y,this.getNullCell(x.DEFAULT_ATTR_DATA));if(j.length>0){const E=(0,y.reflowLargerCreateNewLayout)(this.lines,j);(0,y.reflowLargerApplyNewLayout)(this.lines,E.layout),this._reflowLargerAdjustViewport(b,_,E.countRemoved)}}_reflowLargerAdjustViewport(b,_,j){const E=this.getNullCell(x.DEFAULT_ATTR_DATA);let T=j;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<_&&this.lines.push(new x.BufferLine(b,E))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-j,0)}_reflowSmaller(b,_){const j=this.getNullCell(x.DEFAULT_ATTR_DATA),E=[];let T=0;for(let D=this.lines.length-1;D>=0;D--){let L=this.lines.get(D);if(!L||!L.isWrapped&&L.getTrimmedLength()<=b)continue;const O=[L];for(;L.isWrapped&&D>0;)L=this.lines.get(--D),O.unshift(L);const P=this.ybase+this.y;if(P>=D&&P<D+O.length)continue;const q=O[O.length-1].getTrimmedLength(),W=(0,y.reflowSmallerGetNewLineLengths)(O,this._cols,b),M=W.length-O.length;let H;H=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+M):Math.max(0,this.lines.length-this.lines.maxLength+M);const V=[];for(let I=0;I<M;I++){const G=this.getBlankLine(x.DEFAULT_ATTR_DATA,!0);V.push(G)}V.length>0&&(E.push({start:D+O.length+T,newLines:V}),T+=V.length),O.push(...V);let U=W.length-1,Q=W[U];Q===0&&(U--,Q=W[U]);let X=O.length-M-1,z=q;for(;X>=0;){const I=Math.min(z,Q);if(O[U]===void 0)break;if(O[U].copyCellsFrom(O[X],z-I,Q-I,I,!0),Q-=I,Q===0&&(U--,Q=W[U]),z-=I,z===0){X--;const G=Math.max(X,0);z=(0,y.getWrappedLineTrimmedLength)(O,G,this._cols)}}for(let I=0;I<O.length;I++)W[I]<b&&O[I].setCell(W[I],j);let R=M-H;for(;R-- >0;)this.ybase===0?this.y<_-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-_&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+M,this.ybase+_-1)}if(E.length>0){const D=[],L=[];for(let U=0;U<this.lines.length;U++)L.push(this.lines.get(U));const O=this.lines.length;let P=O-1,q=0,W=E[q];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let M=0;for(let U=Math.min(this.lines.maxLength-1,O+T-1);U>=0;U--)if(W&&W.start>P+M){for(let Q=W.newLines.length-1;Q>=0;Q--)this.lines.set(U--,W.newLines[Q]);U++,D.push({index:P+1,amount:W.newLines.length}),M+=W.newLines.length,W=E[++q]}else this.lines.set(U,L[P--]);let H=0;for(let U=D.length-1;U>=0;U--)D[U].index+=H,this.lines.onInsertEmitter.fire(D[U]),H+=D[U].amount;const V=Math.max(0,O+T-this.lines.maxLength);V>0&&this.lines.onTrimEmitter.fire(V)}}translateBufferLineToString(b,_,j=0,E){const T=this.lines.get(b);return T?T.translateToString(_,j,E):""}getWrappedRangeForLine(b){let _=b,j=b;for(;_>0&&this.lines.get(_).isWrapped;)_--;for(;j+1<this.lines.length&&this.lines.get(j+1).isWrapped;)j++;return{first:_,last:j}}setupTabStops(b){for(b!=null?this.tabs[b]||(b=this.prevStop(b)):(this.tabs={},b=0);b<this._cols;b+=this._optionsService.rawOptions.tabStopWidth)this.tabs[b]=!0}prevStop(b){for(b==null&&(b=this.x);!this.tabs[--b]&&b>0;);return b>=this._cols?this._cols-1:b<0?0:b}nextStop(b){for(b==null&&(b=this.x);!this.tabs[++b]&&b<this._cols;);return b>=this._cols?this._cols-1:b<0?0:b}clearMarkers(b){this._isClearing=!0;for(let _=0;_<this.markers.length;_++)this.markers[_].line===b&&(this.markers[_].dispose(),this.markers.splice(_--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].dispose(),this.markers.splice(b--,1);this._isClearing=!1}addMarker(b){const _=new v.Marker(b);return this.markers.push(_),_.register(this.lines.onTrim((j=>{_.line-=j,_.line<0&&_.dispose()}))),_.register(this.lines.onInsert((j=>{_.line>=j.index&&(_.line+=j.amount)}))),_.register(this.lines.onDelete((j=>{_.line>=j.index&&_.line<j.index+j.amount&&_.dispose(),_.line>j.index&&(_.line-=j.amount)}))),_.register(_.onDispose((()=>this._removeMarker(_)))),_}_removeMarker(b){this._isClearing||this.markers.splice(this.markers.indexOf(b),1)}}},8437:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const f=d(3734),p=d(511),m=d(643),x=d(482);c.DEFAULT_ATTR_DATA=Object.freeze(new f.AttributeData);let y=0;class w{constructor(v,S,b=!1){this.isWrapped=b,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*v);const _=S||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let j=0;j<v;++j)this.setCell(j,_);this.length=v}get(v){const S=this._data[3*v+0],b=2097151&S;return[this._data[3*v+1],2097152&S?this._combined[v]:b?(0,x.stringFromCodePoint)(b):"",S>>22,2097152&S?this._combined[v].charCodeAt(this._combined[v].length-1):b]}set(v,S){this._data[3*v+1]=S[m.CHAR_DATA_ATTR_INDEX],S[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[v]=S[1],this._data[3*v+0]=2097152|v|S[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*v+0]=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.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,x.stringFromCodePoint)(2097151&S):""}isProtected(v){return 536870912&this._data[3*v+2]}loadCell(v,S){return y=3*v,S.content=this._data[y+0],S.fg=this._data[y+1],S.bg=this._data[y+2],2097152&S.content&&(S.combinedData=this._combined[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&_.bg&&(this._extendedAttrs[v]=_.extended),this._data[3*v+0]=S|b<<22,this._data[3*v+1]=_.fg,this._data[3*v+2]=_.bg}addCodepointToCell(v,S,b){let _=this._data[3*v+0];2097152&_?this._combined[v]+=(0,x.stringFromCodePoint)(S):2097151&_?(this._combined[v]=(0,x.stringFromCodePoint)(2097151&_)+(0,x.stringFromCodePoint)(S),_&=-2097152,_|=2097152):_=S|4194304,b&&(_&=-12582913,_|=b<<22),this._data[3*v+0]=_}insertCells(v,S,b){if((v%=this.length)&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,b),S<this.length-v){const _=new p.CellData;for(let j=this.length-v-S-1;j>=0;--j)this.setCell(v+S+j,this.loadCell(v+j,_));for(let j=0;j<S;++j)this.setCell(v+j,b)}else for(let _=v;_<this.length;++_)this.setCell(_,b);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,b)}deleteCells(v,S,b){if(v%=this.length,S<this.length-v){const _=new p.CellData;for(let j=0;j<this.length-v-S;++j)this.setCell(v+j,this.loadCell(v+S+j,_));for(let j=this.length-S;j<this.length;++j)this.setCell(j,b)}else for(let _=v;_<this.length;++_)this.setCell(_,b);v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,b),this.getWidth(v)!==0||this.hasContent(v)||this.setCellFromCodepoint(v,0,1,b)}replaceCells(v,S,b,_=!1){if(_)for(v&&this.getWidth(v-1)===2&&!this.isProtected(v-1)&&this.setCellFromCodepoint(v-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,b);v<S&&v<this.length;)this.isProtected(v)||this.setCell(v,b),v++;else for(v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,b);v<S&&v<this.length;)this.setCell(v++,b)}resize(v,S){if(v===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const b=3*v;if(v>this.length){if(this._data.buffer.byteLength>=4*b)this._data=new Uint32Array(this._data.buffer,0,b);else{const _=new Uint32Array(b);_.set(this._data),this._data=_}for(let _=this.length;_<v;++_)this.setCell(_,S)}else{this._data=this._data.subarray(0,b);const _=Object.keys(this._combined);for(let E=0;E<_.length;E++){const T=parseInt(_[E],10);T>=v&&delete this._combined[T]}const j=Object.keys(this._extendedAttrs);for(let E=0;E<j.length;E++){const T=parseInt(j[E],10);T>=v&&delete this._extendedAttrs[T]}}return this.length=v,4*b*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 b=0;b<this.length;++b)this.isProtected(b)||this.setCell(b,v);else{this._combined={},this._extendedAttrs={};for(let b=0;b<this.length;++b)this.setCell(b,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 D=_-1;D>=0;D--){for(let L=0;L<3;L++)this._data[3*(b+D)+L]=E[3*(S+D)+L];268435456&E[3*(S+D)+2]&&(this._extendedAttrs[b+D]=v._extendedAttrs[S+D])}else for(let D=0;D<_;D++){for(let L=0;L<3;L++)this._data[3*(b+D)+L]=E[3*(S+D)+L];268435456&E[3*(S+D)+2]&&(this._extendedAttrs[b+D]=v._extendedAttrs[S+D])}const T=Object.keys(v._combined);for(let D=0;D<T.length;D++){const L=parseInt(T[D],10);L>=S&&(this._combined[L-S+b]=v._combined[L])}}translateToString(v,S,b,_){S=S??0,b=b??this.length,v&&(b=Math.min(b,this.getTrimmedLength())),_&&(_.length=0);let j="";for(;S<b;){const E=this._data[3*S+0],T=2097151&E,D=2097152&E?this._combined[S]:T?(0,x.stringFromCodePoint)(T):m.WHITESPACE_CELL_CHAR;if(j+=D,_)for(let L=0;L<D.length;++L)_.push(S);S+=E>>22||1}return _&&_.push(S),j}}c.BufferLine=w},4841:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getRangeLength=void 0,c.getRangeLength=function(d,f){if(d.start.y>d.end.y)throw new Error(`Buffer range end (${d.end.x}, ${d.end.y}) cannot be before start (${d.start.x}, ${d.start.y})`);return f*(d.end.y-d.start.y)+(d.end.x-d.start.x+1)}},4634:(u,c)=>{function d(f,p,m){if(p===f.length-1)return f[p].getTrimmedLength();const x=!f[p].hasContent(m-1)&&f[p].getWidth(m-1)===1,y=f[p+1].getWidth(0)===2;return x&&y?m-1:m}Object.defineProperty(c,"__esModule",{value:!0}),c.getWrappedLineTrimmedLength=c.reflowSmallerGetNewLineLengths=c.reflowLargerApplyNewLayout=c.reflowLargerCreateNewLayout=c.reflowLargerGetLinesToRemove=void 0,c.reflowLargerGetLinesToRemove=function(f,p,m,x,y){const w=[];for(let C=0;C<f.length-1;C++){let v=C,S=f.get(++v);if(!S.isWrapped)continue;const b=[f.get(C)];for(;v<f.length&&S.isWrapped;)b.push(S),S=f.get(++v);if(x>=C&&x<v){C+=b.length-1;continue}let _=0,j=d(b,_,p),E=1,T=0;for(;E<b.length;){const L=d(b,E,p),O=L-T,P=m-j,q=Math.min(O,P);b[_].copyCellsFrom(b[E],T,j,q,!1),j+=q,j===m&&(_++,j=0),T+=q,T===L&&(E++,T=0),j===0&&_!==0&&b[_-1].getWidth(m-1)===2&&(b[_].copyCellsFrom(b[_-1],m-1,j++,1,!1),b[_-1].setCell(m-1,y))}b[_].replaceCells(j,m,y);let D=0;for(let L=b.length-1;L>0&&(L>_||b[L].getTrimmedLength()===0);L--)D++;D>0&&(w.push(C+b.length-D),w.push(D)),C+=b.length-1}return w},c.reflowLargerCreateNewLayout=function(f,p){const m=[];let x=0,y=p[x],w=0;for(let C=0;C<f.length;C++)if(y===C){const v=p[++x];f.onDeleteEmitter.fire({index:C-w,amount:v}),C+=v-1,w+=v,y=p[++x]}else m.push(C);return{layout:m,countRemoved:w}},c.reflowLargerApplyNewLayout=function(f,p){const m=[];for(let x=0;x<p.length;x++)m.push(f.get(p[x]));for(let x=0;x<m.length;x++)f.set(x,m[x]);f.length=p.length},c.reflowSmallerGetNewLineLengths=function(f,p,m){const x=[],y=f.map(((S,b)=>d(f,b,p))).reduce(((S,b)=>S+b));let w=0,C=0,v=0;for(;v<y;){if(y-v<m){x.push(y-v);break}w+=m;const S=d(f,C,p);w>S&&(w-=S,C++);const b=f[C].getWidth(w-1)===2;b&&w--;const _=b?m-1:m;x.push(_),v+=_}return x},c.getWrappedLineTrimmedLength=d},5295:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const f=d(8460),p=d(844),m=d(9092);class x extends p.Disposable{constructor(w,C){super(),this._optionsService=w,this._bufferService=C,this._onBufferActivate=this.register(new f.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new m.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new m.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}c.BufferSet=x},511:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CellData=void 0;const f=d(482),p=d(643),m=d(3734);class x extends m.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new m.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new x;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,f.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[p.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[p.CHAR_DATA_CHAR_INDEX].length===2){const v=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=v&&v<=56319){const S=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(v-55296)+S-56320+65536|w[p.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[p.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[p.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.CellData=x},643:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WHITESPACE_CELL_CODE=c.WHITESPACE_CELL_WIDTH=c.WHITESPACE_CELL_CHAR=c.NULL_CELL_CODE=c.NULL_CELL_WIDTH=c.NULL_CELL_CHAR=c.CHAR_DATA_CODE_INDEX=c.CHAR_DATA_WIDTH_INDEX=c.CHAR_DATA_CHAR_INDEX=c.CHAR_DATA_ATTR_INDEX=c.DEFAULT_EXT=c.DEFAULT_ATTR=c.DEFAULT_COLOR=void 0,c.DEFAULT_COLOR=0,c.DEFAULT_ATTR=256|c.DEFAULT_COLOR<<9,c.DEFAULT_EXT=0,c.CHAR_DATA_ATTR_INDEX=0,c.CHAR_DATA_CHAR_INDEX=1,c.CHAR_DATA_WIDTH_INDEX=2,c.CHAR_DATA_CODE_INDEX=3,c.NULL_CELL_CHAR="",c.NULL_CELL_WIDTH=1,c.NULL_CELL_CODE=0,c.WHITESPACE_CELL_CHAR=" ",c.WHITESPACE_CELL_WIDTH=1,c.WHITESPACE_CELL_CODE=32},4863:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Marker=void 0;const f=d(8460),p=d(844);class m{get id(){return this._id}constructor(y){this.line=y,this.isDisposed=!1,this._disposables=[],this._id=m._nextId++,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.disposeArray)(this._disposables),this._disposables.length=0)}register(y){return this._disposables.push(y),y}}c.Marker=m,m._nextId=1},7116:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DEFAULT_CHARSET=c.CHARSETS=void 0,c.CHARSETS={},c.DEFAULT_CHARSET=c.CHARSETS.B,c.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},c.CHARSETS.A={"#":"£"},c.CHARSETS.B=void 0,c.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},c.CHARSETS.C=c.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},c.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},c.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},c.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},c.CHARSETS.E=c.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},c.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},c.CHARSETS.H=c.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(u,c)=>{var d,f,p;Object.defineProperty(c,"__esModule",{value:!0}),c.C1_ESCAPED=c.C1=c.C0=void 0,(function(m){m.NUL="\0",m.SOH="",m.STX="",m.ETX="",m.EOT="",m.ENQ="",m.ACK="",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
|
|
67
|
+
`,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="",m.SI="",m.DLE="",m.DC1="",m.DC2="",m.DC3="",m.DC4="",m.NAK="",m.SYN="",m.ETB="",m.CAN="",m.EM="",m.SUB="",m.ESC="\x1B",m.FS="",m.GS="",m.RS="",m.US="",m.SP=" ",m.DEL=""})(d||(c.C0=d={})),(function(m){m.PAD="",m.HOP="",m.BPH="",m.NBH="",m.IND="",m.NEL="
",m.SSA="",m.ESA="",m.HTS="",m.HTJ="",m.VTS="",m.PLD="",m.PLU="",m.RI="",m.SS2="",m.SS3="",m.DCS="",m.PU1="",m.PU2="",m.STS="",m.CCH="",m.MW="",m.SPA="",m.EPA="",m.SOS="",m.SGCI="",m.SCI="",m.CSI="",m.ST="",m.OSC="",m.PM="",m.APC=""})(f||(c.C1=f={})),(function(m){m.ST=`${d.ESC}\\`})(p||(c.C1_ESCAPED=p={}))},7399:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.evaluateKeyboardEvent=void 0;const f=d(2584),p={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};c.evaluateKeyboardEvent=function(m,x,y,w){const C={type:0,cancel:!1,key:void 0},v=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?C.key=x?f.C0.ESC+"OA":f.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=x?f.C0.ESC+"OD":f.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=x?f.C0.ESC+"OC":f.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=x?f.C0.ESC+"OB":f.C0.ESC+"[B");break;case 8:C.key=m.ctrlKey?"\b":f.C0.DEL,m.altKey&&(C.key=f.C0.ESC+C.key);break;case 9:if(m.shiftKey){C.key=f.C0.ESC+"[Z";break}C.key=f.C0.HT,C.cancel=!0;break;case 13:C.key=m.altKey?f.C0.ESC+f.C0.CR:f.C0.CR,C.cancel=!0;break;case 27:C.key=f.C0.ESC,m.altKey&&(C.key=f.C0.ESC+f.C0.ESC),C.cancel=!0;break;case 37:if(m.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"D",C.key===f.C0.ESC+"[1;3D"&&(C.key=f.C0.ESC+(y?"b":"[1;5D"))):C.key=x?f.C0.ESC+"OD":f.C0.ESC+"[D";break;case 39:if(m.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"C",C.key===f.C0.ESC+"[1;3C"&&(C.key=f.C0.ESC+(y?"f":"[1;5C"))):C.key=x?f.C0.ESC+"OC":f.C0.ESC+"[C";break;case 38:if(m.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"A",y||C.key!==f.C0.ESC+"[1;3A"||(C.key=f.C0.ESC+"[1;5A")):C.key=x?f.C0.ESC+"OA":f.C0.ESC+"[A";break;case 40:if(m.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"B",y||C.key!==f.C0.ESC+"[1;3B"||(C.key=f.C0.ESC+"[1;5B")):C.key=x?f.C0.ESC+"OB":f.C0.ESC+"[B";break;case 45:m.shiftKey||m.ctrlKey||(C.key=f.C0.ESC+"[2~");break;case 46:C.key=v?f.C0.ESC+"[3;"+(v+1)+"~":f.C0.ESC+"[3~";break;case 36:C.key=v?f.C0.ESC+"[1;"+(v+1)+"H":x?f.C0.ESC+"OH":f.C0.ESC+"[H";break;case 35:C.key=v?f.C0.ESC+"[1;"+(v+1)+"F":x?f.C0.ESC+"OF":f.C0.ESC+"[F";break;case 33:m.shiftKey?C.type=2:m.ctrlKey?C.key=f.C0.ESC+"[5;"+(v+1)+"~":C.key=f.C0.ESC+"[5~";break;case 34:m.shiftKey?C.type=3:m.ctrlKey?C.key=f.C0.ESC+"[6;"+(v+1)+"~":C.key=f.C0.ESC+"[6~";break;case 112:C.key=v?f.C0.ESC+"[1;"+(v+1)+"P":f.C0.ESC+"OP";break;case 113:C.key=v?f.C0.ESC+"[1;"+(v+1)+"Q":f.C0.ESC+"OQ";break;case 114:C.key=v?f.C0.ESC+"[1;"+(v+1)+"R":f.C0.ESC+"OR";break;case 115:C.key=v?f.C0.ESC+"[1;"+(v+1)+"S":f.C0.ESC+"OS";break;case 116:C.key=v?f.C0.ESC+"[15;"+(v+1)+"~":f.C0.ESC+"[15~";break;case 117:C.key=v?f.C0.ESC+"[17;"+(v+1)+"~":f.C0.ESC+"[17~";break;case 118:C.key=v?f.C0.ESC+"[18;"+(v+1)+"~":f.C0.ESC+"[18~";break;case 119:C.key=v?f.C0.ESC+"[19;"+(v+1)+"~":f.C0.ESC+"[19~";break;case 120:C.key=v?f.C0.ESC+"[20;"+(v+1)+"~":f.C0.ESC+"[20~";break;case 121:C.key=v?f.C0.ESC+"[21;"+(v+1)+"~":f.C0.ESC+"[21~";break;case 122:C.key=v?f.C0.ESC+"[23;"+(v+1)+"~":f.C0.ESC+"[23~";break;case 123:C.key=v?f.C0.ESC+"[24;"+(v+1)+"~":f.C0.ESC+"[24~";break;default:if(!m.ctrlKey||m.shiftKey||m.altKey||m.metaKey)if(y&&!w||!m.altKey||m.metaKey)!y||m.altKey||m.ctrlKey||m.shiftKey||!m.metaKey?m.key&&!m.ctrlKey&&!m.altKey&&!m.metaKey&&m.keyCode>=48&&m.key.length===1?C.key=m.key:m.key&&m.ctrlKey&&(m.key==="_"&&(C.key=f.C0.US),m.key==="@"&&(C.key=f.C0.NUL)):m.keyCode===65&&(C.type=1);else{const S=p[m.keyCode],b=S==null?void 0:S[m.shiftKey?1:0];if(b)C.key=f.C0.ESC+b;else if(m.keyCode>=65&&m.keyCode<=90){const _=m.ctrlKey?m.keyCode-64:m.keyCode+32;let j=String.fromCharCode(_);m.shiftKey&&(j=j.toUpperCase()),C.key=f.C0.ESC+j}else if(m.keyCode===32)C.key=f.C0.ESC+(m.ctrlKey?f.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let _=m.code.slice(3,4);m.shiftKey||(_=_.toLowerCase()),C.key=f.C0.ESC+_,C.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?C.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?C.key=f.C0.NUL:m.keyCode>=51&&m.keyCode<=55?C.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?C.key=f.C0.DEL:m.keyCode===219?C.key=f.C0.ESC:m.keyCode===220?C.key=f.C0.FS:m.keyCode===221&&(C.key=f.C0.GS)}return C}},482:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Utf8ToUtf32=c.StringToUtf32=c.utf32ToString=c.stringFromCodePoint=void 0,c.stringFromCodePoint=function(d){return d>65535?(d-=65536,String.fromCharCode(55296+(d>>10))+String.fromCharCode(d%1024+56320)):String.fromCharCode(d)},c.utf32ToString=function(d,f=0,p=d.length){let m="";for(let x=f;x<p;++x){let y=d[x];y>65535?(y-=65536,m+=String.fromCharCode(55296+(y>>10))+String.fromCharCode(y%1024+56320)):m+=String.fromCharCode(y)}return m},c.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,f){const p=d.length;if(!p)return 0;let m=0,x=0;if(this._interim){const y=d.charCodeAt(x++);56320<=y&&y<=57343?f[m++]=1024*(this._interim-55296)+y-56320+65536:(f[m++]=this._interim,f[m++]=y),this._interim=0}for(let y=x;y<p;++y){const w=d.charCodeAt(y);if(55296<=w&&w<=56319){if(++y>=p)return this._interim=w,m;const C=d.charCodeAt(y);56320<=C&&C<=57343?f[m++]=1024*(w-55296)+C-56320+65536:(f[m++]=w,f[m++]=C)}else w!==65279&&(f[m++]=w)}return m}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,f){const p=d.length;if(!p)return 0;let m,x,y,w,C=0,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 T,D=0;for(;(T=63&this.interim[++D])&&D<4;)E<<=6,E|=T;const L=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=L-D;for(;S<O;){if(S>=p)return 0;if(T=d[S++],(192&T)!=128){S--,j=!0;break}this.interim[D++]=T,E<<=6,E|=63&T}j||(L===2?E<128?S--:f[C++]=E:L===3?E<2048||E>=55296&&E<=57343||E===65279||(f[C++]=E):E<65536||E>1114111||(f[C++]=E)),this.interim.fill(0)}const b=p-4;let _=S;for(;_<p;){for(;!(!(_<b)||128&(m=d[_])||128&(x=d[_+1])||128&(y=d[_+2])||128&(w=d[_+3]));)f[C++]=m,f[C++]=x,f[C++]=y,f[C++]=w,_+=4;if(m=d[_++],m<128)f[C++]=m;else if((224&m)==192){if(_>=p)return this.interim[0]=m,C;if(x=d[_++],(192&x)!=128){_--;continue}if(v=(31&m)<<6|63&x,v<128){_--;continue}f[C++]=v}else if((240&m)==224){if(_>=p)return this.interim[0]=m,C;if(x=d[_++],(192&x)!=128){_--;continue}if(_>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[_++],(192&y)!=128){_--;continue}if(v=(15&m)<<12|(63&x)<<6|63&y,v<2048||v>=55296&&v<=57343||v===65279)continue;f[C++]=v}else if((248&m)==240){if(_>=p)return this.interim[0]=m,C;if(x=d[_++],(192&x)!=128){_--;continue}if(_>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[_++],(192&y)!=128){_--;continue}if(_>=p)return this.interim[0]=m,this.interim[1]=x,this.interim[2]=y,C;if(w=d[_++],(192&w)!=128){_--;continue}if(v=(7&m)<<18|(63&x)<<12|(63&y)<<6|63&w,v<65536||v>1114111)continue;f[C++]=v}}return C}}},225:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const f=d(1480),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],m=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let x;c.UnicodeV6=class{constructor(){if(this.version="6",!x){x=new Uint8Array(65536),x.fill(1),x[0]=0,x.fill(0,1,32),x.fill(0,127,160),x.fill(2,4352,4448),x[9001]=2,x[9002]=2,x.fill(2,11904,42192),x[12351]=1,x.fill(2,44032,55204),x.fill(2,63744,64256),x.fill(2,65040,65050),x.fill(2,65072,65136),x.fill(2,65280,65377),x.fill(2,65504,65511);for(let y=0;y<p.length;++y)x.fill(0,p[y][0],p[y][1]+1)}}wcwidth(y){return y<32?0:y<127?1:y<65536?x[y]:(function(w,C){let v,S=0,b=C.length-1;if(w<C[0][0]||w>C[b][1])return!1;for(;b>=S;)if(v=S+b>>1,w>C[v][1])S=v+1;else{if(!(w<C[v][0]))return!0;b=v-1}return!1})(y,m)?0:y>=131072&&y<=196605||y>=196608&&y<=262141?2:1}charProperties(y,w){let C=this.wcwidth(y),v=C===0&&w!==0;if(v){const S=f.UnicodeService.extractWidth(w);S===0?v=!1:S>C&&(C=S)}return f.UnicodeService.createPropertyValue(0,C,v)}}},5981:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const f=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._action=y,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new f.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(y,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const v=this._callbacks.shift();v&&v()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(y,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(w)}_innerWrite(y=0,w=!0){const C=y||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const v=this._writeBuffer[this._bufferOffset],S=this._action(v,w);if(S){const _=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(_)}const b=this._callbacks[this._bufferOffset];if(b&&b(),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()}}c.WriteBuffer=m},5941:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.toRgbString=c.parseColor=void 0;const d=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,f=/^[\da-f]+$/;function p(m,x){const y=m.toString(16),w=y.length<2?"0"+y:y;switch(x){case 4:return y[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}c.parseColor=function(m){if(!m)return;let x=m.toLowerCase();if(x.indexOf("rgb:")===0){x=x.slice(4);const y=d.exec(x);if(y){const w=y[1]?15:y[4]?255:y[7]?4095:65535;return[Math.round(parseInt(y[1]||y[4]||y[7]||y[10],16)/w*255),Math.round(parseInt(y[2]||y[5]||y[8]||y[11],16)/w*255),Math.round(parseInt(y[3]||y[6]||y[9]||y[12],16)/w*255)]}}else if(x.indexOf("#")===0&&(x=x.slice(1),f.exec(x)&&[3,6,9,12].includes(x.length))){const y=x.length/3,w=[0,0,0];for(let C=0;C<3;++C){const v=parseInt(x.slice(y*C,y*C+y),16);w[C]=y===1?v<<4:y===2?v:y===3?v>>4:v>>8}return w}},c.toRgbString=function(m,x=16){const[y,w,C]=m;return`rgb:${p(y,x)}/${p(w,x)}/${p(C,x)}`}},5770:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.PAYLOAD_LIMIT=void 0,c.PAYLOAD_LIMIT=1e7},6351:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DcsHandler=c.DcsParser=void 0;const f=d(482),p=d(8742),m=d(5770),x=[];c.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=x,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=x}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const 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=x,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||x,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,f.utf32ToString)(w,C,v))}unhook(w,C=!0){if(this._active.length){let v=!1,S=this._active.length-1,b=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,v=C,b=this._stack.fallThrough,this._stack.paused=!1),!b&&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=x,this._ident=0}};const y=new p.Params;y.addParam(0),c.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=y,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():y,this._data="",this._hitLimit=!1}put(w,C,v){this._hitLimit||(this._data+=(0,f.utf32ToString)(w,C,v),this._data.length>m.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((v=>(this._params=y,this._data="",this._hitLimit=!1,v)));return this._params=y,this._data="",this._hitLimit=!1,C}}},2015:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.EscapeSequenceParser=c.VT500_TRANSITION_TABLE=c.TransitionTable=void 0;const f=d(844),p=d(8742),m=d(6242),x=d(6351);class y{constructor(S){this.table=new Uint8Array(S)}setDefault(S,b){this.table.fill(S<<4|b)}add(S,b,_,j){this.table[b<<8|S]=_<<4|j}addMany(S,b,_,j){for(let E=0;E<S.length;E++)this.table[b<<8|S[E]]=_<<4|j}}c.TransitionTable=y;const w=160;c.VT500_TRANSITION_TABLE=(function(){const v=new y(4095),S=Array.apply(null,Array(256)).map(((D,L)=>L)),b=(D,L)=>S.slice(D,L),_=b(32,127),j=b(0,24);j.push(25),j.push.apply(j,b(28,32));const E=b(0,14);let T;for(T in v.setDefault(1,0),v.addMany(_,0,2,0),E)v.addMany([24,26,153,154],T,3,0),v.addMany(b(128,144),T,3,0),v.addMany(b(144,152),T,3,0),v.add(156,T,0,0),v.add(27,T,11,1),v.add(157,T,4,8),v.addMany([152,158,159],T,0,7),v.add(155,T,11,3),v.add(144,T,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(_,8,5,8),v.add(127,8,5,8),v.addMany([156,27,24,26,7],8,6,0),v.addMany(b(28,32),8,0,8),v.addMany([88,94,95],1,0,7),v.addMany(_,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(b(64,127),3,7,0),v.addMany(b(48,60),3,8,4),v.addMany([60,61,62,63],3,9,4),v.addMany(b(48,60),4,8,4),v.addMany(b(64,127),4,7,0),v.addMany([60,61,62,63],4,0,6),v.addMany(b(32,64),6,0,6),v.add(127,6,0,6),v.addMany(b(64,127),6,0,0),v.addMany(b(32,48),3,9,5),v.addMany(b(32,48),5,9,5),v.addMany(b(48,64),5,0,6),v.addMany(b(64,127),5,7,0),v.addMany(b(32,48),4,9,5),v.addMany(b(32,48),1,9,2),v.addMany(b(32,48),2,9,2),v.addMany(b(48,127),2,10,0),v.addMany(b(48,80),1,10,0),v.addMany(b(81,88),1,10,0),v.addMany([89,90,92],1,10,0),v.addMany(b(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(b(28,32),9,0,9),v.addMany(b(32,48),9,9,12),v.addMany(b(48,60),9,8,10),v.addMany([60,61,62,63],9,9,10),v.addMany(j,11,0,11),v.addMany(b(32,128),11,0,11),v.addMany(b(28,32),11,0,11),v.addMany(j,10,0,10),v.add(127,10,0,10),v.addMany(b(28,32),10,0,10),v.addMany(b(48,60),10,8,10),v.addMany([60,61,62,63],10,0,11),v.addMany(b(32,48),10,9,12),v.addMany(j,12,0,12),v.add(127,12,0,12),v.addMany(b(28,32),12,0,12),v.addMany(b(32,48),12,9,12),v.addMany(b(48,64),12,0,11),v.addMany(b(64,127),12,12,13),v.addMany(b(64,127),10,12,13),v.addMany(b(64,127),9,12,13),v.addMany(j,13,13,13),v.addMany(_,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 f.Disposable{constructor(S=c.VT500_TRANSITION_TABLE){super(),this._transitions=S,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(b,_,j)=>{},this._executeHandlerFb=b=>{},this._csiHandlerFb=(b,_)=>{},this._escHandlerFb=b=>{},this._errorHandlerFb=b=>b,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,f.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new m.OscParser),this._dcsParser=this.register(new x.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,b=[64,126]){let _=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(_=S.prefix.charCodeAt(0),_&&60>_||_>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 T=S.intermediates.charCodeAt(E);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");_<<=8,_|=T}}if(S.final.length!==1)throw new Error("final must be a single byte");const j=S.final.charCodeAt(0);if(b[0]>j||j>b[1])throw new Error(`final must be in range ${b[0]} .. ${b[1]}`);return _<<=8,_|=j,_}identToString(S){const b=[];for(;S;)b.push(String.fromCharCode(255&S)),S>>=8;return b.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,b){const _=this._identifier(S,[48,126]);this._escHandlers[_]===void 0&&(this._escHandlers[_]=[]);const j=this._escHandlers[_];return j.push(b),{dispose:()=>{const E=j.indexOf(b);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,b){this._executeHandlers[S.charCodeAt(0)]=b}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,b){const _=this._identifier(S);this._csiHandlers[_]===void 0&&(this._csiHandlers[_]=[]);const j=this._csiHandlers[_];return j.push(b),{dispose:()=>{const E=j.indexOf(b);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,b){return this._dcsParser.registerHandler(this._identifier(S),b)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,b){return this._oscParser.registerHandler(S,b)}clearOscHandler(S){this._oscParser.clearHandler(S)}setOscHandlerFallback(S){this._oscParser.setHandlerFallback(S)}setErrorHandler(S){this._errorHandler=S}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(S,b,_,j,E){this._parseStack.state=S,this._parseStack.handlers=b,this._parseStack.handlerPos=_,this._parseStack.transition=j,this._parseStack.chunkPos=E}parse(S,b,_){let j,E=0,T=0,D=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,D=this._parseStack.chunkPos+1;else{if(_===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const L=this._parseStack.handlers;let O=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(_===!1&&O>-1){for(;O>=0&&(j=L[O](this._params),j!==!0);O--)if(j instanceof Promise)return this._parseStack.handlerPos=O,j}this._parseStack.handlers=[];break;case 4:if(_===!1&&O>-1){for(;O>=0&&(j=L[O](),j!==!0);O--)if(j instanceof Promise)return this._parseStack.handlerPos=O,j}this._parseStack.handlers=[];break;case 6:if(E=S[this._parseStack.chunkPos],j=this._dcsParser.unhook(E!==24&&E!==26,_),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,_),j)return j;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,D=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let L=D;L<b;++L){switch(E=S[L],T=this._transitions.table[this.currentState<<8|(E<160?E:w)],T>>4){case 2:for(let M=L+1;;++M){if(M>=b||(E=S[M])<32||E>126&&E<w){this._printHandler(S,L,M),L=M-1;break}if(++M>=b||(E=S[M])<32||E>126&&E<w){this._printHandler(S,L,M),L=M-1;break}if(++M>=b||(E=S[M])<32||E>126&&E<w){this._printHandler(S,L,M),L=M-1;break}if(++M>=b||(E=S[M])<32||E>126&&E<w){this._printHandler(S,L,M),L=M-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:L,code:E,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const O=this._csiHandlers[this._collect<<8|E];let P=O?O.length-1:-1;for(;P>=0&&(j=O[P](this._params),j!==!0);P--)if(j instanceof Promise)return this._preserveStack(3,O,P,T,L),j;P<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(++L<b&&(E=S[L])>47&&E<60);L--;break;case 9:this._collect<<=8,this._collect|=E;break;case 10:const q=this._escHandlers[this._collect<<8|E];let W=q?q.length-1:-1;for(;W>=0&&(j=q[W](),j!==!0);W--)if(j instanceof Promise)return this._preserveStack(4,q,W,T,L),j;W<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 M=L+1;;++M)if(M>=b||(E=S[M])===24||E===26||E===27||E>127&&E<w){this._dcsParser.put(S,L,M),L=M-1;break}break;case 14:if(j=this._dcsParser.unhook(E!==24&&E!==26),j)return this._preserveStack(6,[],0,T,L),j;E===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let M=L+1;;M++)if(M>=b||(E=S[M])<32||E>127&&E<w){this._oscParser.put(S,L,M),L=M-1;break}break;case 6:if(j=this._oscParser.end(E!==24&&E!==26),j)return this._preserveStack(5,[],0,T,L),j;E===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&T}}}c.EscapeSequenceParser=C},6242:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OscHandler=c.OscParser=void 0;const f=d(5770),p=d(482),m=[];c.OscParser=class{constructor(){this._state=0,this._active=m,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(x,y){this._handlers[x]===void 0&&(this._handlers[x]=[]);const w=this._handlers[x];return w.push(y),{dispose:()=>{const C=w.indexOf(y);C!==-1&&w.splice(C,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].end(!1);this._stack.paused=!1,this._active=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].start();else this._handlerFb(this._id,"START")}_put(x,y,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(x,y,w);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(x,y,w))}start(){this.reset(),this._state=1}put(x,y,w){if(this._state!==3){if(this._state===1)for(;y<w;){const C=x[y++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-y>0&&this._put(x,y,w)}}end(x,y=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,v=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=y,v=this._stack.fallThrough,this._stack.paused=!1),!v&&w===!1){for(;C>=0&&(w=this._active[C].end(x),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",x);this._active=m,this._id=-1,this._state=0}}},c.OscHandler=class{constructor(x){this._handler=x,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(x,y,w){this._hitLimit||(this._data+=(0,p.utf32ToString)(x,y,w),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(x){let y=!1;if(this._hitLimit)y=!1;else if(x&&(y=this._handler(this._data),y instanceof Promise))return y.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,y}}},8742:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Params=void 0;const d=2147483647;class f{static fromArray(m){const x=new f;if(!m.length)return x;for(let y=Array.isArray(m[0])?1:0;y<m.length;++y){const w=m[y];if(Array.isArray(w))for(let C=0;C<w.length;++C)x.addSubParam(w[C]);else x.addParam(w)}return x}constructor(m=32,x=32){if(this.maxLength=m,this.maxSubParamsLength=x,x>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(x),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(m),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const m=new f(this.maxLength,this.maxSubParamsLength);return m.params.set(this.params),m.length=this.length,m._subParams.set(this._subParams),m._subParamsLength=this._subParamsLength,m._subParamsIdx.set(this._subParamsIdx),m._rejectDigits=this._rejectDigits,m._rejectSubDigits=this._rejectSubDigits,m._digitIsSub=this._digitIsSub,m}toArray(){const m=[];for(let x=0;x<this.length;++x){m.push(this.params[x]);const y=this._subParamsIdx[x]>>8,w=255&this._subParamsIdx[x];w-y>0&&m.push(Array.prototype.slice.call(this._subParams,y,w))}return m}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(m){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=m>d?d:m}}addSubParam(m){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=m>d?d:m,this._subParamsIdx[this.length-1]++}}hasSubParams(m){return(255&this._subParamsIdx[m])-(this._subParamsIdx[m]>>8)>0}getSubParams(m){const x=this._subParamsIdx[m]>>8,y=255&this._subParamsIdx[m];return y-x>0?this._subParams.subarray(x,y):null}getSubParamsAll(){const m={};for(let x=0;x<this.length;++x){const y=this._subParamsIdx[x]>>8,w=255&this._subParamsIdx[x];w-y>0&&(m[x]=this._subParams.slice(y,w))}return m}addDigit(m){let x;if(this._rejectDigits||!(x=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const y=this._digitIsSub?this._subParams:this.params,w=y[x-1];y[x-1]=~w?Math.min(10*w+m,d):m}}c.Params=f},5741:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.AddonManager=void 0,c.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let d=this._addons.length-1;d>=0;d--)this._addons[d].instance.dispose()}loadAddon(d,f){const p={instance:f,dispose:f.dispose,isDisposed:!1};this._addons.push(p),f.dispose=()=>this._wrappedAddonDispose(p),f.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let f=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===d){f=p;break}if(f===-1)throw new Error("Could not dispose an addon that has not been loaded");d.isDisposed=!0,d.dispose.apply(d.instance),this._addons.splice(f,1)}}},8771:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferApiView=void 0;const f=d(3785),p=d(511);c.BufferApiView=class{constructor(m,x){this._buffer=m,this.type=x}init(m){return this._buffer=m,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(m){const x=this._buffer.lines.get(m);if(x)return new f.BufferLineApiView(x)}getNullCell(){return new p.CellData}}},3785:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const f=d(511);c.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,m){if(!(p<0||p>=this._line.length))return m?(this._line.loadCell(p,m),m):this._line.loadCell(p,new f.CellData)}translateToString(p,m,x){return this._line.translateToString(p,m,x)}}},8285:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferNamespaceApi=void 0;const f=d(8771),p=d(8460),m=d(844);class x extends m.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new f.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new f.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}c.BufferNamespaceApi=x},7975:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ParserApi=void 0,c.ParserApi=class{constructor(d){this._core=d}registerCsiHandler(d,f){return this._core.registerCsiHandler(d,(p=>f(p.toArray())))}addCsiHandler(d,f){return this.registerCsiHandler(d,f)}registerDcsHandler(d,f){return this._core.registerDcsHandler(d,((p,m)=>f(p,m.toArray())))}addDcsHandler(d,f){return this.registerDcsHandler(d,f)}registerEscHandler(d,f){return this._core.registerEscHandler(d,f)}addEscHandler(d,f){return this.registerEscHandler(d,f)}registerOscHandler(d,f){return this._core.registerOscHandler(d,f)}addOscHandler(d,f){return this.registerOscHandler(d,f)}}},7090:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeApi=void 0,c.UnicodeApi=class{constructor(d){this._core=d}register(d){this._core.unicodeService.register(d)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(d){this._core.unicodeService.activeVersion=d}}},744:function(u,c,d){var f=this&&this.__decorate||function(v,S,b,_){var j,E=arguments.length,T=E<3?S:_===null?_=Object.getOwnPropertyDescriptor(S,b):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,S,b,_);else for(var D=v.length-1;D>=0;D--)(j=v[D])&&(T=(E<3?j(T):E>3?j(S,b,T):j(S,b))||T);return E>3&&T&&Object.defineProperty(S,b,T),T},p=this&&this.__param||function(v,S){return function(b,_){S(b,_,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const m=d(8460),x=d(844),y=d(5295),w=d(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let C=c.BufferService=class extends x.Disposable{get buffer(){return this.buffers.active}constructor(v){super(),this.isUserScrolling=!1,this._onResize=this.register(new m.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new m.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(v.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(v.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new y.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 b=this.buffer;let _;_=this._cachedBlankLine,_&&_.length===this.cols&&_.getFg(0)===v.fg&&_.getBg(0)===v.bg||(_=b.getBlankLine(v,S),this._cachedBlankLine=_),_.isWrapped=S;const j=b.ybase+b.scrollTop,E=b.ybase+b.scrollBottom;if(b.scrollTop===0){const T=b.lines.isFull;E===b.lines.length-1?T?b.lines.recycle().copyFrom(_):b.lines.push(_.clone()):b.lines.splice(E+1,0,_.clone()),T?this.isUserScrolling&&(b.ydisp=Math.max(b.ydisp-1,0)):(b.ybase++,this.isUserScrolling||b.ydisp++)}else{const T=E-j+1;b.lines.shiftElements(j+1,T-1,-1),b.lines.set(E,_.clone())}this.isUserScrolling||(b.ydisp=b.ybase),this._onScroll.fire(b.ydisp)}scrollLines(v,S,b){const _=this.buffer;if(v<0){if(_.ydisp===0)return;this.isUserScrolling=!0}else v+_.ydisp>=_.ybase&&(this.isUserScrolling=!1);const j=_.ydisp;_.ydisp=Math.max(Math.min(_.ydisp+v,_.ybase),0),j!==_.ydisp&&(S||this._onScroll.fire(_.ydisp))}};c.BufferService=C=f([p(0,w.IOptionsService)],C)},7994:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CharsetService=void 0,c.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(d){this.glevel=d,this.charset=this._charsets[d]}setgCharset(d,f){this._charsets[d]=f,this.glevel===d&&(this.charset=f)}}},1753:function(u,c,d){var f=this&&this.__decorate||function(_,j,E,T){var D,L=arguments.length,O=L<3?j:T===null?T=Object.getOwnPropertyDescriptor(j,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(_,j,E,T);else for(var P=_.length-1;P>=0;P--)(D=_[P])&&(O=(L<3?D(O):L>3?D(j,E,O):D(j,E))||O);return L>3&&O&&Object.defineProperty(j,E,O),O},p=this&&this.__param||function(_,j){return function(E,T){j(E,T,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreMouseService=void 0;const m=d(2585),x=d(8460),y=d(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:_=>_.button!==4&&_.action===1&&(_.ctrl=!1,_.alt=!1,_.shift=!1,!0)},VT200:{events:19,restrict:_=>_.action!==32},DRAG:{events:23,restrict:_=>_.action!==32||_.button!==3},ANY:{events:31,restrict:_=>!0}};function C(_,j){let E=(_.ctrl?16:0)|(_.shift?4:0)|(_.alt?8:0);return _.button===4?(E|=64,E|=_.action):(E|=3&_.button,4&_.button&&(E|=64),8&_.button&&(E|=128),_.action===32?E|=32:_.action!==0||j||(E|=3)),E}const v=String.fromCharCode,S={DEFAULT:_=>{const j=[C(_,!1)+32,_.col+32,_.row+32];return j[0]>255||j[1]>255||j[2]>255?"":`\x1B[M${v(j[0])}${v(j[1])}${v(j[2])}`},SGR:_=>{const j=_.action===0&&_.button!==4?"m":"M";return`\x1B[<${C(_,!0)};${_.col};${_.row}${j}`},SGR_PIXELS:_=>{const j=_.action===0&&_.button!==4?"m":"M";return`\x1B[<${C(_,!0)};${_.x};${_.y}${j}`}};let b=c.CoreMouseService=class extends y.Disposable{constructor(_,j){super(),this._bufferService=_,this._coreService=j,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new x.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const 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(_,j){this._protocols[_]=j}addEncoding(_,j){this._encodings[_]=j}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(_){if(!this._protocols[_])throw new Error(`unknown protocol "${_}"`);this._activeProtocol=_,this._onProtocolChange.fire(this._protocols[_].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(_){if(!this._encodings[_])throw new Error(`unknown encoding "${_}"`);this._activeEncoding=_}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(_){if(_.col<0||_.col>=this._bufferService.cols||_.row<0||_.row>=this._bufferService.rows||_.button===4&&_.action===32||_.button===3&&_.action!==32||_.button!==4&&(_.action===2||_.action===3)||(_.col++,_.row++,_.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,_,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(_))return!1;const j=this._encodings[this._activeEncoding](_);return j&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(j):this._coreService.triggerDataEvent(j,!0)),this._lastEvent=_,!0}explainEvents(_){return{down:!!(1&_),up:!!(2&_),drag:!!(4&_),move:!!(8&_),wheel:!!(16&_)}}_equalEvents(_,j,E){if(E){if(_.x!==j.x||_.y!==j.y)return!1}else if(_.col!==j.col||_.row!==j.row)return!1;return _.button===j.button&&_.action===j.action&&_.ctrl===j.ctrl&&_.alt===j.alt&&_.shift===j.shift}};c.CoreMouseService=b=f([p(0,m.IBufferService),p(1,m.ICoreService)],b)},6975:function(u,c,d){var f=this&&this.__decorate||function(b,_,j,E){var T,D=arguments.length,L=D<3?_:E===null?E=Object.getOwnPropertyDescriptor(_,j):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,_,j,E);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(_,j,L):T(_,j))||L);return D>3&&L&&Object.defineProperty(_,j,L),L},p=this&&this.__param||function(b,_){return function(j,E){_(j,E,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const m=d(1439),x=d(8460),y=d(844),w=d(2585),C=Object.freeze({insertMode:!1}),v=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let S=c.CoreService=class extends y.Disposable{constructor(b,_,j){super(),this._bufferService=b,this._logService=_,this._optionsService=j,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new x.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new x.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new x.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new x.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(v)}reset(){this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(v)}triggerDataEvent(b,_=!1){if(this._optionsService.rawOptions.disableStdin)return;const j=this._bufferService.buffer;_&&this._optionsService.rawOptions.scrollOnUserInput&&j.ybase!==j.ydisp&&this._onRequestScrollToBottom.fire(),_&&this._onUserInput.fire(),this._logService.debug(`sending data "${b}"`,(()=>b.split("").map((E=>E.charCodeAt(0))))),this._onData.fire(b)}triggerBinaryEvent(b){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${b}"`,(()=>b.split("").map((_=>_.charCodeAt(0))))),this._onBinary.fire(b))}};c.CoreService=S=f([p(0,w.IBufferService),p(1,w.ILogService),p(2,w.IOptionsService)],S)},9074:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DecorationService=void 0;const f=d(8055),p=d(8460),m=d(844),x=d(6106);let y=0,w=0;class C extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new x.SortedList((b=>b==null?void 0:b.marker.line)),this._onDecorationRegistered=this.register(new p.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new p.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,m.toDisposable)((()=>this.reset())))}registerDecoration(b){if(b.marker.isDisposed)return;const _=new v(b);if(_){const j=_.marker.onDispose((()=>_.dispose()));_.onDispose((()=>{_&&(this._decorations.delete(_)&&this._onDecorationRemoved.fire(_),j.dispose())})),this._decorations.insert(_),this._onDecorationRegistered.fire(_)}return _}reset(){for(const b of this._decorations.values())b.dispose();this._decorations.clear()}*getDecorationsAtCell(b,_,j){let E=0,T=0;for(const D of this._decorations.getKeyIterator(_))E=D.options.x??0,T=E+(D.options.width??1),b>=E&&b<T&&(!j||(D.options.layer??"bottom")===j)&&(yield D)}forEachDecorationAtCell(b,_,j,E){this._decorations.forEachByKey(_,(T=>{y=T.options.x??0,w=y+(T.options.width??1),b>=y&&b<w&&(!j||(T.options.layer??"bottom")===j)&&E(T)}))}}c.DecorationService=C;class v extends m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=f.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=f.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(b){super(),this.options=b,this.onRenderEmitter=this.register(new p.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new p.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=b.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.InstantiationService=c.ServiceCollection=void 0;const f=d(2585),p=d(8343);class m{constructor(...y){this._entries=new Map;for(const[w,C]of y)this.set(w,C)}set(y,w){const C=this._entries.get(y);return this._entries.set(y,w),C}forEach(y){for(const[w,C]of this._entries.entries())y(w,C)}has(y){return this._entries.has(y)}get(y){return this._entries.get(y)}}c.ServiceCollection=m,c.InstantiationService=class{constructor(){this._services=new m,this._services.set(f.IInstantiationService,this)}setService(x,y){this._services.set(x,y)}getService(x){return this._services.get(x)}createInstance(x,...y){const w=(0,p.getServiceDependencies)(x).sort(((S,b)=>S.index-b.index)),C=[];for(const S of w){const b=this._services.get(S.id);if(!b)throw new Error(`[createInstance] ${x.name} depends on UNKNOWN service ${S.id}.`);C.push(b)}const v=w.length>0?w[0].index:y.length;if(y.length!==v)throw new Error(`[createInstance] First service dependency of ${x.name} at position ${v+1} conflicts with ${y.length} static arguments`);return new x(...y,...C)}}},7866:function(u,c,d){var f=this&&this.__decorate||function(v,S,b,_){var j,E=arguments.length,T=E<3?S:_===null?_=Object.getOwnPropertyDescriptor(S,b):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,S,b,_);else for(var D=v.length-1;D>=0;D--)(j=v[D])&&(T=(E<3?j(T):E>3?j(S,b,T):j(S,b))||T);return E>3&&T&&Object.defineProperty(S,b,T),T},p=this&&this.__param||function(v,S){return function(b,_){S(b,_,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const m=d(844),x=d(2585),y={trace:x.LogLevelEnum.TRACE,debug:x.LogLevelEnum.DEBUG,info:x.LogLevelEnum.INFO,warn:x.LogLevelEnum.WARN,error:x.LogLevelEnum.ERROR,off:x.LogLevelEnum.OFF};let w,C=c.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(v){super(),this._optionsService=v,this._logLevel=x.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=y[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(v){for(let S=0;S<v.length;S++)typeof v[S]=="function"&&(v[S]=v[S]())}_log(v,S,b){this._evalLazyOptionalParams(b),v.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...b)}trace(v,...S){var b;this._logLevel<=x.LogLevelEnum.TRACE&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.trace.bind(this._optionsService.options.logger))??console.log,v,S)}debug(v,...S){var b;this._logLevel<=x.LogLevelEnum.DEBUG&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.debug.bind(this._optionsService.options.logger))??console.log,v,S)}info(v,...S){var b;this._logLevel<=x.LogLevelEnum.INFO&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.info.bind(this._optionsService.options.logger))??console.info,v,S)}warn(v,...S){var b;this._logLevel<=x.LogLevelEnum.WARN&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.warn.bind(this._optionsService.options.logger))??console.warn,v,S)}error(v,...S){var b;this._logLevel<=x.LogLevelEnum.ERROR&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.error.bind(this._optionsService.options.logger))??console.error,v,S)}};c.LogService=C=f([p(0,x.IOptionsService)],C),c.setTraceLogger=function(v){w=v},c.traceCall=function(v,S,b){if(typeof b.value!="function")throw new Error("not supported");const _=b.value;b.value=function(...j){if(w.logLevel!==x.LogLevelEnum.TRACE)return _.apply(this,j);w.trace(`GlyphRenderer#${_.name}(${j.map((T=>JSON.stringify(T))).join(", ")})`);const E=_.apply(this,j);return w.trace(`GlyphRenderer#${_.name} return`,E),E}}},7302:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const f=d(8460),p=d(844),m=d(6114);c.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:m.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const x=["normal","bold","100","200","300","400","500","600","700","800","900"];class y extends p.Disposable{constructor(C){super(),this._onOptionChange=this.register(new f.EventEmitter),this.onOptionChange=this._onOptionChange.event;const v={...c.DEFAULT_OPTIONS};for(const S in C)if(S in v)try{const b=C[S];v[S]=this._sanitizeAndValidateOption(S,b)}catch(b){console.error(b)}this.rawOptions=v,this.options={...v},this._setupOptions(),this.register((0,p.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 c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},v=(S,b)=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);b=this._sanitizeAndValidateOption(S,b),this.rawOptions[S]!==b&&(this.rawOptions[S]=b,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const b={get:C.bind(this,S),set:v.bind(this,S)};Object.defineProperty(this.options,S,b)}}_sanitizeAndValidateOption(C,v){switch(C){case"cursorStyle":if(v||(v=c.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=c.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof v=="number"&&1<=v&&v<=1e3)break;v=x.includes(v)?v:c.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}}c.OptionsService=y},2660:function(u,c,d){var f=this&&this.__decorate||function(y,w,C,v){var S,b=arguments.length,_=b<3?w:v===null?v=Object.getOwnPropertyDescriptor(w,C):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(y,w,C,v);else for(var j=y.length-1;j>=0;j--)(S=y[j])&&(_=(b<3?S(_):b>3?S(w,C,_):S(w,C))||_);return b>3&&_&&Object.defineProperty(w,C,_),_},p=this&&this.__param||function(y,w){return function(C,v){w(C,v,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const m=d(2585);let x=c.OscLinkService=class{constructor(y){this._bufferService=y,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(y){const w=this._bufferService.buffer;if(y.id===void 0){const j=w.addMarker(w.ybase+w.y),E={data:y,id:this._nextId++,lines:[j]};return j.onDispose((()=>this._removeMarkerFromLink(E,j))),this._dataByLinkId.set(E.id,E),E.id}const C=y,v=this._getEntryIdKey(C),S=this._entriesWithId.get(v);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const b=w.addMarker(w.ybase+w.y),_={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(_,b))),this._entriesWithId.set(_.key,_),this._dataByLinkId.set(_.id,_),_.id}addLineToLink(y,w){const C=this._dataByLinkId.get(y);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(y){var w;return(w=this._dataByLinkId.get(y))==null?void 0:w.data}_getEntryIdKey(y){return`${y.id};;${y.uri}`}_removeMarkerFromLink(y,w){const C=y.lines.indexOf(w);C!==-1&&(y.lines.splice(C,1),y.lines.length===0&&(y.data.id!==void 0&&this._entriesWithId.delete(y.key),this._dataByLinkId.delete(y.id)))}};c.OscLinkService=x=f([p(0,m.IBufferService)],x)},8343:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createDecorator=c.getServiceDependencies=c.serviceRegistry=void 0;const d="di$target",f="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(p){return p[f]||[]},c.createDecorator=function(p){if(c.serviceRegistry.has(p))return c.serviceRegistry.get(p);const m=function(x,y,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,v,S){v[d]===v?v[f].push({id:C,index:S}):(v[f]=[{id:C,index:S}],v[d]=v)})(m,x,w)};return m.toString=()=>p,c.serviceRegistry.set(p,m),m}},2585:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.IDecorationService=c.IUnicodeService=c.IOscLinkService=c.IOptionsService=c.ILogService=c.LogLevelEnum=c.IInstantiationService=c.ICharsetService=c.ICoreService=c.ICoreMouseService=c.IBufferService=void 0;const f=d(8343);var p;c.IBufferService=(0,f.createDecorator)("BufferService"),c.ICoreMouseService=(0,f.createDecorator)("CoreMouseService"),c.ICoreService=(0,f.createDecorator)("CoreService"),c.ICharsetService=(0,f.createDecorator)("CharsetService"),c.IInstantiationService=(0,f.createDecorator)("InstantiationService"),(function(m){m[m.TRACE=0]="TRACE",m[m.DEBUG=1]="DEBUG",m[m.INFO=2]="INFO",m[m.WARN=3]="WARN",m[m.ERROR=4]="ERROR",m[m.OFF=5]="OFF"})(p||(c.LogLevelEnum=p={})),c.ILogService=(0,f.createDecorator)("LogService"),c.IOptionsService=(0,f.createDecorator)("OptionsService"),c.IOscLinkService=(0,f.createDecorator)("OscLinkService"),c.IUnicodeService=(0,f.createDecorator)("UnicodeService"),c.IDecorationService=(0,f.createDecorator)("DecorationService")},1480:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const f=d(8460),p=d(225);class m{static extractShouldJoin(y){return(1&y)!=0}static extractWidth(y){return y>>1&3}static extractCharKind(y){return y>>3}static createPropertyValue(y,w,C=!1){return(16777215&y)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new f.EventEmitter,this.onChange=this._onChange.event;const y=new p.UnicodeV6;this.register(y),this._active=y.version,this._activeProvider=y}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(y){if(!this._providers[y])throw new Error(`unknown Unicode version "${y}"`);this._active=y,this._activeProvider=this._providers[y],this._onChange.fire(y)}register(y){this._providers[y.version]=y}wcwidth(y){return this._activeProvider.wcwidth(y)}getStringCellWidth(y){let w=0,C=0;const v=y.length;for(let S=0;S<v;++S){let b=y.charCodeAt(S);if(55296<=b&&b<=56319){if(++S>=v)return w+this.wcwidth(b);const E=y.charCodeAt(S);56320<=E&&E<=57343?b=1024*(b-55296)+E-56320+65536:w+=this.wcwidth(E)}const _=this.charProperties(b,C);let j=m.extractWidth(_);m.extractShouldJoin(_)&&(j-=m.extractWidth(C)),w+=j,C=_}return w}charProperties(y,w){return this._activeProvider.charProperties(y,w)}}c.UnicodeService=m}},r={};function o(u){var c=r[u];if(c!==void 0)return c.exports;var d=r[u]={exports:{}};return n[u].call(d.exports,d,d.exports,o),d.exports}var l={};return(()=>{var u=l;Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const c=o(9042),d=o(3236),f=o(844),p=o(5741),m=o(8285),x=o(7975),y=o(7090),w=["cols","rows"];class C extends f.Disposable{constructor(S){super(),this._core=this.register(new d.Terminal(S)),this._addonManager=this.register(new p.AddonManager),this._publicOptions={...this._core.options};const b=j=>this._core.options[j],_=(j,E)=>{this._checkReadonlyOptions(j),this._core.options[j]=E};for(const j in this._core.options){const E={get:b.bind(this,j),set:_.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 x.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new y.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new m.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const S=this._core.coreService.decPrivateModes;let b="none";switch(this._core.coreMouseService.activeProtocol){case"X10":b="x10";break;case"VT200":b="vt200";break;case"DRAG":b="drag";break;case"ANY":b="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:b,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const b in S)this._publicOptions[b]=S[b]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,b=!0){this._core.input(S,b)}resize(S,b){this._verifyIntegers(S,b),this._core.resize(S,b)}open(S){this._core.open(S)}attachCustomKeyEventHandler(S){this._core.attachCustomKeyEventHandler(S)}attachCustomWheelEventHandler(S){this._core.attachCustomWheelEventHandler(S)}registerLinkProvider(S){return this._core.registerLinkProvider(S)}registerCharacterJoiner(S){return this._checkProposedApi(),this._core.registerCharacterJoiner(S)}deregisterCharacterJoiner(S){this._checkProposedApi(),this._core.deregisterCharacterJoiner(S)}registerMarker(S=0){return this._verifyIntegers(S),this._core.registerMarker(S)}registerDecoration(S){return this._checkProposedApi(),this._verifyPositiveIntegers(S.x??0,S.width??0,S.height??0),this._core.registerDecoration(S)}hasSelection(){return this._core.hasSelection()}select(S,b,_){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,b){this._verifyIntegers(S,b),this._core.selectLines(S,b)}dispose(){super.dispose()}scrollLines(S){this._verifyIntegers(S),this._core.scrollLines(S)}scrollPages(S){this._verifyIntegers(S),this._core.scrollPages(S)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(S){this._verifyIntegers(S),this._core.scrollToLine(S)}clear(){this._core.clear()}write(S,b){this._core.write(S,b)}writeln(S,b){this._core.write(S),this._core.write(`\r
|
|
68
|
+
`,b)}paste(S){this._core.paste(S)}refresh(S,b){this._verifyIntegers(S,b),this._core.refresh(S,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return c}_verifyIntegers(...S){for(const b of S)if(b===1/0||isNaN(b)||b%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const b of S)if(b&&(b===1/0||isNaN(b)||b%1!=0||b<0))throw new Error("This API only accepts positive integers")}}u.Terminal=C})(),l})()))})(tm)),tm.exports}var GN=VN();/**
|
|
69
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
70
|
+
* @license MIT
|
|
71
|
+
*
|
|
72
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
73
|
+
* @license MIT
|
|
74
|
+
*
|
|
75
|
+
* Originally forked from (with the author's permission):
|
|
76
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
77
|
+
* http://bellard.org/jslinux/
|
|
78
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
79
|
+
*/var WN=2,qN=1,KN=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let n=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(n._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var x;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:((x=this._terminal.options.overviewRuler)==null?void 0:x.width)||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),l=Math.max(0,parseInt(r.getPropertyValue("width"))),u=window.getComputedStyle(this._terminal.element),c={top:parseInt(u.getPropertyValue("padding-top")),bottom:parseInt(u.getPropertyValue("padding-bottom")),right:parseInt(u.getPropertyValue("padding-right")),left:parseInt(u.getPropertyValue("padding-left"))},d=c.top+c.bottom,f=c.right+c.left,p=o-d,m=l-f-n;return{cols:Math.max(WN,Math.floor(m/t.css.cell.width)),rows:Math.max(qN,Math.floor(p/t.css.cell.height))}}};function YN({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const o=A.useRef(null),l=A.useRef(e),u=A.useRef(null),c=A.useRef(null),d=Ar(p=>p.writeSession),f=Ar(p=>p.resizeSession);return A.useEffect(()=>{l.current=e},[e]),A.useEffect(()=>{if(!n)return;const p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),n())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),A.useEffect(()=>{if(!o.current)return;const p=new GN.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),m=new KN;p.loadAddon(m),u.current={term:p,fitAddon:m},o.current.addEventListener("keydown",C=>{C.key==="Escape"&&n&&(C.preventDefault(),C.stopPropagation(),n())}),p.open(o.current);const x=o.current.querySelector(".xterm");x&&(x.style.padding="8px"),m.fit(),r&&setTimeout(()=>{p.focus()},150);const y=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var v;m.fit&&m.fit();const C=(v=u.current)==null?void 0:v.term;C&&C.cols>0&&C.rows>0&&f(l.current,C.cols,C.rows)})},100)});y.observe(o.current),p.onData(C=>{if(C==="\x1B"&&n){n();return}d(l.current,C)}),p.onKey(C=>{C.key==="\x1B"&&n&&(C.domEvent.stopPropagation(),n())});const w=Xt.subscribe(C=>{const v=C.payload;if(C.type==="terminal.output"&&(v==null?void 0:v.sessionId)===l.current){const S=v==null?void 0:v.data;S&&p.write(S)}});return()=>{w(),y.disconnect(),c.current&&clearTimeout(c.current),p.dispose(),u.current=null}},[e,d,f]),a.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[a.jsx("div",{}),a.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:a.jsx(zS,{})})]}),a.jsx("div",{ref:o,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),n())}})]})}const n1="openfox-chat-textarea";function qm(){const e=document.getElementById(n1);e&&e.focus()}function XN(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 QN({isOpen:e,onClose:t}){const n=Ar(w=>w.createSession),r=Ar(w=>w.killSession),o=Ar(w=>w.sessions),l=Ar(w=>w.setWorkdir),u=Ar(w=>w.fetchSessions),c=Ut(w=>w.currentProject),[d,f]=A.useState(!0),p=A.useRef(null),m=A.useRef(!1),x=A.useRef(!1),y=A.useCallback(()=>{t()},[t]);return A.useEffect(()=>{c!=null&&c.workdir&&l(c.workdir)},[c==null?void 0:c.workdir,l]),A.useEffect(()=>{e?(f(!0),u(c==null?void 0:c.id).finally(()=>f(!1))):qm()},[e,u,c==null?void 0:c.id]),A.useEffect(()=>{e&&o.length===0&&!d&&!x.current&&(x.current=!0,n(void 0,c==null?void 0:c.id))},[e,o.length,d,n,c==null?void 0:c.id]),A.useEffect(()=>{e?(m.current=!0,setTimeout(()=>{var w;(w=p.current)==null||w.focus(),setTimeout(()=>{m.current=!1},200)},100)):x.current=!1},[e]),A.useEffect(()=>{if(!e)return;const w=C=>{m.current||C.key==="Escape"&&(C.preventDefault(),t())};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e,t]),e?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:y}),a.jsxs("div",{ref:p,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:w=>w.stopPropagation(),onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),y())},children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[a.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>n(void 0,c==null?void 0:c.id),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:a.jsx(nN,{})}),a.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:a.jsx(Xa,{})})]})]}),a.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:d?a.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):o.length===0?a.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"mb-4",children:"No terminal sessions"}),a.jsx("button",{onClick:()=>n(void 0,c==null?void 0:c.id),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):a.jsx("div",{className:`grid ${XN(o.length)} gap-2 h-full auto-rows-fr`,children:o.map(w=>a.jsx(YN,{sessionId:w.id,onClose:()=>r(w.id),onEscape:y,autoFocus:o.length===1},w.id))})})]})]}):null}function Ll({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",isOpen:o,onOpenChange:l}){const[u,c]=A.useState(!1),d=o!==void 0,f=d?o:u,p=M=>{if(d){const H=typeof M=="function"?M(u):M;l==null||l(H)}else c(M)},[m,x]=A.useState(null),y=A.useRef(null),w=A.useRef(null),[C,v]=A.useState(0),S=A.useRef(0),b=A.useMemo(()=>[...e,...t],[e,t]),_=A.useRef(b),j=A.useCallback(()=>{if(!y.current)return;const M=y.current.getBoundingClientRect(),H=200,U=window.innerHeight-M.bottom<H;x({top:U?M.top-H-4:M.bottom+4,left:M.left,alignToTop:U})},[]);A.useEffect(()=>{_.current=b},[b]),A.useEffect(()=>{function M(H){if(w.current){const V=H.target;w.current.contains(V)||p(!1)}}return f&&document.addEventListener("mousedown",M),()=>{document.removeEventListener("mousedown",M)}},[f]),A.useEffect(()=>{f&&j()},[f,j]),A.useEffect(()=>{if(!f)return;setTimeout(()=>{var H;(H=w.current)==null||H.focus()},0);function M(H){const V=_.current,U=V.filter(X=>!E(X)),Q=T(S.current,V);switch(H.key){case"ArrowDown":if(H.preventDefault(),H.stopPropagation(),Q<U.length-1){const X=D(S.current+1,V);S.current=X,v(X)}break;case"ArrowUp":if(H.preventDefault(),H.stopPropagation(),Q>0){const X=L(S.current-1,V);S.current=X,v(X)}break;case"Enter":H.preventDefault(),H.stopPropagation(),O(S.current,V);break;case"Escape":H.preventDefault(),H.stopPropagation(),p(!1);break}}return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[f,b]);function E(M){var U;const H=M.label;return H?String(((U=H.props)==null?void 0:U.className)??"").includes("cursor-default"):!1}function T(M,H){let V=0;for(let U=0;U<M;U++){const Q=H[U];Q&&!E(Q)&&V++}return V}function D(M,H){for(let V=M;V<H.length;V++){const U=H[V];if(U&&!E(U))return V}return M}function L(M,H){for(let V=M;V>=0;V--){const U=H[V];if(U&&!E(U))return V}return M}function O(M,H){var U;const V=H[M];!V||E(V)||((U=V.onClick)==null||U.call(V),V.href&&(window.history.pushState(null,"",V.href),window.dispatchEvent(new PopStateEvent("popstate"))),p(!1))}A.useEffect(()=>{f&&(v(b.findIndex(M=>!E(M))),S.current=b.findIndex(M=>!E(M)))},[f,b]);const P=M=>{M.stopPropagation(),f||j(),p(!f)};function q(M,H,V,U){const X=!E(M)&&U===C,z=a.jsxs(a.Fragment,{children:[M.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:M.icon}),M.label]}),R=H!==V-1;return M.href?a.jsx(or,{href:M.href,onClick:I=>{var G;(G=M.onClick)==null||G.call(M,I),p(!1)},onAuxClick:()=>p(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${M.danger?"text-accent-error hover:bg-accent-error/10":X?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${R?"border-b border-border":""}`,children:z},U):a.jsx("button",{onClick:I=>{var G;(G=M.onClick)==null||G.call(M,I),M.closeOnClick!==!1&&p(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${M.danger?"text-accent-error hover:bg-accent-error/10":X?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${R?"border-b border-border":""}`,children:z},U)}const W=m&&a.jsxs("div",{ref:w,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${m.alignToTop?"mb-1":"mt-1"}`,style:{top:m.top,left:m.left,minWidth:r},tabIndex:-1,children:[a.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.map((M,H)=>q(M,H,e.length,H))}),t.length>0&&a.jsx("div",{className:"border-t border-border",children:t.map((M,H)=>q(M,H,t.length,e.length+H))})]});return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"relative",children:a.jsx("div",{ref:y,onClick:P,children:n})}),f&&Qa.createPortal(W,document.body)]})}function JN(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 r1({isOpen:e,onClose:t,path:n,onRetry:r}){const[o,l]=A.useState(!1),[u,c]=A.useState(null),[d,f]=A.useState(null);A.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const j=await(await ke("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();f({sudoAvailable:j.sudoAvailable,userInGroup:j.userInGroup,groupHasWrite:j.groupHasWrite,groupName:j.groupName||null})}catch{f({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=A.useCallback(async _=>{l(!0),c(null);try{const E=await(await ke("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:_})})).json();E.success?(r(),t()):E.sudoAvailable?c("Failed to fix permissions: "+(E.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
|
|
80
|
+
|
|
81
|
+
`+(_==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(j){c("Failed to fix permissions: "+(j instanceof Error?j.message:"Unknown error"))}finally{l(!1)}},[n,r,t]),x=(d==null?void 0:d.userInGroup)??!1,y=(d==null?void 0:d.groupHasWrite)??!1,w=(d==null?void 0:d.sudoAvailable)??!1,C=(d==null?void 0:d.groupName)??"",v=x&&!y,S=!x&&y,b=!x&&!y;return a.jsx(Ot,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"text-sm text-text-secondary",children:[a.jsx("p",{children:v?a.jsxs(a.Fragment,{children:["The group ",a.jsx("strong",{children:C})," doesn't have write access:"]}):S?a.jsxs(a.Fragment,{children:["You're not a member of group ",a.jsx("strong",{children:C}),":"]}):a.jsxs(a.Fragment,{children:["You're not a member of group ",a.jsx("strong",{children:C})," and it doesn't have write access:"]})}),a.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),u?a.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:u}):d?a.jsxs("div",{className:"flex flex-col gap-2",children:[v&&a.jsxs(a.Fragment,{children:[a.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:o||!w,className:"w-full",children:o?"Granting access...":"Extend group permissions"}),a.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),a.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&a.jsxs(a.Fragment,{children:[a.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:o||!w,className:"w-full",children:o?"Joining group...":"Join group"}),a.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),a.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),b&&a.jsxs(a.Fragment,{children:[a.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("join_group_and_group"),disabled:o||!w,className:"w-full",children:o?"Joining group...":"Join group & grant write permissions"}),a.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),a.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",a.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!u&&a.jsxs("div",{className:"text-xs text-text-secondary",children:[a.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),a.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),a.jsx("div",{className:"flex justify-end",children:a.jsx(rt,{type:"button",variant:"secondary",onClick:t,disabled:o,children:"Cancel"})})]}):null]})})}function s1({isOpen:e,onClose:t}){const[,n]=Gn(),r=Ut(E=>E.listProjects),[o,l]=A.useState(""),[u,c]=A.useState(null),[d,f]=A.useState(!1),[p,m]=A.useState(""),[x,y]=A.useState(null),w=A.useRef(null);A.useEffect(()=>{e&&(ke("/api/config").then(E=>E.json()).then(E=>{E.workdir&&m(E.workdir)}),l(""),c(null),f(!1),y(null),setTimeout(()=>{var E;(E=w.current)==null||E.focus()},100))},[e]);const C=A.useCallback(async E=>{E.preventDefault();const T=JN(o);if(!T.valid){c(T.error);return}const D=`${p}/${o}`;await b(D)},[o,n,t,p]),v=A.useCallback(()=>{y(null)},[]),S=A.useCallback(async()=>{const E=`${p}/${o}`;await b(E)},[p,o,n,t,y,c,f]);async function b(E){f(!0),c(null),y(null);try{const T=await ke("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o,workdir:E})});if(!T.ok){const O=await T.json().catch(()=>({}));if(O.code==="EACCES"){y(E),f(!1);return}throw new Error(O.error||"Failed to create project")}const L=(await T.json()).project;t(),await r(),n(`/p/${L.id}`)}catch(T){c(T instanceof Error?T.message:"Failed to create project"),f(!1)}}const _=A.useCallback(()=>{l(""),c(null),t()},[t]),j=o?`${p}/${o}`:"";return a.jsxs(a.Fragment,{children:[a.jsx(Ot,{isOpen:e,onClose:_,title:"Create New Project",size:"sm",children:a.jsxs("form",{onSubmit:C,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),a.jsx(Ii,{ref:w,id:"project-name",value:o,onChange:E=>{l(E.target.value),c(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),o&&a.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",a.jsx("span",{className:"font-mono",children:j})]}),u&&a.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(rt,{type:"button",variant:"secondary",onClick:_,disabled:d,children:"Cancel"}),a.jsx(rt,{type:"submit",variant:"primary",disabled:d||!o.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(ti,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),x&&a.jsx(r1,{isOpen:!!x,onClose:v,path:x,onRetry:S})]})}function i1(){const[e,t]=A.useState(null);return A.useEffect(()=>{ke("/api/config").then(n=>n.json()).then(n=>{n.workdir&&t(n.workdir)})},[]),e}function av({projects:e,currentProject:t}){const[,n]=Gn(),r=Ut(v=>v.loadProject),o=Ut(v=>v.toggleStar),l=Ut(v=>v.createProject),u=Ut(v=>v.listProjects),[c,d]=A.useState(!1),[f,p]=A.useState(!1),m=i1(),x=A.useCallback(async v=>{const S=XS(v),b=await l(S,v);return b&&"id"in b?(await u(),p(!1),n(`/p/${b.id}`),!0):!1},[l,u,n]),w=A.useMemo(()=>{const v=e.filter(b=>b.isStarred).sort((b,_)=>b.name.localeCompare(_.name)),S=e.filter(b=>!b.isStarred).sort((b,_)=>b.name.localeCompare(_.name));return[...v,...S]},[e]).map(v=>({label:a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[a.jsx("span",{className:"truncate flex-1",children:v.name}),a.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),o(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?a.jsx(PS,{className:"w-3.5 h-3.5 text-yellow-500"}):a.jsx(BS,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:v.id===(t==null?void 0:t.id)?a.jsx(Wr,{}):void 0,href:`/p/${v.id}`,closeOnClick:!0,onClick:()=>{r(v.id)}})),C=[{label:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Tl,{className:"w-4 h-4"}),a.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:a.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[a.jsx(ti,{className:"w-4 h-4"}),a.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return a.jsxs(a.Fragment,{children:[a.jsx(Ll,{items:w,footerItems:C,trigger:a.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)??a.jsx("span",{className:"text-text-muted",children:"Select project..."}),a.jsx(Wn,{})]}),minWidth:"250px"}),c&&a.jsx(s1,{isOpen:c,onClose:()=>d(!1)}),f&&a.jsx(sd,{initialPath:m??void 0,onSelect:x,onClose:()=>p(!1)})]})}function a1(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],o=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0");return`${r} ${o}/${l}/${u}`}function id(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function ZN(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),o=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=Math.floor((r.getTime()-o.getTime())/(1e3*60*60*24)),u=id(e);if(l===0)return`today ${u}`;if(l===1)return`yesterday ${u}`;if(l<7)return`${l} days ago ${u}`;{const c=t.getFullYear(),d=String(t.getMonth()+1).padStart(2,"0"),f=String(t.getDate()).padStart(2,"0");return`${c}/${d}/${f} ${u}`}}function o1(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 eT(e){const{year:t,month:n,day:r}=o1(e);return`${t}-${n}-${r}`}function l1(e){const t=new Map;for(const o of e){const l=eT(o.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(o)}for(const[o,l]of t)l.sort((u,c)=>{const d=new Date(u.updatedAt).getTime();return new Date(c.updatedAt).getTime()-d});const n=Array.from(t.keys()).sort((o,l)=>l.localeCompare(o)),r=new Map;for(const o of n)r.set(o,t.get(o));return r}function tT({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:o}){var p;const l=Le(m=>m.loadSession),u=e.filter(m=>m.projectId===t.id).slice(0,15),c=l1(u),d=A.useMemo(()=>{const m=[];m.push({label:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ti,{className:"w-4 h-4 text-accent-primary"}),a.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[x,y]of c){const w=y[0];if(w){m.push({label:a.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:a1(w.updatedAt)}),onClick:()=>{}});for(const C of y)m.push({label:a.jsxs("div",{className:"min-w-[160px]",children:[a.jsx("div",{className:"truncate text-sm",children:C.title??C.id.slice(0,8)}),a.jsx("div",{className:"text-text-muted text-xs",children:id(C.updatedAt)})]}),icon:C.id===(n==null?void 0:n.id)?a.jsx(Wr,{}):void 0,href:`/p/${t.id}/s/${C.id}`,onClick:()=>{l(C.id)}})}}return m},[t.id,c,n==null?void 0:n.id]),f=n?((p=n.metadata)==null?void 0:p.title)??n.id.slice(0,8):"No session selected";return a.jsx(Ll,{items:d,isOpen:r,onOpenChange:o,trigger:a.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:f,"data-testid":"header-session-dropdown",children:[f,a.jsx(Wn,{})]}),minWidth:"280px"})}function nT({items:e,trigger:t,isActive:n=!1}){const[r,o]=A.useState(!1),l=A.useRef(null);return A.useEffect(()=>{function u(c){l.current&&!l.current.contains(c.target)&&o(!1)}if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),a.jsxs("div",{className:"relative",ref:l,children:[a.jsxs("button",{type:"button",onClick:()=>o(!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"?a.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,a.jsx(Wn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&a.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((u,c)=>{const d=u.label&&typeof u.label=="object"&&u.label.type===or?u.label:null;if(d){const f=d.props.href||"";return a.jsxs(or,{href:f,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,d.props.children]},c)}return u.href?a.jsxs("a",{href:u.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c):a.jsxs("button",{type:"button",onClick:()=>{var f;(f=u.onClick)==null||f.call(u),o(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c)})})]})}function rT({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const o=t.filter(u=>u.projectId===e.id).sort((u,c)=>new Date(c.updatedAt).getTime()-new Date(u.updatedAt).getTime()).slice(0,5),l=[{label:a.jsxs(or,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[a.jsx(ti,{className:"w-3 h-3 text-accent-primary"}),a.jsx("span",{className:"text-sm",children:"New Session"})]})},...o.map(u=>({label:a.jsx(or,{href:`/p/${e.id}/s/${u.id}`,className:"flex items-center gap-2 truncate text-sm",children:a.jsx("span",{children:u.title??u.id.slice(0,8)})}),icon:u.id===(n==null?void 0:n.id)?a.jsx(Wr,{className:"w-3 h-3"}):void 0})),{label:a.jsxs(or,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[a.jsx(qj,{className:"w-3 h-3"}),a.jsx("span",{className:"text-sm",children:"Projects"})]})}];return a.jsx(nT,{items:l,trigger:a.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function sT({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=A.useState(!1),[o,l]=A.useState(!1),[u,c]=A.useState(!!document.fullscreenElement),[d,f]=Gn();A.useEffect(()=>{const E=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",E),()=>document.removeEventListener("fullscreenchange",E)},[]);const p=d.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),x=Le(E=>E.currentSession),y=Le(E=>E.sessions),w=Ut(E=>E.currentProject),C=Ut(E=>E.projects),v=un(E=>E.startAutoRefresh),S=un(E=>E.stopAutoRefresh),b=Ar(E=>E.setOpen),_=Ar(E=>E.isOpen);A.useEffect(()=>{const E=()=>l(!0);return window.addEventListener("open-session-dropdown",E),()=>window.removeEventListener("open-session-dropdown",E)},[]);const j=Rp();return VS(j.terminalToggle,()=>{Ar.getState().toggleOpen()},{capture:!0}),A.useEffect(()=>(v(),()=>S()),[v,S]),a.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&m&&a.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle session list",children:a.jsx(Yb,{})}),a.jsx(or,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),w&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),a.jsx("span",{className:"hidden md:inline",children:a.jsx(av,{projects:C,currentProject:w})}),a.jsx("span",{className:"md:hidden",children:a.jsx(rT,{currentProject:w,sessions:y,currentSession:x,projectIdFromUrl:p&&d.split("/")[2]||null},w==null?void 0:w.id)}),a.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),a.jsx("span",{className:"hidden md:inline",children:a.jsx(tT,{sessions:y,currentProject:w,currentSession:x,isOpen:o,onOpenChange:l})})]}),!w&&a.jsx("span",{className:"hidden md:inline",children:a.jsx(av,{projects:C})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&a.jsx("button",{onClick:()=>{var E,T,D;document.fullscreenElement?(E=document.exitFullscreen)==null||E.call(document):(D=(T=document.documentElement).requestFullscreen)==null||D.call(T)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:u?"Exit fullscreen":"Enter fullscreen",children:u?a.jsx(Xj,{}):a.jsx(Qj,{})}),p&&a.jsx("button",{onClick:()=>b(!_),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${_?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:a.jsx(aN,{})}),a.jsx("button",{onClick:()=>r(!0),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Settings",children:a.jsx(rN,{})}),a.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),f("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:a.jsx(Zj,{})}),t&&m&&a.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle sidebar",children:a.jsx(Yb,{})})]}),a.jsx(FN,{isOpen:n,onClose:()=>r(!1)}),a.jsx(QN,{isOpen:_,onClose:()=>b(!1)})]})}function iT({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:o="Cancel",saveLabel:l=n?"Saving...":"Save"}){return a.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[a.jsx(rt,{variant:"secondary",onClick:e,children:o}),a.jsx(rt,{variant:"primary",onClick:t,disabled:r??n,children:l})]})}const tu=qn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await ke(`/api/worktree/config?workdir=${encodeURIComponent(t)}`)).json();e({config:r.config??null,loading:!1})}catch{e({loading:!1})}},saveConfig:async(t,n)=>{const r=await ke(`/api/worktree/config?workdir=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error("Failed to save worktree config");const o=await r.json();e({config:o.config??n})}}));function aT({isOpen:e,onClose:t,project:n}){const r=Ut(R=>R.updateProject),o=tu(R=>R.config),l=tu(R=>R.loading),u=tu(R=>R.fetchConfig),c=tu(R=>R.saveConfig),d=()=>{try{Xt.send("context.checkDynamic",{})}catch{}t()},[f,p]=A.useState(n.customInstructions??""),[m,x]=A.useState(n.dangerLevel??""),[y,w]=A.useState(!1),[C,v]=A.useState(!1),[S,b]=A.useState(!1),[_,j]=A.useState(null),[E,T]=A.useState("skip"),[D,L]=A.useState([]),[O,P]=A.useState(!1),q=y||C||O;A.useEffect(()=>{e&&(p(n.customInstructions??""),x(n.dangerLevel??""),w(!1),v(!1),P(!1),u(n.workdir))},[e,n,u]),A.useEffect(()=>{o?(T(o.ignoredAssets),L(Object.entries(o.overrides??{}).map(([R,I])=>({path:R,strategy:I})))):(T("skip"),L([]))},[o]);const W=R=>{p(R.target.value),w(!0)},M=R=>{x(R),v(!0)},H=R=>{T(R),P(!0)},V=(R,I,G)=>{L(B=>{const ee=[...B];return ee[R]&&(ee[R]={...ee[R],[I]:G}),ee}),P(!0)},U=()=>{L(R=>[...R,{path:"",strategy:"symlink"}]),P(!0)},Q=R=>{L(I=>I.filter((G,B)=>B!==R)),P(!0)},X=async()=>{b(!0),j(null);try{const R=m===""?null:m;if(await r(n.id,{customInstructions:f||null,dangerLevel:R}),O){const I={};for(const G of D)G.path.trim()&&(I[G.path.trim()]=G.strategy);await c(n.workdir,{ignoredAssets:E,overrides:Object.keys(I).length>0?I:void 0})}w(!1),v(!1),P(!1),d()}catch(R){j(R instanceof Error?R.message:"Failed to save settings")}finally{b(!1)}},z=()=>{p(n.customInstructions??""),x(n.dangerLevel??""),w(!1),v(!1),P(!1),d()};return a.jsx(Ot,{isOpen:e,onClose:z,title:`${n.name} Settings`,size:"lg",footer:a.jsx(iT,{onCancel:z,onSave:X,saving:S,saveDisabled:!q||S}),children:a.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),a.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."}),a.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[a.jsx("button",{type:"button",onClick:()=>M(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m===""?"bg-bg-tertiary text-text-primary border border-border":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Use global default (Normal)",children:"Default"}),a.jsx("button",{type:"button",onClick:()=>M("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="normal"?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),a.jsx("button",{type:"button",onClick:()=>M("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="dangerous"?"bg-red-500/20 text-red-400 border border-red-500/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),a.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),a.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."}),a.jsx("textarea",{value:f,onChange:W,placeholder:"Enter project-specific instructions...",className:"w-full h-32 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:S})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Worktree Asset Strategy"}),a.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Controls how .gitignored files (e.g. node_modules) are handled when creating a worktree. Symlink is fast and saves disk space. Copy works when tools don't follow symlinks."}),l&&a.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),a.jsx("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit mb-4",children:["skip","symlink","copy"].map(R=>a.jsx("button",{type:"button",onClick:()=>H(R),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${E===R?"bg-bg-tertiary text-text-primary border border-border":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,children:R.charAt(0).toUpperCase()+R.slice(1)},R))}),a.jsx("label",{className:"block text-xs font-medium text-text-secondary mb-1",children:"Per-path overrides"}),a.jsxs("div",{className:"space-y-2",children:[D.map((R,I)=>a.jsxs("div",{className:`flex items-center gap-2 ${R.path.trim()?"":"opacity-50"}`,children:[a.jsx("input",{type:"text",value:R.path,onChange:G=>V(I,"path",G.target.value),placeholder:"e.g. node_modules",className:"input flex-1 text-sm"}),a.jsxs("select",{value:R.strategy,onChange:G=>V(I,"strategy",G.target.value),className:"input w-28 text-sm",children:[a.jsx("option",{value:"symlink",children:"Symlink"}),a.jsx("option",{value:"copy",children:"Copy"}),a.jsx("option",{value:"skip",children:"Skip"})]}),a.jsx("button",{type:"button",onClick:()=>Q(I),className:"text-text-muted hover:text-red-400 text-sm px-1",children:"✕"})]},I)),a.jsx("button",{type:"button",onClick:U,className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add override"})]})]}),_&&a.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:_})]})})}const oT={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},lT="M6 18L18 6M6 6l12 12";function Dl({onClick:e,className:t="",size:n="md",variant:r="default"}){const o=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 a.jsx(td,{onClick:e,icon:lT,iconSize:oT[n],className:`${o} ${t}`,title:"Close"})}function c1({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Gn(),[o,l]=A.useState(!1),u=Le(E=>E.sessions),c=Le(E=>E.currentSession),d=Le(E=>E.unreadSessionIds),f=Le(E=>E.deleteSession),p=Le(E=>E.deleteAllSessions),m=Le(E=>E.loadMoreSessions),x=Le(E=>E.sessionsHasMore),y=Le(E=>E.sessionsPaginationLoading),w=Ut(E=>E.currentProject),C=A.useRef(null),v=A.useCallback(()=>{x&&!y&&w&&m(w.id)},[x,y,w,m]);A.useEffect(()=>{if(!C.current||!x)return;const E=new IntersectionObserver(T=>{const D=T[0];D&&D.isIntersecting&&v()},{threshold:.1});return E.observe(C.current),()=>E.disconnect()},[x,v]);const S=u.filter(E=>E.projectId===(w==null?void 0:w.id)),b=(E,T)=>{T==null||T.stopPropagation(),confirm("Delete this session?")&&(f(E),(c==null?void 0:c.id)===E&&r(`/p/${e}`))},_=(E,T)=>{T==null||T.stopPropagation();const D=u.find(P=>P.id===E),L=(D==null?void 0:D.title)??E.slice(0,6),O=prompt("Rename session:",L);if(O!==null&&O.trim()!==""){const P=Le.getState().renameSession;P(E,O.trim())}},j=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(p(e),r(`/p/${e}`))};return a.jsxs(a.Fragment,{children:[t&&n&&a.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),a.jsxs("aside",{className:`
|
|
82
|
+
${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
|
|
83
|
+
md:relative md:h-auto md:translate-x-0
|
|
84
|
+
|
|
85
|
+
fixed z-50 h-[calc(100vh-32px)]
|
|
86
|
+
w-[300px] bg-secondary border-r border-border flex flex-col
|
|
87
|
+
transition-all duration-300 ease-in-out
|
|
88
|
+
${t?"translate-x-0":"-translate-x-full"}
|
|
89
|
+
`,children:[a.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[a.jsx(or,{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"}),a.jsx(Ll,{items:[{label:"Edit project settings",onClick:()=>l(!0)},{label:"Delete all sessions",onClick:j,danger:!0}],trigger:a.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:a.jsx(Lp,{})})}),n&&a.jsx(Dl,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),w&&a.jsx(aT,{isOpen:o,onClose:()=>l(!1),project:w}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:S.length===0?a.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"divide-y divide-border",children:cT(S,c,d,b,_,e)}),y&&a.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),a.jsx("div",{ref:C,className:"h-px"})]})})]})]})}function cT(e,t,n,r,o,l){const u=l1(e);return Array.from(u).map(([c,d])=>{const f=d[0];return f?a.jsxs("div",{children:[a.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:a1(f.updatedAt)}),d.map(p=>{const m=(t==null?void 0:t.id)===p.id,x=n.includes(p.id),y=p.isRunning;return a.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${m?"bg-bg-tertiary":""}`,children:a.jsxs(or,{href:`/p/${l}/s/${p.id}`,className:`block ${m?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[a.jsxs("div",{className:"flex justify-between items-center mb-1",children:[a.jsx("span",{className:`font-medium truncate text-sm ${m?"text-accent-primary":"text-text-primary"}`,children:p.title??p.id.slice(0,6)}),a.jsx(Ll,{items:[{label:"Rename session",onClick:w=>o(p.id,w)},{label:"Delete session",onClick:w=>r(p.id,w),danger:!0}],trigger:a.jsx("button",{onClick:w=>w.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:a.jsx(Lp,{})})})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[y?a.jsx(sN,{}):x&&!m?a.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,a.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:id(p.updatedAt)}),a.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[p.messageCount," messages"]})]})]})},p.id)})]},c):null})}const ov=["⠋","⠙","⠹","⠸","⠼","⠴"];function uT(){var c;const e=Ut(d=>d.currentProject),t=Le(d=>d.currentSession),n=ed(),r=!1,o=A.useRef(0),l=A.useRef(null);A.useEffect(()=>(n?(l.current=window.setInterval(()=>{o.current=(o.current+1)%ov.length,u()},150),u()):(l.current&&(clearInterval(l.current),l.current=null),u()),()=>{l.current&&(clearInterval(l.current),l.current=null)}),[n,e,t,r]);const u=()=>{var m;const f=(m=t==null?void 0:t.metadata)==null?void 0:m.title,p=n?`${ov[o.current]} `:"";e&&f?document.title=`${p}${e.name} - ${f} | OpenFox`:e?document.title=`${p}${e.name} | OpenFox`:document.title=`${p}OpenFox`};return typeof window<"u"&&((c=t==null?void 0:t.metadata)!=null&&c.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function u1({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const o=()=>{r(),t()};return a.jsx(Ot,{isOpen:e,onClose:t,title:"Delete Project",size:"sm",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project"," ",a.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(rt,{variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(rt,{variant:"danger",onClick:o,children:"Delete"})]})]})})}function dT({isOpen:e,onClose:t}){const[,n]=Gn(),[r,o]=A.useState(!1),l=i1(),[u,c]=A.useState(!1),d=Ut(L=>L.projects),f=Ut(L=>L.createProject),p=Ut(L=>L.listProjects),m=Ut(L=>L.deleteProject),[x,y]=A.useState(null),[w,C]=A.useState(null);A.useEffect(()=>{e&&p()},[e,p]);const v=L=>{n(`/p/${L}`),t()},S=(L,O)=>{O.stopPropagation(),y(L)},b=()=>{x&&(m(x.id),y(null))},_=async L=>E(L);function j(L){return L!=null&&typeof L=="object"&&"error"in L&&L.error!=null&&typeof L.error=="object"&&"code"in L.error&&L.error.code==="EACCES"}async function E(L){const O=XS(L),P=await f(O,L);return p(),j(P)?(C(P.error.path||L),!1):P&&"id"in P?(n(`/p/${P.id}`),t(),!0):!1}const T=A.useCallback(()=>{C(null)},[]),D=A.useCallback(async()=>{const L=w;C(null),L&&await E(L)},[w]);return e?a.jsxs(Ot,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(rt,{variant:"secondary",onClick:t,children:"Close"})}),children:[a.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[a.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:[a.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:a.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:d.length===0?a.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[a.jsx("p",{className:"mb-2",children:"No recent projects"}),a.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):a.jsx("div",{className:"divide-y divide-border",children:d.map(L=>a.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[a.jsxs("button",{onClick:()=>v(L.id),className:"flex-1 flex items-center gap-3 text-left",children:[a.jsx(Tl,{className:"w-5 h-5 text-accent-primary"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"font-medium truncate",children:L.name}),a.jsx("div",{className:"text-xs text-text-muted truncate",children:QS(L.workdir,32)})]})]}),a.jsx("button",{onClick:O=>S(L,O),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:a.jsx(Ya,{className:"w-4 h-4"})})]},L.id))})})]}),a.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:a.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[a.jsx(rt,{variant:"primary",onClick:()=>c(!0),children:"Select existing project"}),a.jsx(rt,{variant:"secondary",onClick:()=>o(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&a.jsx(s1,{isOpen:r,onClose:()=>o(!1)}),x&&a.jsx(u1,{isOpen:!0,onClose:()=>y(null),projectName:x.name,onConfirm:b}),u&&a.jsx(sd,{initialPath:l??void 0,onSelect:L=>{_(L)},onClose:()=>c(!1)}),w&&a.jsx(r1,{isOpen:!0,onClose:T,path:w,onRetry:D})]}):null}function Vr(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function za(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(o=>{for(const l of r){let u=0;for(let c=0;c<l.length&&u<o.length;c++)l[c]===o[u]&&u++;if(u===o.length)return!0}return!1})}function d1(e,t,n,r,o){switch(e.key){case"ArrowDown":e.preventDefault(),n(l=>Math.min(l+1,t));break;case"ArrowUp":e.preventDefault(),n(l=>Math.max(l-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),o();break}}function lv(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),o=new Array(e.length).fill(!1),l=n.indexOf(r);if(l>=0)for(let f=l;f<l+r.length;f++)o[f]=!0;else{let f=0;for(let p=0;p<e.length&&f<r.length;p++)n[p]===r[f]&&(o[p]=!0,f++)}const u=[];let c="",d=o[0]??!1;for(let f=0;f<e.length;f++)o[f]===d?c+=e[f]:(u.push(d?a.jsx("span",{className:"font-semibold text-accent-primary",children:c},u.length):c),c=e[f],d=o[f]);return u.push(d?a.jsx("span",{className:"font-semibold text-accent-primary",children:c},u.length):c),a.jsx(a.Fragment,{children:u})}function hT(){const[e,t]=A.useState(!1),[n,r]=A.useState(null),[o,l]=A.useState(""),[u,c]=A.useState(""),d=A.useRef(null),f=Le(H=>H.sessions),p=Ut(H=>H.projects),m=Ut(H=>H.loading),x=Ut(H=>H.listProjects),y=Le(H=>H.listSessions),w=Ut(H=>H.deleteProject),C=Le(H=>H.connectionStatus);A.useEffect(()=>{C==="connected"&&(x(),y())},[C,x,y]),A.useEffect(()=>{const H=setTimeout(()=>c(o),150);return()=>clearTimeout(H)},[o]);const{matchCount:v,filteredSessionIds:S,relevanceScores:b,matchTypes:_,promptSnippets:j}=A.useMemo(()=>{if(!u)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const H=new Map(p.map(z=>[z.id,z])),V=new Map,U=new Map,Q=new Map,X=f.filter(z=>{var K;const R=H.get(z.projectId),I=(R==null?void 0:R.name)??"",G=z.title??"",B=((K=z.recentUserPrompts)==null?void 0:K.map(F=>F.content))??[],ee=B.join(" ");let J=0,ne="";if(za(G,u)&&(J+=10,ne="title"),za(ee,u)){J+=3,ne=ne==="title"?"title":"prompts";const F=B.find(te=>za(te,u));if(F){const te=F.toLowerCase().indexOf(u.toLowerCase());if(te>=0){const re=Math.max(0,te-30),pe=Math.min(F.length,te+u.length+30);Q.set(z.id,(re>0?"…":"")+F.slice(re,pe)+(pe<F.length?"…":""))}else Q.set(z.id,F.slice(0,80)+(F.length>80?"…":""))}}return za(I,u)&&(J+=1,ne=ne||"project"),V.set(z.id,J),U.set(z.id,ne),J>0});return{matchCount:X.length,filteredSessionIds:new Set(X.map(z=>z.id)),relevanceScores:V,matchTypes:U,promptSnippets:Q}},[f,u,p]),E=A.useMemo(()=>{const H=new Map;for(const V of f){const U=new Date(V.updatedAt).getTime(),Q=H.get(V.projectId)??0;U>Q&&H.set(V.projectId,U)}return H},[f]),T=A.useMemo(()=>{const H=new Map;for(const V of f){const U=H.get(V.projectId);U?U.push(V):H.set(V.projectId,[V])}for(const[,V]of H)V.sort((U,Q)=>new Date(Q.updatedAt).getTime()-new Date(U.updatedAt).getTime());return H},[f]),D=A.useMemo(()=>{let H=p;return u&&S&&(H=p.filter(V=>{const U=T.get(V.id);return U==null?void 0:U.some(Q=>S.has(Q.id))})),[...H].sort((V,U)=>{const Q=E.get(V.id)??new Date(V.updatedAt).getTime();return(E.get(U.id)??new Date(U.updatedAt).getTime())-Q})},[p,T,u,S,E]),L=A.useCallback(H=>{const V=T.get(H);return V?u&&S&&b?V.filter(U=>S.has(U.id)).sort((U,Q)=>{const X=(b.get(Q.id)??0)-(b.get(U.id)??0);return X!==0?X:new Date(Q.updatedAt).getTime()-new Date(U.updatedAt).getTime()}):V.slice(0,5):[]},[T,u,S,b]),O=()=>{t(!0)},P=()=>{var H;l(""),c(""),(H=d.current)==null||H.focus()},q=H=>{var V;H.key==="Escape"&&(P(),(V=d.current)==null||V.blur())},W=u.length>0,M=W&&v===0;return a.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[a.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),a.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),a.jsx(rt,{variant:"primary",onClick:O,children:"Open Project"})]}),f.length>0&&a.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[a.jsxs("div",{className:"relative flex items-center",children:[a.jsx(yl,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),a.jsx("input",{ref:d,type:"text",value:o,onChange:H=>l(H.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"}),o&&a.jsx("button",{type:"button",onClick:P,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:a.jsx(Xa,{className:"w-4 h-4"})})]}),W&&!M&&a.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[v," ",v===1?"match":"matches"]})]}),M?a.jsxs("div",{className:"text-center py-16 text-text-muted",children:[a.jsx(yl,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),a.jsxs("p",{className:"text-lg",children:["No sessions matching ",a.jsxs("span",{className:"text-text-primary font-medium",children:["“",u,"”"]})]}),a.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):D.map(H=>{const V=L(H.id);return a.jsx("div",{className:"mb-6 md:mb-8",children:a.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[a.jsxs(or,{href:`/p/${H.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[a.jsx(Tl,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),a.jsx("span",{className:"text-text-primary font-semibold",children:H.name})]}),a.jsx(or,{href:`/p/${H.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"}),a.jsx("button",{type:"button",onClick:()=>r({id:H.id,name:H.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:a.jsx(Ya,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"divide-y divide-border",children:V.length>0?V.map(U=>{const Q=p.find(I=>U.projectId===I.id),X=Q?`/p/${Q.id}/s/${U.id}`:"#",z=U.title??U.id.slice(0,8),R=_==null?void 0:_.get(U.id);return a.jsx(or,{href:X,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm text-text-muted truncate",children:W&&R==="title"?lv(z,u):z}),W&&R&&R!=="title"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[a.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:R==="prompts"?"prompts":"project"}),R==="prompts"&&(j==null?void 0:j.get(U.id))&&a.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:lv(j.get(U.id),u)})]})]})}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{className:"text-text-muted text-xs",children:ZN(U.updatedAt)}),a.jsxs("span",{className:"text-text-muted text-xs",children:[U.messageCount," msgs"]})]})]})},U.id)}):a.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},H.id)}),!W&&D.length===0&&!m&&a.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),m&&a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ni,{})})]}),e&&a.jsx(dT,{isOpen:e,onClose:()=>t(!1)}),n&&a.jsx(u1,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>w(n.id)})]})}function fT(){const[,e]=Ka("/p/:projectId/new"),[,t]=Gn(),n=e==null?void 0:e.projectId,r=Le(u=>u.createSession),o=Le(u=>u.resetPendingSessionCreate),l=A.useCallback(async()=>{if(!n)return;const u=await r(n);u?(t(`/p/${n}/s/${u.id}`),o()):(t(`/p/${n}`),o())},[n,r,t,o]);return A.useEffect(()=>{l()},[l]),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx(ni,{})})}function mT(){const e=Ut(t=>t.currentProject);return a.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:a.jsxs("div",{className:"max-w-md",children:[a.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),a.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),a.jsxs("div",{className:"flex flex-col gap-3",children:[e&&a.jsx(or,{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"}),a.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const Qo=e=>Math.round(e*10)/10;function pT(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function Km(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function gT(e){return`${e.providerId}::${e.model}`}function xT(e){return`${e.providerName} > ${e.model}`}function cv(e){let t=0,n=0,r=0,o=0,l=0,u=0;const c=[],d=[];let f=0;for(const[x,y]of e.entries()){const w=y.stats,C=Km(w);t+=w.totalTime,n+=w.toolTime,r+=w.prefillTokens,o+=w.generationTokens;const v=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;l+=v,u+=S,c.push({messageId:y.id,timestamp:y.timestamp,...C,mode:w.mode,responseIndex:x+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const b=w.llmCalls??[];for(const _ of b)f+=1,d.push({messageId:y.id,timestamp:_.timestamp??y.timestamp,providerId:_.providerId,providerName:_.providerName,backend:_.backend,model:_.model,mode:w.mode,responseIndex:x+1,sessionCallIndex:f,callIndex:_.callIndex,promptTokens:_.promptTokens,completionTokens:_.completionTokens,ttft:_.ttft,completionTime:_.completionTime,prefillSpeed:_.prefillSpeed,generationSpeed:_.generationSpeed,totalTime:_.totalTime,..._.temperature!==void 0&&{temperature:_.temperature},..._.topP!==void 0&&{topP:_.topP},..._.topK!==void 0&&{topK:_.topK},..._.maxTokens!==void 0&&{maxTokens:_.maxTokens}})}const p=l>0?Qo(r/l):0,m=u>0?Qo(o/u):0;return{totalTime:Qo(t),aiTime:Qo(t-n),toolTime:Qo(n),prefillTokens:r,generationTokens:o,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:c,callDataPoints:d}}function yT(e){const t=e.filter(o=>o.stats!==void 0&&o.stats!==null&&pT(o.stats)).sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const o of t){const l=gT(Km(o.stats)),u=n.get(l)??[];n.set(l,[...u,o])}const r=Array.from(n.entries()).map(([o,l])=>{const u=Km(l[0].stats),c=cv(l);return{...u,key:o,label:xT(u),...c}});return{...cv(t),modelGroups:r}}function _T(e){return A.useMemo(()=>yT(e),[e])}function h1(){var o;const e=Le(l=>l.gitStatus),t=Le(l=>l.currentSession),[n,r]=A.useState(!0);return A.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((o=e==null?void 0:e.diff)==null?void 0:o.files)??[],loading:n,error:null}}}function Tu(e){return e.toLocaleString("en-US").replace(/,/g," ")}function uv(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function bT(e){if(!Number.isFinite(e))return"0s";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=Math.round(e%60);return`${t}m${n}s`}const dv=["▁","▂","▃","▄","▅","▆","▇","█"];function vT(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 ST(e,t){if(e===t){const o=Math.max(Math.abs(e)*.05,1);return{minY:e-o,maxY:t+o}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function wT(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((x,y)=>x.x-y.x),r=n[0].x,o=n[n.length-1].x,l=Math.min(...n.map(x=>x.y)),u=Math.max(...n.map(x=>x.y)),{minY:c,maxY:d}=ST(l,u),f=Math.max(0,c),p=Array.from({length:t},()=>" "),m=new Map;for(const x of n){const y=o===r?0:Math.round((x.x-r)/(o-r)*(t-1)),w=m.get(y)??[];m.set(y,[...w,x.y])}for(const[x,y]of m){const w=Math.max(...y);p[x]=dv[vT(w,c,d)]??dv[0]}return{blocks:p.join(""),minX:r,maxX:o,minY:f,maxY:d}}function hv(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function fv({data:e,width:t=60,height:n=78,label:r,xLabel:o,yLabel:l,showAxes:u=!0,formatY:c=hv,formatX:d=hv}){const f=A.useMemo(()=>{const p=wT(e,t),m=Math.max(t*6,240),x=10,y=8,C=[...e].sort((_,j)=>_.x-j.x).map(_=>{const j=p.maxX===p.minX?m/2:x+(_.x-p.minX)/(p.maxX-p.minX)*(m-x*2),E=p.maxY===p.minY?n/2:y+(p.maxY-_.y)/(p.maxY-p.minY)*(n-y*2);return{..._,cx:j,cy:E,leftPercent:j/m*100,topPercent:E/n*100}}),v=C.map((_,j)=>`${j===0?"M":"L"} ${_.cx.toFixed(1)} ${_.cy.toFixed(1)}`).join(" "),b=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(_=>({value:_,y:p.maxY===p.minY?n/2:y+(p.maxY-_)/(p.maxY-p.minY)*(n-y*2)}));return{...p,chartWidth:m,points:C,path:v,gridLines:b}},[e,n,t]);return e.length===0?a.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&a.jsx("div",{className:"mb-1",children:r}),a.jsx("div",{children:"No data"})]}):a.jsxs("div",{className:"font-mono text-xs",children:[r&&a.jsx("div",{className:"text-text-secondary mb-2",children:r}),a.jsxs("div",{className:"flex gap-3",children:[u&&a.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(p=>a.jsx("span",{children:c(p.value)},`${p.value}-${p.y}`))}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsxs("div",{className:"relative h-[78px]",children:[a.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(p=>a.jsx("line",{x1:"0",x2:f.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),f.points.map(p=>a.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),f.points.length>1&&a.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(p=>a.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${c(p.y)}`,children:a.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:a.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),u&&a.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[a.jsx("span",{className:"w-12"}),a.jsxs("span",{className:"flex-1 flex justify-between",children:[a.jsx("span",{children:d(f.minX)}),a.jsx("span",{children:o}),a.jsx("span",{children:d(f.maxX)})]})]}),l&&u&&a.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function CT({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:o=60}){const l=e.map(c=>({x:c.x,y:c.ppSpeed})),u=e.map(c=>({x:c.x,y:c.tgSpeed}));return a.jsxs("div",{className:"space-y-5",children:[a.jsx(fv,{data:l,width:o,label:t,xLabel:r}),a.jsx(fv,{data:u,width:o,label:n,xLabel:r})]})}function kT(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((o,l)=>o.callIndex-l.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function ET(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 jT(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 NT(e){return e.callDataPoints.length>0?jT(e):ET(e)}function nm(e){if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=e%60;return`${t}m ${n.toFixed(0)}s`}function Pi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function cl(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function TT(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Pi(t)} ctx`:`${Pi(t)}-${Pi(n)} ctx`}function Au(e){return`${cl(e)} t/s`}function f1(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function AT(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 LT({isOpen:e,onClose:t,stats:n}){const r=A.useRef(null),[o,l]=A.useState({}),[u,c]=A.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});A.useEffect(()=>{var w;n.modelGroups.some(C=>C.key===u)||c(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[u,n.modelGroups]);const d=A.useMemo(()=>n.modelGroups.find(w=>w.key===u)??n.modelGroups[0],[u,n.modelGroups]),f=A.useMemo(()=>d?kT(d):[],[d]),p=A.useMemo(()=>d?NT(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=A.useCallback(w=>{l(C=>({...C,[w]:!C[w]}))},[]),x=A.useCallback(()=>{if(!d)return;const w=AT(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),y=A.useCallback(async()=>{if(r.current)try{const w=(await Z(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),x()}},[x]);return a.jsx(Ot,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:a.jsxs("div",{ref:r,className:"space-y-6",children:[a.jsx("section",{children:a.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>a.jsx("button",{onClick:()=>c(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.key===(d==null?void 0:d.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:w.label,children:w.label},w.key))})}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[a.jsx(hs,{label:"AI Time",value:nm(d.aiTime)}),a.jsx(hs,{label:"Total Time",value:nm(d.totalTime)}),a.jsx(hs,{label:"Tool Time",value:nm(d.toolTime)}),a.jsx(hs,{label:"Responses",value:d.responseCount.toString()}),a.jsx(hs,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[a.jsx(hs,{label:"Prefill Tokens",value:Pi(d.prefillTokens),subValue:`@ ${cl(d.avgPrefillSpeed)} tok/s`}),a.jsx(hs,{label:"Gen Tokens",value:Pi(d.generationTokens),subValue:`@ ${cl(d.avgGenerationSpeed)} tok/s`}),a.jsx(hs,{label:"Avg PP Speed",value:`${cl(d.avgPrefillSpeed)}`,subValue:"tok/s"}),a.jsx(hs,{label:"Avg TG Speed",value:`${cl(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.points.length>1&&a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),a.jsx("button",{onClick:y,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),a.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:a.jsx(CT,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),d&&a.jsxs("section",{children:[a.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.responseCount," responses)"]}),a.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:a.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[a.jsxs("colgroup",{children:[a.jsx("col",{className:"w-[7%]"}),a.jsx("col",{className:"w-[14%]"}),a.jsx("col",{className:"w-[10%]"}),a.jsx("col",{className:"w-[14%]"}),a.jsx("col",{className:"w-[14%]"}),a.jsx("col",{className:"w-[14%]"}),a.jsx("col",{className:"w-[11%]"}),a.jsx("col",{className:"w-[2%]"})]}),a.jsx("thead",{children:a.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[a.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),a.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),a.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),a.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),a.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),a.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),a.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),a.jsx("th",{className:"px-2 py-2"})]})}),a.jsx("tbody",{children:f.map((w,C)=>a.jsxs(A.Fragment,{children:[a.jsx(DT,{row:w,index:C,isExpanded:o[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(o[w.messageId]??!1)&&w.calls.map((v,S)=>a.jsx(RT,{dataPoint:v,index:S},`${v.messageId}-${v.callIndex}`))]},w.messageId))})]})})]})]})})}function hs({label:e,value:t,subValue:n}){return a.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[a.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),a.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&a.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function DT({row:e,index:t,isExpanded:n,onToggle:r}){const o=e.calls.length>0?TT(e.calls.map(l=>l.promptTokens)):`${Pi(e.prefillTokens)} ctx`;return a.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[a.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),a.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:f1(e.timestamp)}),a.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),a.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:o.replace(/ ctx$/,"")}),a.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Au(e.prefillSpeed)}),a.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Au(e.generationSpeed)}),a.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),a.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function RT({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[a.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]}),a.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:f1(e.timestamp)}),a.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),a.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Pi(e.promptTokens)}),a.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Au(e.prefillSpeed)}),a.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Au(e.generationSpeed)}),a.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),a.jsx("td",{className:"px-2 py-2"})]}),n&&a.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:a.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:a.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&a.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&a.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&a.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&a.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const OT={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"}},MT=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function IT(e){return OT[e]??{icon:"○",color:"text-text-muted"}}function m1(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const ad=A.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:o}=IT(t);return a.jsx("span",{className:`${o} ${n}`,children:r})});function mv({entries:e,title:t}){const n=A.useMemo(()=>e.reduce((r,o)=>(r[o.status]=(r[o.status]??0)+1,r),{}),[e]);return a.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[a.jsx("span",{children:t}),Object.keys(n).length>0&&a.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:MT.map(r=>{const o=n[r];return o?a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(ad,{status:r}),a.jsx("span",{children:o})]},r):null})})]})}const PT=A.memo(function({entries:t,title:n,onClearAll:r}){const[o,l]=A.useState(!1),u=A.useCallback(()=>{l(!1),r==null||r()},[r]);return t.length===0?null:a.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&a.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:a.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),a.jsx("div",{className:"bg-primary",children:t.map((c,d)=>a.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[a.jsx(ad,{status:c.status}),a.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[a.jsxs("span",{className:"text-text-muted",children:["[",c.id,"]"]})," ",m1(c.description)]})]},c.id??d))}),r&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:a.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all",children:[a.jsx(Ya,{className:"w-3 h-3"}),"Clear all"]})}),o&&a.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:a.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[a.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:u,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),a.jsx("button",{onClick:()=>l(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})});async function p1(e,t,n){t({loading:!0});try{const o=await(await ke(e)).json();t({defaults:o.defaults??[],userItems:o.userItems??[],...n?{projectItems:o.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const BT="#6b7280";function _l(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??BT}const wt=qn(e=>{const t=async()=>{await p1("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await ke(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const o=await ei("POST","/api/agents",{...n,destination:r});return o.success&&await t(),o},updateAgent:async(n,r)=>{const o=await ei("PUT",`/api/agents/${n}`,r);return o.success&&await t(),o},deleteAgent:async n=>{try{const r=await ke(`/api/agents/${n}`,{method:"DELETE"}),o=await r.json();return r.ok?(e(l=>({userItems:l.userItems.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)=>Zu(`/api/agents/${n}/duplicate`,t,r)}}),Rt=qn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const r=await(await ke("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const r=await(await ke("/api/workflows")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],activeWorkflowId:r.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async n=>{try{const r=await ke(`/api/workflows/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/workflows/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createWorkflow:async(n,r)=>{const o=await ei("POST","/api/workflows",{...n,destination:r});return o.success&&await t().fetchWorkflows(),o},updateWorkflow:async(n,r)=>{const o=await ei("PUT",`/api/workflows/${n}`,r);return o.success&&await t().fetchWorkflows(),o},deleteWorkflow:async n=>{try{const r=await ke(`/api/workflows/${n}`,{method:"DELETE"}),o=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r)=>Zu(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),r)})),$T={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function zT(e,t){await ke(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function nu({id:e,agents:t}){const n=_l(t,e),r=t.find(o=>o.id===e);return a.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function HT({id:e}){const t=Rt(u=>u.defaults),n=Rt(u=>u.userItems),o=A.useMemo(()=>[...t,...n],[t,n]).find(u=>u.id===e),l=(o==null?void 0:o.color)??"#3b82f6";return a.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${l}20`,color:l},children:(o==null?void 0:o.name)??e})}function UT({entries:e,sessionId:t}){const[n,r]=A.useState(e),[o,l]=A.useState(!1),[u,c]=A.useState(null),[d,f]=A.useState(""),[p,m]=A.useState(""),[x,y]=A.useState(!1),[w,C]=A.useState(!1),v=wt(X=>X.defaults),S=wt(X=>X.userItems),b=wt(X=>X.projectItems),_=A.useMemo(()=>[...v,...S,...b],[v,S,b]),j=A.useRef(null),E=A.useRef(null);A.useEffect(()=>{r(e)},[e]),A.useEffect(()=>{var X;o&&((X=j.current)==null||X.focus())},[o]),A.useEffect(()=>{var X;u&&((X=E.current)==null||X.focus())},[u]);const T=A.useCallback(X=>{r(X),zT(t,X)},[t]),D=A.useCallback(X=>{var B;const z=X.map(ee=>ee.trim()).filter(Boolean);if(z.length===0)return;const R=n.map(ee=>Number(ee.id)).filter(ee=>Number.isInteger(ee)&&ee>=0),I=Math.max(-1,...R)+1,G=z.map((ee,J)=>({id:String(I+J),description:ee,status:"pending"}));T([...n,...G]),f(""),(B=j.current)==null||B.focus()},[n,T]),L=A.useCallback(()=>{D([d])},[D,d]),O=A.useCallback(X=>{const z=X.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);z.length<2||(X.preventDefault(),D(z))},[D]),P=A.useCallback(()=>{l(!1),f("")},[]),q=A.useCallback((X,z)=>{c(X),m(z)},[]),W=A.useCallback(()=>{if(!u)return;const X=p.trim(),z=n.map(R=>R.id===u?{...R,description:X||R.description}:R);T(z),c(null)},[u,p,n,T]),M=A.useCallback(X=>{const z=n.map(R=>R.id===X?{...R,status:$T[R.status]??"pending"}:R);T(z)},[n,T]),H=A.useCallback(X=>{T(n.filter(z=>z.id!==X))},[n,T]),V=A.useCallback(()=>{T([]),y(!1)},[T]),U=A.useCallback(X=>{X.key==="Enter"&&(X.preventDefault(),L()),X.key==="Escape"&&P()},[L,P]),Q=A.useCallback(X=>{X.key==="Enter"&&W(),X.key==="Escape"&&c(null)},[W]);return a.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[a.jsxs("div",{className:"bg-primary",children:[n.length===0&&!o&&a.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",a.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((X,z)=>{const R=X.status,I=u===X.id;return a.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${z>0?"border-t border-border":""}`,children:[a.jsx("button",{onClick:()=>M(X.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${X.status} (click to cycle)`,children:a.jsx(ad,{status:R})}),a.jsx("div",{className:"flex-1 min-w-0",children:I?a.jsx("input",{ref:E,value:p,onChange:G=>m(G.target.value),onBlur:W,onKeyDown:Q,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"}):a.jsxs("button",{onClick:()=>q(X.id,X.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:["[",X.id,"] ",m1(X.description)]})}),a.jsx("button",{onClick:()=>H(X.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:a.jsx(Xa,{className:"w-4 h-4"})})]},X.id)})]}),o&&a.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),a.jsx("input",{ref:j,value:d,onChange:X=>f(X.target.value),onKeyDown:U,onPaste:O,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),a.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[o?a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:L,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[a.jsx(ti,{className:"w-3 h-3"}),"Add"]}),a.jsx("button",{onClick:P,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):a.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[a.jsx(ti,{className:"w-3 h-3"}),"Add"]}),n.length>0&&a.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[a.jsx(Ya,{className:"w-3 h-3"}),"Clear all"]}),a.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:a.jsx(MS,{className:"w-3 h-3"})})]}),x&&a.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:a.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[a.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:V,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),a.jsx("button",{onClick:()=>y(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),a.jsx(Ot,{isOpen:w,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:a.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[a.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),a.jsxs("p",{children:["To use this feature, start in ",a.jsx(nu,{id:"planner",agents:_})," mode and",a.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",a.jsx(HT,{id:"default"})," builtin workflow to launch the automation part."]}),a.jsx("p",{children:"This workflow will automatically:"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsxs("li",{children:["Launch the ",a.jsx(nu,{id:"builder",agents:_}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),a.jsxs("li",{children:["Then launch the ",a.jsx(nu,{id:"verifier",agents:_})," 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."]}),a.jsxs("li",{children:["Launch a ",a.jsx(nu,{id:"code_reviewer",agents:_})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),a.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:a.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function FT({isOpen:e,onClose:t}){const n=Fr(C=>C.config),r=Fr(C=>C.saveConfig),[o,l]=A.useState(""),[u,c]=A.useState(""),[d,f]=A.useState(!1),[p,m]=A.useState(!1),[x,y]=A.useState(!1);A.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),f((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!o.trim()||!u.trim()||(y(!0),await r({command:o.trim(),url:u.trim(),hotReload:d,disableInspect:p}),y(!1),t())};return a.jsx(Ot,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),a.jsx("input",{className:"input w-full",type:"text",value:o,onChange:C=>l(C.target.value),placeholder:"npm run dev"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),a.jsx("input",{className:"input w-full",type:"text",value:u,onChange:C=>c(C.target.value),placeholder:"http://localhost:3000"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>f(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),a.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:C=>m(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),a.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),a.jsx("button",{className:"btn btn-primary",onClick:w,disabled:x||!o.trim()||!u.trim(),children:x?"Saving...":"Save"})]})]})})}const pv={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"},VT={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"},gv={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},GT="text-text-primary";function WT(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,o="text-text-primary",l;try{for(;(l=n.exec(e))!==null;){if(l.index>r){const f=e.slice(r,l.index);f&&t.push({text:f,className:o})}const u=l[1];if(!u)continue;const c=u.split(";").map(Number);if(c.length===0||c[0]===0){o="text-text-primary";continue}const d=[];for(const f of c)if(f>=30&&f<=37){const p=pv[f];p&&d.push(p)}else if(f>=40&&f<=47){const p=VT[f];p&&d.push(p)}else if(f>=90&&f<=97){const p=pv[f];p&&d.push(p)}else if(f in gv){const p=gv[f];p&&d.push(p)}else f===39?d.push(GT):f===49&&(o=o.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));d.length>0&&(o=d.join(" ")),r=n.lastIndex}if(r<e.length){const u=e.slice(r);u&&t.push({text:u,className:o})}return t}catch(u){return console.warn("ANSI parsing failed, stripping codes:",u),[{text:qT(e),className:"text-text-primary"}]}}function qT(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function Lu(e){const t=WT(e),n=[];return t.forEach((r,o)=>{const l=r.text.split(`
|
|
90
|
+
`);l.forEach((u,c)=>{n.push(Ys.createElement("span",{key:`${o}-${c}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push(Ys.createElement("br",{key:`${o}-${c}-br`}))})}),n.length===1?n[0]:n}function g1({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return a.jsx("pre",{ref:t,className:n,children:e.length===0?a.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((r,o)=>a.jsx("span",{className:r.stream==="stderr"?"text-accent-warning":"",children:Lu(r.content)},o))})}function Bp({isActive:e,onToggle:t,className:n,style:r}){return a.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):a.jsx(Wn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const od=(e,t)=>{const n=A.useRef(!0),r=A.useRef(null),[o,l]=A.useState(!0),u=()=>{const c=e.current;c&&(c.scrollTop=c.scrollHeight)};return A.useEffect(()=>{const c=e.current;if(!c)return;const d=y=>{if(y.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}));return}n.current=!1,l(!1)},f=y=>{y.touches[0]&&(r.current=y.touches[0].clientY)},p=y=>{if(r.current===null)return;const w=y.touches[0];if(!w)return;if(w.clientY-r.current>0){n.current=!1,l(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}))},m=new MutationObserver(()=>{n.current&&requestAnimationFrame(u)}),x=setInterval(()=>{n.current&&u()},1e3);return c.addEventListener("wheel",d,{passive:!0}),c.addEventListener("touchstart",f,{passive:!0}),c.addEventListener("touchmove",p,{passive:!0}),m.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{c.removeEventListener("wheel",d),c.removeEventListener("touchstart",f),c.removeEventListener("touchmove",p),m.disconnect(),clearInterval(x)}},[t==null?void 0:t.id]),{force_scroll_to_bottom:()=>{n.current=!0,l(!0),u()},isAutoScrollActive:o,setAutoScroll:c=>{n.current=c,l(c),c&&u()}}},x1=A.memo(function({title:t,logs:n,onClose:r,preClassName:o}){const l=A.useRef(null),{isAutoScrollActive:u,setAutoScroll:c}=od(l,null);return a.jsx(Ot,{isOpen:!0,onClose:r,title:t,size:"full",headerRight:a.jsx(Bp,{isActive:u,onToggle:c,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),children:a.jsx("div",{ref:l,className:"h-full overflow-y-auto",children:a.jsx(g1,{logs:n,preClassName:o})})})}),KT=A.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:o,onSetAutoScroll:l}){const[u,c]=A.useState(null),d=A.useRef(null),f=A.useRef(l);return f.current=l,A.useEffect(()=>{var m;const p=(m=n.current)==null?void 0:m.getBoundingClientRect();p&&c({bottom:window.innerHeight-p.bottom,right:window.innerWidth-p.right,width:p.width,height:p.height})},[n]),A.useEffect(()=>{const p=d.current;if(!p)return;const m=x=>{if(x.deltaY<0){f.current(!1);return}x.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{p.scrollHeight-p.scrollTop-p.offsetHeight<100&&f.current(!0)}))};return p.addEventListener("wheel",m,{passive:!0}),()=>p.removeEventListener("wheel",m)},[]),A.useEffect(()=>{d.current&&o&&(d.current.scrollTop=d.current.scrollHeight)},[t,o,u]),a.jsx("div",{className:`relative ${u?"":"hidden"}`,children:a.jsx("pre",{ref:d,className:"fixed z-40 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border overflow-auto transition-all duration-150 ease-out select-text",style:u?{bottom:u.bottom,right:u.right,width:u.width*2,maxHeight:u.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:t.map((p,m)=>a.jsx("span",{className:p.stream==="stderr"?"text-accent-warning":"",children:Lu(p.content)},m))})})}),YT=A.memo(function({workdir:t}){const n=Fr(W=>W.setWorkdir),r=Fr(W=>W.status),o=Fr(W=>W.config),l=Fr(W=>W.logs),u=Fr(W=>W.start),c=Fr(W=>W.stop),d=Fr(W=>W.fetchLogs),[f,p]=A.useState(!1),[m,x]=A.useState(!1),[y,w]=A.useState(!1),[C,v]=A.useState(!1),S=A.useRef(null),{isAutoScrollActive:b,setAutoScroll:_}=od(S,null),j=A.useRef(null),E=A.useRef(null),T=A.useRef(null),D=()=>{const W=r==null?void 0:r.inspectProxyPort;if(!W){r!=null&&r.url&&window.open(r.url,"_blank");return}const M=`${window.location.protocol}//${window.location.hostname}:${W}`;window.open(M,"_blank")},L=(r==null?void 0:r.state)??"off",O=o!==null,P=L==="running"||L==="warning";A.useEffect(()=>{n(t??null)},[t,n]),A.useEffect(()=>{P&&d()},[P,d]);const q=()=>{P?c():u()};return a.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${L==="running"?"bg-accent-success":L==="warning"?"bg-accent-warning":L==="error"?"bg-accent-error":"bg-text-muted"}`}),a.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),a.jsx("button",{onClick:()=>p(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:a.jsx(Jj,{})})]}),O?a.jsx(a.Fragment,{children:L==="running"||L==="warning"?a.jsxs("div",{className:"flex gap-2",children:[a.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-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[a.jsx($S,{}),"Stop"]}),(r==null?void 0:r.url)&&a.jsxs("button",{onClick:()=>D(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:r.url,children:[a.jsx(eN,{}),"Open"]})]}):a.jsx("button",{onClick:q,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"})}):a.jsx("button",{onClick:()=>p(!0),className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),a.jsxs("div",{ref:T,className:`relative ${O&&P?"":"hidden"}`,onMouseEnter:()=>{!O||!P||(E.current&&clearTimeout(E.current),j.current=setTimeout(()=>{w(!0),v(!1)},500))},onMouseLeave:()=>{j.current&&clearTimeout(j.current),v(!0),E.current=setTimeout(()=>w(!1),150)},children:[a.jsx(g1,{logs:l,preRef:S,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),O&&P&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[(y||C)&&a.jsx(Bp,{isActive:b,onToggle:_,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"}),a.jsx("button",{onClick:()=>x(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),(y||C)&&T.current&&Qa.createPortal(a.jsx(KT,{logs:l,anchorRef:T,isHiding:C,isAutoScrollActive:b,onSetAutoScroll:_}),document.body)]})]}),a.jsx(FT,{isOpen:f,onClose:()=>p(!1)}),m&&a.jsx(x1,{title:"Dev Server Logs",logs:l,onClose:()=>x(!1)})]})}),XT=A.memo(function({sessionId:t}){var y;const n=dl(w=>w.processes),r=dl(w=>w.stopProcess),[o,l]=A.useState(null),[u,c]=A.useState([]),d=n.filter(w=>w.status!=="exited"),f=d.filter(w=>w.status==="running").length;if(n.length===0)return null;const p=w=>{switch(w){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=w=>{const C=dl.getState().logs[w]??[];c(C.map(v=>({content:v.content,stream:v.stream}))),l(w)},x=w=>{t&&r(w,t)};return a.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),a.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),a.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),a.jsx("div",{className:"space-y-2",children:d.map(w=>a.jsx("div",{className:"border border-border rounded p-2",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(w.status)}`}),a.jsx("span",{className:"text-sm text-text-primary truncate",title:w.name,children:w.name}),a.jsxs("span",{className:"text-xs text-text-muted",children:["[",w.status,"]"]})]}),a.jsxs("div",{className:"flex gap-1 ml-2",children:[a.jsx("button",{onClick:()=>m(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),a.jsx("button",{onClick:()=>x(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},w.id))}),o&&a.jsx(x1,{title:((y=d.find(w=>w.id===o))==null?void 0:y.name)??"",logs:u,onClose:()=>{l(null),c([])}})]})});function QT({isOpen:e,onClose:t,versionInfo:n}){const[r,o]=A.useState("ready"),[l,u]=A.useState(""),[c,d]=A.useState(n),[f,p]=A.useState(null),[m,x]=A.useState(null);A.useEffect(()=>{if(e){if(n){d(n);return}fetch("/api/auto-update/check").then(v=>v.json()).then(v=>{d({current:v.current,latest:v.latest})}).catch(()=>{})}},[e]),A.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const v=setInterval(()=>{u(S=>S.length>=3?"":S+".")},400);return()=>clearInterval(v)},[e,r]);const y=A.useCallback(async()=>{o("updating"),x(null);try{const S=await(await ke("/api/auto-update",{method:"POST"})).json();if(S.success){const b=S.version??"unknown";p(b),localStorage.setItem("openfox_updated_to",b),localStorage.setItem("update_pending","true"),S.isService?(o("restarting"),await ke("/api/auto-update/restart",{method:"POST"}).catch(()=>{}),setTimeout(()=>window.location.reload(),5e3)):o("complete")}else x(S.error??"Update failed"),o("failed")}catch(v){x(v instanceof Error?v.message:"Update request failed"),o("failed")}},[]);A.useEffect(()=>{e&&(o("ready"),u(""),p(null),x(null))},[e]);const w=r!=="updating"&&r!=="restarting",C=r==="failed"?"Update Failed":r==="complete"||r==="restarting"?"Update Complete":"New OpenFox Version Available";return a.jsxs(Ot,{isOpen:e,onClose:w?t:void 0,title:C,size:"sm",closeOnBackdropClick:w,showCloseButton:w,children:[a.jsxs("div",{className:"flex flex-col gap-4",children:[c&&a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-text-muted",children:"Current version"}),a.jsx("span",{className:"text-text-primary font-mono",children:c.current})]}),c&&a.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[a.jsx("span",{className:"text-text-muted",children:"Latest version"}),a.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:c.latest})]}),(r==="updating"||r==="restarting")&&a.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[a.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),a.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",l]})]}),r==="complete"&&a.jsx("div",{className:"flex flex-col gap-3 mt-2",children:a.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",f??(c==null?void 0:c.latest),"."," Please restart OpenFox to use the new version."]})}),r==="failed"&&a.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[a.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:[a.jsx("span",{children:"⚠️"}),a.jsx("p",{className:"text-text-secondary",children:m})]}),a.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),a.jsx("p",{className:"text-xs text-text-muted",children:"Run this command in your terminal to complete the update."})]})]}),r==="ready"&&a.jsx("button",{onClick:y,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="complete"||r==="failed")&&a.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 JT({file:e}){const t=QS(e.path,28),n=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",r=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"";return a.jsxs("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:[a.jsx("span",{className:`truncate ${n}`,title:e.path,children:t}),r&&a.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:r})]})}function ZT(){const{diff:e}=h1();return e.loading?a.jsx("div",{className:"mt-3",children:a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[a.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),a.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?a.jsx("div",{className:"mt-3",children:a.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):a.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:a.jsx("div",{className:"pr-1",children:e.files.map((t,n)=>a.jsx(JT,{file:t},n))})})}function eA({isOpen:e,onClose:t,projectId:n,sessionId:r,currentBranch:o,hasWorktree:l,worktreeBranch:u}){const c=Le(Q=>Q.loadSession),[d,f]=A.useState([]),[p,m]=A.useState([]),[x,y]=A.useState(null),[w,C]=A.useState(null),[v,S]=A.useState("feature/"),[b,_]=A.useState("worktree"),[j,E]=A.useState(!1),[T,D]=A.useState(null),[L,O]=A.useState(!1);A.useEffect(()=>{e&&(D(null),E(!1),y(null),C(null),S("feature/"),_("worktree"),O(!0),Promise.all([ke(`/api/projects/${n}/branches`).then(Q=>Q.json()),ke(`/api/projects/${n}/worktrees`).then(Q=>Q.json())]).then(([Q,X])=>{f(Q.branches),m(X.worktrees),O(!1)}).catch(()=>{f([]),m([]),O(!1)}))},[e,n]);const P=new Set(p.map(Q=>Q.branch)),q=d.filter(Q=>!P.has(Q.name)),W=A.useCallback(async()=>{D(null),E(!0);try{if(l){const Q=await ke(`/api/sessions/${r}/close-worktree`,{method:"POST"});if(!Q.ok){const X=await Q.json().catch(()=>({error:"Failed to close worktree"}));D(X.error),E(!1);return}await c(r),t();return}if(w){const Q=await ke(`/api/sessions/${r}/attach-worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:w.path})});if(!Q.ok){const X=await Q.json().catch(()=>({error:"Failed to attach worktree"}));D(X.error),E(!1);return}await c(r),t();return}if(x){const Q=await ke(`/api/projects/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:x})});if(!Q.ok){const X=await Q.json().catch(()=>({error:"Failed to switch branch"}));D(X.error),E(!1);return}await c(r),t();return}if(v.trim()){if(b==="worktree"){const Q=await ke(`/api/sessions/${r}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.trim()})});if(!Q.ok){const X=await Q.json().catch(()=>({error:"Failed to create worktree"}));D(X.error),E(!1);return}}else{const Q=await ke(`/api/projects/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.trim()})});if(!Q.ok){const X=await Q.json().catch(()=>({error:"Failed to create branch"}));D(X.error),E(!1);return}}await c(r),t();return}D("Select a branch or enter a name"),E(!1)}catch(Q){D(Q instanceof Error?Q.message:"Operation failed"),E(!1)}},[l,x,w,v,b,n,r,c,t]),M=A.useCallback(()=>{j||t()},[j,t]),H=l?"Close Worktree":w?"Switch to Worktree":x?"Switch":b==="worktree"?"Create Worktree":"Create Branch",V=!l&&!x&&!w&&!v.trim()||j,U=a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{onClick:M,className:"px-4 py-2 text-sm rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Cancel"}),a.jsx("button",{onClick:W,disabled:V,className:"px-4 py-2 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-50",children:H})]});return a.jsx(Ot,{isOpen:e,onClose:M,title:"Switch Branch",size:"md",footer:U,children:L||j?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ni,{})}):l?a.jsxs("div",{children:[a.jsxs("p",{className:"text-sm text-text-muted mb-2",children:["Working in worktree: ",a.jsx(Ma,{className:"inline-block w-4 h-4 mx-1 align-text-bottom"}),a.jsx("span",{className:"font-mono text-text-secondary",children:u??o})]}),a.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Close the worktree first to switch branches."}),T&&a.jsx("p",{className:"text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:T})]}):a.jsxs("div",{children:[a.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Currently on: ",a.jsx(Ma,{className:"inline-block w-4 h-4 mx-1 align-text-bottom"}),a.jsx("span",{className:"font-mono text-text-secondary",children:o})]}),q.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Existing branches"}),a.jsx("div",{className:"max-h-32 overflow-y-auto space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:q.map(Q=>a.jsxs("button",{onClick:()=>{y(Q.current?null:Q.name),C(null),S("feature/")},className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${x===Q.name?"bg-accent-primary/20 text-accent-primary":Q.current?"bg-bg-tertiary text-text-muted cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,disabled:Q.current,children:[a.jsx(Ma,{className:"w-3.5 h-3.5 shrink-0"}),a.jsx("span",{className:"font-mono truncate",children:Q.name}),Q.current&&a.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"})]},Q.name))})]}),p.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Existing worktrees"}),a.jsx("div",{className:"max-h-32 overflow-y-auto space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:p.map(Q=>a.jsxs("button",{onClick:()=>{C((w==null?void 0:w.path)===Q.path?null:Q),y(null),S("feature/")},className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${(w==null?void 0:w.path)===Q.path?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary text-text-secondary"}`,children:[a.jsx(Ma,{className:"w-3.5 h-3.5 shrink-0"}),a.jsx("span",{className:"font-mono truncate",children:Q.branch}),a.jsx("span",{className:"ml-auto text-xs text-text-muted truncate max-w-[120px]",title:Q.path,children:Q.path.split("/worktrees/")[1]??Q.path})]},Q.path))})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Or create new"}),a.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:[a.jsx(Ma,{className:"w-4 h-4 shrink-0 text-text-muted"}),a.jsx("input",{type:"text",value:v,onChange:Q=>{S(Q.target.value),y(null),C(null)},placeholder:"feature/my-branch",className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-secondary cursor-pointer",children:[a.jsx("input",{type:"radio",name:"createType",value:"branch",checked:b==="branch",onChange:()=>_("branch"),className:"text-accent-primary"}),"Branch"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-secondary cursor-pointer",children:[a.jsx("input",{type:"radio",name:"createType",value:"worktree",checked:b==="worktree",onChange:()=>_("worktree"),className:"text-accent-primary"}),"Worktree"]})]})]}),T&&a.jsx("p",{className:"text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:T})]})})}function xv({messages:e,workdir:t}){var b,_,j,E;const[n,r]=A.useState(!1),[o,l]=A.useState(!1),[u,c]=A.useState(!1),[d,f]=A.useState(!1),[p,m]=A.useState(!1),x=_T(e),{branch:y}=h1(),w=un(T=>T.version),C=Le(T=>T.currentSession),v=!!(C!=null&&C.worktree),S=A.useCallback(async()=>{l(!0);try{const T=await fetch("/api/auto-update/check");if(T.ok){const D=await T.json();c(D.isUpdateAvailable)}}catch{}finally{l(!1)}},[]);return A.useEffect(()=>{S()},[S]),a.jsxs("div",{className:"flex flex-col h-full",children:[x&&a.jsxs("div",{className:"mb-4",children:[a.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:a.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[a.jsx("span",{className:"text-text-secondary",children:bT(x.aiTime)}),a.jsx("span",{className:"w-px h-3 bg-border"}),a.jsx("span",{className:"text-text-secondary",children:uv(x.avgPrefillSpeed)}),a.jsx("span",{children:"pp"}),a.jsx("span",{className:"w-px h-3 bg-border"}),a.jsx("span",{className:"text-text-secondary",children:uv(x.avgGenerationSpeed)}),a.jsx("span",{children:"tg"})]})}),a.jsx(LT,{isOpen:n,onClose:()=>r(!1),stats:x})]}),a.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mt-4",children:[a.jsx(mv,{entries:((b=C==null?void 0:C.metadataEntries)==null?void 0:b.criteria)??[],title:"Acceptance Criteria"}),C&&a.jsx(UT,{entries:((_=C==null?void 0:C.metadataEntries)==null?void 0:_.criteria)??[],sessionId:C.id}),C&&(((E=(j=C.metadataEntries)==null?void 0:j.review_findings)==null?void 0:E.length)??0)>0&&a.jsxs("div",{className:"mt-6",children:[a.jsx(mv,{entries:C.metadataEntries.review_findings,title:"Review Findings"}),a.jsx(PT,{entries:C.metadataEntries.review_findings,onClearAll:async()=>{try{await ke(`/api/sessions/${C.id}/review-findings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({review_findings:[]})})}catch(T){console.error("Failed to clear review findings:",T)}}})]})]})}),y&&a.jsx("div",{className:"mt-4",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ma,{}),a.jsx("span",{className:"truncate text-text-secondary",title:y,children:y}),v&&a.jsx("span",{className:"text-xs text-accent-primary ml-1 font-medium",children:"worktree"}),a.jsx("button",{onClick:()=>m(!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"})]})}),a.jsx(ZT,{}),a.jsx(YT,{workdir:t}),a.jsx(XT,{sessionId:C==null?void 0:C.id}),w&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[a.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",a.jsxs("span",{className:"font-mono",children:["v",w]}),a.jsx("button",{onClick:()=>S(),disabled:o,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:a.jsx(Dp,{className:`w-3 h-3 ${o?"animate-spin":""}`})})]}),u&&a.jsx("button",{onClick:()=>f(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"})]}),a.jsx(QT,{isOpen:d,onClose:()=>f(!1),versionInfo:null}),C&&a.jsx(eA,{isOpen:p,onClose:()=>m(!1),projectId:C.projectId,sessionId:C.id,currentBranch:y,hasWorktree:v,worktreeBranch:y})]})}function tA({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const o=Le(l=>l.currentSession);return a.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&a.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),a.jsxs("div",{className:"flex h-full",children:[a.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?a.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary",children:a.jsx(xv,{messages:r,workdir:(o==null?void 0:o.worktree)??(o==null?void 0:o.workdir)})}):a.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),a.jsx("aside",{className:`
|
|
91
|
+
md:hidden
|
|
92
|
+
p-4 overflow-y-auto bg-secondary
|
|
93
|
+
transition-all duration-300 ease-in-out
|
|
94
|
+
fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
|
|
95
|
+
${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
|
|
96
|
+
`,children:a.jsx(xv,{messages:r,workdir:(o==null?void 0:o.worktree)??(o==null?void 0:o.workdir)})})]})]})}function nA(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function y1({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const o=n==="sm"?"w-12":"w-20",l=n==="sm"?"h-1":"h-1.5";return a.jsx("div",{className:`${l} bg-bg-tertiary rounded-full overflow-hidden ${o} ${r}`,children:a.jsx("div",{className:`h-full transition-all duration-300 ${nA(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function rA({dangerZone:e,size:t="md"}){return e?a.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function yv(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function sA(){const e=Le(b=>b.contextState),t=Le(b=>b.currentSession),n=Le(b=>b.compactContext),[r,o]=A.useState(!1),[l,u]=A.useState(!1),[c,d]=A.useState(!1),f=A.useRef(!1);if(A.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!f.current&&u(!1),f.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),!e||!t)return null;const{currentTokens:p,maxTokens:m,compactionCount:x,dangerZone:y,dynamicContextChanged:w}=e,C=Math.round(p/m*100),v=t.isRunning,S=()=>{Xt.send("context.applyDynamic",{}),u(!0)};return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:yv(C,y),children:[Tu(p)," / ",Tu(m)]}),a.jsxs("span",{className:yv(C,y),children:["(",C,"%)"]}),a.jsx(y1,{percent:C,dangerZone:y}),a.jsx(rA,{dangerZone:y}),x>0&&a.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),a.jsx("div",{className:"flex-1 flex justify-end",children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>o(!r),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:a.jsx(IS,{})}),r&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1)}),a.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:[a.jsx("button",{onClick:()=>{v||n(),o(!1)},disabled:v,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:v?"Cannot compact while running":"Compact context",children:a.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),w&&a.jsx("button",{onClick:()=>{o(!1),d(!0)},disabled:v,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:v?"Cannot apply while running":"Apply dynamic context",children:a.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]})})]})}),w&&!l&&a.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[a.jsx("span",{children:"System prompt has changed —"}),a.jsx("button",{onClick:()=>d(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),a.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:a.jsx(Xa,{})})]})}),a.jsxs(Ot,{isOpen:c,onClose:()=>d(!1),title:"Update system prompt",size:"sm",children:[a.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix."}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),a.jsx("button",{onClick:()=>{S(),d(!1)},disabled:v,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Update"})]})]})]})}function iA({stats:e,onClose:t}){var n;return a.jsx(Ot,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center gap-3",children:a.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",e.mode]})}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[a.jsx(ru,{label:"Total Time",value:`${e.totalTime.toFixed(1)}s`}),a.jsx(ru,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),a.jsx(ru,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),a.jsx(ru,{label:"LLM Calls",value:String(((n=e.llmCalls)==null?void 0:n.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((r,o)=>a.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",o+1]}),a.jsxs("span",{className:"text-xs text-text-muted",children:[r.ttft.toFixed(2),"s TTFT · ",r.completionTime.toFixed(2),"s gen"]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",a.jsxs("span",{className:"text-text-primary",children:[r.promptTokens," → ",r.completionTokens]})]}),a.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[r.temperature!==void 0&&a.jsx(su,{label:"temp",value:r.temperature.toFixed(2)}),r.topP!==void 0&&a.jsx(su,{label:"topP",value:r.topP.toFixed(2)}),r.topK!==void 0&&a.jsx(su,{label:"topK",value:String(r.topK)}),r.maxTokens!==void 0&&a.jsx(su,{label:"maxTok",value:String(r.maxTokens)})]})]})]},o))]})]})})}function ru({label:e,value:t}){return a.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[a.jsx("div",{className:"text-xs text-text-muted",children:e}),a.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function su({label:e,value:t}){return a.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[a.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}function aA(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const oA=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lA=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cA={};function _v(e,t){return(cA.jsx?lA:oA).test(e)}const uA=/[ \t\n\f\r]/g;function dA(e){return typeof e=="object"?e.type==="text"?bv(e.value):!1:bv(e)}function bv(e){return e.replace(uA,"")===""}let Rl=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Rl.prototype.normal={};Rl.prototype.property={};Rl.prototype.space=void 0;function _1(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Rl(n,r,t)}function Ym(e){return e.toLowerCase()}let Kn=class{constructor(t,n){this.attribute=n,this.property=t}};Kn.prototype.attribute="";Kn.prototype.booleanish=!1;Kn.prototype.boolean=!1;Kn.prototype.commaOrSpaceSeparated=!1;Kn.prototype.commaSeparated=!1;Kn.prototype.defined=!1;Kn.prototype.mustUseProperty=!1;Kn.prototype.number=!1;Kn.prototype.overloadedBoolean=!1;Kn.prototype.property="";Kn.prototype.spaceSeparated=!1;Kn.prototype.space=void 0;let hA=0;const dt=Hi(),ln=Hi(),Xm=Hi(),De=Hi(),$t=Hi(),Ha=Hi(),ir=Hi();function Hi(){return 2**++hA}const Qm=Object.freeze(Object.defineProperty({__proto__:null,boolean:dt,booleanish:ln,commaOrSpaceSeparated:ir,commaSeparated:Ha,number:De,overloadedBoolean:Xm,spaceSeparated:$t},Symbol.toStringTag,{value:"Module"})),rm=Object.keys(Qm);let $p=class extends Kn{constructor(t,n,r,o){let l=-1;if(super(t,n),vv(this,"space",o),typeof r=="number")for(;++l<rm.length;){const u=rm[l];vv(this,rm[l],(r&Qm[u])===Qm[u])}}};$p.prototype.defined=!0;function vv(e,t,n){n&&(e[t]=n)}function Ja(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const l=new $p(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[Ym(r)]=r,n[Ym(l.attribute)]=r}return new Rl(t,n,e.space)}const b1=Ja({properties:{ariaActiveDescendant:null,ariaAtomic:ln,ariaAutoComplete:null,ariaBusy:ln,ariaChecked:ln,ariaColCount:De,ariaColIndex:De,ariaColSpan:De,ariaControls:$t,ariaCurrent:null,ariaDescribedBy:$t,ariaDetails:null,ariaDisabled:ln,ariaDropEffect:$t,ariaErrorMessage:null,ariaExpanded:ln,ariaFlowTo:$t,ariaGrabbed:ln,ariaHasPopup:null,ariaHidden:ln,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:$t,ariaLevel:De,ariaLive:null,ariaModal:ln,ariaMultiLine:ln,ariaMultiSelectable:ln,ariaOrientation:null,ariaOwns:$t,ariaPlaceholder:null,ariaPosInSet:De,ariaPressed:ln,ariaReadOnly:ln,ariaRelevant:null,ariaRequired:ln,ariaRoleDescription:$t,ariaRowCount:De,ariaRowIndex:De,ariaRowSpan:De,ariaSelected:ln,ariaSetSize:De,ariaSort:null,ariaValueMax:De,ariaValueMin:De,ariaValueNow:De,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function v1(e,t){return t in e?e[t]:t}function S1(e,t){return v1(e,t.toLowerCase())}const fA=Ja({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ha,acceptCharset:$t,accessKey:$t,action:null,allow:null,allowFullScreen:dt,allowPaymentRequest:dt,allowUserMedia:dt,alt:null,as:null,async:dt,autoCapitalize:null,autoComplete:$t,autoFocus:dt,autoPlay:dt,blocking:$t,capture:null,charSet:null,checked:dt,cite:null,className:$t,cols:De,colSpan:null,content:null,contentEditable:ln,controls:dt,controlsList:$t,coords:De|Ha,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dt,defer:dt,dir:null,dirName:null,disabled:dt,download:Xm,draggable:ln,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dt,formTarget:null,headers:$t,height:De,hidden:Xm,high:De,href:null,hrefLang:null,htmlFor:$t,httpEquiv:$t,id:null,imageSizes:null,imageSrcSet:null,inert:dt,inputMode:null,integrity:null,is:null,isMap:dt,itemId:null,itemProp:$t,itemRef:$t,itemScope:dt,itemType:$t,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dt,low:De,manifest:null,max:null,maxLength:De,media:null,method:null,min:null,minLength:De,multiple:dt,muted:dt,name:null,nonce:null,noModule:dt,noValidate:dt,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:dt,optimum:De,pattern:null,ping:$t,placeholder:null,playsInline:dt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dt,referrerPolicy:null,rel:$t,required:dt,reversed:dt,rows:De,rowSpan:De,sandbox:$t,scope:null,scoped:dt,seamless:dt,selected:dt,shadowRootClonable:dt,shadowRootDelegatesFocus:dt,shadowRootMode:null,shape:null,size:De,sizes:null,slot:null,span:De,spellCheck:ln,src:null,srcDoc:null,srcLang:null,srcSet:null,start:De,step:null,style:null,tabIndex:De,target:null,title:null,translate:null,type:null,typeMustMatch:dt,useMap:null,value:ln,width:De,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:$t,axis:null,background:null,bgColor:null,border:De,borderColor:null,bottomMargin:De,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dt,declare:dt,event:null,face:null,frame:null,frameBorder:null,hSpace:De,leftMargin:De,link:null,longDesc:null,lowSrc:null,marginHeight:De,marginWidth:De,noResize:dt,noHref:dt,noShade:dt,noWrap:dt,object:null,profile:null,prompt:null,rev:null,rightMargin:De,rules:null,scheme:null,scrolling:ln,standby:null,summary:null,text:null,topMargin:De,valueType:null,version:null,vAlign:null,vLink:null,vSpace:De,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dt,disableRemotePlayback:dt,prefix:null,property:null,results:De,security:null,unselectable:null},space:"html",transform:S1}),mA=Ja({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ir,accentHeight:De,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:De,amplitude:De,arabicForm:null,ascent:De,attributeName:null,attributeType:null,azimuth:De,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:De,by:null,calcMode:null,capHeight:De,className:$t,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:De,diffuseConstant:De,direction:null,display:null,dur:null,divisor:De,dominantBaseline:null,download:dt,dx:null,dy:null,edgeMode:null,editable:null,elevation:De,enableBackground:null,end:null,event:null,exponent:De,externalResourcesRequired:null,fill:null,fillOpacity:De,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:Ha,g2:Ha,glyphName:Ha,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:De,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:De,horizOriginX:De,horizOriginY:De,id:null,ideographic:De,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:De,k:De,k1:De,k2:De,k3:De,k4:De,kernelMatrix:ir,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:De,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:De,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:De,overlineThickness:De,paintOrder:null,panose1:null,path:null,pathLength:De,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:$t,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:De,pointsAtY:De,pointsAtZ:De,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ir,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ir,rev:ir,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ir,requiredFeatures:ir,requiredFonts:ir,requiredFormats:ir,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:De,specularExponent:De,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:De,strikethroughThickness:De,string:null,stroke:null,strokeDashArray:ir,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:De,strokeOpacity:De,strokeWidth:null,style:null,surfaceScale:De,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ir,tabIndex:De,tableValues:null,target:null,targetX:De,targetY:De,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ir,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:De,underlineThickness:De,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:De,values:null,vAlphabetic:De,vMathematical:De,vectorEffect:null,vHanging:De,vIdeographic:De,version:null,vertAdvY:De,vertOriginX:De,vertOriginY:De,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:De,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:v1}),w1=Ja({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()}}),C1=Ja({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:S1}),k1=Ja({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),pA={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"},gA=/[A-Z]/g,Sv=/-[a-z]/g,xA=/^data[-\w.:]+$/i;function yA(e,t){const n=Ym(t);let r=t,o=Kn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&xA.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(Sv,bA);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!Sv.test(l)){let u=l.replace(gA,_A);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}o=$p}return new o(r,t)}function _A(e){return"-"+e.toLowerCase()}function bA(e){return e.charAt(1).toUpperCase()}const vA=_1([b1,fA,w1,C1,k1],"html"),zp=_1([b1,mA,w1,C1,k1],"svg");function SA(e){return e.join(" ").trim()}var ja={},sm,wv;function wA(){if(wv)return sm;wv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
97
|
+
`,f="/",p="*",m="",x="comment",y="declaration";function w(v,S){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];S=S||{};var b=1,_=1;function j(H){var V=H.match(t);V&&(b+=V.length);var U=H.lastIndexOf(d);_=~U?H.length-U:_+H.length}function E(){var H={line:b,column:_};return function(V){return V.position=new T(H),O(),V}}function T(H){this.start=H,this.end={line:b,column:_},this.source=S.source}T.prototype.content=v;function D(H){var V=new Error(S.source+":"+b+":"+_+": "+H);if(V.reason=H,V.filename=S.source,V.line=b,V.column=_,V.source=v,!S.silent)throw V}function L(H){var V=H.exec(v);if(V){var U=V[0];return j(U),v=v.slice(U.length),V}}function O(){L(n)}function P(H){var V;for(H=H||[];V=q();)V!==!1&&H.push(V);return H}function q(){var H=E();if(!(f!=v.charAt(0)||p!=v.charAt(1))){for(var V=2;m!=v.charAt(V)&&(p!=v.charAt(V)||f!=v.charAt(V+1));)++V;if(V+=2,m===v.charAt(V-1))return D("End of comment missing");var U=v.slice(2,V-2);return _+=2,j(U),v=v.slice(V),_+=2,H({type:x,comment:U})}}function W(){var H=E(),V=L(r);if(V){if(q(),!L(o))return D("property missing ':'");var U=L(l),Q=H({type:y,property:C(V[0].replace(e,m)),value:U?C(U[0].replace(e,m)):m});return L(u),Q}}function M(){var H=[];P(H);for(var V;V=W();)V!==!1&&(H.push(V),P(H));return H}return O(),M()}function C(v){return v?v.replace(c,m):m}return sm=w,sm}var Cv;function CA(){if(Cv)return ja;Cv=1;var e=ja&&ja.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ja,"__esModule",{value:!0}),ja.default=n;const t=e(wA());function n(r,o){let l=null;if(!r||typeof r!="string")return l;const u=(0,t.default)(r),c=typeof o=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:f,value:p}=d;c?o(f,p,d):p&&(l=l||{},l[f]=p)}),l}return ja}var Jo={},kv;function kA(){if(kv)return Jo;kv=1,Object.defineProperty(Jo,"__esModule",{value:!0}),Jo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,l=function(f){return!f||n.test(f)||e.test(f)},u=function(f,p){return p.toUpperCase()},c=function(f,p){return"".concat(p,"-")},d=function(f,p){return p===void 0&&(p={}),l(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(o,c):f=f.replace(r,c),f.replace(t,u))};return Jo.camelCase=d,Jo}var Zo,Ev;function EA(){if(Ev)return Zo;Ev=1;var e=Zo&&Zo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(CA()),n=kA();function r(o,l){var u={};return!o||typeof o!="string"||(0,t.default)(o,function(c,d){c&&d&&(u[(0,n.camelCase)(c,l)]=d)}),u}return r.default=r,Zo=r,Zo}var jA=EA();const NA=Xu(jA),E1=j1("end"),Hp=j1("start");function j1(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 TA(e){const t=Hp(e),n=E1(e);if(t&&n)return{start:t,end:n}}function hl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?jv(e.position):"start"in e||"end"in e?jv(e):"line"in e||"column"in e?Jm(e):""}function Jm(e){return Nv(e&&e.line)+":"+Nv(e&&e.column)}function jv(e){return Jm(e&&e.start)+"-"+Jm(e&&e.end)}function Nv(e){return e&&typeof e=="number"?e:1}class Ln extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",l={},u=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?o=t:!l.cause&&t&&(u=!0,o=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?l.ruleId=r:(l.source=r.slice(0,d),l.ruleId=r.slice(d+1))}if(!l.place&&l.ancestors&&l.ancestors){const d=l.ancestors[l.ancestors.length-1];d&&(l.place=d.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=c?c.line:void 0,this.name=hl(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=u&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ln.prototype.file="";Ln.prototype.name="";Ln.prototype.reason="";Ln.prototype.message="";Ln.prototype.stack="";Ln.prototype.column=void 0;Ln.prototype.line=void 0;Ln.prototype.ancestors=void 0;Ln.prototype.cause=void 0;Ln.prototype.fatal=void 0;Ln.prototype.place=void 0;Ln.prototype.ruleId=void 0;Ln.prototype.source=void 0;const Up={}.hasOwnProperty,AA=new Map,LA=/[A-Z]/g,DA=new Set(["table","tbody","thead","tfoot","tr"]),RA=new Set(["td","th"]),N1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function OA(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=UA(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=HA(n,t.jsx,t.jsxs)}const o={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"?zp:vA,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=T1(o,e,void 0);return l&&typeof l!="string"?l:o.create(e,o.Fragment,{children:l||void 0},void 0)}function T1(e,t,n){if(t.type==="element")return MA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return IA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return BA(e,t,n);if(t.type==="mdxjsEsm")return PA(e,t);if(t.type==="root")return $A(e,t,n);if(t.type==="text")return zA(e,t)}function MA(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=zp,e.schema=o),e.ancestors.push(t);const l=L1(e,t.tagName,!1),u=FA(e,t);let c=Vp(e,t);return DA.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!dA(d):!0})),A1(e,u,l,t),Fp(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function IA(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)}bl(e,t.position)}function PA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);bl(e,t.position)}function BA(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=zp,e.schema=o),e.ancestors.push(t);const l=t.name===null?e.Fragment:L1(e,t.name,!0),u=VA(e,t),c=Vp(e,t);return A1(e,u,l,t),Fp(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function $A(e,t,n){const r={};return Fp(r,Vp(e,t)),e.create(t,e.Fragment,r,n)}function zA(e,t){return t.value}function A1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Fp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function HA(e,t,n){return r;function r(o,l,u,c){const f=Array.isArray(u.children)?n:t;return c?f(l,u,c):f(l,u)}}function UA(e,t){return n;function n(r,o,l,u){const c=Array.isArray(l.children),d=Hp(r);return t(o,l,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function FA(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&Up.call(t.properties,o)){const l=GA(e,o,t.properties[o]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&RA.has(t.tagName)?r=c:n[u]=c}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function VA(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const u=l.expression;u.type;const c=u.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else bl(e,t.position);else{const o=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else bl(e,t.position);else l=r.value===null?!0:r.value;n[o]=l}return n}function Vp(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:AA;for(;++r<t.children.length;){const l=t.children[r];let u;if(e.passKeys){const d=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(d){const f=o.get(d)||0;u=d+"-"+f,o.set(d,f+1)}}const c=T1(e,l,u);c!==void 0&&n.push(c)}return n}function GA(e,t,n){const r=yA(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?aA(n):SA(n)),r.property==="style"){let o=typeof n=="object"?n:WA(e,String(n));return e.stylePropertyNameCase==="css"&&(o=qA(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?pA[r.property]||r.property:r.attribute,n]}}function WA(e,t){try{return NA(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new Ln("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=N1+"#cannot-parse-style-attribute",o}}function L1(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let l=-1,u;for(;++l<o.length;){const c=_v(o[l])?{type:"Identifier",name:o[l]}:{type:"Literal",value:o[l]};u=u?{type:"MemberExpression",object:u,property:c,computed:!!(l&&c.type==="Literal"),optional:!1}:c}r=u}else r=_v(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return Up.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);bl(e)}function bl(e,t){const n=new Ln("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=N1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function qA(e){const t={};let n;for(n in e)Up.call(e,n)&&(t[KA(n)]=e[n]);return t}function KA(e){let t=e.replace(LA,YA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function YA(e){return"-"+e.toLowerCase()}const im={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"]},XA={};function Gp(e,t){const n=XA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return D1(e,r,o)}function D1(e,t,n){if(QA(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 Tv(e.children,t,n)}return Array.isArray(e)?Tv(e,t,n):""}function Tv(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=D1(e[o],t,n);return r.join("")}function QA(e){return!!(e&&typeof e=="object")}const Av=document.createElement("i");function Wp(e){const t="&"+e+";";Av.innerHTML=t;const n=Av.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function lr(e,t,n,r){const o=e.length;let l=0,u;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)u=Array.from(r),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<r.length;)u=r.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function br(e,t){return e.length>0?(lr(e,e.length,0,t),e):t}const Lv={}.hasOwnProperty;function R1(e){const t={};let n=-1;for(;++n<e.length;)JA(t,e[n]);return t}function JA(e,t){let n;for(n in t){const o=(Lv.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){Lv.call(o,u)||(o[u]=[]);const c=l[u];ZA(o[u],Array.isArray(c)?c:c?[c]:[])}}}function ZA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);lr(e,0,0,r)}function O1(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Rr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const On=ri(/[A-Za-z]/),An=ri(/[\dA-Za-z]/),eL=ri(/[#-'*+\--9=?A-Z^-~]/);function Du(e){return e!==null&&(e<32||e===127)}const Zm=ri(/\d/),tL=ri(/[\dA-Fa-f]/),nL=ri(/[!-/:-@[-`{-~]/);function Xe(e){return e!==null&&e<-2}function Pt(e){return e!==null&&(e<0||e===32)}function pt(e){return e===-2||e===-1||e===32}const ld=ri(new RegExp("\\p{P}|\\p{S}","u")),Bi=ri(/\s/);function ri(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Za(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&An(e.charCodeAt(n+1))&&An(e.charCodeAt(n+2)))o=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const c=e.charCodeAt(n+1);l<56320&&c>56319&&c<57344?(u=String.fromCharCode(l,c),o=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(r,n),encodeURIComponent(u)),r=n+o+1,u=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function bt(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(d){return pt(d)?(e.enter(n),c(d)):t(d)}function c(d){return pt(d)&&l++<o?(e.consume(d),c):(e.exit(n),t(d))}}const rL={tokenize:sL};function sL(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),bt(e,t,"linePrefix")}function o(c){return e.enter("paragraph"),l(c)}function l(c){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,u(c)}function u(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Xe(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const iL={tokenize:aL},Dv={tokenize:oL};function aL(e){const t=this,n=[];let r=0,o,l,u;return c;function c(_){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,d,f)(_)}return f(_)}function d(_){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&b();const j=t.events.length;let E=j,T;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){T=t.events[E][1].end;break}S(r);let D=j;for(;D<t.events.length;)t.events[D][1].end={...T},D++;return lr(t.events,E+1,0,t.events.slice(j)),t.events.length=D,f(_)}return c(_)}function f(_){if(r===n.length){if(!o)return x(_);if(o.currentConstruct&&o.currentConstruct.concrete)return w(_);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Dv,p,m)(_)}function p(_){return o&&b(),S(r),x(_)}function m(_){return t.parser.lazy[t.now().line]=r!==n.length,u=t.now().offset,w(_)}function x(_){return t.containerState={},e.attempt(Dv,y,w)(_)}function y(_){return r++,n.push([t.currentConstruct,t.containerState]),x(_)}function w(_){if(_===null){o&&b(),S(0),e.consume(_);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:l}),C(_)}function C(_){if(_===null){v(e.exit("chunkFlow"),!0),S(0),e.consume(_);return}return Xe(_)?(e.consume(_),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(_),C)}function v(_,j){const E=t.sliceStream(_);if(j&&E.push(null),_.previous=l,l&&(l.next=_),l=_,o.defineSkip(_.start),o.write(E),t.parser.lazy[_.start.line]){let T=o.events.length;for(;T--;)if(o.events[T][1].start.offset<u&&(!o.events[T][1].end||o.events[T][1].end.offset>u))return;const D=t.events.length;let L=D,O,P;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(O){P=t.events[L][1].end;break}O=!0}for(S(r),T=D;T<t.events.length;)t.events[T][1].end={...P},T++;lr(t.events,L+1,0,t.events.slice(D)),t.events.length=T}}function S(_){let j=n.length;for(;j-- >_;){const E=n[j];t.containerState=E[1],E[0].exit.call(t,e)}n.length=_}function b(){o.write([null]),l=void 0,o=void 0,t.containerState._closeFlow=void 0}}function oL(e,t,n){return bt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Va(e){if(e===null||Pt(e)||Bi(e))return 1;if(ld(e))return 2}function cd(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const l=e[o].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const ep={name:"attention",resolveAll:lL,tokenize:cL};function lL(e,t){let n=-1,r,o,l,u,c,d,f,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const m={...e[r][1].end},x={...e[n][1].start};Rv(m,-d),Rv(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...e[r][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},l={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[r][1].end={...u.start},e[n][1].start={...c.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=br(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=br(f,[["enter",o,t],["enter",u,t],["exit",u,t],["enter",l,t]]),f=br(f,cd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=br(f,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,f=br(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,lr(e,r-1,n-r+3,f),n=r+f.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function cL(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Va(r);let l;return u;function u(d){return l=d,e.enter("attentionSequence"),c(d)}function c(d){if(d===l)return e.consume(d),c;const f=e.exit("attentionSequence"),p=Va(d),m=!p||p===2&&o||n.includes(d),x=!o||o===2&&p||n.includes(r);return f._open=!!(l===42?m:m&&(o||!x)),f._close=!!(l===42?x:x&&(p||!m)),t(d)}}function Rv(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const uL={name:"autolink",tokenize:dL};function dL(e,t,n){let r=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return On(y)?(e.consume(y),u):y===64?n(y):f(y)}function u(y){return y===43||y===45||y===46||An(y)?(r=1,c(y)):f(y)}function c(y){return y===58?(e.consume(y),r=0,d):(y===43||y===45||y===46||An(y))&&r++<32?(e.consume(y),c):(r=0,f(y))}function d(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||Du(y)?n(y):(e.consume(y),d)}function f(y){return y===64?(e.consume(y),p):eL(y)?(e.consume(y),f):n(y)}function p(y){return An(y)?m(y):n(y)}function m(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):x(y)}function x(y){if((y===45||An(y))&&r++<63){const w=y===45?x:m;return e.consume(y),w}return n(y)}}const Ol={partial:!0,tokenize:hL};function hL(e,t,n){return r;function r(l){return pt(l)?bt(e,o,"linePrefix")(l):o(l)}function o(l){return l===null||Xe(l)?t(l):n(l)}}const M1={continuation:{tokenize:mL},exit:pL,name:"blockQuote",tokenize:fL};function fL(e,t,n){const r=this;return o;function o(u){if(u===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return n(u)}function l(u){return pt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function mL(e,t,n){const r=this;return o;function o(u){return pt(u)?bt(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(M1,t,n)(u)}}function pL(e){e.exit("blockQuote")}const I1={name:"characterEscape",tokenize:gL};function gL(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),o}function o(l){return nL(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const P1={name:"characterReference",tokenize:xL};function xL(e,t,n){const r=this;let o=0,l,u;return c;function c(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),d}function d(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,u=An,p(m))}function f(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=tL,p):(e.enter("characterReferenceValue"),l=7,u=Zm,p(m))}function p(m){if(m===59&&o){const x=e.exit("characterReferenceValue");return u===An&&!Wp(r.sliceSerialize(x))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(m)&&o++<l?(e.consume(m),p):n(m)}}const Ov={partial:!0,tokenize:_L},Mv={concrete:!0,name:"codeFenced",tokenize:yL};function yL(e,t,n){const r=this,o={partial:!0,tokenize:E};let l=0,u=0,c;return d;function d(T){return f(T)}function f(T){const D=r.events[r.events.length-1];return l=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,c=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===c?(u++,e.consume(T),p):u<3?n(T):(e.exit("codeFencedFenceSequence"),pt(T)?bt(e,m,"whitespace")(T):m(T))}function m(T){return T===null||Xe(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(Ov,C,j)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(T))}function x(T){return T===null||Xe(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(T)):pt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),bt(e,y,"whitespace")(T)):T===96&&T===c?n(T):(e.consume(T),x)}function y(T){return T===null||Xe(T)?m(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||Xe(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(T)):T===96&&T===c?n(T):(e.consume(T),w)}function C(T){return e.attempt(o,j,v)(T)}function v(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),S}function S(T){return l>0&&pt(T)?bt(e,b,"linePrefix",l+1)(T):b(T)}function b(T){return T===null||Xe(T)?e.check(Ov,C,j)(T):(e.enter("codeFlowValue"),_(T))}function _(T){return T===null||Xe(T)?(e.exit("codeFlowValue"),b(T)):(e.consume(T),_)}function j(T){return e.exit("codeFenced"),t(T)}function E(T,D,L){let O=0;return P;function P(V){return T.enter("lineEnding"),T.consume(V),T.exit("lineEnding"),q}function q(V){return T.enter("codeFencedFence"),pt(V)?bt(T,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):W(V)}function W(V){return V===c?(T.enter("codeFencedFenceSequence"),M(V)):L(V)}function M(V){return V===c?(O++,T.consume(V),M):O>=u?(T.exit("codeFencedFenceSequence"),pt(V)?bt(T,H,"whitespace")(V):H(V)):L(V)}function H(V){return V===null||Xe(V)?(T.exit("codeFencedFence"),D(V)):L(V)}}}function _L(e,t,n){const r=this;return o;function o(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}const am={name:"codeIndented",tokenize:vL},bL={partial:!0,tokenize:SL};function vL(e,t,n){const r=this;return o;function o(f){return e.enter("codeIndented"),bt(e,l,"linePrefix",5)(f)}function l(f){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(f):n(f)}function u(f){return f===null?d(f):Xe(f)?e.attempt(bL,u,d)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||Xe(f)?(e.exit("codeFlowValue"),u(f)):(e.consume(f),c)}function d(f){return e.exit("codeIndented"),t(f)}}function SL(e,t,n){const r=this;return o;function o(u){return r.parser.lazy[r.now().line]?n(u):Xe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):bt(e,l,"linePrefix",5)(u)}function l(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):Xe(u)?o(u):n(u)}}const wL={name:"codeText",previous:kL,resolve:CL,tokenize:EL};function CL(e){let t=e.length-4,n=3,r,o;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;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function kL(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function EL(e,t,n){let r=0,o,l;return u;function u(m){return e.enter("codeText"),e.enter("codeTextSequence"),c(m)}function c(m){return m===96?(e.consume(m),r++,c):(e.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),d):m===96?(l=e.enter("codeTextSequence"),o=0,p(m)):Xe(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("codeTextData"),f(m))}function f(m){return m===null||m===32||m===96||Xe(m)?(e.exit("codeTextData"),d(m)):(e.consume(m),f)}function p(m){return m===96?(e.consume(m),o++,p):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",f(m))}}class jL{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 o=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&el(this.left,r),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),el(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),el(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);el(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);el(this.left,n.reverse())}}}function el(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 B1(e){const t={};let n=-1,r,o,l,u,c,d,f;const p=new jL(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,l=0,l<d.length&&d[l][1].type==="lineEndingBlank"&&(l+=2),l<d.length&&d[l][1].type==="content"))for(;++l<d.length&&d[l][1].type!=="content";)d[l][1].type==="chunkText"&&(d[l][1]._isInFirstContentOfListItem=!0,l++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,NL(p,n)),n=t[n],f=!0);else if(r[1]._container){for(l=n,o=void 0;l--;)if(u=p.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(o&&(p.get(o)[1].type="lineEndingBlank"),u[1].type="lineEnding",o=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;o&&(r[1].end={...p.get(o)[1].start},c=p.slice(o,n),c.unshift(r),p.splice(o,n-o+1,c))}}return lr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function NL(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const l=[];let u=n._tokenizer;u||(u=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const c=u.events,d=[],f={};let p,m,x=-1,y=n,w=0,C=0;const v=[C];for(;y;){for(;e.get(++o)[1]!==y;);l.push(o),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),m&&u.defineSkip(y.start),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(p),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),m=y,y=y.next}for(y=n;++x<c.length;)c[x][0]==="exit"&&c[x-1][0]==="enter"&&c[x][1].type===c[x-1][1].type&&c[x][1].start.line!==c[x][1].end.line&&(C=x+1,v.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(u.events=[],y?(y._tokenizer=void 0,y.previous=void 0):v.pop(),x=v.length;x--;){const S=c.slice(v[x],v[x+1]),b=l.pop();d.push([b,b+S.length-1]),e.splice(b,2,S)}for(d.reverse(),x=-1;++x<d.length;)f[w+d[x][0]]=w+d[x][1],w+=d[x][1]-d[x][0]-1;return f}const TL={resolve:LL,tokenize:DL},AL={partial:!0,tokenize:RL};function LL(e){return B1(e),e}function DL(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(c)}function o(c){return c===null?l(c):Xe(c)?e.check(AL,u,l)(c):(e.consume(c),o)}function l(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function u(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function RL(e,t,n){const r=this;return o;function o(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),bt(e,l,"linePrefix")}function l(u){if(u===null||Xe(u))return n(u);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):e.interrupt(r.parser.constructs.flow,n,t)(u)}}function $1(e,t,n,r,o,l,u,c,d){const f=d||Number.POSITIVE_INFINITY;let p=0;return m;function m(S){return S===60?(e.enter(r),e.enter(o),e.enter(l),e.consume(S),e.exit(l),x):S===null||S===32||S===41||Du(S)?n(S):(e.enter(r),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(S))}function x(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(o),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),y(S))}function y(S){return S===62?(e.exit("chunkString"),e.exit(c),x(S)):S===null||S===60||Xe(S)?n(S):(e.consume(S),S===92?w:y)}function w(S){return S===60||S===62||S===92?(e.consume(S),y):y(S)}function C(S){return!p&&(S===null||S===41||Pt(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(r),t(S)):p<f&&S===40?(e.consume(S),p++,C):S===41?(e.consume(S),p--,C):S===null||S===32||S===40||Du(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 z1(e,t,n,r,o,l){const u=this;let c=0,d;return f;function f(y){return e.enter(r),e.enter(o),e.consume(y),e.exit(o),e.enter(l),p}function p(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?n(y):y===93?(e.exit(l),e.enter(o),e.consume(y),e.exit(o),e.exit(r),t):Xe(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===null||y===91||y===93||Xe(y)||c++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!pt(y)),y===92?x:m)}function x(y){return y===91||y===92||y===93?(e.consume(y),c++,m):m(y)}}function H1(e,t,n,r,o,l){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(r),e.enter(o),e.consume(x),e.exit(o),u=x===40?41:x,d):n(x)}function d(x){return x===u?(e.enter(o),e.consume(x),e.exit(o),e.exit(r),t):(e.enter(l),f(x))}function f(x){return x===u?(e.exit(l),d(u)):x===null?n(x):Xe(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),bt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===u||x===null||Xe(x)?(e.exit("chunkString"),f(x)):(e.consume(x),x===92?m:p)}function m(x){return x===u||x===92?(e.consume(x),p):p(x)}}function fl(e,t){let n;return r;function r(o){return Xe(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):pt(o)?bt(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const OL={name:"definition",tokenize:IL},ML={partial:!0,tokenize:PL};function IL(e,t,n){const r=this;let o;return l;function l(y){return e.enter("definition"),u(y)}function u(y){return z1.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return o=Rr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),d):n(y)}function d(y){return Pt(y)?fl(e,f)(y):f(y)}function f(y){return $1(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(ML,m,m)(y)}function m(y){return pt(y)?bt(e,x,"whitespace")(y):x(y)}function x(y){return y===null||Xe(y)?(e.exit("definition"),r.parser.defined.push(o),t(y)):n(y)}}function PL(e,t,n){return r;function r(c){return Pt(c)?fl(e,o)(c):n(c)}function o(c){return H1(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return pt(c)?bt(e,u,"whitespace")(c):u(c)}function u(c){return c===null||Xe(c)?t(c):n(c)}}const BL={name:"hardBreakEscape",tokenize:$L};function $L(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),o}function o(l){return Xe(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const zL={name:"headingAtx",resolve:HL,tokenize:UL};function HL(e,t){let n=e.length-2,r=3,o,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},lr(e,r,n-r+1,[["enter",o,t],["enter",l,t],["exit",l,t],["exit",o,t]])),e}function UL(e,t,n){let r=0;return o;function o(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),u(p)}function u(p){return p===35&&r++<6?(e.consume(p),u):p===null||Pt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||Xe(p)?(e.exit("atxHeading"),t(p)):pt(p)?bt(e,c,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),c(p))}function f(p){return p===null||p===35||Pt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),f)}}const FL=["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"],Iv=["pre","script","style","textarea"],VL={concrete:!0,name:"htmlFlow",resolveTo:qL,tokenize:KL},GL={partial:!0,tokenize:XL},WL={partial:!0,tokenize:YL};function qL(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 KL(e,t,n){const r=this;let o,l,u,c,d;return f;function f(B){return p(B)}function p(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),x):B===47?(e.consume(B),l=!0,C):B===63?(e.consume(B),o=3,r.interrupt?t:R):On(B)?(e.consume(B),u=String.fromCharCode(B),v):n(B)}function x(B){return B===45?(e.consume(B),o=2,y):B===91?(e.consume(B),o=5,c=0,w):On(B)?(e.consume(B),o=4,r.interrupt?t:R):n(B)}function y(B){return B===45?(e.consume(B),r.interrupt?t:R):n(B)}function w(B){const ee="CDATA[";return B===ee.charCodeAt(c++)?(e.consume(B),c===ee.length?r.interrupt?t:W:w):n(B)}function C(B){return On(B)?(e.consume(B),u=String.fromCharCode(B),v):n(B)}function v(B){if(B===null||B===47||B===62||Pt(B)){const ee=B===47,J=u.toLowerCase();return!ee&&!l&&Iv.includes(J)?(o=1,r.interrupt?t(B):W(B)):FL.includes(u.toLowerCase())?(o=6,ee?(e.consume(B),S):r.interrupt?t(B):W(B)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):l?b(B):_(B))}return B===45||An(B)?(e.consume(B),u+=String.fromCharCode(B),v):n(B)}function S(B){return B===62?(e.consume(B),r.interrupt?t:W):n(B)}function b(B){return pt(B)?(e.consume(B),b):P(B)}function _(B){return B===47?(e.consume(B),P):B===58||B===95||On(B)?(e.consume(B),j):pt(B)?(e.consume(B),_):P(B)}function j(B){return B===45||B===46||B===58||B===95||An(B)?(e.consume(B),j):E(B)}function E(B){return B===61?(e.consume(B),T):pt(B)?(e.consume(B),E):_(B)}function T(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),d=B,D):pt(B)?(e.consume(B),T):L(B)}function D(B){return B===d?(e.consume(B),d=null,O):B===null||Xe(B)?n(B):(e.consume(B),D)}function L(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Pt(B)?E(B):(e.consume(B),L)}function O(B){return B===47||B===62||pt(B)?_(B):n(B)}function P(B){return B===62?(e.consume(B),q):n(B)}function q(B){return B===null||Xe(B)?W(B):pt(B)?(e.consume(B),q):n(B)}function W(B){return B===45&&o===2?(e.consume(B),U):B===60&&o===1?(e.consume(B),Q):B===62&&o===4?(e.consume(B),I):B===63&&o===3?(e.consume(B),R):B===93&&o===5?(e.consume(B),z):Xe(B)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(GL,G,M)(B)):B===null||Xe(B)?(e.exit("htmlFlowData"),M(B)):(e.consume(B),W)}function M(B){return e.check(WL,H,G)(B)}function H(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),V}function V(B){return B===null||Xe(B)?M(B):(e.enter("htmlFlowData"),W(B))}function U(B){return B===45?(e.consume(B),R):W(B)}function Q(B){return B===47?(e.consume(B),u="",X):W(B)}function X(B){if(B===62){const ee=u.toLowerCase();return Iv.includes(ee)?(e.consume(B),I):W(B)}return On(B)&&u.length<8?(e.consume(B),u+=String.fromCharCode(B),X):W(B)}function z(B){return B===93?(e.consume(B),R):W(B)}function R(B){return B===62?(e.consume(B),I):B===45&&o===2?(e.consume(B),R):W(B)}function I(B){return B===null||Xe(B)?(e.exit("htmlFlowData"),G(B)):(e.consume(B),I)}function G(B){return e.exit("htmlFlow"),t(B)}}function YL(e,t,n){const r=this;return o;function o(u){return Xe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}function XL(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Ol,t,n)}}const QL={name:"htmlText",tokenize:JL};function JL(e,t,n){const r=this;let o,l,u;return c;function c(R){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(R),d}function d(R){return R===33?(e.consume(R),f):R===47?(e.consume(R),E):R===63?(e.consume(R),_):On(R)?(e.consume(R),L):n(R)}function f(R){return R===45?(e.consume(R),p):R===91?(e.consume(R),l=0,w):On(R)?(e.consume(R),b):n(R)}function p(R){return R===45?(e.consume(R),y):n(R)}function m(R){return R===null?n(R):R===45?(e.consume(R),x):Xe(R)?(u=m,Q(R)):(e.consume(R),m)}function x(R){return R===45?(e.consume(R),y):m(R)}function y(R){return R===62?U(R):R===45?x(R):m(R)}function w(R){const I="CDATA[";return R===I.charCodeAt(l++)?(e.consume(R),l===I.length?C:w):n(R)}function C(R){return R===null?n(R):R===93?(e.consume(R),v):Xe(R)?(u=C,Q(R)):(e.consume(R),C)}function v(R){return R===93?(e.consume(R),S):C(R)}function S(R){return R===62?U(R):R===93?(e.consume(R),S):C(R)}function b(R){return R===null||R===62?U(R):Xe(R)?(u=b,Q(R)):(e.consume(R),b)}function _(R){return R===null?n(R):R===63?(e.consume(R),j):Xe(R)?(u=_,Q(R)):(e.consume(R),_)}function j(R){return R===62?U(R):_(R)}function E(R){return On(R)?(e.consume(R),T):n(R)}function T(R){return R===45||An(R)?(e.consume(R),T):D(R)}function D(R){return Xe(R)?(u=D,Q(R)):pt(R)?(e.consume(R),D):U(R)}function L(R){return R===45||An(R)?(e.consume(R),L):R===47||R===62||Pt(R)?O(R):n(R)}function O(R){return R===47?(e.consume(R),U):R===58||R===95||On(R)?(e.consume(R),P):Xe(R)?(u=O,Q(R)):pt(R)?(e.consume(R),O):U(R)}function P(R){return R===45||R===46||R===58||R===95||An(R)?(e.consume(R),P):q(R)}function q(R){return R===61?(e.consume(R),W):Xe(R)?(u=q,Q(R)):pt(R)?(e.consume(R),q):O(R)}function W(R){return R===null||R===60||R===61||R===62||R===96?n(R):R===34||R===39?(e.consume(R),o=R,M):Xe(R)?(u=W,Q(R)):pt(R)?(e.consume(R),W):(e.consume(R),H)}function M(R){return R===o?(e.consume(R),o=void 0,V):R===null?n(R):Xe(R)?(u=M,Q(R)):(e.consume(R),M)}function H(R){return R===null||R===34||R===39||R===60||R===61||R===96?n(R):R===47||R===62||Pt(R)?O(R):(e.consume(R),H)}function V(R){return R===47||R===62||Pt(R)?O(R):n(R)}function U(R){return R===62?(e.consume(R),e.exit("htmlTextData"),e.exit("htmlText"),t):n(R)}function Q(R){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),X}function X(R){return pt(R)?bt(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):z(R)}function z(R){return e.enter("htmlTextData"),u(R)}}const qp={name:"labelEnd",resolveAll:nD,resolveTo:rD,tokenize:sD},ZL={tokenize:iD},eD={tokenize:aD},tD={tokenize:oD};function nD(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 o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&lr(e,0,e.length,n),e}function rD(e,t){let n=e.length,r=0,o,l,u,c;for(;n--;)if(o=e[n][1],l){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(l=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(u=n);const d={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[l][1].start},end:{...e[u][1].end}},p={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[u-2][1].start}};return c=[["enter",d,t],["enter",f,t]],c=br(c,e.slice(l+1,l+r+3)),c=br(c,[["enter",p,t]]),c=br(c,cd(t.parser.constructs.insideSpan.null,e.slice(l+r+4,u-3),t)),c=br(c,[["exit",p,t],e[u-2],e[u-1],["exit",f,t]]),c=br(c,e.slice(u+1)),c=br(c,[["exit",d,t]]),lr(e,l,e.length,c),e}function sD(e,t,n){const r=this;let o=r.events.length,l,u;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){l=r.events[o][1];break}return c;function c(x){return l?l._inactive?m(x):(u=r.parser.defined.includes(Rr(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),d):n(x)}function d(x){return x===40?e.attempt(ZL,p,u?p:m)(x):x===91?e.attempt(eD,p,u?f:m)(x):u?p(x):m(x)}function f(x){return e.attempt(tD,p,m)(x)}function p(x){return t(x)}function m(x){return l._balanced=!0,n(x)}}function iD(e,t,n){return r;function r(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),o}function o(m){return Pt(m)?fl(e,l)(m):l(m)}function l(m){return m===41?p(m):$1(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return Pt(m)?fl(e,d)(m):p(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?H1(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function f(m){return Pt(m)?fl(e,p)(m):p(m)}function p(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),t):n(m)}}function aD(e,t,n){const r=this;return o;function o(c){return z1.call(r,e,l,u,"reference","referenceMarker","referenceString")(c)}function l(c){return r.parser.defined.includes(Rr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function u(c){return n(c)}}function oD(e,t,n){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),o}function o(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const lD={name:"labelStartImage",resolveAll:qp.resolveAll,tokenize:cD};function cD(e,t,n){const r=this;return o;function o(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),l}function l(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),u):n(c)}function u(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const uD={name:"labelStartLink",resolveAll:qp.resolveAll,tokenize:dD};function dD(e,t,n){const r=this;return o;function o(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const om={name:"lineEnding",tokenize:hD};function hD(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),bt(e,t,"linePrefix")}}const Su={name:"thematicBreak",tokenize:fD};function fD(e,t,n){let r=0,o;return l;function l(f){return e.enter("thematicBreak"),u(f)}function u(f){return o=f,c(f)}function c(f){return f===o?(e.enter("thematicBreakSequence"),d(f)):r>=3&&(f===null||Xe(f))?(e.exit("thematicBreak"),t(f)):n(f)}function d(f){return f===o?(e.consume(f),r++,d):(e.exit("thematicBreakSequence"),pt(f)?bt(e,c,"whitespace")(f):c(f))}}const Fn={continuation:{tokenize:xD},exit:_D,name:"list",tokenize:gD},mD={partial:!0,tokenize:bD},pD={partial:!0,tokenize:yD};function gD(e,t,n){const r=this,o=r.events[r.events.length-1];let l=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,u=0;return c;function c(y){const w=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:Zm(y)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Su,n,f)(y):f(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return Zm(y)&&++u<10?(e.consume(y),d):(!r.interrupt||u<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Ol,r.interrupt?n:p,e.attempt(mD,x,m))}function p(y){return r.containerState.initialBlankLine=!0,l++,x(y)}function m(y){return pt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),x):n(y)}function x(y){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function xD(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ol,o,l);function o(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,bt(e,t,"listItemIndent",r.containerState.size+1)(c)}function l(c){return r.containerState.furtherBlankLines||!pt(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,u(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(pD,t,u)(c))}function u(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,bt(e,e.attempt(Fn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function yD(e,t,n){const r=this;return bt(e,o,"listItemIndent",r.containerState.size+1);function o(l){const u=r.events[r.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===r.containerState.size?t(l):n(l)}}function _D(e){e.exit(this.containerState.type)}function bD(e,t,n){const r=this;return bt(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(l){const u=r.events[r.events.length-1];return!pt(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const Pv={name:"setextUnderline",resolveTo:vD,tokenize:SD};function vD(e,t){let n=e.length,r,o,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",l?(e.splice(o,0,["enter",u,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=u,e.push(["exit",u,t]),e}function SD(e,t,n){const r=this;let o;return l;function l(f){let p=r.events.length,m;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){m=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||m)?(e.enter("setextHeadingLine"),o=f,u(f)):n(f)}function u(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===o?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),pt(f)?bt(e,d,"lineSuffix")(f):d(f))}function d(f){return f===null||Xe(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const wD={tokenize:CD};function CD(e){const t=this,n=e.attempt(Ol,r,e.attempt(this.parser.constructs.flowInitial,o,bt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(TL,o)),"linePrefix")));return n;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const kD={resolveAll:F1()},ED=U1("string"),jD=U1("text");function U1(e){return{resolveAll:F1(e==="text"?ND:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],l=n.attempt(o,u,c);return u;function u(p){return f(p)?l(p):c(p)}function c(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),d}function d(p){return f(p)?(n.exit("data"),l(p)):(n.consume(p),d)}function f(p){if(p===null)return!0;const m=o[p];let x=-1;if(m)for(;++x<m.length;){const y=m[x];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function F1(e){return t;function t(n,r){let o=-1,l;for(;++o<=n.length;)l===void 0?n[o]&&n[o][1].type==="data"&&(l=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==l+2&&(n[l][1].end=n[o-1][1].end,n.splice(l+2,o-l-2),o=l+2),l=void 0);return e?e(n,r):n}}function ND(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],o=t.sliceStream(r);let l=o.length,u=-1,c=0,d;for(;l--;){const f=o[l];if(typeof f=="string"){for(u=f.length;f.charCodeAt(u-1)===32;)c++,u--;if(u)break;u=-1}else if(f===-2)d=!0,c++;else if(f!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const f={type:n===e.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?u:r.start._bufferIndex+u,_index:r.start._index+l,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const TD={42:Fn,43:Fn,45:Fn,48:Fn,49:Fn,50:Fn,51:Fn,52:Fn,53:Fn,54:Fn,55:Fn,56:Fn,57:Fn,62:M1},AD={91:OL},LD={[-2]:am,[-1]:am,32:am},DD={35:zL,42:Su,45:[Pv,Su],60:VL,61:Pv,95:Su,96:Mv,126:Mv},RD={38:P1,92:I1},OD={[-5]:om,[-4]:om,[-3]:om,33:lD,38:P1,42:ep,60:[uL,QL],91:uD,92:[BL,I1],93:qp,95:ep,96:wL},MD={null:[ep,kD]},ID={null:[42,95]},PD={null:[]},BD=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ID,contentInitial:AD,disable:PD,document:TD,flow:DD,flowInitial:LD,insideSpan:MD,string:RD,text:OD},Symbol.toStringTag,{value:"Module"}));function $D(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 o={},l=[];let u=[],c=[];const d={attempt:D(E),check:D(T),consume:b,enter:_,exit:j,interrupt:D(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:m};let p=t.tokenize.call(f,d);return t.resolveAll&&l.push(t),f;function m(q){return u=br(u,q),v(),u[u.length-1]!==null?[]:(L(t,0),f.events=cd(l,f.events,f),f.events)}function x(q,W){return HD(y(q),W)}function y(q){return zD(u,q)}function w(){const{_bufferIndex:q,_index:W,line:M,column:H,offset:V}=r;return{_bufferIndex:q,_index:W,line:M,column:H,offset:V}}function C(q){o[q.line]=q.column,P()}function v(){let q;for(;r._index<u.length;){const W=u[r._index];if(typeof W=="string")for(q=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===q&&r._bufferIndex<W.length;)S(W.charCodeAt(r._bufferIndex));else S(W)}}function S(q){p=p(q)}function b(q){Xe(q)?(r.line++,r.column=1,r.offset+=q===-3?2:1,P()):q!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===u[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=q}function _(q,W){const M=W||{};return M.type=q,M.start=w(),f.events.push(["enter",M,f]),c.push(M),M}function j(q){const W=c.pop();return W.end=w(),f.events.push(["exit",W,f]),W}function E(q,W){L(q,W.from)}function T(q,W){W.restore()}function D(q,W){return M;function M(H,V,U){let Q,X,z,R;return Array.isArray(H)?G(H):"tokenize"in H?G([H]):I(H);function I(ne){return K;function K(F){const te=F!==null&&ne[F],re=F!==null&&ne.null,pe=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(re)?re:re?[re]:[]];return G(pe)(F)}}function G(ne){return Q=ne,X=0,ne.length===0?U:B(ne[X])}function B(ne){return K;function K(F){return R=O(),z=ne,ne.partial||(f.currentConstruct=ne),ne.name&&f.parser.constructs.disable.null.includes(ne.name)?J():ne.tokenize.call(W?Object.assign(Object.create(f),W):f,d,ee,J)(F)}}function ee(ne){return q(z,R),V}function J(ne){return R.restore(),++X<Q.length?B(Q[X]):U}}}function L(q,W){q.resolveAll&&!l.includes(q)&&l.push(q),q.resolve&&lr(f.events,W,f.events.length-W,q.resolve(f.events.slice(W),f)),q.resolveTo&&(f.events=q.resolveTo(f.events,f))}function O(){const q=w(),W=f.previous,M=f.currentConstruct,H=f.events.length,V=Array.from(c);return{from:H,restore:U};function U(){r=q,f.previous=W,f.currentConstruct=M,f.events.length=H,c=V,P()}}function P(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function zD(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,l=t.end._bufferIndex;let u;if(n===o)u=[e[n].slice(r,l)];else{if(u=e.slice(n,o),r>-1){const c=u[0];typeof c=="string"?u[0]=c.slice(r):u.shift()}l>0&&u.push(e[o].slice(0,l))}return u}function HD(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const l=e[n];let u;if(typeof l=="string")u=l;else switch(l){case-5:{u="\r";break}case-4:{u=`
|
|
98
|
+
`;break}case-3:{u=`\r
|
|
99
|
+
`;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&o)continue;u=" ";break}default:u=String.fromCharCode(l)}o=l===-2,r.push(u)}return r.join("")}function UD(e){const r={constructs:R1([BD,...(e||{}).extensions||[]]),content:o(rL),defined:[],document:o(iL),flow:o(wD),lazy:{},string:o(ED),text:o(jD)};return r;function o(l){return u;function u(c){return $D(r,l,c)}}}function FD(e){for(;!B1(e););return e}const Bv=/[\0\t\n\r]/g;function VD(){let e=1,t="",n=!0,r;return o;function o(l,u,c){const d=[];let f,p,m,x,y;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(u||void 0).decode(l)),m=0,t="",n&&(l.charCodeAt(0)===65279&&m++,n=void 0);m<l.length;){if(Bv.lastIndex=m,f=Bv.exec(l),x=f&&f.index!==void 0?f.index:l.length,y=l.charCodeAt(x),!f){t=l.slice(m);break}if(y===10&&m===x&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),m<x&&(d.push(l.slice(m,x)),e+=x-m),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}m=x+1}return c&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const GD=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function WD(e){return e.replace(GD,qD)}function qD(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),l=o===120||o===88;return O1(n.slice(l?2:1),l?16:10)}return Wp(n)||e}const V1={}.hasOwnProperty;function KD(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),YD(n)(FD(UD(n).document().write(VD()(e,t,!0))))}function YD(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(he),autolinkProtocol:O,autolinkEmail:O,atxHeading:l(Ne),blockQuote:l(re),characterEscape:O,characterReference:O,codeFenced:l(pe),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(pe,u),codeText:l(be,u),codeTextData:O,data:O,codeFlowValue:O,definition:l(Pe),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l($e),hardBreakEscape:l(je),hardBreakTrailing:l(je),htmlFlow:l(oe,u),htmlFlowData:O,htmlText:l(oe,u),htmlTextData:O,image:l(Be),label:u,link:l(he),listItem:l(xe),listItemValue:x,listOrdered:l(se,m),listUnordered:l(se),paragraph:l(Ve),reference:B,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l(Ne),strong:l(Ze),thematicBreak:l(Et)},exit:{atxHeading:d(),atxHeadingSequence:E,autolink:d(),autolinkEmail:te,autolinkProtocol:F,blockQuote:d(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:J,characterReferenceMarkerNumeric:J,characterReferenceValue:ne,characterReference:K,codeFenced:d(v),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:P,codeIndented:d(S),codeText:d(V),codeTextData:P,data:P,definition:d(),definitionDestinationString:j,definitionLabelString:b,definitionTitleString:_,emphasis:d(),hardBreakEscape:d(W),hardBreakTrailing:d(W),htmlFlow:d(M),htmlFlowData:P,htmlText:d(H),htmlTextData:P,image:d(Q),label:z,labelText:X,lineEnding:q,link:d(U),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:ee,resourceDestinationString:R,resourceTitleString:I,resource:G,setextHeading:d(L),setextHeadingLineSequence:D,setextHeadingText:T,strong:d(),thematicBreak:d()}};G1(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ce){let Te={type:"root",children:[]};const Fe={stack:[Te],tokenStack:[],config:t,enter:c,exit:f,buffer:u,resume:p,data:n},Ye=[];let tt=-1;for(;++tt<ce.length;)if(ce[tt][1].type==="listOrdered"||ce[tt][1].type==="listUnordered")if(ce[tt][0]==="enter")Ye.push(tt);else{const kt=Ye.pop();tt=o(ce,kt,tt)}for(tt=-1;++tt<ce.length;){const kt=t[ce[tt][0]];V1.call(kt,ce[tt][1].type)&&kt[ce[tt][1].type].call(Object.assign({sliceSerialize:ce[tt][2].sliceSerialize},Fe),ce[tt][1])}if(Fe.tokenStack.length>0){const kt=Fe.tokenStack[Fe.tokenStack.length-1];(kt[1]||$v).call(Fe,void 0,kt[0])}for(Te.position={start:Vs(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:Vs(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},tt=-1;++tt<t.transforms.length;)Te=t.transforms[tt](Te)||Te;return Te}function o(ce,Te,Fe){let Ye=Te-1,tt=-1,kt=!1,at,me,Oe,We;for(;++Ye<=Fe;){const et=ce[Ye];switch(et[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{et[0]==="enter"?tt++:tt--,We=void 0;break}case"lineEndingBlank":{et[0]==="enter"&&(at&&!We&&!tt&&!Oe&&(Oe=Ye),We=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:We=void 0}if(!tt&&et[0]==="enter"&&et[1].type==="listItemPrefix"||tt===-1&&et[0]==="exit"&&(et[1].type==="listUnordered"||et[1].type==="listOrdered")){if(at){let En=Ye;for(me=void 0;En--;){const Wt=ce[En];if(Wt[1].type==="lineEnding"||Wt[1].type==="lineEndingBlank"){if(Wt[0]==="exit")continue;me&&(ce[me][1].type="lineEndingBlank",kt=!0),Wt[1].type="lineEnding",me=En}else if(!(Wt[1].type==="linePrefix"||Wt[1].type==="blockQuotePrefix"||Wt[1].type==="blockQuotePrefixWhitespace"||Wt[1].type==="blockQuoteMarker"||Wt[1].type==="listItemIndent"))break}Oe&&(!me||Oe<me)&&(at._spread=!0),at.end=Object.assign({},me?ce[me][1].start:et[1].end),ce.splice(me||Ye,0,["exit",at,et[2]]),Ye++,Fe++}if(et[1].type==="listItemPrefix"){const En={type:"listItem",_spread:!1,start:Object.assign({},et[1].start),end:void 0};at=En,ce.splice(Ye,0,["enter",En,et[2]]),Ye++,Fe++,Oe=void 0,We=!0}}}return ce[Te][1]._spread=kt,Fe}function l(ce,Te){return Fe;function Fe(Ye){c.call(this,ce(Ye),Ye),Te&&Te.call(this,Ye)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(ce,Te,Fe){this.stack[this.stack.length-1].children.push(ce),this.stack.push(ce),this.tokenStack.push([Te,Fe||void 0]),ce.position={start:Vs(Te.start),end:void 0}}function d(ce){return Te;function Te(Fe){ce&&ce.call(this,Fe),f.call(this,Fe)}}function f(ce,Te){const Fe=this.stack.pop(),Ye=this.tokenStack.pop();if(Ye)Ye[0].type!==ce.type&&(Te?Te.call(this,ce,Ye[0]):(Ye[1]||$v).call(this,ce,Ye[0]));else throw new Error("Cannot close `"+ce.type+"` ("+hl({start:ce.start,end:ce.end})+"): it’s not open");Fe.position.end=Vs(ce.end)}function p(){return Gp(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function x(ce){if(this.data.expectingFirstListItemValue){const Te=this.stack[this.stack.length-2];Te.start=Number.parseInt(this.sliceSerialize(ce),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.lang=ce}function w(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.meta=ce}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.value=ce.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.value=ce.replace(/(\r?\n|\r)$/g,"")}function b(ce){const Te=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Te,Fe.identifier=Rr(this.sliceSerialize(ce)).toLowerCase()}function _(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.title=ce}function j(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.url=ce}function E(ce){const Te=this.stack[this.stack.length-1];if(!Te.depth){const Fe=this.sliceSerialize(ce).length;Te.depth=Fe}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function D(ce){const Te=this.stack[this.stack.length-1];Te.depth=this.sliceSerialize(ce).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function O(ce){const Fe=this.stack[this.stack.length-1].children;let Ye=Fe[Fe.length-1];(!Ye||Ye.type!=="text")&&(Ye=it(),Ye.position={start:Vs(ce.start),end:void 0},Fe.push(Ye)),this.stack.push(Ye)}function P(ce){const Te=this.stack.pop();Te.value+=this.sliceSerialize(ce),Te.position.end=Vs(ce.end)}function q(ce){const Te=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Fe=Te.children[Te.children.length-1];Fe.position.end=Vs(ce.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Te.type)&&(O.call(this,ce),P.call(this,ce))}function W(){this.data.atHardBreak=!0}function M(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.value=ce}function H(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.value=ce}function V(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.value=ce}function U(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const Te=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=Te,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function Q(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const Te=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=Te,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function X(ce){const Te=this.sliceSerialize(ce),Fe=this.stack[this.stack.length-2];Fe.label=WD(Te),Fe.identifier=Rr(Te).toLowerCase()}function z(){const ce=this.stack[this.stack.length-1],Te=this.resume(),Fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Fe.type==="link"){const Ye=ce.children;Fe.children=Ye}else Fe.alt=Te}function R(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.url=ce}function I(){const ce=this.resume(),Te=this.stack[this.stack.length-1];Te.title=ce}function G(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function ee(ce){const Te=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Te,Fe.identifier=Rr(this.sliceSerialize(ce)).toLowerCase(),this.data.referenceType="full"}function J(ce){this.data.characterReferenceType=ce.type}function ne(ce){const Te=this.sliceSerialize(ce),Fe=this.data.characterReferenceType;let Ye;Fe?(Ye=O1(Te,Fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ye=Wp(Te);const tt=this.stack[this.stack.length-1];tt.value+=Ye}function K(ce){const Te=this.stack.pop();Te.position.end=Vs(ce.end)}function F(ce){P.call(this,ce);const Te=this.stack[this.stack.length-1];Te.url=this.sliceSerialize(ce)}function te(ce){P.call(this,ce);const Te=this.stack[this.stack.length-1];Te.url="mailto:"+this.sliceSerialize(ce)}function re(){return{type:"blockquote",children:[]}}function pe(){return{type:"code",lang:null,meta:null,value:""}}function be(){return{type:"inlineCode",value:""}}function Pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $e(){return{type:"emphasis",children:[]}}function Ne(){return{type:"heading",depth:0,children:[]}}function je(){return{type:"break"}}function oe(){return{type:"html",value:""}}function Be(){return{type:"image",title:null,url:"",alt:null}}function he(){return{type:"link",title:null,url:"",children:[]}}function se(ce){return{type:"list",ordered:ce.type==="listOrdered",start:null,spread:ce._spread,children:[]}}function xe(ce){return{type:"listItem",spread:ce._spread,checked:null,children:[]}}function Ve(){return{type:"paragraph",children:[]}}function Ze(){return{type:"strong",children:[]}}function it(){return{type:"text",value:""}}function Et(){return{type:"thematicBreak"}}}function Vs(e){return{line:e.line,column:e.column,offset:e.offset}}function G1(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?G1(e,r):XD(e,r)}}function XD(e,t){let n;for(n in t)if(V1.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function $v(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+hl({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+hl({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+hl({start:t.start,end:t.end})+") is still open")}function QD(e){const t=this;t.parser=n;function n(r){return KD(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function JD(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 ZD(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
100
|
+
`}]}function eR(e,t){const n=t.value?t.value+`
|
|
101
|
+
`:"",r={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(r.className=["language-"+o[0]]);let l={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function tR(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nR(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function rR(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=Za(r.toLowerCase()),l=e.footnoteOrder.indexOf(r);let u,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),u=e.footnoteOrder.length):u=l+1,c+=1,e.footnoteCounts.set(r,c);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const f={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,f),e.applyData(t,f)}function sR(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 iR(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function W1(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 o=e.all(t),l=o[0];l&&l.type==="text"?l.value="["+l.value:o.unshift({type:"text",value:"["});const u=o[o.length-1];return u&&u.type==="text"?u.value+=r:o.push({type:"text",value:r}),o}function aR(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return W1(e,t);const o={src:Za(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(o.title=r.title);const l={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,l),e.applyData(t,l)}function oR(e,t){const n={src:Za(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 lR(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 cR(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return W1(e,t);const o={href:Za(r.url||"")};r.title!==null&&r.title!==void 0&&(o.title=r.title);const l={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function uR(e,t){const n={href:Za(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 dR(e,t,n){const r=e.all(t),o=n?hR(n):q1(t),l={},u=[];if(typeof t.checked=="boolean"){const p=r[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},r.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const p=r[c];(o||c!==0||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
|
|
102
|
+
`}),p.type==="element"&&p.tagName==="p"&&!o?u.push(...p.children):u.push(p)}const d=r[r.length-1];d&&(o||d.type!=="element"||d.tagName!=="p")&&u.push({type:"text",value:`
|
|
103
|
+
`});const f={type:"element",tagName:"li",properties:l,children:u};return e.patch(t,f),e.applyData(t,f)}function hR(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=q1(n[r])}return t}function q1(e){const t=e.spread;return t??e.children.length>1}function fR(e,t){const n={},r=e.all(t);let o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<r.length;){const u=r[o];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,l),e.applyData(t,l)}function mR(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pR(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function gR(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xR(e,t){const n=e.all(t),r=n.shift(),o=[];if(r){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],u),o.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=Hp(t.children[1]),d=E1(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),o.push(u)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,l),e.applyData(t,l)}function yR(e,t,n){const r=n?n.children:void 0,l=(r?r.indexOf(t):1)===0?"th":"td",u=n&&n.type==="table"?n.align:void 0,c=u?u.length:t.children.length;let d=-1;const f=[];for(;++d<c;){const m=t.children[d],x={},y=u?u[d]:void 0;y&&(x.align=y);let w={type:"element",tagName:l,properties:x,children:[]};m&&(w.children=e.all(m),e.patch(m,w),w=e.applyData(m,w)),f.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,p),e.applyData(t,p)}function _R(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const zv=9,Hv=32;function bR(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),o=0;const l=[];for(;r;)l.push(Uv(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return l.push(Uv(t.slice(o),o>0,!1)),l.join("")}function Uv(e,t,n){let r=0,o=e.length;if(t){let l=e.codePointAt(r);for(;l===zv||l===Hv;)r++,l=e.codePointAt(r)}if(n){let l=e.codePointAt(o-1);for(;l===zv||l===Hv;)o--,l=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}function vR(e,t){const n={type:"text",value:bR(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function SR(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const wR={blockquote:JD,break:ZD,code:eR,delete:tR,emphasis:nR,footnoteReference:rR,heading:sR,html:iR,imageReference:aR,image:oR,inlineCode:lR,linkReference:cR,link:uR,listItem:dR,list:fR,paragraph:mR,root:pR,strong:gR,table:xR,tableCell:_R,tableRow:yR,text:vR,thematicBreak:SR,toml:iu,yaml:iu,definition:iu,footnoteDefinition:iu};function iu(){}const K1=-1,ud=0,ml=1,Ru=2,Kp=3,Yp=4,Xp=5,Qp=6,Y1=7,X1=8,Fv=typeof self=="object"?self:globalThis,CR=(e,t)=>{const n=(o,l)=>(e.set(l,o),o),r=o=>{if(e.has(o))return e.get(o);const[l,u]=t[o];switch(l){case ud:case K1:return n(u,o);case ml:{const c=n([],o);for(const d of u)c.push(r(d));return c}case Ru:{const c=n({},o);for(const[d,f]of u)c[r(d)]=r(f);return c}case Kp:return n(new Date(u),o);case Yp:{const{source:c,flags:d}=u;return n(new RegExp(c,d),o)}case Xp:{const c=n(new Map,o);for(const[d,f]of u)c.set(r(d),r(f));return c}case Qp:{const c=n(new Set,o);for(const d of u)c.add(r(d));return c}case Y1:{const{name:c,message:d}=u;return n(new Fv[c](d),o)}case X1:return n(BigInt(u),o);case"BigInt":return n(Object(BigInt(u)),o);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return n(new DataView(c),u)}}return n(new Fv[l](u),o)};return r},Vv=e=>CR(new Map,e)(0),Na="",{toString:kR}={},{keys:ER}=Object,tl=e=>{const t=typeof e;if(t!=="object"||!e)return[ud,t];const n=kR.call(e).slice(8,-1);switch(n){case"Array":return[ml,Na];case"Object":return[Ru,Na];case"Date":return[Kp,Na];case"RegExp":return[Yp,Na];case"Map":return[Xp,Na];case"Set":return[Qp,Na];case"DataView":return[ml,n]}return n.includes("Array")?[ml,n]:n.includes("Error")?[Y1,n]:[Ru,n]},au=([e,t])=>e===ud&&(t==="function"||t==="symbol"),jR=(e,t,n,r)=>{const o=(u,c)=>{const d=r.push(u)-1;return n.set(c,d),d},l=u=>{if(n.has(u))return n.get(u);let[c,d]=tl(u);switch(c){case ud:{let p=u;switch(d){case"bigint":c=X1,p=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return o([K1],u)}return o([c,p],u)}case ml:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),o([d,[...x]],u)}const p=[],m=o([c,p],u);for(const x of u)p.push(l(x));return m}case Ru:{if(d)switch(d){case"BigInt":return o([d,u.toString()],u);case"Boolean":case"Number":case"String":return o([d,u.valueOf()],u)}if(t&&"toJSON"in u)return l(u.toJSON());const p=[],m=o([c,p],u);for(const x of ER(u))(e||!au(tl(u[x])))&&p.push([l(x),l(u[x])]);return m}case Kp:return o([c,u.toISOString()],u);case Yp:{const{source:p,flags:m}=u;return o([c,{source:p,flags:m}],u)}case Xp:{const p=[],m=o([c,p],u);for(const[x,y]of u)(e||!(au(tl(x))||au(tl(y))))&&p.push([l(x),l(y)]);return m}case Qp:{const p=[],m=o([c,p],u);for(const x of u)(e||!au(tl(x)))&&p.push(l(x));return m}}const{message:f}=u;return o([c,{name:d,message:f}],u)};return l},Gv=(e,{json:t,lossy:n}={})=>{const r=[];return jR(!(t||n),!!t,new Map,r)(e),r},Ou=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Vv(Gv(e,t)):structuredClone(e):(e,t)=>Vv(Gv(e,t));function NR(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 TR(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function AR(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||NR,r=e.options.footnoteBackLabel||TR,o=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[d]);if(!f)continue;const p=e.all(f),m=String(f.identifier).toUpperCase(),x=Za(m.toLowerCase());let y=0;const w=[],C=e.footnoteCounts.get(m);for(;C!==void 0&&++y<=C;){w.length>0&&w.push({type:"text",value:" "});let b=typeof n=="string"?n:n(d,y);typeof b=="string"&&(b={type:"text",value:b}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,y),className:["data-footnote-backref"]},children:Array.isArray(b)?b:[b]})}const v=p[p.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const b=v.children[v.children.length-1];b&&b.type==="text"?b.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...w)}else p.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(p,!0)};e.patch(f,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...Ou(u),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
104
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
105
|
+
`}]}}const dd=(function(e){if(e==null)return OR;if(typeof e=="function")return hd(e);if(typeof e=="object")return Array.isArray(e)?LR(e):DR(e);if(typeof e=="string")return RR(e);throw new Error("Expected function, string, or object as test")});function LR(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=dd(e[n]);return hd(r);function r(...o){let l=-1;for(;++l<t.length;)if(t[l].apply(this,o))return!0;return!1}}function DR(e){const t=e;return hd(n);function n(r){const o=r;let l;for(l in e)if(o[l]!==t[l])return!1;return!0}}function RR(e){return hd(t);function t(n){return n&&n.type===e}}function hd(e){return t;function t(n,r,o){return!!(MR(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function OR(){return!0}function MR(e){return e!==null&&typeof e=="object"&&"type"in e}const Q1=[],IR=!0,tp=!1,PR="skip";function J1(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;const l=dd(o),u=r?-1:1;c(e,void 0,[])();function c(d,f,p){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const y=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return x;function x(){let y=Q1,w,C,v;if((!t||l(d,f,p[p.length-1]||void 0))&&(y=BR(n(d,p)),y[0]===tp))return y;if("children"in d&&d.children){const S=d;if(S.children&&y[0]!==PR)for(C=(r?S.children.length:-1)+u,v=p.concat(S);C>-1&&C<S.children.length;){const b=S.children[C];if(w=c(b,C,v)(),w[0]===tp)return w;C=typeof w[1]=="number"?w[1]:C+u}}return y}}}function BR(e){return Array.isArray(e)?e:typeof e=="number"?[IR,e]:e==null?Q1:[e]}function Jp(e,t,n,r){let o,l,u;typeof t=="function"&&typeof n!="function"?(l=void 0,u=t,o=n):(l=t,u=n,o=r),J1(e,l,c,o);function c(d,f){const p=f[f.length-1],m=p?p.children.indexOf(d):void 0;return u(d,m,p)}}const np={}.hasOwnProperty,$R={};function zR(e,t){const n=t||$R,r=new Map,o=new Map,l=new Map,u={...wR,...n.handlers},c={all:f,applyData:UR,definitionById:r,footnoteById:o,footnoteCounts:l,footnoteOrder:[],handlers:u,one:d,options:n,patch:HR,wrap:VR};return Jp(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?r:o,x=String(p.identifier).toUpperCase();m.has(x)||m.set(x,p)}}),c;function d(p,m){const x=p.type,y=c.handlers[x];if(np.call(c.handlers,x)&&y)return y(c,p,m);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in p){const{children:C,...v}=p,S=Ou(v);return S.children=c.all(p),S}return Ou(p)}return(c.options.unknownHandler||FR)(c,p,m)}function f(p){const m=[];if("children"in p){const x=p.children;let y=-1;for(;++y<x.length;){const w=c.one(x[y],p);if(w){if(y&&x[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Wv(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=Wv(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function HR(e,t){e.position&&(t.position=TA(e))}function UR(e,t){let n=t;if(e&&e.data){const r=e.data.hName,o=e.data.hChildren,l=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const u="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:u}}n.type==="element"&&l&&Object.assign(n.properties,Ou(l)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function FR(e,t){const n=t.data||{},r="value"in t&&!(np.call(n,"hProperties")||np.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 VR(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
106
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
107
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
108
|
+
`}),n}function Wv(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function qv(e,t){const n=zR(e,t),r=n.one(e,void 0),o=AR(n),l=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&l.children.push({type:"text",value:`
|
|
109
|
+
`},o),l}function GR(e,t){return e&&"run"in e?async function(n,r){const o=qv(n,{file:r,...t});await e.run(o,r)}:function(n,r){return qv(n,{file:r,...e||t})}}function Kv(e){if(e)throw e}var lm,Yv;function WR(){if(Yv)return lm;Yv=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},l=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var p=e.call(f,"constructor"),m=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!m)return!1;var x;for(x in f);return typeof x>"u"||e.call(f,x)},u=function(f,p){n&&p.name==="__proto__"?n(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},c=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(r)return r(f,p).value}else return;return f[p]};return lm=function d(){var f,p,m,x,y,w,C=arguments[0],v=1,S=arguments.length,b=!1;for(typeof C=="boolean"&&(b=C,C=arguments[1]||{},v=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});v<S;++v)if(f=arguments[v],f!=null)for(p in f)m=c(C,p),x=c(f,p),C!==x&&(b&&x&&(l(x)||(y=o(x)))?(y?(y=!1,w=m&&o(m)?m:[]):w=m&&l(m)?m:{},u(C,{name:p,newValue:d(b,w,x)})):typeof x<"u"&&u(C,{name:p,newValue:x}));return C},lm}var qR=WR();const cm=Xu(qR);function rp(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 KR(){const e=[],t={run:n,use:r};return t;function n(...o){let l=-1;const u=o.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);c(null,...o);function c(d,...f){const p=e[++l];let m=-1;if(d){u(d);return}for(;++m<o.length;)(f[m]===null||f[m]===void 0)&&(f[m]=o[m]);o=f,p?YR(p,c)(...f):u(null,...f)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function YR(e,t){let n;return r;function r(...u){const c=e.length>u.length;let d;c&&u.push(o);try{d=e.apply(this,u)}catch(f){const p=f;if(c&&n)throw p;return o(p)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,o):d instanceof Error?o(d):l(d))}function o(u,...c){n||(n=!0,t(u,...c))}function l(u){o(null,u)}}const Ur={basename:XR,dirname:QR,extname:JR,join:ZR,sep:"/"};function XR(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ml(e);let n=0,r=-1,o=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(l){n=o+1;break}}else r<0&&(l=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let u=-1,c=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(l){n=o+1;break}}else u<0&&(l=!0,u=o+1),c>-1&&(e.codePointAt(o)===t.codePointAt(c--)?c<0&&(r=o):(c=-1,r=u));return n===r?r=u:r<0&&(r=e.length),e.slice(n,r)}function QR(e){if(Ml(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 JR(e){Ml(e);let t=e.length,n=-1,r=0,o=-1,l=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){r=t+1;break}continue}n<0&&(u=!0,n=t+1),c===46?o<0?o=t:l!==1&&(l=1):o>-1&&(l=-1)}return o<0||n<0||l===0||l===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function ZR(...e){let t=-1,n;for(;++t<e.length;)Ml(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":e3(n)}function e3(e){Ml(e);const t=e.codePointAt(0)===47;let n=t3(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function t3(e,t){let n="",r=0,o=-1,l=0,u=-1,c,d;for(;++u<=e.length;){if(u<e.length)c=e.codePointAt(u);else{if(c===47)break;c=47}if(c===47){if(!(o===u-1||l===1))if(o!==u-1&&l===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),o=u,l=0;continue}}else if(n.length>0){n="",r=0,o=u,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,u):n=e.slice(o+1,u),r=u-o-1;o=u,l=0}else c===46&&l>-1?l++:l=-1}return n}function Ml(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const n3={cwd:r3};function r3(){return"/"}function sp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function s3(e){if(typeof e=="string")e=new URL(e);else if(!sp(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 i3(e)}function i3(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 o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}const um=["history","path","basename","stem","extname","dirname"];class Z1{constructor(t){let n;t?sp(t)?n={path:t}:typeof t=="string"||a3(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":n3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<um.length;){const l=um[r];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let o;for(o in n)um.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Ur.basename(this.path):void 0}set basename(t){hm(t,"basename"),dm(t,"basename"),this.path=Ur.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ur.dirname(this.path):void 0}set dirname(t){Xv(this.basename,"dirname"),this.path=Ur.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ur.extname(this.path):void 0}set extname(t){if(dm(t,"extname"),Xv(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=Ur.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){sp(t)&&(t=s3(t)),hm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ur.basename(this.path,this.extname):void 0}set stem(t){hm(t,"stem"),dm(t,"stem"),this.path=Ur.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){const o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){const o=new Ln(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function dm(e,t){if(e&&e.includes(Ur.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ur.sep+"`")}function hm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Xv(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function a3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const o3=(function(e){const r=this.constructor.prototype,o=r[e],l=function(){return o.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),l3={}.hasOwnProperty;class Zp extends o3{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=KR()}copy(){const t=new Zp;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(cm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(pm("data",this.frozen),this.namespace[t]=n,this):l3.call(this.namespace,t)&&this.namespace[t]||void 0:t?(pm("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 o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ou(t),r=this.parser||this.Parser;return fm("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),fm("process",this.parser||this.Parser),mm("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(l,u){const c=ou(t),d=r.parse(c);r.run(d,c,function(p,m,x){if(p||!m||!x)return f(p);const y=m,w=r.stringify(y,x);d3(w)?x.value=w:x.result=w,f(p,x)});function f(p,m){p||!m?u(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,r;return this.freeze(),fm("processSync",this.parser||this.Parser),mm("processSync",this.compiler||this.Compiler),this.process(t,o),Jv("processSync","process",n),r;function o(l,u){n=!0,Kv(l),r=u}}run(t,n,r){Qv(t),this.freeze();const o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?l(void 0,r):new Promise(l);function l(u,c){const d=ou(n);o.run(t,d,f);function f(p,m,x){const y=m||t;p?c(p):u?u(y):r(void 0,y,x)}}}runSync(t,n){let r=!1,o;return this.run(t,n,l),Jv("runSync","run",r),o;function l(u,c){Kv(u),o=c,r=!0}}stringify(t,n){this.freeze();const r=ou(n),o=this.compiler||this.Compiler;return mm("stringify",o),Qv(t),o(t,r)}use(t,...n){const r=this.attachers,o=this.namespace;if(pm("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(f){if(typeof f=="function")d(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[p,...m]=f;d(p,m)}else u(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function u(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(f.plugins),f.settings&&(o.settings=cm(!0,o.settings,f.settings))}function c(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const m=f[p];l(m)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function d(f,p){let m=-1,x=-1;for(;++m<r.length;)if(r[m][0]===f){x=m;break}if(x===-1)r.push([f,...p]);else if(p.length>0){let[y,...w]=p;const C=r[x][1];rp(C)&&rp(y)&&(y=cm(!0,C,y)),r[x]=[f,y,...w]}}}}const c3=new Zp().freeze();function fm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function mm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function pm(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 Qv(e){if(!rp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Jv(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ou(e){return u3(e)?e:new Z1(e)}function u3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function d3(e){return typeof e=="string"||h3(e)}function h3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const f3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Zv=[],e0={allowDangerousHtml:!0},m3=/^(https?|ircs?|mailto|xmpp)$/i,p3=[{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 g3(e){const t=x3(e),n=y3(e);return _3(t.runSync(t.parse(n),n),e)}function x3(e){const t=e.rehypePlugins||Zv,n=e.remarkPlugins||Zv,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...e0}:e0;return c3().use(QD).use(n).use(GR,r).use(t)}function y3(e){const t=e.children||"",n=new Z1;return typeof t=="string"&&(n.value=t),n}function _3(e,t){const n=t.allowedElements,r=t.allowElement,o=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||b3;for(const p of p3)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+f3+p.id,void 0);return Jp(e,f),OA(e,{Fragment:a.Fragment,components:o,ignoreInvalidStyle:!0,jsx:a.jsx,jsxs:a.jsxs,passKeys:!0,passNode:!0});function f(p,m,x){if(p.type==="raw"&&x&&typeof m=="number")return u?x.children.splice(m,1):x.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let y;for(y in im)if(Object.hasOwn(im,y)&&Object.hasOwn(p.properties,y)){const w=p.properties[y],C=im[y];(C===null||C.includes(p.tagName))&&(p.properties[y]=d(String(w||""),y,p))}}if(p.type==="element"){let y=n?!n.includes(p.tagName):l?l.includes(p.tagName):!1;if(!y&&r&&typeof m=="number"&&(y=!r(p,m,x)),y&&x&&typeof m=="number")return c&&p.children?x.children.splice(m,1,...p.children):x.children.splice(m,1),m}}}function b3(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||m3.test(e.slice(0,t))?e:""}function t0(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;o!==-1;)r++,o=n.indexOf(t,o+t.length);return r}function v3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function S3(e,t,n){const o=dd((n||{}).ignore||[]),l=w3(t);let u=-1;for(;++u<l.length;)J1(e,"text",c);function c(f,p){let m=-1,x;for(;++m<p.length;){const y=p[m],w=x?x.children:void 0;if(o(y,w?w.indexOf(y):void 0,x))return;x=y}if(x)return d(f,p)}function d(f,p){const m=p[p.length-1],x=l[u][0],y=l[u][1];let w=0;const v=m.children.indexOf(f);let S=!1,b=[];x.lastIndex=0;let _=x.exec(f.value);for(;_;){const j=_.index,E={index:_.index,input:_.input,stack:[...p,f]};let T=y(..._,E);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=j+1:(w!==j&&b.push({type:"text",value:f.value.slice(w,j)}),Array.isArray(T)?b.push(...T):T&&b.push(T),w=j+_[0].length,S=!0),!x.global)break;_=x.exec(f.value)}return S?(w<f.value.length&&b.push({type:"text",value:f.value.slice(w)}),m.children.splice(v,1,...b)):b=[f],v+b.length}}function w3(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 o=n[r];t.push([C3(o[0]),k3(o[1])])}return t}function C3(e){return typeof e=="string"?new RegExp(v3(e),"g"):e}function k3(e){return typeof e=="function"?e:function(){return e}}const gm="phrasing",xm=["autolink","link","image","label"];function E3(){return{transforms:[R3],enter:{literalAutolink:N3,literalAutolinkEmail:ym,literalAutolinkHttp:ym,literalAutolinkWww:ym},exit:{literalAutolink:D3,literalAutolinkEmail:L3,literalAutolinkHttp:T3,literalAutolinkWww:A3}}}function j3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:gm,notInConstruct:xm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:gm,notInConstruct:xm},{character:":",before:"[ps]",after:"\\/",inConstruct:gm,notInConstruct:xm}]}}function N3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ym(e){this.config.enter.autolinkProtocol.call(this,e)}function T3(e){this.config.exit.autolinkProtocol.call(this,e)}function A3(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 L3(e){this.config.exit.autolinkEmail.call(this,e)}function D3(e){this.exit(e)}function R3(e){S3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,O3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),M3]],{ignore:["link","linkReference"]})}function O3(e,t,n,r,o){let l="";if(!ew(o)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!I3(n)))return!1;const u=P3(n+r);if(!u[0])return!1;const c={type:"link",title:null,url:l+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[c,{type:"text",value:u[1]}]:c}function M3(e,t,n,r){return!ew(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function I3(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 P3(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 o=t0(e,"(");let l=t0(e,")");for(;r!==-1&&o>l;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),l++;return[e,n]}function ew(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Bi(n)||ld(n))&&(!t||n!==47)}tw.peek=W3;function B3(){this.buffer()}function $3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function z3(){this.buffer()}function H3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function U3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Rr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function F3(e){this.exit(e)}function V3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Rr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function G3(e){this.exit(e)}function W3(){return"["}function tw(e,t,n,r){const o=n.createTracker(r);let l=o.move("[^");const u=n.enter("footnoteReference"),c=n.enter("reference");return l+=o.move(n.safe(n.associationId(e),{after:"]",before:l})),c(),u(),l+=o.move("]"),l}function q3(){return{enter:{gfmFootnoteCallString:B3,gfmFootnoteCall:$3,gfmFootnoteDefinitionLabelString:z3,gfmFootnoteDefinition:H3},exit:{gfmFootnoteCallString:U3,gfmFootnoteCall:F3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:G3}}}function K3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:tw},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,o,l,u){const c=l.createTracker(u);let d=c.move("[^");const f=l.enter("footnoteDefinition"),p=l.enter("label");return d+=c.move(l.safe(l.associationId(r),{before:d,after:"]"})),p(),d+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),d+=c.move((t?`
|
|
110
|
+
`:" ")+l.indentLines(l.containerFlow(r,c.current()),t?nw:Y3))),f(),d}}function Y3(e,t,n){return t===0?e:nw(e,t,n)}function nw(e,t,n){return(n?"":" ")+e}const X3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];rw.peek=t5;function Q3(){return{canContainEols:["delete"],enter:{strikethrough:Z3},exit:{strikethrough:e5}}}function J3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:X3}],handlers:{delete:rw}}}function Z3(e){this.enter({type:"delete",children:[]},e)}function e5(e){this.exit(e)}function rw(e,t,n,r){const o=n.createTracker(r),l=n.enter("strikethrough");let u=o.move("~~");return u+=n.containerPhrasing(e,{...o.current(),before:u,after:"~"}),u+=o.move("~~"),l(),u}function t5(){return"~"}function n5(e){return e.length}function r5(e,t){const n=t||{},r=(n.align||[]).concat(),o=n.stringLength||n5,l=[],u=[],c=[],d=[];let f=0,p=-1;for(;++p<e.length;){const C=[],v=[];let S=-1;for(e[p].length>f&&(f=e[p].length);++S<e[p].length;){const b=s5(e[p][S]);if(n.alignDelimiters!==!1){const _=o(b);v[S]=_,(d[S]===void 0||_>d[S])&&(d[S]=_)}C.push(b)}u[p]=C,c[p]=v}let m=-1;if(typeof r=="object"&&"length"in r)for(;++m<f;)l[m]=n0(r[m]);else{const C=n0(r);for(;++m<f;)l[m]=C}m=-1;const x=[],y=[];for(;++m<f;){const C=l[m];let v="",S="";C===99?(v=":",S=":"):C===108?v=":":C===114&&(S=":");let b=n.alignDelimiters===!1?1:Math.max(1,d[m]-v.length-S.length);const _=v+"-".repeat(b)+S;n.alignDelimiters!==!1&&(b=v.length+b+S.length,b>d[m]&&(d[m]=b),y[m]=b),x[m]=_}u.splice(1,0,x),c.splice(1,0,y),p=-1;const w=[];for(;++p<u.length;){const C=u[p],v=c[p];m=-1;const S=[];for(;++m<f;){const b=C[m]||"";let _="",j="";if(n.alignDelimiters!==!1){const E=d[m]-(v[m]||0),T=l[m];T===114?_=" ".repeat(E):T===99?E%2?(_=" ".repeat(E/2+.5),j=" ".repeat(E/2-.5)):(_=" ".repeat(E/2),j=_):j=" ".repeat(E)}n.delimiterStart!==!1&&!m&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&b==="")&&(n.delimiterStart!==!1||m)&&S.push(" "),n.alignDelimiters!==!1&&S.push(_),S.push(b),n.alignDelimiters!==!1&&S.push(j),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||m!==f-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
|
|
111
|
+
`)}function s5(e){return e==null?"":String(e)}function n0(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 i5(e,t,n,r){const o=n.enter("blockquote"),l=n.createTracker(r);l.move("> "),l.shift(2);const u=n.indentLines(n.containerFlow(e,l.current()),a5);return o(),u}function a5(e,t,n){return">"+(n?"":" ")+e}function o5(e,t){return r0(e,t.inConstruct,!0)&&!r0(e,t.notInConstruct,!1)}function r0(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 s0(e,t,n,r){let o=-1;for(;++o<n.unsafe.length;)if(n.unsafe[o].character===`
|
|
112
|
+
`&&o5(n.stack,n.unsafe[o]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
113
|
+
`}function l5(e,t){const n=String(e);let r=n.indexOf(t),o=r,l=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===o?++l>u&&(u=l):l=1,o=r+t.length,r=n.indexOf(t,o);return u}function c5(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function u5(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 d5(e,t,n,r){const o=u5(n),l=e.value||"",u=o==="`"?"GraveAccent":"Tilde";if(c5(e,n)){const m=n.enter("codeIndented"),x=n.indentLines(l,h5);return m(),x}const c=n.createTracker(r),d=o.repeat(Math.max(l5(l,o)+1,3)),f=n.enter("codeFenced");let p=c.move(d);if(e.lang){const m=n.enter(`codeFencedLang${u}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),m()}if(e.lang&&e.meta){const m=n.enter(`codeFencedMeta${u}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
114
|
+
`,encode:["`"],...c.current()})),m()}return p+=c.move(`
|
|
115
|
+
`),l&&(p+=c.move(l+`
|
|
116
|
+
`)),p+=c.move(d),f(),p}function h5(e,t,n){return(n?"":" ")+e}function eg(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 f5(e,t,n,r){const o=eg(n),l=o==='"'?"Quote":"Apostrophe",u=n.enter("definition");let c=n.enter("label");const d=n.createTracker(r);let f=d.move("[");return f+=d.move(n.safe(n.associationId(e),{before:f,after:"]",...d.current()})),f+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(e.url,{before:f,after:e.title?" ":`
|
|
117
|
+
`,...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=d.move(" "+o),f+=d.move(n.safe(e.title,{before:f,after:o,...d.current()})),f+=d.move(o),c()),u(),f}function m5(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 vl(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Mu(e,t,n){const r=Va(e),o=Va(t);return r===void 0?o===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}sw.peek=p5;function sw(e,t,n,r){const o=m5(n),l=n.enter("emphasis"),u=n.createTracker(r),c=u.move(o);let d=u.move(n.containerPhrasing(e,{after:o,before:c,...u.current()}));const f=d.charCodeAt(0),p=Mu(r.before.charCodeAt(r.before.length-1),f,o);p.inside&&(d=vl(f)+d.slice(1));const m=d.charCodeAt(d.length-1),x=Mu(r.after.charCodeAt(0),m,o);x.inside&&(d=d.slice(0,-1)+vl(m));const y=u.move(o);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function p5(e,t,n){return n.options.emphasis||"*"}function g5(e,t){let n=!1;return Jp(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,tp}),!!((!e.depth||e.depth<3)&&Gp(e)&&(t.options.setext||n))}function x5(e,t,n,r){const o=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(r);if(g5(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),x=n.containerPhrasing(e,{...l.current(),before:`
|
|
118
|
+
`,after:`
|
|
119
|
+
`});return m(),p(),x+`
|
|
120
|
+
`+(o===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
|
|
121
|
+
`))+1))}const u="#".repeat(o),c=n.enter("headingAtx"),d=n.enter("phrasing");l.move(u+" ");let f=n.containerPhrasing(e,{before:"# ",after:`
|
|
122
|
+
`,...l.current()});return/^[\t ]/.test(f)&&(f=vl(f.charCodeAt(0))+f.slice(1)),f=f?u+" "+f:u,n.options.closeAtx&&(f+=" "+u),d(),c(),f}iw.peek=y5;function iw(e){return e.value||""}function y5(){return"<"}aw.peek=_5;function aw(e,t,n,r){const o=eg(n),l=o==='"'?"Quote":"Apostrophe",u=n.enter("image");let c=n.enter("label");const d=n.createTracker(r);let f=d.move("![");return f+=d.move(n.safe(e.alt,{before:f,after:"]",...d.current()})),f+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(e.url,{before:f,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=d.move(" "+o),f+=d.move(n.safe(e.title,{before:f,after:o,...d.current()})),f+=d.move(o),c()),f+=d.move(")"),u(),f}function _5(){return"!"}ow.peek=b5;function ow(e,t,n,r){const o=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("![");const f=n.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),o==="full"||!f||f!==m?d+=c.move(m+"]"):o==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function b5(){return"!"}lw.peek=v5;function lw(e,t,n){let r=e.value||"",o="`",l=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++l<n.unsafe.length;){const u=n.unsafe[l],c=n.compilePattern(u);let d;if(u.atBreak)for(;d=c.exec(r);){let f=d.index;r.charCodeAt(f)===10&&r.charCodeAt(f-1)===13&&f--,r=r.slice(0,f)+" "+r.slice(d.index+1)}}return o+r+o}function v5(){return"`"}function cw(e,t){const n=Gp(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))}uw.peek=S5;function uw(e,t,n,r){const o=eg(n),l=o==='"'?"Quote":"Apostrophe",u=n.createTracker(r);let c,d;if(cw(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let m=u.move("<");return m+=u.move(n.containerPhrasing(e,{before:m,after:">",...u.current()})),m+=u.move(">"),c(),n.stack=p,m}c=n.enter("link"),d=n.enter("label");let f=u.move("[");return f+=u.move(n.containerPhrasing(e,{before:f,after:"](",...u.current()})),f+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),f+=u.move("<"),f+=u.move(n.safe(e.url,{before:f,after:">",...u.current()})),f+=u.move(">")):(d=n.enter("destinationRaw"),f+=u.move(n.safe(e.url,{before:f,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=n.enter(`title${l}`),f+=u.move(" "+o),f+=u.move(n.safe(e.title,{before:f,after:o,...u.current()})),f+=u.move(o),d()),f+=u.move(")"),c(),f}function S5(e,t,n){return cw(e,n)?"<":"["}dw.peek=w5;function dw(e,t,n,r){const o=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("[");const f=n.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),o==="full"||!f||f!==m?d+=c.move(m+"]"):o==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function w5(){return"["}function tg(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 C5(e){const t=tg(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 k5(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 hw(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 E5(e,t,n,r){const o=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?k5(n):tg(n);const c=e.ordered?u==="."?")":".":C5(n);let d=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),hw(n)===u&&p){let m=-1;for(;++m<e.children.length;){const x=e.children[m];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(u=c),n.bulletCurrent=u;const f=n.containerFlow(e,r);return n.bulletLastUsed=u,n.bulletCurrent=l,o(),f}function j5(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 N5(e,t,n,r){const o=j5(n);let l=n.bulletCurrent||tg(n);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let u=l.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=n.createTracker(r);c.move(l+" ".repeat(u-l.length)),c.shift(u);const d=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,c.current()),p);return d(),f;function p(m,x,y){return x?(y?"":" ".repeat(u))+m:(y?l:l+" ".repeat(u-l.length))+m}}function T5(e,t,n,r){const o=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,r);return l(),o(),u}const A5=dd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function L5(e,t,n,r){return(e.children.some(function(u){return A5(u)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function D5(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}fw.peek=R5;function fw(e,t,n,r){const o=D5(n),l=n.enter("strong"),u=n.createTracker(r),c=u.move(o+o);let d=u.move(n.containerPhrasing(e,{after:o,before:c,...u.current()}));const f=d.charCodeAt(0),p=Mu(r.before.charCodeAt(r.before.length-1),f,o);p.inside&&(d=vl(f)+d.slice(1));const m=d.charCodeAt(d.length-1),x=Mu(r.after.charCodeAt(0),m,o);x.inside&&(d=d.slice(0,-1)+vl(m));const y=u.move(o+o);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function R5(e,t,n){return n.options.strong||"*"}function O5(e,t,n,r){return n.safe(e.value,r)}function M5(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 I5(e,t,n){const r=(hw(n)+(n.options.ruleSpaces?" ":"")).repeat(M5(n));return n.options.ruleSpaces?r.slice(0,-1):r}const mw={blockquote:i5,break:s0,code:d5,definition:f5,emphasis:sw,hardBreak:s0,heading:x5,html:iw,image:aw,imageReference:ow,inlineCode:lw,link:uw,linkReference:dw,list:E5,listItem:N5,paragraph:T5,root:L5,strong:fw,text:O5,thematicBreak:I5};function P5(){return{enter:{table:B5,tableData:i0,tableHeader:i0,tableRow:z5},exit:{codeText:H5,table:$5,tableData:_m,tableHeader:_m,tableRow:_m}}}function B5(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 $5(e){this.exit(e),this.data.inTable=void 0}function z5(e){this.enter({type:"tableRow",children:[]},e)}function _m(e){this.exit(e)}function i0(e){this.enter({type:"tableCell",children:[]},e)}function H5(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,U5));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function U5(e,t){return t==="|"?t:e}function F5(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
123
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:c}};function u(y,w,C,v){return f(p(y,C,v),y.align)}function c(y,w,C,v){const S=m(y,C,v),b=f([S]);return b.slice(0,b.indexOf(`
|
|
124
|
+
`))}function d(y,w,C,v){const S=C.enter("tableCell"),b=C.enter("phrasing"),_=C.containerPhrasing(y,{...v,before:l,after:l});return b(),S(),_}function f(y,w){return r5(y,{align:w,alignDelimiters:r,padding:n,stringLength:o})}function p(y,w,C){const v=y.children;let S=-1;const b=[],_=w.enter("table");for(;++S<v.length;)b[S]=m(v[S],w,C);return _(),b}function m(y,w,C){const v=y.children;let S=-1;const b=[],_=w.enter("tableRow");for(;++S<v.length;)b[S]=d(v[S],y,w,C);return _(),b}function x(y,w,C){let v=mw.inlineCode(y,w,C);return C.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function V5(){return{exit:{taskListCheckValueChecked:a0,taskListCheckValueUnchecked:a0,paragraph:W5}}}function G5(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:q5}}}function a0(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function W5(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 o=t.children;let l=-1,u;for(;++l<o.length;){const c=o[l];if(c.type==="paragraph"){u=c;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function q5(e,t,n,r){const o=e.children[0],l=typeof e.checked=="boolean"&&o&&o.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);l&&c.move(u);let d=mw.listItem(e,t,n,{...r,...c.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(p){return p+u}}function K5(){return[E3(),q3(),Q3(),P5(),V5()]}function Y5(e){return{extensions:[j3(),K3(e),J3(),F5(e),G5()]}}const X5={tokenize:nO,partial:!0},pw={tokenize:rO,partial:!0},gw={tokenize:sO,partial:!0},xw={tokenize:iO,partial:!0},Q5={tokenize:aO,partial:!0},yw={name:"wwwAutolink",tokenize:eO,previous:bw},_w={name:"protocolAutolink",tokenize:tO,previous:vw},bs={name:"emailAutolink",tokenize:Z5,previous:Sw},qr={};function J5(){return{text:qr}}let wi=48;for(;wi<123;)qr[wi]=bs,wi++,wi===58?wi=65:wi===91&&(wi=97);qr[43]=bs;qr[45]=bs;qr[46]=bs;qr[95]=bs;qr[72]=[bs,_w];qr[104]=[bs,_w];qr[87]=[bs,yw];qr[119]=[bs,yw];function Z5(e,t,n){const r=this;let o,l;return u;function u(m){return!ip(m)||!Sw.call(r,r.previous)||ng(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(m))}function c(m){return ip(m)?(e.consume(m),c):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(Q5,p,f)(m):m===45||m===95||An(m)?(l=!0,e.consume(m),d):p(m)}function f(m){return e.consume(m),o=!0,d}function p(m){return l&&o&&On(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function eO(e,t,n){const r=this;return o;function o(u){return u!==87&&u!==119||!bw.call(r,r.previous)||ng(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(X5,e.attempt(pw,e.attempt(gw,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function tO(e,t,n){const r=this;let o="",l=!1;return u;function u(m){return(m===72||m===104)&&vw.call(r,r.previous)&&!ng(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(m),e.consume(m),c):n(m)}function c(m){if(On(m)&&o.length<5)return o+=String.fromCodePoint(m),e.consume(m),c;if(m===58){const x=o.toLowerCase();if(x==="http"||x==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?f:(l=!0,d)):n(m)}function f(m){return m===null||Du(m)||Pt(m)||Bi(m)||ld(m)?n(m):e.attempt(pw,e.attempt(gw,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function nO(e,t,n){let r=0;return o;function o(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),o):u===46&&r===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function rO(e,t,n){let r,o,l;return u;function u(f){return f===46||f===95?e.check(xw,d,c)(f):f===null||Pt(f)||Bi(f)||f!==45&&ld(f)?d(f):(l=!0,e.consume(f),u)}function c(f){return f===95?r=!0:(o=r,r=void 0),e.consume(f),u}function d(f){return o||r||!l?n(f):t(f)}}function sO(e,t){let n=0,r=0;return o;function o(u){return u===40?(n++,e.consume(u),o):u===41&&r<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(xw,t,l)(u):u===null||Pt(u)||Bi(u)?t(u):(e.consume(u),o)}function l(u){return u===41&&r++,e.consume(u),o}}function iO(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),l):c===93?(e.consume(c),o):c===60||c===null||Pt(c)||Bi(c)?t(c):n(c)}function o(c){return c===null||c===40||c===91||Pt(c)||Bi(c)?t(c):r(c)}function l(c){return On(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),r):On(c)?(e.consume(c),u):n(c)}}function aO(e,t,n){return r;function r(l){return e.consume(l),o}function o(l){return An(l)?n(l):t(l)}}function bw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Pt(e)}function vw(e){return!On(e)}function Sw(e){return!(e===47||ip(e))}function ip(e){return e===43||e===45||e===46||e===95||An(e)}function ng(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 oO={tokenize:pO,partial:!0};function lO(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:hO,continuation:{tokenize:fO},exit:mO}},text:{91:{name:"gfmFootnoteCall",tokenize:dO},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:cO,resolveTo:uO}}}}function cO(e,t,n){const r=this;let o=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;o--;){const d=r.events[o][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return n(d);const f=Rr(r.sliceSerialize({start:u.end,end:r.now()}));return f.codePointAt(0)!==94||!l.includes(f.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function uO(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)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function dO(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l=0,u;return c;function c(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(m){if(l>999||m===93&&!u||m===null||m===91||Pt(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return o.includes(Rr(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return Pt(m)||(u=!0),l++,e.consume(m),m===92?p:f}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,f):f(m)}}function hO(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l,u=0,c;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(w)}function p(w){if(u>999||w===93&&!c||w===null||w===91||Pt(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=Rr(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return Pt(w)||(c=!0),u++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,p):p(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),o.includes(l)||o.push(l),bt(e,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return t(w)}}function fO(e,t,n){return e.check(Ol,t,e.attempt(oO,t,n))}function mO(e){e.exit("gfmFootnoteDefinition")}function pO(e,t,n){const r=this;return bt(e,o,"gfmFootnoteDefinitionIndent",5);function o(l){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function gO(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:l,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(u,c){let d=-1;for(;++d<u.length;)if(u[d][0]==="enter"&&u[d][1].type==="strikethroughSequenceTemporary"&&u[d][1]._close){let f=d;for(;f--;)if(u[f][0]==="exit"&&u[f][1].type==="strikethroughSequenceTemporary"&&u[f][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[f][1].end.offset-u[f][1].start.offset){u[d][1].type="strikethroughSequence",u[f][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},u[f][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[f][1].end),end:Object.assign({},u[d][1].start)},x=[["enter",p,c],["enter",u[f][1],c],["exit",u[f][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&lr(x,x.length,0,cd(y,u.slice(f+1,d),c)),lr(x,x.length,0,[["exit",m,c],["enter",u[d][1],c],["exit",u[d][1],c],["exit",p,c]]),lr(u,f-1,d-f+3,x),d=f+x.length-2;break}}for(d=-1;++d<u.length;)u[d][1].type==="strikethroughSequenceTemporary"&&(u[d][1].type="data");return u}function l(u,c,d){const f=this.previous,p=this.events;let m=0;return x;function x(w){return f===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const C=Va(f);if(w===126)return m>1?d(w):(u.consume(w),m++,y);if(m<2&&!n)return d(w);const v=u.exit("strikethroughSequenceTemporary"),S=Va(w);return v._open=!S||S===2&&!!C,v._close=!C||C===2&&!!S,c(w)}}}class xO{constructor(){this.map=[]}add(t,n,r){yO(this,t,n,r)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const l of o)t.push(l);o=r.pop()}this.map.length=0}}function yO(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function _O(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function bO(){return{flow:{null:{name:"table",tokenize:vO,resolveAll:SO}}}}function vO(e,t,n){const r=this;let o=0,l=0,u;return c;function c(P){let q=r.events.length-1;for(;q>-1;){const H=r.events[q][1].type;if(H==="lineEnding"||H==="linePrefix")q--;else break}const W=q>-1?r.events[q][1].type:null,M=W==="tableHead"||W==="tableRow"?T:d;return M===T&&r.parser.lazy[r.now().line]?n(P):M(P)}function d(P){return e.enter("tableHead"),e.enter("tableRow"),f(P)}function f(P){return P===124||(u=!0,l+=1),p(P)}function p(P){return P===null?n(P):Xe(P)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),y):n(P):pt(P)?bt(e,p,"whitespace")(P):(l+=1,u&&(u=!1,o+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),u=!0,p):(e.enter("data"),m(P)))}function m(P){return P===null||P===124||Pt(P)?(e.exit("data"),p(P)):(e.consume(P),P===92?x:m)}function x(P){return P===92||P===124?(e.consume(P),m):m(P)}function y(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),u=!1,pt(P)?bt(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):w(P))}function w(P){return P===45||P===58?v(P):P===124?(u=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),C):E(P)}function C(P){return pt(P)?bt(e,v,"whitespace")(P):v(P)}function v(P){return P===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),S):P===45?(l+=1,S(P)):P===null||Xe(P)?j(P):E(P)}function S(P){return P===45?(e.enter("tableDelimiterFiller"),b(P)):E(P)}function b(P){return P===45?(e.consume(P),b):P===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_(P))}function _(P){return pt(P)?bt(e,j,"whitespace")(P):j(P)}function j(P){return P===124?w(P):P===null||Xe(P)?!u||o!==l?E(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):E(P)}function E(P){return n(P)}function T(P){return e.enter("tableRow"),D(P)}function D(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),D):P===null||Xe(P)?(e.exit("tableRow"),t(P)):pt(P)?bt(e,D,"whitespace")(P):(e.enter("data"),L(P))}function L(P){return P===null||P===124||Pt(P)?(e.exit("data"),D(P)):(e.consume(P),P===92?O:L)}function O(P){return P===92||P===124?(e.consume(P),L):L(P)}}function SO(e,t){let n=-1,r=!0,o=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,f,p,m;const x=new xO;for(;++n<e.length;){const y=e[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(o0(x,t,d,f,p),p=void 0,d=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",f,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",p,t]])),o=w.type==="tableDelimiterRow"?2:p?3:1):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=lu(x,t,l,o,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(u[0]=u[1],m=lu(x,t,l,o,void 0,m)),l=u,u=[l[1],n,0,0])):w.type==="tableHead"?(c=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,l[1]!==0?(u[0]=u[1],m=lu(x,t,l,o,n,m)):u[1]!==0&&(m=lu(x,t,u,o,n,m)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&o0(x,t,d,f,p),x.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=_O(t.events,n))}return e}function lu(e,t,n,r,o,l){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(l.end=Object.assign({},Pa(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=Pa(t.events,n[1]);if(l={type:u,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const f=Pa(t.events,n[2]),p=Pa(t.events,n[3]),m={type:c,start:Object.assign({},f),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const x=t.events[n[2]],y=t.events[n[3]];if(x[1].end=Object.assign({},y[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return o!==void 0&&(l.end=Object.assign({},Pa(t.events,o)),e.add(o,0,[["exit",l,t]]),l=void 0),l}function o0(e,t,n,r,o){const l=[],u=Pa(t.events,n);o&&(o.end=Object.assign({},u),l.push(["exit",o,t])),r.end=Object.assign({},u),l.push(["exit",r,t]),e.add(n+1,0,l)}function Pa(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const wO={name:"tasklistCheck",tokenize:kO};function CO(){return{text:{91:wO}}}function kO(e,t,n){const r=this;return o;function o(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return Pt(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):n(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(d)}function c(d){return Xe(d)?t(d):pt(d)?e.check({tokenize:EO},t,n)(d):n(d)}}function EO(e,t,n){return bt(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function jO(e){return R1([J5(),lO(),gO(e),bO(),CO()])}const NO={};function TO(e){const t=this,n=e||NO,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(jO(n)),l.push(K5()),u.push(Y5(n))}var ap=Object.defineProperty,AO=Object.getOwnPropertyDescriptor,LO=Object.getOwnPropertyNames,DO=Object.prototype.hasOwnProperty,rg=(e,t)=>{let n={};for(var r in e)ap(n,r,{get:e[r],enumerable:!0});return ap(n,Symbol.toStringTag,{value:"Module"}),n},RO=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=LO(t),l=0,u=o.length,c;l<u;l++)c=o[l],!DO.call(e,c)&&c!==n&&ap(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(r=AO(t,c))||r.enumerable});return e},ww=(e,t,n)=>(RO(e,t,"default"),n);const fd=[{id:"abap",name:"ABAP",import:(()=>Z(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>Z(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>Z(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>Z(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>Z(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>Z(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>Z(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>Z(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>Z(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>Z(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>Z(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>Z(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>Z(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>Z(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>Z(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>Z(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>Z(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>Z(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>Z(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>Z(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>Z(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>Z(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>Z(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>Z(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>Z(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>Z(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>Z(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>Z(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>Z(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>Z(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>Z(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>Z(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>Z(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>Z(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>Z(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>Z(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>Z(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>Z(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>Z(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>Z(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>Z(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>Z(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>Z(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>Z(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>Z(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>Z(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>Z(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>Z(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>Z(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>Z(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>Z(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>Z(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>Z(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>Z(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>Z(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>Z(()=>import("./erb-Dm6A9KJ5.js"),__vite__mapDeps([32,1,2,3,33,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>Z(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>Z(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>Z(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>Z(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>Z(()=>import("./fortran-fixed-form-CkoXwp7k.js"),__vite__mapDeps([41,42])))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>Z(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>Z(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>Z(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>Z(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>Z(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>Z(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>Z(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>Z(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>Z(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>Z(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>Z(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>Z(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>Z(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>Z(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>Z(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>Z(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>Z(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>Z(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>Z(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>Z(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>Z(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>Z(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>Z(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>Z(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>Z(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>Z(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>Z(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>Z(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>Z(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>Z(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>Z(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>Z(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>Z(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>Z(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>Z(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>Z(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>Z(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>Z(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>Z(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>Z(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>Z(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>Z(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>Z(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>Z(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>Z(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>Z(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>Z(()=>import("./just-CUsbIsdP.js"),__vite__mapDeps([63,28,2,11,64,1,3,7,8,16,20,33,34,35,36,13,23,24,25,26,37,38])))},{id:"kdl",name:"KDL",import:(()=>Z(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>Z(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>Z(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>Z(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>Z(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>Z(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>Z(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>Z(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>Z(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>Z(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>Z(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>Z(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>Z(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>Z(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>Z(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>Z(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>Z(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>Z(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>Z(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>Z(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>Z(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>Z(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>Z(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>Z(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>Z(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>Z(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>Z(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>Z(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>Z(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>Z(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>Z(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>Z(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>Z(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>Z(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>Z(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>Z(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>Z(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>Z(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>Z(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>Z(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>Z(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>Z(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>Z(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>Z(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>Z(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>Z(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>Z(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>Z(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>Z(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>Z(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>Z(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>Z(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>Z(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>Z(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>Z(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>Z(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>Z(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>Z(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>Z(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>Z(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>Z(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>Z(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>Z(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>Z(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>Z(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>Z(()=>import("./rst-CpCqk9r5.js"),__vite__mapDeps([80,15,1,2,3,23,24,25,26,16,20,28,38,81,33,34,7,8,35,11,36,13,37])))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>Z(()=>import("./ruby-DyJCeAvU.js"),__vite__mapDeps([33,1,2,3,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>Z(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>Z(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>Z(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>Z(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>Z(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>Z(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>Z(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>Z(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>Z(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>Z(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>Z(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>Z(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>Z(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>Z(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>Z(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>Z(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>Z(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>Z(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>Z(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>Z(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>Z(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>Z(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>Z(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>Z(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>Z(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>Z(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>Z(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>Z(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>Z(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>Z(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>Z(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>Z(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>Z(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>Z(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>Z(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>Z(()=>import("./twig-CW1WmMYd.js"),__vite__mapDeps([95,3,2,5,75,1,7,8,16,9,20,33,34,35,11,36,13,23,24,25,26,28,37,38])))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>Z(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>Z(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>Z(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>Z(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>Z(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>Z(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>Z(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>Z(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>Z(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>Z(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>Z(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>Z(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>Z(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>Z(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>Z(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>Z(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>Z(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>Z(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>Z(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>Z(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>Z(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>Z(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>Z(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>Z(()=>import("./zig-VOosw3JB.js"),[]))}],sg=Object.fromEntries(fd.map(e=>[e.id,e.import])),ig=Object.fromEntries(fd.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),md={...sg,...ig},ag=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>Z(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>Z(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>Z(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>Z(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>Z(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>Z(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>Z(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>Z(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>Z(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>Z(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>Z(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>Z(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>Z(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>Z(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>Z(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>Z(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>Z(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>Z(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>Z(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>Z(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>Z(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>Z(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>Z(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>Z(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>Z(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>Z(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>Z(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>Z(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>Z(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>Z(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>Z(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>Z(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>Z(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>Z(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>Z(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>Z(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>Z(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>Z(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>Z(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>Z(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>Z(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>Z(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>Z(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>Z(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>Z(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>Z(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>Z(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>Z(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>Z(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>Z(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>Z(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>Z(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>Z(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>Z(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>Z(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>Z(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>Z(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>Z(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>Z(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>Z(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>Z(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>Z(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>Z(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>Z(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>Z(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],og=Object.fromEntries(ag.map(e=>[e.id,e.import]));var lg=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function OO(){return 2147483648}function MO(){return typeof performance<"u"?performance.now():Date.now()}const IO=(e,t)=>e+(t-e%t)%t;async function PO(e){let t,n;const r={};function o(y){n=y,r.HEAPU8=new Uint8Array(y),r.HEAPU32=new Uint32Array(y)}function l(y,w,C){r.HEAPU8.copyWithin(y,w,w+C)}function u(y){try{return t.grow(y-n.byteLength+65535>>>16),o(t.buffer),1}catch{}}function c(y){const w=r.HEAPU8.length;y=y>>>0;const C=OO();if(y>C)return!1;for(let v=1;v<=4;v*=2){let S=w*(1+.2/v);S=Math.min(S,y+100663296);const b=Math.min(C,IO(Math.max(y,S),65536));if(u(b))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function f(y,w,C=1024){const v=w+C;let S=w;for(;y[S]&&!(S>=v);)++S;if(S-w>16&&y.buffer&&d)return d.decode(y.subarray(w,S));let b="";for(;w<S;){let _=y[w++];if(!(_&128)){b+=String.fromCharCode(_);continue}const j=y[w++]&63;if((_&224)===192){b+=String.fromCharCode((_&31)<<6|j);continue}const E=y[w++]&63;if((_&240)===224?_=(_&15)<<12|j<<6|E:_=(_&7)<<18|j<<12|E<<6|y[w++]&63,_<65536)b+=String.fromCharCode(_);else{const T=_-65536;b+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return b}function p(y,w){return y?f(r.HEAPU8,y,w):""}const m={emscripten_get_now:MO,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function x(){const w=await e({env:m,wasi_snapshot_preview1:m});t=w.memory,o(t.buffer),Object.assign(r,w),r.UTF8ToString=p}return await x(),r}var BO=Object.defineProperty,$O=(e,t,n)=>t in e?BO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fn=(e,t,n)=>$O(e,typeof t!="symbol"?t+"":t,n);let yn=null;function zO(e){throw new lg(e.UTF8ToString(e.getLastOnigError()))}class pd{constructor(t){fn(this,"utf16Length"),fn(this,"utf8Length"),fn(this,"utf16Value"),fn(this,"utf8Value"),fn(this,"utf16OffsetToUtf8"),fn(this,"utf8OffsetToUtf16");const n=t.length,r=pd._utf8ByteLength(t),o=r!==n,l=o?new Uint32Array(n+1):null;o&&(l[n]=r);const u=o?new Uint32Array(r+1):null;o&&(u[r]=n);const c=new Uint8Array(r);let d=0;for(let f=0;f<n;f++){const p=t.charCodeAt(f);let m=p,x=!1;if(p>=55296&&p<=56319&&f+1<n){const y=t.charCodeAt(f+1);y>=56320&&y<=57343&&(m=(p-55296<<10)+65536|y-56320,x=!0)}o&&(l[f]=d,x&&(l[f+1]=d),m<=127?u[d+0]=f:m<=2047?(u[d+0]=f,u[d+1]=f):m<=65535?(u[d+0]=f,u[d+1]=f,u[d+2]=f):(u[d+0]=f,u[d+1]=f,u[d+2]=f,u[d+3]=f)),m<=127?c[d++]=m:m<=2047?(c[d++]=192|(m&1984)>>>6,c[d++]=128|(m&63)>>>0):m<=65535?(c[d++]=224|(m&61440)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0):(c[d++]=240|(m&1835008)>>>18,c[d++]=128|(m&258048)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0),x&&f++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=c,this.utf16OffsetToUtf8=l,this.utf8OffsetToUtf16=u}static _utf8ByteLength(t){let n=0;for(let r=0,o=t.length;r<o;r++){const l=t.charCodeAt(r);let u=l,c=!1;if(l>=55296&&l<=56319&&r+1<o){const d=t.charCodeAt(r+1);d>=56320&&d<=57343&&(u=(l-55296<<10)+65536|d-56320,c=!0)}u<=127?n+=1:u<=2047?n+=2:u<=65535?n+=3:n+=4,c&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const gd=class zr{constructor(t){if(fn(this,"id",++zr.LAST_ID),fn(this,"_onigBinding"),fn(this,"content"),fn(this,"utf16Length"),fn(this,"utf8Length"),fn(this,"utf16OffsetToUtf8"),fn(this,"utf8OffsetToUtf16"),fn(this,"ptr"),!yn)throw new lg("Must invoke loadWasm first.");this._onigBinding=yn,this.content=t;const n=new pd(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!zr._sharedPtrInUse?(zr._sharedPtr||(zr._sharedPtr=yn.omalloc(1e4)),zr._sharedPtrInUse=!0,yn.HEAPU8.set(n.utf8Value,zr._sharedPtr),this.ptr=zr._sharedPtr):this.ptr=n.createString(yn)}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===zr._sharedPtr?zr._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};fn(gd,"LAST_ID",0);fn(gd,"_sharedPtr",0);fn(gd,"_sharedPtrInUse",!1);let Cw=gd;class HO{constructor(t){if(fn(this,"_onigBinding"),fn(this,"_ptr"),!yn)throw new lg("Must invoke loadWasm first.");const n=[],r=[];for(let c=0,d=t.length;c<d;c++){const f=new pd(t[c]);n[c]=f.createString(yn),r[c]=f.utf8Length}const o=yn.omalloc(4*t.length);yn.HEAPU32.set(n,o/4);const l=yn.omalloc(4*t.length);yn.HEAPU32.set(r,l/4);const u=yn.createOnigScanner(o,l,t.length);for(let c=0,d=t.length;c<d;c++)yn.ofree(n[c]);yn.ofree(l),yn.ofree(o),u===0&&zO(yn),this._onigBinding=yn,this._ptr=u}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let o=0;if(typeof r=="number"&&(o=r),typeof t=="string"){t=new Cw(t);const l=this._findNextMatchSync(t,n,!1,o);return t.dispose(),l}return this._findNextMatchSync(t,n,!1,o)}_findNextMatchSync(t,n,r,o){const l=this._onigBinding,u=l.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),o);if(u===0)return null;const c=l.HEAPU32;let d=u/4;const f=c[d++],p=c[d++],m=[];for(let x=0;x<p;x++){const y=t.convertUtf8OffsetToUtf16(c[d++]),w=t.convertUtf8OffsetToUtf16(c[d++]);m[x]={start:y,end:w,length:w-y}}return{index:f,captureIndices:m}}}function UO(e){return typeof e.instantiator=="function"}function FO(e){return typeof e.default=="function"}function VO(e){return typeof e.data<"u"}function GO(e){return typeof Response<"u"&&e instanceof Response}function WO(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 cu;function cg(e){if(cu)return cu;async function t(){yn=await PO(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),UO(r)?r=await r.instantiator(n):FO(r)?r=await r.default(n):(VO(r)&&(r=r.data),GO(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await qO(r)(n):r=await KO(r)(n):WO(r)?r=await bm(r)(n):r instanceof WebAssembly.Module?r=await bm(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await bm(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return cu=t(),cu}function bm(e){return t=>WebAssembly.instantiate(e,t)}function qO(e){return t=>WebAssembly.instantiateStreaming(e,t)}function KO(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let kw;function YO(e){kw=e}function XO(){return kw}async function Ew(e){return e&&await cg(e),{createScanner(t){return new HO(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new Cw(t)}}}const QO=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:Ew,getDefaultWasmLoader:XO,loadWasm:cg,setDefaultWasmLoader:YO},Symbol.toStringTag,{value:"Module"}));var jw=rg({});ww(jw,QO);var Ht=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function JO(e){return ug(e)}function ug(e){return Array.isArray(e)?ZO(e):e instanceof RegExp?e:typeof e=="object"?e4(e):e}function ZO(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=ug(e[n]);return t}function e4(e){let t={};for(let n in e)t[n]=ug(e[n]);return t}function Nw(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function Tw(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Tw(e.substring(0,e.length-1)):e.substr(~t+1)}var vm=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,uu=class{static hasCaptures(e){return e===null?!1:(vm.lastIndex=0,vm.test(e))}static replaceCaptures(e,t,n){return e.replace(vm,(r,o,l,u)=>{let c=n[parseInt(o||l,10)];if(c){let d=t.substring(c.start,c.end);for(;d[0]===".";)d=d.substring(1);switch(u){case"downcase":return d.toLowerCase();case"upcase":return d.toUpperCase();default:return d}}else return r})}};function Aw(e,t){return e<t?-1:e>t?1:0}function Lw(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 o=0;o<n;o++){let l=Aw(e[o],t[o]);if(l!==0)return l}return 0}return n-r}function l0(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 Dw(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Rw=class{constructor(e){_e(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}},Iu=class{constructor(e,t,n){_e(this,"_cachedMatchRoot",new Rw(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(r4(e),t)}static createFromParsedTheme(e,t){return i4(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(o=>t4(e.parent,o.parentScopes));return r?new Ow(r.fontStyle,r.foreground,r.background):null}},Sm=class wu{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new wu(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new wu(n,t[r]);return n}push(t){return new wu(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 t4(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],o=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],o=!0}for(;e&&!n4(e.scopeName,r);){if(o)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function n4(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Ow=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function r4(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let o=0,l=t.length;o<l;o++){let u=t[o];if(!u.settings)continue;let c;if(typeof u.scope=="string"){let m=u.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),c=m.split(",")}else Array.isArray(u.scope)?c=u.scope:c=[""];let d=-1;if(typeof u.settings.fontStyle=="string"){d=0;let m=u.settings.fontStyle.split(" ");for(let x=0,y=m.length;x<y;x++)switch(m[x]){case"italic":d=d|1;break;case"bold":d=d|2;break;case"underline":d=d|4;break;case"strikethrough":d=d|8;break}}let f=null;typeof u.settings.foreground=="string"&&l0(u.settings.foreground)&&(f=u.settings.foreground);let p=null;typeof u.settings.background=="string"&&l0(u.settings.background)&&(p=u.settings.background);for(let m=0,x=c.length;m<x;m++){let w=c[m].trim().split(" "),C=w[w.length-1],v=null;w.length>1&&(v=w.slice(0,w.length-1),v.reverse()),n[r++]=new s4(C,v,o,d,f,p)}}return n}var s4=class{constructor(e,t,n,r,o,l){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=o,this.background=l}},Tn=(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))(Tn||{});function i4(e,t){e.sort((d,f)=>{let p=Aw(d.scope,f.scope);return p!==0||(p=Lw(d.parentScopes,f.parentScopes),p!==0)?p:d.index-f.index});let n=0,r="#000000",o="#ffffff";for(;e.length>=1&&e[0].scope==="";){let d=e.shift();d.fontStyle!==-1&&(n=d.fontStyle),d.foreground!==null&&(r=d.foreground),d.background!==null&&(o=d.background)}let l=new a4(t),u=new Ow(n,l.getId(r),l.getId(o)),c=new l4(new op(0,null,-1,0,0),[]);for(let d=0,f=e.length;d<f;d++){let p=e[d];c.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new Iu(l,u,c)}var a4=class{constructor(e){_e(this,"_isFrozen");_e(this,"_lastColorId");_e(this,"_id2color");_e(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)}},o4=Object.freeze([]),op=class Mw{constructor(t,n,r,o,l){_e(this,"scopeDepth");_e(this,"parentScopes");_e(this,"fontStyle");_e(this,"foreground");_e(this,"background");this.scopeDepth=t,this.parentScopes=n||o4,this.fontStyle=r,this.foreground=o,this.background=l}clone(){return new Mw(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,o=t.length;r<o;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,o){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),o!==0&&(this.background=o)}},l4=class lp{constructor(t,n=[],r={}){_e(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,o=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[o]===">"&&o++,!(r>=t.parentScopes.length||o>=n.parentScopes.length);){const l=n.parentScopes[o].length-t.parentScopes[r].length;if(l!==0)return l;r++,o++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),o,l;if(r===-1?(o=t,l=""):(o=t.substring(0,r),l=t.substring(r+1)),this._children.hasOwnProperty(o))return this._children[o].match(l)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(lp._cmpBySpecificity),n}insert(t,n,r,o,l,u){if(n===""){this._doInsertHere(t,r,o,l,u);return}let c=n.indexOf("."),d,f;c===-1?(d=n,f=""):(d=n.substring(0,c),f=n.substring(c+1));let p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new lp(this._mainRule.clone(),op.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.insert(t+1,f,r,o,l,u)}_doInsertHere(t,n,r,o,l){if(n===null){this._mainRule.acceptOverwrite(t,r,o,l);return}for(let u=0,c=this._rulesWithParentScopes.length;u<c;u++){let d=this._rulesWithParentScopes[u];if(Lw(d.parentScopes,n)===0){d.acceptOverwrite(t,r,o,l);return}}r===-1&&(r=this._mainRule.fontStyle),o===0&&(o=this._mainRule.foreground),l===0&&(l=this._mainRule.background),this._rulesWithParentScopes.push(new op(t,n,r,o,l))}},Ga=class _r{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=_r.getLanguageId(t),r=_r.getTokenType(t),o=_r.getFontStyle(t),l=_r.getForeground(t),u=_r.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:o,foreground:l,background:u})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,o,l,u,c){let d=_r.getLanguageId(t),f=_r.getTokenType(t),p=_r.containsBalancedBrackets(t)?1:0,m=_r.getFontStyle(t),x=_r.getForeground(t),y=_r.getBackground(t);return n!==0&&(d=n),r!==8&&(f=r),o!==null&&(p=o?1:0),l!==-1&&(m=l),u!==0&&(x=u),c!==0&&(y=c),(d<<0|f<<8|p<<10|m<<11|x<<15|y<<24)>>>0}};function Pu(e,t){const n=[],r=c4(e);let o=r.next();for(;o!==null;){let d=0;if(o.length===2&&o.charAt(1)===":"){switch(o.charAt(0)){case"R":d=1;break;case"L":d=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=r.next()}let f=u();if(n.push({matcher:f,priority:d}),o!==",")break;o=r.next()}return n;function l(){if(o==="-"){o=r.next();const d=l();return f=>!!d&&!d(f)}if(o==="("){o=r.next();const d=c();return o===")"&&(o=r.next()),d}if(c0(o)){const d=[];do d.push(o),o=r.next();while(c0(o));return f=>t(d,f)}return null}function u(){const d=[];let f=l();for(;f;)d.push(f),f=l();return p=>d.every(m=>m(p))}function c(){const d=[];let f=u();for(;f&&(d.push(f),o==="|"||o===",");){do o=r.next();while(o==="|"||o===",");f=u()}return p=>d.some(m=>m(p))}}function c0(e){return!!e&&!!e.match(/[\w\.:]+/)}function c4(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function Iw(e){typeof e.dispose=="function"&&e.dispose()}var Sl=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},u4=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},d4=class{constructor(){_e(this,"_references",[]);_e(this,"_seenReferenceKeys",new Set);_e(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))}},h4=class{constructor(e,t){_e(this,"seenFullScopeRequests",new Set);_e(this,"seenPartialScopeRequests",new Set);_e(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Sl(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new d4;for(const n of e)f4(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof Sl){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 f4(e,t,n,r){const o=n.lookup(e.scopeName);if(!o){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const l=n.lookup(t);e instanceof Sl?Cu({baseGrammar:l,selfGrammar:o},r):cp(e.ruleName,{baseGrammar:l,selfGrammar:o,repository:o.repository},r);const u=n.injections(e.scopeName);if(u)for(const c of u)r.add(new Sl(c))}function cp(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];Bu([r],t,n)}}function Cu(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Bu(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Bu(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Bu(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const o=r.repository?Nw({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Bu(r.patterns,{...t,repository:o},n);const l=r.include;if(!l)continue;const u=Pw(l);switch(u.kind){case 0:Cu({...t,selfGrammar:t.baseGrammar},n);break;case 1:Cu(t,n);break;case 2:cp(u.ruleName,{...t,repository:o},n);break;case 3:case 4:const c=u.scopeName===t.selfGrammar.scopeName?t.selfGrammar:u.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(c){const d={baseGrammar:t.baseGrammar,selfGrammar:c,repository:o};u.kind===4?cp(u.ruleName,d,n):Cu(d,n)}else u.kind===4?n.add(new u4(u.scopeName,u.ruleName)):n.add(new Sl(u.scopeName));break}}}var m4=class{constructor(){_e(this,"kind",0)}},p4=class{constructor(){_e(this,"kind",1)}},g4=class{constructor(e){_e(this,"kind",2);this.ruleName=e}},x4=class{constructor(e){_e(this,"kind",3);this.scopeName=e}},y4=class{constructor(e,t){_e(this,"kind",4);this.scopeName=e,this.ruleName=t}};function Pw(e){if(e==="$base")return new m4;if(e==="$self")return new p4;const t=e.indexOf("#");if(t===-1)return new x4(e);if(t===0)return new g4(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new y4(n,r)}}var _4=/\\(\d+)/,u0=/\\(\d+)/g,b4=-1,Bw=-2;var Il=class{constructor(e,t,n,r){_e(this,"$location");_e(this,"id");_e(this,"_nameIsCapturing");_e(this,"_name");_e(this,"_contentNameIsCapturing");_e(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=uu.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=uu.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${Tw(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:uu.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:uu.replaceCaptures(this._contentName,e,t)}},v4=class extends Il{constructor(t,n,r,o,l){super(t,n,r,o);_e(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=l}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,o){throw new Error("Not supported!")}},S4=class extends Il{constructor(t,n,r,o,l){super(t,n,r,null);_e(this,"_match");_e(this,"captures");_e(this,"_cachedCompiledPatterns");this._match=new wl(o,this.id),this.captures=l,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,o){return this._getCachedCompiledPatterns(t).compileAG(t,r,o)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Cl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},d0=class extends Il{constructor(t,n,r,o,l){super(t,n,r,o);_e(this,"hasMissingPatterns");_e(this,"patterns");_e(this,"_cachedCompiledPatterns");this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,o){return this._getCachedCompiledPatterns(t).compileAG(t,r,o)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Cl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},up=class extends Il{constructor(t,n,r,o,l,u,c,d,f,p){super(t,n,r,o);_e(this,"_begin");_e(this,"beginCaptures");_e(this,"_end");_e(this,"endHasBackReferences");_e(this,"endCaptures");_e(this,"applyEndPatternLast");_e(this,"hasMissingPatterns");_e(this,"patterns");_e(this,"_cachedCompiledPatterns");this._begin=new wl(l,this.id),this.beginCaptures=u,this._end=new wl(c||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=f||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,o){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,o)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Cl;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}},$u=class extends Il{constructor(t,n,r,o,l,u,c,d,f){super(t,n,r,o);_e(this,"_begin");_e(this,"beginCaptures");_e(this,"whileCaptures");_e(this,"_while");_e(this,"whileHasBackReferences");_e(this,"hasMissingPatterns");_e(this,"patterns");_e(this,"_cachedCompiledPatterns");_e(this,"_cachedCompiledWhilePatterns");this._begin=new wl(l,this.id),this.beginCaptures=u,this.whileCaptures=d,this._while=new wl(c,Bw),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=f.patterns,this.hasMissingPatterns=f.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,n){return this._while.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,o){return this._getCachedCompiledPatterns(t).compileAG(t,r,o)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Cl;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,o){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,o)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Cl,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},$w=class Nn{static createCaptureRule(t,n,r,o,l){return t.registerRule(u=>new v4(n,u,r,o,l))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(o=>{if(t.id=o,t.match)return new S4(t.$vscodeTextmateLocation,t.id,t.name,t.match,Nn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Nw({},r,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new d0(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Nn._compilePatterns(l,n,r))}return t.while?new $u(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Nn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Nn._compileCaptures(t.whileCaptures||t.captures,n,r),Nn._compilePatterns(t.patterns,n,r)):new up(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Nn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Nn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Nn._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let o=[];if(t){let l=0;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);c>l&&(l=c)}for(let u=0;u<=l;u++)o[u]=null;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);let d=0;t[u].patterns&&(d=Nn.getCompiledRuleId(t[u],n,r)),o[c]=Nn.createCaptureRule(n,t[u].$vscodeTextmateLocation,t[u].name,t[u].contentName,d)}}return o}static _compilePatterns(t,n,r){let o=[];if(t)for(let l=0,u=t.length;l<u;l++){const c=t[l];let d=-1;if(c.include){const f=Pw(c.include);switch(f.kind){case 0:case 1:d=Nn.getCompiledRuleId(r[c.include],n,r);break;case 2:let p=r[f.ruleName];p&&(d=Nn.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=f.scopeName,x=f.kind===4?f.ruleName:null,y=n.getExternalGrammar(m,r);if(y)if(x){let w=y.repository[x];w&&(d=Nn.getCompiledRuleId(w,n,y.repository))}else d=Nn.getCompiledRuleId(y.repository.$self,n,y.repository);break}}else d=Nn.getCompiledRuleId(c,n,r);if(d!==-1){const f=n.getRule(d);let p=!1;if((f instanceof d0||f instanceof up||f instanceof $u)&&f.hasMissingPatterns&&f.patterns.length===0&&(p=!0),p)continue;o.push(d)}}return{patterns:o,hasMissingPatterns:(t?t.length:0)!==o.length}}},wl=class zw{constructor(t,n){_e(this,"source");_e(this,"ruleId");_e(this,"hasAnchor");_e(this,"hasBackReferences");_e(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let o=0,l=[],u=!1;for(let c=0;c<r;c++)if(t.charAt(c)==="\\"&&c+1<r){const f=t.charAt(c+1);f==="z"?(l.push(t.substring(o,c)),l.push("$(?!\\n)(?<!\\n)"),o=c+2):(f==="A"||f==="G")&&(u=!0),c++}this.hasAnchor=u,o===0?this.source=t:(l.push(t.substring(o,r)),this.source=l.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=_4.test(this.source):this.hasBackReferences=!1}clone(){return new zw(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(o=>t.substring(o.start,o.end));return u0.lastIndex=0,this.source.replace(u0,(o,l)=>Dw(r[parseInt(l,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],o=[],l,u,c,d;for(l=0,u=this.source.length;l<u;l++)c=this.source.charAt(l),t[l]=c,n[l]=c,r[l]=c,o[l]=c,c==="\\"&&l+1<u&&(d=this.source.charAt(l+1),d==="A"?(t[l+1]="",n[l+1]="",r[l+1]="A",o[l+1]="A"):d==="G"?(t[l+1]="",n[l+1]="G",r[l+1]="",o[l+1]="G"):(t[l+1]=d,n[l+1]=d,r[l+1]=d,o[l+1]=d),l++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:o.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}},Cl=class{constructor(){_e(this,"_items");_e(this,"_hasAnchors");_e(this,"_cached");_e(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 h0(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(o=>o.resolveAnchors(t,n));return new h0(e,r,this._items.map(o=>o.ruleId))}},h0=class{constructor(e,t,n){_e(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(`
|
|
125
|
+
`)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},wm=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ys,w4=(ys=class{constructor(t,n){_e(this,"_defaultAttributes");_e(this,"_embeddedLanguagesMatcher");_e(this,"_getBasicScopeAttributes",new Rw(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new wm(n,r)}));this._defaultAttributes=new wm(t,8),this._embeddedLanguagesMatcher=new C4(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?ys._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(ys.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!")}},_e(ys,"_NULL_SCOPE_METADATA",new wm(0,0)),_e(ys,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),ys),C4=class{constructor(e){_e(this,"values");_e(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>Dw(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])}},f0=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Hw(e,t,n,r,o,l,u,c){const d=t.content.length;let f=!1,p=-1;if(u){const y=k4(e,t,n,r,o,l);o=y.stack,r=y.linePos,n=y.isFirstLine,p=y.anchorPosition}const m=Date.now();for(;!f;){if(c!==0&&Date.now()-m>c)return new f0(o,!0);x()}return new f0(o,!1);function x(){const y=E4(e,t,n,r,o,p);if(!y){l.produce(o,d),f=!0;return}const w=y.captureIndices,C=y.matchedRuleId,v=w&&w.length>0?w[0].end>r:!1;if(C===b4){const S=o.getRule(e);l.produce(o,w[0].start),o=o.withContentNameScopesList(o.nameScopesList),ul(e,t,n,o,l,S.endCaptures,w),l.produce(o,w[0].end);const b=o;if(o=o.parent,p=b.getAnchorPos(),!v&&b.getEnterPos()===r){o=b,l.produce(o,d),f=!0;return}}else{const S=e.getRule(C);l.produce(o,w[0].start);const b=o,_=S.getName(t.content,w),j=o.contentNameScopesList.pushAttributed(_,e);if(o=o.push(C,r,p,w[0].end===d,null,j,j),S instanceof up){const E=S;ul(e,t,n,o,l,E.beginCaptures,w),l.produce(o,w[0].end),p=w[0].end;const T=E.getContentName(t.content,w),D=j.pushAttributed(T,e);if(o=o.withContentNameScopesList(D),E.endHasBackReferences&&(o=o.withEndRule(E.getEndWithResolvedBackReferences(t.content,w))),!v&&b.hasSameRuleAs(o)){o=o.pop(),l.produce(o,d),f=!0;return}}else if(S instanceof $u){const E=S;ul(e,t,n,o,l,E.beginCaptures,w),l.produce(o,w[0].end),p=w[0].end;const T=E.getContentName(t.content,w),D=j.pushAttributed(T,e);if(o=o.withContentNameScopesList(D),E.whileHasBackReferences&&(o=o.withEndRule(E.getWhileWithResolvedBackReferences(t.content,w))),!v&&b.hasSameRuleAs(o)){o=o.pop(),l.produce(o,d),f=!0;return}}else if(ul(e,t,n,o,l,S.captures,w),l.produce(o,w[0].end),o=o.pop(),!v){o=o.safePop(),l.produce(o,d),f=!0;return}}w[0].end>r&&(r=w[0].end,n=!1)}}function k4(e,t,n,r,o,l){let u=o.beginRuleCapturedEOL?0:-1;const c=[];for(let d=o;d;d=d.pop()){const f=d.getRule(e);f instanceof $u&&c.push({rule:f,stack:d})}for(let d=c.pop();d;d=c.pop()){const{ruleScanner:f,findOptions:p}=T4(d.rule,e,d.stack.endRule,n,r===u),m=f.findNextMatchSync(t,r,p);if(m){if(m.ruleId!==Bw){o=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(d.stack,m.captureIndices[0].start),ul(e,t,n,d.stack,l,d.rule.whileCaptures,m.captureIndices),l.produce(d.stack,m.captureIndices[0].end),u=m.captureIndices[0].end,m.captureIndices[0].end>r&&(r=m.captureIndices[0].end,n=!1))}else{o=d.stack.pop();break}}return{stack:o,linePos:r,anchorPosition:u,isFirstLine:n}}function E4(e,t,n,r,o,l){const u=j4(e,t,n,r,o,l),c=e.getInjections();if(c.length===0)return u;const d=N4(c,e,t,n,r,o,l);if(!d)return u;if(!u)return d;const f=u.captureIndices[0].start,p=d.captureIndices[0].start;return p<f||d.priorityMatch&&p===f?d:u}function j4(e,t,n,r,o,l){const u=o.getRule(e),{ruleScanner:c,findOptions:d}=Uw(u,e,o.endRule,n,r===l),f=c.findNextMatchSync(t,r,d);return f?{captureIndices:f.captureIndices,matchedRuleId:f.ruleId}:null}function N4(e,t,n,r,o,l,u){let c=Number.MAX_VALUE,d=null,f,p=0;const m=l.contentNameScopesList.getScopeNames();for(let x=0,y=e.length;x<y;x++){const w=e[x];if(!w.matcher(m))continue;const C=t.getRule(w.ruleId),{ruleScanner:v,findOptions:S}=Uw(C,t,null,r,o===u),b=v.findNextMatchSync(n,o,S);if(!b)continue;const _=b.captureIndices[0].start;if(!(_>=c)&&(c=_,d=b.captureIndices,f=b.ruleId,p=w.priority,c===o))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:f}:null}function Uw(e,t,n,r,o){return{ruleScanner:e.compileAG(t,n,r,o),findOptions:0}}function T4(e,t,n,r,o){return{ruleScanner:e.compileWhileAG(t,n,r,o),findOptions:0}}function ul(e,t,n,r,o,l,u){if(l.length===0)return;const c=t.content,d=Math.min(l.length,u.length),f=[],p=u[0].end;for(let m=0;m<d;m++){const x=l[m];if(x===null)continue;const y=u[m];if(y.length===0)continue;if(y.start>p)break;for(;f.length>0&&f[f.length-1].endPos<=y.start;)o.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop();if(f.length>0?o.produceFromScopes(f[f.length-1].scopes,y.start):o.produce(r,y.start),x.retokenizeCapturedWithRuleId){const C=x.getName(c,u),v=r.contentNameScopesList.pushAttributed(C,e),S=x.getContentName(c,u),b=v.pushAttributed(S,e),_=r.push(x.retokenizeCapturedWithRuleId,y.start,-1,!1,null,v,b),j=e.createOnigString(c.substring(0,y.end));Hw(e,j,n&&y.start===0,y.start,_,o,!1,0),Iw(j);continue}const w=x.getName(c,u);if(w!==null){const v=(f.length>0?f[f.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);f.push(new A4(v,y.end))}}for(;f.length>0;)o.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop()}var A4=class{constructor(e,t){_e(this,"scopes");_e(this,"endPos");this.scopes=e,this.endPos=t}};function L4(e,t,n,r,o,l,u,c){return new R4(e,t,n,r,o,l,u,c)}function m0(e,t,n,r,o){const l=Pu(t,zu),u=$w.getCompiledRuleId(n,r,o.repository);for(const c of l)e.push({debugSelector:t,matcher:c.matcher,ruleId:u,grammar:o,priority:c.priority})}function zu(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let o=n;o<t.length;o++)if(D4(t[o],r))return n=o+1,!0;return!1})}function D4(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 R4=class{constructor(e,t,n,r,o,l,u,c){_e(this,"_rootId");_e(this,"_lastRuleId");_e(this,"_ruleId2desc");_e(this,"_includedGrammars");_e(this,"_grammarRepository");_e(this,"_grammar");_e(this,"_injections");_e(this,"_basicScopeAttributesProvider");_e(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new w4(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=p0(t,null),this._injections=null,this._tokenTypeMatchers=[],o)for(const d of Object.keys(o)){const f=Pu(d,zu);for(const p of f)this._tokenTypeMatchers.push({matcher:p.matcher,type:o[d]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:o=>o===this._rootScopeName?this._grammar:this.getExternalGrammar(o),injections:o=>this._grammarRepository.injections(o)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const o=r.injections;if(o)for(let u in o)m0(t,u,o[u],this,r);const l=this._grammarRepository.injections(n);l&&l.forEach(u=>{const c=this.getExternalGrammar(u);if(c){const d=c.injectionSelector;d&&m0(t,d,c,this,c)}})}return t.sort((o,l)=>o.priority-l.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=p0(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=$w.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let o;if(!t||t===dp.NULL){o=!0;const f=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Ga.set(0,f.languageId,f.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),x=this.getRule(this._rootId).getName(null,null);let y;x?y=pl.createRootAndLookUpScopeName(x,m,this):y=pl.createRoot("unknown",m),t=new dp(null,this._rootId,-1,-1,!1,null,y,y)}else o=!1,t.reset();e=e+`
|
|
126
|
+
`;const l=this.createOnigString(e),u=l.content.length,c=new M4(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=Hw(this,l,o,0,t,c,!0,r);return Iw(l),{lineLength:u,lineTokens:c,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function p0(e,t){return e=JO(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 pl=class Hr{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,o=(t==null?void 0:t.scopePath)??null;for(const l of n)o=Sm.push(o,l.scopeNames),r=new Hr(r,o,l.encodedTokenAttributes);return r}static createRoot(t,n){return new Hr(null,new Sm(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const o=r.getMetadataForScope(t),l=new Sm(null,t),u=r.themeProvider.themeMatch(l),c=Hr.mergeAttributes(n,o,u);return new Hr(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Hr.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 o=-1,l=0,u=0;return r!==null&&(o=r.fontStyle,l=r.foregroundId,u=r.backgroundId),Ga.set(t,n.languageId,n.tokenType,null,o,l,u)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Hr._pushAttributed(this,t,n);const r=t.split(/ /g);let o=this;for(const l of r)o=Hr._pushAttributed(o,l,n);return o}static _pushAttributed(t,n,r){const o=r.getMetadataForScope(n),l=t.scopePath.push(n),u=r.themeProvider.themeMatch(l),c=Hr.mergeAttributes(t.tokenAttributes,o,u);return new Hr(t,l,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var o;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((o=r.parent)==null?void 0:o.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},vr,dp=(vr=class{constructor(t,n,r,o,l,u,c,d){_e(this,"_stackElementBrand");_e(this,"_enterPos");_e(this,"_anchorPos");_e(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=l,this.endRule=u,this.nameScopesList=c,this.contentNameScopesList=d,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=o}equals(t){return t===null?!1:vr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?pl.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(){vr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,o,l,u,c){return new vr(this,t,n,r,o,l,u,c)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var r,o;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(o=this.contentNameScopesList)==null?void 0:o.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 vr(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=pl.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new vr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,pl.fromExtension(r,n.contentNameScopesList))}},_e(vr,"NULL",new vr(null,0,0,0,!1,null,null,null)),vr),O4=class{constructor(e,t){_e(this,"balancedBracketScopes");_e(this,"unbalancedBracketScopes");_e(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Pu(n,zu).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Pu(n,zu).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},M4=class{constructor(e,t,n,r){_e(this,"_emitBinaryTokens");_e(this,"_lineText");_e(this,"_tokens");_e(this,"_binaryTokens");_e(this,"_lastTokenEndIndex");_e(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 o=(e==null?void 0:e.tokenAttributes)??0,l=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(l=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const u=(e==null?void 0:e.getScopeNames())??[];for(const c of this._tokenTypeOverrides)c.matcher(u)&&(o=Ga.set(o,0,c.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(u))}if(l&&(o=Ga.set(o,0,8,l,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===o){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(o),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,o=this._binaryTokens.length;r<o;r++)n[r]=this._binaryTokens[r];return n}},I4=class{constructor(e,t){_e(this,"_grammars",new Map);_e(this,"_rawGrammars",new Map);_e(this,"_injectionGrammars",new Map);_e(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,o){if(!this._grammars.has(e)){let l=this._rawGrammars.get(e);if(!l)return null;this._grammars.set(e,L4(e,l,t,n,r,o,this,this._onigLib))}return this._grammars.get(e)}},P4=class{constructor(t){_e(this,"_options");_e(this,"_syncRegistry");_e(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new I4(Iu.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Iu.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 O4(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,o,l){const u=new h4(this._syncRegistry,t);for(;u.Q.length>0;)u.Q.map(c=>this._loadSingleGrammar(c.scopeName)),u.processQueue();return this._grammarForScopeName(t,n,r,o,l)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,o=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,o)}_grammarForScopeName(t,n=0,r=null,o=null,l=null){return this._syncRegistry.grammarForScopeName(t,n,r,o,l)}},hp=dp.NULL;function Hu(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[o,l]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof l=="string"?n[o]=l:o===r&&Object.assign(n,l);return n}function Js(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function B4(e){return Array.isArray(e)?e:[e]}async function Fw(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function xd(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Vw(e){return e==="ansi"||xd(e)}function yd(e){return e==="none"}function Gw(e){return yd(e)}const $4=/(\r?\n)/g;function _d(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split($4);let r=0;const o=[];for(let u=0;u<n.length;u+=2){const c=t?n[u]+(n[u+1]||""):n[u];o.push([c,r]),r+=n[u].length,r+=((l=n[u+1])==null?void 0:l.length)||0}return o}const g0={light:"#333333",dark:"#bbbbbb"},x0={light:"#fffffe",dark:"#1e1e1e"},y0="__shiki_resolved";function dg(e){var c,d,f,p,m;if(e!=null&&e[y0])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||(t.type="dark"),t.colorReplacements={...t.colorReplacements},t.settings||(t.settings=[]);let{bg:n,fg:r}=t;if(!n||!r){const x=t.settings?t.settings.find(y=>!y.name&&!y.scope):void 0;(c=x==null?void 0:x.settings)!=null&&c.foreground&&(r=x.settings.foreground),(d=x==null?void 0:x.settings)!=null&&d.background&&(n=x.settings.background),!r&&((f=t==null?void 0:t.colors)!=null&&f["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?g0.light:g0.dark),n||(n=t.type==="light"?x0.light:x0.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 o=0;const l=new Map;function u(x){var w;if(l.has(x))return l.get(x);o+=1;const y=`#${o.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${y}`]?u(x):(l.set(x,y),y)}t.settings=t.settings.map(x=>{var v,S;const y=((v=x.settings)==null?void 0:v.foreground)&&!x.settings.foreground.startsWith("#"),w=((S=x.settings)==null?void 0:S.background)&&!x.settings.background.startsWith("#");if(!y&&!w)return x;const C={...x,settings:{...x.settings}};if(y){const b=u(x.settings.foreground);t.colorReplacements[b]=x.settings.foreground,C.settings.foreground=b}if(w){const b=u(x.settings.background);t.colorReplacements[b]=x.settings.background,C.settings.background=b}return C});for(const x of Object.keys(t.colors||{}))if((x==="editor.foreground"||x==="editor.background"||x.startsWith("terminal.ansi"))&&!((m=t.colors[x])!=null&&m.startsWith("#"))){const y=u(t.colors[x]);t.colorReplacements[y]=t.colors[x],t.colors[x]=y}return Object.defineProperty(t,y0,{enumerable:!1,writable:!1,value:!0}),t}async function Ww(e){return[...new Set((await Promise.all(e.filter(t=>!Vw(t)).map(async t=>await Fw(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function qw(e){return(await Promise.all(e.map(async t=>Gw(t)?null:dg(await Fw(t))))).filter(t=>!!t)}function Kw(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 Ht(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var z4=class extends P4{constructor(t,n,r,o={}){super(t);_e(this,"_resolver");_e(this,"_themes");_e(this,"_langs");_e(this,"_alias");_e(this,"_resolvedThemes",new Map);_e(this,"_resolvedGrammars",new Map);_e(this,"_langMap",new Map);_e(this,"_langGraph",new Map);_e(this,"_textmateThemeCache",new WeakMap);_e(this,"_loadedThemesCache",null);_e(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=o,this._themes.map(l=>this.loadTheme(l)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=dg(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=Iu.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=Kw(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var l,u,c,d;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(f=>{var p;return(p=f.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const o=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(o.name=t.name,this._resolvedGrammars.set(t.name,o),t.aliases&&t.aliases.forEach(f=>{this._alias[f]=t.name}),this._loadedLanguagesCache=null,n.size)for(const f of n)this._resolvedGrammars.delete(f.name),this._loadedLanguagesCache=null,(u=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||u.delete(f.scopeName),(d=(c=this._syncRegistry)==null?void 0:c._grammars)==null||d.delete(f.scopeName),this.loadLanguage(this._langMap.get(f.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const o of t)this.resolveEmbeddedLanguages(o);const n=[...this._langGraph.entries()],r=n.filter(([o,l])=>!l);if(r.length){const o=n.filter(([l,u])=>{var c;return u?(c=u.embeddedLanguages||u.embeddedLangs)==null?void 0:c.some(d=>r.map(([f])=>f).includes(d)):!1}).filter(l=>!r.includes(l));throw new Ht(`Missing languages ${r.map(([l])=>`\`${l}\``).join(", ")}, required by ${o.map(([l])=>`\`${l}\``).join(", ")}`)}for(const[o,l]of n)this._resolver.addLanguage(l);for(const[o,l]of n)this.loadLanguage(l)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const n=t.embeddedLanguages??t.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}},H4=class{constructor(e,t){_e(this,"_langs",new Map);_e(this,"_scopeToLang",new Map);_e(this,"_injections",new Map);_e(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 o=t.slice(0,r).join(".");n=[...n,...this._injections.get(o)||[]]}return n}};let nl=0;function U4(e){nl+=1,e.warnings!==!1&&nl>=10&&nl%10===0&&console.warn(`[Shiki] ${nl} 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 Ht("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(dg),o=new z4(new H4(e.engine,n),r,n,e.langAlias);let l;function u(b){return Kw(b,e.langAlias)}function c(b){v();const _=o.getGrammar(typeof b=="string"?b:b.name);if(!_)throw new Ht(`Language \`${b}\` not found, you may need to load it first`);return _}function d(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};v();const _=o.getTheme(b);if(!_)throw new Ht(`Theme \`${b}\` not found, you may need to load it first`);return _}function f(b){v();const _=d(b);return l!==b&&(o.setTheme(_),l=b),{theme:_,colorMap:o.getColorMap()}}function p(){return v(),o.getLoadedThemes()}function m(){return v(),o.getLoadedLanguages()}function x(...b){v(),o.loadLanguages(b.flat(1))}async function y(...b){return x(await Ww(b))}function w(...b){v();for(const _ of b.flat(1))o.loadTheme(_)}async function C(...b){return v(),w(await qw(b))}function v(){if(t)throw new Ht("Shiki instance has been disposed")}function S(){t||(t=!0,o.dispose(),nl-=1)}return{setTheme:f,getTheme:d,getLanguage:c,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:u,loadLanguage:y,loadLanguageSync:x,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function F4(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([qw(e.themes||[]),Ww(e.langs||[]),e.engine]);return U4({...e,themes:t,langs:n,engine:r})}const Yw=new WeakMap;function bd(e,t){Yw.set(e,t)}function kl(e){return Yw.get(e)}var vd=class Xw{constructor(...t){_e(this,"_stacks",{});_e(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,o]=t;this.lang=r,this._stacks={[o]: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 Xw(Object.fromEntries(B4(n).map(r=>[r,hp])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return V4(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function V4(e){const t=[],n=new Set;function r(o){var u;if(n.has(o))return;n.add(o);const l=(u=o==null?void 0:o.nameScopesList)==null?void 0:u.scopeName;l&&t.push(l),o.parent&&r(o.parent)}return r(e),t}function G4(e,t){if(!(e instanceof vd))throw new Ht("Invalid grammar state");return e.getInternalStack(t)}const W4=/,/,q4=/ /;function Qw(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(xd(e.resolveLangAlias(n.lang||"text"))||yd(r))return _d(t).map(c=>[{content:c[0],offset:c[1]}]);const{theme:o,colorMap:l}=e.setTheme(r),u=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==u.name)throw new Ht(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(o.name))throw new Ht(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return Y4(t,u,o,l,n)}function K4(...e){if(e.length===2)return kl(e[1]);const[t,n,r={}]=e,{lang:o="text",theme:l=t.getLoadedThemes()[0]}=r;if(xd(o)||yd(l))throw new Ht("Plain language does not have grammar state");if(o==="ansi")throw new Ht("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),d=t.getLanguage(o);return new vd(hg(n,d,u,c,r).stateStack,d.name,u.name)}function Y4(e,t,n,r,o){const l=hg(e,t,n,r,o),u=new vd(l.stateStack,t.name,n.name);return bd(l.tokens,u),l.tokens}function hg(e,t,n,r,o){const l=Hu(n,o),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500}=o,d=_d(e);let f=o.grammarState?G4(o.grammarState,n.name)??hp:o.grammarContextCode!=null?hg(o.grammarContextCode,t,n,r,{...o,grammarState:void 0,grammarContextCode:void 0}).stateStack:hp,p=[];const m=[];for(let x=0,y=d.length;x<y;x++){const[w,C]=d[x];if(w===""){p=[],m.push([]);continue}if(u>0&&w.length>=u){p=[],m.push([{content:w,offset:C,color:"",fontStyle:0}]);continue}let v,S,b;o.includeExplanation&&(v=t.tokenizeLine(w,f,c),S=v.tokens,b=0);const _=t.tokenizeLine2(w,f,c),j=_.tokens.length/2;for(let E=0;E<j;E++){const T=_.tokens[2*E],D=E+1<j?_.tokens[2*E+2]:w.length;if(T===D)continue;const L=_.tokens[2*E+1],O=Js(r[Ga.getForeground(L)],l),P=Ga.getFontStyle(L),q={content:w.substring(T,D),offset:C+T,color:O,fontStyle:P};if(o.includeExplanation){const W=[];if(o.includeExplanation!=="scopeName")for(const H of n.settings){let V;switch(typeof H.scope){case"string":V=H.scope.split(W4).map(U=>U.trim());break;case"object":V=H.scope;break;default:continue}W.push({settings:H,selectors:V.map(U=>U.split(q4))})}q.explanation=[];let M=0;for(;T+M<D;){const H=S[b],V=w.substring(H.startIndex,H.endIndex);M+=V.length,q.explanation.push({content:V,scopes:o.includeExplanation==="scopeName"?X4(H.scopes):Q4(W,H.scopes)}),b+=1}}p.push(q)}m.push(p),p=[],f=_.ruleStack}return{tokens:m,stateStack:f}}function X4(e){return e.map(t=>({scopeName:t}))}function Q4(e,t){const n=[];for(let r=0,o=t.length;r<o;r++){const l=t[r];n[r]={scopeName:l,themeMatches:Z4(e,l,t.slice(0,r))}}return n}function _0(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function J4(e,t,n){if(!_0(e.at(-1),t))return!1;let r=e.length-2,o=n.length-1;for(;r>=0&&o>=0;)_0(e[r],n[o])&&(r-=1),o-=1;return r===-1}function Z4(e,t,n){const r=[];for(const{selectors:o,settings:l}of e)for(const u of o)if(J4(u,t,n)){r.push(l);break}return r}function Jw(e,t,n,r=Qw){const o=Object.entries(n.themes).filter(f=>f[1]).map(f=>({color:f[0],theme:f[1]})),l=o.map(f=>{const p=r(e,t,{...n,theme:f.theme});return{tokens:p,state:kl(p),theme:typeof f.theme=="string"?f.theme:f.theme.name}}),u=eM(...l.map(f=>f.tokens)),c=u[0].map((f,p)=>f.map((m,x)=>{const y={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(y.explanation=m.explanation),u.forEach((w,C)=>{const{content:v,explanation:S,offset:b,..._}=w[p][x];y.variants[o[C].color]=_}),y})),d=l[0].state?new vd(Object.fromEntries(l.map(f=>{var p;return[f.theme,(p=f.state)==null?void 0:p.getInternalStack(f.theme)]})),l[0].state.lang):void 0;return d&&bd(c,d),c}function eM(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const o=e.map(d=>d[r]),l=t.map(()=>[]);t.forEach((d,f)=>d.push(l[f]));const u=o.map(()=>0),c=o.map(d=>d[0]);for(;c.every(d=>d);){const d=Math.min(...c.map(f=>f.content.length));for(let f=0;f<n;f++){const p=c[f];p.content.length===d?(l[f].push(p),u[f]+=1,c[f]=o[f][u[f]]):(l[f].push({...p,content:p.content.slice(0,d)}),c[f]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const tM=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Pl{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Pl.prototype.normal={};Pl.prototype.property={};Pl.prototype.space=void 0;function Zw(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Pl(n,r,t)}function fp(e){return e.toLowerCase()}class Yn{constructor(t,n){this.attribute=n,this.property=t}}Yn.prototype.attribute="";Yn.prototype.booleanish=!1;Yn.prototype.boolean=!1;Yn.prototype.commaOrSpaceSeparated=!1;Yn.prototype.commaSeparated=!1;Yn.prototype.defined=!1;Yn.prototype.mustUseProperty=!1;Yn.prototype.number=!1;Yn.prototype.overloadedBoolean=!1;Yn.prototype.property="";Yn.prototype.spaceSeparated=!1;Yn.prototype.space=void 0;let nM=0;const ht=Ui(),cn=Ui(),mp=Ui(),Re=Ui(),zt=Ui(),Ua=Ui(),ar=Ui();function Ui(){return 2**++nM}const pp=Object.freeze(Object.defineProperty({__proto__:null,boolean:ht,booleanish:cn,commaOrSpaceSeparated:ar,commaSeparated:Ua,number:Re,overloadedBoolean:mp,spaceSeparated:zt},Symbol.toStringTag,{value:"Module"})),Cm=Object.keys(pp);class fg extends Yn{constructor(t,n,r,o){let l=-1;if(super(t,n),b0(this,"space",o),typeof r=="number")for(;++l<Cm.length;){const u=Cm[l];b0(this,Cm[l],(r&pp[u])===pp[u])}}}fg.prototype.defined=!0;function b0(e,t,n){n&&(e[t]=n)}function eo(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const l=new fg(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[fp(r)]=r,n[fp(l.attribute)]=r}return new Pl(t,n,e.space)}const eC=eo({properties:{ariaActiveDescendant:null,ariaAtomic:cn,ariaAutoComplete:null,ariaBusy:cn,ariaChecked:cn,ariaColCount:Re,ariaColIndex:Re,ariaColSpan:Re,ariaControls:zt,ariaCurrent:null,ariaDescribedBy:zt,ariaDetails:null,ariaDisabled:cn,ariaDropEffect:zt,ariaErrorMessage:null,ariaExpanded:cn,ariaFlowTo:zt,ariaGrabbed:cn,ariaHasPopup:null,ariaHidden:cn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:zt,ariaLevel:Re,ariaLive:null,ariaModal:cn,ariaMultiLine:cn,ariaMultiSelectable:cn,ariaOrientation:null,ariaOwns:zt,ariaPlaceholder:null,ariaPosInSet:Re,ariaPressed:cn,ariaReadOnly:cn,ariaRelevant:null,ariaRequired:cn,ariaRoleDescription:zt,ariaRowCount:Re,ariaRowIndex:Re,ariaRowSpan:Re,ariaSelected:cn,ariaSetSize:Re,ariaSort:null,ariaValueMax:Re,ariaValueMin:Re,ariaValueNow:Re,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tC(e,t){return t in e?e[t]:t}function nC(e,t){return tC(e,t.toLowerCase())}const rM=eo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ua,acceptCharset:zt,accessKey:zt,action:null,allow:null,allowFullScreen:ht,allowPaymentRequest:ht,allowUserMedia:ht,alt:null,as:null,async:ht,autoCapitalize:null,autoComplete:zt,autoFocus:ht,autoPlay:ht,blocking:zt,capture:null,charSet:null,checked:ht,cite:null,className:zt,cols:Re,colSpan:null,content:null,contentEditable:cn,controls:ht,controlsList:zt,coords:Re|Ua,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ht,defer:ht,dir:null,dirName:null,disabled:ht,download:mp,draggable:cn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ht,formTarget:null,headers:zt,height:Re,hidden:mp,high:Re,href:null,hrefLang:null,htmlFor:zt,httpEquiv:zt,id:null,imageSizes:null,imageSrcSet:null,inert:ht,inputMode:null,integrity:null,is:null,isMap:ht,itemId:null,itemProp:zt,itemRef:zt,itemScope:ht,itemType:zt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ht,low:Re,manifest:null,max:null,maxLength:Re,media:null,method:null,min:null,minLength:Re,multiple:ht,muted:ht,name:null,nonce:null,noModule:ht,noValidate:ht,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:ht,optimum:Re,pattern:null,ping:zt,placeholder:null,playsInline:ht,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ht,referrerPolicy:null,rel:zt,required:ht,reversed:ht,rows:Re,rowSpan:Re,sandbox:zt,scope:null,scoped:ht,seamless:ht,selected:ht,shadowRootClonable:ht,shadowRootDelegatesFocus:ht,shadowRootMode:null,shape:null,size:Re,sizes:null,slot:null,span:Re,spellCheck:cn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Re,step:null,style:null,tabIndex:Re,target:null,title:null,translate:null,type:null,typeMustMatch:ht,useMap:null,value:cn,width:Re,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:zt,axis:null,background:null,bgColor:null,border:Re,borderColor:null,bottomMargin:Re,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ht,declare:ht,event:null,face:null,frame:null,frameBorder:null,hSpace:Re,leftMargin:Re,link:null,longDesc:null,lowSrc:null,marginHeight:Re,marginWidth:Re,noResize:ht,noHref:ht,noShade:ht,noWrap:ht,object:null,profile:null,prompt:null,rev:null,rightMargin:Re,rules:null,scheme:null,scrolling:cn,standby:null,summary:null,text:null,topMargin:Re,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Re,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ht,disableRemotePlayback:ht,prefix:null,property:null,results:Re,security:null,unselectable:null},space:"html",transform:nC}),sM=eo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ar,accentHeight:Re,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Re,amplitude:Re,arabicForm:null,ascent:Re,attributeName:null,attributeType:null,azimuth:Re,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Re,by:null,calcMode:null,capHeight:Re,className:zt,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:Re,diffuseConstant:Re,direction:null,display:null,dur:null,divisor:Re,dominantBaseline:null,download:ht,dx:null,dy:null,edgeMode:null,editable:null,elevation:Re,enableBackground:null,end:null,event:null,exponent:Re,externalResourcesRequired:null,fill:null,fillOpacity:Re,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:Ua,g2:Ua,glyphName:Ua,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Re,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Re,horizOriginX:Re,horizOriginY:Re,id:null,ideographic:Re,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Re,k:Re,k1:Re,k2:Re,k3:Re,k4:Re,kernelMatrix:ar,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Re,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Re,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:Re,overlineThickness:Re,paintOrder:null,panose1:null,path:null,pathLength:Re,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:zt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Re,pointsAtY:Re,pointsAtZ:Re,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ar,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ar,rev:ar,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ar,requiredFeatures:ar,requiredFonts:ar,requiredFormats:ar,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:Re,specularExponent:Re,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Re,strikethroughThickness:Re,string:null,stroke:null,strokeDashArray:ar,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Re,strokeOpacity:Re,strokeWidth:null,style:null,surfaceScale:Re,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ar,tabIndex:Re,tableValues:null,target:null,targetX:Re,targetY:Re,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ar,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Re,underlineThickness:Re,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Re,values:null,vAlphabetic:Re,vMathematical:Re,vectorEffect:null,vHanging:Re,vIdeographic:Re,version:null,vertAdvY:Re,vertOriginX:Re,vertOriginY:Re,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Re,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tC}),rC=eo({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()}}),sC=eo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:nC}),iC=eo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),iM=/[A-Z]/g,v0=/-[a-z]/g,aM=/^data[-\w.:]+$/i;function oM(e,t){const n=fp(t);let r=t,o=Yn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&aM.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(v0,cM);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!v0.test(l)){let u=l.replace(iM,lM);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}o=fg}return new o(r,t)}function lM(e){return"-"+e.toLowerCase()}function cM(e){return e.charAt(1).toUpperCase()}const uM=Zw([eC,rM,rC,sC,iC],"html"),aC=Zw([eC,sM,rC,sC,iC],"svg"),S0={}.hasOwnProperty;function dM(e,t){const n=t||{};function r(o,...l){let u=r.invalid;const c=r.handlers;if(o&&S0.call(o,e)){const d=String(o[e]);u=S0.call(c,d)?c[d]:r.unknown}if(u)return u.call(this,o,...l)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const hM=/["&'<>`]/g,fM=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,mM=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,pM=/[|\\{}()[\]^$+*?.]/g,w0=new WeakMap;function gM(e,t){if(e=e.replace(t.subset?xM(t.subset):hM,r),t.subset||t.escapeOnly)return e;return e.replace(fM,n).replace(mM,r);function n(o,l,u){return t.format((o.charCodeAt(0)-55296)*1024+o.charCodeAt(1)-56320+65536,u.charCodeAt(l+2),t)}function r(o,l,u){return t.format(o.charCodeAt(0),u.charCodeAt(l+1),t)}}function xM(e){let t=w0.get(e);return t||(t=yM(e),w0.set(e,t)),t}function yM(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(pM,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const _M=/[\dA-Fa-f]/;function bM(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!_M.test(String.fromCharCode(t))?r:r+";"}const vM=/\d/;function SM(e,t,n){const r="&#"+String(e);return n&&t&&!vM.test(String.fromCharCode(t))?r:r+";"}const wM=["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"],km={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:"€"},CM=["cent","copy","divide","gt","lt","not","para","times"],oC={}.hasOwnProperty,gp={};let du;for(du in km)oC.call(km,du)&&(gp[km[du]]=du);const kM=/[^\dA-Za-z]/;function EM(e,t,n,r){const o=String.fromCharCode(e);if(oC.call(gp,o)){const l=gp[o],u="&"+l;return n&&wM.includes(l)&&!CM.includes(l)&&(!r||t&&t!==61&&kM.test(String.fromCharCode(t)))?u:u+";"}return""}function jM(e,t,n){let r=bM(e,t,n.omitOptionalSemicolons),o;if((n.useNamedReferences||n.useShortestReferences)&&(o=EM(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!o)&&n.useShortestReferences){const l=SM(e,t,n.omitOptionalSemicolons);l.length<r.length&&(r=l)}return o&&(!n.useShortestReferences||o.length<r.length)?o:r}function Fa(e,t){return gM(e,Object.assign({format:jM},t))}const NM=/^>|^->|<!--|-->|--!>|<!-$/g,TM=[">"],AM=["<",">"];function LM(e,t,n,r){return r.settings.bogusComments?"<?"+Fa(e.value,Object.assign({},r.settings.characterReferences,{subset:TM}))+">":"<!--"+e.value.replace(NM,o)+"-->";function o(l){return Fa(l,Object.assign({},r.settings.characterReferences,{subset:AM}))}}function DM(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function C0(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;o!==-1;)r++,o=n.indexOf(t,o+t.length);return r}function RM(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function OM(e){return e.join(" ").trim()}const MM=/[ \t\n\f\r]/g;function mg(e){return typeof e=="object"?e.type==="text"?k0(e.value):!1:k0(e)}function k0(e){return e.replace(MM,"")===""}const pn=cC(1),lC=cC(-1),IM=[];function cC(e){return t;function t(n,r,o){const l=n?n.children:IM;let u=(r||0)+e,c=l[u];if(!o)for(;c&&mg(c);)u+=e,c=l[u];return c}}const PM={}.hasOwnProperty;function uC(e){return t;function t(n,r,o){return PM.call(e,n.tagName)&&e[n.tagName](n,r,o)}}const pg=uC({body:$M,caption:Em,colgroup:Em,dd:FM,dt:UM,head:Em,html:BM,li:HM,optgroup:VM,option:GM,p:zM,rp:E0,rt:E0,tbody:qM,td:j0,tfoot:KM,th:j0,thead:WM,tr:YM});function Em(e,t,n){const r=pn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&mg(r.value.charAt(0)))}function BM(e,t,n){const r=pn(n,t);return!r||r.type!=="comment"}function $M(e,t,n){const r=pn(n,t);return!r||r.type!=="comment"}function zM(e,t,n){const r=pn(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 HM(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function UM(e,t,n){const r=pn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function FM(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function E0(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function VM(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function GM(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function WM(e,t,n){const r=pn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function qM(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function KM(e,t,n){return!pn(n,t)}function YM(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function j0(e,t,n){const r=pn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const XM=uC({body:ZM,colgroup:eI,head:JM,html:QM,tbody:tI});function QM(e){const t=pn(e,-1);return!t||t.type!=="comment"}function JM(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 ZM(e){const t=pn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&mg(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function eI(e,t,n){const r=lC(n,t),o=pn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&pg(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function tI(e,t,n){const r=lC(n,t),o=pn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&pg(r,n.children.indexOf(r),n)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}const hu={name:[[`
|
|
127
|
+
\f\r &/=>`.split(""),`
|
|
128
|
+
\f\r "&'/=>\``.split("")],[`\0
|
|
129
|
+
\f\r "&'/<=>`.split(""),`\0
|
|
130
|
+
\f\r "&'/<=>\``.split("")]],unquoted:[[`
|
|
131
|
+
\f\r &>`.split(""),`\0
|
|
132
|
+
\f\r "&'<=>\``.split("")],[`\0
|
|
133
|
+
\f\r "&'<=>\``.split(""),`\0
|
|
134
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function nI(e,t,n,r){const o=r.schema,l=o.space==="svg"?!1:r.settings.omitOptionalTags;let u=o.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const c=[];let d;o.space==="html"&&e.tagName==="svg"&&(r.schema=aC);const f=rI(r,e.properties),p=r.all(o.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=o,p&&(u=!1),(f||!l||!XM(e,t,n))&&(c.push("<",e.tagName,f?" "+f:""),u&&(o.space==="svg"||r.settings.closeSelfClosing)&&(d=f.charAt(f.length-1),(!r.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(p),!u&&(!l||!pg(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function rI(e,t){const n=[];let r=-1,o;if(t){for(o in t)if(t[o]!==null&&t[o]!==void 0){const l=sI(e,o,t[o]);l&&n.push(l)}}for(;++r<n.length;){const l=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&l!=='"'&&l!=="'"&&(n[r]+=" ")}return n.join("")}function sI(e,t,n){const r=oM(e.schema,t),o=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,l=e.settings.allowDangerousCharacters?0:1;let u=e.quote,c;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const d=Fa(r.attribute,Object.assign({},e.settings.characterReferences,{subset:hu.name[o][l]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?RM:OM)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(c=Fa(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:hu.unquoted[o][l]}))),c!==n&&(e.settings.quoteSmart&&C0(n,u)>C0(n,e.alternative)&&(u=e.alternative),c=u+Fa(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?hu.single:hu.double)[o][l],attribute:!0}))+u),d+(c&&"="+c))}const iI=["<","&"];function dC(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Fa(e.value,Object.assign({},r.settings.characterReferences,{subset:iI}))}function aI(e,t,n,r){return r.settings.allowDangerousHtml?e.value:dC(e,t,n,r)}function oI(e,t,n,r){return r.all(e)}const lI=dM("type",{invalid:cI,unknown:uI,handlers:{comment:LM,doctype:DM,element:nI,raw:aI,root:oI,text:dC}});function cI(e){throw new Error("Expected node, not `"+e+"`")}function uI(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const dI={},hI={},fI=[];function mI(e,t){const n=t||dI,r=n.quote||'"',o=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:pI,all:gI,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||tM,characterReferences:n.characterReferences||hI,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?aC:uM,quote:r,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function pI(e,t,n){return lI(e,t,n,this)}function gI(e){const t=[],n=e&&e.children||fI;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const N0=/\s+/g;function hC(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(N0)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(N0);for(const o of n)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}const xI=/:?lang=["']([^"']+)["']/g,yI=/(?:```|~~~)([\w-]+)/g,_I=/\\begin\{([\w-]+)\}/g,bI=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function vI(e){const t=_d(e,!0).map(([o])=>o);function n(o){if(o===e.length)return{line:t.length-1,character:t.at(-1).length};let l=o,u=0;for(const c of t){if(l<c.length)break;l-=c.length,u++}return{line:u,character:l}}function r(o,l){let u=0;for(let c=0;c<o;c++)u+=t[c].length;return u+=l,u}return{lines:t,indexToPos:n,posToIndex:r}}function SI(e,t,n){const r=new Set;for(const l of e.matchAll(xI)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(yI)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(_I)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(bI)){const u=l[1].toLowerCase().trim(),c=u.includes("/")?u.split("/").pop():u;c&&r.add(c)}if(!n)return[...r];const o=n.getBundledLanguages();return[...r].filter(l=>l&&o[l])}const wI=["color","background-color"];function CI(e,t){let n=0;const r=[];for(const o of t)o>n&&r.push({...e,content:e.content.slice(n,o),offset:e.offset+n}),n=o;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function kI(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,o)=>r-o);return n.length?e.map(r=>r.flatMap(o=>{const l=n.filter(u=>o.offset<u&&u<o.offset+o.content.length).map(u=>u-o.offset).sort((u,c)=>u-c);return l.length?CI(o,l):o})):e}function EI(e,t,n,r,o="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(p=>Uu(e.variants[p])),c=new Set(u.flatMap(p=>Object.keys(p))),d={},f=(p,m)=>{const x=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":x)};return u.forEach((p,m)=>{for(const x of c){const y=p[x]||"inherit";if(m===0&&r&&wI.includes(x))if(r==="light-dark()"&&u.length>1){const w=t.findIndex(v=>v==="light"),C=t.findIndex(v=>v==="dark");if(w===-1||C===-1)throw new Ht('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[x]=`light-dark(${u[w][x]||"inherit"}, ${u[C][x]||"inherit"})`,o==="css-vars"&&(d[f(m,x)]=y)}else d[x]=y;else o==="css-vars"&&(d[f(m,x)]=y)}}),l.htmlStyle=d,l}function Uu(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&Tn.Italic&&(t["font-style"]="italic"),e.fontStyle&Tn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&Tn.Underline&&n.push("underline"),e.fontStyle&Tn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function xp(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function jI(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let l=function(c){if(typeof c=="number"){if(c<0||c>n.source.length)throw new Ht(`Invalid decoration offset: ${c}. Code length: ${n.source.length}`);return{...o.indexToPos(c),offset:c}}else{const d=o.lines[c.line];if(d===void 0)throw new Ht(`Invalid decoration position ${JSON.stringify(c)}. Lines length: ${o.lines.length}`);let f=c.character;if(f<0&&(f=d.length+f),f<0||f>d.length)throw new Ht(`Invalid decoration position ${JSON.stringify(c)}. Line ${c.line} length: ${d.length}`);return{...c,character:f,offset:o.posToIndex(c.line,f)}}};var r=l;const o=vI(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));NI(u),e.set(n.meta,{decorations:u,converter:o,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 kI(n,t(this).decorations.flatMap(o=>[o.start.offset,o.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),o=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(o.length!==r.converter.lines.length)throw new Ht(`Number of lines in code element (${o.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function l(m,x,y,w){const C=o[m];let v="",S=-1,b=-1;if(x===0&&(S=0),y===0&&(b=0),y===Number.POSITIVE_INFINITY&&(b=C.children.length),S===-1||b===-1)for(let j=0;j<C.children.length;j++)v+=fC(C.children[j]),S===-1&&v.length===x&&(S=j+1),b===-1&&v.length===y&&(b=j+1);if(S===-1)throw new Ht(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(b===-1)throw new Ht(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const _=C.children.slice(S,b);if(!w.alwaysWrap&&_.length===C.children.length)c(C,w,"line");else if(!w.alwaysWrap&&_.length===1&&_[0].type==="element")c(_[0],w,"token");else{const j={type:"element",tagName:"span",properties:{},children:_};c(j,w,"wrapper"),C.children.splice(S,_.length,j)}}function u(m,x){o[m]=c(o[m],x,"line")}function c(m,x,y){var v;const w=x.properties||{},C=x.transform||(S=>S);return m.tagName=x.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(v=x.properties)!=null&&v.class&&hC(m,x.properties.class),m=C(m,y)||m,m}const d=[],f=r.decorations.sort((m,x)=>x.start.offset-m.start.offset||m.end.offset-x.end.offset);for(const m of f){const{start:x,end:y}=m;if(x.line===y.line)l(x.line,x.character,y.character,m);else if(x.line<y.line){l(x.line,x.character,Number.POSITIVE_INFINITY,m);for(let w=x.line+1;w<y.line;w++)d.unshift(()=>u(w,m));l(y.line,0,y.character,m)}}d.forEach(m=>m())}}}function NI(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Ht(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const o=e[r],l=n.start.offset<=o.start.offset&&o.start.offset<n.end.offset,u=n.start.offset<o.end.offset&&o.end.offset<=n.end.offset,c=o.start.offset<=n.start.offset&&n.start.offset<o.end.offset,d=o.start.offset<n.end.offset&&n.end.offset<=o.end.offset;if(l||u||c||d){if(l&&u||c&&d||c&&n.start.offset===n.end.offset||u&&o.start.offset===o.end.offset)continue;throw new Ht(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(o.start)} intersect.`)}}}}function fC(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(fC).join(""):""}const TI=[jI()];function Fu(e){const t=AI(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...TI]}function AI(e){const t=[],n=[],r=[];for(const o of e)switch(o.enforce){case"pre":t.push(o);break;case"post":n.push(o);break;default:r.push(o)}return{pre:t,post:n,normal:r}}var Di=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],jm={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function LI(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 T0(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 DI(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)jm[r]&&t.push({type:"setDecoration",value:jm[r]});else if(r<=29){const o=jm[r-20];o&&(t.push({type:"resetDecoration",value:o}),o==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Di[r-30]}});else if(r===38){const o=T0(e);o&&t.push({type:"setForegroundColor",value:o})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Di[r-40]}});else if(r===48){const o=T0(e);o&&t.push({type:"setBackgroundColor",value:o})}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:Di[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Di[r-100+8]}})}return t}function RI(){let e=null,t=null,n=new Set;return{parse(r){const o=[];let l=0;do{const u=LI(r,l),c=u.sequence?r.substring(l,u.startPosition):r.substring(l);if(c.length>0&&o.push({value:c,foreground:e,background:t,decorations:new Set(n)}),u.sequence){const d=DI(u.sequence);for(const f of d)f.type==="resetAll"?(e=null,t=null,n.clear()):f.type==="resetForegroundColor"?e=null:f.type==="resetBackgroundColor"?t=null:f.type==="resetDecoration"&&n.delete(f.value);for(const f of d)f.type==="setForegroundColor"?e=f.value:f.type==="setBackgroundColor"?t=f.value:f.type==="setDecoration"&&n.add(f.value)}l=u.position}while(l<r.length);return o}}}var OI={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 MI(e=OI){function t(c){return e[c]}function n(c){return`#${c.map(d=>Math.max(0,Math.min(d,255)).toString(16).padStart(2,"0")).join("")}`}let r;function o(){if(r)return r;r=[];for(let f=0;f<Di.length;f++)r.push(t(Di[f]));let c=[0,95,135,175,215,255];for(let f=0;f<6;f++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([c[f],c[p],c[m]]));let d=8;for(let f=0;f<24;f++,d+=10)r.push(n([d,d,d]));return r}function l(c){return o()[c]}function u(c){switch(c.type){case"named":return t(c.name);case"rgb":return n(c.rgb);case"table":return l(c.index)}}return{value:u}}const II=/#([0-9a-f]{3,8})/i,PI=/var\((--[\w-]+-ansi-[\w-]+)\)/,BI={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 $I(e,t,n){const r=Hu(e,n),o=_d(t),l=MI(Object.fromEntries(Di.map(c=>{var f;const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((f=e.colors)==null?void 0:f[d])||BI[c]]}))),u=RI();return o.map(c=>u.parse(c[0]).map(d=>{let f,p;d.decorations.has("reverse")?(f=d.background?l.value(d.background):e.bg,p=d.foreground?l.value(d.foreground):e.fg):(f=d.foreground?l.value(d.foreground):e.fg,p=d.background?l.value(d.background):void 0),f=Js(f,r),p=Js(p,r),d.decorations.has("dim")&&(f=zI(f));let m=Tn.None;return d.decorations.has("bold")&&(m|=Tn.Bold),d.decorations.has("italic")&&(m|=Tn.Italic),d.decorations.has("underline")&&(m|=Tn.Underline),d.decorations.has("strikethrough")&&(m|=Tn.Strikethrough),{content:d.value,offset:c[1],color:f,bgColor:p,fontStyle:m}}))}function zI(e){const t=e.match(II);if(t){const r=t[1];if(r.length===8){const o=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${o}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const o=r[0],l=r[1],u=r[2],c=r[3];return`#${o}${o}${l}${l}${u}${u}${Math.round(Number.parseInt(`${c}${c}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const o=r[0],l=r[1],u=r[2];return`#${o}${o}${l}${l}${u}${u}80`}}}const n=e.match(PI);return n?`var(${n[1]}-dim)`:e}function yp(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:o=e.getLoadedThemes()[0]}=n;if(!xd(r)&&!yd(o)&&r==="ansi"){const{theme:l}=e.setTheme(o);return $I(l,t,n)}return Qw(e,t,n)}function Vu(e,t,n){let r,o,l,u,c,d;if("themes"in n){const{defaultColor:f="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,x=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,b)=>S.color===f?-1:b.color===f?1:0);if(x.length===0)throw new Ht("`themes` option must not be empty");const y=Jw(e,t,n,yp);if(d=kl(y),f&&f!=="light-dark()"&&!x.some(S=>S.color===f))throw new Ht(`\`themes\` option must contain the defaultColor key \`${f}\``);const w=x.map(S=>e.getTheme(S.theme)),C=x.map(S=>S.color);l=y.map(S=>S.map(b=>EI(b,C,p,f,m))),d&&bd(l,d);const v=x.map(S=>Hu(S.theme,n));o=A0(x,w,v,p,f,"fg",m),r=A0(x,w,v,p,f,"bg",m),u=`shiki-themes ${w.map(S=>S.name).join(" ")}`,c=f?void 0:[o,r].join(";")}else if("theme"in n){const f=Hu(n.theme,n);l=yp(e,t,n);const p=e.getTheme(n.theme);r=Js(p.bg,f),o=Js(p.fg,f),u=p.name,d=kl(l)}else throw new Ht("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:o,bg:r,themeName:u,rootStyle:c,grammarState:d}}function A0(e,t,n,r,o,l,u){return e.map((c,d)=>{const f=Js(t[d][l],n[d])||"inherit",p=`${r+c.color}${l==="bg"?"-bg":""}:${f}`;if(d===0&&o){if(o==="light-dark()"&&e.length>1){const m=e.findIndex(y=>y.color==="light"),x=e.findIndex(y=>y.color==="dark");if(m===-1||x===-1)throw new Ht('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Js(t[m][l],n[m])||"inherit"}, ${Js(t[x][l],n[x])||"inherit"});${p}`}return f}return u==="css-vars"?p:null}).filter(c=>!!c).join(";")}const mC=/^\s+$/,HI=/^(\s*)(.*?)(\s*)$/;function Gu(e,t,n,r={meta:{},options:n,codeToHast:(o,l)=>Gu(e,o,l),codeToTokens:(o,l)=>Vu(e,o,l)}){var w,C;let o=t;for(const v of Fu(n))o=((w=v.preprocess)==null?void 0:w.call(r,o,n))||o;let{tokens:l,fg:u,bg:c,themeName:d,rootStyle:f,grammarState:p}=Vu(e,o,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:x=!1}=n;m===!0?l=FI(l):m==="never"&&(l=VI(l)),x&&(l=GI(l));const y={...r,get source(){return o}};for(const v of Fu(n))l=((C=v.tokens)==null?void 0:C.call(y,l))||l;return UI(l,{...n,fg:u,bg:c,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??f},y,p)}function UI(e,t,n,r=kl(e)){var C,v,S,b;const o=Fu(t),l=[],u={type:"root",children:[]},{structure:c="classic",tabindex:d="0"}=t,f={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?f.style=t.rootStyle:f.style=`background-color:${t.bg};color:${t.fg}`),d!==!1&&d!=null&&(f.tabindex=d.toString());for(const[_,j]of Object.entries(t.meta||{}))_.startsWith("_")||(f[_]=j);let p={type:"element",tagName:"pre",properties:f,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const x=[],y={...n,structure:c,addClassToHast:hC,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return u},get pre(){return p},get code(){return m},get lines(){return x}};if(e.forEach((_,j)=>{var D,L;j&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
|
|
135
|
+
`}));let E={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(const O of _){let P={type:"element",tagName:"span",properties:{...O.htmlAttrs},children:[{type:"text",value:O.content}]};const q=xp(O.htmlStyle||Uu(O));q&&(P.properties.style=q);for(const W of o)P=((D=W==null?void 0:W.span)==null?void 0:D.call(y,P,j+1,T,E,O))||P;c==="inline"?u.children.push(P):c==="classic"&&E.children.push(P),T+=O.content.length}if(c==="classic"){for(const O of o)E=((L=O==null?void 0:O.line)==null?void 0:L.call(y,E,j+1))||E;x.push(E),l.push(E)}else c==="inline"&&x.push(E)}),c==="classic"){for(const _ of o)m=((C=_==null?void 0:_.code)==null?void 0:C.call(y,m))||m;p.children.push(m);for(const _ of o)p=((v=_==null?void 0:_.pre)==null?void 0:v.call(y,p))||p;u.children.push(p)}else if(c==="inline"){const _=[];let j={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const T of u.children)T.type==="element"&&T.tagName==="br"?(_.push(j),j={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(T.type==="element"||T.type==="text")&&j.children.push(T);_.push(j);let E={type:"element",tagName:"code",properties:{},children:_};for(const T of o)E=((S=T==null?void 0:T.code)==null?void 0:S.call(y,E))||E;u.children=[];for(let T=0;T<E.children.length;T++){T>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const D=E.children[T];D.type==="element"&&u.children.push(...D.children)}}let w=u;for(const _ of o)w=((b=_==null?void 0:_.root)==null?void 0:b.call(y,w))||w;return r&&bd(w,r),w}function FI(e){return e.map(t=>{const n=[];let r="",o;return t.forEach((l,u)=>{const c=!(l.fontStyle&&(l.fontStyle&Tn.Underline||l.fontStyle&Tn.Strikethrough));c&&mC.test(l.content)&&t[u+1]?(o===void 0&&(o=l.offset),r+=l.content):r?(c?n.push({...l,offset:o,content:r+l.content}):n.push({content:r,offset:o},l),o=void 0,r=""):n.push(l)}),n})}function VI(e){return e.map(t=>t.flatMap(n=>{if(mC.test(n.content))return n;const r=n.content.match(HI);if(!r)return n;const[,o,l,u]=r;if(!o&&!u)return n;const c=[{...n,offset:n.offset+o.length,content:l}];return o&&c.unshift({content:o,offset:n.offset}),u&&c.push({content:u,offset:n.offset+o.length+l.length}),c}))}function GI(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const o=n.at(-1),l=xp(o.htmlStyle||Uu(o)),u=xp(r.htmlStyle||Uu(r)),c=o.fontStyle&&(o.fontStyle&Tn.Underline||o.fontStyle&Tn.Strikethrough),d=r.fontStyle&&(r.fontStyle&Tn.Underline||r.fontStyle&Tn.Strikethrough);!c&&!d&&l===u?o.content+=r.content:n.push({...r})}return n})}const WI=mI;function qI(e,t,n){var l;const r={meta:{},options:n,codeToHast:(u,c)=>Gu(e,u,c),codeToTokens:(u,c)=>Vu(e,u,c)};let o=WI(Gu(e,t,n,r));for(const u of Fu(n))o=((l=u.postprocess)==null?void 0:l.call(r,o,n))||o;return o}async function KI(e){const t=await F4(e);return{getLastGrammarState:(...n)=>K4(t,...n),codeToTokensBase:(n,r)=>yp(t,n,r),codeToTokensWithThemes:(n,r)=>Jw(t,n,r),codeToTokens:(n,r)=>Vu(t,n,r),codeToHast:(n,r)=>Gu(t,n,r),codeToHtml:(n,r)=>qI(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function YI(e){const t=e.langs,n=e.themes,r=e.engine;async function o(l){function u(m){var x;if(typeof m=="string"){if(m=((x=l.langAlias)==null?void 0:x[m])||m,Vw(m))return[];const y=t[m];if(!y)throw new Ht(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return y}return m}function c(m){if(Gw(m))return"none";if(typeof m=="string"){const x=n[m];if(!x)throw new Ht(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return x}return m}const d=(l.themes??[]).map(m=>c(m)),f=(l.langs??[]).map(m=>u(m)),p=await KI({engine:l.engine??r(),...l,themes:d,langs:f});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(u))},loadTheme(...m){return p.loadTheme(...m.map(c))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return o}function XI(e){let t;async function n(r={}){if(t){const o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}else{t=e({...r,themes:[],langs:[]});const o=await t;return await Promise.all([o.loadTheme(...r.themes||[]),o.loadLanguage(...r.langs||[])]),o}}return n}function QI(e,t){const n=XI(e);async function r(o,l){var d;const u=await n({langs:[l.lang],themes:"theme"in l?[l.theme]:Object.values(l.themes)}),c=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,o,l.lang,u));return c&&await u.loadLanguage(...c),u}return{getSingletonHighlighter(o){return n(o)},async codeToHtml(o,l){return(await r(o,l)).codeToHtml(o,l)},async codeToHast(o,l){return(await r(o,l)).codeToHast(o,l)},async codeToTokens(o,l){return(await r(o,l)).codeToTokens(o,l)},async codeToTokensBase(o,l){return(await r(o,l)).codeToTokensBase(o,l)},async codeToTokensWithThemes(o,l){return(await r(o,l)).codeToTokensWithThemes(o,l)},async getLastGrammarState(o,l){return(await n({langs:[l.lang],themes:[l.theme]})).getLastGrammarState(o,l)}}}var JI=rg({bundledLanguages:()=>md,bundledLanguagesAlias:()=>ig,bundledLanguagesBase:()=>sg,bundledLanguagesInfo:()=>fd,bundledThemes:()=>og,bundledThemesInfo:()=>ag,codeToHast:()=>gC,codeToHtml:()=>pC,codeToTokens:()=>xC,codeToTokensBase:()=>yC,codeToTokensWithThemes:()=>_C,createHighlighter:()=>Sd,getLastGrammarState:()=>vC,getSingletonHighlighter:()=>bC});const Sd=YI({langs:md,themes:og,engine:()=>(0,jw.createOnigurumaEngine)(Z(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:pC,codeToHast:gC,codeToTokens:xC,codeToTokensBase:yC,codeToTokensWithThemes:_C,getSingletonHighlighter:bC,getLastGrammarState:vC}=QI(Sd,{guessEmbeddedLanguages:SI}),L0=4294967295;var ZI=class{constructor(e,t={}){_e(this,"patterns");_e(this,"options");_e(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:o}=t;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(l=>{if(typeof l!="string")return l;const u=r==null?void 0:r.get(l);if(u){if(u instanceof RegExp)return u;if(n)return null;throw u}try{const c=o(l);return r==null||r.set(l,c),c}catch(c){if(r==null||r.set(l,c),n)return null;throw c}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,o=[];function l(u,c,d=0){return{index:u,captureIndices:c.indices.map(f=>f==null?{start:L0,end:L0,length:0}:{start:f[0]+d,end:f[1]+d,length:f[1]-f[0]})}}for(let u=0;u<this.regexps.length;u++){const c=this.regexps[u];if(c)try{c.lastIndex=t;const d=c.exec(r);if(!d)continue;if(d.index===t)return l(u,d,0);o.push([u,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(o.length){const u=Math.min(...o.map(c=>c[1].index));for(const[c,d,f]of o)if(d.index===u)return l(c,d,f)}return null}};function to(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function eP(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const gg=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),_n=String.raw;function no(e,t){if(e==null)throw new Error(t??"Value expected");return e}const SC=_n`\[\^?`,wC=`c.? | C(?:-.?)?|${_n`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${_n`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${_n`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${_n`o\{[^\}]*\}?`}|${_n`\d{1,3}`}`,xg=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,fu=new RegExp(_n`
|
|
136
|
+
\\ (?:
|
|
137
|
+
${wC}
|
|
138
|
+
| [gk]<[^>]*>?
|
|
139
|
+
| [gk]'[^']*'?
|
|
140
|
+
| .
|
|
141
|
+
)
|
|
142
|
+
| \( (?:
|
|
143
|
+
\? (?:
|
|
144
|
+
[:=!>({]
|
|
145
|
+
| <[=!]
|
|
146
|
+
| <[^>]*>
|
|
147
|
+
| '[^']*'
|
|
148
|
+
| ~\|?
|
|
149
|
+
| #(?:[^)\\]|\\.?)*
|
|
150
|
+
| [^:)]*[:)]
|
|
151
|
+
)?
|
|
152
|
+
| \*[^\)]*\)?
|
|
153
|
+
)?
|
|
154
|
+
| (?:${xg.source})+
|
|
155
|
+
| ${SC}
|
|
156
|
+
| .
|
|
157
|
+
`.replace(/\s+/g,""),"gsu"),Nm=new RegExp(_n`
|
|
158
|
+
\\ (?:
|
|
159
|
+
${wC}
|
|
160
|
+
| .
|
|
161
|
+
)
|
|
162
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
163
|
+
| ${SC}
|
|
164
|
+
| &&
|
|
165
|
+
| .
|
|
166
|
+
`.replace(/\s+/g,""),"gsu");function tP(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=bP(n.flags),o=[r.extended],l={captureGroup:n.rules.captureGroup,getCurrentModX(){return o.at(-1)},numOpenGroups:0,popModX(){o.pop()},pushModX(m){o.push(m)},replaceCurrentModX(m){o[o.length-1]=m},singleline:n.rules.singleline};let u=[],c;for(fu.lastIndex=0;c=fu.exec(e);){const m=nP(l,e,c[0],fu.lastIndex);m.tokens?u.push(...m.tokens):m.token&&u.push(m.token),m.lastIndex!==void 0&&(fu.lastIndex=m.lastIndex)}const d=[];let f=0;u.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++f:m.raw==="("&&d.push(m)}),f||d.forEach((m,x)=>{m.kind="capturing",m.number=x+1});const p=f||d.length;return{tokens:u.map(m=>m.type==="EscapedNumber"?SP(m,p):m).flat(),flags:r}}function nP(e,t,n,r){const[o,l]=n;if(n==="["||n==="[^"){const u=rP(t,n,r);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(o==="\\"){if("AbBGyYzZ".includes(l))return{token:D0(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:fP(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:kC(n)}}if(l==="K")return{token:EC("keep",n)};if(l==="N"||l==="R")return{token:Ri("newline",n,{negate:l==="N"})};if(l==="O")return{token:Ri("any",n)};if(l==="X")return{token:Ri("text_segment",n)};const u=CC(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(o==="("){if(l==="*")return{token:xP(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:gP(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Ba("group",n)};if(n==="(?>")return{token:Ba("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Ba(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Ba("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Ba("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:uP(n)}}if(e.getCurrentModX()){if(n==="#"){const u=t.indexOf(`
|
|
167
|
+
`,r);return{lastIndex:u===-1?t.length:u}}if(/^\s$/.test(n)){const u=/\s+/y;return u.lastIndex=r,{lastIndex:u.exec(t)?u.lastIndex:r}}}if(n===".")return{token:Ri("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":_n`\A`,$:_n`\Z`}[n]:n;return{token:D0(u,n)}}return n==="|"?{token:iP(n)}:xg.test(n)?{tokens:wP(n)}:{token:_s(to(n),n)}}function rP(e,t,n){const r=[R0(t[1]==="^",t)];let o=1,l;for(Nm.lastIndex=n;l=Nm.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")o++,r.push(R0(u[1]==="^",u));else if(u==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(_s(93,u));else if(o--,r.push(aP(u)),!o)break}else{const c=sP(u);Array.isArray(c)?r.push(...c):r.push(c)}}return{tokens:r,lastIndex:Nm.lastIndex||e.length}}function sP(e){if(e[0]==="\\")return CC(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!gg.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Ri("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?oP(e):e==="&&"?lP(e):_s(to(e),e)}function CC(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return pP(e);if("dDhHsSwW".includes(n))return yP(e);if(e.startsWith(_n`\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 _P(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(u=>parseInt(u,16)),o=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),l=new TextEncoder;return[...o].map(u=>{const c=[...l.encode(u)].map(d=>`\\x${d.toString(16)}`).join("");return _s(to(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return _s(vP(e),e);if(O0.has(n))return _s(O0.get(n),e);if(/\d/.test(n))return cP(t,e);if(e==="\\")throw new Error(_n`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return _s(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function iP(e){return{type:"Alternator",raw:e}}function D0(e,t){return{type:"Assertion",kind:e,raw:t}}function kC(e){return{type:"Backreference",raw:e}}function _s(e,t){return{type:"Character",value:e,raw:t}}function aP(e){return{type:"CharacterClassClose",raw:e}}function oP(e){return{type:"CharacterClassHyphen",raw:e}}function lP(e){return{type:"CharacterClassIntersector",raw:e}}function R0(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Ri(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function EC(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:no(n.flags),raw:t}}function cP(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function uP(e){return{type:"GroupClose",raw:e}}function Ba(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function dP(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function hP(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function fP(e){return{type:"Subroutine",raw:e}}const mP=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),O0=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function pP(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 _s(to(t.toUpperCase())-64,e)}function gP(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const o=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),l=I0(n),u=I0(r),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(o),EC("flags",e,{flags:c});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,Ba("group",e,{...(l||u)&&{flags:c}});throw new Error(`Unexpected flag modifier "${e}"`)}function xP(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:o}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const l=o?o.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[u,c,d]=l,f=mP.has(n)?n.toLowerCase():"custom";switch(f){case"fail":case"mismatch":case"skip":if(l.length>0)throw new Error(`Named callout arguments not allowed "${l}"`);break;case"error":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(typeof u=="string")throw new Error(`Named callout argument must be a number "${u}"`);break;case"max":if(!l.length||l.length>2)throw new Error(`Named callout must have one or two arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(l.length===2&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${c}"`);break;case"count":case"total_count":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(l.length===1&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${u}"`);break;case"cmp":if(l.length!==3)throw new Error(`Named callout must have three arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(typeof c=="number"||!/^(?:[<>!=]=|[<>])$/.test(c))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${c}"`);if(typeof d=="string"&&!/^[A-Za-z_]\w*$/.test(d))throw new Error(`Named callout argument three must be a tag or number "${d}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${f}"`)}return dP(f,r??null,(o==null?void 0:o.split(","))??null,e)}function M0(e){let t=null,n,r;if(e[0]==="{"){const{minStr:o,maxStr:l}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,u=1e5;if(+o>u||l&&+l>u)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+o,r=l===void 0?+o:l===""?1/0:+l,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return hP(t,n,r,e)}function yP(e){const t=e[1].toLowerCase();return Ri({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function _P(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Ri("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function I0(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 bP(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 vP(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 SP(e,t){const{raw:n,inCharClass:r}=e,o=n.slice(1);if(!r&&(o!=="0"&&o.length===1||o[0]!=="0"&&+o<=t))return[kC(n)];const l=[],u=o.match(/^[0-7]+|\d/g);for(let c=0;c<u.length;c++){const d=u[c];let f;if(c===0&&d!=="8"&&d!=="9"){if(f=parseInt(d,8),f>127)throw new Error(_n`Octal encoded byte above 177 unsupported "${n}"`)}else f=to(d);l.push(_s(f,(c===0?"\\":"")+d))}return l}function wP(e){const t=[],n=new RegExp(xg,"gy");let r;for(;r=n.exec(e);){const o=r[0];if(o[0]==="{"){const l=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(o);if(l){const{min:u,max:c}=l.groups;if(+u>+c&&o.endsWith("?")){n.lastIndex--,t.push(M0(o.slice(0,-1)));continue}}}t.push(M0(o))}return t}function jC(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 CP(e){return kP.has(e.type)}const kP=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function NC(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=tP(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),o=(x,y)=>{const w=r.tokens[l.nextIndex];switch(l.parent=x,l.nextIndex++,w.type){case"Alternator":return $i();case"Assertion":return EP(w);case"Backreference":return jP(w,l);case"Character":return wd(w.value,{useLastValid:!!y.isCheckingRangeEnd});case"CharacterClassHyphen":return NP(w,l,y);case"CharacterClassOpen":return TP(w,l,y);case"CharacterSet":return AP(w,l);case"Directive":return IP(w.kind,{flags:w.flags});case"GroupOpen":return LP(w,l,y);case"NamedCallout":return BP(w.kind,w.tag,w.arguments);case"Quantifier":return DP(w,l);case"Subroutine":return RP(w,l);default:throw new Error(`Unexpected token type "${w.type}"`)}},l={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:o},u=zP(PP(r.flags));let c=u.body[0];for(;l.nextIndex<r.tokens.length;){const x=o(c,{});x.type==="Alternative"?(u.body.push(x),c=x):c.body.push(x)}const{capturingGroups:d,hasNumberedRef:f,namedGroupsByName:p,subroutines:m}=l;if(f&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:x}of m)if(typeof x=="number"){if(x>d.length)throw new Error("Subroutine uses a group number that's not defined");x&&(d[x-1].isSubroutined=!0)}else if(p.has(x)){if(p.get(x).length>1)throw new Error(_n`Subroutine uses a duplicate group name "\g<${x}>"`);p.get(x)[0].isSubroutined=!0}else throw new Error(_n`Subroutine uses a group name that's not defined "\g<${x}>"`);return u}function EP({kind:e}){return _p(no({"^":"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===_n`\B`||e===_n`\Y`})}function jP({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),o=(l,u=!1)=>{const c=t.capturingGroups.length;let d=!1;if(l>c)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,bp(u?c+1-l:l,{orphan:d})};if(n){const l=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(l)return o(+l.groups.num,!!l.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return bp(r)}return o(+r)}function NP(e,t,n){const{tokens:r,walk:o}=t,l=t.parent,u=l.body.at(-1),c=r[t.nextIndex];if(!n.isCheckingRangeEnd&&u&&u.type!=="CharacterClass"&&u.type!=="CharacterClassRange"&&c&&c.type!=="CharacterClassOpen"&&c.type!=="CharacterClassClose"&&c.type!=="CharacterClassIntersector"){const d=o(l,{...n,isCheckingRangeEnd:!0});if(u.type==="Character"&&d.type==="Character")return l.body.pop(),MP(u,d);throw new Error("Invalid character class range")}return wd(to("-"))}function TP({negate:e},t,n){const{tokens:r,walk:o}=t,l=[ku()],u=r[t.nextIndex];let c=$0(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(ku()),t.nextIndex++;else{const f=l.at(-1);f.body.push(o(f,n))}c=$0(r[t.nextIndex],u)}const d=ku({negate:e});return l.length===1?d.body=l[0].body:(d.kind="intersection",d.body=l.map(f=>f.body.length===1?f.body[0]:f)),t.nextIndex++,d}function AP({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:l,unicodePropertyMap:u}=r;if(e==="property"){const c=Cd(n);if(gg.has(c)&&!(u!=null&&u.has(c)))e="posix",n=c;else return $a(n,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:l,unicodePropertyMap:u})}return e==="posix"?$P(n,{negate:t}):vp(e,{negate:t})}function LP(e,t,n){const{tokens:r,capturingGroups:o,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,d=HP(e),f=d.type==="AbsenceFunction",p=B0(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(o.push(d),d.name&&eP(l,d.name,[]).push(d)),f&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let x=z0(r[t.nextIndex]);for(;x.type!=="GroupClose";){if(x.type==="Alternator")d.body.push($i()),t.nextIndex++;else{const y=d.body.at(-1),w=c(y,{...n,isInAbsenceFunction:n.isInAbsenceFunction||f,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||m});if(y.body.push(w),(p||n.isInLookbehind)&&!u){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(m||n.isInNegLookbehind){if(P0(w)||w.type==="CapturingGroup")throw new Error(C)}else if(P0(w)||B0(w)&&w.negate)throw new Error(C)}}x=z0(r[t.nextIndex])}return t.nextIndex++,d}function DP({kind:e,min:t,max:n},r){const o=r.parent,l=o.body.at(-1);if(!l||!CP(l))throw new Error("Quantifier requires a repeatable token");const u=AC(e,t,n,l);return o.body.pop(),u}function RP({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let o=e.slice(3,-1);const l=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(o);if(l){const c=+l.groups.num,d=n.length;if(t.hasNumberedRef=!0,o={"":c,"+":d+c,"-":d+1-c}[l.groups.sign],o<1)throw new Error("Invalid subroutine number")}else o==="0"&&(o=0);const u=LC(o);return r.push(u),u}function OP(e,t){return{type:"AbsenceFunction",kind:e,body:Bl(t==null?void 0:t.body)}}function $i(e){return{type:"Alternative",body:DC(e==null?void 0:e.body)}}function _p(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function bp(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function TC(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!UP(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:Bl(t==null?void 0:t.body)}}function wd(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 ku(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:DC(e==null?void 0:e.body)}}function MP(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function vp(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 IP(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:no(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function PP(e){return{type:"Flags",...e}}function Lr(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:Bl(e==null?void 0:e.body)}}function Li(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Bl(e==null?void 0:e.body)}}function BP(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function $P(e,t){const n=!!(t!=null&&t.negate);if(!gg.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function AC(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 zP(e,t){return{type:"Regex",body:Bl(t==null?void 0:t.body),flags:e}}function LC(e){return{type:"Subroutine",ref:e}}function $a(e,t){var o;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(o=n.unicodePropertyMap)==null?void 0:o.get(Cd(e));if(!r){if(n.normalizeUnknownPropertyNames)r=FP(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(_n`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function HP({flags:e,kind:t,name:n,negate:r,number:o}){switch(t){case"absence_repeater":return OP("repeater");case"atomic":return Lr({atomic:!0});case"capturing":return TC(o,{name:n});case"group":return Lr({flags:e});case"lookahead":case"lookbehind":return Li({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function Bl(e){if(e===void 0)e=[$i()];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 DC(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 P0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function B0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function UP(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function FP(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 Cd(e){return e.replace(/[- _]+/g,"").toLowerCase()}function $0(e,t){const n=t;return no(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function z0(e){return no(e,"Unclosed group")}function gl(e,t,n=null){function r(l,u){for(let c=0;c<l.length;c++){const d=o(l[c],u,c,l);c=Math.max(-1,c+d)}}function o(l,u=null,c=null,d=null){var S,b;let f=0,p=!1;const m={node:l,parent:u,key:c,container:d,root:e,remove(){mu(d).splice(Math.max(0,Ta(c)+f),1),f--,p=!0},removeAllNextSiblings(){return mu(d).splice(Ta(c)+1)},removeAllPrevSiblings(){const _=Ta(c)+f;return f-=_,mu(d).splice(0,Math.max(0,_))},replaceWith(_,j={}){const E=!!j.traverse;d?d[Math.max(0,Ta(c)+f)]=_:no(u,"Can't replace root node")[c]=_,E&&o(_,u,c,d),p=!0},replaceWithMultiple(_,j={}){const E=!!j.traverse;if(mu(d).splice(Math.max(0,Ta(c)+f),1,..._),f+=_.length-1,E){let T=0;for(let D=0;D<_.length;D++)T+=o(_[D],u,Ta(c)+D+T,d)}p=!0},skip(){p=!0}},{type:x}=l,y=t["*"],w=t[x],C=typeof y=="function"?y:y==null?void 0:y.enter,v=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(m,n),v==null||v(m,n),!p)switch(x){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(l.body,l);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":o(l.min,l,"min"),o(l.max,l,"max");break;case"Quantifier":o(l.body,l,"body");break;case"Regex":r(l.body,l),o(l.flags,l,"flags");break;default:throw new Error(`Unexpected node type "${x}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,m,n),(b=y==null?void 0:y.exit)==null||b.call(y,m,n),f}return o(e),e}function mu(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Ta(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const VP=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function GP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function WP(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const wr=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function yg(e,t,n,r){const o=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let u=0,c="";for(const d of e.matchAll(o)){const{0:f,groups:{$skip:p}}=d;if(!p&&(!r||r===wr.DEFAULT==!u)){n instanceof Function?c+=n(d,{context:u?wr.CHAR_CLASS:wr.DEFAULT,negated:l[l.length-1]}):c+=n;continue}f[0]==="["?(u++,l.push(f[1]==="^")):f==="]"&&u&&(u--,l.pop()),c+=f}return c}function RC(e,t,n,r){yg(e,t,n,r)}function qP(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const o=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");o.lastIndex=n;let l=0,u;for(;u=o.exec(e);){const{0:c,groups:{$skip:d}}=u;if(!d&&(!r||r===wr.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,o.lastIndex==u.index&&o.lastIndex++}return null}function pu(e,t,n){return!!qP(e,t,0,n)}function KP(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,o=0,l=1,u;for(;u=n.exec(e);){const[c]=u;if(c==="[")o++;else if(o)c==="]"&&o--;else if(c==="(")l++;else if(c===")"&&(l--,!l)){r=u.index;break}}return e.slice(t,r)}const H0=new RegExp(String.raw`(?<noncapturingStart>${VP})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function YP(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 o="(?>",l="(?:(?=(",u=[0],c=[];let d=0,f=0,p=NaN,m;do{m=!1;let x=0,y=0,w=!1,C;for(H0.lastIndex=Number.isNaN(p)?0:p+l.length;C=H0.exec(e);){const{0:v,index:S,groups:{capturingStart:b,noncapturingStart:_}}=C;if(v==="[")x++;else if(x)v==="]"&&x--;else if(v===o&&!w)p=S,w=!0;else if(w&&_)y++;else if(b)w?y++:(d++,u.push(d+f));else if(v===")"&&w){if(!y){f++;const j=d+f;if(e=`${e.slice(0,p)}${l}${e.slice(p+o.length,S)}))<$$${j}>)${e.slice(S+1)}`,m=!0,c.push(j),GP(n,j),r.size){const E=new Map;r.forEach((T,D)=>{E.set(D>=j?D+1:D,T.map(L=>L>=j?L+1:L))}),r=E}break}y--}}}while(m);return n.push(...c),e=yg(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:x,groups:{backrefNum:y,wrappedBackrefNum:w}})=>{if(y){const C=+y;if(C>u.length-1)throw new Error(`Backref "${x}" greater than number of captures`);return`\\${u[C]}`}return`\\${w}`},wr.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const OC=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Tm=new RegExp(String.raw`
|
|
168
|
+
\\(?: \d+
|
|
169
|
+
| c[A-Za-z]
|
|
170
|
+
| [gk]<[^>]+>
|
|
171
|
+
| [pPu]\{[^\}]+\}
|
|
172
|
+
| u[A-Fa-f\d]{4}
|
|
173
|
+
| x[A-Fa-f\d]{2}
|
|
174
|
+
)
|
|
175
|
+
| \((?: \? (?: [:=!>]
|
|
176
|
+
| <(?:[=!]|[^>]+>)
|
|
177
|
+
| [A-Za-z\-]+:
|
|
178
|
+
| \(DEFINE\)
|
|
179
|
+
))?
|
|
180
|
+
| (?<qBase>${OC})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
181
|
+
| \\?.
|
|
182
|
+
`.replace(/\s+/g,""),"gsu");function XP(e){if(!new RegExp(`${OC}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,o="",l=0,u;for(Tm.lastIndex=0;u=Tm.exec(e);){const{0:c,index:d,groups:{qBase:f,qMod:p,invalidQ:m}}=u;if(c==="[")l||(r=d),l++;else if(c==="]")l?l--:r=null;else if(!l)if(p==="+"&&o&&!o.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${c}"`);let x=-1;if(/^\{\d+\}$/.test(f))e=WP(e,d+f.length,p,"");else{if(o===")"||o==="]"){const y=o===")"?n:r;if(y===null)throw new Error(`Invalid unmatched "${o}"`);e=`${e.slice(0,y)}(?>${e.slice(y,d)}${f})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-o.length)}(?>${o}${f})${e.slice(d+c.length)}`;x+=4}Tm.lastIndex+=x}else c[0]==="("?t.push(d):c===")"&&(n=t.length?t.pop():null);o=c}return{pattern:e}}const Sr=String.raw,QP=Sr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Sp=Sr`\(\?R=(?<rDepth>[^\)]+)\)|${QP}`,kd=Sr`\(\?<(?![=!])(?<captureName>[^>]+)>`,MC=Sr`${kd}|(?<unnamed>\()(?!\?)`,Ci=new RegExp(Sr`${kd}|${Sp}|\(\?|\\?.`,"gsu"),Am="Cannot use multiple overlapping recursions";function JP(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let o=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(Sp,"su").test(e))return{pattern:e,captureTransfers:o,hiddenCaptures:n};if(r==="plugin"&&pu(e,Sr`\(\?\(DEFINE\)`,wr.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=pu(e,Sr`\\[1-9]`,wr.DEFAULT),c=new Map,d=[];let f=!1,p=0,m=0,x;for(Ci.lastIndex=0;x=Ci.exec(e);){const{0:y,groups:{captureName:w,rDepth:C,gRNameOrNum:v,gRDepth:S}}=x;if(y==="[")p++;else if(p)y==="]"&&p--;else if(C){if(U0(C),f)throw new Error(Am);if(u)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const b=e.slice(0,x.index),_=e.slice(Ci.lastIndex);if(pu(_,Sp,wr.DEFAULT))throw new Error(Am);const j=+C-1;e=F0(b,_,j,!1,n,l,m),o=G0(o,b,j,l.length,0,m);break}else if(v){U0(S);let b=!1;for(const W of d)if(W.name===v||W.num===+v){if(b=!0,W.hasRecursedWithin)throw new Error(Am);break}if(!b)throw new Error(Sr`Recursive \g cannot be used outside the referenced group "${r==="external"?v:Sr`\g<${v}&R=${S}>`}"`);const _=c.get(v),j=KP(e,_);if(u&&pu(j,Sr`${kd}|\((?!\?)`,wr.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const E=e.slice(_,x.index),T=j.slice(E.length+y.length),D=l.length,L=+S-1,O=F0(E,T,L,!0,n,l,m);o=G0(o,E,L,l.length-D,D,m);const P=e.slice(0,_),q=e.slice(_+j.length);e=`${P}${O}${q}`,Ci.lastIndex+=O.length-y.length-E.length-T.length,d.forEach(W=>W.hasRecursedWithin=!0),f=!0}else if(w)m++,c.set(String(m),Ci.lastIndex),c.set(w,Ci.lastIndex),d.push({num:m,name:w});else if(y[0]==="("){const b=y==="(";b&&(m++,c.set(String(m),Ci.lastIndex)),d.push(b?{num:m}:{})}else y===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:o,hiddenCaptures:n}}function U0(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 F0(e,t,n,r,o,l,u){const c=new Set;r&&RC(e+t,kd,({groups:{captureName:f}})=>{c.add(f)},wr.DEFAULT);const d=[n,r?c:null,o,l,u];return`${e}${V0(`(?:${e}`,"forward",...d)}(?:)${V0(`${t})`,"backward",...d)}${t}`}function V0(e,t,n,r,o,l,u){const d=p=>t==="forward"?p+2:n-p+2-1;let f="";for(let p=0;p<n;p++){const m=d(p);f+=yg(e,Sr`${MC}|\\k<(?<backref>[^>]+)>`,({0:x,groups:{captureName:y,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return x;const v=`_$${m}`;if(w||y){const S=u+l.length+1;return l.push(S),ZP(o,S),w?x:`(?<${y}${v}>`}return Sr`\k<${C}${v}>`},wr.DEFAULT)}return f}function ZP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function G0(e,t,n,r,o,l){if(e.size&&r){let u=0;RC(t,MC,()=>u++,wr.DEFAULT);const c=l-u+o,d=new Map;return e.forEach((f,p)=>{const m=(r-u*n)/n,x=u*n,y=p>c+u?p+r:p,w=[];for(const C of f)if(C<=c)w.push(C);else if(C>c+u+m)w.push(C+r);else if(C<=c+u)for(let v=0;v<=n;v++)w.push(C+u*v);else for(let v=0;v<=n;v++)w.push(C+x+m*v);d.set(y,w)}),d}return e}var mn=String.fromCodePoint,ot=String.raw,Or={},Ed=globalThis.RegExp;Or.flagGroups=(()=>{try{new Ed("(?i:)")}catch{return!1}return!0})();Or.unicodeSets=(()=>{try{new Ed("[[]]","v")}catch{return!1}return!0})();Or.bugFlagVLiteralHyphenIsRange=Or.unicodeSets?(()=>{try{new Ed(ot`[\d\-a]`,"v")}catch{return!0}return!1})():!1;Or.bugNestedClassIgnoresNegation=Or.unicodeSets&&new Ed("[[^a]]","v").test("a");function Wu(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 El(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function wp(e,t){return W0[e]>=W0[t]}function e6(e,t){if(e==null)throw new Error(t??"Value expected");return e}var W0={ES2025:2025,ES2024:2024,ES2018:2018},t6={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function IC(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!t6[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=Or.flagGroups?"ES2025":Or.unicodeSets?"ES2024":"ES2018"),t}var n6="[ -\r ]",r6=new Set([mn(304),mn(305)]),fs=ot`[\p{L}\p{M}\p{N}\p{Pc}]`;function PC(e){if(r6.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),o=a6.get(n),l=s6.get(n),u=i6.get(n);return[...r].length===1&&t.add(r),u&&t.add(u),o&&t.add(o),t.add(n),l&&t.add(l),[...t]}var _g=new Map(`C Other
|
|
183
|
+
Cc Control cntrl
|
|
184
|
+
Cf Format
|
|
185
|
+
Cn Unassigned
|
|
186
|
+
Co Private_Use
|
|
187
|
+
Cs Surrogate
|
|
188
|
+
L Letter
|
|
189
|
+
LC Cased_Letter
|
|
190
|
+
Ll Lowercase_Letter
|
|
191
|
+
Lm Modifier_Letter
|
|
192
|
+
Lo Other_Letter
|
|
193
|
+
Lt Titlecase_Letter
|
|
194
|
+
Lu Uppercase_Letter
|
|
195
|
+
M Mark Combining_Mark
|
|
196
|
+
Mc Spacing_Mark
|
|
197
|
+
Me Enclosing_Mark
|
|
198
|
+
Mn Nonspacing_Mark
|
|
199
|
+
N Number
|
|
200
|
+
Nd Decimal_Number digit
|
|
201
|
+
Nl Letter_Number
|
|
202
|
+
No Other_Number
|
|
203
|
+
P Punctuation punct
|
|
204
|
+
Pc Connector_Punctuation
|
|
205
|
+
Pd Dash_Punctuation
|
|
206
|
+
Pe Close_Punctuation
|
|
207
|
+
Pf Final_Punctuation
|
|
208
|
+
Pi Initial_Punctuation
|
|
209
|
+
Po Other_Punctuation
|
|
210
|
+
Ps Open_Punctuation
|
|
211
|
+
S Symbol
|
|
212
|
+
Sc Currency_Symbol
|
|
213
|
+
Sk Modifier_Symbol
|
|
214
|
+
Sm Math_Symbol
|
|
215
|
+
So Other_Symbol
|
|
216
|
+
Z Separator
|
|
217
|
+
Zl Line_Separator
|
|
218
|
+
Zp Paragraph_Separator
|
|
219
|
+
Zs Space_Separator
|
|
220
|
+
ASCII
|
|
221
|
+
ASCII_Hex_Digit AHex
|
|
222
|
+
Alphabetic Alpha
|
|
223
|
+
Any
|
|
224
|
+
Assigned
|
|
225
|
+
Bidi_Control Bidi_C
|
|
226
|
+
Bidi_Mirrored Bidi_M
|
|
227
|
+
Case_Ignorable CI
|
|
228
|
+
Cased
|
|
229
|
+
Changes_When_Casefolded CWCF
|
|
230
|
+
Changes_When_Casemapped CWCM
|
|
231
|
+
Changes_When_Lowercased CWL
|
|
232
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
233
|
+
Changes_When_Titlecased CWT
|
|
234
|
+
Changes_When_Uppercased CWU
|
|
235
|
+
Dash
|
|
236
|
+
Default_Ignorable_Code_Point DI
|
|
237
|
+
Deprecated Dep
|
|
238
|
+
Diacritic Dia
|
|
239
|
+
Emoji
|
|
240
|
+
Emoji_Component EComp
|
|
241
|
+
Emoji_Modifier EMod
|
|
242
|
+
Emoji_Modifier_Base EBase
|
|
243
|
+
Emoji_Presentation EPres
|
|
244
|
+
Extended_Pictographic ExtPict
|
|
245
|
+
Extender Ext
|
|
246
|
+
Grapheme_Base Gr_Base
|
|
247
|
+
Grapheme_Extend Gr_Ext
|
|
248
|
+
Hex_Digit Hex
|
|
249
|
+
IDS_Binary_Operator IDSB
|
|
250
|
+
IDS_Trinary_Operator IDST
|
|
251
|
+
ID_Continue IDC
|
|
252
|
+
ID_Start IDS
|
|
253
|
+
Ideographic Ideo
|
|
254
|
+
Join_Control Join_C
|
|
255
|
+
Logical_Order_Exception LOE
|
|
256
|
+
Lowercase Lower
|
|
257
|
+
Math
|
|
258
|
+
Noncharacter_Code_Point NChar
|
|
259
|
+
Pattern_Syntax Pat_Syn
|
|
260
|
+
Pattern_White_Space Pat_WS
|
|
261
|
+
Quotation_Mark QMark
|
|
262
|
+
Radical
|
|
263
|
+
Regional_Indicator RI
|
|
264
|
+
Sentence_Terminal STerm
|
|
265
|
+
Soft_Dotted SD
|
|
266
|
+
Terminal_Punctuation Term
|
|
267
|
+
Unified_Ideograph UIdeo
|
|
268
|
+
Uppercase Upper
|
|
269
|
+
Variation_Selector VS
|
|
270
|
+
White_Space space
|
|
271
|
+
XID_Continue XIDC
|
|
272
|
+
XID_Start XIDS`.split(/\s/).map(e=>[Cd(e),e])),s6=new Map([["s",mn(383)],[mn(383),"s"]]),i6=new Map([[mn(223),mn(7838)],[mn(107),mn(8490)],[mn(229),mn(8491)],[mn(969),mn(8486)]]),a6=new Map([Gs(453),Gs(456),Gs(459),Gs(498),...Lm(8072,8079),...Lm(8088,8095),...Lm(8104,8111),Gs(8124),Gs(8140),Gs(8188)]),o6=new Map([["alnum",ot`[\p{Alpha}\p{Nd}]`],["alpha",ot`\p{Alpha}`],["ascii",ot`\p{ASCII}`],["blank",ot`[\p{Zs}\t]`],["cntrl",ot`\p{Cc}`],["digit",ot`\p{Nd}`],["graph",ot`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",ot`\p{Lower}`],["print",ot`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",ot`[\p{P}\p{S}]`],["space",ot`\p{space}`],["upper",ot`\p{Upper}`],["word",ot`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",ot`\p{AHex}`]]);function l6(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Gs(e){const t=mn(e);return[t.toLowerCase(),t]}function Lm(e,t){return l6(e,t).map(n=>Gs(n))}var BC=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function c6(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};$C(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:wp(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};gl(e,u6,r);const o={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},l={currentFlags:o,prevFlags:null,globalFlags:o,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};gl(e,d6,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return gl(e,h6,u),e._originMap=l.groupOriginByCopy,e._strategy=r.strategy,e}var u6={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:o}=e;if(o==="repeater"){const l=Lr();l.body[0].body.push(Li({negate:!0,body:r}),$a("Any"));const u=Lr();u.body[0].body.push(AC("greedy",0,1/0,l)),n(en(u,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const o=e.body.filter(l=>l.kind==="flags");for(let l=n+1;l<t.body.length;l++){const u=t.body[l];El(r,u,[]).push(...o)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=HC(t.get(e));if(r){const o=Lr({flags:r});o.body[0].body=e.body,e.body=[en(o,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:o,remove:l,replaceWith:u},c){const{kind:d,negate:f}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:x,wordIsAscii:y}=c;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${f?"Y":"y"}"`);if(d==="line_end")u(en(Li({body:[$i({body:[_p("string_end")]}),$i({body:[wd(10)]})]}),t));else if(d==="line_start")u(en(ms(ot`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(x.has(e))o.flags.sticky=!0,l();else{const w=r[n-1];if(w&&y6(w))u(en(Li({negate:!0}),t));else{if(m)throw new Error(ot`Uses "\G" in a way that requires a subclass`);u(Ws(_p("string_start"),t)),c.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")u(en(ms(ot`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!y&&!p){const w=`(?:(?<=${fs})(?!${fs})|(?<!${fs})(?=${fs}))`,C=`(?:(?<=${fs})(?=${fs})|(?<!${fs})(?!${fs}))`;u(en(ms(f?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Rm(n)&&(n=Dm(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Rm(r)&&(r=Dm(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=ku({body:[e]});n(en(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:o,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:d,negate:f,value:p}=e;if(l&&(d==="digit"||p==="digit")){n(Ws(vp("digit",{negate:f}),t));return}if(u&&(d==="space"||p==="space")){n(en(Om(ms(n6),f),t));return}if(c&&(d==="word"||p==="word")){n(Ws(vp("word",{negate:f}),t));return}if(d==="any")n(Ws($a("Any"),t));else if(d==="digit")n(Ws($a("Nd",{negate:f}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(ot`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",x=ot`\p{RI}{2}|${m}(?:\u200D${m})*`;n(en(ms(ot`(?>\r\n|${o?ot`\p{RGI_Emoji}`:x}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Ws($a("AHex",{negate:f}),t));else if(d==="newline")n(en(ms(f?`[^
|
|
273
|
+
]`:`(?>\r
|
|
274
|
+
?|[
|
|
275
|
+
\v\f
\u2028\u2029])`),t));else if(d==="posix")if(!o&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];f&&(m=`\0-${mn(m.codePointAt(0)-1)}${mn(m.codePointAt(2)+1)}-`),n(en(ms(`[${m}]`),t))}else n(en(Om(ms(o6.get(p)),f),t));else if(d==="property")_g.has(Cd(p))||(e.key="sc");else if(d==="space")n(Ws($a("space",{negate:f}),t));else if(d==="word")n(en(Om(ms(fs),f),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:o,removeAllPrevSiblings:l,removeAllNextSiblings:u}){const{kind:c,flags:d}=e;if(c==="flags")if(!d.enable&&!d.disable)r();else{const f=Lr({flags:d});f.body[0].body=u(),o(en(f,t),{traverse:!0})}else if(c==="keep"){const f=n.body[0],m=n.body.length===1&&jC(f,{type:"Group"})&&f.body[0].body.length===1?f.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(ot`Uses "\K" in a way that's unsupported`);const x=Li({behind:!0});x.body[0].body=l(),o(en(x,t))}else throw new Error(`Unexpected directive kind "${c}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(en(Li({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=Lr();t.body[0].body.push(e.body),e.body=en(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,o=!1;for(const l of e.body)if(l.body.length===1&&l.body[0].kind==="search_start")l.body.pop();else{const u=FC(l.body);u?(r=!0,Array.isArray(u)?n.push(...u):n.push(u)):o=!0}r&&!o&&n.forEach(l=>t.add(l))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(ot`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Rm(n)&&(n=Dm(n,t),e.ref=n)}},d6={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:o}=e;r||n.set(e,[...t.get(o).map(({node:l})=>l)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:o,groupsByName:l,multiplexCapturesToLeftByRef:u,openRefs:c,reffedNodesByReferencer:d}){const f=o.get(e);if(f&&c.has(e.number)){const m=Ws(q0(e.number),t);d.set(m,c.get(e.number)),n(m);return}c.set(e.number,e),u.set(e.number,[]),e.name&&El(u,e.name,[]);const p=u.get(e.name??e.number);for(let m=0;m<p.length;m++){const x=p[m];if(f===x.node||f&&f===x.origin||e===x.origin){p.splice(m,1);break}}if(u.get(e.number).push({node:e,origin:f}),e.name&&u.get(e.name).push({node:e,origin:f}),e.name){const m=El(l,e.name,new Map);let x=!1;if(f)x=!0;else for(const y of m.values())if(!y.hasDuplicateNameToRemove){x=!0;break}l.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:x})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Wu(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:o,ref:l}=e;if(o){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===l||p.number===l)););r.reffedNodesByReferencer.set(e,p);return}const u=r.subroutineRefMap.get(l),c=l===0,d=c?q0(0):zC(u,r.groupOriginByCopy,null);let f=d;if(!c){const p=HC(p6(u,x=>x.type==="Group"&&!!x.flags)),m=p?Wu(r.globalFlags,p):r.globalFlags;f6(m,r.currentFlags)||(f=Lr({flags:g6(m)}),f.body[0].body.push(d))}n(en(f,t),{traverse:!c})}},h6={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const l=r.reffedNodesByReferencer.get(e).filter(u=>m6(u,e));if(!l.length)n(en(Li({negate:!0}),t));else if(l.length>1){const u=Lr({atomic:!0,body:l.reverse().map(c=>$i({body:[bp(c.number)]}))});n(en(u,t))}else e.ref=l[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const o=TC();e.body.at(-1).body.push(o)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function $C(e){gl(e,{"*"({node:t,parent:n}){t.parent=n}})}function f6(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function m6(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=UC(n.parent);for(const o of r){if(o===n)break;if(o===e||VC(o,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function zC(e,t,n,r){const o=Array.isArray(e)?[]:{};for(const[l,u]of Object.entries(e))l==="parent"?o.parent=Array.isArray(n)?r:n:u&&typeof u=="object"?o[l]=zC(u,t,o,n):(l==="type"&&u==="CapturingGroup"&&t.set(o,t.get(e)??e),o[l]=u);return o}function q0(e){const t=LC(e);return t.isRecursive=!0,t}function p6(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Dm(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 HC(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(o=>{var l,u;(l=r.enable)!=null&&l[o]&&(delete n.disable[o],n.enable[o]=!0),(u=r.disable)!=null&&u[o]&&(n.disable[o]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function g6({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 UC(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function FC(e){const t=e.find(n=>n.kind==="search_start"||_6(n,{negate:!1})||!x6(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 o=FC(r.body);if(!o)return null;Array.isArray(o)?n.push(...o):n.push(o)}return n}return null}function VC(e,t){const n=UC(e)??[];for(const r of n)if(r===t||VC(r,t))return!0;return!1}function x6({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function y6(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function _6(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&jC(e.body[0],{type:"Assertion",kind:"search_start"})}function Rm(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function ms(e,t){const r=NC(e,{...t,unicodePropertyMap:_g}).body;return r.length>1||r[0].body.length>1?Lr({body:r}):r[0].body[0]}function Om(e,t){return e.negate=t,e}function Ws(e,t){return e.parent=t,e}function en(e,t){return $C(e),e.parent=t,e}function b6(e,t){const n=IC(t),r=wp(n.target,"ES2024"),o=wp(n.target,"ES2025"),l=n.rules.recursionLimit;if(!Number.isInteger(l)||l<2||l>20)throw new Error("Invalid recursionLimit; use 2-20");let u=null,c=null;if(!o){const y=[e.flags.ignoreCase];gl(e,v6,{getCurrentModI:()=>y.at(-1),popModI(){y.pop()},pushModI(w){y.push(w)},setHasCasedChar(){y.at(-1)?u=!0:c=!0}})}const d={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||u)&&!c)};let f=e;const p={accuracy:n.accuracy,appliedGlobalFlags:d,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:f,originMap:e._originMap,recursionLimit:l,useAppliedIgnoreCase:!!(!o&&u&&c),useFlagMods:o,useFlagV:r,verbose:n.verbose};function m(y){return p.lastNode=f,f=y,e6(S6[y.type],`Unexpected node type "${y.type}"`)(y,p,m)}const x={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};return r||(delete x.options.force.v,x.options.disable.v=!0,x.options.unicodeSetsPlugin=null),x._captureTransfers=new Map,x._hiddenCaptures=[],p.captureMap.forEach((y,w)=>{y.hidden&&x._hiddenCaptures.push(w),y.transferTo&&El(x._captureTransfers,y.transferTo,[]).push(w)}),x}var v6={"*":{enter({node:e},t){if(Y0(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Wu({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Y0(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){bg(mn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),GC(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&BC.has(e.value)&&t.setHasCasedChar()}},S6={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?ot`\B`:ot`\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:o,number:l}=e,u={ignoreCase:t.currentFlags.ignoreCase},c=t.originMap.get(e);return c&&(u.hidden=!0,l>c.number&&(u.transferTo=c.number)),t.captureMap.set(l,u),`(${o?`?<${o}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=mn(e),r=Aa(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&bg(n)){const o=PC(n);return t.inCharClass?o.join(""):o.length>1?`[${o.join("")}]`:o[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:o,parent:l}=e;let{body:u}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Or.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&u.some(X0)&&(u=[wd(45),...u.filter(f=>!X0(f))]);const c=()=>`[${o?"^":""}${u.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Or.bugNestedClassIgnoresNegation)&&!o){const p=u.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=Lr(),x=m.body[0];return m.parent=l,x.parent=m,u=u.filter(y=>!p.includes(y)),e.body=u,u.length?(e.parent=x,x.body.push(e)):m.body.pop(),p.forEach(y=>{const w=$i({body:[y]});y.parent=w,w.parent=m,m.body.push(w)}),n(m)}}t.inCharClass=!0;const f=c();return t.inCharClass=!1,f}const d=u[0];if(r==="union"&&!o&&d&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(Or.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&l.kind==="intersection"&&u.length===1&&d.type!=="CharacterClassRange"))return u.map(n).join("");if(!t.useFlagV&&l.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return c()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,o={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=Aa(n,o),u=Aa(r,o),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=GC(e);j6(d).forEach(p=>{c.add(Array.isArray(p)?`${Aa(p[0],o)}-${Aa(p[1],o)}`:Aa(p,o))})}return`${l}-${u}${[...c].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},o){if(e==="dot")return o.currentFlags.dotAll?o.appliedGlobalFlags.dotAll||o.useFlagMods?".":"[^]":ot`[^\n]`;if(e==="digit")return t?ot`\D`:ot`\d`;if(e==="property"){if(o.useAppliedIgnoreCase&&o.currentFlags.ignoreCase&&BC.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?ot`\P`:ot`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?ot`\W`:ot`\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},o,l){const u=o.currentFlags;n&&(o.currentFlags=Wu(u,n));const c=t.map(l).join("|"),d=!o.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!o.useFlagMods||!n)?c:`(?${N6(e,n,o.useFlagMods)}${c})`;return o.currentFlags=u,d},LookaroundAssertion({body:e,kind:t,negate:n},r,o){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(o).join("|")})`},Quantifier(e,t,n){return n(e.body)+T6(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})`:ot`\g<${t}&R=${r}>`}},w6=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),C6=new Set(["-","\\","]","^","["]),k6=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),K0=new Map([[9,ot`\t`],[10,ot`\n`],[11,ot`\v`],[12,ot`\f`],[13,ot`\r`],[8232,ot`\u2028`],[8233,ot`\u2029`],[65279,ot`\uFEFF`]]),E6=new RegExp("^\\p{Cased}$","u");function bg(e){return E6.test(e)}function GC(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,o=e.max.value,l=[];if(r<65&&(o===65535||o>=131071)||r===65536&&o>=131071)return l;for(let u=r;u<=o;u++){const c=mn(u);if(!bg(c))continue;const d=PC(c).filter(f=>{const p=f.codePointAt(0);return p<r||p>o});if(d.length&&(l.push(...d),n))break}return l}function Aa(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(K0.has(e))return K0.get(e);if(e<32||e>126&&e<160||e>262143||t&&A6(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const o=n?r?k6:C6:w6,l=mn(e);return(o.has(l)?"\\":"")+l}function j6(e){const t=e.map(o=>o.codePointAt(0)).sort((o,l)=>o-l),n=[];let r=null;for(let o=0;o<t.length;o++)t[o+1]===t[o]+1?r??(r=t[o]):r===null?n.push(t[o]):(n.push([r,t[o]]),r=null);return n}function N6(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:o,disable:l}=t;r=(o!=null&&o.ignoreCase?"i":"")+(o!=null&&o.dotAll?"s":"")+(l?"-":"")+(l!=null&&l.ignoreCase?"i":"")+(l!=null&&l.dotAll?"s":"")}return`${r}:`}function T6({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 Y0({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function A6(e){return e>47&&e<58}function X0({type:e,value:t}){return e==="Character"&&t===45}var qs,xs,Oi,Ks,Mi,jl,Cp,Zs,L6=(Zs=class extends RegExp{constructor(n,r,o){var t=(...sH)=>(super(...sH),vi(this,jl),vi(this,qs,new Map),vi(this,xs,null),vi(this,Oi),vi(this,Ks,null),vi(this,Mi,null),_e(this,"rawOptions",{}),this);const l=!!(o!=null&&o.lazyCompile);if(n instanceof RegExp){if(o)throw new Error("Cannot provide options when copying a regexp");const u=n;t(u,r),Nr(this,Oi,u.source),u instanceof Zs&&(Nr(this,qs,Rn(u,qs)),Nr(this,Ks,Rn(u,Ks)),Nr(this,Mi,Rn(u,Mi)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...o};t(l?"":n,r),Nr(this,Oi,n),Nr(this,qs,R6(u.hiddenCaptures,u.transfers)),Nr(this,Mi,u.strategy),this.rawOptions=o??{}}l||Nr(this,xs,this)}get source(){return Rn(this,Oi)||"(?:)"}exec(n){if(!Rn(this,xs)){const{lazyCompile:l,...u}=this.rawOptions;Nr(this,xs,new Zs(Rn(this,Oi),this.flags,u))}const r=this.global||this.sticky,o=this.lastIndex;if(Rn(this,Mi)==="clip_search"&&r&&o){this.lastIndex=0;const l=$f(this,jl,Cp).call(this,n.slice(o));return l&&(D6(l,o,n,this.hasIndices),this.lastIndex+=o),l}return $f(this,jl,Cp).call(this,n)}},qs=new WeakMap,xs=new WeakMap,Oi=new WeakMap,Ks=new WeakMap,Mi=new WeakMap,jl=new WeakSet,Cp=function(n){Rn(this,xs).lastIndex=this.lastIndex;const r=gb(Zs.prototype,this,"exec").call(Rn(this,xs),n);if(this.lastIndex=Rn(this,xs).lastIndex,!r||!Rn(this,qs).size)return r;const o=[...r];r.length=1;let l;this.hasIndices&&(l=[...r.indices],r.indices.length=1);const u=[0];for(let c=1;c<o.length;c++){const{hidden:d,transferTo:f}=Rn(this,qs).get(c)??{};if(d?u.push(null):(u.push(r.length),r.push(o[c]),this.hasIndices&&r.indices.push(l[c])),f&&o[c]!==void 0){const p=u[f];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=o[c],this.hasIndices&&(r.indices[p]=l[c]),r.groups){Rn(this,Ks)||Nr(this,Ks,O6(this.source));const m=Rn(this,Ks).get(f);m&&(r.groups[m]=o[c],this.hasIndices&&(r.indices.groups[m]=l[c]))}}}return r},Zs);function D6(e,t,n,r){if(e.index+=t,e.input=n,r){const o=e.indices;for(let u=0;u<o.length;u++){const c=o[u];c&&(o[u]=[c[0]+t,c[1]+t])}const l=o.groups;l&&Object.keys(l).forEach(u=>{const c=l[u];c&&(l[u]=[c[0]+t,c[1]+t])})}}function R6(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,o]of t)for(const l of o)El(n,l,{}).transferTo=r;return n}function O6(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,o=0,l;for(;l=t.exec(e);){const{0:u,groups:{capture:c,name:d}}=l;u==="["?r++:r?u==="]"&&r--:c&&(o++,d&&n.set(o,d))}return n}function M6(e,t){const n=I6(e,t);return n.options?new L6(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function I6(e,t){const n=IC(t),r=NC(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:_g}),o=c6(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=b6(o,n),u=JP(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=XP(u.pattern),d=YP(c.pattern,{captureTransfers:u.captureTransfers,hiddenCaptures:u.hiddenCaptures}),f={pattern:d.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${l.flags}${l.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=d.hiddenCaptures.sort((w,C)=>w-C),m=Array.from(d.captureTransfers),x=o._strategy,y=f.pattern.length>=n.lazyCompileLength;(p.length||m.length||x||y)&&(f.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...x&&{strategy:x},...y&&{lazyCompile:y}})}return f}function WC(e,t){return M6(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function P6(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>WC(n,{target:t.target})),{createScanner(n){return new ZI(n,t)},createString(n){return{content:n}}}}ww(rg({bundledLanguages:()=>md,bundledLanguagesAlias:()=>ig,bundledLanguagesBase:()=>sg,bundledLanguagesInfo:()=>fd,bundledThemes:()=>og,bundledThemesInfo:()=>ag,codeToHast:()=>gC,codeToHtml:()=>pC,codeToTokens:()=>xC,codeToTokensBase:()=>yC,codeToTokensWithThemes:()=>_C,createHighlighter:()=>Sd,createJavaScriptRegexEngine:()=>P6,createOnigurumaEngine:()=>Ew,defaultJavaScriptRegexConstructor:()=>WC,getLastGrammarState:()=>vC,getSingletonHighlighter:()=>bC,loadWasm:()=>cg}),JI);let Mm=null;const xl=new Set,gu=new Map,Q0=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],B6=["github-dark-default","vitesse-light","monokai","dracula","nord"],$6={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord"};function z6(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function qC(){return Mm||(Mm=Sd({themes:B6,langs:Q0}).then(e=>(Q0.forEach(t=>xl.add(t)),e))),Mm}async function H6(e){if(xl.has(e))return;if(gu.has(e))return gu.get(e);const t=(async()=>{const n=await qC(),r=md[e];if(r){await n.loadLanguage(r),xl.add(e);return}try{const o=await Z(()=>import(`shiki/langs/${e}.mjs`),[]);o.default&&(await n.loadLanguage(o.default),xl.add(e))}catch(o){console.warn(`Failed to load language ${e}:`,o)}})();gu.set(e,t),await t,gu.delete(e)}const rl=new Map,U6=50;function F6(e,t,n){return`${e}|${t}|${n}`}async function KC(e,t,n="github-dark-default"){t!=="text"&&!xl.has(t)&&await H6(t);const r=F6(e,t,n),o=rl.get(r);if(o)return o;const u=(await qC()).codeToHtml(e,{lang:t,theme:n,transformers:[z6()]});if(rl.size>=U6){const c=rl.keys().next().value;c&&rl.delete(c)}return rl.set(r,u),u}const V6={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 jd(e){var o;if(!e)return"text";const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(o=t.split(".").pop())==null?void 0:o.toLowerCase();return r?V6[r]??"text":"text"}function YC(){const e=Yt(n=>n.currentPreset);return Yt(n=>n.isCustom)?"github-dark-default":$6[e]??"github-dark-default"}function XC(e=2e3){const[t,n]=A.useState(!1),r=A.useCallback(async o=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(o);else{const l=document.createElement("textarea");l.value=o,l.style.position="fixed",l.style.left="-9999px",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}n(!0),setTimeout(()=>n(!1),e)}catch(l){console.error("Failed to copy:",l)}},[e]);return{copied:t,copy:r}}const G6=A.memo(function({language:t,codeString:n,showSyntaxHighlighting:r}){const{copied:o,copy:l}=XC(),[u,c]=A.useState(null),d=YC(),f=A.useRef(n);return A.useEffect(()=>{r&&(f.current=n,KC(n,t,d).then(p=>{f.current===n&&c(p)}))},[n,t,d,r]),a.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[a.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:[a.jsx("span",{children:t}),a.jsx("button",{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),l(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:o?a.jsx(Wr,{}):a.jsx(Ap,{})})]}),r&&u?a.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):a.jsx("div",{className:"overflow-x-auto",children:a.jsx("pre",{className:"my-0 px-4 py-3 overflow-x-auto font-mono text-sm whitespace-pre-wrap break-word",children:a.jsx("code",{className:`language-${t}`,children:n})})})]})});function W6(e,t){const n=e?"text-text-muted":"text-sky-400",r=e?"text-text-secondary":"text-amber-400";return{code({className:o,children:l,...u}){const c=/language-(\w+)/.exec(o||"");if(!c&&!String(l).includes(`
|
|
276
|
+
`)){const m=e?"text-text-muted":"text-accent-secondary";return a.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${m} font-mono text-xs`,...u,children:l})}const f=(c==null?void 0:c[1])||"text",p=String(l).replace(/\n$/,"");return a.jsx(G6,{language:f,codeString:p,showSyntaxHighlighting:t})},p({children:o}){const l=e?"text-text-muted":"text-text-primary";return a.jsx("p",{className:`${l} mb-1.5 last:mb-0 leading-tight break-words`,children:o})},ul({children:o}){return a.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:o})},ol({children:o}){return a.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:o})},li({children:o}){const l=e?"text-text-muted":"text-text-primary";return a.jsx("li",{className:`${l} text-sm list-item`,children:o})},h1({children:o}){return a.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:o})},h2({children:o}){return a.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:o})},h3({children:o}){return a.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:o})},h4({children:o}){return a.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:o})},strong({children:o}){return a.jsx("strong",{className:`font-bold ${r}`,children:o})},em({children:o}){return a.jsx("em",{className:e?"italic text-text-secondary":"italic",children:o})},a({href:o,children:l}){return a.jsx("a",{href:o,className:"text-accent-primary hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:l})},blockquote({children:o}){const l=e?"text-text-muted":"text-text-secondary";return a.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${l} italic text-sm`,children:o})},table({children:o}){return a.jsx("div",{className:"overflow-x-auto my-1.5",children:a.jsx("table",{className:"min-w-full border border-border",children:o})})},th({children:o}){return a.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 a.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:o})},hr(){return a.jsx("hr",{className:"border-border my-2"})},input({checked:o,...l}){return a.jsx("input",{type:"checkbox",checked:o,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...l})}}}const Vn=A.memo(function({content:t,className:n="",muted:r=!1}){const{showSyntaxHighlighting:o}=zi(),l=A.useMemo(()=>{let c=q6(t);return c=K6(c),c},[t]),u=A.useMemo(()=>W6(r,o),[r,o]);return a.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:a.jsx(g3,{remarkPlugins:[TO],components:u,children:l})})});function q6(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 K6(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const o=e.lastIndexOf("```");return e.slice(o+3).includes(`
|
|
277
|
+
`),e+"\n```"}return e}const Y6=A.memo(function({content:t,variant:n="default"}){return n==="labeled"?a.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[a.jsx("span",{className:"text-purple-400",children:"thinking:"}),a.jsx("div",{className:"ml-1.5 mt-0.5 overflow-x-auto",children:a.jsx(Vn,{content:t})})]}):a.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item overflow-x-auto",children:a.jsx(Vn,{content:t,muted:!0})})});function QC({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?a.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"?a.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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==="worktree"?a.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):a.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}function X6({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return a.jsx(n,{className:"language-",children:a.jsx("code",{className:"language-",children:e})})}const Wa=A.memo(function({code:t,language:n,variant:r,showLineNumbers:o=!1,startLine:l=1}){const{showSyntaxHighlighting:u}=zi(),[c,d]=A.useState(null),f=YC(),p=A.useRef(t);if(A.useEffect(()=>{u&&(p.current=t,KC(t,n,f).then(x=>{p.current===t&&d(x)}))},[t,n,f,u]),!u||!c)return a.jsx(X6,{code:t,variant:r});if(r==="inline")return a.jsx("span",{dangerouslySetInnerHTML:{__html:c}});const m=o?"":"shiki-plain";return a.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:c}})});function JC({src:e,alt:t,isOpen:n,onClose:r}){return n?a.jsx(Ot,{isOpen:n,onClose:r,title:"",size:"full",children:a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const qu=A.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",o=t==="removed"?"line-through decoration-red-400/30":"";return a.jsx("div",{className:`border-l-[3px] ${r}`,children:a.jsx("div",{className:`min-w-0 py-3 ${o}`,children:a.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),Q6=A.memo(function({oldString:t,newString:n,filePath:r}){const o=A.useMemo(()=>jd(r),[r]),l=t.length>0,u=n.length>0;return!l&&!u?a.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):a.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[l&&a.jsx(qu,{type:"removed",children:a.jsx(Wa,{code:t,language:o,variant:"block",showLineNumbers:!0})}),u&&a.jsx(qu,{type:"added",children:a.jsx(Wa,{code:n,language:o,variant:"block",showLineNumbers:!0})})]})}),J6=A.memo(function({content:t,filePath:n}){const r=A.useMemo(()=>jd(n),[n]);return a.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:a.jsx(qu,{type:"added",children:a.jsx(Wa,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),Z6=A.memo(function({regions:t,filePath:n}){const r=A.useMemo(()=>jd(n),[n]);return t.length===0?a.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):a.jsx("div",{className:"space-y-2",children:t.map((o,l)=>a.jsx(tB,{region:o,language:r},l))})});function eB(e){const t=[];function n(r,o,l){const u=t[t.length-1];u&&u.type===r&&u.startLine+u.lines.length===o?u.lines.push(l):t.push({type:r,startLine:o,lines:[l]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const o=r.oldContent.split(`
|
|
278
|
+
`);for(let u=0;u<o.length;u++)n("removed",r.startLine+u,o[u]);const l=r.newContent.split(`
|
|
279
|
+
`);for(let u=0;u<l.length;u++)n("added",r.startLine+u,l[u])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const tB=A.memo(function({region:t,language:n}){const r=eB(t);return a.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((o,l)=>a.jsx(nB,{section:o,language:n},l))})}),nB=A.memo(function({section:t,language:n}){const r=t.lines.join(`
|
|
280
|
+
`);return t.type==="context"?a.jsx("div",{children:a.jsx("div",{className:"min-w-0 py-3",children:a.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:a.jsx(Wa,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):a.jsx(qu,{type:t.type,children:a.jsx(Wa,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function J0(e){return e.split(`
|
|
281
|
+
`).filter(t=>!t.startsWith(`
|
|
282
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
|
|
283
|
+
`)}const rB=A.memo(function({result:t,metadata:n,filePath:r,heightExpanded:o=!1}){const[l,u]=A.useState(!1),c=A.useMemo(()=>jd(r),[r]),d=n==null?void 0:n.mimeType,f=n==null?void 0:n.base64Data;if(d!=null&&d.startsWith("image/")&&f){const C=`data:${d};base64,${f}`;return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`rounded overflow-hidden border border-border ${o?"":"max-h-[45vh]"} flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors`,onClick:()=>u(!0),children:a.jsx("img",{src:C,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),a.jsx(JC,{src:C,alt:r,isOpen:l,onClose:()=>u(!1)})]})}if(!t)return a.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const p=t;if(c==="markdown"){const C=J0(p);return a.jsx("div",{className:`rounded overflow-hidden border border-border ${o?"":"max-h-[45vh]"} overflow-y-auto p-2`,children:a.jsx(Vn,{content:C})})}const m=J0(p),x=p.split(`
|
|
284
|
+
`)[0],y=x==null?void 0:x.match(/^(\d+)\|/),w=y?parseInt(y[1],10):1;return a.jsx("div",{className:`rounded overflow-hidden border border-border ${o?"":"max-h-[45vh]"} overflow-y-auto`,children:a.jsx(Wa,{code:m,language:c,variant:"block",showLineNumbers:!0,startLine:w})})}),sB={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"}},Z0=A.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(l=>l.severity==="error"),r=t.filter(l=>l.severity==="warning"),o=t.filter(l=>l.severity==="info"||l.severity==="hint");return a.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[a.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[a.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&a.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&a.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),o.length>0&&a.jsxs("span",{className:"text-xs text-text-muted",children:[o.length," info"]})]}),a.jsx("div",{className:"max-h-48 overflow-y-auto",children:t.map((l,u)=>{const c=sB[l.severity];return a.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${c.bg} border-b border-border last:border-b-0`,children:[a.jsx("span",{className:`${c.color} text-xs flex-shrink-0 w-4 text-center`,children:c.icon}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",l.range.start.line+1,":",l.range.start.character+1]}),l.code&&a.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",l.code,"]"]})]}),a.jsx("div",{className:"text-xs text-text-primary break-words",children:l.message})]})]},u)})})]})}),iB=A.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:o,status:l,result:u,error:c,durationMs:d}){const f=A.useRef(null),[p,m]=A.useState(0);A.useEffect(()=>{f.current&&l==="pending"&&(f.current.scrollTop=f.current.scrollHeight)},[o,l]),A.useEffect(()=>{if(l!=="pending"||!r)return;const C=setInterval(()=>{m(Date.now()-r)},100);return()=>clearInterval(C)},[l,r]);const x=n/1e3,y=l==="pending"?p/1e3:(d??0)/1e3,w=l==="pending"?(o==null?void 0:o.map(C=>C.content).join(""))??"":u??"";return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[a.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),a.jsx("code",{className:"text-text-primary break-all",children:t})]}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[l==="pending"&&a.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),l==="interrupted"&&a.jsx("span",{className:"text-red-400",children:"interrupted"}),a.jsxs("span",{className:l==="pending"?"text-text-secondary":"text-text-muted",children:[y.toFixed(1),"s / ",x,"s"]})]})]}),l==="pending"&&a.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:a.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(w||l==="pending")&&a.jsx("pre",{ref:f,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&o?o.map((C,v)=>a.jsx("span",{className:C.stream==="stderr"?"text-accent-warning":"",children:Lu(C.content)},v)):Lu(w)}),l==="error"&&c&&a.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:c}),l!=="pending"&&d!==void 0&&a.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",(d/1e3).toFixed(2),"s"]})]})}),sl=A.memo(function({className:t=""}){return a.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})}),aB=A.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return console.warn("DevServerView: failed to parse result JSON",t.slice(0,200)),a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}return n==="logs"?oB(r):lB(r)});function oB(e){if(!e.logs)return a.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
|
|
285
|
+
`);return a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] overflow-y-auto break-words",children:t.map((n,r)=>{const o=n.startsWith("[stderr] ");return a.jsx("div",{className:o?"text-accent-warning":"",children:o?n.slice(9):n},r)})}),e.hasMore&&a.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function lB(e){const t=String(e.state??""),n=String(e.url??""),r=e.error?String(e.error):void 0,o=t==="running"?"text-accent-success":t==="stopped"?"text-text-muted":t==="error"?"text-accent-error":"text-text-muted";return a.jsxs("div",{className:"space-y-2 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"State:"}),a.jsx("span",{className:`font-medium ${o}`,children:t})]}),n&&n!=="undefined"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"URL:"}),a.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&a.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const cB=A.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return console.warn("BackgroundProcessView: failed to parse result JSON",t.slice(0,200)),a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}return n==="logs"?uB(r):n==="list"?dB(r):n==="status"?hB(r):n==="start"||n==="stop"?fB(r):a.jsxs("div",{className:"space-y-2 text-xs",children:[a.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})]})});function uB(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?a.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] overflow-y-auto break-words",children:t.map((o,l)=>a.jsx("div",{className:o.stream==="stderr"?"text-accent-warning":"",children:o.content},l))}),n&&r!=null&&a.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function dB(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?a.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):a.jsxs("div",{className:"space-y-2",children:[t.map(o=>a.jsx(ZC,{process:o},o.id)),n!=null&&r!=null&&a.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function hB(e){const t=e.process,n=e.uptime;return t?a.jsxs("div",{className:"space-y-2",children:[a.jsx(ZC,{process:t}),n!=null&&a.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",mB(n)]})]}):a.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function fB(e){const t=e.processId,n=e.name,r=e.pid,o=e.status,l=o==="running"?"text-accent-success":"text-text-muted";return a.jsxs("div",{className:"space-y-2 text-xs",children:[n&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"Name:"}),a.jsx("span",{className:"font-medium",children:n})]}),t&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"ID:"}),a.jsx("span",{className:"font-mono",children:t})]}),r!=null&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"PID:"}),a.jsx("span",{className:"font-mono",children:r})]}),o&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"Status:"}),a.jsx("span",{className:`font-medium ${l}`,children:o})]})]})}function ZC({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return a.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"font-medium",children:e.name}),a.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&a.jsxs("div",{className:"text-text-muted",children:["PID: ",a.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&a.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function mB(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 pB=A.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}switch(n){case"list_branches":return gB(r);case"status":return xB(r);case"create":case"attach":case"close":return yB(r);default:return a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}});function gB(e){const t=e.branches??[];return t.length===0?a.jsx("div",{className:"text-xs text-text-muted italic",children:"No branches found"}):a.jsxs("div",{className:"space-y-1 text-xs",children:[a.jsx("div",{className:"text-text-muted mb-1",children:"Local branches:"}),t.map(n=>a.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[a.jsx("span",{className:n.current?"text-accent-success":"text-text-muted",children:n.current?"●":"○"}),a.jsx("span",{className:n.current?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.current&&a.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function xB(e){return a.jsxs("div",{className:"space-y-2 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"Worktree active:"}),a.jsx("span",{className:e.active?"text-accent-success font-medium":"text-text-muted",children:e.active?"Yes":"No"})]}),e.active&&e.worktree&&a.jsxs(a.Fragment,{children:[a.jsx(Ku,{label:"Path",value:e.worktree,mono:!0}),e.branch&&a.jsx(Ku,{label:"Branch",value:e.branch,mono:!0})]}),!e.active&&a.jsx("div",{className:"text-text-muted italic",children:"Session is using the project root directory."}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-text-muted",children:"Project root:"}),a.jsx("span",{className:"font-mono text-text-secondary",children:e.workdir})]})]})}function Ku({label:e,value:t,mono:n}){return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"text-text-muted",children:[e,":"]}),a.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function yB(e){return a.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&a.jsx("div",{className:"text-text-primary",children:e.message}),e.worktree&&a.jsx(Ku,{label:"Worktree",value:e.worktree,mono:!0}),e.branch&&a.jsx(Ku,{label:"Branch",value:e.branch,mono:!0})]})}function _B(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 bB({confirmation:e}){const t=Le(m=>m.confirmPath),n=Le(m=>m.currentSession),r=Le(m=>m.switchDangerLevel),{title:o,description:l}=_B(e.reason),u=e.reason==="sensitive_file"||e.reason==="both",c=u?"border-red-500/50":"border-amber-500/50",d=u?"bg-red-500/10":"bg-amber-500/10",f=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return a.jsxs("div",{className:`border ${c} ${d} rounded p-3 my-2`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Vm,{}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:o}),a.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),a.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[a.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),a.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:a.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,x)=>a.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:m},x))})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),a.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),a.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${f?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function vB(e,t){if(e==="read_file"){const r=String(t.path??""),o=t.offset,l=t.limit,u=[];return o!==void 0&&o!==1&&u.push(`offset=${o}`),l!==void 0&&u.push(`limit=${l}`),u.length>0?`${r} [${u.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}if(e==="call_sub_agent")return String(t.subAgentType??"");if(e==="load_skill")return String(t.skillId??"");if(e==="web_fetch")return String(t.url??"");if(e==="web_search"){const r=String(t.query??"");return r.length>60?r.slice(0,57)+"...":r}if(e==="dev_server")return String(t.action??"");if(e==="background_process"){const r=String(t.action??""),o=t.name?String(t.name):"";return o?`${r}: ${o}`:r}if(e==="mcp_config")return String(t.action??"");const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function eS(e,t,n){var o;const r=vB(e,t);if(e==="read_file"&&n){const l=n.format,u=n.pageCount;if(l==="pdf"&&u!=null)return`${r} (PDF, ${u}p)`;if(l==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const l=n.contentType;if(l){const u=((o=l.split(";")[0])==null?void 0:o.trim())??"";if(u&&u!=="text/html")return`${r} (${u})`}}return r}function SB(e){return JSON.stringify(e,null,2)}const wB={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-red-400",animate:!1}},CB=A.memo(function({tool:t,args:n,status:r,variant:o="compact",forceCompact:l,result:u,error:c,durationMs:d,diagnostics:f,editContext:p,startedAt:m,streamingOutput:x,metadata:y,truncated:w,callId:C}){var L;const v=!l,[S,b]=A.useState(v),_=wB[r],j=tn(O=>O.settings[Ie.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",E=t==="edit_file"?(L=p==null?void 0:p.regions[0])==null?void 0:L.startLine:t==="read_file"?(()=>{const O=u==null?void 0:u.split(`
|
|
286
|
+
`)[0],P=O==null?void 0:O.match(/^(\d+): /);return P?parseInt(P[1],10):void 0})():void 0,T=Le(O=>O.pendingPathConfirmations),D=r==="pending"&&C?T.find(O=>O.callId===C)??null:null;return o==="compact"?a.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary rounded px-2 py-1.5",children:[a.jsx(QC,{tool:t}),a.jsx("span",{className:"text-accent-primary font-medium",children:t}),a.jsx("span",{className:"text-text-muted truncate flex-1",children:eS(t,n,y)}),a.jsx("span",{className:`${_.color} ${_.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):a.jsxs("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0",children:[a.jsxs("button",{className:"w-full flex items-center gap-1.5 p-2 bg-secondary hover:bg-secondary/80 text-left",onClick:()=>b(!S),children:[a.jsx("span",{className:`${_.color} ${_.animate?"animate-pulse":""}`,children:_.icon}),a.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),a.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:eS(t,n,y)}),a.jsx("span",{className:"text-text-muted text-xs",children:S?"▼":"▶"})]}),D&&a.jsx(bB,{confirmation:D}),S&&a.jsxs("div",{className:"p-2 bg-primary border-t border-border space-y-2 min-w-0",children:[t==="run_command"&&a.jsx(iB,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:x,status:r,result:u,error:c,durationMs:d}),t==="edit_file"&&r==="success"&&a.jsxs(a.Fragment,{children:[p&&p.regions.length>0?a.jsx(Z6,{regions:p.regions,filePath:String(n.path??"")}):a.jsx(Q6,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),f&&f.length>0&&a.jsx(Z0,{diagnostics:f})]}),t==="write_file"&&r==="success"&&a.jsxs(a.Fragment,{children:[a.jsx(J6,{content:String(n.content??""),filePath:String(n.path??"")}),f&&f.length>0&&a.jsx(Z0,{diagnostics:f})]}),t==="read_file"&&r==="success"&&a.jsx(rB,{result:u,metadata:y,filePath:String(n.path??""),heightExpanded:S}),t==="return_value"&&(()=>{const O=(x==null?void 0:x.map(q=>q.content).join(""))??"",P=r==="pending"&&O?O:String(n.content??"");return a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),a.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:a.jsx(Vn,{content:P})})]})})(),t==="call_sub_agent"&&a.jsxs("div",{children:[a.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),a.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:a.jsx(Vn,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&a.jsxs("div",{children:[a.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:a.jsx(Vn,{content:u??""})}),w&&a.jsx(sl,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&a.jsxs("div",{children:[a.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),a.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:a.jsx(Vn,{content:u??""})}),w&&a.jsx(sl,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&a.jsxs("div",{className:"space-y-2",children:[!!(y!=null&&y.url)&&a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[a.jsx("span",{children:"Source:"}),a.jsx("a",{href:String(y.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(y.url)}),!!(y!=null&&y.contentType)&&a.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(y.contentType),")"]}),(y==null?void 0:y.pageCount)!=null&&a.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(y.pageCount)," pages"]})]}),a.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:a.jsx(Vn,{content:u??""})}),w&&a.jsx(sl,{})]}),t==="dev_server"&&r==="success"&&u&&a.jsx(aB,{result:u,action:String(n.action??"")}),t==="worktree"&&r==="success"&&u&&a.jsx(pB,{result:u,action:String(n.action??"")}),t==="background_process"&&r==="success"&&u&&a.jsx(cB,{result:u,action:String(n.action??"")}),t==="mcp_config"&&r==="success"&&a.jsxs("div",{children:[a.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:a.jsx(Vn,{content:u??""})}),w&&a.jsx(sl,{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!=="worktree"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&a.jsxs(a.Fragment,{children:[Object.keys(n).length>0&&a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto break-words",children:SB(n)})]}),r==="success"&&u!==void 0&&a.jsxs("div",{children:[a.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}ms)`,":"]}),a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:u||"No output"}),w&&a.jsx(sl,{className:"mt-1"})]})]}),r==="success"&&(t==="edit_file"||t==="write_file"||t==="read_file")&&d!==void 0&&a.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[a.jsxs("span",{children:["Completed in ",d,"ms"]}),j&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((y==null?void 0:y.path)??n.path??"")&&a.jsx("a",{href:`vscode://file/${String((y==null?void 0:y.path)??n.path)}${E?`:${E}`:""}`,className:"text-accent-primary hover:underline ml-auto",children:"Open in VSCode"})]}),r==="error"&&c&&t!=="run_command"&&a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),a.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:c})]})]})]})}),kB={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"},EB={criteria:"criteria",review_findings:"review findings",todos:"tasks"};function jB(e,t){const n=kB[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const o=JSON.parse(t).key;if(o){const l=EB[o]??o;return`${n} ${l}`}}catch{}return n}function NB(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 TB=A.memo(function({name:t,arguments:n}){let o=jB(t,n)+"...";if(t==="run_command"&&n){const l=NB(n);l&&(o=l)}return a.jsx("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0 animate-pulse",children:a.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-bg-tertiary",children:[a.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),a.jsx(QC,{tool:t}),a.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?a.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:o}):a.jsx("span",{className:"text-text-muted text-xs flex-1",children:o})]})})}),AB={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},LB=A.memo(function({todos:t}){return Array.isArray(t)?t.length===0?a.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):a.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[a.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:a.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),a.jsx("div",{children:t.map((n,r)=>{const o=AB[n.status];return a.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[a.jsx("span",{className:`${(o==null?void 0:o.color)??"text-text-muted"} ${o!=null&&o.animate?"animate-pulse":""} text-sm leading-tight`,children:(o==null?void 0:o.icon)??"○"}),a.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):a.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function DB({toolCall:e}){var j;const t=Le(E=>E.pendingQuestions),n=Le(E=>E.answerQuestion),[r,o]=A.useState(""),l=A.useRef(null),u=A.useRef(null),c=t.find(E=>E.callId===e.id),d=e.arguments.question??(c==null?void 0:c.question)??"",f=e.arguments.type??(c==null?void 0:c.type)??"text",p=e.arguments.options??(c==null?void 0:c.options)??void 0,m=e.result!==void 0,x=c!==void 0&&!m,y=((j=e.result)==null?void 0:j.output)??"",w=y==="[user skipped]";A.useEffect(()=>{x&&l.current&&l.current.focus()},[x]),A.useEffect(()=>{x&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const C=A.useCallback(()=>{c&&n(c.callId,r)},[c,r,n]),v=A.useCallback(()=>{c&&n(c.callId,"",!0)},[c,n]),S=A.useCallback(E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),C()),E.key==="Escape"&&!E.shiftKey&&(E.preventDefault(),v())},[C,v]),b=A.useCallback(E=>{c&&n(c.callId,E)},[c,n]),_="px-3 py-1.5 text-xs font-medium rounded transition-colors";return a.jsxs("div",{ref:u,className:"my-1",children:[a.jsx("div",{className:"text-sm text-text-primary",children:d}),x&&a.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:a.jsx("div",{className:"p-3 bg-primary space-y-2",children:f==="confirm"?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>b("yes"),className:`${_} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),a.jsx("button",{onClick:()=>b("no"),className:`${_} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),a.jsx("button",{onClick:v,className:`${_} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):f==="choice"&&p&&p.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-col gap-1.5",children:p.map(E=>a.jsx("button",{onClick:()=>b(E),className:`${_} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:E},E))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("textarea",{ref:l,value:r,onChange:E=>o(E.target.value),onKeyDown:S,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),a.jsx("button",{onClick:C,disabled:!r.trim(),className:`${_} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),a.jsx("button",{onClick:v,className:`${_} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("textarea",{ref:l,value:r,onChange:E=>o(E.target.value),onKeyDown:S,placeholder:"Type your answer here... (Enter to submit, Shift+Enter for new line)",className:"w-full min-h-[80px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:!0}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:v,className:`${_} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),a.jsx("button",{onClick:C,disabled:!r.trim(),className:`${_} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),m&&a.jsx("div",{className:"mt-1 flex items-center gap-2",children:a.jsx("span",{className:`text-xs ${w?"text-amber-400":"text-accent-success"}`,children:w?"Skipped":`Answered: ${y}`})})]})}const tS={add:{icon:"○",color:"text-text-muted"},update:{icon:"○",color:"text-text-muted"},remove:{icon:"○",color:"text-text-muted"},complete:{icon:"◉",color:"text-purple-400"},pass:{icon:"✓",color:"text-accent-success"},fail:{icon:"✗",color:"text-accent-error"},get:{icon:"○",color:"text-text-muted"},list:{icon:"○",color:"text-text-muted"},schema:{icon:"○",color:"text-text-muted"}},RB=A.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(d=>[d.id,d]))??[]),o=t.find(d=>{var f,p;return d.arguments.action==="get"&&((f=d.result)==null?void 0:f.success)&&((p=d.result)==null?void 0:p.output)}),l=t.some(d=>d.name==="session_metadata"),u={criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"},c=(()=>{if(!l)return"Acceptance Criteria";const d=new Set(t.map(f=>f.arguments.key).filter(Boolean));if(d.size===1){const f=d.values().next().value;return f?u[f]??f:"Session Data"}return"Session Data"})();return a.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[a.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:a.jsx("span",{className:"text-xs font-medium text-text-muted",children:c})}),a.jsx("div",{className:"bg-primary",children:o?(()=>{const d=o.result.output;if(d==="No criteria defined yet.")return a.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[a.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),a.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(d).map((p,m)=>a.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${m>0?"border-t border-border":""}`,children:[a.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx(Vn,{content:`[${p.id}] ${p.description}`})})]},p.id??m))}catch{return t.map((f,p)=>a.jsx(nS,{tc:f,index:p,criteriaMap:r},f.id??p))}})():t.map((d,f)=>a.jsx(nS,{tc:d,index:f,criteriaMap:r},d.id??f))})]})});function nS({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,o=e.arguments,l=e.name==="session_metadata",u=r==="remove",c=o.id,d=o.description,f=c?n.get(c):void 0,p=d??(f==null?void 0:f.description)??(u&&c?`[${c}]`:"Criterion updated"),m=o.reason,x=r==="fail";return a.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l?a.jsx(ad,{status:o.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const y=r&&tS[r]?tS[r]:{icon:"○",color:"text-text-muted"};return a.jsx("span",{className:`${y.color} text-sm leading-tight flex-shrink-0`,children:y.icon})})(),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:u?"line-through text-text-muted":"",children:a.jsx(Vn,{content:p})}),m&&a.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[a.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function OB(e){return e==="criterion"||e==="session_metadata"}function MB(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const o of e)o.type==="tool_call"&&OB(o.toolCall.name)?n.push(o.toolCall):(r(),t.push(o));return r(),t}function IB(e,t){if(e.segments&&e.segments.length>0)return PB(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 PB(e,t,n,r,o){const l=[],u=new Map(t.map(c=>[c.id,c]));for(const c of e)switch(c.type){case"text":l.push({type:"text",content:c.content});break;case"thinking":c.content&&c.content.trim().length>0&&l.push({type:"thinking",content:c.content});break;case"tool_call":{const d=u.get(c.toolCallId);d&&l.push({type:"tool_call",toolCall:d});break}}for(const c of n)l.push({type:"preparing_tool_call",preparing:c});return o&&r&&l.push({type:"stats",stats:r}),l}const vg=A.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:o=!0}){const l=Le(x=>{var y,w;return(w=(y=x.currentSession)==null?void 0:y.metadataEntries)==null?void 0:w.criteria}),u=wt(x=>x.defaults),c=wt(x=>x.userItems),d=[...u,...c],f=IB(t,n),p=r?f:f.filter(x=>x.type!=="thinking"),m=MB(p);return m.length===0?null:a.jsx("div",{className:"feed-item",children:a.jsxs("div",{className:"min-w-0",children:[m.map((x,y)=>{var w;switch(x.type){case"thinking":return a.jsx(Y6,{content:x.content},y);case"text":return a.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:a.jsx(Vn,{content:x.content})},y);case"preparing_tool_call":return a.jsx(TB,{name:x.preparing.name,arguments:x.preparing.arguments},`preparing-${x.preparing.index}`);case"tool_call":{const C=x.toolCall,v=C.result;if(C.name==="ask_user")return a.jsx(DB,{toolCall:C},y);if(C.name==="todo_write"){const _=C.arguments.todos,j=Array.isArray(_)?_:[];return a.jsx(LB,{todos:j},y)}const S=(w=v==null?void 0:v.output)==null?void 0:w.includes("[interrupted by user]"),b=v?S?"interrupted":v.success?"success":"error":"pending";return a.jsx(CB,{tool:C.name,args:C.arguments,status:b,variant:"expandable",forceCompact:!o,result:v==null?void 0:v.output,error:v==null?void 0:v.error,durationMs:v==null?void 0:v.durationMs,diagnostics:v==null?void 0:v.diagnostics,editContext:v==null?void 0:v.editContext,startedAt:C.startedAt,streamingOutput:C.streamingOutput,metadata:v==null?void 0:v.metadata,truncated:(v==null?void 0:v.truncated)??!1,callId:C.id},y)}case"criteria_group":return a.jsx(RB,{toolCalls:x.toolCalls,criteria:l},y);case"stats":{const C=x.stats;if(!C||"error"in C)return null;const v=C.model.split("/").pop()??C.model,S=_l(d,C.mode),b=j=>j>=1e3?`${(j/1e3).toFixed(1)}k`:j.toString(),_=j=>j>=1e3?`${(j/1e3).toFixed(1)}k`:j.toFixed(1);return a.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[a.jsx("span",{className:"flex-1 h-px bg-border"}),a.jsx("span",{className:"text-text-secondary",children:v}),a.jsx("span",{className:"text-text-muted",children:"·"}),a.jsx("span",{style:{color:S},children:C.mode}),a.jsx("span",{className:"text-text-muted",children:"·"}),a.jsxs("span",{children:[C.totalTime.toFixed(1),"s"]}),C.toolTime>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-muted",children:"·"}),a.jsxs("span",{children:[C.toolTime.toFixed(1),"s tools"]})]}),a.jsx("span",{className:"text-text-muted",children:"·"}),a.jsxs("span",{children:[b(C.prefillTokens)," @ ",_(C.prefillSpeed)," pp"]}),a.jsx("span",{className:"text-text-muted",children:"·"}),a.jsxs("span",{children:[b(C.generationTokens)," @ ",_(C.generationSpeed)," tg"]}),a.jsx("span",{className:"text-text-muted",children:"·"}),a.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const j=new CustomEvent("open-turn-stats",{detail:{stats:C}});window.dispatchEvent(j)},children:a.jsx(MS,{className:"w-3 h-3"})}),a.jsx("span",{className:"flex-1 h-px bg-border"})]},y)}}}),t.partial&&a.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[a.jsx(Vm,{}),a.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&a.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-amber-400/80 mt-1",children:[a.jsx(Vm,{}),a.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function Yu(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${o},${t})`}function BB(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),n=Math.round(e%60);return n>0?`${t}m ${n}s`:`${t}m`}function $B(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const zB=A.memo(function({data:t}){var u;const n=Rt(c=>c.defaults),r=Rt(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#8b949e";return a.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:Yu(l,.3),backgroundColor:Yu(l,.08)},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(iN,{color:l}),a.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName??"Task Completed"})]}),a.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[a.jsx(il,{label:"Iterations",value:String(t.iterations)}),a.jsx(il,{label:"Total time",value:BB(t.totalTimeSeconds)}),a.jsx(il,{label:"Tool calls",value:String(t.totalToolCalls)}),a.jsx(il,{label:"Tokens",value:$B(t.totalTokensGenerated)}),a.jsx(il,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function il({label:e,value:t}){return a.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[a.jsx("div",{className:"text-sm text-text-muted",children:e}),a.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const HB=A.memo(function({data:t}){var u;const n=Rt(c=>c.defaults),r=Rt(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#6b7280";return a.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:Yu(l,.3),backgroundColor:Yu(l,.08)},children:[a.jsx(tN,{className:"w-3 h-3 shrink-0",color:l}),a.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName}),a.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function UB({attachments:e,messageId:t}){const[n,r]=A.useState(null),o=Le(p=>p.visionFallbackByMessage),l=Le(p=>p.messages),u=A.useMemo(()=>{const p=l.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<l.length;m++){const x=l[m];if(x&&x.role==="assistant")return x.id}return null},[l,t]),c=p=>{r(p)},d=()=>{r(null)},f=p=>{const m=`${t}-${p}`;if(o[m])return o[m];if(u){const x=`${u}-${p}`;return o[x]}return null};return e.length===0?null:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=f(p.id);return a.jsxs("div",{className:"relative inline-block",children:[a.jsxs("button",{onClick:()=>c(p.data),className:"group relative inline-block",title:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,disabled:(m==null?void 0:m.type)==="start",children:[a.jsx("img",{src:p.data,alt:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(m==null?void 0:m.type)==="start"&&a.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:a.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&a.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[m.description.slice(0,200),m.description.length>200?"...":""]})]},p.id)})}),n&&a.jsx(JC,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function FB({content:e,align:t="right",messageId:n,sessionId:r}){const[o,l]=A.useState(!1),[u,c]=A.useState(!1),[d,f]=A.useState("left"),p=A.useRef(null),m=A.useRef(null),x=Le(S=>S.loadSession),y=t==="right",w=()=>{if(!m.current)return"left";const S=m.current.getBoundingClientRect(),b=window.innerWidth-S.right,_=S.left,j=160,E=b>=j,T=_>=j;return T&&E||T?"left":E?"right":_>=b?"left":"right"};A.useEffect(()=>{const S=b=>{p.current&&!p.current.contains(b.target)&&l(!1)};return o&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[o]);const C=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(e);else{const S=document.createElement("textarea");S.value=e,S.style.position="fixed",S.style.left="-999999px",document.body.appendChild(S),S.select(),document.execCommand("copy"),document.body.removeChild(S)}c(!0),l(!1),window.setTimeout(()=>c(!1),1500)}catch(S){console.error("Failed to copy:",S)}},v=async()=>{!r||!n||(l(!1),await V2(r,n),x(r))};return a.jsx(a.Fragment,{children:a.jsxs("div",{className:`flex items-start gap-1.5 ${y?"":"order-first"}`,children:[u&&a.jsx(Wr,{className:"w-4 h-4 text-accent-success"}),a.jsxs("div",{ref:p,className:"relative",children:[a.jsx("button",{ref:m,onClick:()=>{o||f(w()),l(!o)},className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",title:"Message options",children:a.jsx(Lp,{})}),o&&a.jsxs("div",{className:`absolute top-full mt-1 bg-bg-secondary border border-border rounded shadow-xl z-50 py-1 min-w-36 ${d==="right"?"left-0":"right-0"}`,children:[a.jsxs("button",{onClick:C,className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[a.jsx(Ap,{className:"w-4 h-4"}),"Copy"]}),r&&n&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"border-t border-border my-1"}),a.jsxs("button",{onClick:v,className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[a.jsx(Dp,{className:"w-4 h-4"}),"Replay"]})]})]})]})]})})}function VB({message:e}){const[t,n]=A.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,o=(r==null?void 0:r.color)??"#6b7280",l=(r==null?void 0:r.name)??"Agent",u=(r==null?void 0:r.type)??"agent",d={agent:(r==null?void 0:r.kind)==="reminder"?"reminder":"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions",worktree:(r==null?void 0:r.kind)==="reminder"?`${(r==null?void 0:r.branchName)??""} (closed)`:`${(r==null?void 0:r.branchName)??""} (open)`}[u]??"injected",f=u==="workflow"||u==="subagent";return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[a.jsx("span",{className:"flex-1 h-px bg-border"}),a.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${f?"":"cursor-pointer"}`,style:{backgroundColor:o},onClick:()=>!f&&n(!0)}),a.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:o},onClick:()=>!f&&n(!0),children:l}),a.jsx("span",{children:"·"}),a.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!f&&n(!0),children:d}),a.jsx("span",{className:"flex-1 h-px bg-border"})]}),f&&a.jsx("div",{className:"flex justify-center feed-item mb-4",children:a.jsx("div",{className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm overflow-x-auto",style:{borderLeft:`3px solid ${o}`},children:a.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),a.jsx(Ot,{isOpen:t,onClose:()=>n(!1),title:`${l} Prompt`,size:"lg",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:o}}),a.jsx("span",{className:"text-sm text-text-primary font-medium",children:l}),a.jsxs("span",{className:"text-xs text-text-muted",children:["(",u,")"]})]}),a.jsx("div",{className:"h-full min-h-96",children:a.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap break-words bg-bg-tertiary rounded p-4 h-full min-h-96 overflow-auto font-mono",children:e.content})})]})})]})}function GB({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",o=e.messageKind==="command",l=e.isSystemGenerated;return a.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",children:[!l&&a.jsx(FB,{content:e.content,align:"right",messageId:t,sessionId:n}),a.jsxs("div",{className:`max-w-[75%] rounded p-2 ${l?o?"bg-teal-500/10 border border-teal-500/30":r?"bg-slate-500/10 border border-slate-500/30":"bg-amber-500/10 border border-amber-500/30":"bg-accent-primary/15 text-text-primary"}`,children:[l&&a.jsx("span",{className:`text-[10px] block mb-0.5 ${o?"text-teal-400":r?"text-slate-400":"text-amber-400"}`,children:o?"Command":r?"Auto":"System"}),a.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${l?`${o?"text-teal-200":r?"text-slate-200":"text-amber-200 italic"}`:""}`,children:e.content}),e.attachments&&e.attachments.length>0&&a.jsx(UB,{attachments:e.attachments,messageId:e.id})]})]})}const ek=A.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:o}){const l=t.role==="user",u=t.role==="assistant",c=t.role==="system",d=t.role==="tool";if(u)return a.jsx(vg,{message:t,showStats:n});if(c&&t.isCompacted)return a.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[a.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),a.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
|
|
287
|
+
`,"")})]});if(d)return a.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[a.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),a.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap break-words overflow-x-auto max-h-32",children:[t.content.slice(0,500),t.content.length>500&&"..."]})]});if(t.messageKind==="workflow-started")try{const f=JSON.parse(t.content);return a.jsx(HB,{data:f})}catch{}if(t.messageKind==="task-completed")try{const f=JSON.parse(t.content);return a.jsx(zB,{data:f})}catch{}return t.messageKind==="context-reset"?a.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[a.jsx("div",{className:"flex-1 border-t border-border"}),a.jsx("span",{children:t.content}),a.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?a.jsx(VB,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?a.jsx("div",{className:"flex justify-end feed-item",children:a.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-amber-500/10 border border-amber-500/30",children:[a.jsx("span",{className:"text-[10px] block mb-0.5 text-amber-400",children:"System"}),a.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-amber-200 italic",children:t.content})]})}):l?a.jsx(GB,{message:t,messageId:r,sessionId:o}):a.jsx("div",{className:"flex justify-start feed-item",children:a.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:a.jsx(Vn,{content:t.content})})})}),WB={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function qB(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function rS(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function KB({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:o}=e,l=Math.round(t/n*100);return a.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[a.jsxs("span",{className:rS(l,o),children:[Tu(t),"/",Tu(n)]}),a.jsxs("span",{className:rS(l,o),children:["(",l,"%)"]}),a.jsx(y1,{percent:l,dangerZone:o,size:"sm"}),o&&a.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&a.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const YB=A.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:o}){const l=A.useRef(null),u=A.useRef(null),[c,d]=A.useState(!1),f=wt(D=>D.defaults),p=wt(D=>D.userItems),m=[...f,...p],x=Le(D=>D.subAgentContextStates[r]),{showThinking:y,showVerboseToolOutput:w}=zi(),{isAutoScrollActive:C,setAutoScroll:v}=od(u,null),S=A.useCallback(()=>{const D=!c;d(D),D&&setTimeout(()=>{var L;(L=l.current)==null||L.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),b=m.find(D=>D.id===n),_=(b==null?void 0:b.name)??WB[n]??n,j=_l(m,n),E=qB(j),T=t.filter(D=>D.role!=="tool");return a.jsxs("div",{ref:l,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[a.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:E,children:[a.jsx("span",{className:"text-xs font-medium",children:_}),a.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:x&&a.jsx(KB,{contextState:x})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>v(!C),children:[a.jsx("span",{className:`w-1 h-1 rounded-full ${C?"bg-accent-success":"border border-text-muted"}`}),"live"]}),a.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:S,children:[c?"▼":"▶"," Expand"]})]})]}),a.jsx("div",{ref:u,className:`${c?"max-h-[calc(100vh-10rem)]":"max-h-80"} overflow-y-auto p-2 transition-[max-height] duration-200`,children:T.map(D=>D.role==="assistant"?a.jsx(vg,{message:D,showStats:!0,showThinking:y,showVerboseToolOutput:w},D.id):a.jsx(ek,{message:D,isLastAssistantMessage:!1},D.id))})]})});function xu(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 tk=A.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,showThinking:o=!0,showVerboseToolOutput:l=!0,showStats:u=!0,showAgentDefinitions:c=!0,showWorkflowBars:d=!0}){return a.jsx(a.Fragment,{children:t.map((f,p)=>{if(f.type==="context-divider")return a.jsxs("div",{"data-item-index":p,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[a.jsx("div",{className:"flex-1 border-t border-border"}),a.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),a.jsx("div",{className:"flex-1 border-t border-border"})]},xu(f));if(f.type==="subagent"){const w=f.messages.some(C=>C.isStreaming);return a.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",children:a.jsx(YB,{messages:f.messages,subAgentType:f.subAgentType,subAgentId:f.subAgentId,isStreaming:w})},xu(f))}const m=f.message;if(m.role==="assistant")return a.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",children:a.jsx(vg,{message:m,showStats:u,showThinking:o,showVerboseToolOutput:l})},xu(f));const x=!c&&m.messageKind==="auto-prompt",y=!d&&(m.messageKind==="workflow-started"||m.messageKind==="task-completed");return x||y?null:a.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",children:a.jsx("div",{"data-message-id":m.id,className:n===m.id?"rounded animate-highlight-fade":void 0,children:a.jsx(ek,{message:m,messageId:m.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},xu(f))})})});function nk(e,t,n=!0){A.useEffect(()=>{if(!n)return;const r=o=>{var l;(l=e.current)!=null&&l.contains(o.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const XB=[],QB=A.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:o,hiddenCount:l=0}){const u=Le(H=>{var V,U;return((U=(V=H.currentSession)==null?void 0:V.metadataEntries)==null?void 0:U.criteria)??XB}),c=Le(H=>{var V;return(V=H.currentSession)==null?void 0:V.id}),d=Le(H=>{var V;return(V=H.currentSession)==null?void 0:V.mode}),f=Le(H=>{var V;return(V=H.currentSession)==null?void 0:V.phase}),p=Le(H=>H.error),m=Le(H=>H.clearError),x=ed(),{showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S}=zi(),b=Rt(H=>H.defaults),_=Rt(H=>H.userItems),j=[...b,..._],E=d==="planner",T=u.length>0,D=f==="done",L=t.some(H=>H.type==="message"&&H.message.role==="assistant"),O=E&&T&&!x&&L&&!D,P=Le(H=>{var V;return(V=H.currentSession)==null?void 0:V.projectId}),[q,W]=A.useState(!1),M=()=>{if(!P||!c)return;W(!1),window.open(`/p/${P}/s/${c}/readonly`,"_blank")||W(!0)};return a.jsxs("div",{ref:n,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto relative bg-primary",children:[a.jsxs("div",{className:"pt-4",children:[l>0&&a.jsxs("div",{className:"px-2 md:px-4 pb-2 space-y-1",children:[a.jsxs("button",{onClick:M,className:"w-full text-sm text-text-muted hover:text-text-primary bg-bg-tertiary/50 hover:bg-bg-tertiary border border-border rounded px-3 py-2 transition-colors text-center",children:[l," older item",l!==1?"s":""," hidden — View full history"]}),q&&a.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",a.jsx("a",{href:P&&c?`/p/${P}/s/${c}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),a.jsx(tk,{displayItems:t,highlightedMessageId:r,sessionId:c,showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S})]}),a.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[p&&a.jsx("div",{className:"feed-item bg-red-500/10 border border-red-500/50 rounded p-2",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-red-400 text-sm font-medium",children:p.code}),a.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:p.message})]}),a.jsx(Dl,{onClick:m,className:"text-red-400 hover:text-red-300 p-0.5",size:"sm"})]})}),O&&a.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:j.map(H=>{const V=H.color??"#3b82f6",U=parseInt(V.slice(1,3),16),Q=parseInt(V.slice(3,5),16),X=parseInt(V.slice(5,7),16),z=`rgba(${U},${Q},${X},0.12)`,R=`rgba(${U},${Q},${X},0.22)`,I=`rgba(${U},${Q},${X},0.25)`;return a.jsx(JB,{workflowName:H.name,color:V,bg:z,bgHover:R,border:I,subGroups:H.subGroups,onLaunch:G=>o(H.id,G)},H.id)})})]})]})});function JB({workflowName:e,color:t,bg:n,bgHover:r,border:o,subGroups:l,onLaunch:u}){const[c,d]=A.useState(!1),f=A.useRef(null);return nk(f,()=>d(!1),c),a.jsxs("div",{className:"relative flex",children:[a.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:"px-4 py-1.5 rounded-l text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${o}`,borderRight:"none"},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=r},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),l&&l.length>0&&a.jsxs("div",{ref:f,className:"relative",children:[a.jsx("button",{onClick:()=>d(!c),className:"px-1.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${o}`},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=r},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:"⋮"}),c&&a.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:[a.jsx("button",{onClick:()=>{u(),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),a.jsx("div",{className:"border-t border-border/50"}),l.map(p=>a.jsx("button",{onClick:()=>{u(p),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:p},p))]})]})]})}function ZB(){const e=Le(r=>r.connectionStatus),t=Le(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return a.jsxs("div",{className:`
|
|
288
|
+
flex items-center justify-between px-4 py-2
|
|
289
|
+
text-sm font-medium
|
|
290
|
+
${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"}
|
|
291
|
+
`,children:[a.jsx("div",{className:"flex items-center gap-2",children:n?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),a.jsx("span",{children:"Reconnecting to server..."})]}):a.jsxs(a.Fragment,{children:[a.jsx(oN,{}),a.jsx("span",{children:"Connection lost"})]})}),a.jsx("button",{onClick:()=>t(),disabled:n,className:`
|
|
292
|
+
px-3 py-1 rounded text-xs font-medium
|
|
293
|
+
transition-colors
|
|
294
|
+
${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"}
|
|
295
|
+
`,children:n?"Reconnecting...":"Reconnect"})]})}const dn=qn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await p1("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await ke(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const o=await ei("POST","/api/commands",{...n,destination:r});return o.success&&await t().fetchCommands(),o},updateCommand:async(n,r)=>{const o=await ei("PUT",`/api/commands/${n}`,r);return o.success&&await t().fetchCommands(),o},deleteCommand:async n=>{try{const r=await ke(`/api/commands/${n}`,{method:"DELETE"}),o=await r.json();return r.ok?(e(l=>({userItems:l.userItems.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)=>Zu(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function e8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function t8({onClick:e}){return a.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:a.jsx(Eu,{})})}function rk({isOpen:e,onClose:t,initialEditId:n}){const r=dn(se=>se.defaults),o=dn(se=>se.userItems),l=dn(se=>se.projectItems),u=dn(se=>se.loading),c=dn(se=>se.fetchCommands),d=dn(se=>se.fetchCommand),f=dn(se=>se.fetchDefaultContent),p=dn(se=>se.createCommand),m=dn(se=>se.updateCommand),x=dn(se=>se.deleteCommand),[y,w]=A.useState(null),[C,v]=A.useState(null),{view:S,editingId:b,formError:_,saving:j,formData:E,setView:T,setEditingId:D,setFormError:L,setFormData:O,setSaving:P}=YS(),{requestDelete:q,clearConfirm:W,isConfirming:M}=nd(),H=A.useRef(!1),V=wt(se=>se.defaults),U=wt(se=>se.userItems),Q=wt(se=>se.fetchAgents),z=[...V,...U].filter(se=>!se.subagent),R=A.useRef(c),I=A.useRef(Q),G=A.useRef(d),B=A.useRef(f),ee=A.useRef(n),J=A.useRef(T),ne=A.useRef(D),K=A.useRef(L),F=A.useRef(W);A.useEffect(()=>{R.current=c,I.current=Q,G.current=d,B.current=f,ee.current=n,J.current=T,ne.current=D,K.current=L,F.current=W}),A.useEffect(()=>{if(e)if(R.current(),I.current(),H.current||(F.current(),H.current=!0),ee.current){const se=r.some(xe=>xe.id===ee.current);J.current("edit"),ne.current(ee.current),K.current(""),se?B.current(ee.current).then(xe=>{xe&&O({name:xe.metadata.name+" (copy)",id:`${ee.current}-copy-${Date.now()}`,prompt:xe.prompt,agentMode:xe.metadata.agentMode??"",isDefault:!0,destination:"user"})}):G.current(ee.current).then(xe=>{xe&&O({name:xe.metadata.name,id:xe.metadata.id,prompt:xe.prompt,agentMode:xe.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else J.current("list"),ne.current(null);else H.current=!1},[e]);const te=async se=>{w(se);const xe=await f(se);v((xe==null?void 0:xe.prompt)??null)},re=async se=>{if(r.some(Ve=>Ve.id===se)){const Ve=await f(se);Ve&&(D(null),O({name:`${Ve.metadata.name} (copy)`,id:`${se}-copy-${Date.now()}`,prompt:Ve.prompt,agentMode:Ve.metadata.agentMode??"",isDefault:!0,destination:"user"}),L(""),T("edit"))}else{const Ve=await d(se);Ve&&(D(null),O({name:`${Ve.metadata.name} (copy)`,id:`${se}-copy-${Date.now()}`,prompt:Ve.prompt,agentMode:Ve.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))}},pe=()=>{O({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),D(null),T("edit")},be=async se=>{const xe=await d(se);xe&&(D(se),O({name:xe.metadata.name,id:xe.metadata.id,prompt:xe.prompt,agentMode:xe.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))},Pe=async se=>{await x(se),W()},$e=async()=>{const se=b??E.id;if(!se||!E.name||!E.prompt){L("Name and message are required.");return}P(!0),L("");const xe={metadata:{id:se,name:E.name,...E.agentMode?{agentMode:E.agentMode}:{}},prompt:E.prompt},Ve=b?await m(b,xe):await p(xe,E.destination);if(P(!1),!Ve.success){L(Ve.error??"Failed to save command.");return}n?t():T("list")},Ne=()=>{n?t():(T("list"),w(null),v(null))},je=se=>{O(xe=>({...xe,name:se})),(!b||E.isDefault)&&O(xe=>({...xe,id:e8(se)}))},oe=()=>{w(null),v(null),T("list")},Be=()=>{y&&(w(null),T("edit"),D(y),f(y).then(se=>{se&&O({name:`${se.metadata.name} (copy)`,id:`${y}-copy-${Date.now()}`,prompt:se.prompt,agentMode:se.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(y){const se=r.find(xe=>xe.id===y);return a.jsx(Ot,{isOpen:e,onClose:oe,title:`Default: ${(se==null?void 0:se.name)??y}`,size:"xl",children:a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"space-y-3 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),a.jsx("span",{className:"font-mono",children:y})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),a.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:se==null?void 0:se.name})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),a.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(se==null?void 0:se.agentMode)||"None"})]})]}),a.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),a.jsx("textarea",{value:C??"",readOnly:!0,placeholder:"...",className:"flex-1 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none opacity-60"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[a.jsx(rt,{variant:"secondary",onClick:oe,children:"Close"}),a.jsx(rt,{variant:"primary",onClick:Be,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return a.jsx(Ot,{isOpen:e,onClose:Ne,title:b?"Edit Command":"New Command",size:"xl",children:a.jsxs("div",{className:"flex flex-col h-full",children:[_&&a.jsx(rd,{message:_}),a.jsxs("div",{className:"space-y-3 mb-3",children:[a.jsx(KS,{name:E.name,id:E.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!b&&!E.isDefault,onNameChange:je,onIdChange:se=>O(xe=>({...xe,id:se}))}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",a.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),a.jsxs("select",{value:E.agentMode,onChange:se=>O(xe=>({...xe,agentMode:se.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:[a.jsx("option",{value:"",children:"None (keep current mode)"}),z.map(se=>a.jsx("option",{value:se.id,children:se.name},se.id))]})]}),!b&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),a.jsxs("select",{value:E.destination,onChange:se=>O(xe=>({...xe,destination:se.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:[a.jsx("option",{value:"user",children:"Global config"}),a.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})]}),a.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),a.jsx("textarea",{value:E.prompt,onChange:se=>O(xe=>({...xe,prompt:se.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"})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[a.jsx(rt,{variant:"secondary",onClick:Ne,children:"Cancel"}),a.jsx(rt,{variant:"primary",onClick:$e,disabled:j||!E.name||!E.prompt,children:j?"Saving...":"Save"})]})]})});const he=se=>se.map(xe=>a.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[a.jsx("div",{className:"min-w-0 flex-1 mr-3",children:a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{className:"text-text-primary text-sm font-medium",children:xe.name})})}),a.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[a.jsx(Qs,{onClick:()=>be(xe.id)}),a.jsx(ju,{onClick:()=>re(xe.id)}),M(xe.id,"delete")?a.jsx(Mp,{onConfirm:()=>Pe(xe.id),onCancel:W}):a.jsx(Ip,{onClick:()=>q(xe.id)})]})]},xe.id));return a.jsxs(Ot,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[a.jsx(qS,{description:"Commands are pre-defined messages you can send with a single click.",onNew:pe}),a.jsxs(Pp,{loading:u,hasItems:r.length>0||o.length>0||l.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),a.jsx("div",{className:"space-y-2",children:r.map(se=>a.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[a.jsx("div",{className:"min-w-0 flex-1 mr-3",children:a.jsx("span",{className:"text-text-primary text-sm font-medium",children:se.name})}),a.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[a.jsx(t8,{onClick:()=>te(se.id)}),a.jsx(ju,{onClick:()=>re(se.id)})]})]},se.id))})]}),o.length>0&&a.jsx(WS,{children:he(o)}),l.length>0&&a.jsxs("div",{className:"mt-4",children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),a.jsx("div",{className:"space-y-2",children:he(l)})]})]})]})}const ki=150,ps=54,yu=80,Tr=30,La=70,sS=100,Ei=50,_u=50,iS=4,sk={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},ik=[{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)"}],n8=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}];function Sg(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.agentId);return{name:(n==null?void 0:n.name)??(e.agentId||"Agent"),color:(n==null?void 0:n.color)||"#3b82f6"}}if(e.type==="sub_agent"){const n=t.find(r=>r.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return{name:"Shell",color:"#22c55e"}}function r8(e,t,n,r){const o=_u+Ei+ki+sS+ki+Ei+_u,l=o/2,u=_u+Ei+ki/2,c=_u+Ei+ki+sS+ki/2,d=[],f=[],p=new Map,m=e.filter(V=>V.type==="agent"||V.type==="shell"),x=e.filter(V=>V.type==="sub_agent"),y=x.length>0,w=y?u:l,C=m.length>0?c:l,v=Ei+Tr/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:v,w:yu,h:Tr}),p.set("$start",{cx:w,cy:v,w:yu,h:Tr});const S=V=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:V,w:yu,h:Tr}),p.set("$done",{cx:w,cy:V,w:yu,h:Tr})};if(e.length===0){const V=v+Tr/2+La*2+Tr/2;return S(V),{nodes:d,edges:f,width:o,height:V+Tr/2+Ei,posMap:p}}const b=v+Tr/2+La,_=(V,U)=>{V.forEach((Q,X)=>{const z=b+X*(ps+La)+ps/2,{name:R,color:I}=Sg(Q,r);d.push({id:Q.id,type:"step",label:R,color:I,cx:U,cy:z,w:ki,h:ps}),p.set(Q.id,{cx:U,cy:z,w:ki,h:ps})})};_(m,w),_(x,C);const j=m.length>0?b+(m.length-1)*(ps+La)+ps/2:v,E=y?b+(x.length-1)*(ps+La)+ps/2:v,T=Math.max(j,E)+ps/2+La+Tr/2;S(T);const D=[];t&&p.has(t)&&D.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let L=0;for(const V of e)V.transitions.forEach((U,Q)=>{var B;if(!U.goto||!p.has(U.goto))return;const X=p.get(V.id),z=p.get(U.goto),R=U.when.type==="step_result"?`${U.when.result}`:U.when.type==="metadata_all_match"?`${U.when.key??"?"}=${U.when.value??"?"}`:U.when.type==="metadata_all_in"?`${U.when.key??"?"} in [${((B=U.when.values)==null?void 0:B.join(","))??"?"}]`:sk[U.when.type]??U.when.type,I=V.id===U.goto;let G;I?G="back":z.cy>X.cy+1?G="down":z.cy<X.cy-1?G="back":G="same",D.push({from:V.id,to:U.goto,label:R,edgeKey:`${V.id}:${Q}`,direction:G,backEdgeIndex:G==="back"?L++:0})});const O=new Map,P=new Map,q=new Map,W=new Map;for(const V of D)V.direction==="down"&&(O.set(V.from,(O.get(V.from)??0)+1),P.set(V.to,(P.get(V.to)??0)+1));const M=new Map,H=new Map;for(const V of D){if(V.direction!=="same")continue;const U=[V.from,V.to].sort().join("|");M.set(U,(M.get(U)??0)+1)}for(const V of D){if(V.direction==="back"||V.direction==="same"){let G=0;if(V.direction==="same"){const B=[V.from,V.to].sort().join("|");G=H.get(B)??0,H.set(B,G+1)}f.push({...V,fromPort:0,toPort:0,sameEdgeIndex:G});continue}const U=O.get(V.from)??1,Q=P.get(V.to)??1,X=q.get(V.from)??0,z=W.get(V.to)??0;q.set(V.from,X+1),W.set(V.to,z+1);const R=U===1?0:-.6+1.2*X/(U-1),I=Q===1?0:-.6+1.2*z/(Q-1);f.push({...V,fromPort:R,toPort:I,sameEdgeIndex:0})}return{nodes:d,edges:f,width:o,height:T+Tr/2+Ei,posMap:p}}function s8({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:o,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:d,onRemoveStep:f,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:x,onDeleteTransition:y}){const w=A.useRef(null),C=A.useRef(!1),[v,S]=A.useState(null),[b,_]=A.useState(null),[j,E]=A.useState(null),{nodes:T,edges:D,width:L,height:O,posMap:P}=A.useMemo(()=>r8(e,t,o,l),[e,t,o,l]),q=A.useCallback(J=>{var re;const ne=w.current;if(!ne)return{x:0,y:0};const K=ne.createSVGPoint();K.x=J.clientX,K.y=J.clientY;const F=(re=ne.getScreenCTM())==null?void 0:re.inverse();if(!F)return{x:0,y:0};const te=K.matrixTransform(F);return{x:te.x,y:te.y}},[]),W=A.useCallback(J=>!J||!b||J==="$start"?!1:b.type==="reconnect-from"?J!=="$done":!0,[b]),M=A.useCallback((J,ne)=>{if(u)return;J.stopPropagation(),J.preventDefault();const K=q(J);_({type:"new",fromNodeId:ne,mouseX:K.x,mouseY:K.y})},[q,u]),H=A.useCallback((J,ne)=>{if(u)return;J.stopPropagation(),J.preventDefault();const K=q(J);_({type:"reconnect-to",fromNodeId:ne.from,edgeKey:ne.edgeKey,mouseX:K.x,mouseY:K.y})},[q,u]),V=A.useCallback((J,ne)=>{if(u)return;J.stopPropagation(),J.preventDefault();const K=q(J);_({type:"reconnect-from",fromNodeId:ne.from,fixedTargetId:ne.to,edgeKey:ne.edgeKey,mouseX:K.x,mouseY:K.y})},[q,u]),U=A.useCallback(J=>{if(!b)return;const ne=q(J);_(K=>K?{...K,mouseX:ne.x,mouseY:ne.y}:null)},[b,q]),Q=A.useCallback(()=>{b&&(C.current=!0,j&&W(j)&&(b.type==="new"?p(b.fromNodeId,j):b.type==="reconnect-to"?m(b.edgeKey,j):b.type==="reconnect-from"&&x(b.edgeKey,j)),_(null),E(null))},[b,j,W,p,m,x]),X=A.useCallback(()=>{if(C.current){C.current=!1;return}c(null),d(null)},[c,d]);A.useEffect(()=>{if(u)return;const J=ne=>{ne.target instanceof HTMLInputElement||ne.target instanceof HTMLTextAreaElement||ne.target instanceof HTMLSelectElement||(ne.key==="Delete"||ne.key==="Backspace")&&r&&r!=="start"&&(ne.preventDefault(),y(r),d(null))};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[u,r,y,d]);const z=J=>{const ne=P.get(J.from),K=P.get(J.to);if(!ne||!K)return null;let F,te,re,pe="middle",be,Pe;if(J.direction==="down"){const $e=ne.cx+J.fromPort*(ne.w/2-10),Ne=ne.cy+ne.h/2,je=K.cx+J.toPort*(K.w/2-10),oe=K.cy-K.h/2,Be=oe-Ne,he=je-$e;F=`M ${$e} ${Ne} C ${$e} ${Ne+Be*.4}, ${je-he*.2} ${oe-Be*.1}, ${je} ${oe}`,te=$e+(je-$e)*.5,re=Ne+Be*.6,be={x:$e,y:Ne},Pe={x:je,y:oe}}else if(J.direction==="back"){const $e=J.from===J.to,Ne=ne.cx>=L/2,je=J.backEdgeIndex*16,oe=Ne?L-20-je:20+je;if($e){const Be=ne.cx>=L/2,he=30+J.backEdgeIndex*14,se=ne.cy-ne.h/2,xe=Be?ne.cx+ne.w/2:ne.cx-ne.w/2,Ve=Be?xe+he:xe-he,Ze=ne.cx+(Be?ne.w/4:-ne.w/4),it=se-20-J.backEdgeIndex*10;F=`M ${xe} ${ne.cy} C ${Ve} ${ne.cy}, ${Ve} ${it}, ${Ze} ${se}`,te=Ve+10,re=it+4,pe="middle",be={x:xe,y:ne.cy},Pe={x:Ze,y:se}}else{const Be=Ne?ne.cx+ne.w/2:ne.cx-ne.w/2,he=K.cx+(Ne?K.w/4:-K.w/4),se=Math.min(ne.cy,K.cy)-K.h/2-18-J.backEdgeIndex*14;F=`M ${Be} ${ne.cy} L ${oe} ${ne.cy} L ${oe} ${se} L ${he} ${se} L ${he} ${K.cy-K.h/2}`,te=oe,re=(ne.cy+se)/2,pe=Ne?"start":"end",be={x:Be,y:ne.cy},Pe={x:he,y:K.cy-K.h/2}}}else{const $e=K.cx>ne.cx,Ne=J.sameEdgeIndex===0?-12:12,je=$e?ne.cx+ne.w/2:ne.cx-ne.w/2,oe=$e?K.cx-K.w/2:K.cx+K.w/2,Be=ne.cy+Ne,he=K.cy+Ne,se=(je+oe)/2;F=`M ${je} ${Be} C ${se} ${Be}, ${se} ${he}, ${oe} ${he}`,te=se,re=(Be+he)/2-6,be={x:je,y:Be},Pe={x:oe,y:he}}return{path:F,labelX:te,labelY:re,labelAnchor:pe,fromPt:be,toPt:Pe}},R=(J,ne)=>{const K=z(J);if(!K)return null;const{path:F,labelX:te,labelY:re,labelAnchor:pe}=K,be=r===J.edgeKey,Pe=J.label&&J.label!=="otherwise";return a.jsxs("g",{children:[a.jsx("path",{d:F,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:$e=>{$e.stopPropagation(),u||d(be?null:J.edgeKey)}}),a.jsx("path",{d:F,fill:"none",stroke:be?"#58a6ff":"#484f58",strokeWidth:be?2.2:1.2,markerEnd:be?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),Pe&&a.jsx("text",{x:te+(pe==="start"?5:pe==="end"?-5:0),y:re+3,textAnchor:pe,className:"text-[8px]",fill:be?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:J.label})]},ne)},I=()=>{if(!r||b)return null;const J=D.find(re=>re.edgeKey===r);if(!J)return null;const ne=z(J);if(!ne)return null;const{fromPt:K,toPt:F}=ne,te=6;return a.jsxs(a.Fragment,{children:[J.edgeKey!=="start"&&a.jsx("circle",{cx:K.x,cy:K.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:re=>V(re,J)}),a.jsx("circle",{cx:F.x,cy:F.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:re=>H(re,J)})]})},G=()=>{if(!b)return null;let J,ne,K,F;if(b.type==="reconnect-from"){const pe=P.get(b.fixedTargetId);if(!pe)return null;J=b.mouseX,ne=b.mouseY,K=pe.cx,F=pe.cy-pe.h/2}else{const pe=P.get(b.fromNodeId);if(!pe)return null;J=pe.cx,ne=pe.cy+pe.h/2,K=b.mouseX,F=b.mouseY}const te=F-ne,re=Math.abs(te)>10?`M ${J} ${ne} C ${J} ${ne+te*.4}, ${K} ${F-te*.4}, ${K} ${F}`:`M ${J} ${ne} L ${K} ${F}`;return a.jsx("path",{d:re,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},B=J=>{const ne=J.cy+J.h/2,K=(b==null?void 0:b.fromNodeId)===J.id;return a.jsx("circle",{cx:J.cx,cy:ne,r:iS,fill:K?"#58a6ff":"#1c2128",stroke:K?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5,className:"cursor-crosshair",onMouseDown:F=>M(F,J.id)})},ee=J=>{const ne=J.cy-J.h/2,K=b&&j===J.id&&W(J.id);return a.jsx("circle",{cx:J.cx,cy:ne,r:iS,fill:K?"#3fb950":"#1c2128",stroke:K?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5})};return a.jsxs("svg",{ref:w,viewBox:`0 0 ${L} ${O}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:U,onMouseUp:Q,onClick:X,children:[a.jsxs("defs",{children:[a.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:a.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),a.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:a.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),D.map((J,ne)=>R(J,ne)),T.map(J=>{const ne=n===J.id,K=J.cx-J.w/2,F=J.cy-J.h/2,te=v===J.id,re=b&&j===J.id&&W(J.id);if(J.type==="terminal"){const be=J.id==="$start",Pe=be?"#58a6ff":"#3fb950",$e=be,Ne=!be;return a.jsxs("g",{onClick:je=>{je.stopPropagation(),be&&!u&&d("start")},className:be&&!u?"cursor-pointer":void 0,children:[re&&a.jsx("rect",{x:K-3,y:F-3,width:J.w+6,height:J.h+6,rx:J.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),be&&r==="start"&&a.jsx("rect",{x:K-3,y:F-3,width:J.w+6,height:J.h+6,rx:J.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),a.jsx("rect",{x:K,y:F,width:J.w,height:J.h,rx:J.h/2,fill:Pe,fillOpacity:.08,stroke:Pe,strokeOpacity:.4,strokeWidth:1.5}),a.jsx("text",{x:J.cx,y:J.cy+4,textAnchor:"middle",fill:Pe,className:"text-[10px] font-medium",pointerEvents:"none",children:J.label}),$e&&B(J),Ne&&ee(J)]},J.id)}const pe=J.color??"#6b7280";return a.jsxs("g",{onClick:be=>{be.stopPropagation(),u||c(ne?null:J.id)},onMouseEnter:()=>S(J.id),onMouseLeave:()=>S(null),className:u?void 0:"cursor-pointer",children:[re&&a.jsx("rect",{x:K-3,y:F-3,width:J.w+6,height:J.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ne&&a.jsx("rect",{x:K-3,y:F-3,width:J.w+6,height:J.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),a.jsx("rect",{x:K,y:F,width:J.w,height:J.h,rx:10,fill:pe,fillOpacity:.08,stroke:pe,strokeOpacity:.6,strokeWidth:ne?2:1.5}),a.jsx("text",{x:J.cx,y:J.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:J.label}),!u&&B(J),!u&&ee(J),te&&!b&&!u&&a.jsxs("g",{onClick:be=>{be.stopPropagation(),f(J.id)},className:"cursor-pointer",children:[a.jsx("circle",{cx:K+J.w-2,cy:F+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),a.jsx("line",{x1:K+J.w-5,y1:F-1,x2:K+J.w+1,y2:F+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),a.jsx("line",{x1:K+J.w+1,y1:F-1,x2:K+J.w-5,y2:F+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},J.id)}),b&&T.map(J=>W(J.id)?a.jsx("rect",{x:J.cx-J.w/2-8,y:J.cy-J.h/2-8,width:J.w+16,height:J.h+16,fill:"transparent",rx:12,onMouseEnter:()=>E(J.id),onMouseLeave:()=>E(null),onMouseUp:ne=>{ne.stopPropagation(),Q()}},`drop-${J.id}`):null),G(),I()]})}const bu="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";function i8({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:o,isReadOnly:l,onNameChange:u,onDescriptionChange:c,onMaxIterationsChange:d,onColorChange:f}){return a.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[a.jsxs("div",{className:"min-w-[140px]",children:[a.jsx("label",{className:al,children:"Name"}),a.jsx("input",{value:e,onChange:p=>u(p.target.value),placeholder:"Workflow name",className:`${bu} ${l?"opacity-50":""}`,readOnly:l})]}),a.jsxs("div",{className:"min-w-[100px]",children:[a.jsx("label",{className:al,children:"ID"}),a.jsx("input",{value:t,readOnly:!0,className:`${bu} font-mono opacity-50`})]}),a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:al,children:"Description"}),a.jsx("input",{value:n,onChange:p=>!l&&c(p.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${bu} ${l?"opacity-50":""}`})]}),a.jsxs("div",{className:"w-20",children:[a.jsx("label",{className:al,children:"Max Iter."}),a.jsx("input",{type:"number",value:r,onChange:p=>!l&&d(Number(p.target.value)),readOnly:l,className:`${bu} font-mono ${l?"opacity-50":""}`})]}),a.jsxs("div",{children:[a.jsx("label",{className:al,children:"Color"}),a.jsx("input",{type:"color",value:o,onChange:p=>!l&&f(p.target.value),disabled:l,className:`w-8 h-8 rounded border border-border bg-transparent ${l?"opacity-50":"cursor-pointer"}`})]})]})}function a8({name:e,id:t,color:n,description:r,isBuiltIn:o,actions:l}){return a.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),a.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),a.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),o&&a.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&a.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),a.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:l})]})}function aS({title:e,items:t,renderActions:n}){return t.length===0?null:a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),a.jsx("div",{className:"space-y-2",children:t.map(r=>a.jsx(a8,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const Da="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",Im="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",gs="block text-[11px] text-text-secondary mb-0.5";function Pm({variables:e,onInsert:t}){return e.length===0?null:a.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>a.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 o8({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:o,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:d,name:f}=Sg(e,n);return a.jsxs("div",{className:"space-y-3 text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:d+"20",color:d},children:f}),t&&a.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[!t&&a.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),a.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Type"}),a.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,x=m==="sub_agent"?"verification":"build";if(m==="agent"){const y=n.find(w=>!w.subagent);l({...e,type:m,phase:x,agentId:(y==null?void 0:y.id)??"builder",name:(y==null?void 0:y.name)??"Agent"})}else if(m==="sub_agent"){const y=n.find(w=>w.subagent);l({...e,type:m,phase:x,subAgentType:(y==null?void 0:y.id)??"",name:(y==null?void 0:y.name)??"Sub-Agent"})}else l({...e,type:m,phase:x,name:"Shell"})},className:Im,children:n8.map(p=>a.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Agent Type"}),a.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Im,children:n.filter(p=>!p.subagent).map(p=>a.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Sub-Agent Type"}),a.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Im,children:[a.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>a.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Prompt"}),a.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${Da} resize-y text-xs`,placeholder:"Injected on first entry..."}),a.jsx(Pm,{variables:o,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Nudge Prompt"}),a.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${Da} resize-y text-xs`,placeholder:"Injected on re-entry..."}),a.jsx(Pm,{variables:o,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Command"}),a.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${Da} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),a.jsx(Pm,{variables:o,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Timeout (ms)"}),a.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${Da} font-mono text-xs`})]}),a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Success Codes"}),a.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>l({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${Da} font-mono text-xs`})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:gs,children:"Sub-group"}),a.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Da})]}),a.jsx("div",{className:"pt-1 border-t border-border/50",children:a.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Ra="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",oS="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",ji="block text-[11px] text-text-secondary mb-0.5";function l8({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:o,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:d,onUpdateSubGroup:f,onDelete:p,onMoveUp:m,onMoveDown:x}){var C;const y=o&&(o.type==="sub_agent"||o.type==="agent")?l.find(v=>v.id===(o.type==="sub_agent"?o.subAgentType:o.agentId)):void 0,w=(y==null?void 0:y.results)&&y.results.length>0;return a.jsxs("div",{className:"space-y-3 text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",u+1]}),c>1&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:m,disabled:u===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:a.jsx(Wn,{className:"w-3 h-3",rotate:180})}),a.jsx("button",{onClick:x,disabled:u===c-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:a.jsx(Wn,{className:"w-3 h-3"})})]})]}),a.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[a.jsx("span",{className:"font-medium text-text-primary",children:e}),a.jsx(OS,{}),a.jsx("span",{className:"font-medium text-text-primary",children:t})]}),a.jsxs("div",{children:[a.jsx("label",{className:ji,children:"Condition"}),a.jsx("select",{value:n.type,onChange:v=>{d(v.target.value==="step_result"?{type:"step_result",result:"success"}:{type:v.target.value})},className:oS,children:ik.map(v=>a.jsx("option",{value:v.value,children:v.label},v.value))})]}),n.type==="step_result"&&a.jsxs("div",{children:[a.jsx("label",{className:ji,children:"Result"}),w?a.jsx("select",{value:n.result??y.results[0],onChange:v=>{d({type:"step_result",result:v.target.value})},className:oS,children:y.results.map(v=>a.jsx("option",{value:v,children:v},v))}):a.jsx("input",{type:"text",value:n.result??"success",onChange:v=>d({type:"step_result",result:v.target.value}),placeholder:"e.g. success, passed, failed",className:Ra})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:ji,children:"Metadata Key"}),a.jsx("input",{type:"text",value:n.key??"",onChange:v=>d({...n,key:v.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Ra})]}),a.jsxs("div",{children:[a.jsx("label",{className:ji,children:"Field"}),a.jsx("input",{type:"text",value:n.field??"",onChange:v=>d({...n,field:v.target.value}),placeholder:"e.g. status",className:Ra})]}),n.type==="metadata_all_match"?a.jsxs("div",{children:[a.jsx("label",{className:ji,children:"Value"}),a.jsx("input",{type:"text",value:n.value??"",onChange:v=>d({...n,value:v.target.value}),placeholder:"e.g. passed, resolved",className:Ra})]}):a.jsxs("div",{children:[a.jsx("label",{className:ji,children:"Values (comma-separated)"}),a.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:v=>d({...n,values:v.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Ra})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:ji,children:"Sub-group"}),a.jsx("input",{type:"text",value:r??"",onChange:v=>f(v.target.value||void 0),placeholder:"e.g. build, verify",className:Ra})]}),a.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function c8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function u8(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const ol="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",lS="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",Oa="block text-[11px] text-text-secondary mb-0.5",cS=[];function ak({isOpen:e,onClose:t,initialEditId:n}){var bn,Cr;const r=Rt(ve=>ve.defaults),o=Rt(ve=>ve.userItems),l=Rt(ve=>ve.loading),u=Rt(ve=>ve.templateVariables),c=Rt(ve=>ve.fetchWorkflows),d=Rt(ve=>ve.fetchWorkflow),f=Rt(ve=>ve.fetchDefaultContent),p=Rt(ve=>ve.fetchTemplateVariables),m=Rt(ve=>ve.createWorkflow),x=Rt(ve=>ve.updateWorkflow),y=Rt(ve=>ve.deleteWorkflow),{requestDelete:w,clearConfirm:C,isConfirming:v}=nd(),[S,b]=A.useState("list"),[_,j]=A.useState(null),[E,T]=A.useState(!1),[D,L]=A.useState(null),[O,P]=A.useState(null),[q,W]=A.useState(""),[M,H]=A.useState(""),[V,U]=A.useState(""),[Q,X]=A.useState("1.0.0"),[z,R]=A.useState("#3b82f6"),[I,G]=A.useState(""),[B,ee]=A.useState(50),[J,ne]=A.useState(cS),[K,F]=A.useState({type:"always"}),[te,re]=A.useState(""),[pe,be]=A.useState(!1),Pe=wt(ve=>ve.defaults),$e=wt(ve=>ve.userItems),Ne=wt(ve=>ve.projectItems),je=A.useMemo(()=>[...Pe,...$e,...Ne],[Pe,$e,Ne]),oe=wt(ve=>ve.fetchAgents),[Be]=A.useState(null);A.useEffect(()=>{e&&(c(),p(),oe(),L(null),P(null),n?r.some(we=>we.id===n)?f(n).then(we=>{we&&he({...we,metadata:{...we.metadata,name:we.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):d(n).then(we=>{we&&he(we,{editingId:n,isReadOnly:!1})}):(b("list"),j(null),T(!1)))},[e,c,d,f,p,n]);const he=(ve,we)=>{W(ve.metadata.name),H(ve.metadata.id),U(ve.metadata.description),X(ve.metadata.version),R(ve.metadata.color??"#3b82f6"),G(ve.entryStep),ee(ve.settings.maxIterations),ne(ve.steps),F(ve.startCondition??{type:"always"}),re(""),(we==null?void 0:we.editingId)!==void 0&&j(we.editingId),(we==null?void 0:we.isReadOnly)!==void 0&&T(we.isReadOnly),(we==null?void 0:we.selectedNodeKey)!==void 0&&L(null),(we==null?void 0:we.selectedEdgeKey)!==void 0&&P(null),b("edit")},se=async ve=>{const we=await d(ve);we&&he(we,{editingId:ve,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},xe=async()=>{var lt;const ve=_??M;if(!ve||!q)return re("Name is required."),!1;if(J.length===0)return re("Add at least one step."),!1;let we=I;if(!we||!J.some(nt=>nt.id===we)){if(we=((lt=J.find(nt=>nt.id))==null?void 0:lt.id)??"",!we)return re("All steps need an ID."),!1;G(we)}be(!0),re("");const ze={metadata:{id:ve,name:q,description:V,version:Q||"1.0.0",color:z},entryStep:we,settings:{maxIterations:B},steps:J,startCondition:K},qe=_?await x(_,ze):await m(ze);return be(!1),qe.success?(_||j(ve),!0):(re(qe.error??"Failed to save."),!1)},Ve=async()=>{await xe()},Ze=async()=>{await xe()&&(n?t():b("list"))},it=()=>{n?t():b("list")},Et=ve=>{W(ve),_||H(c8(ve))},ce=async ve=>r.some(ze=>ze.id===ve)?await f(ve):await d(ve),Te=async ve=>{const we=await ce(ve);we&&he(we,{editingId:ve,isReadOnly:!0})},Fe=async ve=>{const we=await ce(ve);we&&he({...we,metadata:{...we.metadata,name:we.metadata.name+" (copy)",id:`${ve}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Ye=()=>{j(null),W(""),H(""),U(""),X("1.0.0"),R("#3b82f6"),G(""),ee(50),ne(structuredClone(cS)),F({type:"always"}),re(""),L(null),P(null),T(!1),b("edit")},tt=async ve=>{await y(ve),C()},kt=A.useCallback(ve=>{L(ve),P(null)},[]),at=A.useCallback(ve=>{P(ve),L(null)},[]),me=D!==null?Number(D):-1,Oe=me>=0?J[me]??null:null,We=A.useCallback(ve=>{ne(we=>we.map((ze,qe)=>qe===me?ve:ze))},[me]),et=K.type==="step_result"?`${K.result}`:K.type==="metadata_all_match"?`${K.key??"?"}=${K.value??"?"}`:K.type==="metadata_all_in"?`${K.key??"?"} in [${((bn=K.values)==null?void 0:bn.join(","))??"?"}]`:sk[K.type]??K.type,En=()=>{const ve=J.length,we=u8(J),ze=je.find(qe=>!qe.subagent);ne([...J,{id:we,name:(ze==null?void 0:ze.name)??"Agent",type:"agent",phase:"build",agentId:(ze==null?void 0:ze.id)??"builder",transitions:[]}]),I||G(we),kt(String(ve))},Wt=A.useCallback((ve,we)=>{ve==="$start"?(G(we),at("start")):ne(ze=>{const qe=ze.find(nt=>nt.id===ve),lt=qe?qe.transitions.length:0;return at(`${ve}:${lt}`),ze.map(nt=>nt.id===ve?{...nt,transitions:[...nt.transitions,{when:{type:"always"},goto:we}]}:nt)})},[at]),Xn=ve=>{if(ve==="start")return null;const we=ve.lastIndexOf(":"),ze=ve.slice(0,we),qe=parseInt(ve.slice(we+1));return{stepId:ze,transIdx:qe}},Qn=A.useCallback((ve,we)=>{const ze=Xn(ve);ze&&ne(qe=>qe.map(lt=>lt.id===ze.stepId?{...lt,transitions:lt.transitions.map((nt,yt)=>yt===ze.transIdx?we(nt):nt)}:lt))},[]),ye=A.useCallback((ve,we)=>{if(ve==="start"){G(we);return}Qn(ve,ze=>({...ze,goto:we}))},[Qn]),He=A.useCallback((ve,we)=>{const ze=Xn(ve);ze&&(ne(qe=>{const lt=qe.find(yt=>yt.id===ze.stepId);if(!lt)return qe;const nt=lt.transitions[ze.transIdx];return nt?qe.map(yt=>yt.id===ze.stepId?{...yt,transitions:yt.transitions.filter((nn,Mt)=>Mt!==ze.transIdx)}:yt.id===we?{...yt,transitions:[...yt.transitions,nt]}:yt):qe}),P(null))},[]),Me=A.useCallback(ve=>{if(ve==="start"){G(""),P(null);return}const we=Xn(ve);we&&(ne(ze=>ze.map(qe=>qe.id===we.stepId?{...qe,transitions:qe.transitions.filter((lt,nt)=>nt!==we.transIdx)}:qe)),P(null))},[]),Ae=A.useCallback((ve,we)=>{if(ve==="start"){F(we);return}Qn(ve,ze=>({...ze,when:we}))},[Qn]),Qe=A.useCallback((ve,we)=>{ve!=="start"&&Qn(ve,ze=>({...ze,subGroup:we||void 0}))},[Qn]),Bt=ve=>Sg(ve,je).name,Mn=()=>{if(!O)return null;if(O==="start"){const nn=J.find(Mt=>Mt.id===I);return{type:"start",fromLabel:"Start",toLabel:nn?Bt(nn):"(none)",condition:K}}const ve=O.lastIndexOf(":"),we=O.slice(0,ve),ze=parseInt(O.slice(ve+1)),qe=J.find(nn=>nn.id===we);if(!qe)return null;const lt=qe.transitions[ze];if(!lt)return null;const nt=J.find(nn=>nn.id===lt.goto),yt=lt.goto==="$done"?"Done":nt?Bt(nt):lt.goto;return{type:"step",fromLabel:Bt(qe),toLabel:yt,condition:lt.when,subGroup:lt.subGroup}};if(S==="edit"){const ve=Mn();return a.jsxs(Ot,{isOpen:e,onClose:it,title:E?q:_?"Edit Workflow":"New Workflow",size:"full",children:[te&&a.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:te}),a.jsx(i8,{formName:q,formId:M,formDescription:V,formMaxIterations:B,formColor:z,isReadOnly:E,onNameChange:Et,onDescriptionChange:U,onMaxIterationsChange:ee,onColorChange:R}),a.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[a.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[a.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!E&&a.jsx("button",{onClick:En,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),a.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[a.jsx(s8,{steps:J,entryStep:I,selectedNodeId:(Oe==null?void 0:Oe.id)??null,selectedEdgeKey:O,startConditionLabel:et,agentTypes:je,isReadOnly:E,onSelectNode:we=>{if(we===null){kt(null);return}const ze=J.findIndex(qe=>qe.id===we);kt(ze>=0?String(ze):null)},onSelectEdge:at,onRemoveStep:we=>{var qe;const ze=J.findIndex(lt=>lt.id===we);if(ne(lt=>lt.filter(nt=>nt.id!==we)),me===ze&&kt(null),I===we){const lt=J.filter(nt=>nt.id!==we);G(((qe=lt[0])==null?void 0:qe.id)??"")}},onCreateTransition:Wt,onReconnectTo:ye,onReconnectFrom:He,onDeleteTransition:Me}),J.length===0&&a.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[a.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),a.jsx("button",{onClick:En,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"})]})]})]}),a.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[a.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:a.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),a.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:E&&(ve||Oe)?a.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):ve?ve.type==="start"?a.jsxs("div",{className:"space-y-3 text-sm",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),I&&a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[a.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),a.jsx(OS,{}),a.jsx("span",{className:"text-text-primary font-medium",children:ve.toLabel})]}),a.jsxs("div",{children:[a.jsx("label",{className:Oa,children:"Activation Condition"}),a.jsx("select",{value:K.type,onChange:we=>F(we.target.value==="step_result"?{type:"step_result",result:"success"}:we.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:we.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:we.target.value}),className:lS,children:ik.map(we=>a.jsx("option",{value:we.value,children:we.label},we.value))})]}),K.type==="step_result"&&a.jsxs("div",{children:[a.jsx("label",{className:Oa,children:"Result"}),I&&(()=>{const we=J.find(nt=>nt.id===I),ze=we&&(we.type==="sub_agent"||we.type==="agent")?je.find(nt=>nt.id===(we.type==="sub_agent"?we.subAgentType:we.agentId)):void 0,qe=(ze==null?void 0:ze.results)&&ze.results.length>0,lt=(ze==null?void 0:ze.results)??[];return qe?a.jsx("select",{value:K.result??lt[0],onChange:nt=>F({type:"step_result",result:nt.target.value}),className:lS,children:lt.map(nt=>a.jsx("option",{value:nt,children:nt},nt))}):a.jsx("input",{type:"text",value:K.result??"success",onChange:nt=>F({type:"step_result",result:nt.target.value}),placeholder:"e.g. success, passed, failed",className:ol})})()]}),(K.type==="metadata_all_match"||K.type==="metadata_all_in")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:Oa,children:"Metadata Key"}),a.jsx("input",{type:"text",value:K.key??"",onChange:we=>F({...K,key:we.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:ol})]}),a.jsxs("div",{children:[a.jsx("label",{className:Oa,children:"Field"}),a.jsx("input",{type:"text",value:K.field??"",onChange:we=>F({...K,field:we.target.value}),placeholder:"e.g. status",className:ol})]}),K.type==="metadata_all_match"?a.jsxs("div",{children:[a.jsx("label",{className:Oa,children:"Value"}),a.jsx("input",{type:"text",value:K.value??"",onChange:we=>F({...K,value:we.target.value}),placeholder:"e.g. passed, resolved",className:ol})]}):a.jsxs("div",{children:[a.jsx("label",{className:Oa,children:"Values (comma-separated)"}),a.jsx("input",{type:"text",value:((Cr=K.values)==null?void 0:Cr.join(", "))??"",onChange:we=>F({...K,values:we.target.value.split(",").map(ze=>ze.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:ol})]})]}),a.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 we=Xn(O),ze=we==null?void 0:we.stepId,qe=(we==null?void 0:we.transIdx)??0,lt=ze?J.find(yt=>yt.id===ze):void 0,nt=(lt==null?void 0:lt.transitions.length)??0;return a.jsx(l8,{fromLabel:ve.fromLabel,toLabel:ve.toLabel,condition:ve.condition,subGroup:"subGroup"in ve?ve.subGroup:void 0,fromStep:ve.type==="step"?J.find(yt=>yt.id===ve.fromLabel):void 0,agentTypes:je,transitionIndex:qe,totalTransitions:nt,onUpdateCondition:yt=>Ae(O,yt),onUpdateSubGroup:yt=>Qe(O,yt),onDelete:()=>Me(O),onMoveUp:()=>{ne(yt=>{const nn=yt.find(jt=>jt.id===ze);if(!nn||qe===0)return yt;const Mt=[...nn.transitions];return[Mt[qe-1],Mt[qe]]=[Mt[qe],Mt[qe-1]],yt.map(jt=>jt.id===ze?{...jt,transitions:Mt}:jt)}),P(`${ze}:${qe-1}`)},onMoveDown:()=>{ne(yt=>{const nn=yt.find(jt=>jt.id===ze);if(!nn||qe===nn.transitions.length-1)return yt;const Mt=[...nn.transitions];return[Mt[qe],Mt[qe+1]]=[Mt[qe+1],Mt[qe]],yt.map(jt=>jt.id===ze?{...jt,transitions:Mt}:jt)}),P(`${ze}:${qe+1}`)}})})():Oe?a.jsx(o8,{step:Oe,isEntry:Oe.id===I,agentTypes:je,transitionCount:Oe.transitions.length,templateVariables:u,onUpdate:We,onRemove:()=>{var we;if(Oe&&(ne(J.filter((ze,qe)=>qe!==me)),kt(null),I===Oe.id)){const ze=J.filter((qe,lt)=>lt!==me);G(((we=ze[0])==null?void 0:we.id)??"")}},onSetEntry:()=>G(Oe.id)}):a.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",a.jsx("br",{}),"Drag from a port to connect."]})})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[a.jsx(rt,{variant:"secondary",onClick:it,children:"Close"}),E?a.jsx(rt,{variant:"primary",onClick:()=>{W(q+" (copy)"),H(`${_}-copy-${Date.now()}`),j(null),T(!1)},children:"Duplicate & Customize"}):a.jsxs(a.Fragment,{children:[a.jsx(rt,{variant:"primary",onClick:Ve,children:"Save"}),a.jsx(rt,{variant:"primary",onClick:Ze,children:"Save & Close"})]})]})]})}return a.jsx(Ot,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:a.jsx(GS,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Ye,loading:l,hasItems:r.length>0||o.length>0,children:a.jsxs("div",{className:"space-y-4",children:[a.jsx(aS,{title:"Built-in",items:r,renderActions:ve=>a.jsx(a.Fragment,{children:a.jsx(Qs,{onClick:()=>Fe(ve.id),children:a.jsx(Eu,{})})})}),a.jsx(aS,{title:"Custom",items:o,renderActions:ve=>a.jsxs(a.Fragment,{children:[a.jsx(Qs,{onClick:()=>Te(ve.id),children:a.jsx(Eu,{})}),a.jsx(Qs,{onClick:()=>se(ve.id),children:a.jsx("span",{className:"text-[10px]",children:"Edit"})}),a.jsx(ju,{onClick:()=>Fe(ve.id)}),v(ve.id,"delete")?a.jsx(Mp,{onConfirm:()=>tt(ve.id),onCancel:C}):a.jsx(Ip,{onClick:()=>w(ve.id)})]})})]})})})}function d8(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function h8({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:o,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:d,isAutoScrollActive:f}){const[,p]=Gn(),m=dn(B=>B.fetchCommands),x=Rt(B=>B.fetchWorkflows),y=wt(B=>B.fetchAgents),w=dn(B=>B.defaults),C=dn(B=>B.userItems),v=dn(B=>B.projectItems),S=Rt(B=>B.defaults),b=Rt(B=>B.userItems),_=Rt(B=>B.projectItems),j=wt(B=>B.defaults),E=wt(B=>B.userItems),T=wt(B=>B.projectItems),D=Le(B=>{var ee;return(ee=B.currentSession)==null?void 0:ee.mode}),L=Le(B=>{var ee;return((ee=B.currentSession)==null?void 0:ee.dangerLevel)??"normal"}),O=Le(B=>B.switchMode),P=Le(B=>B.switchDangerLevel),q=Le(B=>{var ee;return(ee=B.currentSession)==null?void 0:ee.projectId}),W=A.useRef(void 0),[M,H]=A.useState(""),[V,U]=A.useState(0),Q=A.useRef(null),X=A.useRef(!1);A.useEffect(()=>{e&&(X.current=!0)},[e]),A.useEffect(()=>{if(e){m(),x(),y(),H(""),U(0);const B=setTimeout(()=>{var ee;return(ee=Q.current)==null?void 0:ee.focus()},50);return()=>clearTimeout(B)}},[e,m,x,y]),A.useEffect(()=>{var B;!e&&X.current&&(n==null||n(),(B=W.current)==null||B.call(W),W.current=void 0)},[e,n]);const R=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const B=q??d8(window.location.pathname);B&&p(`/p/${B}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{W.current=l,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),c==null||c()}},{id:"toggle-autoscroll",name:f?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!f)}},...Vr(Vr(j,E),T).filter(B=>!B.subagent&&B.id!==D).map(B=>({id:B.id,name:B.name,prefix:"Agent > Switch to",action:()=>O(B.id)})),...Vr(Vr(w,C),v).map(B=>({id:B.id,name:B.name,prefix:"Command > Launch",action:()=>r(B.id,u)})),...Vr(Vr(S,b),_).map(B=>({id:B.id,name:B.name,prefix:"Workflow > Run",action:()=>o(B.id)})),...["normal","dangerous"].filter(B=>B!==L).map(B=>({id:B,name:B.charAt(0).toUpperCase()+B.slice(1),prefix:"Mode > Switch to",action:()=>P(B)}))].filter(B=>za(`${B.prefix} ${B.name}`,M)),I=R.length-1,G=B=>{d1(B,I,U,()=>{var ee;(ee=R[V])==null||ee.action(),t()},t)};return e?Qa.createPortal(a.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),a.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[a.jsx("input",{ref:Q,type:"text",value:M,onChange:B=>{H(B.target.value),U(0)},onKeyDown:G,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),a.jsx(Op,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),a.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:R.length===0?a.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+b.length>0?"No matches":"No agents, commands, or workflows yet"}):R.map((B,ee)=>a.jsxs("button",{type:"button",onClick:()=>{B.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${ee===V?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[a.jsxs("span",{className:"text-text-muted font-normal",children:[B.prefix," "]}),a.jsx("span",{children:B.name})]},B.id))})]})]}),document.body):null}const ok="openfox-message-search-filters",f8=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function m8(){try{const e=localStorage.getItem(ok);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function p8(e){localStorage.setItem(ok,JSON.stringify([...e]))}function g8(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 x8(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 o=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0"),c=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${o}/${l}/${u} ${c}:${d}`}function y8(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 _8(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const o=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!o?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function b8(e){var n,r;if(e.type!=="message")return a.jsx(Xb,{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())?a.jsx(cN,{className:"w-3.5 h-3.5"}):a.jsx(Xb,{className:"w-3.5 h-3.5"}):a.jsx(lN,{className:"w-3.5 h-3.5"})}function uS(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",o=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 o?o.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const l=o.slice(0,200);return l.length<o.length?`${l}...`:l}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function v8({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[o,l]=A.useState(""),[u,c]=A.useState(0),[d,f]=A.useState(m8),p=A.useRef(null),m=A.useRef(null),x=A.useRef(null),y=E=>{f(T=>{const D=new Set(T);return D.has(E)?D.delete(E):D.add(E),p8(D),D})},w=A.useMemo(()=>n.filter(E=>{var T,D;return!(E.type==="context-divider"||E.type==="message"&&(E.message.messageKind==="auto-prompt"||E.message.role==="assistant"&&!((T=E.message.content)!=null&&T.trim())&&!((D=E.message.thinkingContent)!=null&&D.trim())))}),[n]),C=A.useMemo(()=>w.filter(E=>{const T=g8(E);return!(T&&!d.has(T))}),[w,d]),v=A.useMemo(()=>o?w.filter(E=>{const T=uS(E);return za(T,o)}):C,[C,o]),S=v.length-1;A.useEffect(()=>{if(e){l(""),c(0);const E=setTimeout(()=>{var T;return(T=p.current)==null?void 0:T.focus()},50);return()=>clearTimeout(E)}},[e]),A.useEffect(()=>{e&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[e]),A.useEffect(()=>{x.current&&x.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[u]);const b=E=>{d1(E,S,c,()=>{const T=v[u];if(T){const D=n.indexOf(T);D>=0&&r(D),t()}},t)},_=E=>{const T=n.indexOf(E);T>=0&&r(T),t()},j=E=>n.indexOf(E);return e?Qa.createPortal(a.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),a.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[a.jsx(yl,{}),a.jsx("input",{ref:p,type:"text",value:o,onChange:E=>{l(E.target.value),c(0)},onKeyDown:b,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),a.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:a.jsx(Xa,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:f8.map(E=>{const T=d.has(E.key);return a.jsx("button",{type:"button",onClick:()=>y(E.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${T?"bg-accent-primary/20 text-accent-primary border border-accent-primary/40":"bg-bg-tertiary text-text-muted border border-border hover:text-text-secondary"}`,children:E.label},E.key)})}),a.jsx("div",{ref:m,className:"overflow-y-auto max-h-[60vh] p-2",children:v.length===0?a.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,T)=>{const D=j(E),L=b8(E),O=uS(E),P=_8(E),q=y8(E),W=E.type==="message"&&E.message.role==="user";return a.jsx("button",{ref:T===u?x:null,type:"button",onClick:()=>_(E),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${T===u?"bg-accent-primary/20 text-text-primary":W?"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:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[a.jsx("span",{className:"flex-shrink-0",children:L}),a.jsx("span",{className:`truncate flex-1 ${P}`,children:O})]}),q&&a.jsx("span",{className:"text-text-muted text-xs shrink-0",children:x8(q)})]})},`${D}-${E.type}`)})})]})]}),document.body):null}function S8({attachment:e,onRemove:t}){const n=r=>r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`;return a.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[a.jsx(Dl,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),a.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}),a.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),a.jsx("div",{className:"text-[10px] text-text-muted",children:n(e.size)})]})}function w8({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:o}){const l=A.useRef(null),u=A.useRef(null);A.useEffect(()=>{u.current&&l.current&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const c=f=>{switch(f.key){case"Enter":f.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":f.preventDefault(),r();break;case"ArrowUp":f.preventDefault(),o("up");break;case"ArrowDown":f.preventDefault(),o("down");break}},d=f=>{n(f)};return a.jsx("div",{ref:l,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg overflow-y-auto max-h-64",onKeyDown:c,children:e.map((f,p)=>a.jsxs("div",{ref:p===t?u:null,role:"listitem",onClick:()=>d(f.content),className:`
|
|
296
|
+
p-2 rounded cursor-pointer transition-colors
|
|
297
|
+
${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
|
|
298
|
+
`,children:[a.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[f.formattedTimestamp,f.sessionName&&a.jsxs(a.Fragment,{children:[" | ",a.jsx("span",{className:"text-accent-primary font-medium",children:f.sessionName})]})]}),a.jsx("div",{className:"text-sm text-text-primary mt-1",children:f.trimmedContent})]},f.id))})}function C8(){const e=Pj(),t=e?"bg-amber-400":"bg-accent-primary";return a.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs("span",{className:"flex gap-0.5",children:[a.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),a.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),a.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),a.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&a.jsx("span",{className:"text-text-muted",children:"esc to interrupt"})]})}const k8={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function E8(e,t={}){const n={...k8,...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 o=await e.arrayBuffer(),l=R8(o),u=`data:${e.type};base64,${l}`,c=await lk(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await j8(e,n)}async function j8(e,t){const n=await T8(e),r=await lk(n),{width:o,height:l}=N8(r.width,r.height,t.maxWidth,t.maxHeight),u=A8();u.width=o,u.height=l;const c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(r,0,0,o,l);let d=t.quality,f="";for(let m=0;m<10&&(f=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(dS(f)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=dS(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:o,height:l}}function N8(e,t,n,r){const o=e/t;return e>t&&e>n?{width:n,height:Math.round(n/o)}:t>e&&t>r?{width:Math.round(r*o),height:r}:{width:e,height:t}}function T8(e){return new Promise((t,n)=>{const r=D8(),o=new r;o.onload=()=>t(o.result),o.onerror=()=>n(new Error("Failed to read file")),o.readAsDataURL(e)})}function lk(e){return new Promise((t,n)=>{const r=L8(),o=new r;o.onload=()=>t(o),o.onerror=()=>n(new Error("Failed to load image")),o.src=e})}function A8(){var t;const e=wg();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function L8(){const e=wg();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function D8(){const e=wg();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function wg(){return globalThis}function R8(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const o=t[r];o!==void 0&&(n+=String.fromCharCode(o))}return btoa(n)}function dS(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}function O8(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function M8(e,t=50*1024*1024){return e.size>t?{valid:!1,error:`Image file is too large (${hS(e.size)}). Maximum size is ${hS(t)}.`}:{valid:!0}}function hS(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function Bm(e,t,n,r={}){const{maxSizeBytes:o=50*1024*1024,filename:l}=r;if(!O8(e)){n(`Unsupported file type: ${e.type}. Only PNG, JPG, and GIF are supported.`);return}const u=M8(e,o);if(!u.valid){n(u.error??"Image file is too large");return}try{const c=await E8(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),d={id:kS(),filename:l??e.name,mimeType:c.mimeType,size:c.size,data:c.dataUrl};t(d)}catch(c){const d=c instanceof Error?c.message??"Failed to process image":"Failed to process image";n(d)}}function ck(e){const t=Le(l=>l.sendMessage),n=Le(l=>l.launchWorkflow),r=A.useCallback((l,u,c)=>{e(!0),t(l,u,c)},[e,t]),o=A.useCallback((l,u,c,d)=>{e(!0),n(l,u,c,d)},[e,n]);return{sendMessage:r,launchWorkflow:o}}function I8({children:e}){return Qa.createPortal(e,document.body)}function P8(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 B8({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:o,onAttach:l,textareaContent:u,attachments:c}){const[d,f]=A.useState(!1),[p,m]=A.useState("commands"),[x,y]=A.useState(""),[w,C]=A.useState(0),[v,S]=A.useState(null),[b,_]=A.useState(null),j=A.useRef(null),E=A.useRef(null),T=dn(ee=>ee.defaults),D=dn(ee=>ee.userItems),L=dn(ee=>ee.projectItems),O=dn(ee=>ee.fetchCommands),P=Rt(ee=>ee.defaults),q=Rt(ee=>ee.userItems),W=Rt(ee=>ee.projectItems),M=Rt(ee=>ee.fetchWorkflows),H=Vr(Vr(T,D),L),V=Vr(Vr(P,q),W);A.useEffect(()=>{d&&(p==="commands"?O():p==="workflows"&&M())},[d,p,O,M]),A.useEffect(()=>{d&&(y(""),C(0),requestAnimationFrame(()=>{var ee;return(ee=j.current)==null?void 0:ee.focus()}))},[d,p]),A.useEffect(()=>{if(!d)return;const ee=J=>{var ne;(ne=E.current)!=null&&ne.contains(J.target)||f(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[d]);const U=ee=>{switch(ee.key){case"ArrowDown":ee.preventDefault(),C(J=>{const K=(p==="commands"?H:V).filter(F=>{const te=x.toLowerCase();return!te||F.name.toLowerCase().includes(te)});return Math.min(J+1,K.length-1)});break;case"ArrowUp":ee.preventDefault(),C(J=>Math.max(J-1,0));break;case"Enter":ee.preventDefault();break;case"Escape":ee.preventDefault(),f(!1);break}},Q=ee=>{y(ee),C(0)},X=H.filter(ee=>!x||ee.name.toLowerCase().includes(x.toLowerCase())),z=V.filter(ee=>!x||ee.name.toLowerCase().includes(x.toLowerCase())),R=async ee=>{const J=await dn.getState().fetchCommand(ee);J&&e(J.prompt,J.metadata.agentMode,u,c),f(!1)},I=ee=>{t(ee),f(!1)},G=(ee,J)=>{J.stopPropagation(),f(!1),S(ee)},B=(ee,J)=>{J.stopPropagation(),f(!1),_(ee)};return a.jsxs("div",{ref:E,className:"relative",children:[a.jsx("button",{type:"button",onClick:()=>f(!d),className:"px-1.5 py-2 rounded-r bg-bg-secondary text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors border-l border-border/50",title:"More options",children:a.jsx(IS,{className:"w-4 h-4"})}),d&&a.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:[a.jsxs("div",{className:"flex border-b border-border",children:[a.jsx("button",{type:"button",onClick:()=>{m("commands"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),a.jsx("button",{type:"button",onClick:()=>{m("workflows"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),a.jsx("button",{type:"button",onClick:()=>m("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&a.jsx("div",{className:"p-2 border-b border-border",children:a.jsx("input",{ref:j,value:x,onChange:ee=>Q(ee.target.value),onKeyDown:U,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),a.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:p==="commands"?X.length===0?a.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:H.length===0?"No commands yet":"No matches"}):X.map((ee,J)=>a.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${J===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[a.jsx("button",{type:"button",onClick:()=>R(ee.id),className:"flex-1 text-left",children:a.jsx("div",{className:"text-sm text-text-primary font-medium",children:ee.name})}),a.jsx(Qs,{className:"opacity-0 group-hover:opacity-100",onClick:ne=>G(ee.id,ne)})]},ee.id)):p==="workflows"?z.length===0?a.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:V.length===0?"No workflows yet":"No matches"}):z.map((ee,J)=>{const ne=P8(ee),K=ee.color??"#3b82f6";return a.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${J===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[a.jsxs("button",{type:"button",onClick:()=>I(ee.id),className:"flex-1 text-left flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:K}}),a.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:ee.name}),ne!==null&&a.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:ne?"#22c55e":"#6b7280"},title:ne?"Entry condition met":"Entry condition not met"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[ee.subGroups&&ee.subGroups.length>0&&a.jsx($8,{subGroups:ee.subGroups,onSelect:F=>{f(!1),n(ee.id,F)}}),a.jsx(Qs,{className:"opacity-0 group-hover:opacity-100",onClick:F=>B(ee.id,F)})]})]},ee.id)}):a.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>{l(),f(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[a.jsx(Wj,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm font-medium",children:"Attach image"})]}),a.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&a.jsx("div",{className:"border-t border-border p-1",children:a.jsx("button",{type:"button",onClick:()=>{f(!1),p==="commands"?r():o()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),a.jsx(rk,{isOpen:!!v,onClose:()=>S(null),initialEditId:v}),a.jsx(ak,{isOpen:!!b,onClose:()=>_(null),initialEditId:b})]})}function $8({subGroups:e,onSelect:t}){const[n,r]=A.useState(!1),[o,l]=A.useState({top:0,right:0}),u=A.useRef(null),c=A.useRef(null);nk(c,()=>r(!1),n);const d=f=>{if(f.stopPropagation(),!n&&u.current){const p=u.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return a.jsxs(a.Fragment,{children:[a.jsx("button",{ref:u,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&a.jsx(I8,{children:a.jsx("div",{ref:c,onMouseDown:f=>f.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:o.top,right:o.right},children:e.map(f=>a.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(f)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:f},f))})})]})}function z8({messages:e,onCancel:t}){return e.length===0?null:a.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>a.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:[a.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),a.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),a.jsx(Dl,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function H8({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,onView:o,onEdit:l,onDuplicate:u,onDelete:c}){const d=e.allowedTools.filter(f=>!(r!=null&&r.has(f)));return a.jsxs(e1,{isBuiltIn:t,isConfirmingDelete:n,onView:o,onEdit:l,onDuplicate:u,onDelete:c,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),a.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),a.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&a.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),e.description&&a.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[d.slice(0,5).map(f=>a.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:f},f)),d.length>5&&a.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",d.length-5," more"]})]})]})}function fS({title:e,agents:t,subagents:n,isBuiltIn:r,alwaysAllowedNames:o,onView:l,onDuplicate:u,onEdit:c,onDelete:d}){if(t.length===0&&n.length===0)return null;const f=p=>a.jsx(H8,{agent:p,isBuiltIn:r,isConfirmingDelete:!1,alwaysAllowedNames:o,onView:()=>l(p.id),onEdit:r?void 0:()=>c==null?void 0:c(p.id),onDuplicate:()=>u(p.id),onDelete:r?void 0:()=>d==null?void 0:d(p.id)},p.id);return a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),a.jsxs("div",{className:"space-y-2",children:[t.map(f),n.length>0&&a.jsxs("div",{className:"mt-3",children:[a.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:"Sub-agents"}),a.jsx("div",{className:"space-y-2",children:n.map(f)})]})]})]})}function U8(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const o=n.slice(0,r),u=n.slice(r+1).split(",").filter(Boolean);t.set(o,new Set(u))}}return t}function $m(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function F8({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:o,formColor:l,formPrompt:u,formError:c,saving:d,isReadOnly:f,availableTools:p,onNameChange:m,onIdChange:x,onDescriptionChange:y,onSubagentChange:w,onToolsChange:C,onColorChange:v,onPromptChange:S,onSave:b,onCancel:_,onDuplicate:j}){const E=U8(o),T=p.filter(O=>!(r&&O.topLevelOnly)),D=(O,P)=>{const q=new Map(E),W=q.get(O)||new Set,M=new Set(W);M.has(P)?M.delete(P):M.add(P),M.size===0?q.set(O,new Set):q.set(O,M),C($m(q))},L=O=>{const P=new Map(E);P.has(O)?P.delete(O):P.set(O,new Set),C($m(P))};return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"space-y-3",children:[c&&a.jsx(rd,{message:c}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Dr,{label:"Name",value:e,onChange:m,placeholder:"My Agent",readOnly:f}),a.jsx(Dr,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Dr,{label:"Description",value:n,onChange:y,placeholder:"What this agent does",readOnly:f}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),a.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[a.jsx("button",{onClick:()=>!f&&w(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${f?"pointer-events-none opacity-60":""}`,children:"Agent"}),a.jsx("button",{onClick:()=>!f&&w(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${f?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),a.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[a.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),a.jsx("input",{type:"color",value:l,onChange:O=>!f&&v(O.target.value),disabled:f,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32 overflow-y-auto",children:T.map(O=>{const P=E.has(O.name),q=O.actions.length>0,W=E.get(O.name)||new Set;return q?f?a.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:[a.jsx("span",{children:O.name}),a.jsx("span",{className:"text-[10px]",children:"*"})]},O.name):a.jsx(Ll,{trigger:a.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${P?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[a.jsx("span",{children:O.name}),q&&a.jsx("span",{className:`text-[10px] ${P&&W.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...O.actions.map(M=>({label:a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${O.name}-${M}`,children:[a.jsx("input",{type:"checkbox",id:`${O.name}-${M}`,checked:W.has(M),onChange:()=>D(O.name,M),disabled:f,className:"w-3 h-3 rounded accent-accent-primary"}),a.jsx("span",{children:M})]}),closeOnClick:!1})),{label:P?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(P)L(O.name);else{const M=new Map(E);M.set(O.name,new Set(O.actions)),C($m(M))}}}]},O.name):a.jsx("button",{onClick:()=>!f&&L(O.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${P?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${f?"pointer-events-none":"cursor-pointer"}`,children:a.jsx("span",{children:O.name})},O.name)})})]})]}),a.jsxs("div",{className:"flex-1 min-h-[150px] border-t border-border pt-3 flex flex-col",children:[a.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),a.jsx("textarea",{value:u,onChange:O=>!f&&S(O.target.value),readOnly:f,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${f?"opacity-60":""}`})]}),a.jsx(bN,{onCancel:_,onSave:b,saving:d,saveDisabled:!e||!u||f}),f&&a.jsx("div",{className:"flex justify-end mt-2",children:a.jsx("button",{onClick:j,className:"px-3 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors",children:"Duplicate & Customize"})})]})}function V8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function G8({isOpen:e,onClose:t,initialEditId:n}){const r=wt(he=>he.defaults),o=wt(he=>he.userItems),l=wt(he=>he.loading),u=wt(he=>he.fetchAgents),c=wt(he=>he.fetchAgent),d=wt(he=>he.fetchDefaultContent),f=wt(he=>he.createAgent),p=wt(he=>he.updateAgent),m=wt(he=>he.deleteAgent),[x,y]=A.useState("list"),[w,C]=A.useState(null),[v,S]=A.useState(!1),[b,_]=A.useState(""),[j,E]=A.useState(""),[T,D]=A.useState(""),[L,O]=A.useState(!0),[P,q]=A.useState([]),[W,M]=A.useState("#6b7280"),[H,V]=A.useState(""),[U,Q]=A.useState(""),[X,z]=A.useState(!1),[R,I]=A.useState([]),[G,B]=A.useState(new Set),ee=he=>{_(he.metadata.name),E(he.metadata.id),D(he.metadata.description),O(he.metadata.subagent),q(he.metadata.allowedTools),M(he.metadata.color??"#6b7280"),V(he.prompt),Q("")},J=(he,se,xe)=>{_(he.metadata.name+" (copy)"),E(`${se}-copy-${Date.now()}`),D(he.metadata.description),O(he.metadata.subagent),q(he.metadata.allowedTools),M(he.metadata.color??"#6b7280"),V(he.prompt),Q(""),C(null),S(!1),y("edit")},ne=(he,se)=>{ee(he),C(se),S(!0),y("edit")};A.useEffect(()=>{e&&(u(),ke("/api/tools").then(he=>he.json()).then(he=>{const se=he.tools||[];B(new Set(se.filter(xe=>xe.alwaysAllowed).map(xe=>xe.name))),I(se.filter(xe=>!xe.alwaysAllowed))}).catch(()=>{I([]),B(new Set)}),n?r.some(se=>se.id===n)?d(n).then(se=>{se&&J(se,n)}):c(n).then(se=>{se&&(ee(se),C(n),S(!1),y("edit"))}):(y("list"),C(null),S(!1)))},[e,u,c,d,n]);const K=async he=>{if(r.some(xe=>xe.id===he)){const xe=await d(he);if(!xe)return;ne(xe,he)}else{const xe=await c(he);if(!xe)return;ne(xe,he)}},F=async he=>{const se=await d(he);se&&J(se,he)},te=()=>{C(null),_(""),E(""),D(""),O(!0),q(["read_file"]),M("#6b7280"),V(""),Q(""),S(!1),y("edit")},re=async he=>{const se=await c(he);se&&(ee(se),C(he),S(!1),y("edit"))},pe=async he=>{await m(he)},be=async()=>{const he=w??j;if(!he||!b||!H){Q("Name and prompt are required.");return}z(!0),Q("");const se={metadata:{id:he,name:b,description:T,subagent:L,allowedTools:P.filter(Ve=>!G.has(Ve)),color:W},prompt:H},xe=w?await p(w,se):await f(se);if(z(!1),!xe.success){Q(xe.error??"Failed to save agent.");return}n?t():y("list")},Pe=()=>{n?t():(y("list"),S(!1))},$e=he=>{_(he),w||E(V8(he))},Ne=r.filter(he=>he.subagent),je=r.filter(he=>!he.subagent),oe=o.filter(he=>he.subagent),Be=o.filter(he=>!he.subagent);return x==="edit"?a.jsx(Ot,{isOpen:e,onClose:Pe,title:v?`${b}`:w?"Edit Agent":"New Agent",size:"xl",children:a.jsx(F8,{formName:b,formId:j,formDescription:T,formSubagent:L,formTools:P,formColor:W,formPrompt:H,formError:U,saving:X,isReadOnly:v,availableTools:R,onNameChange:$e,onIdChange:E,onDescriptionChange:D,onSubagentChange:he=>{O(he),he&&q(se=>se.filter(xe=>{var Ve;return!((Ve=R.find(Ze=>Ze.name===xe))!=null&&Ve.topLevelOnly)}))},onToolsChange:q,onColorChange:M,onPromptChange:V,onSave:be,onCancel:Pe,onDuplicate:()=>{_(b+" (copy)"),E(`${w}-copy-${Date.now()}`),C(null),S(!1)}})}):a.jsx(Ot,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:a.jsx(GS,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:te,loading:l,hasItems:r.length>0||o.length>0,children:a.jsxs("div",{className:"space-y-4",children:[r.length>0&&a.jsx(fS,{title:"Built-in",agents:je,subagents:Ne,isBuiltIn:!0,alwaysAllowedNames:G,onView:K,onDuplicate:F}),o.length>0&&a.jsx(fS,{title:"Custom",agents:Be,subagents:oe,isBuiltIn:!1,alwaysAllowedNames:G,onView:K,onDuplicate:F,onEdit:re,onDelete:pe})]})})})}function W8(){const e=Le(b=>{var _;return(_=b.currentSession)==null?void 0:_.mode}),t=Le(b=>b.switchMode),n=wt(b=>b.defaults),r=wt(b=>b.userItems),o=wt(b=>b.fetchAgents),l=[...n,...r],[u,c]=A.useState(!1),[d,f]=A.useState(!1),[p,m]=A.useState(null),x=A.useRef(null);A.useEffect(()=>{o()},[o]),A.useEffect(()=>{function b(_){x.current&&!x.current.contains(_.target)&&c(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]);const y=Rp();if(!e)return null;const w=l.filter(b=>!b.subagent),C=w.find(b=>b.id===e),v=(C==null?void 0:C.name)??e,S=_l(l,e);return a.jsxs("div",{className:"relative",ref:x,children:[a.jsxs("button",{type:"button",onClick:()=>c(!u),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[a.jsx("span",{className:"text-sm font-medium",style:{color:S},children:v}),a.jsx(Wn,{className:`w-3 h-3 text-text-muted transition-transform ${u?"rotate-180":""}`})]}),u&&w.length>0&&a.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[w.map((b,_)=>{const j=b.id===e,E=_l(l,b.id),T=y.agentSwitching[_],D=T?HS(T):null;return a.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${j?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[a.jsxs("button",{type:"button",onClick:()=>{j||t(b.id),c(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"font-medium truncate",style:{color:E},children:b.name}),j&&a.jsx(Wr,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),D&&a.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:D})]},b.id)}),a.jsx("div",{className:"border-t border-border p-1",children:a.jsx("button",{type:"button",onClick:()=>{c(!1),f(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),a.jsx(G8,{isOpen:d,onClose:()=>{f(!1),m(null)},initialEditId:p})]})}function q8(){const e=Le(r=>r.currentSession),t=Le(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return a.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[a.jsx("button",{type:"button",onClick:()=>t("normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),a.jsx("button",{type:"button",onClick:()=>t("dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})}function mS({value:e,onChange:t}){return a.jsxs("div",{children:[a.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",a.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),a.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 K8=[8080,11434,8e3,1234];function kp(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function uk(e){return{name:e.name,url:e.url,backend:e.backend,apiKey:e.apiKey,isLocal:e.isLocal,thinkingField:e.thinkingField,authAdapter:e.authAdapter,transportAdapter:e.transportAdapter,models:e.models}}function Y8({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:o,onRunAutoConfig:l,onTestParams:u,onShowRaw:c}){var d,f,p,m,x,y,w,C,v,S,b,_,j,E,T,D,L,O,P,q,W,M,H,V,U,Q,X,z,R,I,G,B,ee,J,ne,K,F,te,re,pe,be,Pe,$e;return a.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>l(e.id),disabled:n.progress[e.id]==="probing",className:"px-4 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:n.progress[e.id]==="probing"?"Probing...":"Auto-config"}),n.progress[e.id]==="done"&&a.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&a.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),a.jsxs("div",{className:"flex gap-3 items-end",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),a.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:Ne=>o(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"})]}),a.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[a.jsx("input",{type:"checkbox",checked:((f=t[e.id])==null?void 0:f.supportsVision)??!1,onChange:Ne=>o(e.id,{supportsVision:Ne.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>u(e.id,"thinking"),disabled:(p=r[e.id+"-thinking"])==null?void 0:p.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(m=r[e.id+"-thinking"])!=null&&m.loading?"Testing...":"Test thinking"}),((x=r[e.id+"-thinking"])==null?void 0:x.result)&&a.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((y=r[e.id+"-thinking"])==null?void 0:y.error)&&a.jsx("span",{className:"text-xs text-red-500",title:(w=r[e.id+"-thinking"])==null?void 0:w.error,children:"Fail"}),((C=r[e.id+"-thinking"])==null?void 0:C.result)&&a.jsx("button",{onClick:()=>c(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>u(e.id,"non-thinking"),disabled:(v=r[e.id+"-non-thinking"])==null?void 0:v.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(S=r[e.id+"-non-thinking"])!=null&&S.loading?"Testing...":"Test non-thinking"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.result)&&a.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((_=r[e.id+"-non-thinking"])==null?void 0:_.error)&&a.jsx("span",{className:"text-xs text-red-500",title:(j=r[e.id+"-non-thinking"])==null?void 0:j.error,children:"Fail"}),((E=r[e.id+"-non-thinking"])==null?void 0:E.result)&&a.jsx("button",{onClick:()=>c(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),a.jsxs("details",{className:"group",children:[a.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[a.jsx(Wn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:((T=t[e.id])==null?void 0:T.thinkingEnabled)??!1,onChange:Ne=>o(e.id,{thinkingEnabled:Ne.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),a.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((D=t[e.id])==null?void 0:D.thinkingEnabled)&&a.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(L=e.reasoningEfforts)!=null&&L.length?a.jsx("select",{"aria-label":"Reasoning effort",value:((O=t[e.id])==null?void 0:O.thinkingLevel)??kp(e.reasoningEfforts),onChange:Ne=>o(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=>a.jsx("option",{value:Ne,children:Ne},Ne))}):a.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((P=t[e.id])==null?void 0:P.thinkingLevel)??"",onChange:Ne=>o(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"})]}),a.jsx(mS,{value:(q=t[e.id])==null?void 0:q.thinkingQueryParams,onChange:Ne=>o(e.id,{thinkingQueryParams:Ne})})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:((W=t[e.id])==null?void 0:W.nonThinkingEnabled)??!1,onChange:Ne=>o(e.id,{nonThinkingEnabled:Ne.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),a.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((M=t[e.id])==null?void 0:M.nonThinkingEnabled)&&a.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:a.jsx(mS,{value:(H=t[e.id])==null?void 0:H.nonThinkingQueryParams,onChange:Ne=>o(e.id,{nonThinkingQueryParams:Ne})})})]}),a.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[a.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),a.jsx("input",{type:"number",step:"0.1",value:((V=t[e.id])==null?void 0:V.temperature)??"",onChange:Ne=>o(e.id,{temperature:Ne.target.value?parseFloat(Ne.target.value):void 0}),placeholder:((Q=(U=t[e.id])==null?void 0:U.defaultTemperature)==null?void 0:Q.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((X=t[e.id])==null?void 0:X.defaultTemperature)!==void 0&&a.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(z=t[e.id])==null?void 0:z.defaultTemperature]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),a.jsx("input",{type:"number",step:"0.05",value:((R=t[e.id])==null?void 0:R.topP)??"",onChange:Ne=>o(e.id,{topP:Ne.target.value?parseFloat(Ne.target.value):void 0}),placeholder:((G=(I=t[e.id])==null?void 0:I.defaultTopP)==null?void 0:G.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((B=t[e.id])==null?void 0:B.defaultTopP)!==void 0&&a.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(ee=t[e.id])==null?void 0:ee.defaultTopP]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),a.jsx("input",{type:"number",value:((J=t[e.id])==null?void 0:J.topK)??"",onChange:Ne=>o(e.id,{topK:Ne.target.value?parseInt(Ne.target.value):void 0}),placeholder:((K=(ne=t[e.id])==null?void 0:ne.defaultTopK)==null?void 0:K.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((F=t[e.id])==null?void 0:F.defaultTopK)!==void 0&&a.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(te=t[e.id])==null?void 0:te.defaultTopK]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),a.jsx("input",{type:"number",value:((re=t[e.id])==null?void 0:re.maxTokens)??"",onChange:Ne=>o(e.id,{maxTokens:Ne.target.value?parseInt(Ne.target.value):void 0}),placeholder:((be=(pe=t[e.id])==null?void 0:pe.defaultMaxTokens)==null?void 0:be.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((Pe=t[e.id])==null?void 0:Pe.defaultMaxTokens)!==void 0&&a.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",($e=t[e.id])==null?void 0:$e.defaultMaxTokens]})]})]})]})]})]})}function dk({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:o,editModelId:l}){const[u,c]=A.useState(r),[d,f]=A.useState(""),[p,m]=A.useState(""),[x,y]=A.useState("unknown"),[w,C]=A.useState(""),[v,S]=A.useState(!1),[b,_]=A.useState(),[j,E]=A.useState(),[T,D]=A.useState(!1),[L,O]=A.useState(null),[P,q]=A.useState([]),[W,M]=A.useState(null),[H,V]=A.useState(!1),[U,Q]=A.useState(""),[X,z]=A.useState({}),[R,I]=A.useState({loading:!1,progress:{}}),[G,B]=A.useState({}),[ee,J]=A.useState(null),[ne,K]=A.useState(new Set),[F,te]=A.useState(""),[re,pe]=A.useState(null),[be,Pe]=A.useState("disconnected"),[$e,Ne]=A.useState(!1),[je,oe]=A.useState(null),[Be,he]=A.useState([]),[se,xe]=A.useState(!1),[Ve,Ze]=A.useState(!1),it=A.useRef(null),Et=A.useRef(!1),ce=A.useRef(null);A.useEffect(()=>{u===1&&e&&requestAnimationFrame(()=>{var ye;return(ye=ce.current)==null?void 0:ye.focus()})},[u,e]),A.useEffect(()=>()=>{it.current!==null&&window.clearTimeout(it.current)},[]),A.useEffect(()=>{e&&ke("/api/provider-presets").then(async ye=>ye.ok?await ye.json():{presets:[]}).then(ye=>he(ye.presets)).catch(()=>he([]))},[e]);function Te(ye,He){z(Me=>({...Me,[ye]:{...Me[ye],...He}}))}function Fe(ye){K(He=>new Set(He).add(ye.id)),z(He=>({...He,[ye.id]:{contextWindow:ye.contextWindow,...He[ye.id]}}))}function Ye(ye){if(!ye.trim())return P;const He=ye.toLowerCase().split(/\s+/).filter(Boolean);return P.filter(Me=>He.every(Ae=>Me.id.toLowerCase().includes(Ae)))}A.useEffect(()=>{var ye,He;if(e)if(c(r),f((o==null?void 0:o.name)??""),m((o==null?void 0:o.url)??""),y((o==null?void 0:o.backend)??"unknown"),C((o==null?void 0:o.apiKey)??""),S((o==null?void 0:o.isLocal)??!1),_(o==null?void 0:o.authAdapter),E(o==null?void 0:o.transportAdapter),O(null),Q((o==null?void 0:o.thinkingField)??""),B({}),J(null),pe(null),Pe("disconnected"),oe(null),xe(!1),Ze(!1),(ye=o==null?void 0:o.models)!=null&&ye.length){const Me={},Ae=new Set;for(const Qe of o.models)Me[Qe.id]={contextWindow:Qe.contextWindow,supportsVision:Qe.supportsVision,thinkingEnabled:Qe.thinkingEnabled,thinkingLevel:Qe.thinkingLevel??kp(Qe.reasoningEfforts),nonThinkingEnabled:Qe.nonThinkingEnabled,thinkingQueryParams:Qe.thinkingQueryParams,nonThinkingQueryParams:Qe.nonThinkingQueryParams,defaultTemperature:Qe.defaultTemperature,defaultTopP:Qe.defaultTopP,defaultTopK:Qe.defaultTopK,defaultMaxTokens:Qe.defaultMaxTokens},Qe.selected&&Ae.add(Qe.id);if(Ae.size===0)for(const Qe of o.models)Ae.add(Qe.id);K(Ae),z(Me),q(o.models),M(l??((He=o.models[0])==null?void 0:He.id)??null)}else q([]),z({}),M(null),K(new Set)},[e,r,o==null?void 0:o.id,l]),A.useEffect(()=>{const ye=!!b;u===2&&p&&P.length===0&&!T&&!L&&(!ye||be==="connected")&&We(p)},[u,be]),A.useEffect(()=>{!e||!b||!(o!=null&&o.id)||kt(o.id)},[e,j,o==null?void 0:o.id]),A.useEffect(()=>{if(!je)return;const ye=(o==null?void 0:o.id)??re;if(!ye)return;let He=!1;const Me=async()=>{const Qe=await kt(ye);He||Qe!=="connected"||(oe(null),xe(!1),Ze(!1),await We(p))};Me();const Ae=window.setInterval(()=>void Me(),2e3);return()=>{He=!0,window.clearInterval(Ae)}},[je,re,o==null?void 0:o.id]);async function tt(){if(o!=null&&o.id)return o.id;if(re)return re;const ye=await ke("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:p,backend:x,authAdapter:b,transportAdapter:j,isLocal:!1,models:[]})});if(!ye.ok)throw new Error("Unable to create provider");const He=await ye.json();return pe(He.provider.id),He.provider.id}async function kt(ye){const He=await ke(`/api/provider-auth/${ye}/status`);if(!He.ok)return"error";const Me=await He.json(),Ae=Me.state==="connected"?"connected":Me.state==="pending"?"pending":Me.state==="error"?"error":"disconnected";return Pe(Ae),Ae}async function at(){Ne(!0),Pe("pending");try{const ye=await tt(),He=await ke(`/api/provider-auth/${ye}/login`,{method:"POST"});if(!He.ok)throw new Error("Unable to start provider sign-in");const Me=await He.json();oe(Me)}catch{Pe("error")}finally{Ne(!1)}}async function me(){var ye;je!=null&&je.userCode&&(await((ye=navigator.clipboard)==null?void 0:ye.writeText(je.userCode)),it.current!==null&&window.clearTimeout(it.current),Ze(!1),requestAnimationFrame(()=>Ze(!0)),it.current=window.setTimeout(()=>{Ze(!1),it.current=null},1500))}function Oe(){je&&(window.open(je.directUrl??je.verificationUrl,"_blank","noopener,noreferrer"),xe(!0))}async function We(ye){var He,Me;D(!0),O(null),q([]);try{const Ae=new URLSearchParams({url:ye});w&&Ae.set("apiKey",w),x&&Ae.set("backend",x);const Qe=j?await ke(`/api/providers/${await tt()}/models`):await ke(`/api/providers/models?${Ae.toString()}`);if(Qe.ok){const Bt=await Qe.json();if((He=Bt.models)!=null&&He.length){q(Bt.models),M(((Me=Bt.models[0])==null?void 0:Me.id)??null);const Mn={};for(const bn of Bt.models)Mn[bn.id]={contextWindow:bn.contextWindow,thinkingEnabled:!0,thinkingLevel:kp(bn.reasoningEfforts),defaultTemperature:bn.defaultTemperature,defaultTopP:bn.defaultTopP,defaultTopK:bn.defaultTopK,defaultMaxTokens:bn.defaultMaxTokens};z(Mn),Bt.models.length===1&&(K(new Set([Bt.models[0].id])),M(Bt.models[0].id),et(Bt.models[0].id))}}else{const Bt=await Qe.json();O(Bt.error??`Failed to fetch models from ${ye}`)}}catch(Ae){O(`Failed to fetch models from ${ye}: ${Ae instanceof Error?Ae.message:"Unknown error"}`)}D(!1)}async function et(ye){I(He=>({loading:!0,progress:{...He.progress,[ye]:"probing"}}));try{const He=await ke("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,apiKey:w||void 0,backend:x||"unknown",models:[{id:ye}]})});if(!He.ok){const Ae=await He.json();throw new Error(Ae.error??"Auto-config failed")}const Me=await He.json();for(const Ae of Me.models){const Qe={};Ae.contextSource!=="default"&&(Qe.contextWindow=Ae.contextWindow,Qe.supportsVision=Ae.supportsVision),Ae.thinkingConfig&&(Qe.thinkingEnabled=!0,Qe.thinkingQueryParams=JSON.stringify(Ae.thinkingConfig)),Ae.nonThinkingConfig&&(Qe.nonThinkingEnabled=!0,Qe.nonThinkingQueryParams=JSON.stringify(Ae.nonThinkingConfig)),Te(Ae.id,Qe),I(Bt=>({...Bt,progress:{...Bt.progress,[Ae.id]:"done"}}))}}catch(He){console.error("Auto-config error:",He),I(Me=>({...Me,progress:{...Me.progress,[ye]:"error"}}))}finally{I(He=>({...He,loading:!1}))}}async function En(ye,He){const Me=ye+"-"+He;B(Ae=>({...Ae,[Me]:{loading:!0}}));try{const Ae=X[ye],Qe=await ke("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,providerId:(o==null?void 0:o.id)??re??void 0,transportAdapter:j,model:ye,apiKey:w||void 0,backend:x||"unknown",thinkingField:U||void 0,mode:He,modelConfig:{temperature:Ae==null?void 0:Ae.temperature,topP:Ae==null?void 0:Ae.topP,topK:Ae==null?void 0:Ae.topK,maxTokens:Ae==null?void 0:Ae.maxTokens,supportsVision:Ae==null?void 0:Ae.supportsVision,thinkingEnabled:Ae==null?void 0:Ae.thinkingEnabled,thinkingLevel:Ae==null?void 0:Ae.thinkingLevel,nonThinkingEnabled:Ae==null?void 0:Ae.nonThinkingEnabled,thinkingQueryParams:Ae==null?void 0:Ae.thinkingQueryParams,nonThinkingQueryParams:Ae==null?void 0:Ae.nonThinkingQueryParams}})}),Bt=await Qe.json();Qe.ok?B(Mn=>({...Mn,[Me]:{loading:!1,result:JSON.stringify(Bt,null,2),message:Bt.message}})):B(Mn=>({...Mn,[Me]:{loading:!1,error:Bt.error??"Test failed"}}))}catch(Ae){B(Qe=>({...Qe,[Me]:{loading:!1,error:Ae instanceof Error?Ae.message:"Request failed"}}))}}function Wt(){q([]),z({}),I({loading:!1,progress:{}}),B({}),J(null),K(new Set),te("")}function Xn(){re&&!Et.current&&ke(`/api/providers/${re}`,{method:"DELETE"}).catch(ye=>{console.warn("Failed to clean up draft provider",ye)}),t()}function Qn(){const ye=d||"Provider",He=(o==null?void 0:o.id)??re??`temp-${Date.now()}`;n({id:He,name:ye,url:p,backend:x||"unknown",apiKey:w||void 0,isLocal:v,thinkingField:U||void 0,authAdapter:b,transportAdapter:j,models:P.map(Me=>{var Ae,Qe,Bt,Mn,bn,Cr,ve,we,ze,qe,lt,nt,yt,nn,Mt;return{id:Me.id,name:Me.name,apiModelId:Me.apiModelId,requestBody:Me.requestBody,reasoningEfforts:Me.reasoningEfforts,contextWindow:((Ae=X[Me.id])==null?void 0:Ae.contextWindow)??Me.contextWindow,selected:ne.has(Me.id)||void 0,supportsVision:(Qe=X[Me.id])==null?void 0:Qe.supportsVision,thinkingEnabled:(Bt=X[Me.id])==null?void 0:Bt.thinkingEnabled,thinkingLevel:(Mn=X[Me.id])==null?void 0:Mn.thinkingLevel,nonThinkingEnabled:(bn=X[Me.id])==null?void 0:bn.nonThinkingEnabled,thinkingQueryParams:(Cr=X[Me.id])==null?void 0:Cr.thinkingQueryParams,nonThinkingQueryParams:(ve=X[Me.id])==null?void 0:ve.nonThinkingQueryParams,temperature:(we=X[Me.id])==null?void 0:we.temperature,topP:(ze=X[Me.id])==null?void 0:ze.topP,topK:(qe=X[Me.id])==null?void 0:qe.topK,maxTokens:(lt=X[Me.id])==null?void 0:lt.maxTokens,defaultMaxTokens:(nt=X[Me.id])==null?void 0:nt.defaultMaxTokens,defaultTemperature:(yt=X[Me.id])==null?void 0:yt.defaultTemperature,defaultTopP:(nn=X[Me.id])==null?void 0:nn.defaultTopP,defaultTopK:(Mt=X[Me.id])==null?void 0:Mt.defaultTopK}})}),Et.current=!0,t()}return e?a.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[a.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] overflow-y-auto shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[a.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:o?"Edit Provider":"Add Provider"}),a.jsx("button",{onClick:Xn,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),a.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(ye=>a.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ye<u?"bg-accent-success":ye===u?"bg-accent-primary":"bg-border"}`},ye))}),u===1&&a.jsxs("div",{className:"px-6 py-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),a.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[Be.map(ye=>a.jsx("button",{type:"button",onClick:()=>{f(ye.defaults.name??ye.name),m(ye.defaults.url),y(ye.defaults.backend),S(!1),C(""),_(ye.authAdapter),E(ye.transportAdapter),O(null),Wt()},className:`p-2 rounded border text-center text-sm transition-colors ${j&&j===ye.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:ye.name},ye.id)),a.jsx("button",{type:"button",onClick:()=>{y("unknown"),S(!1),_(void 0),E(void 0),O(null),Wt()},className:`p-2 rounded border text-center text-sm transition-colors ${x==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),K8.map(ye=>{const He={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},Me={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return a.jsx("button",{type:"button",onClick:()=>{f(Ae=>Ae||(Me[ye]??"")),m(Ae=>Ae||`http://localhost:${ye}`),y(He[ye]??""),S(!0),_(void 0),E(void 0),O(null),Wt()},className:`p-2 rounded border text-center text-sm transition-colors ${x===He[ye]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Me[ye]??`localhost:${ye}`},ye)})]})]}),!b&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),a.jsx("input",{ref:ce,type:"text",value:p,"data-testid":"provider-modal-url",onChange:ye=>{m(ye.target.value),O(null),q([]),z({})},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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),a.jsx("input",{type:"text",autoComplete:"off",value:d,onChange:ye=>f(ye.target.value),placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!b&&a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",a.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),a.jsx("input",{type:"text",autoComplete:"off",value:w,onChange:ye=>C(ye.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!b&&a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:v,onChange:ye=>S(ye.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),a.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),u===2&&a.jsxs("div",{className:"px-6 py-4 space-y-4",children:[!!b&&a.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),a.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),be==="connected"?a.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):a.jsx("button",{type:"button",onClick:()=>void at(),disabled:$e||be==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:$e||be==="pending"?"Connecting...":be==="error"?"Retry":"Connect"})]}),je&&a.jsxs("div",{className:"mt-4 border-t border-border pt-4",children:[a.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),a.jsx("button",{type:"button",onClick:()=>void me(),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:je.userCode??"Continue"}),a.jsxs("div",{className:"mt-3 flex gap-2",children:[a.jsx("button",{type:"button",onClick:()=>void me(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:Ve?"Copied":"Copy code"}),a.jsx("button",{type:"button",onClick:Oe,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:se?"Reopen authorization":"Open authorization"})]})]})]}),T&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[a.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),L&&a.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[a.jsx("p",{children:L}),a.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:()=>We(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),a.jsx("button",{onClick:()=>{Wt(),c(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"})]})]}),P.length>0&&x&&(!b||be==="connected")&&a.jsxs(a.Fragment,{children:[ne.size>0&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",ne.size,")"]}),a.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),a.jsx("div",{className:"space-y-2",children:P.filter(ye=>ne.has(ye.id)).map(ye=>{var He;return a.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[a.jsxs("div",{onClick:()=>M(W===ye.id?null:ye.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm font-medium text-text-primary",children:ye.name??ye.id.split("/").pop()}),a.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((He=X[ye.id])==null?void 0:He.contextWindow)??ye.contextWindow).toLocaleString()," ctx"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[R.progress[ye.id]==="probing"?a.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):R.progress[ye.id]==="done"?a.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):R.progress[ye.id]==="error"?a.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):b?null:a.jsx("button",{onClick:Me=>{Me.stopPropagation(),et(ye.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),P.length>1&&a.jsx("button",{onClick:Me=>{Me.stopPropagation();const Ae=new Set(ne);Ae.delete(ye.id),K(Ae),W===ye.id&&M(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),a.jsx(Wn,{className:`w-4 h-4 text-text-muted transition-transform ${W===ye.id?"rotate-180":""}`})]})]}),W===ye.id&&a.jsx(Y8,{model:ye,modelConfigs:X,autoConfigState:R,testResults:G,onUpdateConfig:Te,onRunAutoConfig:et,onTestParams:En,onShowRaw:J})]},ye.id)})})]}),P.length>1&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),ne.size===0&&a.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."}),a.jsxs("div",{className:"relative mb-2",children:[a.jsx("input",{type:"text",value:F,onChange:ye=>te(ye.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),F&&a.jsx("button",{onClick:()=>te(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",Ye(F).length," of ",P.length," models"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>{const ye=new Set(ne),He=Ye(F);for(const Me of He)ye.add(Me.id);if(K(ye),z(Me=>{const Ae={...Me};for(const Qe of He)Ae[Qe.id]={contextWindow:Qe.contextWindow,...Ae[Qe.id]};return Ae}),!b)for(const Me of He)R.progress[Me.id]!=="probing"&&R.progress[Me.id]!=="done"&&et(Me.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),a.jsx("button",{onClick:()=>{const ye=new Set(ne),He=Ye(F);for(const Me of He)ye.delete(Me.id);K(ye)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),a.jsxs("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-border rounded-lg bg-bg-primary",children:[Ye(F).map(ye=>{var Me;const He=ne.has(ye.id);return a.jsxs("div",{role:"checkbox","aria-checked":He,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${He?"bg-accent-primary/5":""}`,onClick:()=>{if(He){const Ae=new Set(ne);Ae.delete(ye.id),K(Ae)}else Fe(ye),b||et(ye.id)},onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Ae.currentTarget.click())},children:[a.jsx("input",{type:"checkbox",checked:He,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),a.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:ye.name??ye.id.split("/").pop()}),a.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Me=X[ye.id])==null?void 0:Me.contextWindow)??ye.contextWindow).toLocaleString()," ctx"]}),R.progress[ye.id]==="probing"&&a.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),R.progress[ye.id]==="done"&&a.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),R.progress[ye.id]==="error"&&a.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},ye.id)}),Ye(F).length===0&&a.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",F,"”"]})]})]})]})]}),a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[a.jsx("div",{children:u>1&&a.jsx("button",{onClick:()=>{u===2&&Wt(),c(u-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:Xn,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),u===1?a.jsx("button",{onClick:()=>c(2),disabled:!p,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):a.jsx("button",{onClick:Qn,disabled:R.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:R.loading?"Configuring...":"Save Provider"})]})]})]}),H&&a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ye=>{ye.target===ye.currentTarget&&V(!1)},children:a.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[a.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),a.jsx("button",{onClick:()=>V(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),a.jsxs("div",{className:"px-6 py-4 space-y-4",children:[a.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),a.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),a.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"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",a.jsx("span",{className:"text-text-muted",children:"(override)"})]}),a.jsx("input",{type:"text",value:U,onChange:ye=>Q(ye.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"}),a.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)."})]})]}),a.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:a.jsx("button",{onClick:()=>V(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),ee&&a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ye=>{ye.target===ye.currentTarget&&J(null)},children:a.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[a.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),a.jsx("button",{onClick:()=>J(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),a.jsx("pre",{className:"px-6 py-4 overflow-y-auto text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:ee})]})})]}):null}function X8(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function Q8(){var at;const[,e]=Gn(),t=Le(me=>me.currentSession),n=Le(me=>me.setSessionProvider),[r,o]=A.useState(!1),[l,u]=A.useState([]),[c,d]=A.useState(null),f=A.useRef(null),[p,m]=A.useState(null),[x,y]=A.useState(!1),[w,C]=A.useState({}),[v,S]=A.useState(null),[b,_]=A.useState(null),[j,E]=A.useState(!1),T=A.useRef(null),[D,L]=A.useState(!1),O=A.useRef(new Set),P=un(me=>me.providers),q=un(me=>me.activeProviderId),W=un(me=>me.defaultModelSelection),M=un(me=>me.activating),H=un(me=>me.activateProvider),V=un(me=>me.refreshModel),U=un(me=>me.refreshProviderModels),Q=un(me=>me.setDefaultModel),X=un(me=>me.fetchConfig),z=(t==null?void 0:t.providerId)??null,R=(t==null?void 0:t.providerModel)??null,I=(W==null?void 0:W.split("/")[0])??null,G=(W==null?void 0:W.split("/").slice(1).join("/"))??null,B=z??I,ee=R??G,J=ee?((at=ee.split("/").pop())==null?void 0:at.replace(/-/g," "))??ee:"No model",K=!!(t&&R)&&R!==G,[F,te]=A.useState(!1);A.useEffect(()=>{function me(Oe){f.current&&!f.current.contains(Oe.target)&&(o(!1),u([]),O.current=new Set)}return document.addEventListener("mousedown",me),()=>document.removeEventListener("mousedown",me)},[]),A.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current)},[]),A.useEffect(()=>{if(r){const me=P.map(Oe=>Oe.id);u(me),P.filter(Oe=>!!Oe.authAdapter).forEach(Oe=>void he(Oe.id)),me.forEach(Oe=>{O.current.has(Oe)||(O.current.add(Oe),$e(Oe))})}},[r,P]),A.useEffect(()=>{if(!b)return;let me=!1;const Oe=async()=>{const et=await he(b.providerId);me||et==="connected"&&(_(null),E(!1),L(!1),await X(),O.current.delete(b.providerId),await $e(b.providerId))};Oe();const We=window.setInterval(()=>void Oe(),2e3);return()=>{me=!0,window.clearInterval(We)}},[b]);const re=P.find(me=>me.id===B),pe=(re==null?void 0:re.status)==="disconnected",be=(me,Oe)=>t?t.providerId===me&&t.providerModel===Oe:!1,Pe=(me,Oe)=>W?W===`${me}/${Oe}`:!1,$e=async me=>{d(me);try{await U(me)}catch{}finally{d(null)}},Ne=me=>{l.includes(me.id)?u(l.filter(Oe=>Oe!==me.id)):(u([...l,me.id]),$e(me.id))},je=async me=>{if(me.id===q){Ne(me);return}t?(n(me.id,void 0),o(!1),u([])):await H(me.id)&&(o(!1),u([]))},oe=me=>{Ne(me)},Be=async(me,Oe)=>{me.stopPropagation(),O.current.delete(Oe),await $e(Oe)},he=async me=>{const Oe=await ke(`/api/provider-auth/${me}/status`);if(!Oe.ok)return"error";const We=await Oe.json();return C(et=>({...et,[me]:We.state})),We.state},se=async(me,Oe)=>{me.stopPropagation(),S(Oe),C(We=>({...We,[Oe]:"pending"})),E(!1),L(!1);try{const We=await ke(`/api/provider-auth/${Oe}/login`,{method:"POST"});if(!We.ok)throw new Error("Unable to start provider sign-in");const et=await We.json();_({providerId:Oe,...et})}catch{C(We=>({...We,[Oe]:"error"}))}finally{S(null)}},xe=async()=>{var me;b!=null&&b.userCode&&(await((me=navigator.clipboard)==null?void 0:me.writeText(b.userCode)),T.current!==null&&window.clearTimeout(T.current),E(!1),requestAnimationFrame(()=>E(!0)),T.current=window.setTimeout(()=>{E(!1),T.current=null},1500))},Ve=()=>{b&&(window.open(b.directUrl??b.verificationUrl,"_blank","noopener,noreferrer"),L(!0))},Ze=()=>{_(null),E(!1),L(!1)},it=async(me,Oe)=>{me.stopPropagation(),S(Oe);try{if(!(await ke(`/api/provider-auth/${Oe}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");C(et=>({...et,[Oe]:"disconnected"})),await X()}finally{S(null)}},Et=(me,Oe)=>{m({providerId:me,model:Oe}),y(!0)},ce=p?P.find(me=>me.id===p.providerId):void 0,Te=()=>{m(null),y(!1)},Fe=async me=>{try{if(!(await ke(`/api/providers/${me.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(uk(me))})).ok)throw new Error("Failed to update provider");await un.getState().fetchConfig()}catch{}m(null),y(!1)},Ye=async(me,Oe)=>{if(t){Le.setState(et=>({currentSession:et.currentSession?{...et.currentSession,providerId:me,providerModel:Oe}:null})),n(me,Oe),u([]),o(!1);return}await H(me)&&(u([]),o(!1))},tt=async(me,Oe,We)=>{me.stopPropagation(),te(!0);try{await Q(Oe,We)}catch{}finally{te(!1)}};function kt(me){return me.models.some(We=>We.selected)?me.models.filter(We=>We.selected):me.models}return P.length===0?a.jsxs("button",{type:"button",onClick:()=>V(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:pe?"LLM server is offline. Click to retry.":J??"Click to refresh model",children:[pe?a.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-accent-primary",children:J}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${re!=null&&re.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:re!=null&&re.isLocal?"local":"api"})]}),a.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):a.jsxs("div",{className:"relative",ref:f,children:[a.jsxs("button",{type:"button",onClick:()=>o(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[pe?a.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`text-sm ${K?"text-accent-primary italic":"text-accent-primary"}`,children:J}),K&&a.jsx("span",{className:"text-xs text-text-muted ml-0.5",title:"Session-scoped model (different from default)",children:"•"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${re!=null&&re.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:re!=null&&re.isLocal?"local":"api"})]}),a.jsx(Wn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&a.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 overflow-hidden max-h-[80vh] overflow-y-auto",children:[a.jsx("div",{className:"py-1",children:P.map(me=>{var Oe;return a.jsxs("div",{children:[a.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${me.id===B?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${M?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[a.jsxs("div",{onClick:()=>!M&&je(me),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[a.jsx("span",{className:`text-sm font-medium truncate ${me.id===B?"text-accent-primary":"text-text-primary"}`,children:me.name}),a.jsx("span",{className:"text-xs text-text-muted truncate",children:me.backend!=="unknown"&&ES(me.backend)})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!me.authAdapter&&(w[me.id]==="connected"||me.credentialRef?a.jsx("button",{type:"button",onClick:We=>it(We,me.id),disabled:v===me.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"}):a.jsx("button",{type:"button",onClick:We=>se(We,me.id),disabled:v===me.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:v===me.id?"Starting…":w[me.id]==="error"||w[me.id]==="expired"?"Retry":"Connect"})),me.id===B?a.jsx("span",{className:"text-accent-success",title:"Active provider",children:a.jsx(Wr,{className:"w-4 h-4"})}):a.jsx("span",{className:"w-4"}),a.jsx("button",{type:"button",onClick:We=>{We.stopPropagation(),Be(We,me.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:a.jsx(Dp,{className:`w-4 h-4 ${c===me.id?"animate-spin":""} ${me.id===q?"text-accent-primary":"text-text-muted"}`})}),a.jsx("button",{type:"button",onClick:We=>{We.stopPropagation(),oe(me)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:a.jsx(Wn,{className:`w-4 h-4 transition-transform ${l.includes(me.id)?"rotate-180":""} ${me.id===q?"text-accent-primary":"text-text-muted"}`})})]})]}),l.includes(me.id)&&a.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:c===me.id?a.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):(Oe=me.models)!=null&&Oe.length?kt(me).map(We=>{var Wt;const et=be(me.id,We.id),En=Pe(me.id,We.id);return a.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm hover:bg-bg-tertiary transition-colors group ${c==="activating"?"opacity-50 cursor-wait":""} ${et?"text-accent-primary":"text-text-secondary"}`,children:[a.jsx("button",{type:"button",onClick:()=>Ye(me.id,We.id),disabled:c==="activating",className:"flex-1 truncate text-left",children:We.name??((Wt=We.id.split("/").pop())==null?void 0:Wt.replace(/-/g," "))??We.id}),a.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[a.jsx("span",{className:"text-xs text-text-muted",children:X8(We.contextWindow)}),t&&a.jsx("button",{type:"button",onClick:Xn=>tt(Xn,me.id,We.id),disabled:F,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:En?"Default model":"Set as default model",children:En?a.jsx(PS,{className:"w-3.5 h-3.5 text-accent-warning"}):a.jsx(BS,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),a.jsx("button",{type:"button",onClick:Xn=>{Xn.stopPropagation(),Et(me.id,We)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:a.jsx(Yj,{className:"w-3 h-3 text-text-muted"})}),et&&a.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:a.jsx(Wr,{className:"w-3.5 h-3.5"})})]})]},We.id)}):a.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},me.id)})}),a.jsx("div",{className:"border-t border-border px-3 py-2",children:a.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),b&&a.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:me=>{me.target===me.currentTarget&&Ze()},children:a.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),a.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),a.jsx("button",{type:"button",onClick:Ze,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:"×"})]}),a.jsx("button",{type:"button",onClick:xe,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"}),a.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:j?"Copied to clipboard":"Click the code to copy it"}),a.jsxs("div",{className:"mt-6 flex gap-3",children:[a.jsx("button",{type:"button",onClick:xe,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:j?"Copied":"Copy code"}),a.jsx("button",{type:"button",onClick:Ve,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})]}),a.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:D?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]})}),p&&x&&a.jsx(dk,{isOpen:!0,onClose:Te,onSave:Fe,initialStep:2,editProvider:{id:p.providerId,name:(ce==null?void 0:ce.name)??"",url:(ce==null?void 0:ce.url)??"",backend:(ce==null?void 0:ce.backend)??"unknown",apiKey:ce==null?void 0:ce.apiKey,isLocal:ce==null?void 0:ce.isLocal,thinkingField:ce==null?void 0:ce.thinkingField,authAdapter:ce==null?void 0:ce.authAdapter,transportAdapter:ce==null?void 0:ce.transportAdapter,models:ce==null?void 0:ce.models},editModelId:p.model.id})]})}function J8(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return null;const o=n.slice(r+1);return o.includes(" ")||o.includes(`
|
|
299
|
+
`)||o.includes(" ")?null:{query:o,startIndex:r}}const Z8=A.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:o},l){const u=J8(t,n),[c,d]=A.useState([]),[f,p]=A.useState(!1),[m,x]=A.useState(0),y=A.useRef(null),w=A.useRef([]),C=A.useRef(0),v=A.useRef([]);A.useEffect(()=>{C.current=m},[m]),A.useEffect(()=>{v.current=c},[c]),A.useEffect(()=>{if(!u){d([]);return}const _=setTimeout(()=>{S(u.query)},150);return()=>clearTimeout(_)},[u==null?void 0:u.query,r]);const S=async _=>{p(!0);try{const j=new URLSearchParams({q:_});r&&j.set("workdir",r);const T=await(await ke(`/api/files?${j.toString()}`)).json();d(T),x(0),C.current=0}catch(j){console.error("File search failed:",j),d([])}finally{p(!1)}},b=A.useCallback(_=>{if(!u)return!1;switch(_.key){case"ArrowDown":return _.preventDefault(),x(j=>{var T;const E=Math.min(j+1,v.current.length-1);return w.current[E]&&((T=w.current[E])==null||T.scrollIntoView({block:"nearest"})),E}),C.current=Math.min(C.current+1,v.current.length-1),!0;case"ArrowUp":return _.preventDefault(),x(j=>{var T;const E=Math.max(j-1,0);return w.current[E]&&((T=w.current[E])==null||T.scrollIntoView({block:"nearest"})),E}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const j=v.current;return j[C.current]?(_.preventDefault(),o(j[C.current],u.startIndex),!0):!1}case"Escape":return _.preventDefault(),d([]),!0}return!1},[u,o]);return A.useImperativeHandle(l,()=>({handleKeyDown:b}),[b]),A.useEffect(()=>{if(!u)return;const _=j=>{y.current&&!y.current.contains(j.target)&&d([])};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[u]),u?f?a.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:a.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:a.jsx("div",{className:"p-4 text-center",children:a.jsx(ni,{size:"sm"})})})}):c.length===0?null:a.jsx("div",{ref:y,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:a.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64 overflow-y-auto",children:a.jsx("ul",{className:"py-1",children:c.map((_,j)=>a.jsxs("li",{ref:E=>{w.current[j]=E},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${j===m?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{u&&o(_,u.startIndex)},children:[_.type==="directory"?a.jsx(Tl,{className:"w-4 h-4 shrink-0"}):a.jsx("span",{className:"w-4 h-4 shrink-0"}),a.jsx("span",{className:"truncate",children:_.path})]},_.path))})})}):null});function e$({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:o,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollContainerRef:d,sessionId:f,sessionMode:p,showHistory:m,history:x,selectedIndex:y,openHistory:w,closeHistory:C,navigateUp:v,navigateDown:S,selectCurrent:b,isAutoScrollActive:_,setAutoScroll:j,onOpenMessageSearch:E,onOpenCommandsModal:T,onOpenWorkflowsModal:D,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:O,clearInput:P}){const q=A.useRef(null),W=A.useRef(null),M=A.useRef(0),H=A.useRef(0),V=A.useRef(null),U=ed(),Q=Le(se=>se.stopGeneration),X=Le(se=>se.cancelQueued),z=Le(se=>se.queuedMessages),R=Le(se=>se.restoredInput),I=Le(se=>se.clearRestoredInput),G=Le(se=>{var xe;return(xe=se.currentSession)==null?void 0:xe.workdir}),B=Le(se=>se.currentSession),ee=A.useRef(!1),{sendMessage:J}=ck(j);A.useEffect(()=>{var se;R!==null&&(t(R),I(),(se=q.current)==null||se.focus())},[R,t,I]);const ne=A.useCallback(()=>{const se=q.current;if(!se)return;const xe=e.length>=M.current;M.current=e.length,xe||(se.style.height="auto"),se.style.height=`${Math.min(200,se.scrollHeight)}px`},[e]);A.useEffect(()=>{if(!f)return;const se=`openfox:draft:${f}`,xe=localStorage.getItem(se);xe!==null&&t(xe)},[f,t]),A.useEffect(()=>{var se;(se=q.current)==null||se.focus(),ne()},[f,ne]),A.useEffect(()=>{if(!f)return;const se=`openfox:draft:${f}`,xe=setTimeout(()=>{e?localStorage.setItem(se,e):localStorage.removeItem(se)},500);return()=>clearTimeout(xe)},[f,e]),A.useEffect(()=>{ne()},[e,ne]),A.useEffect(()=>{const se=q.current;if(!se)return;const xe=async Ve=>{var it;if(document.activeElement!==se)return;const Ze=(it=Ve.clipboardData)==null?void 0:it.items;if(Ze){for(const Et of Array.from(Ze))if(Et.type.startsWith("image/")){Ve.preventDefault();const ce=Et.getAsFile();if(!ce)continue;await Bm(ce,Te=>r([...n,Te]),c,{filename:"pasted-image"})}}};return se.addEventListener("paste",xe),()=>se.removeEventListener("paste",xe)},[n,r,c]);const K=se=>{se.preventDefault(),!(!e.trim()&&n.length===0)&&(J(e,n.length>0?n:void 0),P())},F=se=>{var xe;if(!((xe=V.current)!=null&&xe.handleKeyDown(se))){if(m)switch(se.key){case"Enter":{se.preventDefault();const Ve=b();Ve&&(t(Ve),C());return}case"Escape":se.preventDefault(),C(),U&&Q();return;case"ArrowUp":se.preventDefault(),v();return;case"ArrowDown":se.preventDefault(),S();return}if(se.key==="ArrowUp"&&e.trim()===""&&!m){se.preventDefault(),w();return}se.key==="Enter"&&!se.shiftKey&&(se.preventDefault(),K(se))}},te=A.useCallback(async se=>{const xe=se.target.files;if(!(!xe||xe.length===0)){c(null);for(const Ve of Array.from(xe))await Bm(Ve,Ze=>r([...n,Ze]),c);W.current&&(W.current.value="")}},[n,r,c]),re=A.useCallback(se=>{se.preventDefault(),se.stopPropagation(),l(!0)},[l]),pe=A.useCallback(se=>{se.preventDefault(),se.stopPropagation(),l(!1)},[l]),be=A.useCallback(async se=>{se.preventDefault(),se.stopPropagation(),l(!1),c(null);const xe=se.dataTransfer.files;if(!(!xe||xe.length===0))for(const Ve of Array.from(xe))await Bm(Ve,Ze=>r([...n,Ze]),c)},[n,r,l,c]),Pe=A.useCallback(se=>{r(n.filter(xe=>xe.id!==se))},[n,r]),$e=A.useCallback(()=>{var se;(se=W.current)==null||se.click()},[]),Ne=()=>{var se;!e.trim()&&n.length===0||((se=d.current)==null||se.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),J(e,n),P())},je=A.useCallback((se,xe)=>{const Ze=se.type==="directory"?"/":" ",it=e.slice(0,xe),Et=e.slice(H.current),ce=`${it}@${se.path}${Ze}${Et}`;t(ce);const Te=xe+se.path.length+2;H.current=Te,q.current&&(q.current.selectionStart=Te,q.current.selectionEnd=Te,q.current.focus())},[e,t]),oe=A.useCallback(se=>{const xe=se.target.value;t(xe),m&&C(),H.current=se.target.selectionStart,!ee.current&&f&&xe&&B&&B.messages.length===0&&(ee.current=!0,ke(`/api/sessions/${f}/warmup`,{method:"POST"}).catch(()=>{}))},[t,m,C,f,B]),Be=A.useCallback(se=>{H.current=se.target.selectionStart},[]),he=A.useCallback(se=>{H.current=se.currentTarget.selectionStart},[]);return a.jsxs("form",{onSubmit:K,className:"relative p-2 md:p-4 bg-secondary",children:[U&&a.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:a.jsx(C8,{})}),a.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:[a.jsx(Bp,{isActive:_,onToggle: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"}),a.jsxs("button",{type:"button",onClick:E,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[a.jsx(yl,{}),"Browse history"]})]}),a.jsx("input",{ref:W,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:te,className:"hidden",multiple:!0}),u&&a.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:u}),n.length>0&&a.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(se=>a.jsx(S8,{attachment:se,onRemove:Pe},se.id))}),m&&a.jsx(w8,{history:x,selectedIndex:y,onSelect:se=>{t(se),C()},onEscape:C,onNavigate:se=>{se==="up"?v():S()}}),a.jsx(z8,{messages:z,onCancel:X}),a.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${o?"bg-accent-primary/10":"bg-primary"}`,onDragOver:re,onDragLeave:pe,onDrop:be,children:[a.jsxs("div",{className:"relative flex-1 min-w-0",children:[a.jsx("textarea",{id:n1,ref:q,value:e,onChange:oe,onKeyDown:F,onSelect:Be,onKeyUp:he,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),a.jsx(Z8,{ref:V,text:e,cursorPos:H.current,workdir:G,onSelect:je})]}),a.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[U&&a.jsxs("button",{type:"button",onClick:()=>Q(),"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:[a.jsx($S,{}),"Abort"]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("button",{type:"button",onClick:Ne,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"}),a.jsx(B8,{onSendCommand:(se,xe,Ve,Ze)=>{var Et;xe&&p!==xe&&Le.getState().switchMode(xe);const it=Ve&&Ve.trim()?`${Ve.trim()}
|
|
300
|
+
|
|
301
|
+
${se}`:se;(Et=d.current)==null||Et.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),J(it,Ze!=null&&Ze.length?Ze:void 0,{messageKind:"command",isSystemGenerated:!0}),P()},onSelectWorkflow:L,onSelectWorkflowWithSubGroup:O,onOpenCommandsManager:T,onOpenWorkflowsManager:D,onAttach:$e,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),a.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(W8,{}),a.jsx(q8,{})]}),a.jsx(Q8,{})]})]})}function t$(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function hk(e,t=[]){const n=[];let r=null,o,l=1;const u=new Map,c=new Map;for(const f of t)f.type==="message"?u.set(f.message.id,f):f.type==="subagent"&&c.set(f.subAgentId,f);const d=()=>{if(!r)return;const f=r,p=c.get(f.subAgentId);p&&p.type==="subagent"&&p.messages.length===f.messages.length&&p.messages.every((x,y)=>x===f.messages[y])?n.push(p):n.push({type:"subagent",subAgentId:f.subAgentId,subAgentType:f.subAgentType,messages:f.messages}),r=null};for(const f of e)if(f.role!=="tool")if(f.contextWindowId&&o&&f.contextWindowId!==o&&(d(),l++,n.push({type:"context-divider",windowSequence:l})),o=f.contextWindowId,f.subAgentId&&f.subAgentType)r&&r.subAgentId===f.subAgentId?r.messages.push(f):(d(),r={subAgentId:f.subAgentId,subAgentType:f.subAgentType,messages:[f]});else{d();const p=u.get(f.id);p&&p.type==="message"&&p.message===f?n.push(p):n.push({type:"message",message:f})}return d(),n}function n$(e){const{year:t,month:n,day:r}=o1(e);return`${t}/${n}/${r} ${id(e)}`}function r$(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const s$=10,i$=150;function a$(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 o$(e){return[...e].sort((r,o)=>new Date(o.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,s$).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:n$(r.timestamp),trimmedContent:r$(r.content,i$),sessionId:r.sessionId,sessionName:r.sessionName}))}function l$(e,t,n){const r=[],o=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of o)r.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:n??"",sessionName:"This session"});for(const l of t)n&&l.id===n||r.push(...a$(l));return o$(r)}function c$(e,t=[],n=null){const[r,o]=A.useState(0),[l,u]=A.useState(!1),c=A.useMemo(()=>l$(e,t,n),[e,t,n]),d=A.useCallback(()=>{c.length>0&&(o(c.length-1),u(!0))},[c.length]),f=A.useCallback(()=>{u(!1),o(0)},[]),p=A.useCallback(()=>{o(y=>c.length===0?y:y===0?c.length-1:y-1)},[c.length]),m=A.useCallback(()=>{o(y=>c.length===0?y:y===c.length-1?0:y+1)},[c.length]),x=A.useCallback(()=>{if(c.length===0||!l)return null;const y=c[r];return(y==null?void 0:y.content)??null},[c,r,l]);return{history:c,selectedIndex:r,showHistory:l,openHistory:d,closeHistory:f,navigateUp:p,navigateDown:m,selectCurrent:x}}A.memo(function({item:t}){const[n,r]=A.useState(!1);return t.type==="start"?a.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:[a.jsx("span",{className:"animate-pulse",children:"●"}),a.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&a.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):a.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[a.jsx("span",{className:"text-accent-success",children:"✓"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),a.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&&a.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:a.jsx(Vn,{content:t.description})})]})]})});function u$({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t}={}){const n=e??!0,[r,o]=A.useState(""),[l,u]=A.useState([]),[c,d]=A.useState(!1),[f,p]=A.useState(null),[m,x]=A.useState(!1),[y,w]=A.useState(!1),[C,v]=A.useState(!1),[S,b]=A.useState(!1),[_,j]=A.useState(null),E=A.useRef(null),T=Le(je=>je.currentSession),D=Le(je=>je.messages),L=Le(je=>je.sessions),O=ed(),P=Le(je=>je.stopGeneration),q=wt(je=>je.defaults),W=wt(je=>je.userItems),M=[...q,...W].filter(je=>!je.subagent),{history:H,selectedIndex:V,showHistory:U,openHistory:Q,closeHistory:X,navigateUp:z,navigateDown:R,selectCurrent:I}=c$(D,L,T==null?void 0:T.id);A.useEffect(()=>{const je=oe=>{j(oe.detail.stats)};return window.addEventListener("open-turn-stats",je),()=>window.removeEventListener("open-turn-stats",je)},[]),A.useEffect(()=>{Rt.getState().fetchWorkflows()},[]),A.useEffect(()=>{const je=oe=>{t$(oe)&&(oe.preventDefault(),b(!0))};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[]);const{maxVisibleItems:G}=zi(),B=A.useRef([]),{displayItems:ee,hiddenCount:J}=A.useMemo(()=>{const je=hk(D,B.current);return B.current=je,G>0&&je.length>G?{displayItems:je.slice(-G),hiddenCount:je.length-G}:{displayItems:je,hiddenCount:0}},[D,G]),{isAutoScrollActive:ne,setAutoScroll:K}=od(E,T),{sendMessage:F,launchWorkflow:te}=ck(K),re=A.useCallback((je,oe)=>{te(void 0,void 0,je,oe)},[te]),pe=A.useCallback(je=>{var Be;K(!1);const oe=document.querySelector(`[data-item-index="${je}"]`);oe&&(oe.scrollIntoView({behavior:"smooth",block:"start"}),(Be=oe.closest('[data-testid="chat-scroll-container"]'))==null||Be.scrollBy(0,-80))},[K]);A.useEffect(()=>{const je=oe=>{const Be=C||m||y||S||_;oe.key==="Escape"&&O&&!Be&&P(),oe.key==="ScrollLock"&&K(!ne)};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[O,P,ne,C,m,y,S,_]);const be=Rp();VS(be.quickAction,()=>{v(!0)}),mN(be.agentSwitching,M,je=>{Le.getState().switchMode(je)});const Pe=je=>{const oe=r.trim()?r:void 0,Be=l.length>0?l:void 0;te(oe,Be,je),Ne()},$e=(je,oe)=>{const Be=r.trim()?r:void 0,he=l.length>0?l:void 0;te(Be,he,je,oe),Ne()},Ne=()=>{o(""),u([]),T!=null&&T.id&&localStorage.removeItem(`openfox:draft:${T.id}`)};return a.jsxs(a.Fragment,{children:[a.jsxs(tA,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:t,messages:D,children:[a.jsx(sA,{}),_&&a.jsx(iA,{stats:_,onClose:()=>j(null)}),a.jsx(ZB,{}),a.jsx(QB,{displayItems:ee,scrollContainerRef:E,highlightedMessageId:null,onLaunchWorkflow:re,hiddenCount:J}),a.jsx(e$,{input:r,setInput:o,attachments:l,setAttachments:u,dragOver:c,setDragOver:d,errorMessage:f,setErrorMessage:p,scrollContainerRef:E,sessionId:T==null?void 0:T.id,sessionMode:T==null?void 0:T.mode,showHistory:U,history:H,selectedIndex:V,openHistory:Q,closeHistory:X,navigateUp:z,navigateDown:R,selectCurrent:I,isAutoScrollActive:ne,setAutoScroll:K,onOpenMessageSearch:()=>b(!0),onOpenCommandsModal:()=>x(!0),onOpenWorkflowsModal:()=>w(!0),onSelectWorkflow:Pe,onSelectWorkflowWithSubGroup:$e,clearInput:Ne}),a.jsx(rk,{isOpen:m,onClose:()=>x(!1)}),a.jsx(ak,{isOpen:y,onClose:()=>w(!1)}),a.jsx(h8,{isOpen:C,onClose:()=>v(!1),onSearchMessages:()=>b(!0),isAutoScrollActive:ne,onToggleAutoScroll:K,textareaContent:r,onCloseComplete:qm,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(je,oe)=>{const Be=await dn.getState().fetchCommand(je);if(Be){const he=oe!=null&&oe.trim()?`${oe.trim()}
|
|
302
|
+
|
|
303
|
+
${Be.prompt}`:Be.prompt;Be.metadata.agentMode&&Le.getState().switchMode(Be.metadata.agentMode),F(he,l!=null&&l.length?l:void 0,{messageKind:"command",isSystemGenerated:!0}),Ne()}},onSelectWorkflow:je=>{const oe=r.trim()||void 0,Be=l.length>0?l:void 0;te(oe,Be,je),Ne()}})]}),S&&a.jsx(v8,{isOpen:S,onClose:()=>{b(!1),qm()},displayItems:ee,onNavigate:pe})]})}function d$(){var S;const[,e]=Ka("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=A.useState(null),[o,l]=A.useState([]),[u,c]=A.useState(!0),[d,f]=A.useState(null),p=async()=>{if(t){c(!0),f(null);try{const b=await ke(`/api/sessions/${t}`);if(!b.ok){f(`Failed to load session (${b.status})`),c(!1);return}const _=await b.json();r(_.session??null),l(_.messages??[])}catch(b){f(b instanceof Error?b.message:"Unknown error")}finally{c(!1)}}};A.useEffect(()=>{tn.getState().getSettings([...Ep])},[]),A.useEffect(()=>{p()},[t]);const{showThinking:m,showVerboseToolOutput:x,showStats:y,showAgentDefinitions:w,showWorkflowBars:C}=zi(),v=A.useMemo(()=>hk(o),[o]);return u?a.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:a.jsx(ni,{})}):d?a.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:a.jsxs("div",{className:"text-center space-y-4",children:[a.jsx("div",{className:"text-red-400 text-sm",children:d}),a.jsx("button",{onClick:p,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"})]})}):a.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((S=n==null?void 0:n.metadata)==null?void 0:S.title)??"Session"," — Read-only view"]}),a.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[o.length," messages"]})]}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("button",{onClick:p,disabled:u,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:u?"Refreshing...":"Refresh"})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto print:overflow-visible",children:[a.jsx("div",{className:"pt-4",children:a.jsx(tk,{displayItems:v,showThinking:m,showVerboseToolOutput:x,showStats:y,showAgentDefinitions:w,showWorkflowBars:C})}),a.jsx("div",{className:"h-8"})]})]})}function pS({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[o,l]=A.useState(""),u=A.useRef(null);A.useEffect(()=>{e&&(l(""),setTimeout(()=>{var d;return(d=u.current)==null?void 0:d.focus()},100))},[e]);const c=d=>{d.preventDefault(),o.trim()&&n(o)};return a.jsx(Ot,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:a.jsxs("form",{onSubmit:c,className:"space-y-4",children:[a.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."}),a.jsx(Ii,{ref:u,type:"password",value:o,onChange:d=>l(d.target.value),placeholder:"Enter password",autoFocus:!0}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(rt,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),a.jsx(rt,{type:"submit",disabled:!o.trim(),children:t?"Try Again":"Connect"})]})]})})}function h$({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return a.jsx("div",{className:"flex justify-center py-6",children:a.jsx("div",{className:"flex items-center",children:Array.from({length:t},(o,l)=>{const u=l+1,c=u<e,d=u===e;return a.jsxs("div",{className:"flex items-center",children:[a.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${c?"bg-accent-primary text-text-primary hover:opacity-80":d?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:c?"✓":u}),a.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${d?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[l]}),l<t-1&&a.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${c?"bg-accent-primary":"bg-border"}`})]},l)})})})}function f$({onNext:e}){const[t,n]=A.useState([]),[r,o]=A.useState([]),[l,u]=A.useState(!1),[c,d]=A.useState(null),[f,p]=A.useState(null),[m,x]=A.useState(null);A.useEffect(()=>{y()},[]);async function y(){try{const E=await ke("/api/providers");if(E.ok){const D=(await E.json()).providers.map(L=>({id:L.id,name:L.name,url:L.url,backend:L.backend,model:null,apiKey:L.apiKey,isLocal:L.isLocal,thinkingField:L.thinkingField,models:L.models}));n(D),o(D)}}catch{}}async function w(E){const T=E.id.startsWith("temp-"),D=r.some(P=>P.id===E.id),L=r.length===0&&c===null,O=uk(E);try{let P;if(T){const W=await ke("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!W.ok)throw new Error("Failed to create provider");const M=await W.json();P={...E,id:M.provider.id,model:null}}else{if(!(await ke(`/api/providers/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).ok)throw new Error("Failed to update provider");P={...E,model:null}}const q=W=>W.some(M=>M.id===P.id)?W.map(M=>M.id===P.id?P:M):[...W,P];o(q),n(q),L&&!D&&e({providers:[P]})}catch{if(T){const P={...E,model:null};o(q=>[...q,P])}}}function C(){d(null),u(!0)}function v(E){d(E),u(!0)}function S(){u(!1),d(null)}function b(E){p(E),t.some(D=>D.id===E)?ke(`/api/providers/${E}`,{method:"DELETE"}).then(()=>{o(r.filter(D=>D.id!==E)),n(t.filter(D=>D.id!==E)),p(null)}).catch(()=>p(null)):(o(r.filter(D=>D.id!==E)),p(null))}function _(){const E=r.filter(T=>!T.id.startsWith("temp-"));e({providers:E})}const j=r.length>0;return a.jsxs("div",{className:"max-w-xl mx-auto",children:[a.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),a.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),a.jsxs("div",{className:"space-y-4",children:[r.length>0?a.jsx("div",{className:"space-y-2",children:r.map(E=>a.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:ES(E.backend)}),a.jsx("span",{className:"text-text-primary font-medium",children:E.name}),a.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"})]}),a.jsx("p",{className:"text-text-muted text-sm mt-1",children:E.url}),E.model&&a.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",E.model]})]}),a.jsx("div",{className:"flex items-center gap-1",children:m===E.id?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>b(E.id),disabled:f===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:f===E.id?"Deleting...":"Confirm"}),a.jsx("button",{onClick:()=>x(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):a.jsxs(a.Fragment,{children:[a.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"}),a.jsx("button",{onClick:()=>x(E.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:a.jsx(Ya,{})})]})})]},E.id))}):a.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:a.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),a.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:[a.jsx(ti,{className:"w-4 h-4"}),"Add Provider"]}),a.jsx("button",{onClick:_,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"})]}),a.jsx(dk,{isOpen:l,onClose:S,onSave:w,initialStep:1,editProvider:c??void 0})]})}function m$({onNext:e}){const[t,n]=A.useState(""),[r,o]=A.useState(!1);return A.useEffect(()=>{ke("/api/config").then(l=>l.json()).then(l=>{l.workdir?n(l.workdir):fetch("/api/directories?path="+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&n(u.current)}).catch(()=>{})}).catch(()=>{fetch("/api/directories?path="+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})})},[]),a.jsxs("div",{className:"max-w-xl mx-auto",children:[a.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),a.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:t,onChange:l=>n(l.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),a.jsx("button",{onClick:()=>o(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&a.jsx(sd,{initialPath:t||void 0,onSelect:l=>{n(l),o(!1)},onClose:()=>o(!1)}),a.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 p$({onNext:e}){const[t,n]=A.useState(!1),[r,o]=A.useState("http://localhost:11434"),[l,u]=A.useState("qwen3.5:0.8b"),[c,d]=A.useState("ollama"),{copied:f,copy:p}=XC();A.useEffect(()=>{ke("/api/config").then(x=>x.json()).then(x=>{x.visionFallback&&(n(x.visionFallback.enabled),o(x.visionFallback.url),u(x.visionFallback.model),x.visionFallback.backend&&d(x.visionFallback.backend))}).catch(()=>{})},[]);function m(x){if(x){e({});return}e({visionFallback:{enabled:t,url:r,model:l,timeout:120,backend:c}})}return a.jsxs("div",{className:"max-w-xl mx-auto",children:[a.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),a.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[a.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),a.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),a.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),a.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[a.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),a.jsx("button",{onClick:()=>p("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:f?a.jsx(Wr,{className:"w-4 h-4 text-accent-primary"}):a.jsx(Kj,{className:"w-4 h-4"})})]}),a.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",a.jsx("strong",{children:"OpenAI"})," backend type."]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t,onChange:x=>n(x.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),a.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),t&&a.jsxs("div",{className:"space-y-4 pl-8",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),a.jsxs("select",{value:c,onChange:x=>d(x.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[a.jsx("option",{value:"ollama",children:"Ollama"}),a.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),a.jsx("input",{type:"text",value:r,onChange:x=>o(x.target.value),placeholder:c==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),a.jsx("input",{type:"text",value:l,onChange:x=>u(x.target.value),placeholder:c==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),a.jsxs("div",{className:"flex items-center justify-between pt-4",children:[a.jsx("button",{onClick:()=>m(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),a.jsx("button",{onClick:()=>m(!1),className:"px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Finish Setup"})]})]})]})}function g$({onComplete:e}){const[t,n]=A.useState(1),[r,o]=A.useState(!1),[l,u]=A.useState({});async function c(m){u(x=>({...x,providers:m.providers})),n(2)}async function d(m){u(x=>({...x,...m})),n(3)}async function f(m){o(!0);try{if(!(await ke("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:l.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),o(!1)}}const p=m=>{n(m)};return a.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[a.jsx(Dl,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),a.jsx(h$,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),a.jsx("div",{className:"max-w-xl mx-auto",children:r?a.jsxs("div",{className:"text-center",children:[a.jsx(ti,{className:"w-6 h-6"}),a.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):a.jsxs(a.Fragment,{children:[t===1&&a.jsx(f$,{onNext:c}),t===2&&a.jsx(m$,{onNext:d}),t===3&&a.jsx(p$,{onNext:f})]})})]})}const zm="openfox_updated_to",Hm="update_pending";function x$(){const[e,t]=A.useState(!1),n=localStorage.getItem(zm),r=localStorage.getItem(Hm);A.useEffect(()=>{if(!n||!r)return;const l=setTimeout(()=>{localStorage.removeItem(zm),localStorage.removeItem(Hm),t(!0)},8e3);return()=>clearTimeout(l)},[n,r]);const o=()=>{localStorage.removeItem(zm),localStorage.removeItem(Hm),t(!0)};return e||r!=="true"||!n?null:a.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:[a.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:a.jsx(Wr,{className:"w-3 h-3 text-accent-primary"})}),a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),a.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),a.jsx("button",{onClick:o,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:a.jsx(zS,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Yt.getState().loadUserPresets(),Yt.getState().applySavedTheme());function Cg(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function fk(){return a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx(ni,{})})}function y$({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Ka("/p/:projectId"),r=n==null?void 0:n.projectId,o=Le(d=>d.connectionStatus),l=Ut(d=>d.currentProject),u=Cg();return Fj({canLoad:o==="connected"||u,projectId:r,currentProjectId:l==null?void 0:l.id}),!l||l.id!==r?a.jsx(fk,{}):a.jsxs(a.Fragment,{children:[a.jsx(c1,{projectId:r,isOpen:e,onClose:t}),a.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:a.jsx(mT,{})})]})}function _$({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,o]=Ka("/p/:projectId/s/:sessionId"),l=o==null?void 0:o.projectId,u=o==null?void 0:o.sessionId,[,c]=Gn(),d=Le(C=>C.connectionStatus),f=Le(C=>C.currentSession),p=Le(C=>C.error),m=Le(C=>C.clearError),x=Ut(C=>C.currentProject),y=Cg();return Vj({canLoad:d==="connected"||y,projectId:l,sessionId:u,currentProjectId:x==null?void 0:x.id,currentSessionId:f==null?void 0:f.id}),A.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),c(`/p/${l}`))},[p,l,m,c]),!x||x.id!==l?a.jsx(fk,{}):a.jsxs(a.Fragment,{children:[a.jsx(c1,{projectId:l,isOpen:e,onClose:t}),a.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:a.jsx(u$,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})})]})}function b$(){const e=un(r=>r.fetchConfig),[,t]=Gn();async function n(){await e(),t("/")}return a.jsx("div",{className:"flex-1 overflow-y-auto",children:a.jsx(g$,{onComplete:n})})}function v$(){const{connectionStatus:e}=Bj(),t=un(X=>X.fetchConfig),n=un(X=>X.refreshProviderModels),r=un(X=>X.providers),o=un(X=>X.activeProviderId),[,l]=Gn(),u=Cg(),[c,d]=A.useState(!1);A.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{d(!0),tn.getState().getSettings([...Ep,Ie.DISPLAY_THEME,Ie.DISPLAY_USER_PRESETS,Ie.KEYBINDINGS])})},[e,u,t]),A.useEffect(()=>{c&&o&&n(o).then(()=>{const X=un.getState().defaultModelSelection;(X?X.split("/")[0]:null)!==o&&t()})},[c,o,n,t]);const f=tn(X=>X.settings);A.useEffect(()=>{c&&r.length===0&&l("/onboarding")},[c,r.length]),A.useEffect(()=>{const{applyPreset:X,applyTokens:z,setFollowSystemTheme:R,initSystemThemeListener:I}=Yt.getState(),G=f[Ie.DISPLAY_THEME],B=f[Ie.DISPLAY_USER_PRESETS],ee=f[Ie.DISPLAY_FOLLOW_SYSTEM_THEME];if(B&&localStorage.setItem("openfox:userPresets",B),G){localStorage.setItem("openfox:theme",G);try{const ne=JSON.parse(G);ne.preset&&ne.tokens?(X(ne.preset),Yt.setState({basePreset:ne.preset}),z(ne.tokens)):ne.preset?X(ne.preset):ne.tokens&&z(ne.tokens)}catch{X("dark")}}else X("system");ee!==void 0&&Yt.getState().followSystemTheme!==(ee==="true")&&R(ee==="true");const J=I();return()=>J()},[f[Ie.DISPLAY_THEME],f[Ie.DISPLAY_USER_PRESETS]]);const p=()=>{const X=localStorage.getItem("openfox:leftSidebar");return X!==null?X==="true":!0},m=()=>{const X=localStorage.getItem("openfox:rightSidebar");return X!==null?X==="true":!0},[x,y]=A.useState(p),[w,C]=A.useState(m),[v,S]=A.useState(!1),[b,_]=A.useState(!1),[j,E]=A.useState(!1),T=G2();A.useEffect(()=>{const X=()=>{E(window.innerWidth<768)};return X(),window.addEventListener("resize",X),()=>window.removeEventListener("resize",X)},[]);const[D]=Gn(),L=/^\/p\/[^/]+$/.test(D),O=j?v:L?!0:x,P=j?b:w,q=()=>{j?S(!v):y(!x)},W=()=>{j?_(!b):C(!w)};A.useEffect(()=>{j||localStorage.setItem("openfox:leftSidebar",String(x))},[x,j]),A.useEffect(()=>{j||localStorage.setItem("openfox:rightSidebar",String(w))},[w,j]),A.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const M=Le(X=>X.showPasswordModal),H=Le(X=>X.passwordModalRetry),V=Le(X=>X.submitPassword),U=Le(X=>X.cancelPassword),[Q]=Ka("/p/:projectId/s/:sessionId/readonly");return!Q&&e!=="connected"&&!M&&!u?a.jsxs(a.Fragment,{children:[a.jsx(pS,{isOpen:!0,isRetry:H,onSubmit:V,onCancel:U}),a.jsx("div",{className:"h-screen flex items-center justify-center",children:a.jsx(SN,{text:"Connecting to server..."})})]}):Q?a.jsx(d$,{}):a.jsxs(a.Fragment,{children:[a.jsx(pS,{isOpen:M,isRetry:H,onSubmit:V,onCancel:U}),a.jsxs("div",{className:"flex flex-col",style:{height:j?`calc(${T.offsetTop}px + ${T.height}px)`:"100vh"},children:[a.jsx(uT,{}),a.jsx(sT,{onMenuClick:q,onCriteriaToggle:W}),a.jsx("div",{className:"flex-1 flex overflow-hidden",children:a.jsxs(fj,{children:[a.jsx(Yo,{path:"/onboarding",children:a.jsx(b$,{})}),a.jsx(Yo,{path:"/p/:projectId/s/:sessionId",children:a.jsx(_$,{sidebarOpen:O,onSidebarToggle:q,rightSidebarOpen:P,onRightSidebarToggle:W})}),a.jsx(Yo,{path:"/p/:projectId/new",children:a.jsx(fT,{})}),a.jsx(Yo,{path:"/p/:projectId",children:a.jsx(y$,{sidebarOpen:O,onSidebarToggle:q})}),a.jsx(Yo,{path:"/",children:a.jsx(hT,{})})]})})]}),a.jsx(x$,{})]})}z2.createRoot(document.getElementById("root")).render(a.jsx(Ys.StrictMode,{children:a.jsx(v$,{})}));
|