openfox 2.0.97 → 2.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/CHANGELOG.md +6 -0
- package/dist/{chat-handler-XXXMTO7W.js → chat-handler-YPWT4MAQ.js} +8 -8
- package/dist/{chunk-K2O7JTCX.js → chunk-AY37NB76.js} +2 -2
- package/dist/{chunk-URQQOUCS.js → chunk-B56G5OEF.js} +3 -1
- package/dist/{chunk-CCEG3AFM.js → chunk-C6QW2IDH.js} +8 -8
- package/dist/{chunk-C3XL7X4E.js → chunk-CFTT46KH.js} +4 -4
- package/dist/{chunk-T3INQCET.js → chunk-E2CSSHSI.js} +2 -2
- package/dist/{chunk-HJEATCSM.js → chunk-H5HL36MZ.js} +7 -7
- package/dist/{chunk-GPGJBDI6.js → chunk-HGEDHHTU.js} +41 -37
- package/dist/{chunk-LZW5LSVH.js → chunk-IXFEXEUL.js} +3 -3
- package/dist/chunk-JYHWOFPM.js +7 -0
- package/dist/{chunk-O5YWFX7H.js → chunk-MO3GJIT3.js} +8 -8
- package/dist/{chunk-RMXPVQP4.js → chunk-UIK6GA3P.js} +17 -9
- package/dist/{chunk-2VJIQEZE.js → chunk-VJILJ22N.js} +12 -6
- package/dist/{chunk-CSKPPHD3.js → chunk-W77HIJGH.js} +4 -3
- package/dist/{chunk-3W6STALV.js → chunk-XTKLA4AK.js} +2 -2
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-IK47PLPP.js → client-CFTJH6BY.js} +3 -3
- package/dist/{client-pure-5YE5WFJP.js → client-pure-DCEZBFKW.js} +2 -2
- package/dist/{compactor-U7EUKEUE.js → compactor-B4V75Q3A.js} +4 -4
- package/dist/{config-M7RDIFC5.js → config-3FKJV3KI.js} +2 -2
- package/dist/{dynamic-context-TDB4G5CH.js → dynamic-context-MA5BIJ52.js} +2 -2
- package/dist/{orchestrator-MTCF2EPU.js → orchestrator-DHBU7LRB.js} +7 -7
- package/dist/package.json +1 -1
- package/dist/{processor-F3EZWNPO.js → processor-RC3IBY2J.js} +7 -7
- package/dist/{protocol-C5ROb3nH.d.ts → protocol-BXgdUKgZ.d.ts} +1 -1
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-5KFIZM5T.js → provider-PEJ27FBM.js} +6 -6
- package/dist/{provider-manager-23O5QVDJ.js → provider-manager-EJGPSLOZ.js} +4 -4
- package/dist/{serve-JACH7OQW.js → serve-H7HR7BWI.js} +14 -14
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +13 -13
- package/dist/{server-KIRPYPP6.js → server-ORYMG5HD.js} +10 -10
- package/dist/shared/index.d.ts +3 -3
- package/dist/{tools-I3BAXRVD.js → tools-X5FONL4Q.js} +5 -5
- package/dist/{types-DHxO1nqw.d.ts → types-7idXD8Bq.d.ts} +4 -0
- package/dist/{types-D-dEQIrh.d.ts → types-DBftgbfl.d.ts} +1 -1
- package/dist/{update-NZZWLDK7.js → update-ZOUZYW6Q.js} +2 -2
- package/dist/web/assets/index-D8AjFhiw.js +324 -0
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-DRMYR6BF.js +0 -7
- package/dist/web/assets/index-C1sXLxiM.js +0 -324
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-DA-rfuFy.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/angular-ts-BrjP3tb8.js","assets/scss-D5BDwBP9.js","assets/apl-CORt7UWP.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-HNnZUWAn.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-2xfisSek.js","assets/html-derivative-DlHx6ybY.js","assets/sql-CRqJ_cUM.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nBiQ_Alo.js","assets/coffee-Ch7k5sss.js","assets/cpp-UfJy6YNI.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-DGywbUpC.js","assets/shellscript-Yzrsuije.js","assets/edge-FbVlp4U3.js","assets/elixir-CkH2-t6x.js","assets/elm-DbKCFpqz.js","assets/erb-Dm6A9KJ5.js","assets/ruby-DyJCeAvU.js","assets/haml-D5jkg6IW.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-ByusRIyA.js","assets/glimmer-ts-BfAWNZQY.js","assets/hack-DbPARsA_.js","assets/handlebars-BpdQsYii.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-f2NsQr07.js","assets/jison-wvAkD_A8.js","assets/julia-D7OTSIA_.js","assets/r-Dspwwk_N.js","assets/just-CUsbIsdP.js","assets/perl-B9cMNwum.js","assets/latex-CaSxy8MP.js","assets/tex-idrVyKtj.js","assets/liquid-C0sCDyMI.js","assets/marko-DjSrsDqO.js","assets/less-B1dDrJ26.js","assets/mdc-DTYItulj.js","assets/nextflow-C-mBbutL.js","assets/nextflow-groovy-vE_lwT2v.js","assets/nginx-BpAMiNFr.js","assets/nim-BIad80T-.js","assets/php-Csjmro_R.js","assets/pug-DKIMFp6K.js","assets/qml-3beO22l8.js","assets/razor-BjBPvh-w.js","assets/csharp-DSvCPggb.js","assets/rst-CpCqk9r5.js","assets/cmake-D1j8_8rp.js","assets/sas-DEy46yEz.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-8wufbnw4.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-DI20mbqo.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-Cy7k_4gC.js","assets/templ-DhtptRzy.js","assets/go-C27-OAKa.js","assets/ts-tags-D351s5mN.js","assets/twig-CW1WmMYd.js","assets/vue-D2xRrEX4.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-BoDAl6tE.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var zE=Object.defineProperty;var HE=Object.getPrototypeOf;var UE=Reflect.get;var Zv=e=>{throw TypeError(e)};var FE=(e,t,n)=>t in e?zE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var be=(e,t,n)=>FE(e,typeof t!="symbol"?t+"":t,n),dm=(e,t,n)=>t.has(e)||Zv("Cannot "+n);var $n=(e,t,n)=>(dm(e,t,"read from private field"),n?n.call(e):t.get(e)),Mi=(e,t,n)=>t.has(e)?Zv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Dr=(e,t,n,r)=>(dm(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),hm=(e,t,n)=>(dm(e,t,"access private method"),n);var e_=(e,t,n)=>UE(HE(e),n,t);function VE(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function Cd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fm={exports:{}},cl={};/**
|
|
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 t_;function WE(){if(t_)return cl;t_=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,l){var u=null;if(l!==void 0&&(u=""+l),a.key!==void 0&&(u=""+a.key),"key"in a){l={};for(var c in a)c!=="key"&&(l[c]=a[c])}else l=a;return a=l.ref,{$$typeof:e,type:r,key:u,ref:a!==void 0?a:null,props:l}}return cl.Fragment=t,cl.jsx=n,cl.jsxs=n,cl}var n_;function GE(){return n_||(n_=1,fm.exports=WE()),fm.exports}var i=GE(),mm={exports:{}},ut={};/**
|
|
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 r_;function qE(){if(r_)return ut;r_=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),x=Symbol.iterator;function y(B){return B===null||typeof B!="object"?null:(B=x&&B[x]||B["@@iterator"],typeof B=="function"?B:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,_={};function S(B,q,z){this.props=B,this.context=q,this.refs=_,this.updater=z||w}S.prototype.isReactComponent={},S.prototype.setState=function(B,q){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,q,"setState")},S.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function v(){}v.prototype=S.prototype;function b(B,q,z){this.props=B,this.context=q,this.refs=_,this.updater=z||w}var j=b.prototype=new v;j.constructor=b,C(j,S.prototype),j.isPureReactComponent=!0;var N=Array.isArray;function T(){}var D={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function I(B,q,z){var re=z.ref;return{$$typeof:e,type:B,key:q,ref:re!==void 0?re:null,props:z}}function M(B,q){return I(B.type,q,B.props)}function G(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function U(B){var q={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(z){return q[z]})}var R=/\/+/g;function H(B,q){return typeof B=="object"&&B!==null&&B.key!=null?U(""+B.key):q.toString(36)}function W(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(T,T):(B.status="pending",B.then(function(q){B.status==="pending"&&(B.status="fulfilled",B.value=q)},function(q){B.status==="pending"&&(B.status="rejected",B.reason=q)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function V(B,q,z,re,ne){var J=typeof B;(J==="undefined"||J==="boolean")&&(B=null);var K=!1;if(B===null)K=!0;else switch(J){case"bigint":case"string":case"number":K=!0;break;case"object":switch(B.$$typeof){case e:case t:K=!0;break;case p:return K=B._init,V(K(B._payload),q,z,re,ne)}}if(K)return ne=ne(B),K=re===""?"."+H(B,0):re,N(ne)?(z="",K!=null&&(z=K.replace(R,"$&/")+"/"),V(ne,q,z,"",function(ae){return ae})):ne!=null&&(G(ne)&&(ne=M(ne,z+(ne.key==null||B&&B.key===ne.key?"":(""+ne.key).replace(R,"$&/")+"/")+K)),q.push(ne)),1;K=0;var P=re===""?".":re+":";if(N(B))for(var Q=0;Q<B.length;Q++)re=B[Q],J=P+H(re,Q),K+=V(re,q,z,J,ne);else if(Q=y(B),typeof Q=="function")for(B=Q.call(B),Q=0;!(re=B.next()).done;)re=re.value,J=P+H(re,Q++),K+=V(re,q,z,J,ne);else if(J==="object"){if(typeof B.then=="function")return V(W(B),q,z,re,ne);throw q=String(B),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return K}function ee(B,q,z){if(B==null)return B;var re=[],ne=0;return V(B,re,"","",function(J){return q.call(z,J,ne++)}),re}function X(B){if(B._status===-1){var q=B._result;q=q(),q.then(function(z){(B._status===0||B._status===-1)&&(B._status=1,B._result=z)},function(z){(B._status===0||B._status===-1)&&(B._status=2,B._result=z)}),B._status===-1&&(B._status=0,B._result=q)}if(B._status===1)return B._result.default;throw B._result}var $=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},O={map:ee,forEach:function(B,q,z){ee(B,function(){q.apply(this,arguments)},z)},count:function(B){var q=0;return ee(B,function(){q++}),q},toArray:function(B){return ee(B,function(q){return q})||[]},only:function(B){if(!G(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return ut.Activity=m,ut.Children=O,ut.Component=S,ut.Fragment=n,ut.Profiler=a,ut.PureComponent=b,ut.StrictMode=r,ut.Suspense=d,ut.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,ut.__COMPILER_RUNTIME={__proto__:null,c:function(B){return D.H.useMemoCache(B)}},ut.cache=function(B){return function(){return B.apply(null,arguments)}},ut.cacheSignal=function(){return null},ut.cloneElement=function(B,q,z){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var re=C({},B.props),ne=B.key;if(q!=null)for(J in q.key!==void 0&&(ne=""+q.key),q)!L.call(q,J)||J==="key"||J==="__self"||J==="__source"||J==="ref"&&q.ref===void 0||(re[J]=q[J]);var J=arguments.length-2;if(J===1)re.children=z;else if(1<J){for(var K=Array(J),P=0;P<J;P++)K[P]=arguments[P+2];re.children=K}return I(B.type,ne,re)},ut.createContext=function(B){return B={$$typeof:u,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:l,_context:B},B},ut.createElement=function(B,q,z){var re,ne={},J=null;if(q!=null)for(re in q.key!==void 0&&(J=""+q.key),q)L.call(q,re)&&re!=="key"&&re!=="__self"&&re!=="__source"&&(ne[re]=q[re]);var K=arguments.length-2;if(K===1)ne.children=z;else if(1<K){for(var P=Array(K),Q=0;Q<K;Q++)P[Q]=arguments[Q+2];ne.children=P}if(B&&B.defaultProps)for(re in K=B.defaultProps,K)ne[re]===void 0&&(ne[re]=K[re]);return I(B,J,ne)},ut.createRef=function(){return{current:null}},ut.forwardRef=function(B){return{$$typeof:c,render:B}},ut.isValidElement=G,ut.lazy=function(B){return{$$typeof:p,_payload:{_status:-1,_result:B},_init:X}},ut.memo=function(B,q){return{$$typeof:h,type:B,compare:q===void 0?null:q}},ut.startTransition=function(B){var q=D.T,z={};D.T=z;try{var re=B(),ne=D.S;ne!==null&&ne(z,re),typeof re=="object"&&re!==null&&typeof re.then=="function"&&re.then(T,$)}catch(J){$(J)}finally{q!==null&&z.types!==null&&(q.types=z.types),D.T=q}},ut.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},ut.use=function(B){return D.H.use(B)},ut.useActionState=function(B,q,z){return D.H.useActionState(B,q,z)},ut.useCallback=function(B,q){return D.H.useCallback(B,q)},ut.useContext=function(B){return D.H.useContext(B)},ut.useDebugValue=function(){},ut.useDeferredValue=function(B,q){return D.H.useDeferredValue(B,q)},ut.useEffect=function(B,q){return D.H.useEffect(B,q)},ut.useEffectEvent=function(B){return D.H.useEffectEvent(B)},ut.useId=function(){return D.H.useId()},ut.useImperativeHandle=function(B,q,z){return D.H.useImperativeHandle(B,q,z)},ut.useInsertionEffect=function(B,q){return D.H.useInsertionEffect(B,q)},ut.useLayoutEffect=function(B,q){return D.H.useLayoutEffect(B,q)},ut.useMemo=function(B,q){return D.H.useMemo(B,q)},ut.useOptimistic=function(B,q){return D.H.useOptimistic(B,q)},ut.useReducer=function(B,q,z){return D.H.useReducer(B,q,z)},ut.useRef=function(B){return D.H.useRef(B)},ut.useState=function(B){return D.H.useState(B)},ut.useSyncExternalStore=function(B,q,z){return D.H.useSyncExternalStore(B,q,z)},ut.useTransition=function(){return D.H.useTransition()},ut.version="19.2.4",ut}var s_;function kd(){return s_||(s_=1,mm.exports=qE()),mm.exports}var E=kd();const oi=Cd(E),KE=VE({__proto__:null,default:oi},[E]);var pm={exports:{}},ul={},gm={exports:{}},xm={};/**
|
|
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 i_;function YE(){return i_||(i_=1,(function(e){function t(V,ee){var X=V.length;V.push(ee);e:for(;0<X;){var $=X-1>>>1,O=V[$];if(0<a(O,ee))V[$]=ee,V[X]=O,X=$;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var ee=V[0],X=V.pop();if(X!==ee){V[0]=X;e:for(var $=0,O=V.length,B=O>>>1;$<B;){var q=2*($+1)-1,z=V[q],re=q+1,ne=V[re];if(0>a(z,X))re<O&&0>a(ne,z)?(V[$]=ne,V[re]=X,$=re):(V[$]=z,V[q]=X,$=q);else if(re<O&&0>a(ne,X))V[$]=ne,V[re]=X,$=re;else break e}}return ee}function a(V,ee){var X=V.sortIndex-ee.sortIndex;return X!==0?X:V.id-ee.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=[],h=[],p=1,m=null,x=3,y=!1,w=!1,C=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;function j(V){for(var ee=n(h);ee!==null;){if(ee.callback===null)r(h);else if(ee.startTime<=V)r(h),ee.sortIndex=ee.expirationTime,t(d,ee);else break;ee=n(h)}}function N(V){if(C=!1,j(V),!w)if(n(d)!==null)w=!0,T||(T=!0,U());else{var ee=n(h);ee!==null&&W(N,ee.startTime-V)}}var T=!1,D=-1,L=5,I=-1;function M(){return _?!0:!(e.unstable_now()-I<L)}function G(){if(_=!1,T){var V=e.unstable_now();I=V;var ee=!0;try{e:{w=!1,C&&(C=!1,v(D),D=-1),y=!0;var X=x;try{t:{for(j(V),m=n(d);m!==null&&!(m.expirationTime>V&&M());){var $=m.callback;if(typeof $=="function"){m.callback=null,x=m.priorityLevel;var O=$(m.expirationTime<=V);if(V=e.unstable_now(),typeof O=="function"){m.callback=O,j(V),ee=!0;break t}m===n(d)&&r(d),j(V)}else r(d);m=n(d)}if(m!==null)ee=!0;else{var B=n(h);B!==null&&W(N,B.startTime-V),ee=!1}}break e}finally{m=null,x=X,y=!1}ee=void 0}}finally{ee?U():T=!1}}}var U;if(typeof b=="function")U=function(){b(G)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,H=R.port2;R.port1.onmessage=G,U=function(){H.postMessage(null)}}else U=function(){S(G,0)};function W(V,ee){D=S(function(){V(e.unstable_now())},ee)}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(V){V.callback=null},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(V){switch(x){case 1:case 2:case 3:var ee=3;break;default:ee=x}var X=x;x=ee;try{return V()}finally{x=X}},e.unstable_requestPaint=function(){_=!0},e.unstable_runWithPriority=function(V,ee){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var X=x;x=V;try{return ee()}finally{x=X}},e.unstable_scheduleCallback=function(V,ee,X){var $=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?$+X:$):X=$,V){case 1:var O=-1;break;case 2:O=250;break;case 5:O=1073741823;break;case 4:O=1e4;break;default:O=5e3}return O=X+O,V={id:p++,callback:ee,priorityLevel:V,startTime:X,expirationTime:O,sortIndex:-1},X>$?(V.sortIndex=X,t(h,V),n(d)===null&&V===n(h)&&(C?(v(D),D=-1):C=!0,W(N,X-$))):(V.sortIndex=O,t(d,V),w||y||(w=!0,T||(T=!0,U()))),V},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(V){var ee=x;return function(){var X=x;x=ee;try{return V.apply(this,arguments)}finally{x=X}}}})(xm)),xm}var a_;function XE(){return a_||(a_=1,gm.exports=YE()),gm.exports}var ym={exports:{}},Ln={};/**
|
|
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 o_;function QE(){if(o_)return Ln;o_=1;var e=kd();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+d+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function l(d,h,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:m==null?null:""+m,children:d,containerInfo:h,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(d,h){if(d==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Ln.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ln.createPortal=function(d,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return l(d,h,null,p)},Ln.flushSync=function(d){var h=u.T,p=r.p;try{if(u.T=null,r.p=2,d)return d()}finally{u.T=h,r.p=p,r.d.f()}},Ln.preconnect=function(d,h){typeof d=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(d,h))},Ln.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},Ln.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var p=h.as,m=c(p,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,y=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:m,integrity:x,fetchPriority:y}):p==="script"&&r.d.X(d,{crossOrigin:m,integrity:x,fetchPriority:y,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Ln.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=c(h.as,h.crossOrigin);r.d.M(d,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(d)},Ln.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,m=c(p,h.crossOrigin);r.d.L(d,p,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Ln.preloadModule=function(d,h){if(typeof d=="string")if(h){var p=c(h.as,h.crossOrigin);r.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(d)},Ln.requestFormReset=function(d){r.d.r(d)},Ln.unstable_batchedUpdates=function(d,h){return d(h)},Ln.useFormState=function(d,h,p){return u.H.useFormState(d,h,p)},Ln.useFormStatus=function(){return u.H.useHostTransitionStatus()},Ln.version="19.2.4",Ln}var l_;function l1(){if(l_)return ym.exports;l_=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(),ym.exports=QE(),ym.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 c_;function JE(){if(c_)return ul;c_=1;var e=XE(),t=kd(),n=l1();function r(s){var o="https://react.dev/errors/"+s;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)o+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+s+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function l(s){var o=s,f=s;if(s.alternate)for(;o.return;)o=o.return;else{s=o;do o=s,(o.flags&4098)!==0&&(f=o.return),s=o.return;while(s)}return o.tag===3?f:null}function u(s){if(s.tag===13){var o=s.memoizedState;if(o===null&&(s=s.alternate,s!==null&&(o=s.memoizedState)),o!==null)return o.dehydrated}return null}function c(s){if(s.tag===31){var o=s.memoizedState;if(o===null&&(s=s.alternate,s!==null&&(o=s.memoizedState)),o!==null)return o.dehydrated}return null}function d(s){if(l(s)!==s)throw Error(r(188))}function h(s){var o=s.alternate;if(!o){if(o=l(s),o===null)throw Error(r(188));return o!==s?null:s}for(var f=s,g=o;;){var k=f.return;if(k===null)break;var A=k.alternate;if(A===null){if(g=k.return,g!==null){f=g;continue}break}if(k.child===A.child){for(A=k.child;A;){if(A===f)return d(k),s;if(A===g)return d(k),o;A=A.sibling}throw Error(r(188))}if(f.return!==g.return)f=k,g=A;else{for(var F=!1,Y=k.child;Y;){if(Y===f){F=!0,f=k,g=A;break}if(Y===g){F=!0,g=k,f=A;break}Y=Y.sibling}if(!F){for(Y=A.child;Y;){if(Y===f){F=!0,f=A,g=k;break}if(Y===g){F=!0,g=A,f=k;break}Y=Y.sibling}if(!F)throw Error(r(189))}}if(f.alternate!==g)throw Error(r(190))}if(f.tag!==3)throw Error(r(188));return f.stateNode.current===f?s:o}function p(s){var o=s.tag;if(o===5||o===26||o===27||o===6)return s;for(s=s.child;s!==null;){if(o=p(s),o!==null)return o;s=s.sibling}return null}var m=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),b=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function U(s){return s===null||typeof s!="object"?null:(s=G&&s[G]||s["@@iterator"],typeof s=="function"?s:null)}var R=Symbol.for("react.client.reference");function H(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===R?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case C:return"Fragment";case S:return"Profiler";case _:return"StrictMode";case N:return"Suspense";case T:return"SuspenseList";case I:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case w:return"Portal";case b:return s.displayName||"Context";case v:return(s._context.displayName||"Context")+".Consumer";case j:var o=s.render;return s=s.displayName,s||(s=o.displayName||o.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case D:return o=s.displayName||null,o!==null?o:H(s.type)||"Memo";case L:o=s._payload,s=s._init;try{return H(s(o))}catch{}}return null}var W=Array.isArray,V=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},$=[],O=-1;function B(s){return{current:s}}function q(s){0>O||(s.current=$[O],$[O]=null,O--)}function z(s,o){O++,$[O]=s.current,s.current=o}var re=B(null),ne=B(null),J=B(null),K=B(null);function P(s,o){switch(z(J,o),z(ne,s),z(re,null),o.nodeType){case 9:case 11:s=(s=o.documentElement)&&(s=s.namespaceURI)?Sv(s):0;break;default:if(s=o.tagName,o=o.namespaceURI)o=Sv(o),s=wv(o,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}q(re),z(re,s)}function Q(){q(re),q(ne),q(J)}function ae(s){s.memoizedState!==null&&z(K,s);var o=re.current,f=wv(o,s.type);o!==f&&(z(ne,s),z(re,f))}function he(s){ne.current===s&&(q(re),q(ne)),K.current===s&&(q(K),il._currentValue=X)}var ce,De;function Re(s){if(ce===void 0)try{throw Error()}catch(f){var o=f.stack.trim().match(/\n( *(at )?)/);ce=o&&o[1]||"",De=-1<f.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+ce+s+De}var $e=!1;function Ge(s,o){if(!s||$e)return"";$e=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(o){var Ae=function(){throw Error()};if(Object.defineProperty(Ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ae,[])}catch(xe){var ge=xe}Reflect.construct(s,[],Ae)}else{try{Ae.call()}catch(xe){ge=xe}s.call(Ae.prototype)}}else{try{throw Error()}catch(xe){ge=xe}(Ae=s())&&typeof Ae.catch=="function"&&Ae.catch(function(){})}}catch(xe){if(xe&&ge&&typeof xe.stack=="string")return[xe.stack,ge.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var A=g.DetermineComponentFrameRoot(),F=A[0],Y=A[1];if(F&&Y){var le=F.split(`
|
|
45
|
+
`),pe=Y.split(`
|
|
46
|
+
`);for(k=g=0;g<le.length&&!le[g].includes("DetermineComponentFrameRoot");)g++;for(;k<pe.length&&!pe[k].includes("DetermineComponentFrameRoot");)k++;if(g===le.length||k===pe.length)for(g=le.length-1,k=pe.length-1;1<=g&&0<=k&&le[g]!==pe[k];)k--;for(;1<=g&&0<=k;g--,k--)if(le[g]!==pe[k]){if(g!==1||k!==1)do if(g--,k--,0>k||le[g]!==pe[k]){var Ce=`
|
|
47
|
+
`+le[g].replace(" at new "," at ");return s.displayName&&Ce.includes("<anonymous>")&&(Ce=Ce.replace("<anonymous>",s.displayName)),Ce}while(1<=g&&0<=k);break}}}finally{$e=!1,Error.prepareStackTrace=f}return(f=s?s.displayName||s.name:"")?Re(f):""}function je(s,o){switch(s.tag){case 26:case 27:case 5:return Re(s.type);case 16:return Re("Lazy");case 13:return s.child!==o&&o!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("SuspenseList");case 0:case 15:return Ge(s.type,!1);case 11:return Ge(s.type.render,!1);case 1:return Ge(s.type,!0);case 31:return Re("Activity");default:return""}}function Ye(s){try{var o="",f=null;do o+=je(s,f),f=s,s=s.return;while(s);return o}catch(g){return`
|
|
48
|
+
Error generating stack: `+g.message+`
|
|
49
|
+
`+g.stack}}var at=Object.prototype.hasOwnProperty,ke=e.unstable_scheduleCallback,ze=e.unstable_cancelCallback,lt=e.unstable_shouldYield,we=e.unstable_requestPaint,He=e.unstable_now,Ve=e.unstable_getCurrentPriorityLevel,Z=e.unstable_ImmediatePriority,oe=e.unstable_UserBlockingPriority,ie=e.unstable_NormalPriority,me=e.unstable_LowPriority,Ue=e.unstable_IdlePriority,Ie=e.log,Ke=e.unstable_setDisableYieldValue,ct=null,et=null;function tt(s){if(typeof Ie=="function"&&Ke(s),et&&typeof et.setStrictMode=="function")try{et.setStrictMode(ct,s)}catch{}}var ot=Math.clz32?Math.clz32:hn,Ct=Math.log,dt=Math.LN2;function hn(s){return s>>>=0,s===0?32:31-(Ct(s)/dt|0)|0}var yn=256,Fn=262144,Vn=4194304;function se(s){var o=s&42;if(o!==0)return o;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function ve(s,o,f){var g=s.pendingLanes;if(g===0)return 0;var k=0,A=s.suspendedLanes,F=s.pingedLanes;s=s.warmLanes;var Y=g&134217727;return Y!==0?(g=Y&~A,g!==0?k=se(g):(F&=Y,F!==0?k=se(F):f||(f=Y&~s,f!==0&&(k=se(f))))):(Y=g&~A,Y!==0?k=se(Y):F!==0?k=se(F):f||(f=g&~s,f!==0&&(k=se(f)))),k===0?0:o!==0&&o!==k&&(o&A)===0&&(A=k&-k,f=o&-o,A>=f||A===32&&(f&4194048)!==0)?o:k}function Ne(s,o){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&o)===0}function Oe(s,o){switch(s){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Je(){var s=Vn;return Vn<<=1,(Vn&62914560)===0&&(Vn=4194304),s}function Dt(s){for(var o=[],f=0;31>f;f++)o.push(s);return o}function wn(s,o){s.pendingLanes|=o,o!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function An(s,o,f,g,k,A){var F=s.pendingLanes;s.pendingLanes=f,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=f,s.entangledLanes&=f,s.errorRecoveryDisabledLanes&=f,s.shellSuspendCounter=0;var Y=s.entanglements,le=s.expirationTimes,pe=s.hiddenUpdates;for(f=F&~f;0<f;){var Ce=31-ot(f),Ae=1<<Ce;Y[Ce]=0,le[Ce]=-1;var ge=pe[Ce];if(ge!==null)for(pe[Ce]=null,Ce=0;Ce<ge.length;Ce++){var xe=ge[Ce];xe!==null&&(xe.lane&=-536870913)}f&=~Ae}g!==0&&yi(s,g,0),A!==0&&k===0&&s.tag!==0&&(s.suspendedLanes|=A&~(F&~o))}function yi(s,o,f){s.pendingLanes|=o,s.suspendedLanes&=~o;var g=31-ot(o);s.entangledLanes|=o,s.entanglements[g]=s.entanglements[g]|1073741824|f&261930}function As(s,o){var f=s.entangledLanes|=o;for(s=s.entanglements;f;){var g=31-ot(f),k=1<<g;k&o|s[g]&o&&(s[g]|=o),f&=~k}}function Ls(s,o){var f=o&-o;return f=(f&42)!==0?1:_e(f),(f&(s.suspendedLanes|o))!==0?0:f}function _e(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 Se(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function Me(){var s=ee.p;return s!==0?s:(s=window.event,s===void 0?32:Gv(s.type))}function We(s,o){var f=ee.p;try{return ee.p=s,o()}finally{ee.p=f}}var Fe=Math.random().toString(36).slice(2),Qe="__reactFiber$"+Fe,nt="__reactProps$"+Fe,Kt="__reactContainer$"+Fe,fn="__reactEvents$"+Fe,tr="__reactListeners$"+Fe,Aj="__reactHandles$"+Fe,cx="__reactResources$"+Fe,vo="__reactMarker$"+Fe;function nh(s){delete s[Qe],delete s[nt],delete s[fn],delete s[tr],delete s[Aj]}function ia(s){var o=s[Qe];if(o)return o;for(var f=s.parentNode;f;){if(o=f[Kt]||f[Qe]){if(f=o.alternate,o.child!==null||f!==null&&f.child!==null)for(s=Av(s);s!==null;){if(f=s[Qe])return f;s=Av(s)}return o}s=f,f=s.parentNode}return null}function aa(s){if(s=s[Qe]||s[Kt]){var o=s.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return s}return null}function _o(s){var o=s.tag;if(o===5||o===26||o===27||o===6)return s.stateNode;throw Error(r(33))}function oa(s){var o=s[cx];return o||(o=s[cx]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function bn(s){s[vo]=!0}var ux=new Set,dx={};function bi(s,o){la(s,o),la(s+"Capture",o)}function la(s,o){for(dx[s]=o,s=0;s<o.length;s++)ux.add(o[s])}var Lj=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]*$"),hx={},fx={};function Dj(s){return at.call(fx,s)?!0:at.call(hx,s)?!1:Lj.test(s)?fx[s]=!0:(hx[s]=!0,!1)}function oc(s,o,f){if(Dj(o))if(f===null)s.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":s.removeAttribute(o);return;case"boolean":var g=o.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){s.removeAttribute(o);return}}s.setAttribute(o,""+f)}}function lc(s,o,f){if(f===null)s.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(o);return}s.setAttribute(o,""+f)}}function es(s,o,f,g){if(g===null)s.removeAttribute(f);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(f);return}s.setAttributeNS(o,f,""+g)}}function hr(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function mx(s){var o=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Rj(s,o,f){var g=Object.getOwnPropertyDescriptor(s.constructor.prototype,o);if(!s.hasOwnProperty(o)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var k=g.get,A=g.set;return Object.defineProperty(s,o,{configurable:!0,get:function(){return k.call(this)},set:function(F){f=""+F,A.call(this,F)}}),Object.defineProperty(s,o,{enumerable:g.enumerable}),{getValue:function(){return f},setValue:function(F){f=""+F},stopTracking:function(){s._valueTracker=null,delete s[o]}}}}function rh(s){if(!s._valueTracker){var o=mx(s)?"checked":"value";s._valueTracker=Rj(s,o,""+s[o])}}function px(s){if(!s)return!1;var o=s._valueTracker;if(!o)return!0;var f=o.getValue(),g="";return s&&(g=mx(s)?s.checked?"true":"false":s.value),s=g,s!==f?(o.setValue(s),!0):!1}function cc(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 Oj=/[\n"\\]/g;function fr(s){return s.replace(Oj,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function sh(s,o,f,g,k,A,F,Y){s.name="",F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"?s.type=F:s.removeAttribute("type"),o!=null?F==="number"?(o===0&&s.value===""||s.value!=o)&&(s.value=""+hr(o)):s.value!==""+hr(o)&&(s.value=""+hr(o)):F!=="submit"&&F!=="reset"||s.removeAttribute("value"),o!=null?ih(s,F,hr(o)):f!=null?ih(s,F,hr(f)):g!=null&&s.removeAttribute("value"),k==null&&A!=null&&(s.defaultChecked=!!A),k!=null&&(s.checked=k&&typeof k!="function"&&typeof k!="symbol"),Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?s.name=""+hr(Y):s.removeAttribute("name")}function gx(s,o,f,g,k,A,F,Y){if(A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"&&(s.type=A),o!=null||f!=null){if(!(A!=="submit"&&A!=="reset"||o!=null)){rh(s);return}f=f!=null?""+hr(f):"",o=o!=null?""+hr(o):f,Y||o===s.value||(s.value=o),s.defaultValue=o}g=g??k,g=typeof g!="function"&&typeof g!="symbol"&&!!g,s.checked=Y?s.checked:!!g,s.defaultChecked=!!g,F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"&&(s.name=F),rh(s)}function ih(s,o,f){o==="number"&&cc(s.ownerDocument)===s||s.defaultValue===""+f||(s.defaultValue=""+f)}function ca(s,o,f,g){if(s=s.options,o){o={};for(var k=0;k<f.length;k++)o["$"+f[k]]=!0;for(f=0;f<s.length;f++)k=o.hasOwnProperty("$"+s[f].value),s[f].selected!==k&&(s[f].selected=k),k&&g&&(s[f].defaultSelected=!0)}else{for(f=""+hr(f),o=null,k=0;k<s.length;k++){if(s[k].value===f){s[k].selected=!0,g&&(s[k].defaultSelected=!0);return}o!==null||s[k].disabled||(o=s[k])}o!==null&&(o.selected=!0)}}function xx(s,o,f){if(o!=null&&(o=""+hr(o),o!==s.value&&(s.value=o),f==null)){s.defaultValue!==o&&(s.defaultValue=o);return}s.defaultValue=f!=null?""+hr(f):""}function yx(s,o,f,g){if(o==null){if(g!=null){if(f!=null)throw Error(r(92));if(W(g)){if(1<g.length)throw Error(r(93));g=g[0]}f=g}f==null&&(f=""),o=f}f=hr(o),s.defaultValue=f,g=s.textContent,g===f&&g!==""&&g!==null&&(s.value=g),rh(s)}function ua(s,o){if(o){var f=s.firstChild;if(f&&f===s.lastChild&&f.nodeType===3){f.nodeValue=o;return}}s.textContent=o}var Ij=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 bx(s,o,f){var g=o.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?g?s.setProperty(o,""):o==="float"?s.cssFloat="":s[o]="":g?s.setProperty(o,f):typeof f!="number"||f===0||Ij.has(o)?o==="float"?s.cssFloat=f:s[o]=(""+f).trim():s[o]=f+"px"}function vx(s,o,f){if(o!=null&&typeof o!="object")throw Error(r(62));if(s=s.style,f!=null){for(var g in f)!f.hasOwnProperty(g)||o!=null&&o.hasOwnProperty(g)||(g.indexOf("--")===0?s.setProperty(g,""):g==="float"?s.cssFloat="":s[g]="");for(var k in o)g=o[k],o.hasOwnProperty(k)&&f[k]!==g&&bx(s,k,g)}else for(var A in o)o.hasOwnProperty(A)&&bx(s,A,o[A])}function ah(s){if(s.indexOf("-")===-1)return!1;switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Mj=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Pj=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function uc(s){return Pj.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function ts(){}var oh=null;function lh(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var da=null,ha=null;function _x(s){var o=aa(s);if(o&&(s=o.stateNode)){var f=s[nt]||null;e:switch(s=o.stateNode,o.type){case"input":if(sh(s,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),o=f.name,f.type==="radio"&&o!=null){for(f=s;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+fr(""+o)+'"][type="radio"]'),o=0;o<f.length;o++){var g=f[o];if(g!==s&&g.form===s.form){var k=g[nt]||null;if(!k)throw Error(r(90));sh(g,k.value,k.defaultValue,k.defaultValue,k.checked,k.defaultChecked,k.type,k.name)}}for(o=0;o<f.length;o++)g=f[o],g.form===s.form&&px(g)}break e;case"textarea":xx(s,f.value,f.defaultValue);break e;case"select":o=f.value,o!=null&&ca(s,!!f.multiple,o,!1)}}}var ch=!1;function Sx(s,o,f){if(ch)return s(o,f);ch=!0;try{var g=s(o);return g}finally{if(ch=!1,(da!==null||ha!==null)&&(Qc(),da&&(o=da,s=ha,ha=da=null,_x(o),s)))for(o=0;o<s.length;o++)_x(s[o])}}function So(s,o){var f=s.stateNode;if(f===null)return null;var g=f[nt]||null;if(g===null)return null;f=g[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(s=s.type,g=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!g;break e;default:s=!1}if(s)return null;if(f&&typeof f!="function")throw Error(r(231,o,typeof f));return f}var ns=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),uh=!1;if(ns)try{var wo={};Object.defineProperty(wo,"passive",{get:function(){uh=!0}}),window.addEventListener("test",wo,wo),window.removeEventListener("test",wo,wo)}catch{uh=!1}var Ds=null,dh=null,dc=null;function wx(){if(dc)return dc;var s,o=dh,f=o.length,g,k="value"in Ds?Ds.value:Ds.textContent,A=k.length;for(s=0;s<f&&o[s]===k[s];s++);var F=f-s;for(g=1;g<=F&&o[f-g]===k[A-g];g++);return dc=k.slice(s,1<g?1-g:void 0)}function hc(s){var o=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&o===13&&(s=13)):s=o,s===10&&(s=13),32<=s||s===13?s:0}function fc(){return!0}function Cx(){return!1}function Wn(s){function o(f,g,k,A,F){this._reactName=f,this._targetInst=k,this.type=g,this.nativeEvent=A,this.target=F,this.currentTarget=null;for(var Y in s)s.hasOwnProperty(Y)&&(f=s[Y],this[Y]=f?f(A):A[Y]);return this.isDefaultPrevented=(A.defaultPrevented!=null?A.defaultPrevented:A.returnValue===!1)?fc:Cx,this.isPropagationStopped=Cx,this}return m(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=fc)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=fc)},persist:function(){},isPersistent:fc}),o}var vi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},mc=Wn(vi),Co=m({},vi,{view:0,detail:0}),Bj=Wn(Co),hh,fh,ko,pc=m({},Co,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ph,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!==ko&&(ko&&s.type==="mousemove"?(hh=s.screenX-ko.screenX,fh=s.screenY-ko.screenY):fh=hh=0,ko=s),hh)},movementY:function(s){return"movementY"in s?s.movementY:fh}}),kx=Wn(pc),$j=m({},pc,{dataTransfer:0}),zj=Wn($j),Hj=m({},Co,{relatedTarget:0}),mh=Wn(Hj),Uj=m({},vi,{animationName:0,elapsedTime:0,pseudoElement:0}),Fj=Wn(Uj),Vj=m({},vi,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Wj=Wn(Vj),Gj=m({},vi,{data:0}),jx=Wn(Gj),qj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Kj={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"},Yj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Xj(s){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(s):(s=Yj[s])?!!o[s]:!1}function ph(){return Xj}var Qj=m({},Co,{key:function(s){if(s.key){var o=qj[s.key]||s.key;if(o!=="Unidentified")return o}return s.type==="keypress"?(s=hc(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Kj[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ph,charCode:function(s){return s.type==="keypress"?hc(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?hc(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Jj=Wn(Qj),Zj=m({},pc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ex=Wn(Zj),e2=m({},Co,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ph}),t2=Wn(e2),n2=m({},vi,{propertyName:0,elapsedTime:0,pseudoElement:0}),r2=Wn(n2),s2=m({},pc,{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}),i2=Wn(s2),a2=m({},vi,{newState:0,oldState:0}),o2=Wn(a2),l2=[9,13,27,32],gh=ns&&"CompositionEvent"in window,jo=null;ns&&"documentMode"in document&&(jo=document.documentMode);var c2=ns&&"TextEvent"in window&&!jo,Nx=ns&&(!gh||jo&&8<jo&&11>=jo),Tx=" ",Ax=!1;function Lx(s,o){switch(s){case"keyup":return l2.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dx(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var fa=!1;function u2(s,o){switch(s){case"compositionend":return Dx(o);case"keypress":return o.which!==32?null:(Ax=!0,Tx);case"textInput":return s=o.data,s===Tx&&Ax?null:s;default:return null}}function d2(s,o){if(fa)return s==="compositionend"||!gh&&Lx(s,o)?(s=wx(),dc=dh=Ds=null,fa=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return Nx&&o.locale!=="ko"?null:o.data;default:return null}}var h2={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 Rx(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o==="input"?!!h2[s.type]:o==="textarea"}function Ox(s,o,f,g){da?ha?ha.push(g):ha=[g]:da=g,o=su(o,"onChange"),0<o.length&&(f=new mc("onChange","change",null,f,g),s.push({event:f,listeners:o}))}var Eo=null,No=null;function f2(s){gv(s,0)}function gc(s){var o=_o(s);if(px(o))return s}function Ix(s,o){if(s==="change")return o}var Mx=!1;if(ns){var xh;if(ns){var yh="oninput"in document;if(!yh){var Px=document.createElement("div");Px.setAttribute("oninput","return;"),yh=typeof Px.oninput=="function"}xh=yh}else xh=!1;Mx=xh&&(!document.documentMode||9<document.documentMode)}function Bx(){Eo&&(Eo.detachEvent("onpropertychange",$x),No=Eo=null)}function $x(s){if(s.propertyName==="value"&&gc(No)){var o=[];Ox(o,No,s,lh(s)),Sx(f2,o)}}function m2(s,o,f){s==="focusin"?(Bx(),Eo=o,No=f,Eo.attachEvent("onpropertychange",$x)):s==="focusout"&&Bx()}function p2(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return gc(No)}function g2(s,o){if(s==="click")return gc(o)}function x2(s,o){if(s==="input"||s==="change")return gc(o)}function y2(s,o){return s===o&&(s!==0||1/s===1/o)||s!==s&&o!==o}var nr=typeof Object.is=="function"?Object.is:y2;function To(s,o){if(nr(s,o))return!0;if(typeof s!="object"||s===null||typeof o!="object"||o===null)return!1;var f=Object.keys(s),g=Object.keys(o);if(f.length!==g.length)return!1;for(g=0;g<f.length;g++){var k=f[g];if(!at.call(o,k)||!nr(s[k],o[k]))return!1}return!0}function zx(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Hx(s,o){var f=zx(s);s=0;for(var g;f;){if(f.nodeType===3){if(g=s+f.textContent.length,s<=o&&g>=o)return{node:f,offset:o-s};s=g}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=zx(f)}}function Ux(s,o){return s&&o?s===o?!0:s&&s.nodeType===3?!1:o&&o.nodeType===3?Ux(s,o.parentNode):"contains"in s?s.contains(o):s.compareDocumentPosition?!!(s.compareDocumentPosition(o)&16):!1:!1}function Fx(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var o=cc(s.document);o instanceof s.HTMLIFrameElement;){try{var f=typeof o.contentWindow.location.href=="string"}catch{f=!1}if(f)s=o.contentWindow;else break;o=cc(s.document)}return o}function bh(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o&&(o==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||o==="textarea"||s.contentEditable==="true")}var b2=ns&&"documentMode"in document&&11>=document.documentMode,ma=null,vh=null,Ao=null,_h=!1;function Vx(s,o,f){var g=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;_h||ma==null||ma!==cc(g)||(g=ma,"selectionStart"in g&&bh(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}),Ao&&To(Ao,g)||(Ao=g,g=su(vh,"onSelect"),0<g.length&&(o=new mc("onSelect","select",null,o,f),s.push({event:o,listeners:g}),o.target=ma)))}function _i(s,o){var f={};return f[s.toLowerCase()]=o.toLowerCase(),f["Webkit"+s]="webkit"+o,f["Moz"+s]="moz"+o,f}var pa={animationend:_i("Animation","AnimationEnd"),animationiteration:_i("Animation","AnimationIteration"),animationstart:_i("Animation","AnimationStart"),transitionrun:_i("Transition","TransitionRun"),transitionstart:_i("Transition","TransitionStart"),transitioncancel:_i("Transition","TransitionCancel"),transitionend:_i("Transition","TransitionEnd")},Sh={},Wx={};ns&&(Wx=document.createElement("div").style,"AnimationEvent"in window||(delete pa.animationend.animation,delete pa.animationiteration.animation,delete pa.animationstart.animation),"TransitionEvent"in window||delete pa.transitionend.transition);function Si(s){if(Sh[s])return Sh[s];if(!pa[s])return s;var o=pa[s],f;for(f in o)if(o.hasOwnProperty(f)&&f in Wx)return Sh[s]=o[f];return s}var Gx=Si("animationend"),qx=Si("animationiteration"),Kx=Si("animationstart"),v2=Si("transitionrun"),_2=Si("transitionstart"),S2=Si("transitioncancel"),Yx=Si("transitionend"),Xx=new Map,wh="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(" ");wh.push("scrollEnd");function Tr(s,o){Xx.set(s,o),bi(o,[s])}var xc=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},mr=[],ga=0,Ch=0;function yc(){for(var s=ga,o=Ch=ga=0;o<s;){var f=mr[o];mr[o++]=null;var g=mr[o];mr[o++]=null;var k=mr[o];mr[o++]=null;var A=mr[o];if(mr[o++]=null,g!==null&&k!==null){var F=g.pending;F===null?k.next=k:(k.next=F.next,F.next=k),g.pending=k}A!==0&&Qx(f,k,A)}}function bc(s,o,f,g){mr[ga++]=s,mr[ga++]=o,mr[ga++]=f,mr[ga++]=g,Ch|=g,s.lanes|=g,s=s.alternate,s!==null&&(s.lanes|=g)}function kh(s,o,f,g){return bc(s,o,f,g),vc(s)}function wi(s,o){return bc(s,null,null,o),vc(s)}function Qx(s,o,f){s.lanes|=f;var g=s.alternate;g!==null&&(g.lanes|=f);for(var k=!1,A=s.return;A!==null;)A.childLanes|=f,g=A.alternate,g!==null&&(g.childLanes|=f),A.tag===22&&(s=A.stateNode,s===null||s._visibility&1||(k=!0)),s=A,A=A.return;return s.tag===3?(A=s.stateNode,k&&o!==null&&(k=31-ot(f),s=A.hiddenUpdates,g=s[k],g===null?s[k]=[o]:g.push(o),o.lane=f|536870912),A):null}function vc(s){if(50<Jo)throw Jo=0,If=null,Error(r(185));for(var o=s.return;o!==null;)s=o,o=s.return;return s.tag===3?s.stateNode:null}var xa={};function w2(s,o,f,g){this.tag=s,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rr(s,o,f,g){return new w2(s,o,f,g)}function jh(s){return s=s.prototype,!(!s||!s.isReactComponent)}function rs(s,o){var f=s.alternate;return f===null?(f=rr(s.tag,o,s.key,s.mode),f.elementType=s.elementType,f.type=s.type,f.stateNode=s.stateNode,f.alternate=s,s.alternate=f):(f.pendingProps=o,f.type=s.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=s.flags&65011712,f.childLanes=s.childLanes,f.lanes=s.lanes,f.child=s.child,f.memoizedProps=s.memoizedProps,f.memoizedState=s.memoizedState,f.updateQueue=s.updateQueue,o=s.dependencies,f.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},f.sibling=s.sibling,f.index=s.index,f.ref=s.ref,f.refCleanup=s.refCleanup,f}function Jx(s,o){s.flags&=65011714;var f=s.alternate;return f===null?(s.childLanes=0,s.lanes=o,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=f.childLanes,s.lanes=f.lanes,s.child=f.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=f.memoizedProps,s.memoizedState=f.memoizedState,s.updateQueue=f.updateQueue,s.type=f.type,o=f.dependencies,s.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),s}function _c(s,o,f,g,k,A){var F=0;if(g=s,typeof s=="function")jh(s)&&(F=1);else if(typeof s=="string")F=NE(s,f,re.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case I:return s=rr(31,f,o,k),s.elementType=I,s.lanes=A,s;case C:return Ci(f.children,k,A,o);case _:F=8,k|=24;break;case S:return s=rr(12,f,o,k|2),s.elementType=S,s.lanes=A,s;case N:return s=rr(13,f,o,k),s.elementType=N,s.lanes=A,s;case T:return s=rr(19,f,o,k),s.elementType=T,s.lanes=A,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case b:F=10;break e;case v:F=9;break e;case j:F=11;break e;case D:F=14;break e;case L:F=16,g=null;break e}F=29,f=Error(r(130,s===null?"null":typeof s,"")),g=null}return o=rr(F,f,o,k),o.elementType=s,o.type=g,o.lanes=A,o}function Ci(s,o,f,g){return s=rr(7,s,g,o),s.lanes=f,s}function Eh(s,o,f){return s=rr(6,s,null,o),s.lanes=f,s}function Zx(s){var o=rr(18,null,null,0);return o.stateNode=s,o}function Nh(s,o,f){return o=rr(4,s.children!==null?s.children:[],s.key,o),o.lanes=f,o.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},o}var ey=new WeakMap;function pr(s,o){if(typeof s=="object"&&s!==null){var f=ey.get(s);return f!==void 0?f:(o={value:s,source:o,stack:Ye(o)},ey.set(s,o),o)}return{value:s,source:o,stack:Ye(o)}}var ya=[],ba=0,Sc=null,Lo=0,gr=[],xr=0,Rs=null,zr=1,Hr="";function ss(s,o){ya[ba++]=Lo,ya[ba++]=Sc,Sc=s,Lo=o}function ty(s,o,f){gr[xr++]=zr,gr[xr++]=Hr,gr[xr++]=Rs,Rs=s;var g=zr;s=Hr;var k=32-ot(g)-1;g&=~(1<<k),f+=1;var A=32-ot(o)+k;if(30<A){var F=k-k%5;A=(g&(1<<F)-1).toString(32),g>>=F,k-=F,zr=1<<32-ot(o)+k|f<<k|g,Hr=A+s}else zr=1<<A|f<<k|g,Hr=s}function Th(s){s.return!==null&&(ss(s,1),ty(s,1,0))}function Ah(s){for(;s===Sc;)Sc=ya[--ba],ya[ba]=null,Lo=ya[--ba],ya[ba]=null;for(;s===Rs;)Rs=gr[--xr],gr[xr]=null,Hr=gr[--xr],gr[xr]=null,zr=gr[--xr],gr[xr]=null}function ny(s,o){gr[xr++]=zr,gr[xr++]=Hr,gr[xr++]=Rs,zr=o.id,Hr=o.overflow,Rs=s}var Cn=null,Gt=null,kt=!1,Os=null,yr=!1,Lh=Error(r(519));function Is(s){var o=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Do(pr(o,s)),Lh}function ry(s){var o=s.stateNode,f=s.type,g=s.memoizedProps;switch(o[Qe]=s,o[nt]=g,f){case"dialog":bt("cancel",o),bt("close",o);break;case"iframe":case"object":case"embed":bt("load",o);break;case"video":case"audio":for(f=0;f<el.length;f++)bt(el[f],o);break;case"source":bt("error",o);break;case"img":case"image":case"link":bt("error",o),bt("load",o);break;case"details":bt("toggle",o);break;case"input":bt("invalid",o),gx(o,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":bt("invalid",o);break;case"textarea":bt("invalid",o),yx(o,g.value,g.defaultValue,g.children)}f=g.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||o.textContent===""+f||g.suppressHydrationWarning===!0||vv(o.textContent,f)?(g.popover!=null&&(bt("beforetoggle",o),bt("toggle",o)),g.onScroll!=null&&bt("scroll",o),g.onScrollEnd!=null&&bt("scrollend",o),g.onClick!=null&&(o.onclick=ts),o=!0):o=!1,o||Is(s,!0)}function sy(s){for(Cn=s.return;Cn;)switch(Cn.tag){case 5:case 31:case 13:yr=!1;return;case 27:case 3:yr=!0;return;default:Cn=Cn.return}}function va(s){if(s!==Cn)return!1;if(!kt)return sy(s),kt=!0,!1;var o=s.tag,f;if((f=o!==3&&o!==27)&&((f=o===5)&&(f=s.type,f=!(f!=="form"&&f!=="button")||Xf(s.type,s.memoizedProps)),f=!f),f&&Gt&&Is(s),sy(s),o===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Gt=Tv(s)}else if(o===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Gt=Tv(s)}else o===27?(o=Gt,Ys(s.type)?(s=tm,tm=null,Gt=s):Gt=o):Gt=Cn?vr(s.stateNode.nextSibling):null;return!0}function ki(){Gt=Cn=null,kt=!1}function Dh(){var s=Os;return s!==null&&(Yn===null?Yn=s:Yn.push.apply(Yn,s),Os=null),s}function Do(s){Os===null?Os=[s]:Os.push(s)}var Rh=B(null),ji=null,is=null;function Ms(s,o,f){z(Rh,o._currentValue),o._currentValue=f}function as(s){s._currentValue=Rh.current,q(Rh)}function Oh(s,o,f){for(;s!==null;){var g=s.alternate;if((s.childLanes&o)!==o?(s.childLanes|=o,g!==null&&(g.childLanes|=o)):g!==null&&(g.childLanes&o)!==o&&(g.childLanes|=o),s===f)break;s=s.return}}function Ih(s,o,f,g){var k=s.child;for(k!==null&&(k.return=s);k!==null;){var A=k.dependencies;if(A!==null){var F=k.child;A=A.firstContext;e:for(;A!==null;){var Y=A;A=k;for(var le=0;le<o.length;le++)if(Y.context===o[le]){A.lanes|=f,Y=A.alternate,Y!==null&&(Y.lanes|=f),Oh(A.return,f,s),g||(F=null);break e}A=Y.next}}else if(k.tag===18){if(F=k.return,F===null)throw Error(r(341));F.lanes|=f,A=F.alternate,A!==null&&(A.lanes|=f),Oh(F,f,s),F=null}else F=k.child;if(F!==null)F.return=k;else for(F=k;F!==null;){if(F===s){F=null;break}if(k=F.sibling,k!==null){k.return=F.return,F=k;break}F=F.return}k=F}}function _a(s,o,f,g){s=null;for(var k=o,A=!1;k!==null;){if(!A){if((k.flags&524288)!==0)A=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var F=k.alternate;if(F===null)throw Error(r(387));if(F=F.memoizedProps,F!==null){var Y=k.type;nr(k.pendingProps.value,F.value)||(s!==null?s.push(Y):s=[Y])}}else if(k===K.current){if(F=k.alternate,F===null)throw Error(r(387));F.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(s!==null?s.push(il):s=[il])}k=k.return}s!==null&&Ih(o,s,f,g),o.flags|=262144}function wc(s){for(s=s.firstContext;s!==null;){if(!nr(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function Ei(s){ji=s,is=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function kn(s){return iy(ji,s)}function Cc(s,o){return ji===null&&Ei(s),iy(s,o)}function iy(s,o){var f=o._currentValue;if(o={context:o,memoizedValue:f,next:null},is===null){if(s===null)throw Error(r(308));is=o,s.dependencies={lanes:0,firstContext:o},s.flags|=524288}else is=is.next=o;return f}var C2=typeof AbortController<"u"?AbortController:function(){var s=[],o=this.signal={aborted:!1,addEventListener:function(f,g){s.push(g)}};this.abort=function(){o.aborted=!0,s.forEach(function(f){return f()})}},k2=e.unstable_scheduleCallback,j2=e.unstable_NormalPriority,rn={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Mh(){return{controller:new C2,data:new Map,refCount:0}}function Ro(s){s.refCount--,s.refCount===0&&k2(j2,function(){s.controller.abort()})}var Oo=null,Ph=0,Sa=0,wa=null;function E2(s,o){if(Oo===null){var f=Oo=[];Ph=0,Sa=Hf(),wa={status:"pending",value:void 0,then:function(g){f.push(g)}}}return Ph++,o.then(ay,ay),o}function ay(){if(--Ph===0&&Oo!==null){wa!==null&&(wa.status="fulfilled");var s=Oo;Oo=null,Sa=0,wa=null;for(var o=0;o<s.length;o++)(0,s[o])()}}function N2(s,o){var f=[],g={status:"pending",value:null,reason:null,then:function(k){f.push(k)}};return s.then(function(){g.status="fulfilled",g.value=o;for(var k=0;k<f.length;k++)(0,f[k])(o)},function(k){for(g.status="rejected",g.reason=k,k=0;k<f.length;k++)(0,f[k])(void 0)}),g}var oy=V.S;V.S=function(s,o){Vb=He(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&E2(s,o),oy!==null&&oy(s,o)};var Ni=B(null);function Bh(){var s=Ni.current;return s!==null?s:$t.pooledCache}function kc(s,o){o===null?z(Ni,Ni.current):z(Ni,o.pool)}function ly(){var s=Bh();return s===null?null:{parent:rn._currentValue,pool:s}}var Ca=Error(r(460)),$h=Error(r(474)),jc=Error(r(542)),Ec={then:function(){}};function cy(s){return s=s.status,s==="fulfilled"||s==="rejected"}function uy(s,o,f){switch(f=s[f],f===void 0?s.push(o):f!==o&&(o.then(ts,ts),o=f),o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,hy(s),s;default:if(typeof o.status=="string")o.then(ts,ts);else{if(s=$t,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=o,s.status="pending",s.then(function(g){if(o.status==="pending"){var k=o;k.status="fulfilled",k.value=g}},function(g){if(o.status==="pending"){var k=o;k.status="rejected",k.reason=g}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,hy(s),s}throw Ai=o,Ca}}function Ti(s){try{var o=s._init;return o(s._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(Ai=f,Ca):f}}var Ai=null;function dy(){if(Ai===null)throw Error(r(459));var s=Ai;return Ai=null,s}function hy(s){if(s===Ca||s===jc)throw Error(r(483))}var ka=null,Io=0;function Nc(s){var o=Io;return Io+=1,ka===null&&(ka=[]),uy(ka,s,o)}function Mo(s,o){o=o.props.ref,s.ref=o!==void 0?o:null}function Tc(s,o){throw o.$$typeof===x?Error(r(525)):(s=Object.prototype.toString.call(o),Error(r(31,s==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":s)))}function fy(s){function o(de,ue){if(s){var fe=de.deletions;fe===null?(de.deletions=[ue],de.flags|=16):fe.push(ue)}}function f(de,ue){if(!s)return null;for(;ue!==null;)o(de,ue),ue=ue.sibling;return null}function g(de){for(var ue=new Map;de!==null;)de.key!==null?ue.set(de.key,de):ue.set(de.index,de),de=de.sibling;return ue}function k(de,ue){return de=rs(de,ue),de.index=0,de.sibling=null,de}function A(de,ue,fe){return de.index=fe,s?(fe=de.alternate,fe!==null?(fe=fe.index,fe<ue?(de.flags|=67108866,ue):fe):(de.flags|=67108866,ue)):(de.flags|=1048576,ue)}function F(de){return s&&de.alternate===null&&(de.flags|=67108866),de}function Y(de,ue,fe,Ee){return ue===null||ue.tag!==6?(ue=Eh(fe,de.mode,Ee),ue.return=de,ue):(ue=k(ue,fe),ue.return=de,ue)}function le(de,ue,fe,Ee){var Ze=fe.type;return Ze===C?Ce(de,ue,fe.props.children,Ee,fe.key):ue!==null&&(ue.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===L&&Ti(Ze)===ue.type)?(ue=k(ue,fe.props),Mo(ue,fe),ue.return=de,ue):(ue=_c(fe.type,fe.key,fe.props,null,de.mode,Ee),Mo(ue,fe),ue.return=de,ue)}function pe(de,ue,fe,Ee){return ue===null||ue.tag!==4||ue.stateNode.containerInfo!==fe.containerInfo||ue.stateNode.implementation!==fe.implementation?(ue=Nh(fe,de.mode,Ee),ue.return=de,ue):(ue=k(ue,fe.children||[]),ue.return=de,ue)}function Ce(de,ue,fe,Ee,Ze){return ue===null||ue.tag!==7?(ue=Ci(fe,de.mode,Ee,Ze),ue.return=de,ue):(ue=k(ue,fe),ue.return=de,ue)}function Ae(de,ue,fe){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return ue=Eh(""+ue,de.mode,fe),ue.return=de,ue;if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case y:return fe=_c(ue.type,ue.key,ue.props,null,de.mode,fe),Mo(fe,ue),fe.return=de,fe;case w:return ue=Nh(ue,de.mode,fe),ue.return=de,ue;case L:return ue=Ti(ue),Ae(de,ue,fe)}if(W(ue)||U(ue))return ue=Ci(ue,de.mode,fe,null),ue.return=de,ue;if(typeof ue.then=="function")return Ae(de,Nc(ue),fe);if(ue.$$typeof===b)return Ae(de,Cc(de,ue),fe);Tc(de,ue)}return null}function ge(de,ue,fe,Ee){var Ze=ue!==null?ue.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return Ze!==null?null:Y(de,ue,""+fe,Ee);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case y:return fe.key===Ze?le(de,ue,fe,Ee):null;case w:return fe.key===Ze?pe(de,ue,fe,Ee):null;case L:return fe=Ti(fe),ge(de,ue,fe,Ee)}if(W(fe)||U(fe))return Ze!==null?null:Ce(de,ue,fe,Ee,null);if(typeof fe.then=="function")return ge(de,ue,Nc(fe),Ee);if(fe.$$typeof===b)return ge(de,ue,Cc(de,fe),Ee);Tc(de,fe)}return null}function xe(de,ue,fe,Ee,Ze){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint")return de=de.get(fe)||null,Y(ue,de,""+Ee,Ze);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case y:return de=de.get(Ee.key===null?fe:Ee.key)||null,le(ue,de,Ee,Ze);case w:return de=de.get(Ee.key===null?fe:Ee.key)||null,pe(ue,de,Ee,Ze);case L:return Ee=Ti(Ee),xe(de,ue,fe,Ee,Ze)}if(W(Ee)||U(Ee))return de=de.get(fe)||null,Ce(ue,de,Ee,Ze,null);if(typeof Ee.then=="function")return xe(de,ue,fe,Nc(Ee),Ze);if(Ee.$$typeof===b)return xe(de,ue,fe,Cc(ue,Ee),Ze);Tc(ue,Ee)}return null}function qe(de,ue,fe,Ee){for(var Ze=null,Nt=null,Xe=ue,mt=ue=0,wt=null;Xe!==null&&mt<fe.length;mt++){Xe.index>mt?(wt=Xe,Xe=null):wt=Xe.sibling;var Tt=ge(de,Xe,fe[mt],Ee);if(Tt===null){Xe===null&&(Xe=wt);break}s&&Xe&&Tt.alternate===null&&o(de,Xe),ue=A(Tt,ue,mt),Nt===null?Ze=Tt:Nt.sibling=Tt,Nt=Tt,Xe=wt}if(mt===fe.length)return f(de,Xe),kt&&ss(de,mt),Ze;if(Xe===null){for(;mt<fe.length;mt++)Xe=Ae(de,fe[mt],Ee),Xe!==null&&(ue=A(Xe,ue,mt),Nt===null?Ze=Xe:Nt.sibling=Xe,Nt=Xe);return kt&&ss(de,mt),Ze}for(Xe=g(Xe);mt<fe.length;mt++)wt=xe(Xe,de,mt,fe[mt],Ee),wt!==null&&(s&&wt.alternate!==null&&Xe.delete(wt.key===null?mt:wt.key),ue=A(wt,ue,mt),Nt===null?Ze=wt:Nt.sibling=wt,Nt=wt);return s&&Xe.forEach(function(ei){return o(de,ei)}),kt&&ss(de,mt),Ze}function it(de,ue,fe,Ee){if(fe==null)throw Error(r(151));for(var Ze=null,Nt=null,Xe=ue,mt=ue=0,wt=null,Tt=fe.next();Xe!==null&&!Tt.done;mt++,Tt=fe.next()){Xe.index>mt?(wt=Xe,Xe=null):wt=Xe.sibling;var ei=ge(de,Xe,Tt.value,Ee);if(ei===null){Xe===null&&(Xe=wt);break}s&&Xe&&ei.alternate===null&&o(de,Xe),ue=A(ei,ue,mt),Nt===null?Ze=ei:Nt.sibling=ei,Nt=ei,Xe=wt}if(Tt.done)return f(de,Xe),kt&&ss(de,mt),Ze;if(Xe===null){for(;!Tt.done;mt++,Tt=fe.next())Tt=Ae(de,Tt.value,Ee),Tt!==null&&(ue=A(Tt,ue,mt),Nt===null?Ze=Tt:Nt.sibling=Tt,Nt=Tt);return kt&&ss(de,mt),Ze}for(Xe=g(Xe);!Tt.done;mt++,Tt=fe.next())Tt=xe(Xe,de,mt,Tt.value,Ee),Tt!==null&&(s&&Tt.alternate!==null&&Xe.delete(Tt.key===null?mt:Tt.key),ue=A(Tt,ue,mt),Nt===null?Ze=Tt:Nt.sibling=Tt,Nt=Tt);return s&&Xe.forEach(function($E){return o(de,$E)}),kt&&ss(de,mt),Ze}function Pt(de,ue,fe,Ee){if(typeof fe=="object"&&fe!==null&&fe.type===C&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case y:e:{for(var Ze=fe.key;ue!==null;){if(ue.key===Ze){if(Ze=fe.type,Ze===C){if(ue.tag===7){f(de,ue.sibling),Ee=k(ue,fe.props.children),Ee.return=de,de=Ee;break e}}else if(ue.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===L&&Ti(Ze)===ue.type){f(de,ue.sibling),Ee=k(ue,fe.props),Mo(Ee,fe),Ee.return=de,de=Ee;break e}f(de,ue);break}else o(de,ue);ue=ue.sibling}fe.type===C?(Ee=Ci(fe.props.children,de.mode,Ee,fe.key),Ee.return=de,de=Ee):(Ee=_c(fe.type,fe.key,fe.props,null,de.mode,Ee),Mo(Ee,fe),Ee.return=de,de=Ee)}return F(de);case w:e:{for(Ze=fe.key;ue!==null;){if(ue.key===Ze)if(ue.tag===4&&ue.stateNode.containerInfo===fe.containerInfo&&ue.stateNode.implementation===fe.implementation){f(de,ue.sibling),Ee=k(ue,fe.children||[]),Ee.return=de,de=Ee;break e}else{f(de,ue);break}else o(de,ue);ue=ue.sibling}Ee=Nh(fe,de.mode,Ee),Ee.return=de,de=Ee}return F(de);case L:return fe=Ti(fe),Pt(de,ue,fe,Ee)}if(W(fe))return qe(de,ue,fe,Ee);if(U(fe)){if(Ze=U(fe),typeof Ze!="function")throw Error(r(150));return fe=Ze.call(fe),it(de,ue,fe,Ee)}if(typeof fe.then=="function")return Pt(de,ue,Nc(fe),Ee);if(fe.$$typeof===b)return Pt(de,ue,Cc(de,fe),Ee);Tc(de,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint"?(fe=""+fe,ue!==null&&ue.tag===6?(f(de,ue.sibling),Ee=k(ue,fe),Ee.return=de,de=Ee):(f(de,ue),Ee=Eh(fe,de.mode,Ee),Ee.return=de,de=Ee),F(de)):f(de,ue)}return function(de,ue,fe,Ee){try{Io=0;var Ze=Pt(de,ue,fe,Ee);return ka=null,Ze}catch(Xe){if(Xe===Ca||Xe===jc)throw Xe;var Nt=rr(29,Xe,null,de.mode);return Nt.lanes=Ee,Nt.return=de,Nt}finally{}}}var Li=fy(!0),my=fy(!1),Ps=!1;function zh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hh(s,o){s=s.updateQueue,o.updateQueue===s&&(o.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function Bs(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function $s(s,o,f){var g=s.updateQueue;if(g===null)return null;if(g=g.shared,(At&2)!==0){var k=g.pending;return k===null?o.next=o:(o.next=k.next,k.next=o),g.pending=o,o=vc(s),Qx(s,null,f),o}return bc(s,g,o,f),vc(s)}function Po(s,o,f){if(o=o.updateQueue,o!==null&&(o=o.shared,(f&4194048)!==0)){var g=o.lanes;g&=s.pendingLanes,f|=g,o.lanes=f,As(s,f)}}function Uh(s,o){var f=s.updateQueue,g=s.alternate;if(g!==null&&(g=g.updateQueue,f===g)){var k=null,A=null;if(f=f.firstBaseUpdate,f!==null){do{var F={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};A===null?k=A=F:A=A.next=F,f=f.next}while(f!==null);A===null?k=A=o:A=A.next=o}else k=A=o;f={baseState:g.baseState,firstBaseUpdate:k,lastBaseUpdate:A,shared:g.shared,callbacks:g.callbacks},s.updateQueue=f;return}s=f.lastBaseUpdate,s===null?f.firstBaseUpdate=o:s.next=o,f.lastBaseUpdate=o}var Fh=!1;function Bo(){if(Fh){var s=wa;if(s!==null)throw s}}function $o(s,o,f,g){Fh=!1;var k=s.updateQueue;Ps=!1;var A=k.firstBaseUpdate,F=k.lastBaseUpdate,Y=k.shared.pending;if(Y!==null){k.shared.pending=null;var le=Y,pe=le.next;le.next=null,F===null?A=pe:F.next=pe,F=le;var Ce=s.alternate;Ce!==null&&(Ce=Ce.updateQueue,Y=Ce.lastBaseUpdate,Y!==F&&(Y===null?Ce.firstBaseUpdate=pe:Y.next=pe,Ce.lastBaseUpdate=le))}if(A!==null){var Ae=k.baseState;F=0,Ce=pe=le=null,Y=A;do{var ge=Y.lane&-536870913,xe=ge!==Y.lane;if(xe?(St&ge)===ge:(g&ge)===ge){ge!==0&&ge===Sa&&(Fh=!0),Ce!==null&&(Ce=Ce.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var qe=s,it=Y;ge=o;var Pt=f;switch(it.tag){case 1:if(qe=it.payload,typeof qe=="function"){Ae=qe.call(Pt,Ae,ge);break e}Ae=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=it.payload,ge=typeof qe=="function"?qe.call(Pt,Ae,ge):qe,ge==null)break e;Ae=m({},Ae,ge);break e;case 2:Ps=!0}}ge=Y.callback,ge!==null&&(s.flags|=64,xe&&(s.flags|=8192),xe=k.callbacks,xe===null?k.callbacks=[ge]:xe.push(ge))}else xe={lane:ge,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},Ce===null?(pe=Ce=xe,le=Ae):Ce=Ce.next=xe,F|=ge;if(Y=Y.next,Y===null){if(Y=k.shared.pending,Y===null)break;xe=Y,Y=xe.next,xe.next=null,k.lastBaseUpdate=xe,k.shared.pending=null}}while(!0);Ce===null&&(le=Ae),k.baseState=le,k.firstBaseUpdate=pe,k.lastBaseUpdate=Ce,A===null&&(k.shared.lanes=0),Vs|=F,s.lanes=F,s.memoizedState=Ae}}function py(s,o){if(typeof s!="function")throw Error(r(191,s));s.call(o)}function gy(s,o){var f=s.callbacks;if(f!==null)for(s.callbacks=null,s=0;s<f.length;s++)py(f[s],o)}var ja=B(null),Ac=B(0);function xy(s,o){s=ps,z(Ac,s),z(ja,o),ps=s|o.baseLanes}function Vh(){z(Ac,ps),z(ja,ja.current)}function Wh(){ps=Ac.current,q(ja),q(Ac)}var sr=B(null),br=null;function zs(s){var o=s.alternate;z(en,en.current&1),z(sr,s),br===null&&(o===null||ja.current!==null||o.memoizedState!==null)&&(br=s)}function Gh(s){z(en,en.current),z(sr,s),br===null&&(br=s)}function yy(s){s.tag===22?(z(en,en.current),z(sr,s),br===null&&(br=s)):Hs()}function Hs(){z(en,en.current),z(sr,sr.current)}function ir(s){q(sr),br===s&&(br=null),q(en)}var en=B(0);function Lc(s){for(var o=s;o!==null;){if(o.tag===13){var f=o.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||Zf(f)||em(f)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var os=0,ft=null,It=null,sn=null,Dc=!1,Ea=!1,Di=!1,Rc=0,zo=0,Na=null,T2=0;function Jt(){throw Error(r(321))}function qh(s,o){if(o===null)return!1;for(var f=0;f<o.length&&f<s.length;f++)if(!nr(s[f],o[f]))return!1;return!0}function Kh(s,o,f,g,k,A){return os=A,ft=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,V.H=s===null||s.memoizedState===null?tb:uf,Di=!1,A=f(g,k),Di=!1,Ea&&(A=vy(o,f,g,k)),by(s),A}function by(s){V.H=Fo;var o=It!==null&&It.next!==null;if(os=0,sn=It=ft=null,Dc=!1,zo=0,Na=null,o)throw Error(r(300));s===null||an||(s=s.dependencies,s!==null&&wc(s)&&(an=!0))}function vy(s,o,f,g){ft=s;var k=0;do{if(Ea&&(Na=null),zo=0,Ea=!1,25<=k)throw Error(r(301));if(k+=1,sn=It=null,s.updateQueue!=null){var A=s.updateQueue;A.lastEffect=null,A.events=null,A.stores=null,A.memoCache!=null&&(A.memoCache.index=0)}V.H=nb,A=o(f,g)}while(Ea);return A}function A2(){var s=V.H,o=s.useState()[0];return o=typeof o.then=="function"?Ho(o):o,s=s.useState()[0],(It!==null?It.memoizedState:null)!==s&&(ft.flags|=1024),o}function Yh(){var s=Rc!==0;return Rc=0,s}function Xh(s,o,f){o.updateQueue=s.updateQueue,o.flags&=-2053,s.lanes&=~f}function Qh(s){if(Dc){for(s=s.memoizedState;s!==null;){var o=s.queue;o!==null&&(o.pending=null),s=s.next}Dc=!1}os=0,sn=It=ft=null,Ea=!1,zo=Rc=0,Na=null}function Bn(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return sn===null?ft.memoizedState=sn=s:sn=sn.next=s,sn}function tn(){if(It===null){var s=ft.alternate;s=s!==null?s.memoizedState:null}else s=It.next;var o=sn===null?ft.memoizedState:sn.next;if(o!==null)sn=o,It=s;else{if(s===null)throw ft.alternate===null?Error(r(467)):Error(r(310));It=s,s={memoizedState:It.memoizedState,baseState:It.baseState,baseQueue:It.baseQueue,queue:It.queue,next:null},sn===null?ft.memoizedState=sn=s:sn=sn.next=s}return sn}function Oc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ho(s){var o=zo;return zo+=1,Na===null&&(Na=[]),s=uy(Na,s,o),o=ft,(sn===null?o.memoizedState:sn.next)===null&&(o=o.alternate,V.H=o===null||o.memoizedState===null?tb:uf),s}function Ic(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return Ho(s);if(s.$$typeof===b)return kn(s)}throw Error(r(438,String(s)))}function Jh(s){var o=null,f=ft.updateQueue;if(f!==null&&(o=f.memoCache),o==null){var g=ft.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(o={data:g.data.map(function(k){return k.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),f===null&&(f=Oc(),ft.updateQueue=f),f.memoCache=o,f=o.data[o.index],f===void 0)for(f=o.data[o.index]=Array(s),g=0;g<s;g++)f[g]=M;return o.index++,f}function ls(s,o){return typeof o=="function"?o(s):o}function Mc(s){var o=tn();return Zh(o,It,s)}function Zh(s,o,f){var g=s.queue;if(g===null)throw Error(r(311));g.lastRenderedReducer=f;var k=s.baseQueue,A=g.pending;if(A!==null){if(k!==null){var F=k.next;k.next=A.next,A.next=F}o.baseQueue=k=A,g.pending=null}if(A=s.baseState,k===null)s.memoizedState=A;else{o=k.next;var Y=F=null,le=null,pe=o,Ce=!1;do{var Ae=pe.lane&-536870913;if(Ae!==pe.lane?(St&Ae)===Ae:(os&Ae)===Ae){var ge=pe.revertLane;if(ge===0)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null}),Ae===Sa&&(Ce=!0);else if((os&ge)===ge){pe=pe.next,ge===Sa&&(Ce=!0);continue}else Ae={lane:0,revertLane:pe.revertLane,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},le===null?(Y=le=Ae,F=A):le=le.next=Ae,ft.lanes|=ge,Vs|=ge;Ae=pe.action,Di&&f(A,Ae),A=pe.hasEagerState?pe.eagerState:f(A,Ae)}else ge={lane:Ae,revertLane:pe.revertLane,gesture:pe.gesture,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},le===null?(Y=le=ge,F=A):le=le.next=ge,ft.lanes|=Ae,Vs|=Ae;pe=pe.next}while(pe!==null&&pe!==o);if(le===null?F=A:le.next=Y,!nr(A,s.memoizedState)&&(an=!0,Ce&&(f=wa,f!==null)))throw f;s.memoizedState=A,s.baseState=F,s.baseQueue=le,g.lastRenderedState=A}return k===null&&(g.lanes=0),[s.memoizedState,g.dispatch]}function ef(s){var o=tn(),f=o.queue;if(f===null)throw Error(r(311));f.lastRenderedReducer=s;var g=f.dispatch,k=f.pending,A=o.memoizedState;if(k!==null){f.pending=null;var F=k=k.next;do A=s(A,F.action),F=F.next;while(F!==k);nr(A,o.memoizedState)||(an=!0),o.memoizedState=A,o.baseQueue===null&&(o.baseState=A),f.lastRenderedState=A}return[A,g]}function _y(s,o,f){var g=ft,k=tn(),A=kt;if(A){if(f===void 0)throw Error(r(407));f=f()}else f=o();var F=!nr((It||k).memoizedState,f);if(F&&(k.memoizedState=f,an=!0),k=k.queue,rf(Cy.bind(null,g,k,s),[s]),k.getSnapshot!==o||F||sn!==null&&sn.memoizedState.tag&1){if(g.flags|=2048,Ta(9,{destroy:void 0},wy.bind(null,g,k,f,o),null),$t===null)throw Error(r(349));A||(os&127)!==0||Sy(g,o,f)}return f}function Sy(s,o,f){s.flags|=16384,s={getSnapshot:o,value:f},o=ft.updateQueue,o===null?(o=Oc(),ft.updateQueue=o,o.stores=[s]):(f=o.stores,f===null?o.stores=[s]:f.push(s))}function wy(s,o,f,g){o.value=f,o.getSnapshot=g,ky(o)&&jy(s)}function Cy(s,o,f){return f(function(){ky(o)&&jy(s)})}function ky(s){var o=s.getSnapshot;s=s.value;try{var f=o();return!nr(s,f)}catch{return!0}}function jy(s){var o=wi(s,2);o!==null&&Xn(o,s,2)}function tf(s){var o=Bn();if(typeof s=="function"){var f=s;if(s=f(),Di){tt(!0);try{f()}finally{tt(!1)}}}return o.memoizedState=o.baseState=s,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ls,lastRenderedState:s},o}function Ey(s,o,f,g){return s.baseState=f,Zh(s,It,typeof g=="function"?g:ls)}function L2(s,o,f,g,k){if($c(s))throw Error(r(485));if(s=o.action,s!==null){var A={payload:k,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(F){A.listeners.push(F)}};V.T!==null?f(!0):A.isTransition=!1,g(A),f=o.pending,f===null?(A.next=o.pending=A,Ny(o,A)):(A.next=f.next,o.pending=f.next=A)}}function Ny(s,o){var f=o.action,g=o.payload,k=s.state;if(o.isTransition){var A=V.T,F={};V.T=F;try{var Y=f(k,g),le=V.S;le!==null&&le(F,Y),Ty(s,o,Y)}catch(pe){nf(s,o,pe)}finally{A!==null&&F.types!==null&&(A.types=F.types),V.T=A}}else try{A=f(k,g),Ty(s,o,A)}catch(pe){nf(s,o,pe)}}function Ty(s,o,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(g){Ay(s,o,g)},function(g){return nf(s,o,g)}):Ay(s,o,f)}function Ay(s,o,f){o.status="fulfilled",o.value=f,Ly(o),s.state=f,o=s.pending,o!==null&&(f=o.next,f===o?s.pending=null:(f=f.next,o.next=f,Ny(s,f)))}function nf(s,o,f){var g=s.pending;if(s.pending=null,g!==null){g=g.next;do o.status="rejected",o.reason=f,Ly(o),o=o.next;while(o!==g)}s.action=null}function Ly(s){s=s.listeners;for(var o=0;o<s.length;o++)(0,s[o])()}function Dy(s,o){return o}function Ry(s,o){if(kt){var f=$t.formState;if(f!==null){e:{var g=ft;if(kt){if(Gt){t:{for(var k=Gt,A=yr;k.nodeType!==8;){if(!A){k=null;break t}if(k=vr(k.nextSibling),k===null){k=null;break t}}A=k.data,k=A==="F!"||A==="F"?k:null}if(k){Gt=vr(k.nextSibling),g=k.data==="F!";break e}}Is(g)}g=!1}g&&(o=f[0])}}return f=Bn(),f.memoizedState=f.baseState=o,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Dy,lastRenderedState:o},f.queue=g,f=Jy.bind(null,ft,g),g.dispatch=f,g=tf(!1),A=cf.bind(null,ft,!1,g.queue),g=Bn(),k={state:o,dispatch:null,action:s,pending:null},g.queue=k,f=L2.bind(null,ft,k,A,f),k.dispatch=f,g.memoizedState=s,[o,f,!1]}function Oy(s){var o=tn();return Iy(o,It,s)}function Iy(s,o,f){if(o=Zh(s,o,Dy)[0],s=Mc(ls)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var g=Ho(o)}catch(F){throw F===Ca?jc:F}else g=o;o=tn();var k=o.queue,A=k.dispatch;return f!==o.memoizedState&&(ft.flags|=2048,Ta(9,{destroy:void 0},D2.bind(null,k,f),null)),[g,A,s]}function D2(s,o){s.action=o}function My(s){var o=tn(),f=It;if(f!==null)return Iy(o,f,s);tn(),o=o.memoizedState,f=tn();var g=f.queue.dispatch;return f.memoizedState=s,[o,g,!1]}function Ta(s,o,f,g){return s={tag:s,create:f,deps:g,inst:o,next:null},o=ft.updateQueue,o===null&&(o=Oc(),ft.updateQueue=o),f=o.lastEffect,f===null?o.lastEffect=s.next=s:(g=f.next,f.next=s,s.next=g,o.lastEffect=s),s}function Py(){return tn().memoizedState}function Pc(s,o,f,g){var k=Bn();ft.flags|=s,k.memoizedState=Ta(1|o,{destroy:void 0},f,g===void 0?null:g)}function Bc(s,o,f,g){var k=tn();g=g===void 0?null:g;var A=k.memoizedState.inst;It!==null&&g!==null&&qh(g,It.memoizedState.deps)?k.memoizedState=Ta(o,A,f,g):(ft.flags|=s,k.memoizedState=Ta(1|o,A,f,g))}function By(s,o){Pc(8390656,8,s,o)}function rf(s,o){Bc(2048,8,s,o)}function R2(s){ft.flags|=4;var o=ft.updateQueue;if(o===null)o=Oc(),ft.updateQueue=o,o.events=[s];else{var f=o.events;f===null?o.events=[s]:f.push(s)}}function $y(s){var o=tn().memoizedState;return R2({ref:o,nextImpl:s}),function(){if((At&2)!==0)throw Error(r(440));return o.impl.apply(void 0,arguments)}}function zy(s,o){return Bc(4,2,s,o)}function Hy(s,o){return Bc(4,4,s,o)}function Uy(s,o){if(typeof o=="function"){s=s();var f=o(s);return function(){typeof f=="function"?f():o(null)}}if(o!=null)return s=s(),o.current=s,function(){o.current=null}}function Fy(s,o,f){f=f!=null?f.concat([s]):null,Bc(4,4,Uy.bind(null,o,s),f)}function sf(){}function Vy(s,o){var f=tn();o=o===void 0?null:o;var g=f.memoizedState;return o!==null&&qh(o,g[1])?g[0]:(f.memoizedState=[s,o],s)}function Wy(s,o){var f=tn();o=o===void 0?null:o;var g=f.memoizedState;if(o!==null&&qh(o,g[1]))return g[0];if(g=s(),Di){tt(!0);try{s()}finally{tt(!1)}}return f.memoizedState=[g,o],g}function af(s,o,f){return f===void 0||(os&1073741824)!==0&&(St&261930)===0?s.memoizedState=o:(s.memoizedState=f,s=Gb(),ft.lanes|=s,Vs|=s,f)}function Gy(s,o,f,g){return nr(f,o)?f:ja.current!==null?(s=af(s,f,g),nr(s,o)||(an=!0),s):(os&42)===0||(os&1073741824)!==0&&(St&261930)===0?(an=!0,s.memoizedState=f):(s=Gb(),ft.lanes|=s,Vs|=s,o)}function qy(s,o,f,g,k){var A=ee.p;ee.p=A!==0&&8>A?A:8;var F=V.T,Y={};V.T=Y,cf(s,!1,o,f);try{var le=k(),pe=V.S;if(pe!==null&&pe(Y,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var Ce=N2(le,g);Uo(s,o,Ce,lr(s))}else Uo(s,o,g,lr(s))}catch(Ae){Uo(s,o,{then:function(){},status:"rejected",reason:Ae},lr())}finally{ee.p=A,F!==null&&Y.types!==null&&(F.types=Y.types),V.T=F}}function O2(){}function of(s,o,f,g){if(s.tag!==5)throw Error(r(476));var k=Ky(s).queue;qy(s,k,o,X,f===null?O2:function(){return Yy(s),f(g)})}function Ky(s){var o=s.memoizedState;if(o!==null)return o;o={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ls,lastRenderedState:X},next:null};var f={};return o.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ls,lastRenderedState:f},next:null},s.memoizedState=o,s=s.alternate,s!==null&&(s.memoizedState=o),o}function Yy(s){var o=Ky(s);o.next===null&&(o=s.alternate.memoizedState),Uo(s,o.next.queue,{},lr())}function lf(){return kn(il)}function Xy(){return tn().memoizedState}function Qy(){return tn().memoizedState}function I2(s){for(var o=s.return;o!==null;){switch(o.tag){case 24:case 3:var f=lr();s=Bs(f);var g=$s(o,s,f);g!==null&&(Xn(g,o,f),Po(g,o,f)),o={cache:Mh()},s.payload=o;return}o=o.return}}function M2(s,o,f){var g=lr();f={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},$c(s)?Zy(o,f):(f=kh(s,o,f,g),f!==null&&(Xn(f,s,g),eb(f,o,g)))}function Jy(s,o,f){var g=lr();Uo(s,o,f,g)}function Uo(s,o,f,g){var k={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if($c(s))Zy(o,k);else{var A=s.alternate;if(s.lanes===0&&(A===null||A.lanes===0)&&(A=o.lastRenderedReducer,A!==null))try{var F=o.lastRenderedState,Y=A(F,f);if(k.hasEagerState=!0,k.eagerState=Y,nr(Y,F))return bc(s,o,k,0),$t===null&&yc(),!1}catch{}finally{}if(f=kh(s,o,k,g),f!==null)return Xn(f,s,g),eb(f,o,g),!0}return!1}function cf(s,o,f,g){if(g={lane:2,revertLane:Hf(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},$c(s)){if(o)throw Error(r(479))}else o=kh(s,f,g,2),o!==null&&Xn(o,s,2)}function $c(s){var o=s.alternate;return s===ft||o!==null&&o===ft}function Zy(s,o){Ea=Dc=!0;var f=s.pending;f===null?o.next=o:(o.next=f.next,f.next=o),s.pending=o}function eb(s,o,f){if((f&4194048)!==0){var g=o.lanes;g&=s.pendingLanes,f|=g,o.lanes=f,As(s,f)}}var Fo={readContext:kn,use:Ic,useCallback:Jt,useContext:Jt,useEffect:Jt,useImperativeHandle:Jt,useLayoutEffect:Jt,useInsertionEffect:Jt,useMemo:Jt,useReducer:Jt,useRef:Jt,useState:Jt,useDebugValue:Jt,useDeferredValue:Jt,useTransition:Jt,useSyncExternalStore:Jt,useId:Jt,useHostTransitionStatus:Jt,useFormState:Jt,useActionState:Jt,useOptimistic:Jt,useMemoCache:Jt,useCacheRefresh:Jt};Fo.useEffectEvent=Jt;var tb={readContext:kn,use:Ic,useCallback:function(s,o){return Bn().memoizedState=[s,o===void 0?null:o],s},useContext:kn,useEffect:By,useImperativeHandle:function(s,o,f){f=f!=null?f.concat([s]):null,Pc(4194308,4,Uy.bind(null,o,s),f)},useLayoutEffect:function(s,o){return Pc(4194308,4,s,o)},useInsertionEffect:function(s,o){Pc(4,2,s,o)},useMemo:function(s,o){var f=Bn();o=o===void 0?null:o;var g=s();if(Di){tt(!0);try{s()}finally{tt(!1)}}return f.memoizedState=[g,o],g},useReducer:function(s,o,f){var g=Bn();if(f!==void 0){var k=f(o);if(Di){tt(!0);try{f(o)}finally{tt(!1)}}}else k=o;return g.memoizedState=g.baseState=k,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:k},g.queue=s,s=s.dispatch=M2.bind(null,ft,s),[g.memoizedState,s]},useRef:function(s){var o=Bn();return s={current:s},o.memoizedState=s},useState:function(s){s=tf(s);var o=s.queue,f=Jy.bind(null,ft,o);return o.dispatch=f,[s.memoizedState,f]},useDebugValue:sf,useDeferredValue:function(s,o){var f=Bn();return af(f,s,o)},useTransition:function(){var s=tf(!1);return s=qy.bind(null,ft,s.queue,!0,!1),Bn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,o,f){var g=ft,k=Bn();if(kt){if(f===void 0)throw Error(r(407));f=f()}else{if(f=o(),$t===null)throw Error(r(349));(St&127)!==0||Sy(g,o,f)}k.memoizedState=f;var A={value:f,getSnapshot:o};return k.queue=A,By(Cy.bind(null,g,A,s),[s]),g.flags|=2048,Ta(9,{destroy:void 0},wy.bind(null,g,A,f,o),null),f},useId:function(){var s=Bn(),o=$t.identifierPrefix;if(kt){var f=Hr,g=zr;f=(g&~(1<<32-ot(g)-1)).toString(32)+f,o="_"+o+"R_"+f,f=Rc++,0<f&&(o+="H"+f.toString(32)),o+="_"}else f=T2++,o="_"+o+"r_"+f.toString(32)+"_";return s.memoizedState=o},useHostTransitionStatus:lf,useFormState:Ry,useActionState:Ry,useOptimistic:function(s){var o=Bn();o.memoizedState=o.baseState=s;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=f,o=cf.bind(null,ft,!0,f),f.dispatch=o,[s,o]},useMemoCache:Jh,useCacheRefresh:function(){return Bn().memoizedState=I2.bind(null,ft)},useEffectEvent:function(s){var o=Bn(),f={impl:s};return o.memoizedState=f,function(){if((At&2)!==0)throw Error(r(440));return f.impl.apply(void 0,arguments)}}},uf={readContext:kn,use:Ic,useCallback:Vy,useContext:kn,useEffect:rf,useImperativeHandle:Fy,useInsertionEffect:zy,useLayoutEffect:Hy,useMemo:Wy,useReducer:Mc,useRef:Py,useState:function(){return Mc(ls)},useDebugValue:sf,useDeferredValue:function(s,o){var f=tn();return Gy(f,It.memoizedState,s,o)},useTransition:function(){var s=Mc(ls)[0],o=tn().memoizedState;return[typeof s=="boolean"?s:Ho(s),o]},useSyncExternalStore:_y,useId:Xy,useHostTransitionStatus:lf,useFormState:Oy,useActionState:Oy,useOptimistic:function(s,o){var f=tn();return Ey(f,It,s,o)},useMemoCache:Jh,useCacheRefresh:Qy};uf.useEffectEvent=$y;var nb={readContext:kn,use:Ic,useCallback:Vy,useContext:kn,useEffect:rf,useImperativeHandle:Fy,useInsertionEffect:zy,useLayoutEffect:Hy,useMemo:Wy,useReducer:ef,useRef:Py,useState:function(){return ef(ls)},useDebugValue:sf,useDeferredValue:function(s,o){var f=tn();return It===null?af(f,s,o):Gy(f,It.memoizedState,s,o)},useTransition:function(){var s=ef(ls)[0],o=tn().memoizedState;return[typeof s=="boolean"?s:Ho(s),o]},useSyncExternalStore:_y,useId:Xy,useHostTransitionStatus:lf,useFormState:My,useActionState:My,useOptimistic:function(s,o){var f=tn();return It!==null?Ey(f,It,s,o):(f.baseState=s,[s,f.queue.dispatch])},useMemoCache:Jh,useCacheRefresh:Qy};nb.useEffectEvent=$y;function df(s,o,f,g){o=s.memoizedState,f=f(g,o),f=f==null?o:m({},o,f),s.memoizedState=f,s.lanes===0&&(s.updateQueue.baseState=f)}var hf={enqueueSetState:function(s,o,f){s=s._reactInternals;var g=lr(),k=Bs(g);k.payload=o,f!=null&&(k.callback=f),o=$s(s,k,g),o!==null&&(Xn(o,s,g),Po(o,s,g))},enqueueReplaceState:function(s,o,f){s=s._reactInternals;var g=lr(),k=Bs(g);k.tag=1,k.payload=o,f!=null&&(k.callback=f),o=$s(s,k,g),o!==null&&(Xn(o,s,g),Po(o,s,g))},enqueueForceUpdate:function(s,o){s=s._reactInternals;var f=lr(),g=Bs(f);g.tag=2,o!=null&&(g.callback=o),o=$s(s,g,f),o!==null&&(Xn(o,s,f),Po(o,s,f))}};function rb(s,o,f,g,k,A,F){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(g,A,F):o.prototype&&o.prototype.isPureReactComponent?!To(f,g)||!To(k,A):!0}function sb(s,o,f,g){s=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(f,g),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(f,g),o.state!==s&&hf.enqueueReplaceState(o,o.state,null)}function Ri(s,o){var f=o;if("ref"in o){f={};for(var g in o)g!=="ref"&&(f[g]=o[g])}if(s=s.defaultProps){f===o&&(f=m({},f));for(var k in s)f[k]===void 0&&(f[k]=s[k])}return f}function ib(s){xc(s)}function ab(s){console.error(s)}function ob(s){xc(s)}function zc(s,o){try{var f=s.onUncaughtError;f(o.value,{componentStack:o.stack})}catch(g){setTimeout(function(){throw g})}}function lb(s,o,f){try{var g=s.onCaughtError;g(f.value,{componentStack:f.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(k){setTimeout(function(){throw k})}}function ff(s,o,f){return f=Bs(f),f.tag=3,f.payload={element:null},f.callback=function(){zc(s,o)},f}function cb(s){return s=Bs(s),s.tag=3,s}function ub(s,o,f,g){var k=f.type.getDerivedStateFromError;if(typeof k=="function"){var A=g.value;s.payload=function(){return k(A)},s.callback=function(){lb(o,f,g)}}var F=f.stateNode;F!==null&&typeof F.componentDidCatch=="function"&&(s.callback=function(){lb(o,f,g),typeof k!="function"&&(Ws===null?Ws=new Set([this]):Ws.add(this));var Y=g.stack;this.componentDidCatch(g.value,{componentStack:Y!==null?Y:""})})}function P2(s,o,f,g,k){if(f.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(o=f.alternate,o!==null&&_a(o,f,k,!0),f=sr.current,f!==null){switch(f.tag){case 31:case 13:return br===null?Jc():f.alternate===null&&Zt===0&&(Zt=3),f.flags&=-257,f.flags|=65536,f.lanes=k,g===Ec?f.flags|=16384:(o=f.updateQueue,o===null?f.updateQueue=new Set([g]):o.add(g),Bf(s,g,k)),!1;case 22:return f.flags|=65536,g===Ec?f.flags|=16384:(o=f.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([g])},f.updateQueue=o):(f=o.retryQueue,f===null?o.retryQueue=new Set([g]):f.add(g)),Bf(s,g,k)),!1}throw Error(r(435,f.tag))}return Bf(s,g,k),Jc(),!1}if(kt)return o=sr.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=k,g!==Lh&&(s=Error(r(422),{cause:g}),Do(pr(s,f)))):(g!==Lh&&(o=Error(r(423),{cause:g}),Do(pr(o,f))),s=s.current.alternate,s.flags|=65536,k&=-k,s.lanes|=k,g=pr(g,f),k=ff(s.stateNode,g,k),Uh(s,k),Zt!==4&&(Zt=2)),!1;var A=Error(r(520),{cause:g});if(A=pr(A,f),Qo===null?Qo=[A]:Qo.push(A),Zt!==4&&(Zt=2),o===null)return!0;g=pr(g,f),f=o;do{switch(f.tag){case 3:return f.flags|=65536,s=k&-k,f.lanes|=s,s=ff(f.stateNode,g,s),Uh(f,s),!1;case 1:if(o=f.type,A=f.stateNode,(f.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(Ws===null||!Ws.has(A))))return f.flags|=65536,k&=-k,f.lanes|=k,k=cb(k),ub(k,s,f,g),Uh(f,k),!1}f=f.return}while(f!==null);return!1}var mf=Error(r(461)),an=!1;function jn(s,o,f,g){o.child=s===null?my(o,null,f,g):Li(o,s.child,f,g)}function db(s,o,f,g,k){f=f.render;var A=o.ref;if("ref"in g){var F={};for(var Y in g)Y!=="ref"&&(F[Y]=g[Y])}else F=g;return Ei(o),g=Kh(s,o,f,F,A,k),Y=Yh(),s!==null&&!an?(Xh(s,o,k),cs(s,o,k)):(kt&&Y&&Th(o),o.flags|=1,jn(s,o,g,k),o.child)}function hb(s,o,f,g,k){if(s===null){var A=f.type;return typeof A=="function"&&!jh(A)&&A.defaultProps===void 0&&f.compare===null?(o.tag=15,o.type=A,fb(s,o,A,g,k)):(s=_c(f.type,null,g,o,o.mode,k),s.ref=o.ref,s.return=o,o.child=s)}if(A=s.child,!Sf(s,k)){var F=A.memoizedProps;if(f=f.compare,f=f!==null?f:To,f(F,g)&&s.ref===o.ref)return cs(s,o,k)}return o.flags|=1,s=rs(A,g),s.ref=o.ref,s.return=o,o.child=s}function fb(s,o,f,g,k){if(s!==null){var A=s.memoizedProps;if(To(A,g)&&s.ref===o.ref)if(an=!1,o.pendingProps=g=A,Sf(s,k))(s.flags&131072)!==0&&(an=!0);else return o.lanes=s.lanes,cs(s,o,k)}return pf(s,o,f,g,k)}function mb(s,o,f,g){var k=g.children,A=s!==null?s.memoizedState:null;if(s===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((o.flags&128)!==0){if(A=A!==null?A.baseLanes|f:f,s!==null){for(g=o.child=s.child,k=0;g!==null;)k=k|g.lanes|g.childLanes,g=g.sibling;g=k&~A}else g=0,o.child=null;return pb(s,o,A,f,g)}if((f&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},s!==null&&kc(o,A!==null?A.cachePool:null),A!==null?xy(o,A):Vh(),yy(o);else return g=o.lanes=536870912,pb(s,o,A!==null?A.baseLanes|f:f,f,g)}else A!==null?(kc(o,A.cachePool),xy(o,A),Hs(),o.memoizedState=null):(s!==null&&kc(o,null),Vh(),Hs());return jn(s,o,k,f),o.child}function Vo(s,o){return s!==null&&s.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function pb(s,o,f,g,k){var A=Bh();return A=A===null?null:{parent:rn._currentValue,pool:A},o.memoizedState={baseLanes:f,cachePool:A},s!==null&&kc(o,null),Vh(),yy(o),s!==null&&_a(s,o,g,!0),o.childLanes=k,null}function Hc(s,o){return o=Fc({mode:o.mode,children:o.children},s.mode),o.ref=s.ref,s.child=o,o.return=s,o}function gb(s,o,f){return Li(o,s.child,null,f),s=Hc(o,o.pendingProps),s.flags|=2,ir(o),o.memoizedState=null,s}function B2(s,o,f){var g=o.pendingProps,k=(o.flags&128)!==0;if(o.flags&=-129,s===null){if(kt){if(g.mode==="hidden")return s=Hc(o,g),o.lanes=536870912,Vo(null,s);if(Gh(o),(s=Gt)?(s=Nv(s,yr),s=s!==null&&s.data==="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:Rs!==null?{id:zr,overflow:Hr}:null,retryLane:536870912,hydrationErrors:null},f=Zx(s),f.return=o,o.child=f,Cn=o,Gt=null)):s=null,s===null)throw Is(o);return o.lanes=536870912,null}return Hc(o,g)}var A=s.memoizedState;if(A!==null){var F=A.dehydrated;if(Gh(o),k)if(o.flags&256)o.flags&=-257,o=gb(s,o,f);else if(o.memoizedState!==null)o.child=s.child,o.flags|=128,o=null;else throw Error(r(558));else if(an||_a(s,o,f,!1),k=(f&s.childLanes)!==0,an||k){if(g=$t,g!==null&&(F=Ls(g,f),F!==0&&F!==A.retryLane))throw A.retryLane=F,wi(s,F),Xn(g,s,F),mf;Jc(),o=gb(s,o,f)}else s=A.treeContext,Gt=vr(F.nextSibling),Cn=o,kt=!0,Os=null,yr=!1,s!==null&&ny(o,s),o=Hc(o,g),o.flags|=4096;return o}return s=rs(s.child,{mode:g.mode,children:g.children}),s.ref=o.ref,o.child=s,s.return=o,s}function Uc(s,o){var f=o.ref;if(f===null)s!==null&&s.ref!==null&&(o.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(r(284));(s===null||s.ref!==f)&&(o.flags|=4194816)}}function pf(s,o,f,g,k){return Ei(o),f=Kh(s,o,f,g,void 0,k),g=Yh(),s!==null&&!an?(Xh(s,o,k),cs(s,o,k)):(kt&&g&&Th(o),o.flags|=1,jn(s,o,f,k),o.child)}function xb(s,o,f,g,k,A){return Ei(o),o.updateQueue=null,f=vy(o,g,f,k),by(s),g=Yh(),s!==null&&!an?(Xh(s,o,A),cs(s,o,A)):(kt&&g&&Th(o),o.flags|=1,jn(s,o,f,A),o.child)}function yb(s,o,f,g,k){if(Ei(o),o.stateNode===null){var A=xa,F=f.contextType;typeof F=="object"&&F!==null&&(A=kn(F)),A=new f(g,A),o.memoizedState=A.state!==null&&A.state!==void 0?A.state:null,A.updater=hf,o.stateNode=A,A._reactInternals=o,A=o.stateNode,A.props=g,A.state=o.memoizedState,A.refs={},zh(o),F=f.contextType,A.context=typeof F=="object"&&F!==null?kn(F):xa,A.state=o.memoizedState,F=f.getDerivedStateFromProps,typeof F=="function"&&(df(o,f,F,g),A.state=o.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof A.getSnapshotBeforeUpdate=="function"||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(F=A.state,typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount(),F!==A.state&&hf.enqueueReplaceState(A,A.state,null),$o(o,g,A,k),Bo(),A.state=o.memoizedState),typeof A.componentDidMount=="function"&&(o.flags|=4194308),g=!0}else if(s===null){A=o.stateNode;var Y=o.memoizedProps,le=Ri(f,Y);A.props=le;var pe=A.context,Ce=f.contextType;F=xa,typeof Ce=="object"&&Ce!==null&&(F=kn(Ce));var Ae=f.getDerivedStateFromProps;Ce=typeof Ae=="function"||typeof A.getSnapshotBeforeUpdate=="function",Y=o.pendingProps!==Y,Ce||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(Y||pe!==F)&&sb(o,A,g,F),Ps=!1;var ge=o.memoizedState;A.state=ge,$o(o,g,A,k),Bo(),pe=o.memoizedState,Y||ge!==pe||Ps?(typeof Ae=="function"&&(df(o,f,Ae,g),pe=o.memoizedState),(le=Ps||rb(o,f,le,g,ge,pe,F))?(Ce||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(o.flags|=4194308)):(typeof A.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=g,o.memoizedState=pe),A.props=g,A.state=pe,A.context=F,g=le):(typeof A.componentDidMount=="function"&&(o.flags|=4194308),g=!1)}else{A=o.stateNode,Hh(s,o),F=o.memoizedProps,Ce=Ri(f,F),A.props=Ce,Ae=o.pendingProps,ge=A.context,pe=f.contextType,le=xa,typeof pe=="object"&&pe!==null&&(le=kn(pe)),Y=f.getDerivedStateFromProps,(pe=typeof Y=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(F!==Ae||ge!==le)&&sb(o,A,g,le),Ps=!1,ge=o.memoizedState,A.state=ge,$o(o,g,A,k),Bo();var xe=o.memoizedState;F!==Ae||ge!==xe||Ps||s!==null&&s.dependencies!==null&&wc(s.dependencies)?(typeof Y=="function"&&(df(o,f,Y,g),xe=o.memoizedState),(Ce=Ps||rb(o,f,Ce,g,ge,xe,le)||s!==null&&s.dependencies!==null&&wc(s.dependencies))?(pe||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(g,xe,le),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(g,xe,le)),typeof A.componentDidUpdate=="function"&&(o.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof A.componentDidUpdate!="function"||F===s.memoizedProps&&ge===s.memoizedState||(o.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&ge===s.memoizedState||(o.flags|=1024),o.memoizedProps=g,o.memoizedState=xe),A.props=g,A.state=xe,A.context=le,g=Ce):(typeof A.componentDidUpdate!="function"||F===s.memoizedProps&&ge===s.memoizedState||(o.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&ge===s.memoizedState||(o.flags|=1024),g=!1)}return A=g,Uc(s,o),g=(o.flags&128)!==0,A||g?(A=o.stateNode,f=g&&typeof f.getDerivedStateFromError!="function"?null:A.render(),o.flags|=1,s!==null&&g?(o.child=Li(o,s.child,null,k),o.child=Li(o,null,f,k)):jn(s,o,f,k),o.memoizedState=A.state,s=o.child):s=cs(s,o,k),s}function bb(s,o,f,g){return ki(),o.flags|=256,jn(s,o,f,g),o.child}var gf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function xf(s){return{baseLanes:s,cachePool:ly()}}function yf(s,o,f){return s=s!==null?s.childLanes&~f:0,o&&(s|=or),s}function vb(s,o,f){var g=o.pendingProps,k=!1,A=(o.flags&128)!==0,F;if((F=A)||(F=s!==null&&s.memoizedState===null?!1:(en.current&2)!==0),F&&(k=!0,o.flags&=-129),F=(o.flags&32)!==0,o.flags&=-33,s===null){if(kt){if(k?zs(o):Hs(),(s=Gt)?(s=Nv(s,yr),s=s!==null&&s.data!=="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:Rs!==null?{id:zr,overflow:Hr}:null,retryLane:536870912,hydrationErrors:null},f=Zx(s),f.return=o,o.child=f,Cn=o,Gt=null)):s=null,s===null)throw Is(o);return em(s)?o.lanes=32:o.lanes=536870912,null}var Y=g.children;return g=g.fallback,k?(Hs(),k=o.mode,Y=Fc({mode:"hidden",children:Y},k),g=Ci(g,k,f,null),Y.return=o,g.return=o,Y.sibling=g,o.child=Y,g=o.child,g.memoizedState=xf(f),g.childLanes=yf(s,F,f),o.memoizedState=gf,Vo(null,g)):(zs(o),bf(o,Y))}var le=s.memoizedState;if(le!==null&&(Y=le.dehydrated,Y!==null)){if(A)o.flags&256?(zs(o),o.flags&=-257,o=vf(s,o,f)):o.memoizedState!==null?(Hs(),o.child=s.child,o.flags|=128,o=null):(Hs(),Y=g.fallback,k=o.mode,g=Fc({mode:"visible",children:g.children},k),Y=Ci(Y,k,f,null),Y.flags|=2,g.return=o,Y.return=o,g.sibling=Y,o.child=g,Li(o,s.child,null,f),g=o.child,g.memoizedState=xf(f),g.childLanes=yf(s,F,f),o.memoizedState=gf,o=Vo(null,g));else if(zs(o),em(Y)){if(F=Y.nextSibling&&Y.nextSibling.dataset,F)var pe=F.dgst;F=pe,g=Error(r(419)),g.stack="",g.digest=F,Do({value:g,source:null,stack:null}),o=vf(s,o,f)}else if(an||_a(s,o,f,!1),F=(f&s.childLanes)!==0,an||F){if(F=$t,F!==null&&(g=Ls(F,f),g!==0&&g!==le.retryLane))throw le.retryLane=g,wi(s,g),Xn(F,s,g),mf;Zf(Y)||Jc(),o=vf(s,o,f)}else Zf(Y)?(o.flags|=192,o.child=s.child,o=null):(s=le.treeContext,Gt=vr(Y.nextSibling),Cn=o,kt=!0,Os=null,yr=!1,s!==null&&ny(o,s),o=bf(o,g.children),o.flags|=4096);return o}return k?(Hs(),Y=g.fallback,k=o.mode,le=s.child,pe=le.sibling,g=rs(le,{mode:"hidden",children:g.children}),g.subtreeFlags=le.subtreeFlags&65011712,pe!==null?Y=rs(pe,Y):(Y=Ci(Y,k,f,null),Y.flags|=2),Y.return=o,g.return=o,g.sibling=Y,o.child=g,Vo(null,g),g=o.child,Y=s.child.memoizedState,Y===null?Y=xf(f):(k=Y.cachePool,k!==null?(le=rn._currentValue,k=k.parent!==le?{parent:le,pool:le}:k):k=ly(),Y={baseLanes:Y.baseLanes|f,cachePool:k}),g.memoizedState=Y,g.childLanes=yf(s,F,f),o.memoizedState=gf,Vo(s.child,g)):(zs(o),f=s.child,s=f.sibling,f=rs(f,{mode:"visible",children:g.children}),f.return=o,f.sibling=null,s!==null&&(F=o.deletions,F===null?(o.deletions=[s],o.flags|=16):F.push(s)),o.child=f,o.memoizedState=null,f)}function bf(s,o){return o=Fc({mode:"visible",children:o},s.mode),o.return=s,s.child=o}function Fc(s,o){return s=rr(22,s,null,o),s.lanes=0,s}function vf(s,o,f){return Li(o,s.child,null,f),s=bf(o,o.pendingProps.children),s.flags|=2,o.memoizedState=null,s}function _b(s,o,f){s.lanes|=o;var g=s.alternate;g!==null&&(g.lanes|=o),Oh(s.return,o,f)}function _f(s,o,f,g,k,A){var F=s.memoizedState;F===null?s.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:g,tail:f,tailMode:k,treeForkCount:A}:(F.isBackwards=o,F.rendering=null,F.renderingStartTime=0,F.last=g,F.tail=f,F.tailMode=k,F.treeForkCount=A)}function Sb(s,o,f){var g=o.pendingProps,k=g.revealOrder,A=g.tail;g=g.children;var F=en.current,Y=(F&2)!==0;if(Y?(F=F&1|2,o.flags|=128):F&=1,z(en,F),jn(s,o,g,f),g=kt?Lo:0,!Y&&s!==null&&(s.flags&128)!==0)e:for(s=o.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&_b(s,f,o);else if(s.tag===19)_b(s,f,o);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===o)break e;for(;s.sibling===null;){if(s.return===null||s.return===o)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(k){case"forwards":for(f=o.child,k=null;f!==null;)s=f.alternate,s!==null&&Lc(s)===null&&(k=f),f=f.sibling;f=k,f===null?(k=o.child,o.child=null):(k=f.sibling,f.sibling=null),_f(o,!1,k,f,A,g);break;case"backwards":case"unstable_legacy-backwards":for(f=null,k=o.child,o.child=null;k!==null;){if(s=k.alternate,s!==null&&Lc(s)===null){o.child=k;break}s=k.sibling,k.sibling=f,f=k,k=s}_f(o,!0,f,null,A,g);break;case"together":_f(o,!1,null,null,void 0,g);break;default:o.memoizedState=null}return o.child}function cs(s,o,f){if(s!==null&&(o.dependencies=s.dependencies),Vs|=o.lanes,(f&o.childLanes)===0)if(s!==null){if(_a(s,o,f,!1),(f&o.childLanes)===0)return null}else return null;if(s!==null&&o.child!==s.child)throw Error(r(153));if(o.child!==null){for(s=o.child,f=rs(s,s.pendingProps),o.child=f,f.return=o;s.sibling!==null;)s=s.sibling,f=f.sibling=rs(s,s.pendingProps),f.return=o;f.sibling=null}return o.child}function Sf(s,o){return(s.lanes&o)!==0?!0:(s=s.dependencies,!!(s!==null&&wc(s)))}function $2(s,o,f){switch(o.tag){case 3:P(o,o.stateNode.containerInfo),Ms(o,rn,s.memoizedState.cache),ki();break;case 27:case 5:ae(o);break;case 4:P(o,o.stateNode.containerInfo);break;case 10:Ms(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Gh(o),null;break;case 13:var g=o.memoizedState;if(g!==null)return g.dehydrated!==null?(zs(o),o.flags|=128,null):(f&o.child.childLanes)!==0?vb(s,o,f):(zs(o),s=cs(s,o,f),s!==null?s.sibling:null);zs(o);break;case 19:var k=(s.flags&128)!==0;if(g=(f&o.childLanes)!==0,g||(_a(s,o,f,!1),g=(f&o.childLanes)!==0),k){if(g)return Sb(s,o,f);o.flags|=128}if(k=o.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),z(en,en.current),g)break;return null;case 22:return o.lanes=0,mb(s,o,f,o.pendingProps);case 24:Ms(o,rn,s.memoizedState.cache)}return cs(s,o,f)}function wb(s,o,f){if(s!==null)if(s.memoizedProps!==o.pendingProps)an=!0;else{if(!Sf(s,f)&&(o.flags&128)===0)return an=!1,$2(s,o,f);an=(s.flags&131072)!==0}else an=!1,kt&&(o.flags&1048576)!==0&&ty(o,Lo,o.index);switch(o.lanes=0,o.tag){case 16:e:{var g=o.pendingProps;if(s=Ti(o.elementType),o.type=s,typeof s=="function")jh(s)?(g=Ri(s,g),o.tag=1,o=yb(null,o,s,g,f)):(o.tag=0,o=pf(null,o,s,g,f));else{if(s!=null){var k=s.$$typeof;if(k===j){o.tag=11,o=db(null,o,s,g,f);break e}else if(k===D){o.tag=14,o=hb(null,o,s,g,f);break e}}throw o=H(s)||s,Error(r(306,o,""))}}return o;case 0:return pf(s,o,o.type,o.pendingProps,f);case 1:return g=o.type,k=Ri(g,o.pendingProps),yb(s,o,g,k,f);case 3:e:{if(P(o,o.stateNode.containerInfo),s===null)throw Error(r(387));g=o.pendingProps;var A=o.memoizedState;k=A.element,Hh(s,o),$o(o,g,null,f);var F=o.memoizedState;if(g=F.cache,Ms(o,rn,g),g!==A.cache&&Ih(o,[rn],f,!0),Bo(),g=F.element,A.isDehydrated)if(A={element:g,isDehydrated:!1,cache:F.cache},o.updateQueue.baseState=A,o.memoizedState=A,o.flags&256){o=bb(s,o,g,f);break e}else if(g!==k){k=pr(Error(r(424)),o),Do(k),o=bb(s,o,g,f);break e}else{switch(s=o.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(Gt=vr(s.firstChild),Cn=o,kt=!0,Os=null,yr=!0,f=my(o,null,g,f),o.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling}else{if(ki(),g===k){o=cs(s,o,f);break e}jn(s,o,g,f)}o=o.child}return o;case 26:return Uc(s,o),s===null?(f=Ov(o.type,null,o.pendingProps,null))?o.memoizedState=f:kt||(f=o.type,s=o.pendingProps,g=iu(J.current).createElement(f),g[Qe]=o,g[nt]=s,En(g,f,s),bn(g),o.stateNode=g):o.memoizedState=Ov(o.type,s.memoizedProps,o.pendingProps,s.memoizedState),null;case 27:return ae(o),s===null&&kt&&(g=o.stateNode=Lv(o.type,o.pendingProps,J.current),Cn=o,yr=!0,k=Gt,Ys(o.type)?(tm=k,Gt=vr(g.firstChild)):Gt=k),jn(s,o,o.pendingProps.children,f),Uc(s,o),s===null&&(o.flags|=4194304),o.child;case 5:return s===null&&kt&&((k=g=Gt)&&(g=pE(g,o.type,o.pendingProps,yr),g!==null?(o.stateNode=g,Cn=o,Gt=vr(g.firstChild),yr=!1,k=!0):k=!1),k||Is(o)),ae(o),k=o.type,A=o.pendingProps,F=s!==null?s.memoizedProps:null,g=A.children,Xf(k,A)?g=null:F!==null&&Xf(k,F)&&(o.flags|=32),o.memoizedState!==null&&(k=Kh(s,o,A2,null,null,f),il._currentValue=k),Uc(s,o),jn(s,o,g,f),o.child;case 6:return s===null&&kt&&((s=f=Gt)&&(f=gE(f,o.pendingProps,yr),f!==null?(o.stateNode=f,Cn=o,Gt=null,s=!0):s=!1),s||Is(o)),null;case 13:return vb(s,o,f);case 4:return P(o,o.stateNode.containerInfo),g=o.pendingProps,s===null?o.child=Li(o,null,g,f):jn(s,o,g,f),o.child;case 11:return db(s,o,o.type,o.pendingProps,f);case 7:return jn(s,o,o.pendingProps,f),o.child;case 8:return jn(s,o,o.pendingProps.children,f),o.child;case 12:return jn(s,o,o.pendingProps.children,f),o.child;case 10:return g=o.pendingProps,Ms(o,o.type,g.value),jn(s,o,g.children,f),o.child;case 9:return k=o.type._context,g=o.pendingProps.children,Ei(o),k=kn(k),g=g(k),o.flags|=1,jn(s,o,g,f),o.child;case 14:return hb(s,o,o.type,o.pendingProps,f);case 15:return fb(s,o,o.type,o.pendingProps,f);case 19:return Sb(s,o,f);case 31:return B2(s,o,f);case 22:return mb(s,o,f,o.pendingProps);case 24:return Ei(o),g=kn(rn),s===null?(k=Bh(),k===null&&(k=$t,A=Mh(),k.pooledCache=A,A.refCount++,A!==null&&(k.pooledCacheLanes|=f),k=A),o.memoizedState={parent:g,cache:k},zh(o),Ms(o,rn,k)):((s.lanes&f)!==0&&(Hh(s,o),$o(o,null,null,f),Bo()),k=s.memoizedState,A=o.memoizedState,k.parent!==g?(k={parent:g,cache:g},o.memoizedState=k,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=k),Ms(o,rn,g)):(g=A.cache,Ms(o,rn,g),g!==k.cache&&Ih(o,[rn],f,!0))),jn(s,o,o.pendingProps.children,f),o.child;case 29:throw o.pendingProps}throw Error(r(156,o.tag))}function us(s){s.flags|=4}function wf(s,o,f,g,k){if((o=(s.mode&32)!==0)&&(o=!1),o){if(s.flags|=16777216,(k&335544128)===k)if(s.stateNode.complete)s.flags|=8192;else if(Xb())s.flags|=8192;else throw Ai=Ec,$h}else s.flags&=-16777217}function Cb(s,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!$v(o))if(Xb())s.flags|=8192;else throw Ai=Ec,$h}function Vc(s,o){o!==null&&(s.flags|=4),s.flags&16384&&(o=s.tag!==22?Je():536870912,s.lanes|=o,Ra|=o)}function Wo(s,o){if(!kt)switch(s.tailMode){case"hidden":o=s.tail;for(var f=null;o!==null;)o.alternate!==null&&(f=o),o=o.sibling;f===null?s.tail=null:f.sibling=null;break;case"collapsed":f=s.tail;for(var g=null;f!==null;)f.alternate!==null&&(g=f),f=f.sibling;g===null?o||s.tail===null?s.tail=null:s.tail.sibling=null:g.sibling=null}}function qt(s){var o=s.alternate!==null&&s.alternate.child===s.child,f=0,g=0;if(o)for(var k=s.child;k!==null;)f|=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;)f|=k.lanes|k.childLanes,g|=k.subtreeFlags,g|=k.flags,k.return=s,k=k.sibling;return s.subtreeFlags|=g,s.childLanes=f,o}function z2(s,o,f){var g=o.pendingProps;switch(Ah(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qt(o),null;case 1:return qt(o),null;case 3:return f=o.stateNode,g=null,s!==null&&(g=s.memoizedState.cache),o.memoizedState.cache!==g&&(o.flags|=2048),as(rn),Q(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(s===null||s.child===null)&&(va(o)?us(o):s===null||s.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Dh())),qt(o),null;case 26:var k=o.type,A=o.memoizedState;return s===null?(us(o),A!==null?(qt(o),Cb(o,A)):(qt(o),wf(o,k,null,g,f))):A?A!==s.memoizedState?(us(o),qt(o),Cb(o,A)):(qt(o),o.flags&=-16777217):(s=s.memoizedProps,s!==g&&us(o),qt(o),wf(o,k,s,g,f)),null;case 27:if(he(o),f=J.current,k=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==g&&us(o);else{if(!g){if(o.stateNode===null)throw Error(r(166));return qt(o),null}s=re.current,va(o)?ry(o):(s=Lv(k,g,f),o.stateNode=s,us(o))}return qt(o),null;case 5:if(he(o),k=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==g&&us(o);else{if(!g){if(o.stateNode===null)throw Error(r(166));return qt(o),null}if(A=re.current,va(o))ry(o);else{var F=iu(J.current);switch(A){case 1:A=F.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:A=F.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":A=F.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":A=F.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":A=F.createElement("div"),A.innerHTML="<script><\/script>",A=A.removeChild(A.firstChild);break;case"select":A=typeof g.is=="string"?F.createElement("select",{is:g.is}):F.createElement("select"),g.multiple?A.multiple=!0:g.size&&(A.size=g.size);break;default:A=typeof g.is=="string"?F.createElement(k,{is:g.is}):F.createElement(k)}}A[Qe]=o,A[nt]=g;e:for(F=o.child;F!==null;){if(F.tag===5||F.tag===6)A.appendChild(F.stateNode);else if(F.tag!==4&&F.tag!==27&&F.child!==null){F.child.return=F,F=F.child;continue}if(F===o)break e;for(;F.sibling===null;){if(F.return===null||F.return===o)break e;F=F.return}F.sibling.return=F.return,F=F.sibling}o.stateNode=A;e:switch(En(A,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&&us(o)}}return qt(o),wf(o,o.type,s===null?null:s.memoizedProps,o.pendingProps,f),null;case 6:if(s&&o.stateNode!=null)s.memoizedProps!==g&&us(o);else{if(typeof g!="string"&&o.stateNode===null)throw Error(r(166));if(s=J.current,va(o)){if(s=o.stateNode,f=o.memoizedProps,g=null,k=Cn,k!==null)switch(k.tag){case 27:case 5:g=k.memoizedProps}s[Qe]=o,s=!!(s.nodeValue===f||g!==null&&g.suppressHydrationWarning===!0||vv(s.nodeValue,f)),s||Is(o,!0)}else s=iu(s).createTextNode(g),s[Qe]=o,o.stateNode=s}return qt(o),null;case 31:if(f=o.memoizedState,s===null||s.memoizedState!==null){if(g=va(o),f!==null){if(s===null){if(!g)throw Error(r(318));if(s=o.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[Qe]=o}else ki(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;qt(o),s=!1}else f=Dh(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=f),s=!0;if(!s)return o.flags&256?(ir(o),o):(ir(o),null);if((o.flags&128)!==0)throw Error(r(558))}return qt(o),null;case 13:if(g=o.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(k=va(o),g!==null&&g.dehydrated!==null){if(s===null){if(!k)throw Error(r(318));if(k=o.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(r(317));k[Qe]=o}else ki(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;qt(o),k=!1}else k=Dh(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=k),k=!0;if(!k)return o.flags&256?(ir(o),o):(ir(o),null)}return ir(o),(o.flags&128)!==0?(o.lanes=f,o):(f=g!==null,s=s!==null&&s.memoizedState!==null,f&&(g=o.child,k=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(k=g.alternate.memoizedState.cachePool.pool),A=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(A=g.memoizedState.cachePool.pool),A!==k&&(g.flags|=2048)),f!==s&&f&&(o.child.flags|=8192),Vc(o,o.updateQueue),qt(o),null);case 4:return Q(),s===null&&Wf(o.stateNode.containerInfo),qt(o),null;case 10:return as(o.type),qt(o),null;case 19:if(q(en),g=o.memoizedState,g===null)return qt(o),null;if(k=(o.flags&128)!==0,A=g.rendering,A===null)if(k)Wo(g,!1);else{if(Zt!==0||s!==null&&(s.flags&128)!==0)for(s=o.child;s!==null;){if(A=Lc(s),A!==null){for(o.flags|=128,Wo(g,!1),s=A.updateQueue,o.updateQueue=s,Vc(o,s),o.subtreeFlags=0,s=f,f=o.child;f!==null;)Jx(f,s),f=f.sibling;return z(en,en.current&1|2),kt&&ss(o,g.treeForkCount),o.child}s=s.sibling}g.tail!==null&&He()>Yc&&(o.flags|=128,k=!0,Wo(g,!1),o.lanes=4194304)}else{if(!k)if(s=Lc(A),s!==null){if(o.flags|=128,k=!0,s=s.updateQueue,o.updateQueue=s,Vc(o,s),Wo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!A.alternate&&!kt)return qt(o),null}else 2*He()-g.renderingStartTime>Yc&&f!==536870912&&(o.flags|=128,k=!0,Wo(g,!1),o.lanes=4194304);g.isBackwards?(A.sibling=o.child,o.child=A):(s=g.last,s!==null?s.sibling=A:o.child=A,g.last=A)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=He(),s.sibling=null,f=en.current,z(en,k?f&1|2:f&1),kt&&ss(o,g.treeForkCount),s):(qt(o),null);case 22:case 23:return ir(o),Wh(),g=o.memoizedState!==null,s!==null?s.memoizedState!==null!==g&&(o.flags|=8192):g&&(o.flags|=8192),g?(f&536870912)!==0&&(o.flags&128)===0&&(qt(o),o.subtreeFlags&6&&(o.flags|=8192)):qt(o),f=o.updateQueue,f!==null&&Vc(o,f.retryQueue),f=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(f=s.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==f&&(o.flags|=2048),s!==null&&q(Ni),null;case 24:return f=null,s!==null&&(f=s.memoizedState.cache),o.memoizedState.cache!==f&&(o.flags|=2048),as(rn),qt(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function H2(s,o){switch(Ah(o),o.tag){case 1:return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 3:return as(rn),Q(),s=o.flags,(s&65536)!==0&&(s&128)===0?(o.flags=s&-65537|128,o):null;case 26:case 27:case 5:return he(o),null;case 31:if(o.memoizedState!==null){if(ir(o),o.alternate===null)throw Error(r(340));ki()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 13:if(ir(o),s=o.memoizedState,s!==null&&s.dehydrated!==null){if(o.alternate===null)throw Error(r(340));ki()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 19:return q(en),null;case 4:return Q(),null;case 10:return as(o.type),null;case 22:case 23:return ir(o),Wh(),s!==null&&q(Ni),s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 24:return as(rn),null;case 25:return null;default:return null}}function kb(s,o){switch(Ah(o),o.tag){case 3:as(rn),Q();break;case 26:case 27:case 5:he(o);break;case 4:Q();break;case 31:o.memoizedState!==null&&ir(o);break;case 13:ir(o);break;case 19:q(en);break;case 10:as(o.type);break;case 22:case 23:ir(o),Wh(),s!==null&&q(Ni);break;case 24:as(rn)}}function Go(s,o){try{var f=o.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var k=g.next;f=k;do{if((f.tag&s)===s){g=void 0;var A=f.create,F=f.inst;g=A(),F.destroy=g}f=f.next}while(f!==k)}}catch(Y){Ot(o,o.return,Y)}}function Us(s,o,f){try{var g=o.updateQueue,k=g!==null?g.lastEffect:null;if(k!==null){var A=k.next;g=A;do{if((g.tag&s)===s){var F=g.inst,Y=F.destroy;if(Y!==void 0){F.destroy=void 0,k=o;var le=f,pe=Y;try{pe()}catch(Ce){Ot(k,le,Ce)}}}g=g.next}while(g!==A)}}catch(Ce){Ot(o,o.return,Ce)}}function jb(s){var o=s.updateQueue;if(o!==null){var f=s.stateNode;try{gy(o,f)}catch(g){Ot(s,s.return,g)}}}function Eb(s,o,f){f.props=Ri(s.type,s.memoizedProps),f.state=s.memoizedState;try{f.componentWillUnmount()}catch(g){Ot(s,o,g)}}function qo(s,o){try{var f=s.ref;if(f!==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 f=="function"?s.refCleanup=f(g):f.current=g}}catch(k){Ot(s,o,k)}}function Ur(s,o){var f=s.ref,g=s.refCleanup;if(f!==null)if(typeof g=="function")try{g()}catch(k){Ot(s,o,k)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(k){Ot(s,o,k)}else f.current=null}function Nb(s){var o=s.type,f=s.memoizedProps,g=s.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":f.autoFocus&&g.focus();break e;case"img":f.src?g.src=f.src:f.srcSet&&(g.srcset=f.srcSet)}}catch(k){Ot(s,s.return,k)}}function Cf(s,o,f){try{var g=s.stateNode;cE(g,s.type,f,o),g[nt]=o}catch(k){Ot(s,s.return,k)}}function Tb(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Ys(s.type)||s.tag===4}function kf(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Tb(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&&Ys(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 jf(s,o,f){var g=s.tag;if(g===5||g===6)s=s.stateNode,o?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(s,o):(o=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,o.appendChild(s),f=f._reactRootContainer,f!=null||o.onclick!==null||(o.onclick=ts));else if(g!==4&&(g===27&&Ys(s.type)&&(f=s.stateNode,o=null),s=s.child,s!==null))for(jf(s,o,f),s=s.sibling;s!==null;)jf(s,o,f),s=s.sibling}function Wc(s,o,f){var g=s.tag;if(g===5||g===6)s=s.stateNode,o?f.insertBefore(s,o):f.appendChild(s);else if(g!==4&&(g===27&&Ys(s.type)&&(f=s.stateNode),s=s.child,s!==null))for(Wc(s,o,f),s=s.sibling;s!==null;)Wc(s,o,f),s=s.sibling}function Ab(s){var o=s.stateNode,f=s.memoizedProps;try{for(var g=s.type,k=o.attributes;k.length;)o.removeAttributeNode(k[0]);En(o,g,f),o[Qe]=s,o[nt]=f}catch(A){Ot(s,s.return,A)}}var ds=!1,on=!1,Ef=!1,Lb=typeof WeakSet=="function"?WeakSet:Set,vn=null;function U2(s,o){if(s=s.containerInfo,Kf=hu,s=Fx(s),bh(s)){if("selectionStart"in s)var f={start:s.selectionStart,end:s.selectionEnd};else e:{f=(f=s.ownerDocument)&&f.defaultView||window;var g=f.getSelection&&f.getSelection();if(g&&g.rangeCount!==0){f=g.anchorNode;var k=g.anchorOffset,A=g.focusNode;g=g.focusOffset;try{f.nodeType,A.nodeType}catch{f=null;break e}var F=0,Y=-1,le=-1,pe=0,Ce=0,Ae=s,ge=null;t:for(;;){for(var xe;Ae!==f||k!==0&&Ae.nodeType!==3||(Y=F+k),Ae!==A||g!==0&&Ae.nodeType!==3||(le=F+g),Ae.nodeType===3&&(F+=Ae.nodeValue.length),(xe=Ae.firstChild)!==null;)ge=Ae,Ae=xe;for(;;){if(Ae===s)break t;if(ge===f&&++pe===k&&(Y=F),ge===A&&++Ce===g&&(le=F),(xe=Ae.nextSibling)!==null)break;Ae=ge,ge=Ae.parentNode}Ae=xe}f=Y===-1||le===-1?null:{start:Y,end:le}}else f=null}f=f||{start:0,end:0}}else f=null;for(Yf={focusedElem:s,selectionRange:f},hu=!1,vn=o;vn!==null;)if(o=vn,s=o.child,(o.subtreeFlags&1028)!==0&&s!==null)s.return=o,vn=s;else for(;vn!==null;){switch(o=vn,A=o.alternate,s=o.flags,o.tag){case 0:if((s&4)!==0&&(s=o.updateQueue,s=s!==null?s.events:null,s!==null))for(f=0;f<s.length;f++)k=s[f],k.ref.impl=k.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&A!==null){s=void 0,f=o,k=A.memoizedProps,A=A.memoizedState,g=f.stateNode;try{var qe=Ri(f.type,k);s=g.getSnapshotBeforeUpdate(qe,A),g.__reactInternalSnapshotBeforeUpdate=s}catch(it){Ot(f,f.return,it)}}break;case 3:if((s&1024)!==0){if(s=o.stateNode.containerInfo,f=s.nodeType,f===9)Jf(s);else if(f===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":Jf(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(r(163))}if(s=o.sibling,s!==null){s.return=o.return,vn=s;break}vn=o.return}}function Db(s,o,f){var g=f.flags;switch(f.tag){case 0:case 11:case 15:fs(s,f),g&4&&Go(5,f);break;case 1:if(fs(s,f),g&4)if(s=f.stateNode,o===null)try{s.componentDidMount()}catch(F){Ot(f,f.return,F)}else{var k=Ri(f.type,o.memoizedProps);o=o.memoizedState;try{s.componentDidUpdate(k,o,s.__reactInternalSnapshotBeforeUpdate)}catch(F){Ot(f,f.return,F)}}g&64&&jb(f),g&512&&qo(f,f.return);break;case 3:if(fs(s,f),g&64&&(s=f.updateQueue,s!==null)){if(o=null,f.child!==null)switch(f.child.tag){case 27:case 5:o=f.child.stateNode;break;case 1:o=f.child.stateNode}try{gy(s,o)}catch(F){Ot(f,f.return,F)}}break;case 27:o===null&&g&4&&Ab(f);case 26:case 5:fs(s,f),o===null&&g&4&&Nb(f),g&512&&qo(f,f.return);break;case 12:fs(s,f);break;case 31:fs(s,f),g&4&&Ib(s,f);break;case 13:fs(s,f),g&4&&Mb(s,f),g&64&&(s=f.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(f=Q2.bind(null,f),xE(s,f))));break;case 22:if(g=f.memoizedState!==null||ds,!g){o=o!==null&&o.memoizedState!==null||on,k=ds;var A=on;ds=g,(on=o)&&!A?ms(s,f,(f.subtreeFlags&8772)!==0):fs(s,f),ds=k,on=A}break;case 30:break;default:fs(s,f)}}function Rb(s){var o=s.alternate;o!==null&&(s.alternate=null,Rb(o)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(o=s.stateNode,o!==null&&nh(o)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var Yt=null,Gn=!1;function hs(s,o,f){for(f=f.child;f!==null;)Ob(s,o,f),f=f.sibling}function Ob(s,o,f){if(et&&typeof et.onCommitFiberUnmount=="function")try{et.onCommitFiberUnmount(ct,f)}catch{}switch(f.tag){case 26:on||Ur(f,o),hs(s,o,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:on||Ur(f,o);var g=Yt,k=Gn;Ys(f.type)&&(Yt=f.stateNode,Gn=!1),hs(s,o,f),nl(f.stateNode),Yt=g,Gn=k;break;case 5:on||Ur(f,o);case 6:if(g=Yt,k=Gn,Yt=null,hs(s,o,f),Yt=g,Gn=k,Yt!==null)if(Gn)try{(Yt.nodeType===9?Yt.body:Yt.nodeName==="HTML"?Yt.ownerDocument.body:Yt).removeChild(f.stateNode)}catch(A){Ot(f,o,A)}else try{Yt.removeChild(f.stateNode)}catch(A){Ot(f,o,A)}break;case 18:Yt!==null&&(Gn?(s=Yt,jv(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,f.stateNode),Ha(s)):jv(Yt,f.stateNode));break;case 4:g=Yt,k=Gn,Yt=f.stateNode.containerInfo,Gn=!0,hs(s,o,f),Yt=g,Gn=k;break;case 0:case 11:case 14:case 15:Us(2,f,o),on||Us(4,f,o),hs(s,o,f);break;case 1:on||(Ur(f,o),g=f.stateNode,typeof g.componentWillUnmount=="function"&&Eb(f,o,g)),hs(s,o,f);break;case 21:hs(s,o,f);break;case 22:on=(g=on)||f.memoizedState!==null,hs(s,o,f),on=g;break;default:hs(s,o,f)}}function Ib(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Ha(s)}catch(f){Ot(o,o.return,f)}}}function Mb(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Ha(s)}catch(f){Ot(o,o.return,f)}}function F2(s){switch(s.tag){case 31:case 13:case 19:var o=s.stateNode;return o===null&&(o=s.stateNode=new Lb),o;case 22:return s=s.stateNode,o=s._retryCache,o===null&&(o=s._retryCache=new Lb),o;default:throw Error(r(435,s.tag))}}function Gc(s,o){var f=F2(s);o.forEach(function(g){if(!f.has(g)){f.add(g);var k=J2.bind(null,s,g);g.then(k,k)}})}function qn(s,o){var f=o.deletions;if(f!==null)for(var g=0;g<f.length;g++){var k=f[g],A=s,F=o,Y=F;e:for(;Y!==null;){switch(Y.tag){case 27:if(Ys(Y.type)){Yt=Y.stateNode,Gn=!1;break e}break;case 5:Yt=Y.stateNode,Gn=!1;break e;case 3:case 4:Yt=Y.stateNode.containerInfo,Gn=!0;break e}Y=Y.return}if(Yt===null)throw Error(r(160));Ob(A,F,k),Yt=null,Gn=!1,A=k.alternate,A!==null&&(A.return=null),k.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)Pb(o,s),o=o.sibling}var Ar=null;function Pb(s,o){var f=s.alternate,g=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:qn(o,s),Kn(s),g&4&&(Us(3,s,s.return),Go(3,s),Us(5,s,s.return));break;case 1:qn(o,s),Kn(s),g&512&&(on||f===null||Ur(f,f.return)),g&64&&ds&&(s=s.updateQueue,s!==null&&(g=s.callbacks,g!==null&&(f=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=f===null?g:f.concat(g))));break;case 26:var k=Ar;if(qn(o,s),Kn(s),g&512&&(on||f===null||Ur(f,f.return)),g&4){var A=f!==null?f.memoizedState:null;if(g=s.memoizedState,f===null)if(g===null)if(s.stateNode===null){e:{g=s.type,f=s.memoizedProps,k=k.ownerDocument||k;t:switch(g){case"title":A=k.getElementsByTagName("title")[0],(!A||A[vo]||A[Qe]||A.namespaceURI==="http://www.w3.org/2000/svg"||A.hasAttribute("itemprop"))&&(A=k.createElement(g),k.head.insertBefore(A,k.querySelector("head > title"))),En(A,g,f),A[Qe]=s,bn(A),g=A;break e;case"link":var F=Pv("link","href",k).get(g+(f.href||""));if(F){for(var Y=0;Y<F.length;Y++)if(A=F[Y],A.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&A.getAttribute("rel")===(f.rel==null?null:f.rel)&&A.getAttribute("title")===(f.title==null?null:f.title)&&A.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){F.splice(Y,1);break t}}A=k.createElement(g),En(A,g,f),k.head.appendChild(A);break;case"meta":if(F=Pv("meta","content",k).get(g+(f.content||""))){for(Y=0;Y<F.length;Y++)if(A=F[Y],A.getAttribute("content")===(f.content==null?null:""+f.content)&&A.getAttribute("name")===(f.name==null?null:f.name)&&A.getAttribute("property")===(f.property==null?null:f.property)&&A.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&A.getAttribute("charset")===(f.charSet==null?null:f.charSet)){F.splice(Y,1);break t}}A=k.createElement(g),En(A,g,f),k.head.appendChild(A);break;default:throw Error(r(468,g))}A[Qe]=s,bn(A),g=A}s.stateNode=g}else Bv(k,s.type,s.stateNode);else s.stateNode=Mv(k,g,s.memoizedProps);else A!==g?(A===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):A.count--,g===null?Bv(k,s.type,s.stateNode):Mv(k,g,s.memoizedProps)):g===null&&s.stateNode!==null&&Cf(s,s.memoizedProps,f.memoizedProps)}break;case 27:qn(o,s),Kn(s),g&512&&(on||f===null||Ur(f,f.return)),f!==null&&g&4&&Cf(s,s.memoizedProps,f.memoizedProps);break;case 5:if(qn(o,s),Kn(s),g&512&&(on||f===null||Ur(f,f.return)),s.flags&32){k=s.stateNode;try{ua(k,"")}catch(qe){Ot(s,s.return,qe)}}g&4&&s.stateNode!=null&&(k=s.memoizedProps,Cf(s,k,f!==null?f.memoizedProps:k)),g&1024&&(Ef=!0);break;case 6:if(qn(o,s),Kn(s),g&4){if(s.stateNode===null)throw Error(r(162));g=s.memoizedProps,f=s.stateNode;try{f.nodeValue=g}catch(qe){Ot(s,s.return,qe)}}break;case 3:if(lu=null,k=Ar,Ar=au(o.containerInfo),qn(o,s),Ar=k,Kn(s),g&4&&f!==null&&f.memoizedState.isDehydrated)try{Ha(o.containerInfo)}catch(qe){Ot(s,s.return,qe)}Ef&&(Ef=!1,Bb(s));break;case 4:g=Ar,Ar=au(s.stateNode.containerInfo),qn(o,s),Kn(s),Ar=g;break;case 12:qn(o,s),Kn(s);break;case 31:qn(o,s),Kn(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Gc(s,g)));break;case 13:qn(o,s),Kn(s),s.child.flags&8192&&s.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(Kc=He()),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Gc(s,g)));break;case 22:k=s.memoizedState!==null;var le=f!==null&&f.memoizedState!==null,pe=ds,Ce=on;if(ds=pe||k,on=Ce||le,qn(o,s),on=Ce,ds=pe,Kn(s),g&8192)e:for(o=s.stateNode,o._visibility=k?o._visibility&-2:o._visibility|1,k&&(f===null||le||ds||on||Oi(s)),f=null,o=s;;){if(o.tag===5||o.tag===26){if(f===null){le=f=o;try{if(A=le.stateNode,k)F=A.style,typeof F.setProperty=="function"?F.setProperty("display","none","important"):F.display="none";else{Y=le.stateNode;var Ae=le.memoizedProps.style,ge=Ae!=null&&Ae.hasOwnProperty("display")?Ae.display:null;Y.style.display=ge==null||typeof ge=="boolean"?"":(""+ge).trim()}}catch(qe){Ot(le,le.return,qe)}}}else if(o.tag===6){if(f===null){le=o;try{le.stateNode.nodeValue=k?"":le.memoizedProps}catch(qe){Ot(le,le.return,qe)}}}else if(o.tag===18){if(f===null){le=o;try{var xe=le.stateNode;k?Ev(xe,!0):Ev(le.stateNode,!1)}catch(qe){Ot(le,le.return,qe)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===s)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break e;for(;o.sibling===null;){if(o.return===null||o.return===s)break e;f===o&&(f=null),o=o.return}f===o&&(f=null),o.sibling.return=o.return,o=o.sibling}g&4&&(g=s.updateQueue,g!==null&&(f=g.retryQueue,f!==null&&(g.retryQueue=null,Gc(s,f))));break;case 19:qn(o,s),Kn(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Gc(s,g)));break;case 30:break;case 21:break;default:qn(o,s),Kn(s)}}function Kn(s){var o=s.flags;if(o&2){try{for(var f,g=s.return;g!==null;){if(Tb(g)){f=g;break}g=g.return}if(f==null)throw Error(r(160));switch(f.tag){case 27:var k=f.stateNode,A=kf(s);Wc(s,A,k);break;case 5:var F=f.stateNode;f.flags&32&&(ua(F,""),f.flags&=-33);var Y=kf(s);Wc(s,Y,F);break;case 3:case 4:var le=f.stateNode.containerInfo,pe=kf(s);jf(s,pe,le);break;default:throw Error(r(161))}}catch(Ce){Ot(s,s.return,Ce)}s.flags&=-3}o&4096&&(s.flags&=-4097)}function Bb(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var o=s;Bb(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),s=s.sibling}}function fs(s,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)Db(s,o.alternate,o),o=o.sibling}function Oi(s){for(s=s.child;s!==null;){var o=s;switch(o.tag){case 0:case 11:case 14:case 15:Us(4,o,o.return),Oi(o);break;case 1:Ur(o,o.return);var f=o.stateNode;typeof f.componentWillUnmount=="function"&&Eb(o,o.return,f),Oi(o);break;case 27:nl(o.stateNode);case 26:case 5:Ur(o,o.return),Oi(o);break;case 22:o.memoizedState===null&&Oi(o);break;case 30:Oi(o);break;default:Oi(o)}s=s.sibling}}function ms(s,o,f){for(f=f&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var g=o.alternate,k=s,A=o,F=A.flags;switch(A.tag){case 0:case 11:case 15:ms(k,A,f),Go(4,A);break;case 1:if(ms(k,A,f),g=A,k=g.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(pe){Ot(g,g.return,pe)}if(g=A,k=g.updateQueue,k!==null){var Y=g.stateNode;try{var le=k.shared.hiddenCallbacks;if(le!==null)for(k.shared.hiddenCallbacks=null,k=0;k<le.length;k++)py(le[k],Y)}catch(pe){Ot(g,g.return,pe)}}f&&F&64&&jb(A),qo(A,A.return);break;case 27:Ab(A);case 26:case 5:ms(k,A,f),f&&g===null&&F&4&&Nb(A),qo(A,A.return);break;case 12:ms(k,A,f);break;case 31:ms(k,A,f),f&&F&4&&Ib(k,A);break;case 13:ms(k,A,f),f&&F&4&&Mb(k,A);break;case 22:A.memoizedState===null&&ms(k,A,f),qo(A,A.return);break;case 30:break;default:ms(k,A,f)}o=o.sibling}}function Nf(s,o){var f=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(f=s.memoizedState.cachePool.pool),s=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(s=o.memoizedState.cachePool.pool),s!==f&&(s!=null&&s.refCount++,f!=null&&Ro(f))}function Tf(s,o){s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&Ro(s))}function Lr(s,o,f,g){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)$b(s,o,f,g),o=o.sibling}function $b(s,o,f,g){var k=o.flags;switch(o.tag){case 0:case 11:case 15:Lr(s,o,f,g),k&2048&&Go(9,o);break;case 1:Lr(s,o,f,g);break;case 3:Lr(s,o,f,g),k&2048&&(s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&Ro(s)));break;case 12:if(k&2048){Lr(s,o,f,g),s=o.stateNode;try{var A=o.memoizedProps,F=A.id,Y=A.onPostCommit;typeof Y=="function"&&Y(F,o.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(le){Ot(o,o.return,le)}}else Lr(s,o,f,g);break;case 31:Lr(s,o,f,g);break;case 13:Lr(s,o,f,g);break;case 23:break;case 22:A=o.stateNode,F=o.alternate,o.memoizedState!==null?A._visibility&2?Lr(s,o,f,g):Ko(s,o):A._visibility&2?Lr(s,o,f,g):(A._visibility|=2,Aa(s,o,f,g,(o.subtreeFlags&10256)!==0||!1)),k&2048&&Nf(F,o);break;case 24:Lr(s,o,f,g),k&2048&&Tf(o.alternate,o);break;default:Lr(s,o,f,g)}}function Aa(s,o,f,g,k){for(k=k&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var A=s,F=o,Y=f,le=g,pe=F.flags;switch(F.tag){case 0:case 11:case 15:Aa(A,F,Y,le,k),Go(8,F);break;case 23:break;case 22:var Ce=F.stateNode;F.memoizedState!==null?Ce._visibility&2?Aa(A,F,Y,le,k):Ko(A,F):(Ce._visibility|=2,Aa(A,F,Y,le,k)),k&&pe&2048&&Nf(F.alternate,F);break;case 24:Aa(A,F,Y,le,k),k&&pe&2048&&Tf(F.alternate,F);break;default:Aa(A,F,Y,le,k)}o=o.sibling}}function Ko(s,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var f=s,g=o,k=g.flags;switch(g.tag){case 22:Ko(f,g),k&2048&&Nf(g.alternate,g);break;case 24:Ko(f,g),k&2048&&Tf(g.alternate,g);break;default:Ko(f,g)}o=o.sibling}}var Yo=8192;function La(s,o,f){if(s.subtreeFlags&Yo)for(s=s.child;s!==null;)zb(s,o,f),s=s.sibling}function zb(s,o,f){switch(s.tag){case 26:La(s,o,f),s.flags&Yo&&s.memoizedState!==null&&TE(f,Ar,s.memoizedState,s.memoizedProps);break;case 5:La(s,o,f);break;case 3:case 4:var g=Ar;Ar=au(s.stateNode.containerInfo),La(s,o,f),Ar=g;break;case 22:s.memoizedState===null&&(g=s.alternate,g!==null&&g.memoizedState!==null?(g=Yo,Yo=16777216,La(s,o,f),Yo=g):La(s,o,f));break;default:La(s,o,f)}}function Hb(s){var o=s.alternate;if(o!==null&&(s=o.child,s!==null)){o.child=null;do o=s.sibling,s.sibling=null,s=o;while(s!==null)}}function Xo(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var g=o[f];vn=g,Fb(g,s)}Hb(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Ub(s),s=s.sibling}function Ub(s){switch(s.tag){case 0:case 11:case 15:Xo(s),s.flags&2048&&Us(9,s,s.return);break;case 3:Xo(s);break;case 12:Xo(s);break;case 22:var o=s.stateNode;s.memoizedState!==null&&o._visibility&2&&(s.return===null||s.return.tag!==13)?(o._visibility&=-3,qc(s)):Xo(s);break;default:Xo(s)}}function qc(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var g=o[f];vn=g,Fb(g,s)}Hb(s)}for(s=s.child;s!==null;){switch(o=s,o.tag){case 0:case 11:case 15:Us(8,o,o.return),qc(o);break;case 22:f=o.stateNode,f._visibility&2&&(f._visibility&=-3,qc(o));break;default:qc(o)}s=s.sibling}}function Fb(s,o){for(;vn!==null;){var f=vn;switch(f.tag){case 0:case 11:case 15:Us(8,f,o);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var g=f.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:Ro(f.memoizedState.cache)}if(g=f.child,g!==null)g.return=f,vn=g;else e:for(f=s;vn!==null;){g=vn;var k=g.sibling,A=g.return;if(Rb(g),g===f){vn=null;break e}if(k!==null){k.return=A,vn=k;break e}vn=A}}}var V2={getCacheForType:function(s){var o=kn(rn),f=o.data.get(s);return f===void 0&&(f=s(),o.data.set(s,f)),f},cacheSignal:function(){return kn(rn).controller.signal}},W2=typeof WeakMap=="function"?WeakMap:Map,At=0,$t=null,yt=null,St=0,Rt=0,ar=null,Fs=!1,Da=!1,Af=!1,ps=0,Zt=0,Vs=0,Ii=0,Lf=0,or=0,Ra=0,Qo=null,Yn=null,Df=!1,Kc=0,Vb=0,Yc=1/0,Xc=null,Ws=null,mn=0,Gs=null,Oa=null,gs=0,Rf=0,Of=null,Wb=null,Jo=0,If=null;function lr(){return(At&2)!==0&&St!==0?St&-St:V.T!==null?Hf():Me()}function Gb(){if(or===0)if((St&536870912)===0||kt){var s=Fn;Fn<<=1,(Fn&3932160)===0&&(Fn=262144),or=s}else or=536870912;return s=sr.current,s!==null&&(s.flags|=32),or}function Xn(s,o,f){(s===$t&&(Rt===2||Rt===9)||s.cancelPendingCommit!==null)&&(Ia(s,0),qs(s,St,or,!1)),wn(s,f),((At&2)===0||s!==$t)&&(s===$t&&((At&2)===0&&(Ii|=f),Zt===4&&qs(s,St,or,!1)),Fr(s))}function qb(s,o,f){if((At&6)!==0)throw Error(r(327));var g=!f&&(o&127)===0&&(o&s.expiredLanes)===0||Ne(s,o),k=g?K2(s,o):Pf(s,o,!0),A=g;do{if(k===0){Da&&!g&&qs(s,o,0,!1);break}else{if(f=s.current.alternate,A&&!G2(f)){k=Pf(s,o,!1),A=!1;continue}if(k===2){if(A=o,s.errorRecoveryDisabledLanes&A)var F=0;else F=s.pendingLanes&-536870913,F=F!==0?F:F&536870912?536870912:0;if(F!==0){o=F;e:{var Y=s;k=Qo;var le=Y.current.memoizedState.isDehydrated;if(le&&(Ia(Y,F).flags|=256),F=Pf(Y,F,!1),F!==2){if(Af&&!le){Y.errorRecoveryDisabledLanes|=A,Ii|=A,k=4;break e}A=Yn,Yn=k,A!==null&&(Yn===null?Yn=A:Yn.push.apply(Yn,A))}k=F}if(A=!1,k!==2)continue}}if(k===1){Ia(s,0),qs(s,o,0,!0);break}e:{switch(g=s,A=k,A){case 0:case 1:throw Error(r(345));case 4:if((o&4194048)!==o)break;case 6:qs(g,o,or,!Fs);break e;case 2:Yn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((o&62914560)===o&&(k=Kc+300-He(),10<k)){if(qs(g,o,or,!Fs),ve(g,0,!0)!==0)break e;gs=o,g.timeoutHandle=Cv(Kb.bind(null,g,f,Yn,Xc,Df,o,or,Ii,Ra,Fs,A,"Throttled",-0,0),k);break e}Kb(g,f,Yn,Xc,Df,o,or,Ii,Ra,Fs,A,null,-0,0)}}break}while(!0);Fr(s)}function Kb(s,o,f,g,k,A,F,Y,le,pe,Ce,Ae,ge,xe){if(s.timeoutHandle=-1,Ae=o.subtreeFlags,Ae&8192||(Ae&16785408)===16785408){Ae={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ts},zb(o,A,Ae);var qe=(A&62914560)===A?Kc-He():(A&4194048)===A?Vb-He():0;if(qe=AE(Ae,qe),qe!==null){gs=A,s.cancelPendingCommit=qe(nv.bind(null,s,o,A,f,g,k,F,Y,le,Ce,Ae,null,ge,xe)),qs(s,A,F,!pe);return}}nv(s,o,A,f,g,k,F,Y,le)}function G2(s){for(var o=s;;){var f=o.tag;if((f===0||f===11||f===15)&&o.flags&16384&&(f=o.updateQueue,f!==null&&(f=f.stores,f!==null)))for(var g=0;g<f.length;g++){var k=f[g],A=k.getSnapshot;k=k.value;try{if(!nr(A(),k))return!1}catch{return!1}}if(f=o.child,o.subtreeFlags&16384&&f!==null)f.return=o,o=f;else{if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function qs(s,o,f,g){o&=~Lf,o&=~Ii,s.suspendedLanes|=o,s.pingedLanes&=~o,g&&(s.warmLanes|=o),g=s.expirationTimes;for(var k=o;0<k;){var A=31-ot(k),F=1<<A;g[A]=-1,k&=~F}f!==0&&yi(s,f,o)}function Qc(){return(At&6)===0?(Zo(0),!1):!0}function Mf(){if(yt!==null){if(Rt===0)var s=yt.return;else s=yt,is=ji=null,Qh(s),ka=null,Io=0,s=yt;for(;s!==null;)kb(s.alternate,s),s=s.return;yt=null}}function Ia(s,o){var f=s.timeoutHandle;f!==-1&&(s.timeoutHandle=-1,hE(f)),f=s.cancelPendingCommit,f!==null&&(s.cancelPendingCommit=null,f()),gs=0,Mf(),$t=s,yt=f=rs(s.current,null),St=o,Rt=0,ar=null,Fs=!1,Da=Ne(s,o),Af=!1,Ra=or=Lf=Ii=Vs=Zt=0,Yn=Qo=null,Df=!1,(o&8)!==0&&(o|=o&32);var g=s.entangledLanes;if(g!==0)for(s=s.entanglements,g&=o;0<g;){var k=31-ot(g),A=1<<k;o|=s[k],g&=~A}return ps=o,yc(),f}function Yb(s,o){ft=null,V.H=Fo,o===Ca||o===jc?(o=dy(),Rt=3):o===$h?(o=dy(),Rt=4):Rt=o===mf?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,ar=o,yt===null&&(Zt=1,zc(s,pr(o,s.current)))}function Xb(){var s=sr.current;return s===null?!0:(St&4194048)===St?br===null:(St&62914560)===St||(St&536870912)!==0?s===br:!1}function Qb(){var s=V.H;return V.H=Fo,s===null?Fo:s}function Jb(){var s=V.A;return V.A=V2,s}function Jc(){Zt=4,Fs||(St&4194048)!==St&&sr.current!==null||(Da=!0),(Vs&134217727)===0&&(Ii&134217727)===0||$t===null||qs($t,St,or,!1)}function Pf(s,o,f){var g=At;At|=2;var k=Qb(),A=Jb();($t!==s||St!==o)&&(Xc=null,Ia(s,o)),o=!1;var F=Zt;e:do try{if(Rt!==0&&yt!==null){var Y=yt,le=ar;switch(Rt){case 8:Mf(),F=6;break e;case 3:case 2:case 9:case 6:sr.current===null&&(o=!0);var pe=Rt;if(Rt=0,ar=null,Ma(s,Y,le,pe),f&&Da){F=0;break e}break;default:pe=Rt,Rt=0,ar=null,Ma(s,Y,le,pe)}}q2(),F=Zt;break}catch(Ce){Yb(s,Ce)}while(!0);return o&&s.shellSuspendCounter++,is=ji=null,At=g,V.H=k,V.A=A,yt===null&&($t=null,St=0,yc()),F}function q2(){for(;yt!==null;)Zb(yt)}function K2(s,o){var f=At;At|=2;var g=Qb(),k=Jb();$t!==s||St!==o?(Xc=null,Yc=He()+500,Ia(s,o)):Da=Ne(s,o);e:do try{if(Rt!==0&&yt!==null){o=yt;var A=ar;t:switch(Rt){case 1:Rt=0,ar=null,Ma(s,o,A,1);break;case 2:case 9:if(cy(A)){Rt=0,ar=null,ev(o);break}o=function(){Rt!==2&&Rt!==9||$t!==s||(Rt=7),Fr(s)},A.then(o,o);break e;case 3:Rt=7;break e;case 4:Rt=5;break e;case 7:cy(A)?(Rt=0,ar=null,ev(o)):(Rt=0,ar=null,Ma(s,o,A,7));break;case 5:var F=null;switch(yt.tag){case 26:F=yt.memoizedState;case 5:case 27:var Y=yt;if(F?$v(F):Y.stateNode.complete){Rt=0,ar=null;var le=Y.sibling;if(le!==null)yt=le;else{var pe=Y.return;pe!==null?(yt=pe,Zc(pe)):yt=null}break t}}Rt=0,ar=null,Ma(s,o,A,5);break;case 6:Rt=0,ar=null,Ma(s,o,A,6);break;case 8:Mf(),Zt=6;break e;default:throw Error(r(462))}}Y2();break}catch(Ce){Yb(s,Ce)}while(!0);return is=ji=null,V.H=g,V.A=k,At=f,yt!==null?0:($t=null,St=0,yc(),Zt)}function Y2(){for(;yt!==null&&!lt();)Zb(yt)}function Zb(s){var o=wb(s.alternate,s,ps);s.memoizedProps=s.pendingProps,o===null?Zc(s):yt=o}function ev(s){var o=s,f=o.alternate;switch(o.tag){case 15:case 0:o=xb(f,o,o.pendingProps,o.type,void 0,St);break;case 11:o=xb(f,o,o.pendingProps,o.type.render,o.ref,St);break;case 5:Qh(o);default:kb(f,o),o=yt=Jx(o,ps),o=wb(f,o,ps)}s.memoizedProps=s.pendingProps,o===null?Zc(s):yt=o}function Ma(s,o,f,g){is=ji=null,Qh(o),ka=null,Io=0;var k=o.return;try{if(P2(s,k,o,f,St)){Zt=1,zc(s,pr(f,s.current)),yt=null;return}}catch(A){if(k!==null)throw yt=k,A;Zt=1,zc(s,pr(f,s.current)),yt=null;return}o.flags&32768?(kt||g===1?s=!0:Da||(St&536870912)!==0?s=!1:(Fs=s=!0,(g===2||g===9||g===3||g===6)&&(g=sr.current,g!==null&&g.tag===13&&(g.flags|=16384))),tv(o,s)):Zc(o)}function Zc(s){var o=s;do{if((o.flags&32768)!==0){tv(o,Fs);return}s=o.return;var f=z2(o.alternate,o,ps);if(f!==null){yt=f;return}if(o=o.sibling,o!==null){yt=o;return}yt=o=s}while(o!==null);Zt===0&&(Zt=5)}function tv(s,o){do{var f=H2(s.alternate,s);if(f!==null){f.flags&=32767,yt=f;return}if(f=s.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!o&&(s=s.sibling,s!==null)){yt=s;return}yt=s=f}while(s!==null);Zt=6,yt=null}function nv(s,o,f,g,k,A,F,Y,le){s.cancelPendingCommit=null;do eu();while(mn!==0);if((At&6)!==0)throw Error(r(327));if(o!==null){if(o===s.current)throw Error(r(177));if(A=o.lanes|o.childLanes,A|=Ch,An(s,f,A,F,Y,le),s===$t&&(yt=$t=null,St=0),Oa=o,Gs=s,gs=f,Rf=A,Of=k,Wb=g,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,Z2(ie,function(){return ov(),null})):(s.callbackNode=null,s.callbackPriority=0),g=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||g){g=V.T,V.T=null,k=ee.p,ee.p=2,F=At,At|=4;try{U2(s,o,f)}finally{At=F,ee.p=k,V.T=g}}mn=1,rv(),sv(),iv()}}function rv(){if(mn===1){mn=0;var s=Gs,o=Oa,f=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||f){f=V.T,V.T=null;var g=ee.p;ee.p=2;var k=At;At|=4;try{Pb(o,s);var A=Yf,F=Fx(s.containerInfo),Y=A.focusedElem,le=A.selectionRange;if(F!==Y&&Y&&Y.ownerDocument&&Ux(Y.ownerDocument.documentElement,Y)){if(le!==null&&bh(Y)){var pe=le.start,Ce=le.end;if(Ce===void 0&&(Ce=pe),"selectionStart"in Y)Y.selectionStart=pe,Y.selectionEnd=Math.min(Ce,Y.value.length);else{var Ae=Y.ownerDocument||document,ge=Ae&&Ae.defaultView||window;if(ge.getSelection){var xe=ge.getSelection(),qe=Y.textContent.length,it=Math.min(le.start,qe),Pt=le.end===void 0?it:Math.min(le.end,qe);!xe.extend&&it>Pt&&(F=Pt,Pt=it,it=F);var de=Hx(Y,it),ue=Hx(Y,Pt);if(de&&ue&&(xe.rangeCount!==1||xe.anchorNode!==de.node||xe.anchorOffset!==de.offset||xe.focusNode!==ue.node||xe.focusOffset!==ue.offset)){var fe=Ae.createRange();fe.setStart(de.node,de.offset),xe.removeAllRanges(),it>Pt?(xe.addRange(fe),xe.extend(ue.node,ue.offset)):(fe.setEnd(ue.node,ue.offset),xe.addRange(fe))}}}}for(Ae=[],xe=Y;xe=xe.parentNode;)xe.nodeType===1&&Ae.push({element:xe,left:xe.scrollLeft,top:xe.scrollTop});for(typeof Y.focus=="function"&&Y.focus(),Y=0;Y<Ae.length;Y++){var Ee=Ae[Y];Ee.element.scrollLeft=Ee.left,Ee.element.scrollTop=Ee.top}}hu=!!Kf,Yf=Kf=null}finally{At=k,ee.p=g,V.T=f}}s.current=o,mn=2}}function sv(){if(mn===2){mn=0;var s=Gs,o=Oa,f=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||f){f=V.T,V.T=null;var g=ee.p;ee.p=2;var k=At;At|=4;try{Db(s,o.alternate,o)}finally{At=k,ee.p=g,V.T=f}}mn=3}}function iv(){if(mn===4||mn===3){mn=0,we();var s=Gs,o=Oa,f=gs,g=Wb;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?mn=5:(mn=0,Oa=Gs=null,av(s,s.pendingLanes));var k=s.pendingLanes;if(k===0&&(Ws=null),Se(f),o=o.stateNode,et&&typeof et.onCommitFiberRoot=="function")try{et.onCommitFiberRoot(ct,o,void 0,(o.current.flags&128)===128)}catch{}if(g!==null){o=V.T,k=ee.p,ee.p=2,V.T=null;try{for(var A=s.onRecoverableError,F=0;F<g.length;F++){var Y=g[F];A(Y.value,{componentStack:Y.stack})}}finally{V.T=o,ee.p=k}}(gs&3)!==0&&eu(),Fr(s),k=s.pendingLanes,(f&261930)!==0&&(k&42)!==0?s===If?Jo++:(Jo=0,If=s):Jo=0,Zo(0)}}function av(s,o){(s.pooledCacheLanes&=o)===0&&(o=s.pooledCache,o!=null&&(s.pooledCache=null,Ro(o)))}function eu(){return rv(),sv(),iv(),ov()}function ov(){if(mn!==5)return!1;var s=Gs,o=Rf;Rf=0;var f=Se(gs),g=V.T,k=ee.p;try{ee.p=32>f?32:f,V.T=null,f=Of,Of=null;var A=Gs,F=gs;if(mn=0,Oa=Gs=null,gs=0,(At&6)!==0)throw Error(r(331));var Y=At;if(At|=4,Ub(A.current),$b(A,A.current,F,f),At=Y,Zo(0,!1),et&&typeof et.onPostCommitFiberRoot=="function")try{et.onPostCommitFiberRoot(ct,A)}catch{}return!0}finally{ee.p=k,V.T=g,av(s,o)}}function lv(s,o,f){o=pr(f,o),o=ff(s.stateNode,o,2),s=$s(s,o,2),s!==null&&(wn(s,2),Fr(s))}function Ot(s,o,f){if(s.tag===3)lv(s,s,f);else for(;o!==null;){if(o.tag===3){lv(o,s,f);break}else if(o.tag===1){var g=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Ws===null||!Ws.has(g))){s=pr(f,s),f=cb(2),g=$s(o,f,2),g!==null&&(ub(f,g,o,s),wn(g,2),Fr(g));break}}o=o.return}}function Bf(s,o,f){var g=s.pingCache;if(g===null){g=s.pingCache=new W2;var k=new Set;g.set(o,k)}else k=g.get(o),k===void 0&&(k=new Set,g.set(o,k));k.has(f)||(Af=!0,k.add(f),s=X2.bind(null,s,o,f),o.then(s,s))}function X2(s,o,f){var g=s.pingCache;g!==null&&g.delete(o),s.pingedLanes|=s.suspendedLanes&f,s.warmLanes&=~f,$t===s&&(St&f)===f&&(Zt===4||Zt===3&&(St&62914560)===St&&300>He()-Kc?(At&2)===0&&Ia(s,0):Lf|=f,Ra===St&&(Ra=0)),Fr(s)}function cv(s,o){o===0&&(o=Je()),s=wi(s,o),s!==null&&(wn(s,o),Fr(s))}function Q2(s){var o=s.memoizedState,f=0;o!==null&&(f=o.retryLane),cv(s,f)}function J2(s,o){var f=0;switch(s.tag){case 31:case 13:var g=s.stateNode,k=s.memoizedState;k!==null&&(f=k.retryLane);break;case 19:g=s.stateNode;break;case 22:g=s.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(o),cv(s,f)}function Z2(s,o){return ke(s,o)}var tu=null,Pa=null,$f=!1,nu=!1,zf=!1,Ks=0;function Fr(s){s!==Pa&&s.next===null&&(Pa===null?tu=Pa=s:Pa=Pa.next=s),nu=!0,$f||($f=!0,tE())}function Zo(s,o){if(!zf&&nu){zf=!0;do for(var f=!1,g=tu;g!==null;){if(s!==0){var k=g.pendingLanes;if(k===0)var A=0;else{var F=g.suspendedLanes,Y=g.pingedLanes;A=(1<<31-ot(42|s)+1)-1,A&=k&~(F&~Y),A=A&201326741?A&201326741|1:A?A|2:0}A!==0&&(f=!0,fv(g,A))}else A=St,A=ve(g,g===$t?A:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(A&3)===0||Ne(g,A)||(f=!0,fv(g,A));g=g.next}while(f);zf=!1}}function eE(){uv()}function uv(){nu=$f=!1;var s=0;Ks!==0&&dE()&&(s=Ks);for(var o=He(),f=null,g=tu;g!==null;){var k=g.next,A=dv(g,o);A===0?(g.next=null,f===null?tu=k:f.next=k,k===null&&(Pa=f)):(f=g,(s!==0||(A&3)!==0)&&(nu=!0)),g=k}mn!==0&&mn!==5||Zo(s),Ks!==0&&(Ks=0)}function dv(s,o){for(var f=s.suspendedLanes,g=s.pingedLanes,k=s.expirationTimes,A=s.pendingLanes&-62914561;0<A;){var F=31-ot(A),Y=1<<F,le=k[F];le===-1?((Y&f)===0||(Y&g)!==0)&&(k[F]=Oe(Y,o)):le<=o&&(s.expiredLanes|=Y),A&=~Y}if(o=$t,f=St,f=ve(s,s===o?f:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g=s.callbackNode,f===0||s===o&&(Rt===2||Rt===9)||s.cancelPendingCommit!==null)return g!==null&&g!==null&&ze(g),s.callbackNode=null,s.callbackPriority=0;if((f&3)===0||Ne(s,f)){if(o=f&-f,o===s.callbackPriority)return o;switch(g!==null&&ze(g),Se(f)){case 2:case 8:f=oe;break;case 32:f=ie;break;case 268435456:f=Ue;break;default:f=ie}return g=hv.bind(null,s),f=ke(f,g),s.callbackPriority=o,s.callbackNode=f,o}return g!==null&&g!==null&&ze(g),s.callbackPriority=2,s.callbackNode=null,2}function hv(s,o){if(mn!==0&&mn!==5)return s.callbackNode=null,s.callbackPriority=0,null;var f=s.callbackNode;if(eu()&&s.callbackNode!==f)return null;var g=St;return g=ve(s,s===$t?g:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g===0?null:(qb(s,g,o),dv(s,He()),s.callbackNode!=null&&s.callbackNode===f?hv.bind(null,s):null)}function fv(s,o){if(eu())return null;qb(s,o,!0)}function tE(){fE(function(){(At&6)!==0?ke(Z,eE):uv()})}function Hf(){if(Ks===0){var s=Sa;s===0&&(s=yn,yn<<=1,(yn&261888)===0&&(yn=256)),Ks=s}return Ks}function mv(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:uc(""+s)}function pv(s,o){var f=o.ownerDocument.createElement("input");return f.name=o.name,f.value=o.value,s.id&&f.setAttribute("form",s.id),o.parentNode.insertBefore(f,o),s=new FormData(s),f.parentNode.removeChild(f),s}function nE(s,o,f,g,k){if(o==="submit"&&f&&f.stateNode===k){var A=mv((k[nt]||null).action),F=g.submitter;F&&(o=(o=F[nt]||null)?mv(o.formAction):F.getAttribute("formAction"),o!==null&&(A=o,F=null));var Y=new mc("action","action",null,g,k);s.push({event:Y,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(Ks!==0){var le=F?pv(k,F):new FormData(k);of(f,{pending:!0,data:le,method:k.method,action:A},null,le)}}else typeof A=="function"&&(Y.preventDefault(),le=F?pv(k,F):new FormData(k),of(f,{pending:!0,data:le,method:k.method,action:A},A,le))},currentTarget:k}]})}}for(var Uf=0;Uf<wh.length;Uf++){var Ff=wh[Uf],rE=Ff.toLowerCase(),sE=Ff[0].toUpperCase()+Ff.slice(1);Tr(rE,"on"+sE)}Tr(Gx,"onAnimationEnd"),Tr(qx,"onAnimationIteration"),Tr(Kx,"onAnimationStart"),Tr("dblclick","onDoubleClick"),Tr("focusin","onFocus"),Tr("focusout","onBlur"),Tr(v2,"onTransitionRun"),Tr(_2,"onTransitionStart"),Tr(S2,"onTransitionCancel"),Tr(Yx,"onTransitionEnd"),la("onMouseEnter",["mouseout","mouseover"]),la("onMouseLeave",["mouseout","mouseover"]),la("onPointerEnter",["pointerout","pointerover"]),la("onPointerLeave",["pointerout","pointerover"]),bi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),bi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),bi("onBeforeInput",["compositionend","keypress","textInput","paste"]),bi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),bi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),bi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var el="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(" "),iE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(el));function gv(s,o){o=(o&4)!==0;for(var f=0;f<s.length;f++){var g=s[f],k=g.event;g=g.listeners;e:{var A=void 0;if(o)for(var F=g.length-1;0<=F;F--){var Y=g[F],le=Y.instance,pe=Y.currentTarget;if(Y=Y.listener,le!==A&&k.isPropagationStopped())break e;A=Y,k.currentTarget=pe;try{A(k)}catch(Ce){xc(Ce)}k.currentTarget=null,A=le}else for(F=0;F<g.length;F++){if(Y=g[F],le=Y.instance,pe=Y.currentTarget,Y=Y.listener,le!==A&&k.isPropagationStopped())break e;A=Y,k.currentTarget=pe;try{A(k)}catch(Ce){xc(Ce)}k.currentTarget=null,A=le}}}}function bt(s,o){var f=o[fn];f===void 0&&(f=o[fn]=new Set);var g=s+"__bubble";f.has(g)||(xv(o,s,2,!1),f.add(g))}function Vf(s,o,f){var g=0;o&&(g|=4),xv(f,s,g,o)}var ru="_reactListening"+Math.random().toString(36).slice(2);function Wf(s){if(!s[ru]){s[ru]=!0,ux.forEach(function(f){f!=="selectionchange"&&(iE.has(f)||Vf(f,!1,s),Vf(f,!0,s))});var o=s.nodeType===9?s:s.ownerDocument;o===null||o[ru]||(o[ru]=!0,Vf("selectionchange",!1,o))}}function xv(s,o,f,g){switch(Gv(o)){case 2:var k=RE;break;case 8:k=OE;break;default:k=am}f=k.bind(null,o,f,s),k=void 0,!uh||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(k=!0),g?k!==void 0?s.addEventListener(o,f,{capture:!0,passive:k}):s.addEventListener(o,f,!0):k!==void 0?s.addEventListener(o,f,{passive:k}):s.addEventListener(o,f,!1)}function Gf(s,o,f,g,k){var A=g;if((o&1)===0&&(o&2)===0&&g!==null)e:for(;;){if(g===null)return;var F=g.tag;if(F===3||F===4){var Y=g.stateNode.containerInfo;if(Y===k)break;if(F===4)for(F=g.return;F!==null;){var le=F.tag;if((le===3||le===4)&&F.stateNode.containerInfo===k)return;F=F.return}for(;Y!==null;){if(F=ia(Y),F===null)return;if(le=F.tag,le===5||le===6||le===26||le===27){g=A=F;continue e}Y=Y.parentNode}}g=g.return}Sx(function(){var pe=A,Ce=lh(f),Ae=[];e:{var ge=Xx.get(s);if(ge!==void 0){var xe=mc,qe=s;switch(s){case"keypress":if(hc(f)===0)break e;case"keydown":case"keyup":xe=Jj;break;case"focusin":qe="focus",xe=mh;break;case"focusout":qe="blur",xe=mh;break;case"beforeblur":case"afterblur":xe=mh;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xe=kx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xe=zj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xe=t2;break;case Gx:case qx:case Kx:xe=Fj;break;case Yx:xe=r2;break;case"scroll":case"scrollend":xe=Bj;break;case"wheel":xe=i2;break;case"copy":case"cut":case"paste":xe=Wj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xe=Ex;break;case"toggle":case"beforetoggle":xe=o2}var it=(o&4)!==0,Pt=!it&&(s==="scroll"||s==="scrollend"),de=it?ge!==null?ge+"Capture":null:ge;it=[];for(var ue=pe,fe;ue!==null;){var Ee=ue;if(fe=Ee.stateNode,Ee=Ee.tag,Ee!==5&&Ee!==26&&Ee!==27||fe===null||de===null||(Ee=So(ue,de),Ee!=null&&it.push(tl(ue,Ee,fe))),Pt)break;ue=ue.return}0<it.length&&(ge=new xe(ge,qe,null,f,Ce),Ae.push({event:ge,listeners:it}))}}if((o&7)===0){e:{if(ge=s==="mouseover"||s==="pointerover",xe=s==="mouseout"||s==="pointerout",ge&&f!==oh&&(qe=f.relatedTarget||f.fromElement)&&(ia(qe)||qe[Kt]))break e;if((xe||ge)&&(ge=Ce.window===Ce?Ce:(ge=Ce.ownerDocument)?ge.defaultView||ge.parentWindow:window,xe?(qe=f.relatedTarget||f.toElement,xe=pe,qe=qe?ia(qe):null,qe!==null&&(Pt=l(qe),it=qe.tag,qe!==Pt||it!==5&&it!==27&&it!==6)&&(qe=null)):(xe=null,qe=pe),xe!==qe)){if(it=kx,Ee="onMouseLeave",de="onMouseEnter",ue="mouse",(s==="pointerout"||s==="pointerover")&&(it=Ex,Ee="onPointerLeave",de="onPointerEnter",ue="pointer"),Pt=xe==null?ge:_o(xe),fe=qe==null?ge:_o(qe),ge=new it(Ee,ue+"leave",xe,f,Ce),ge.target=Pt,ge.relatedTarget=fe,Ee=null,ia(Ce)===pe&&(it=new it(de,ue+"enter",qe,f,Ce),it.target=fe,it.relatedTarget=Pt,Ee=it),Pt=Ee,xe&&qe)t:{for(it=aE,de=xe,ue=qe,fe=0,Ee=de;Ee;Ee=it(Ee))fe++;Ee=0;for(var Ze=ue;Ze;Ze=it(Ze))Ee++;for(;0<fe-Ee;)de=it(de),fe--;for(;0<Ee-fe;)ue=it(ue),Ee--;for(;fe--;){if(de===ue||ue!==null&&de===ue.alternate){it=de;break t}de=it(de),ue=it(ue)}it=null}else it=null;xe!==null&&yv(Ae,ge,xe,it,!1),qe!==null&&Pt!==null&&yv(Ae,Pt,qe,it,!0)}}e:{if(ge=pe?_o(pe):window,xe=ge.nodeName&&ge.nodeName.toLowerCase(),xe==="select"||xe==="input"&&ge.type==="file")var Nt=Ix;else if(Rx(ge))if(Mx)Nt=x2;else{Nt=p2;var Xe=m2}else xe=ge.nodeName,!xe||xe.toLowerCase()!=="input"||ge.type!=="checkbox"&&ge.type!=="radio"?pe&&ah(pe.elementType)&&(Nt=Ix):Nt=g2;if(Nt&&(Nt=Nt(s,pe))){Ox(Ae,Nt,f,Ce);break e}Xe&&Xe(s,ge,pe),s==="focusout"&&pe&&ge.type==="number"&&pe.memoizedProps.value!=null&&ih(ge,"number",ge.value)}switch(Xe=pe?_o(pe):window,s){case"focusin":(Rx(Xe)||Xe.contentEditable==="true")&&(ma=Xe,vh=pe,Ao=null);break;case"focusout":Ao=vh=ma=null;break;case"mousedown":_h=!0;break;case"contextmenu":case"mouseup":case"dragend":_h=!1,Vx(Ae,f,Ce);break;case"selectionchange":if(b2)break;case"keydown":case"keyup":Vx(Ae,f,Ce)}var mt;if(gh)e:{switch(s){case"compositionstart":var wt="onCompositionStart";break e;case"compositionend":wt="onCompositionEnd";break e;case"compositionupdate":wt="onCompositionUpdate";break e}wt=void 0}else fa?Lx(s,f)&&(wt="onCompositionEnd"):s==="keydown"&&f.keyCode===229&&(wt="onCompositionStart");wt&&(Nx&&f.locale!=="ko"&&(fa||wt!=="onCompositionStart"?wt==="onCompositionEnd"&&fa&&(mt=wx()):(Ds=Ce,dh="value"in Ds?Ds.value:Ds.textContent,fa=!0)),Xe=su(pe,wt),0<Xe.length&&(wt=new jx(wt,s,null,f,Ce),Ae.push({event:wt,listeners:Xe}),mt?wt.data=mt:(mt=Dx(f),mt!==null&&(wt.data=mt)))),(mt=c2?u2(s,f):d2(s,f))&&(wt=su(pe,"onBeforeInput"),0<wt.length&&(Xe=new jx("onBeforeInput","beforeinput",null,f,Ce),Ae.push({event:Xe,listeners:wt}),Xe.data=mt)),nE(Ae,s,pe,f,Ce)}gv(Ae,o)})}function tl(s,o,f){return{instance:s,listener:o,currentTarget:f}}function su(s,o){for(var f=o+"Capture",g=[];s!==null;){var k=s,A=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||A===null||(k=So(s,f),k!=null&&g.unshift(tl(s,k,A)),k=So(s,o),k!=null&&g.push(tl(s,k,A))),s.tag===3)return g;s=s.return}return[]}function aE(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function yv(s,o,f,g,k){for(var A=o._reactName,F=[];f!==null&&f!==g;){var Y=f,le=Y.alternate,pe=Y.stateNode;if(Y=Y.tag,le!==null&&le===g)break;Y!==5&&Y!==26&&Y!==27||pe===null||(le=pe,k?(pe=So(f,A),pe!=null&&F.unshift(tl(f,pe,le))):k||(pe=So(f,A),pe!=null&&F.push(tl(f,pe,le)))),f=f.return}F.length!==0&&s.push({event:o,listeners:F})}var oE=/\r\n?/g,lE=/\u0000|\uFFFD/g;function bv(s){return(typeof s=="string"?s:""+s).replace(oE,`
|
|
50
|
+
`).replace(lE,"")}function vv(s,o){return o=bv(o),bv(s)===o}function Mt(s,o,f,g,k,A){switch(f){case"children":typeof g=="string"?o==="body"||o==="textarea"&&g===""||ua(s,g):(typeof g=="number"||typeof g=="bigint")&&o!=="body"&&ua(s,""+g);break;case"className":lc(s,"class",g);break;case"tabIndex":lc(s,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":lc(s,f,g);break;case"style":vx(s,g,A);break;case"data":if(o!=="object"){lc(s,"data",g);break}case"src":case"href":if(g===""&&(o!=="a"||f!=="href")){s.removeAttribute(f);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(f);break}g=uc(""+g),s.setAttribute(f,g);break;case"action":case"formAction":if(typeof g=="function"){s.setAttribute(f,"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 A=="function"&&(f==="formAction"?(o!=="input"&&Mt(s,o,"name",k.name,k,null),Mt(s,o,"formEncType",k.formEncType,k,null),Mt(s,o,"formMethod",k.formMethod,k,null),Mt(s,o,"formTarget",k.formTarget,k,null)):(Mt(s,o,"encType",k.encType,k,null),Mt(s,o,"method",k.method,k,null),Mt(s,o,"target",k.target,k,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(f);break}g=uc(""+g),s.setAttribute(f,g);break;case"onClick":g!=null&&(s.onclick=ts);break;case"onScroll":g!=null&&bt("scroll",s);break;case"onScrollEnd":g!=null&&bt("scrollend",s);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(f=g.__html,f!=null){if(k.children!=null)throw Error(r(60));s.innerHTML=f}}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}f=uc(""+g),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);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(f,""+g):s.removeAttribute(f);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(f,""):s.removeAttribute(f);break;case"capture":case"download":g===!0?s.setAttribute(f,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(f,g):s.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?s.setAttribute(f,g):s.removeAttribute(f);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?s.removeAttribute(f):s.setAttribute(f,g);break;case"popover":bt("beforetoggle",s),bt("toggle",s),oc(s,"popover",g);break;case"xlinkActuate":es(s,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":es(s,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":es(s,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":es(s,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":es(s,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":es(s,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":es(s,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":es(s,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":es(s,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":oc(s,"is",g);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=Mj.get(f)||f,oc(s,f,g))}}function qf(s,o,f,g,k,A){switch(f){case"style":vx(s,g,A);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(f=g.__html,f!=null){if(k.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"children":typeof g=="string"?ua(s,g):(typeof g=="number"||typeof g=="bigint")&&ua(s,""+g);break;case"onScroll":g!=null&&bt("scroll",s);break;case"onScrollEnd":g!=null&&bt("scrollend",s);break;case"onClick":g!=null&&(s.onclick=ts);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!dx.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(k=f.endsWith("Capture"),o=f.slice(2,k?f.length-7:void 0),A=s[nt]||null,A=A!=null?A[f]:null,typeof A=="function"&&s.removeEventListener(o,A,k),typeof g=="function")){typeof A!="function"&&A!==null&&(f in s?s[f]=null:s.hasAttribute(f)&&s.removeAttribute(f)),s.addEventListener(o,g,k);break e}f in s?s[f]=g:g===!0?s.setAttribute(f,""):oc(s,f,g)}}}function En(s,o,f){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":bt("error",s),bt("load",s);var g=!1,k=!1,A;for(A in f)if(f.hasOwnProperty(A)){var F=f[A];if(F!=null)switch(A){case"src":g=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Mt(s,o,A,F,f,null)}}k&&Mt(s,o,"srcSet",f.srcSet,f,null),g&&Mt(s,o,"src",f.src,f,null);return;case"input":bt("invalid",s);var Y=A=F=k=null,le=null,pe=null;for(g in f)if(f.hasOwnProperty(g)){var Ce=f[g];if(Ce!=null)switch(g){case"name":k=Ce;break;case"type":F=Ce;break;case"checked":le=Ce;break;case"defaultChecked":pe=Ce;break;case"value":A=Ce;break;case"defaultValue":Y=Ce;break;case"children":case"dangerouslySetInnerHTML":if(Ce!=null)throw Error(r(137,o));break;default:Mt(s,o,g,Ce,f,null)}}gx(s,A,Y,le,pe,F,k,!1);return;case"select":bt("invalid",s),g=F=A=null;for(k in f)if(f.hasOwnProperty(k)&&(Y=f[k],Y!=null))switch(k){case"value":A=Y;break;case"defaultValue":F=Y;break;case"multiple":g=Y;default:Mt(s,o,k,Y,f,null)}o=A,f=F,s.multiple=!!g,o!=null?ca(s,!!g,o,!1):f!=null&&ca(s,!!g,f,!0);return;case"textarea":bt("invalid",s),A=k=g=null;for(F in f)if(f.hasOwnProperty(F)&&(Y=f[F],Y!=null))switch(F){case"value":g=Y;break;case"defaultValue":k=Y;break;case"children":A=Y;break;case"dangerouslySetInnerHTML":if(Y!=null)throw Error(r(91));break;default:Mt(s,o,F,Y,f,null)}yx(s,g,k,A);return;case"option":for(le in f)if(f.hasOwnProperty(le)&&(g=f[le],g!=null))switch(le){case"selected":s.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:Mt(s,o,le,g,f,null)}return;case"dialog":bt("beforetoggle",s),bt("toggle",s),bt("cancel",s),bt("close",s);break;case"iframe":case"object":bt("load",s);break;case"video":case"audio":for(g=0;g<el.length;g++)bt(el[g],s);break;case"image":bt("error",s),bt("load",s);break;case"details":bt("toggle",s);break;case"embed":case"source":case"link":bt("error",s),bt("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(pe in f)if(f.hasOwnProperty(pe)&&(g=f[pe],g!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Mt(s,o,pe,g,f,null)}return;default:if(ah(o)){for(Ce in f)f.hasOwnProperty(Ce)&&(g=f[Ce],g!==void 0&&qf(s,o,Ce,g,f,void 0));return}}for(Y in f)f.hasOwnProperty(Y)&&(g=f[Y],g!=null&&Mt(s,o,Y,g,f,null))}function cE(s,o,f,g){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var k=null,A=null,F=null,Y=null,le=null,pe=null,Ce=null;for(xe in f){var Ae=f[xe];if(f.hasOwnProperty(xe)&&Ae!=null)switch(xe){case"checked":break;case"value":break;case"defaultValue":le=Ae;default:g.hasOwnProperty(xe)||Mt(s,o,xe,null,g,Ae)}}for(var ge in g){var xe=g[ge];if(Ae=f[ge],g.hasOwnProperty(ge)&&(xe!=null||Ae!=null))switch(ge){case"type":A=xe;break;case"name":k=xe;break;case"checked":pe=xe;break;case"defaultChecked":Ce=xe;break;case"value":F=xe;break;case"defaultValue":Y=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(r(137,o));break;default:xe!==Ae&&Mt(s,o,ge,xe,g,Ae)}}sh(s,F,Y,le,pe,Ce,A,k);return;case"select":xe=F=Y=ge=null;for(A in f)if(le=f[A],f.hasOwnProperty(A)&&le!=null)switch(A){case"value":break;case"multiple":xe=le;default:g.hasOwnProperty(A)||Mt(s,o,A,null,g,le)}for(k in g)if(A=g[k],le=f[k],g.hasOwnProperty(k)&&(A!=null||le!=null))switch(k){case"value":ge=A;break;case"defaultValue":Y=A;break;case"multiple":F=A;default:A!==le&&Mt(s,o,k,A,g,le)}o=Y,f=F,g=xe,ge!=null?ca(s,!!f,ge,!1):!!g!=!!f&&(o!=null?ca(s,!!f,o,!0):ca(s,!!f,f?[]:"",!1));return;case"textarea":xe=ge=null;for(Y in f)if(k=f[Y],f.hasOwnProperty(Y)&&k!=null&&!g.hasOwnProperty(Y))switch(Y){case"value":break;case"children":break;default:Mt(s,o,Y,null,g,k)}for(F in g)if(k=g[F],A=f[F],g.hasOwnProperty(F)&&(k!=null||A!=null))switch(F){case"value":ge=k;break;case"defaultValue":xe=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(r(91));break;default:k!==A&&Mt(s,o,F,k,g,A)}xx(s,ge,xe);return;case"option":for(var qe in f)if(ge=f[qe],f.hasOwnProperty(qe)&&ge!=null&&!g.hasOwnProperty(qe))switch(qe){case"selected":s.selected=!1;break;default:Mt(s,o,qe,null,g,ge)}for(le in g)if(ge=g[le],xe=f[le],g.hasOwnProperty(le)&&ge!==xe&&(ge!=null||xe!=null))switch(le){case"selected":s.selected=ge&&typeof ge!="function"&&typeof ge!="symbol";break;default:Mt(s,o,le,ge,g,xe)}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 it in f)ge=f[it],f.hasOwnProperty(it)&&ge!=null&&!g.hasOwnProperty(it)&&Mt(s,o,it,null,g,ge);for(pe in g)if(ge=g[pe],xe=f[pe],g.hasOwnProperty(pe)&&ge!==xe&&(ge!=null||xe!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(r(137,o));break;default:Mt(s,o,pe,ge,g,xe)}return;default:if(ah(o)){for(var Pt in f)ge=f[Pt],f.hasOwnProperty(Pt)&&ge!==void 0&&!g.hasOwnProperty(Pt)&&qf(s,o,Pt,void 0,g,ge);for(Ce in g)ge=g[Ce],xe=f[Ce],!g.hasOwnProperty(Ce)||ge===xe||ge===void 0&&xe===void 0||qf(s,o,Ce,ge,g,xe);return}}for(var de in f)ge=f[de],f.hasOwnProperty(de)&&ge!=null&&!g.hasOwnProperty(de)&&Mt(s,o,de,null,g,ge);for(Ae in g)ge=g[Ae],xe=f[Ae],!g.hasOwnProperty(Ae)||ge===xe||ge==null&&xe==null||Mt(s,o,Ae,ge,g,xe)}function _v(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function uE(){if(typeof performance.getEntriesByType=="function"){for(var s=0,o=0,f=performance.getEntriesByType("resource"),g=0;g<f.length;g++){var k=f[g],A=k.transferSize,F=k.initiatorType,Y=k.duration;if(A&&Y&&_v(F)){for(F=0,Y=k.responseEnd,g+=1;g<f.length;g++){var le=f[g],pe=le.startTime;if(pe>Y)break;var Ce=le.transferSize,Ae=le.initiatorType;Ce&&_v(Ae)&&(le=le.responseEnd,F+=Ce*(le<Y?1:(Y-pe)/(le-pe)))}if(--g,o+=8*(A+F)/(k.duration/1e3),s++,10<s)break}}if(0<s)return o/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var Kf=null,Yf=null;function iu(s){return s.nodeType===9?s:s.ownerDocument}function Sv(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function wv(s,o){if(s===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&o==="foreignObject"?0:s}function Xf(s,o){return s==="textarea"||s==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Qf=null;function dE(){var s=window.event;return s&&s.type==="popstate"?s===Qf?!1:(Qf=s,!0):(Qf=null,!1)}var Cv=typeof setTimeout=="function"?setTimeout:void 0,hE=typeof clearTimeout=="function"?clearTimeout:void 0,kv=typeof Promise=="function"?Promise:void 0,fE=typeof queueMicrotask=="function"?queueMicrotask:typeof kv<"u"?function(s){return kv.resolve(null).then(s).catch(mE)}:Cv;function mE(s){setTimeout(function(){throw s})}function Ys(s){return s==="head"}function jv(s,o){var f=o,g=0;do{var k=f.nextSibling;if(s.removeChild(f),k&&k.nodeType===8)if(f=k.data,f==="/$"||f==="/&"){if(g===0){s.removeChild(k),Ha(o);return}g--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")g++;else if(f==="html")nl(s.ownerDocument.documentElement);else if(f==="head"){f=s.ownerDocument.head,nl(f);for(var A=f.firstChild;A;){var F=A.nextSibling,Y=A.nodeName;A[vo]||Y==="SCRIPT"||Y==="STYLE"||Y==="LINK"&&A.rel.toLowerCase()==="stylesheet"||f.removeChild(A),A=F}}else f==="body"&&nl(s.ownerDocument.body);f=k}while(f);Ha(o)}function Ev(s,o){var f=s;s=0;do{var g=f.nextSibling;if(f.nodeType===1?o?(f._stashedDisplay=f.style.display,f.style.display="none"):(f.style.display=f._stashedDisplay||"",f.getAttribute("style")===""&&f.removeAttribute("style")):f.nodeType===3&&(o?(f._stashedText=f.nodeValue,f.nodeValue=""):f.nodeValue=f._stashedText||""),g&&g.nodeType===8)if(f=g.data,f==="/$"){if(s===0)break;s--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||s++;f=g}while(f)}function Jf(s){var o=s.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var f=o;switch(o=o.nextSibling,f.nodeName){case"HTML":case"HEAD":case"BODY":Jf(f),nh(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}s.removeChild(f)}}function pE(s,o,f,g){for(;s.nodeType===1;){var k=f;if(s.nodeName.toLowerCase()!==o.toLowerCase()){if(!g&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(g){if(!s[vo])switch(o){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(A=s.getAttribute("rel"),A==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(A!==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(A=s.getAttribute("src"),(A!==(k.src==null?null:k.src)||s.getAttribute("type")!==(k.type==null?null:k.type)||s.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&A&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(o==="input"&&s.type==="hidden"){var A=k.name==null?null:""+k.name;if(k.type==="hidden"&&s.getAttribute("name")===A)return s}else return s;if(s=vr(s.nextSibling),s===null)break}return null}function gE(s,o,f){if(o==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!f||(s=vr(s.nextSibling),s===null))return null;return s}function Nv(s,o){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!o||(s=vr(s.nextSibling),s===null))return null;return s}function Zf(s){return s.data==="$?"||s.data==="$~"}function em(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function xE(s,o){var f=s.ownerDocument;if(s.data==="$~")s._reactRetry=o;else if(s.data!=="$?"||f.readyState!=="loading")o();else{var g=function(){o(),f.removeEventListener("DOMContentLoaded",g)};f.addEventListener("DOMContentLoaded",g),s._reactRetry=g}}function vr(s){for(;s!=null;s=s.nextSibling){var o=s.nodeType;if(o===1||o===3)break;if(o===8){if(o=s.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return s}var tm=null;function Tv(s){s=s.nextSibling;for(var o=0;s;){if(s.nodeType===8){var f=s.data;if(f==="/$"||f==="/&"){if(o===0)return vr(s.nextSibling);o--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||o++}s=s.nextSibling}return null}function Av(s){s=s.previousSibling;for(var o=0;s;){if(s.nodeType===8){var f=s.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(o===0)return s;o--}else f!=="/$"&&f!=="/&"||o++}s=s.previousSibling}return null}function Lv(s,o,f){switch(o=iu(f),s){case"html":if(s=o.documentElement,!s)throw Error(r(452));return s;case"head":if(s=o.head,!s)throw Error(r(453));return s;case"body":if(s=o.body,!s)throw Error(r(454));return s;default:throw Error(r(451))}}function nl(s){for(var o=s.attributes;o.length;)s.removeAttributeNode(o[0]);nh(s)}var _r=new Map,Dv=new Set;function au(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var xs=ee.d;ee.d={f:yE,r:bE,D:vE,C:_E,L:SE,m:wE,X:kE,S:CE,M:jE};function yE(){var s=xs.f(),o=Qc();return s||o}function bE(s){var o=aa(s);o!==null&&o.tag===5&&o.type==="form"?Yy(o):xs.r(s)}var Ba=typeof document>"u"?null:document;function Rv(s,o,f){var g=Ba;if(g&&typeof o=="string"&&o){var k=fr(o);k='link[rel="'+s+'"][href="'+k+'"]',typeof f=="string"&&(k+='[crossorigin="'+f+'"]'),Dv.has(k)||(Dv.add(k),s={rel:s,crossOrigin:f,href:o},g.querySelector(k)===null&&(o=g.createElement("link"),En(o,"link",s),bn(o),g.head.appendChild(o)))}}function vE(s){xs.D(s),Rv("dns-prefetch",s,null)}function _E(s,o){xs.C(s,o),Rv("preconnect",s,o)}function SE(s,o,f){xs.L(s,o,f);var g=Ba;if(g&&s&&o){var k='link[rel="preload"][as="'+fr(o)+'"]';o==="image"&&f&&f.imageSrcSet?(k+='[imagesrcset="'+fr(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(k+='[imagesizes="'+fr(f.imageSizes)+'"]')):k+='[href="'+fr(s)+'"]';var A=k;switch(o){case"style":A=$a(s);break;case"script":A=za(s)}_r.has(A)||(s=m({rel:"preload",href:o==="image"&&f&&f.imageSrcSet?void 0:s,as:o},f),_r.set(A,s),g.querySelector(k)!==null||o==="style"&&g.querySelector(rl(A))||o==="script"&&g.querySelector(sl(A))||(o=g.createElement("link"),En(o,"link",s),bn(o),g.head.appendChild(o)))}}function wE(s,o){xs.m(s,o);var f=Ba;if(f&&s){var g=o&&typeof o.as=="string"?o.as:"script",k='link[rel="modulepreload"][as="'+fr(g)+'"][href="'+fr(s)+'"]',A=k;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":A=za(s)}if(!_r.has(A)&&(s=m({rel:"modulepreload",href:s},o),_r.set(A,s),f.querySelector(k)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(sl(A)))return}g=f.createElement("link"),En(g,"link",s),bn(g),f.head.appendChild(g)}}}function CE(s,o,f){xs.S(s,o,f);var g=Ba;if(g&&s){var k=oa(g).hoistableStyles,A=$a(s);o=o||"default";var F=k.get(A);if(!F){var Y={loading:0,preload:null};if(F=g.querySelector(rl(A)))Y.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":o},f),(f=_r.get(A))&&nm(s,f);var le=F=g.createElement("link");bn(le),En(le,"link",s),le._p=new Promise(function(pe,Ce){le.onload=pe,le.onerror=Ce}),le.addEventListener("load",function(){Y.loading|=1}),le.addEventListener("error",function(){Y.loading|=2}),Y.loading|=4,ou(F,o,g)}F={type:"stylesheet",instance:F,count:1,state:Y},k.set(A,F)}}}function kE(s,o){xs.X(s,o);var f=Ba;if(f&&s){var g=oa(f).hoistableScripts,k=za(s),A=g.get(k);A||(A=f.querySelector(sl(k)),A||(s=m({src:s,async:!0},o),(o=_r.get(k))&&rm(s,o),A=f.createElement("script"),bn(A),En(A,"link",s),f.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(k,A))}}function jE(s,o){xs.M(s,o);var f=Ba;if(f&&s){var g=oa(f).hoistableScripts,k=za(s),A=g.get(k);A||(A=f.querySelector(sl(k)),A||(s=m({src:s,async:!0,type:"module"},o),(o=_r.get(k))&&rm(s,o),A=f.createElement("script"),bn(A),En(A,"link",s),f.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(k,A))}}function Ov(s,o,f,g){var k=(k=J.current)?au(k):null;if(!k)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(o=$a(f.href),f=oa(k).hoistableStyles,g=f.get(o),g||(g={type:"style",instance:null,count:0,state:null},f.set(o,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){s=$a(f.href);var A=oa(k).hoistableStyles,F=A.get(s);if(F||(k=k.ownerDocument||k,F={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},A.set(s,F),(A=k.querySelector(rl(s)))&&!A._p&&(F.instance=A,F.state.loading=5),_r.has(s)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},_r.set(s,f),A||EE(k,s,f,F.state))),o&&g===null)throw Error(r(528,""));return F}if(o&&g!==null)throw Error(r(529,""));return null;case"script":return o=f.async,f=f.src,typeof f=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=za(f),f=oa(k).hoistableScripts,g=f.get(o),g||(g={type:"script",instance:null,count:0,state:null},f.set(o,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function $a(s){return'href="'+fr(s)+'"'}function rl(s){return'link[rel="stylesheet"]['+s+"]"}function Iv(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function EE(s,o,f,g){s.querySelector('link[rel="preload"][as="style"]['+o+"]")?g.loading=1:(o=s.createElement("link"),g.preload=o,o.addEventListener("load",function(){return g.loading|=1}),o.addEventListener("error",function(){return g.loading|=2}),En(o,"link",f),bn(o),s.head.appendChild(o))}function za(s){return'[src="'+fr(s)+'"]'}function sl(s){return"script[async]"+s}function Mv(s,o,f){if(o.count++,o.instance===null)switch(o.type){case"style":var g=s.querySelector('style[data-href~="'+fr(f.href)+'"]');if(g)return o.instance=g,bn(g),g;var k=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return g=(s.ownerDocument||s).createElement("style"),bn(g),En(g,"style",k),ou(g,f.precedence,s),o.instance=g;case"stylesheet":k=$a(f.href);var A=s.querySelector(rl(k));if(A)return o.state.loading|=4,o.instance=A,bn(A),A;g=Iv(f),(k=_r.get(k))&&nm(g,k),A=(s.ownerDocument||s).createElement("link"),bn(A);var F=A;return F._p=new Promise(function(Y,le){F.onload=Y,F.onerror=le}),En(A,"link",g),o.state.loading|=4,ou(A,f.precedence,s),o.instance=A;case"script":return A=za(f.src),(k=s.querySelector(sl(A)))?(o.instance=k,bn(k),k):(g=f,(k=_r.get(A))&&(g=m({},f),rm(g,k)),s=s.ownerDocument||s,k=s.createElement("script"),bn(k),En(k,"link",g),s.head.appendChild(k),o.instance=k);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(g=o.instance,o.state.loading|=4,ou(g,f.precedence,s));return o.instance}function ou(s,o,f){for(var g=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=g.length?g[g.length-1]:null,A=k,F=0;F<g.length;F++){var Y=g[F];if(Y.dataset.precedence===o)A=Y;else if(A!==k)break}A?A.parentNode.insertBefore(s,A.nextSibling):(o=f.nodeType===9?f.head:f,o.insertBefore(s,o.firstChild))}function nm(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.title==null&&(s.title=o.title)}function rm(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.integrity==null&&(s.integrity=o.integrity)}var lu=null;function Pv(s,o,f){if(lu===null){var g=new Map,k=lu=new Map;k.set(f,g)}else k=lu,g=k.get(f),g||(g=new Map,k.set(f,g));if(g.has(s))return g;for(g.set(s,null),f=f.getElementsByTagName(s),k=0;k<f.length;k++){var A=f[k];if(!(A[vo]||A[Qe]||s==="link"&&A.getAttribute("rel")==="stylesheet")&&A.namespaceURI!=="http://www.w3.org/2000/svg"){var F=A.getAttribute(o)||"";F=s+F;var Y=g.get(F);Y?Y.push(A):g.set(F,[A])}}return g}function Bv(s,o,f){s=s.ownerDocument||s,s.head.insertBefore(f,o==="title"?s.querySelector("head > title"):null)}function NE(s,o,f){if(f===1||o.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return s=o.disabled,typeof o.precedence=="string"&&s==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function $v(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function TE(s,o,f,g){if(f.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var k=$a(g.href),A=o.querySelector(rl(k));if(A){o=A._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(s.count++,s=cu.bind(s),o.then(s,s)),f.state.loading|=4,f.instance=A,bn(A);return}A=o.ownerDocument||o,g=Iv(g),(k=_r.get(k))&&nm(g,k),A=A.createElement("link"),bn(A);var F=A;F._p=new Promise(function(Y,le){F.onload=Y,F.onerror=le}),En(A,"link",g),f.instance=A}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(f,o),(o=f.state.preload)&&(f.state.loading&3)===0&&(s.count++,f=cu.bind(s),o.addEventListener("load",f),o.addEventListener("error",f))}}var sm=0;function AE(s,o){return s.stylesheets&&s.count===0&&du(s,s.stylesheets),0<s.count||0<s.imgCount?function(f){var g=setTimeout(function(){if(s.stylesheets&&du(s,s.stylesheets),s.unsuspend){var A=s.unsuspend;s.unsuspend=null,A()}},6e4+o);0<s.imgBytes&&sm===0&&(sm=62500*uE());var k=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&du(s,s.stylesheets),s.unsuspend)){var A=s.unsuspend;s.unsuspend=null,A()}},(s.imgBytes>sm?50:800)+o);return s.unsuspend=f,function(){s.unsuspend=null,clearTimeout(g),clearTimeout(k)}}:null}function cu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)du(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var uu=null;function du(s,o){s.stylesheets=null,s.unsuspend!==null&&(s.count++,uu=new Map,o.forEach(LE,s),uu=null,cu.call(s))}function LE(s,o){if(!(o.state.loading&4)){var f=uu.get(s);if(f)var g=f.get(null);else{f=new Map,uu.set(s,f);for(var k=s.querySelectorAll("link[data-precedence],style[data-precedence]"),A=0;A<k.length;A++){var F=k[A];(F.nodeName==="LINK"||F.getAttribute("media")!=="not all")&&(f.set(F.dataset.precedence,F),g=F)}g&&f.set(null,g)}k=o.instance,F=k.getAttribute("data-precedence"),A=f.get(F)||g,A===g&&f.set(null,k),f.set(F,k),this.count++,g=cu.bind(this),k.addEventListener("load",g),k.addEventListener("error",g),A?A.parentNode.insertBefore(k,A.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(k,s.firstChild)),o.state.loading|=4}}var il={$$typeof:b,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function DE(s,o,f,g,k,A,F,Y,le){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=Dt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dt(0),this.hiddenUpdates=Dt(null),this.identifierPrefix=g,this.onUncaughtError=k,this.onCaughtError=A,this.onRecoverableError=F,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=le,this.incompleteTransitions=new Map}function zv(s,o,f,g,k,A,F,Y,le,pe,Ce,Ae){return s=new DE(s,o,f,F,le,pe,Ce,Ae,Y),o=1,A===!0&&(o|=24),A=rr(3,null,null,o),s.current=A,A.stateNode=s,o=Mh(),o.refCount++,s.pooledCache=o,o.refCount++,A.memoizedState={element:g,isDehydrated:f,cache:o},zh(A),s}function Hv(s){return s?(s=xa,s):xa}function Uv(s,o,f,g,k,A){k=Hv(k),g.context===null?g.context=k:g.pendingContext=k,g=Bs(o),g.payload={element:f},A=A===void 0?null:A,A!==null&&(g.callback=A),f=$s(s,g,o),f!==null&&(Xn(f,s,o),Po(f,s,o))}function Fv(s,o){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var f=s.retryLane;s.retryLane=f!==0&&f<o?f:o}}function im(s,o){Fv(s,o),(s=s.alternate)&&Fv(s,o)}function Vv(s){if(s.tag===13||s.tag===31){var o=wi(s,67108864);o!==null&&Xn(o,s,67108864),im(s,67108864)}}function Wv(s){if(s.tag===13||s.tag===31){var o=lr();o=_e(o);var f=wi(s,o);f!==null&&Xn(f,s,o),im(s,o)}}var hu=!0;function RE(s,o,f,g){var k=V.T;V.T=null;var A=ee.p;try{ee.p=2,am(s,o,f,g)}finally{ee.p=A,V.T=k}}function OE(s,o,f,g){var k=V.T;V.T=null;var A=ee.p;try{ee.p=8,am(s,o,f,g)}finally{ee.p=A,V.T=k}}function am(s,o,f,g){if(hu){var k=om(g);if(k===null)Gf(s,o,g,fu,f),qv(s,g);else if(ME(k,s,o,f,g))g.stopPropagation();else if(qv(s,g),o&4&&-1<IE.indexOf(s)){for(;k!==null;){var A=aa(k);if(A!==null)switch(A.tag){case 3:if(A=A.stateNode,A.current.memoizedState.isDehydrated){var F=se(A.pendingLanes);if(F!==0){var Y=A;for(Y.pendingLanes|=2,Y.entangledLanes|=2;F;){var le=1<<31-ot(F);Y.entanglements[1]|=le,F&=~le}Fr(A),(At&6)===0&&(Yc=He()+500,Zo(0))}}break;case 31:case 13:Y=wi(A,2),Y!==null&&Xn(Y,A,2),Qc(),im(A,2)}if(A=om(g),A===null&&Gf(s,o,g,fu,f),A===k)break;k=A}k!==null&&g.stopPropagation()}else Gf(s,o,g,null,f)}}function om(s){return s=lh(s),lm(s)}var fu=null;function lm(s){if(fu=null,s=ia(s),s!==null){var o=l(s);if(o===null)s=null;else{var f=o.tag;if(f===13){if(s=u(o),s!==null)return s;s=null}else if(f===31){if(s=c(o),s!==null)return s;s=null}else if(f===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;s=null}else o!==s&&(s=null)}}return fu=s,null}function Gv(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(Ve()){case Z:return 2;case oe:return 8;case ie:case me:return 32;case Ue:return 268435456;default:return 32}default:return 32}}var cm=!1,Xs=null,Qs=null,Js=null,al=new Map,ol=new Map,Zs=[],IE="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 qv(s,o){switch(s){case"focusin":case"focusout":Xs=null;break;case"dragenter":case"dragleave":Qs=null;break;case"mouseover":case"mouseout":Js=null;break;case"pointerover":case"pointerout":al.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":ol.delete(o.pointerId)}}function ll(s,o,f,g,k,A){return s===null||s.nativeEvent!==A?(s={blockedOn:o,domEventName:f,eventSystemFlags:g,nativeEvent:A,targetContainers:[k]},o!==null&&(o=aa(o),o!==null&&Vv(o)),s):(s.eventSystemFlags|=g,o=s.targetContainers,k!==null&&o.indexOf(k)===-1&&o.push(k),s)}function ME(s,o,f,g,k){switch(o){case"focusin":return Xs=ll(Xs,s,o,f,g,k),!0;case"dragenter":return Qs=ll(Qs,s,o,f,g,k),!0;case"mouseover":return Js=ll(Js,s,o,f,g,k),!0;case"pointerover":var A=k.pointerId;return al.set(A,ll(al.get(A)||null,s,o,f,g,k)),!0;case"gotpointercapture":return A=k.pointerId,ol.set(A,ll(ol.get(A)||null,s,o,f,g,k)),!0}return!1}function Kv(s){var o=ia(s.target);if(o!==null){var f=l(o);if(f!==null){if(o=f.tag,o===13){if(o=u(f),o!==null){s.blockedOn=o,We(s.priority,function(){Wv(f)});return}}else if(o===31){if(o=c(f),o!==null){s.blockedOn=o,We(s.priority,function(){Wv(f)});return}}else if(o===3&&f.stateNode.current.memoizedState.isDehydrated){s.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}s.blockedOn=null}function mu(s){if(s.blockedOn!==null)return!1;for(var o=s.targetContainers;0<o.length;){var f=om(s.nativeEvent);if(f===null){f=s.nativeEvent;var g=new f.constructor(f.type,f);oh=g,f.target.dispatchEvent(g),oh=null}else return o=aa(f),o!==null&&Vv(o),s.blockedOn=f,!1;o.shift()}return!0}function Yv(s,o,f){mu(s)&&f.delete(o)}function PE(){cm=!1,Xs!==null&&mu(Xs)&&(Xs=null),Qs!==null&&mu(Qs)&&(Qs=null),Js!==null&&mu(Js)&&(Js=null),al.forEach(Yv),ol.forEach(Yv)}function pu(s,o){s.blockedOn===o&&(s.blockedOn=null,cm||(cm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,PE)))}var gu=null;function Xv(s){gu!==s&&(gu=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){gu===s&&(gu=null);for(var o=0;o<s.length;o+=3){var f=s[o],g=s[o+1],k=s[o+2];if(typeof g!="function"){if(lm(g||f)===null)continue;break}var A=aa(f);A!==null&&(s.splice(o,3),o-=3,of(A,{pending:!0,data:k,method:f.method,action:g},g,k))}}))}function Ha(s){function o(le){return pu(le,s)}Xs!==null&&pu(Xs,s),Qs!==null&&pu(Qs,s),Js!==null&&pu(Js,s),al.forEach(o),ol.forEach(o);for(var f=0;f<Zs.length;f++){var g=Zs[f];g.blockedOn===s&&(g.blockedOn=null)}for(;0<Zs.length&&(f=Zs[0],f.blockedOn===null);)Kv(f),f.blockedOn===null&&Zs.shift();if(f=(s.ownerDocument||s).$$reactFormReplay,f!=null)for(g=0;g<f.length;g+=3){var k=f[g],A=f[g+1],F=k[nt]||null;if(typeof A=="function")F||Xv(f);else if(F){var Y=null;if(A&&A.hasAttribute("formAction")){if(k=A,F=A[nt]||null)Y=F.formAction;else if(lm(k)!==null)continue}else Y=F.action;typeof Y=="function"?f[g+1]=Y:(f.splice(g,3),g-=3),Xv(f)}}}function Qv(){function s(A){A.canIntercept&&A.info==="react-transition"&&A.intercept({handler:function(){return new Promise(function(F){return k=F})},focusReset:"manual",scroll:"manual"})}function o(){k!==null&&(k(),k=null),g||setTimeout(f,20)}function f(){if(!g&&!navigation.transition){var A=navigation.currentEntry;A&&A.url!=null&&navigation.navigate(A.url,{state:A.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,k=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(f,100),function(){g=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),k!==null&&(k(),k=null)}}}function um(s){this._internalRoot=s}xu.prototype.render=um.prototype.render=function(s){var o=this._internalRoot;if(o===null)throw Error(r(409));var f=o.current,g=lr();Uv(f,g,s,o,null,null)},xu.prototype.unmount=um.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var o=s.containerInfo;Uv(s.current,2,null,s,null,null),Qc(),o[Kt]=null}};function xu(s){this._internalRoot=s}xu.prototype.unstable_scheduleHydration=function(s){if(s){var o=Me();s={blockedOn:null,target:s,priority:o};for(var f=0;f<Zs.length&&o!==0&&o<Zs[f].priority;f++);Zs.splice(f,0,s),f===0&&Kv(s)}};var Jv=t.version;if(Jv!=="19.2.4")throw Error(r(527,Jv,"19.2.4"));ee.findDOMNode=function(s){var o=s._reactInternals;if(o===void 0)throw typeof s.render=="function"?Error(r(188)):(s=Object.keys(s).join(","),Error(r(268,s)));return s=h(o),s=s!==null?p(s):null,s=s===null?null:s.stateNode,s};var BE={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yu.isDisabled&&yu.supportsFiber)try{ct=yu.inject(BE),et=yu}catch{}}return ul.createRoot=function(s,o){if(!a(s))throw Error(r(299));var f=!1,g="",k=ib,A=ab,F=ob;return o!=null&&(o.unstable_strictMode===!0&&(f=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onUncaughtError!==void 0&&(k=o.onUncaughtError),o.onCaughtError!==void 0&&(A=o.onCaughtError),o.onRecoverableError!==void 0&&(F=o.onRecoverableError)),o=zv(s,1,!1,null,null,f,g,null,k,A,F,Qv),s[Kt]=o.current,Wf(s),new um(o)},ul.hydrateRoot=function(s,o,f){if(!a(s))throw Error(r(299));var g=!1,k="",A=ib,F=ab,Y=ob,le=null;return f!=null&&(f.unstable_strictMode===!0&&(g=!0),f.identifierPrefix!==void 0&&(k=f.identifierPrefix),f.onUncaughtError!==void 0&&(A=f.onUncaughtError),f.onCaughtError!==void 0&&(F=f.onCaughtError),f.onRecoverableError!==void 0&&(Y=f.onRecoverableError),f.formState!==void 0&&(le=f.formState)),o=zv(s,1,!0,o,f??null,g,k,le,A,F,Y,Qv),o.context=Hv(null),f=o.current,g=lr(),g=_e(g),k=Bs(g),k.callback=null,$s(f,k,g),f=g,o.current.lanes=f,wn(o,f),Fr(o),s[Kt]=o.current,Wf(s),new xu(o)},ul.version="19.2.4",ul}var u_;function ZE(){if(u_)return pm.exports;u_=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(),pm.exports=JE(),pm.exports}var eN=ZE();const tN=Cd(eN);function nN(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,l,u=[],c="",d=e.split("/");for(d[0]||d.shift();a=d.shift();)n=a[0],n==="*"?(u.push(n),c+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=a.indexOf("?",1),l=a.indexOf(".",1),u.push(a.substring(1,~r?r:~l?l:a.length)),c+=~r&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(c+=(~r?"?":"")+"\\"+a.substring(l))):c+="/"+a;return{keys:u,pattern:new RegExp("^"+c+(t?"(?=$|/)":"/?$"),"i")}}var bm={exports:{}},vm={};/**
|
|
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 d_;function rN(){if(d_)return vm;d_=1;var e=kd();function t(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(m,x){var y=x(),w=r({inst:{value:y,getSnapshot:x}}),C=w[0].inst,_=w[1];return l(function(){C.value=y,C.getSnapshot=x,d(C)&&_({inst:C})},[m,y,x]),a(function(){return d(C)&&_({inst:C}),m(function(){d(C)&&_({inst:C})})},[m]),u(y),y}function d(m){var x=m.getSnapshot;m=m.value;try{var y=x();return!n(m,y)}catch{return!0}}function h(m,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return vm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,vm}var h_;function sN(){return h_||(h_=1,bm.exports=rN()),bm.exports}var iN=sN();const aN=KE.useInsertionEffect,oN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",lN=oN?E.useLayoutEffect:E.useEffect,cN=aN||lN,c1=e=>{const t=E.useRef([e,(...n)=>t[0](...n)]).current;return cN(()=>{t[0]=e}),t[1]},uN="popstate",sg="pushState",ig="replaceState",dN="hashchange",f_=[uN,sg,ig,dN],hN=e=>{for(const t of f_)addEventListener(t,e);return()=>{for(const t of f_)removeEventListener(t,e)}},u1=(e,t)=>iN.useSyncExternalStore(hN,e,t),m_=()=>location.search,fN=({ssrSearch:e}={})=>u1(m_,e!=null?()=>e:m_),p_=()=>location.pathname,mN=({ssrPath:e}={})=>u1(p_,e!=null?()=>e:p_),pN=(e,{replace:t=!1,state:n=null}={})=>history[t?ig:sg](n,"",e),gN=(e={})=>[mN(e),pN],g_=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[g_]>"u"){for(const e of[sg,ig]){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,g_,{value:!0})}const xN=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",d1=(e="")=>e==="/"?"":e,yN=(e,t)=>e[0]==="~"?e.slice(1):d1(t)+e,bN=(e="",t)=>xN(x_(d1(e)),x_(t)),x_=e=>{try{return decodeURI(e)}catch{return e}},h1={hook:gN,searchHook:fN,parser:nN,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},f1=E.createContext(h1),ho=()=>E.useContext(f1),m1={},p1=E.createContext(m1),vN=()=>E.useContext(p1),jd=e=>{const[t,n]=e.hook(e);return[bN(e.base,t),c1((r,a)=>e.aroundNav(n,yN(r,e.base),a))]},Tn=()=>jd(ho()),ag=(e,t,n,r)=>{const{pattern:a,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),u=a.exec(n)||[],[c,...d]=u;return c!==void 0?[!0,(()=>{const h=l!==!1?Object.fromEntries(l.map((m,x)=>[m,d[x]])):u.groups;let p={...d};return h&&Object.assign(p,h),p})(),...r?[c]:[]]:[!1,null]},fo=e=>ag(ho().parser,e,Tn()[0]),g1=({children:e,...t})=>{var p,m,x;const n=ho(),r=t.hook?h1:n;let a=r;const[l,u=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];l&&(t.ssrSearch=u,t.ssrPath=l),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let c=E.useRef({}),d=c.current,h=d;for(let y in r){const w=y==="base"?r[y]+(t[y]??""):t[y]??r[y];d===h&&w!==h[y]&&(c.current=h={...h}),h[y]=w,(w!==r[y]||w!==a[y])&&(a=h)}return E.createElement(f1.Provider,{value:a,children:e})},y_=({children:e,component:t},n)=>t?E.createElement(t,{params:n}):typeof e=="function"?e(n):e,_N=e=>{let t=E.useRef(m1);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,a])=>a!==n[r])?e:n},dl=({path:e,nest:t,match:n,...r})=>{const a=ho(),[l]=jd(a),[u,c,d]=n??ag(a.parser,e,l,t),h=_N({...vN(),...c});if(!u)return null;const p=d?E.createElement(g1,{base:d},y_(r,h)):y_(r,h);return E.createElement(p1.Provider,{value:h,children:p})},Jn=E.forwardRef((e,t)=>{const n=ho(),[r,a]=jd(n),{to:l="",href:u=l,onClick:c,asChild:d,children:h,className:p,replace:m,state:x,transition:y,...w}=e,C=c1(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(c==null||c(S),S.defaultPrevented||(S.preventDefault(),a(u,e)))}),_=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return d&&E.isValidElement(h)?E.cloneElement(h,{onClick:C,href:_}):E.createElement("a",{...w,onClick:C,href:_,className:p!=null&&p.call?p(r===u):p,children:h,ref:t})}),x1=e=>Array.isArray(e)?e.flatMap(t=>x1(t&&t.type===E.Fragment?t.props.children:t)):[e],SN=({children:e,location:t})=>{const n=ho(),[r]=jd(n);for(const a of x1(e)){let l=0;if(E.isValidElement(a)&&(l=ag(n.parser,a.props.path,t||r,a.props.nest))[0])return E.cloneElement(a,{match:l})}return null},b_=e=>{let t;const n=new Set,r=(h,p)=>{const m=typeof h=="function"?h(t):h;if(!Object.is(m,t)){const x=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,x))}},a=()=>t,c={setState:r,getState:a,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h))},d=t=e(r,a,c);return c},wN=(e=>e?b_(e):b_),CN=e=>e;function kN(e,t=CN){const n=oi.useSyncExternalStore(e.subscribe,oi.useCallback(()=>t(e.getState()),[e,t]),oi.useCallback(()=>t(e.getInitialState()),[e,t]));return oi.useDebugValue(n),n}const v_=e=>{const t=wN(e),n=r=>kN(t,r);return Object.assign(n,t),n},Mn=(e=>e?v_(e):v_);function jN(){if(typeof document>"u")return"";const e=Array.from(document.scripts).find(a=>{const l=new URL(a.src,window.location.href).pathname;return l.includes("/assets/")||l.endsWith("/src/main.tsx")});if(!e)return"";const t=new URL(e.src,window.location.href).pathname,n=t.includes("/assets/")?"/assets/":"/src/",r=t.indexOf(n);return r>0?t.slice(0,r):""}const y1=jN();function Es(e){return e.startsWith("/")?`${y1}${e}`||"/":e}async function ye(e,t={}){const n=localStorage.getItem("openfox_token"),r={...t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers,...n?{"x-session-token":n}:{}};return fetch(Es(e),{...t,headers:r})}async function __(e,t,n){try{return(await ye(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{content:n}:{}})})).ok}catch{return!1}}async function b1(e,t,n){try{const r=await ye(`/api/sessions/${e}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{title:n}:{}})});return r.ok?await r.json():null}catch{return null}}const Te={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SYSTEM_THEME_PREFS:"display.systemThemePrefs",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",DISPLAY_SHOW_CHANGELOG_ON_UPDATE:"display.showChangelogOnUpdate",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",DISPLAY_CUSTOM_CSS:"display.customCss",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey",TOOLS_USE_RTK:"tools.useRtk",TOOLS_SHELL:"tools.shell",CONFIRM_ON_WORKSPACE_ACTIONS:"tools.confirmOnWorkspaceActions",FEATURES_PER_SESSION_MCP:"features.perSessionMcp",PROXY_URL:"network.proxyUrl",DEFAULT_AGENT:"agent.defaultAgent"};function bu(e,t){return n=>({loading:{...n.loading,[e]:t}})}function S_(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const og=[Te.DISPLAY_SHOW_THINKING,Te.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Te.DISPLAY_SHOW_STATS,Te.DISPLAY_SHOW_AGENT_DEFINITIONS,Te.DISPLAY_SHOW_WORKFLOW_BARS,Te.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Te.DISPLAY_FOLLOW_SYSTEM_THEME,Te.DISPLAY_SHOW_OPEN_IN_EDITOR,Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,Te.DISPLAY_MAX_VISIBLE_ITEMS];function ea(){return{showThinking:Ft(e=>e.settings[Te.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Ft(e=>e.settings[Te.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Ft(e=>e.settings[Te.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Ft(e=>e.settings[Te.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Ft(e=>e.settings[Te.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Ft(e=>e.settings[Te.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Ft(e=>e.settings[Te.DISPLAY_MAX_VISIBLE_ITEMS]??"300"))}}const Ft=Mn(e=>({settings:{},loading:{},getSetting:async t=>{e(bu(t,!0));try{const r=await(await ye(`/api/settings/${t}`)).json();return e(S_(t,r.value??"")),r.value}catch{return e(bu(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await ye(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(a=>[a,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(bu(t,!0));try{const a=await(await ye(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(S_(t,a.value??""))}catch{e(bu(t,!1))}}})),hl=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:og,SETTINGS_KEYS:Te,useDisplaySettings:ea,useSettingsStore:Ft},Symbol.toStringTag,{value:"Module"}));function EN(){const[e,t]=E.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=E.useRef(window.innerHeight);return E.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const l=r.offsetTop,u=r.height,c=n.current-u>100;t({offsetTop:l,height:u,keyboardVisible:c})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}function NN(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Wu(){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 TN{constructor(t){be(this,"ws",null);be(this,"handlers",new Set);be(this,"statusHandler",null);be(this,"baseUrl");be(this,"isReconnecting",!1);be(this,"connectingPromise",null);be(this,"lastCloseCode",0);be(this,"reconnectAttempts",0);be(this,"manualReconnectScheduled",!1);be(this,"pwaRecoveryAttempted",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,r;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,l)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const c=setTimeout(()=>{var d;((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var d;clearTimeout(c),this.isReconnecting=!1,this.reconnectAttempts=0,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),a()},this.ws.onclose=d=>{var h,p,m;clearTimeout(c),this.lastCloseCode=d.code,((h=this.ws)==null?void 0:h.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 h=JSON.parse(d.data);NN(h)&&this.handlers.forEach(p=>p(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}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=Wu(),a={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(a)),r}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const AN=window.location.protocol==="https:"?"wss:":"ws:";let bp=window.location.port;bp||(bp=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const LN=`${AN}//${window.location.hostname}:${bp}${Es("/ws")}`,Lt=new TN(LN),DN=3e4;function v1(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}const Qt=Mn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,platform:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const n=await ye("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json(),a=r.platform&&typeof r.platform=="object"?{isWSL:!!r.platform.isWSL,wslDistro:String(r.platform.wslDistro??"")}:null;e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,platform:a,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await ye("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json();e({model:r.model,llmStatus:r.llmStatus,backend:r.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:r,providers:a}=t();if(n===r)return!0;e({activating:!0,error:null});try{const l=await ye(`/api/providers/${n}/activate`,{method:"POST"});if(!l.ok){const c=await l.json();throw new Error(c.error??"Failed to activate provider")}const u=await l.json();return e({activeProviderId:u.activeProviderId,model:u.model,backend:u.backend,providers:a.map(c=>({...c,isActive:c.id===u.activeProviderId})),activating:!1}),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,r)=>{const{providers:a}=t();try{const l=await ye("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!l.ok)return!1;const u=await l.json();return e({activeProviderId:n,model:r,defaultModelSelection:u.defaultModelSelection,providers:a.map(c=>({...c,isActive:c.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await ye(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const u=await r.json();throw new Error(u.error??"Failed to refresh models")}const a=await r.json(),{providers:l}=t();return e({providers:l.map(u=>u.id===n?{...u,models:a.models,status:a.status}:u),activating:!1}),!0}catch(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const a=setInterval(()=>{r()},DN);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(a=>a.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:a}=t(),l=r.find(c=>c.id===a);if(!l)return 2e5;const u=l.models.find(c=>c.id===n);return(u==null?void 0:u.contextWindow)??2e5}})),Wt=Mn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await ye("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const a=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!a.ok){const u=await a.json().catch(()=>({}));return{error:{code:u.code||"UNKNOWN",path:u.path,message:u.error}}}const l=await a.json();return await t().listProjects(),l.project}catch{return null}},loadProject:async n=>{try{const r=await ye(`/api/projects/${n}`);if(!r.ok)return null;const a=await r.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,r)=>{var a;try{const l=await ye(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!l.ok)return null;const u=await l.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:u.project}),await t().listProjects(),u.project}catch{return null}},deleteProject:async n=>{var r;try{return(await ye(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var a;try{const l=await ye(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!l.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const u=await l.json();e({currentProject:u.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),mi=async(e,t,n)=>{try{const r=await ye(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?{success:!0}:{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}},Ed=async(e,t,n)=>{try{const r=await ye(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function _1(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let vu=[];const Nl=Mn()((e,t)=>{function n(){if(vu.length===0)return;const a=vu;vu=[],e(l=>{const u={...l.logs};for(const c of a){const d=u[c.processId]??[];u[c.processId]=[...d,{offset:d.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:u}})}const r=_1(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(l=>({processes:[...l.processes,a]})),updateProcess:(a,l)=>e(u=>({processes:u.processes.map(c=>c.id===a?{...c,...l}:c)})),removeProcess:a=>e(l=>({processes:l.processes.filter(u=>u.id!==a),logs:Object.fromEntries(Object.entries(l.logs).filter(([u])=>u!==a))})),stopProcess:async(a,l)=>{try{(await ye(`/api/sessions/${l}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,l,u)=>{vu.push({processId:a,stream:l,content:u}),r()},setLogs:(a,l)=>e(u=>({logs:{...u.logs,[a]:l}})),clearLogs:a=>e(l=>({logs:{...l.logs,[a]:[]}})),handleMessage:(a,l)=>{switch(a){case"backgroundProcess.started":{const{processId:u,name:c,pid:d,status:h}=l;e(p=>({processes:[...p.processes,{id:u,sessionId:"",name:c,command:"",cwd:"",pid:d,status:h,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(h=>h.id===u?{...h,status:"exited",exitCode:c}:h)}));break}case"backgroundProcess.removed":{const u=l.processId;t().removeProcess(u);break}}}}}),RN={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Gu=null;function ON(e){Gu=e}function Ui(){return RN}function _m(){Gu==null||Gu()}let _u=[];const Rn=Mn()((e,t)=>{function n(){if(_u.length===0)return;const a=_u;_u=[],e(l=>({logs:[...l.logs,...a]}))}const r=_1(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:a=>{t().workdir!==a&&(e({workdir:a,status:null,logs:[],config:null,loading:!0}),a&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const a=t().workdir;if(a)try{const u=await(await ye(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:u,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const u=await(await ye(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:u.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const c=(await(await ye(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content,...d.type?{type:d.type}:{}}));e({logs:c})}catch{}},clearLogs:async()=>{const a=t().workdir;if(a)try{await ye(`/api/dev-server/clear-logs?workdir=${encodeURIComponent(a)}`,{method:"POST"}),e({logs:[]})}catch{}},insertMarker:async()=>{const a=t().workdir;if(a)try{await ye(`/api/dev-server/insert-marker?workdir=${encodeURIComponent(a)}`,{method:"POST"}),t().fetchLogs()}catch{}},start:async()=>{const a=t().workdir;if(a)try{const u=await(await ye(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const u=await(await ye(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const u=await(await ye(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},saveConfig:async a=>{const l=t().workdir;if(l)try{const c=await(await ye(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:c.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const l=t().workdir;if(l)switch(a.type){case"devServer.output":{const u=a.payload;if(u.workdir!==l)return;_u.push({stream:u.stream,content:u.content}),r();break}case"devServer.state":{const u=a.payload;if(u.workdir!==l)return;e(c=>({status:c.status?{...c.status,state:u.state,errorMessage:u.errorMessage,...u.url!==void 0?{url:u.url}:{},...u.inspectProxyPort!==void 0?{inspectProxyPort:u.inspectProxyPort}:{}}:{state:u.state,url:u.url??null,hotReload:!1,config:null,errorMessage:u.errorMessage,inspectProxyPort:u.inspectProxyPort??null}}));break}}}}}),IN=[{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"}],MN=[{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"}],S1={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"},li={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},w1={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},vp={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...li},waiting_for_user:{...li},phase_done:{...li},phase_blocked:{...li},new_message:{...w1}},agentOverrides:{}};function C1(e,t,n){var l;const r=e.events[t];if(!n)return r;const a=(l=e.agentOverrides[n])==null?void 0:l[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const Fi=Mn((e,t)=>({settings:vp,loaded:!1,load:()=>{Ft.getState().getSetting(Te.NOTIFICATION_SETTINGS);const r=Ft.subscribe(l=>{const u=l.settings[Te.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:w_(c),loaded:!0})}catch{e({loaded:!0})}}),a=Ft.getState().settings[Te.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:w_(l),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Sm(n)},updateEvent:(n,r)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:l}),Sm(l)},updateAgentOverride:(n,r,a)=>{var d;const l=t().settings,u={...l.agentOverrides};if(a===null){if(u[n]){const h={...u[n]};delete h[r],Object.keys(h).length===0?delete u[n]:u[n]=h}}else u[n]={...u[n],[r]:{...((d=u[n])==null?void 0:d[r])??{},...a}};const c={...l,agentOverrides:u};e({settings:c}),Sm(c)}}));function Sm(e){Ft.getState().setSetting(Te.NOTIFICATION_SETTINGS,JSON.stringify(e))}function w_(e){var t,n,r,a,l;return{soundEnabled:e.soundEnabled??vp.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??vp.browserNotificationEnabled,events:{complete:{...li,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...li,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...li,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...li,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...w1,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const C_=new Map;function PN(e){let t=C_.get(e);return t||(t=new Audio(Es(e)),t.volume=.5,C_.set(e,t)),t}let k1=typeof Notification<"u"?Notification.permission:"denied";function BN(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(k1=e,e))}const $N={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},zN={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 HN(e){typeof Notification>"u"||k1==="granted"&&(document.hasFocus()||new Notification($N[e],{body:zN[e],icon:Es("/fox.svg"),tag:`openfox-${e}`}))}function Xl(e,t){const{settings:n}=Fi.getState(),r=C1(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??S1[e],l=PN(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&HN(e)}const UN=e=>Xl("complete",e),FN=e=>Xl("phase_done",e),VN=e=>Xl("phase_blocked",e),wm=e=>Xl("waiting_for_user",e),WN=e=>Xl("new_message",e),k_=new Map;function Xa(e,t){var l;const n=t===((l=e.currentSession)==null?void 0:l.id)?e.currentSession:null,r=e.sessions.find(u=>u.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function GN(e,t){if(e.type==="chat.done"){const n=e.payload,r=Xa(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&UN(a),n.reason==="waiting_for_user"&&wm(a);return}if(e.type==="chat.path_confirmation"){const n=Xa(t,e.sessionId);wm(n);return}if(e.type==="session.confirmation_pending"){const n=Xa(t,e.sessionId);wm(n);return}if(e.type==="task.completed"){const n=Xa(t,e.sessionId);FN(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=k_.get(e.sessionId)??null;if(k_.set(e.sessionId,n.phase),r===n.phase)return;const a=Xa(t,e.sessionId);n.phase==="blocked"&&VN(a)}}const Il=Mn(e=>({servers:[],setServers:t=>e({servers:t}),fetchServers:async()=>{try{const t=await ye("/api/mcp/servers");if(!t.ok)return;const r=((await t.json()).servers??[]).sort((a,l)=>a.name.localeCompare(l.name));e({servers:r})}catch{}}})),Cm=new Set;function ln(e,t){return t!==null&&e.sessionId===t}function qN(e,t,n){return e.id!==void 0||ln(e,t)||n===!0&&e.sessionId!==void 0}function KN(e,t){return e.includes(t)?e:[...e,t]}function j_(e,t){return e.filter(n=>n!==t)}function YN(e,t){const n=e.find(l=>l.id===t.id),r=t.messageCount??t.messages.length,a=n?{...n,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length,messageCount:r};return n?e.map(l=>l.id===t.id?a:l):[a,...e]}function km(e,t){const n=e.findIndex(r=>r.callId===t.callId);if(n>=0){const r=[...e];return r[n]=t,r}return[...e,t]}function XN(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,l=t.find(u=>u.id===r.id);return{...r,title:r.title??(l==null?void 0:l.title),mode:(a==null?void 0:a.mode)??(l==null?void 0:l.mode)??r.mode,phase:(a==null?void 0:a.phase)??(l==null?void 0:l.phase)??r.phase,isRunning:r.isRunning&&(l==null?void 0:l.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function E_(e,t,n,r){var c;const a=e.sessionId,l=(c=n().currentSession)==null?void 0:c.id,u=a&&a!==l;if(t(d=>({sessions:d.sessions.map(h=>h.id===a?r(h):h)})),!u){const d=n().currentSession;if(d){const h=r(d);t(()=>({currentSession:h}))}}}function N_(e,t,n){var c,d,h,p,m,x,y,w,C,_,S,v,b,j,N,T,D,L,I,M,G,U;const r=n();GN(e,r);const a=((c=r.currentSession)==null?void 0:c.id)??null,l=()=>{const R=e.sessionId;!R||R===a||t(H=>({unreadSessionIds:KN(H.unreadSessionIds,R)}))},u=(R,H,W)=>({messages:R.messages.map(V=>V.id===H?W(V):V)});switch(e.type){case"session.state":{const R=e.payload;if(!qN(e,a,r.pendingSessionCreate))break;const H=n().pendingSessionCreate===!0,W=R.pendingConfirmations??[],V=R.session.id,ee={...n().crossSessionConfirmations};delete ee[V],t({currentSession:R.session,sessions:YN(n().sessions,R.session),unreadSessionIds:j_(n().unreadSessionIds,V),messages:R.messages,hiddenCount:R.hiddenCount??0,currentTodos:[],pendingPathConfirmations:W,crossSessionConfirmations:ee,sessionsWithPendingConfirmations:Object.keys(ee),pendingQuestions:R.pendingQuestions??[],activeWorkflowExecution:R.activeWorkflowExecution??null,...H?{pendingSessionCreate:R.session.id}:{}});break}case"session.list":{const R=e.payload;t(H=>({sessions:XN(R.sessions,H.sessions,H.currentSession)}));break}case"session.created":{const R=e.payload;t(H=>({sessions:H.sessions.some(W=>W.id===R.session.id)?H.sessions.map(W=>W.id===R.session.id?{...W,...R.session}:W):[R.session,...H.sessions]}));break}case"session.deleted":{const R=e.payload;t(H=>({unreadSessionIds:j_(H.unreadSessionIds,R.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const R=e.payload;E_(e,t,n,H=>({...H,isRunning:R.isRunning})),R.isRunning||t({abortInProgress:!1,queuedMessages:[]}),R.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!ln(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const R=e.payload;t(H=>{if(H.messages.some(V=>V.id===R.message.id))return H;const W=R.message.role==="user";return{messages:[...H.messages,R.message],sessions:H.sessions.map(V=>V.id===e.sessionId&&W?{...V,messageCount:V.messageCount+1}:V)}});break}case"chat.message_updated":{if(!ln(e,((h=n().currentSession)==null?void 0:h.id)??null)){l();break}const R=e.payload,H=n().messages.find(W=>W.id===R.messageId);R.updates.isStreaming===!1&&(H==null||H.isStreaming),t(W=>({messages:W.messages.map(V=>V.id===R.messageId?{...V,...R.updates}:V)}));break}case"chat.delta":{if(!ln(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const R=e.payload;if(!Cm.has(R.messageId)){Cm.add(R.messageId);const W=R.subAgentType?"sub-agent":Xa(n(),e.sessionId);WN(W)}const H=Ui();H.messageId=R.messageId,H.deltaContent+=R.content,_m();break}case"chat.thinking":{if(!ln(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const R=e.payload,H=Ui();H.messageId=R.messageId,H.thinkingContent+=R.content,_m();break}case"chat.tool_preparing":{if(!ln(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const R=e.payload;t(H=>{var O;const W=H.messages.find(B=>B.id===R.messageId);if(!W)return{};if((O=W.toolCalls)==null?void 0:O.find((B,q)=>q===R.index))return{};const ee=W.preparingToolCalls??[],X=ee.findIndex(B=>B.index===R.index);let $;return X>=0?$=ee.map((B,q)=>q===X?{...B,arguments:R.arguments}:B):$=[...ee,{index:R.index,name:R.name,...R.arguments?{arguments:R.arguments}:{}}],{messages:H.messages.map(B=>B.id===R.messageId?{...B,preparingToolCalls:$}:B)}});break}case"chat.tool_call":{if(!ln(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const R=e.payload,H=W=>{var O;const V=(W.toolCalls??[]).length,ee=(O=W.preparingToolCalls)==null?void 0:O.filter(B=>B.index!==V),X=Ui(),$=X.toolOutput.filter(B=>B.callId===R.callId);return $.length>0&&(X.toolOutput=X.toolOutput.filter(B=>B.callId!==R.callId)),{...W,toolCalls:[...W.toolCalls??[],{id:R.callId,name:R.tool,arguments:R.args,startedAt:Date.now(),...$.length>0?{streamingOutput:$.map(B=>({stream:B.stream,content:B.content,timestamp:Date.now()}))}:{}}],...ee&&ee.length>0?{preparingToolCalls:ee}:{preparingToolCalls:void 0}}};t(W=>u(W,R.messageId,H));break}case"chat.tool_output":{if(!ln(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const R=e.payload,H=Ui();H.messageId=R.messageId,H.toolOutput.push({messageId:R.messageId,callId:R.callId,stream:R.stream,content:R.output}),_m();break}case"chat.tool_result":{if(!ln(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const R=e.payload,H=W=>{var ee;const V=(ee=W.toolCalls)==null?void 0:ee.map(X=>X.id===R.callId?{...X,result:R.result}:X);return{...W,toolCalls:V}};t(W=>u(W,R.messageId,H));break}case"chat.vision_fallback":{if(!ln(e,((_=n().currentSession)==null?void 0:_.id)??null)){l();break}const R=e.payload;t(H=>{const W=`${R.messageId}-${R.attachmentId}`,V={...H.visionFallbackByMessage};return V[W]={type:R.type,attachmentId:R.attachmentId,filename:R.filename,description:R.description},{visionFallbackByMessage:V}});break}case"chat.todo":{if(!ln(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const R=e.payload;t({currentTodos:R.todos});break}case"chat.progress":{if(!ln(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const R=e.payload;console.warn("Progress:",R.message,R.phase);break}case"chat.format_retry":{if(!ln(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const R=e.payload;console.warn("Format retry:",R.attempt,"/",R.maxAttempts);break}case"chat.done":{if(!ln(e,((j=n().currentSession)==null?void 0:j.id)??null)){l();break}const R=Ui();R.messageId=null,R.deltaContent="",R.thinkingContent="",R.toolOutput=[],Cm.delete(e.payload.messageId);const H=e.payload,W=H.stats;t(V=>({messages:V.messages.map(ee=>ee.id===H.messageId?{...ee,isStreaming:!1,stats:W??ee.stats,completeReason:H.reason,preparingToolCalls:void 0}:ee),visionFallbackByMessage:{}}));break}case"chat.error":{if(!ln(e,((N=n().currentSession)==null?void 0:N.id)??null)){l();break}const R=Ui(),H=e.payload;console.error("Chat error:",H.error,"recoverable:",H.recoverable),H.recoverable||(R.messageId=null,R.deltaContent="",R.thinkingContent="",R.toolOutput=[]),t(W=>({error:{code:"CHAT_ERROR",message:H.error},...H.recoverable?{}:{messages:W.messages}}));break}case"chat.path_confirmation":{const R=e.sessionId,H=R===(((T=n().currentSession)==null?void 0:T.id)??null),W=e.payload,V={callId:W.callId,tool:W.tool,paths:W.paths,workdir:W.workdir,reason:W.reason};if(!H){l(),R&&t(ee=>({crossSessionConfirmations:{...ee.crossSessionConfirmations,[R]:km(ee.crossSessionConfirmations[R]??[],V)},sessionsWithPendingConfirmations:ee.sessionsWithPendingConfirmations.includes(R)?ee.sessionsWithPendingConfirmations:[...ee.sessionsWithPendingConfirmations,R]}));break}t(ee=>({pendingPathConfirmations:km(ee.pendingPathConfirmations,V)}));break}case"session.confirmation_pending":{const R=e.sessionId,H=e.payload,W={callId:H.callId,tool:H.tool,paths:H.paths,workdir:H.workdir,reason:H.reason};R&&t(V=>({crossSessionConfirmations:{...V.crossSessionConfirmations,[R]:km(V.crossSessionConfirmations[R]??[],W)},sessionsWithPendingConfirmations:V.sessionsWithPendingConfirmations.includes(R)?V.sessionsWithPendingConfirmations:[...V.sessionsWithPendingConfirmations,R]}));break}case"session.confirmation_resolved":{const R=e.sessionId,H=e.payload;R&&t(W=>{const ee=(W.crossSessionConfirmations[R]??[]).filter($=>$.callId!==H.callId),X={...W.crossSessionConfirmations};return ee.length===0?delete X[R]:X[R]=ee,{crossSessionConfirmations:X,sessionsWithPendingConfirmations:Object.keys(X)}});break}case"chat.ask_user":{if(!ln(e,((D=n().currentSession)==null?void 0:D.id)??null)){l();return}const R=e.payload,H={callId:R.callId,question:R.question,type:R.type??"text",options:R.options??void 0};t(W=>({pendingQuestions:[...W.pendingQuestions.filter(V=>V.callId!==R.callId),H]}));break}case"mode.changed":{if(!ln(e,((L=n().currentSession)==null?void 0:L.id)??null)){l();break}const R=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,mode:R.mode}:null}));break}case"phase.changed":{const R=e.payload;E_(e,t,n,H=>({...H,phase:R.phase}));break}case"workflow.execution_changed":{const R=e.payload;t(H=>{const W=H.activeWorkflowExecution;return W?{activeWorkflowExecution:{...W,status:R.status,...R.currentStepId?{currentStepId:R.currentStepId}:{},...R.currentStepName?{currentStepName:R.currentStepName}:{}}}:{activeWorkflowExecution:{id:R.executionId,sessionId:e.sessionId??"",workflowId:R.workflowId,workflowName:R.workflowName,...R.workflowColor?{workflowColor:R.workflowColor}:{},status:R.status,...R.currentStepId?{currentStepId:R.currentStepId}:{},...R.currentStepName?{currentStepName:R.currentStepName}:{},stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}});break}case"criteria.updated":{if(!ln(e,((I=n().currentSession)==null?void 0:I.id)??null)){l();break}const R=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,criteria:R.criteria}:null}));break}case"metadata.updated":{if(!ln(e,((M=n().currentSession)==null?void 0:M.id)??null)){l();break}const R=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,metadataEntries:{...H.currentSession.metadataEntries,[R.key]:R.entries}}:null}));break}case"context.state":{const R=e.payload,H=ln(e,((G=n().currentSession)==null?void 0:G.id)??null);R.subAgentId?H&&n().updateSubAgentContextState(R.subAgentId,R.context):H?t({contextState:R.context}):l();break}case"session.name_generated":{const R=e.payload,H=e.sessionId,W=(U=n().currentSession)==null?void 0:U.id;t(V=>{const ee=V.sessions.map($=>$.id===H?{...$,title:R.name}:$),X=W===H?V.currentSession?{...V.currentSession,metadata:{...V.currentSession.metadata,title:R.name}}:null:V.currentSession;return{sessions:ee,currentSession:X}});break}case"queue.state":{const R=e.payload;t({queuedMessages:R.messages??[]});break}case"mcp.servers.changed":{const R=e.payload;if(R!=null&&R.servers){const H=[...R.servers].sort((W,V)=>W.name.localeCompare(V.name));Il.getState().setServers(H)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const R=e.payload;t({gitStatus:{branch:R.branch,diff:R.diff}});break}case"devServer.output":case"devServer.state":{Rn.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Nl.getState().handleMessage(e.type,e.payload);break}case"error":{const R=e.payload;console.error("Server error:",R),t({error:{code:R.code,message:R.message}});break}}}let fl=!1,Vr=null;const jm=new Set,Su=new Map;function T_(e,t,n){return e==null?void 0:e.map(r=>{const a=t.filter(l=>l.callId===r.id);return a.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...a.map(l=>({stream:l.stream,content:l.content,timestamp:Date.now()}))]})})}async function A_(e,t,n,r,a){try{const u=await(await ye(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();u.queueState&&a({queuedMessages:u.queueState})}catch(l){console.error("Error queueing message:",l)}}const Le=Mn((e,t)=>{ON(()=>{const r=Ui();if(!r.messageId)return;const a=r.deltaContent.length>0,l=r.thinkingContent.length>0,u=r.toolOutput.length>0;if(!a&&!l&&!u)return;const c=r.deltaContent,d=r.thinkingContent,h=r.toolOutput;r.deltaContent="",r.thinkingContent="",r.toolOutput=[],e(p=>{const m=p.messages.find(x=>x.id===r.messageId);if(m){const x={...m};if(a&&(x.content=x.content+c),l&&(x.thinkingContent=(x.thinkingContent??"")+d),u){const y=new Set;x.toolCalls=T_(x.toolCalls,h,y);const w=h.filter(C=>!y.has(C.callId));w.length>0&&r.toolOutput.push(...w)}return{messages:p.messages.map(y=>y.id===r.messageId?x:y)}}if(u){const x=new Set,y=p.messages.map(C=>C.id!==r.messageId?C:{...C,toolCalls:T_(C.toolCalls,h,x)}),w=h.filter(C=>!x.has(C.callId));return w.length>0&&r.toolOutput.push(...w),{messages:y}}return p})});function n(r,a,l,u){return{workflowId:r.workflowId,resumeFrom:r.currentStepId,stepOutput:r.stepOutput,...r.params&&Object.keys(r.params).length>0?{params:r.params}:{},...a!=null&&a.trim()?{content:a}:{},...l&&l.length>0?{attachments:l}:{},...u?{messageKind:u}:{}}}return{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],crossSessionConfirmations:{},sessionsWithPendingConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,activeWorkflowExecution:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,pendingUpdate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let a=!1;try{a=(await(await ye("/api/auth")).json()).requiresAuth}catch{}if(a&&!Lt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Lt.onStatusChange(l=>{var u;if(e({connectionStatus:l}),l==="connected"){t().listSessions(void 0),Wt.getState().listProjects();const c=(u=t().currentSession)==null?void 0:u.id;c&&t().loadSession(c)}});try{await Lt.connect(),fl||(fl=!0,Vr=Lt.subscribe(l=>{N_(l,e,t)}))}catch(l){console.error("Failed to connect:",l);const u=Lt.getLastCloseCode();if(!Lt.hasToken()&&(u===1006||u===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Vr&&(Vr(),Vr=null),fl=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Lt.disconnect(),Vr&&(Vr(),Vr=null),fl=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Lt.disconnect(),Vr&&(Vr(),Vr=null),fl=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async r=>{try{const a=await fetch(Es("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})});if(!a.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:l}=await a.json();Lt.setToken(l),e({showPasswordModal:!1}),t().connect();const{listProjects:u}=Wt.getState(),{fetchConfig:c}=Qt.getState();u(),c(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Lt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(r,a)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const u=await ye("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r,title:a})});if(!u.ok)return e({pendingSessionCreate:!1}),null;const c=await u.json();try{Lt.send("session.load",{sessionId:c.session.id})}catch{}return c.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async r=>{if(!jm.has(r)){jm.add(r);try{const a=t().currentSession;if(!a||a.id!==r){const h=a==null?void 0:a.id,p=t().pendingPathConfirmations,x={...t().crossSessionConfirmations};h&&p.length>0&&(x[h]=[...x[h]??[],...p]),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(y=>y!==r),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,gitStatus:null,pendingSessionCreate:!1,crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x)})}else e({unreadSessionIds:t().unreadSessionIds.filter(h=>h!==r)});const l=await ye(`/api/sessions/${r}`);if(!l.ok)return;const u=await l.json(),c=u.messages??[],d={...t().crossSessionConfirmations};delete d[r],e({currentSession:u.session,messages:c,hiddenCount:u.hiddenCount??0,contextState:u.contextState,queuedMessages:u.queueState??[],pendingPathConfirmations:u.pendingConfirmations??[],pendingQuestions:u.pendingQuestions??[],activeWorkflowExecution:u.activeWorkflowExecution??null,crossSessionConfirmations:d,sessionsWithPendingConfirmations:Object.keys(d)}),Lt.send("session.load",{sessionId:r});try{const h=await ye(`/api/sessions/${r}/background-processes`);if(h.ok){const p=await h.json();Nl.getState().setProcesses(p.processes??[])}}catch{}}catch{}finally{jm.delete(r)}}},listSessions:async(r,a=20)=>{const l=r??"global";if(Su.has(l))return Su.get(l);const u=(async()=>{var c;try{const d=new URLSearchParams;d.set("limit",String(a)),r&&d.set("projectId",r);const p=await(await ye(`/api/sessions?${d.toString()}`)).json(),m=p.sessions??[];e(y=>({sessions:m.map(w=>{var _,S;const C=y.sessions.find(v=>v.id===w.id);return{...w,title:w.title??(C==null?void 0:C.title),mode:((_=y.currentSession)==null?void 0:_.id)===w.id?y.currentSession.mode:(C==null?void 0:C.mode)??w.mode,phase:((S=y.currentSession)==null?void 0:S.id)===w.id?y.currentSession.phase:(C==null?void 0:C.phase)??w.phase,isRunning:w.isRunning&&(C==null?void 0:C.isRunning)!==!1,messageCount:w.messageCount,recentUserPrompts:w.recentUserPrompts}}),sessionsHasMore:r?p.hasMore??!1:!0}));const x=p.pendingConfirmationsBySession;if(x){const y=(c=t().currentSession)==null?void 0:c.id,w={};for(const[C,_]of Object.entries(x))C!==y&&(w[C]=_);e({crossSessionConfirmations:w,sessionsWithPendingConfirmations:Object.keys(w)})}}catch{}finally{Su.delete(l)}})();return Su.set(l,u),u},loadMoreSessions:async r=>{const a=t();if(!(a.sessionsPaginationLoading||!a.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const l=new URLSearchParams;l.set("limit","20"),l.set("offset",String(a.sessions.length)),l.set("projectId",r);const c=await(await ye(`/api/sessions?${l.toString()}`)).json(),d=c.sessions??[];e(h=>({sessions:[...h.sessions,...d.map(p=>{const m=h.sessions.find(x=>x.id===p.id);return(m==null?void 0:m.isRunning)===!1?{...p,isRunning:!1}:p})],sessionsHasMore:c.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async r=>{var a;try{return(await ye(`/api/sessions/${r}`,{method:"DELETE"})).ok?(await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===r&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(r,a)=>{var l;try{const u=await ye(`/api/sessions/${r}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a})});if(!u.ok)return!1;if(await t().listSessions(),((l=t().currentSession)==null?void 0:l.id)===r){const d=await u.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},deleteAllSessions:async r=>{try{return(await ye(`/api/projects/${r}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{e(r=>({currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,unreadSessionIds:r.currentSession?r.unreadSessionIds.filter(a=>a!==r.currentSession.id):r.unreadSessionIds}))},sendMessage:async(r,a,l)=>{var d;e({error:null});const u=(d=t().currentSession)==null?void 0:d.id;if(!u)return;const c=t().activeWorkflowExecution;if(c&&c.status==="running"){Lt.send("runner.launch",n(c,r,a,l==null?void 0:l.messageKind));return}try{const h=r==null?void 0:r.trim(),p=a&&a.length>0,m={};h&&(m.content=r),p&&(m.attachments=a),l!=null&&l.messageKind&&(m.messageKind=l.messageKind);const y=await(await ye(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)})).json();y.queueState&&e({queuedMessages:y.queueState})}catch(h){console.error("Error sending message:",h)}},stopGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r&&!t().abortInProgress){e({abortInProgress:!0});try{const u=await(await ye(`/api/sessions/${r}/stop`,{method:"POST"})).json();if(u.queuedMessages&&u.queuedMessages.length>0){const c=u.queuedMessages.map(d=>d.content).join(`
|
|
59
|
+
`);e({restoredInput:c})}}catch(l){console.error("Error stopping generation:",l)}}},continueGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{await ye(`/api/sessions/${r}/continue`,{method:"POST"})}catch(l){console.error("Error continuing generation:",l)}},launchWorkflow:(r,a,l,u,c)=>{const d={};r!=null&&r.trim()&&(d.content=r),a&&a.length>0&&(d.attachments=a),l&&(d.workflowId=l),u&&(d.subGroup=u),c&&(d.params=c),Lt.send("runner.launch",d)},continueWorkflow:()=>{const a=t().activeWorkflowExecution;!a||a.status!=="waiting"||Lt.send("runner.launch",n(a))},exitWorkflow:()=>{Lt.send("workflow.exit",{})},switchMode:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await ye(`/api/sessions/${a}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})});if(!u.ok){console.error("Failed to switch mode:",await u.json());return}const c=await u.json();c.session&&e({currentSession:c.session}),c.messages&&e({messages:c.messages,hiddenCount:c.hiddenCount??0})}catch(u){console.error("Error switching mode:",u)}},switchDangerLevel:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await ye(`/api/sessions/${a}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:r})});if(!u.ok){console.error("Failed to switch danger level:",await u.json());return}const c=await u.json();c.session&&e({currentSession:c.session})}catch(u){console.error("Error switching danger level:",u)}},editCriteria:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await ye(`/api/sessions/${a}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:r})});u.ok||console.error("Failed to update criteria:",await u.json())}catch(u){console.error("Error updating criteria:",u)}},compactContext:()=>{Lt.send("context.compact",{})},setSessionProvider:async(r,a)=>{var l;try{const u=(l=t().currentSession)==null?void 0:l.id;if(!u)return null;const c=await ye(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r,...a?{model:a}:{}})});if(!c.ok)return null;const d=await c.json();return e({currentSession:d.session,messages:d.messages??[],hiddenCount:d.hiddenCount??0,contextState:d.contextState}),d.session}catch{return null}},updateContextState:r=>{e({contextState:r})},updateSubAgentContextState:(r,a)=>{e(l=>({subAgentContextStates:{...l.subAgentContextStates,[r]:a}}))},clearSubAgentContextState:r=>{e(a=>{const l={...a.subAgentContextStates};return delete l[r],{subAgentContextStates:l}})},confirmPath:async(r,a,l=!1)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;if(u)try{const d=await ye(`/api/sessions/${u}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,approved:a,alwaysAllow:l})});if(!d.ok){const h=await d.json().catch(()=>({}));console.error("Error confirming path:",h.error??`HTTP ${d.status}`)}}catch(d){console.error("Error confirming path:",d)}},answerQuestion:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;if(u){try{await ye(`/api/sessions/${u}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,answer:a,skip:l})})}catch(d){console.error("Error answering question:",d)}e(d=>({pendingQuestions:d.pendingQuestions.filter(h=>h.callId!==r)}))}},queueAsap:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;u&&await A_(u,r,a,l,e)},queueCompletion:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;u&&await A_(u,r,a,l,e)},cancelQueued:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const c=await(await ye(`/api/sessions/${a}/queue/${r}`,{method:"DELETE"})).json();c.queueState&&e({queuedMessages:c.queueState})}catch(u){console.error("Error canceling queued message:",u)}},clearError:()=>{e({error:null})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:()=>{e({pendingUpdate:!0})},triggerPendingUpdate:()=>{t().pendingUpdate&&(e({pendingUpdate:!1}),Lt.send("context.applyDynamic",{}))},handleServerMessage:r=>{N_(r,e,t)}}});function Nd(){return Le(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function QN(){return Le(e=>e.abortInProgress)}function JN(){const e=Le(a=>a.connect),t=Le(a=>a.connectionStatus),n=Fi(a=>a.load),r=fo("/p/:projectId/s/:sessionId/readonly")[0];return E.useEffect(()=>{r||e()},[e,r]),E.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const ZN="modulepreload",eT=function(e){return"/"+e},L_={},te=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=u(n.map(h=>{if(h=eT(h),h in L_)return;L_[h]=!0;const p=h.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":ZN,p||(x.as="script"),x.crossOrigin="",x.href=h,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 ${h}`)))})}))}function l(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return a.then(u=>{for(const c of u||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})},tT=[{key:"color-bg-primary",category:"background",label:"Primary Background",defaultValue:"13 17 23"},{key:"color-bg-secondary",category:"background",label:"Secondary Background",defaultValue:"22 27 34"},{key:"color-bg-tertiary",category:"background",label:"Tertiary Background",defaultValue:"33 38 45"},{key:"color-primary",category:"surface",label:"Primary Surface",defaultValue:"10 10 10"},{key:"color-secondary",category:"surface",label:"Secondary Surface",defaultValue:"20 20 20"},{key:"color-text-primary",category:"text",label:"Primary Text",defaultValue:"139 148 158"},{key:"color-text-secondary",category:"text",label:"Secondary Text",defaultValue:"139 148 158"},{key:"color-text-muted",category:"text",label:"Muted Text",defaultValue:"72 79 88"},{key:"color-accent-primary",category:"accent",label:"Primary Accent",defaultValue:"88 166 255"},{key:"color-accent-success",category:"accent",label:"Success Accent",defaultValue:"63 185 80"},{key:"color-accent-warning",category:"accent",label:"Warning Accent",defaultValue:"210 153 34"},{key:"color-accent-error",category:"accent",label:"Error Accent",defaultValue:"248 81 73"},{key:"color-border",category:"border",label:"Border",defaultValue:"48 53 60"},{key:"color-text-heading",category:"text",label:"Heading Text",defaultValue:"56 189 248"},{key:"color-text-bold",category:"text",label:"Bold Text",defaultValue:"251 191 36"},{key:"color-text-code",category:"text",label:"Inline Code Text",defaultValue:"88 166 255"},{key:"color-text-link",category:"text",label:"Link Text",defaultValue:"88 166 255"},{key:"color-bg-system",category:"background",label:"System Message Background",defaultValue:"40 35 28"},{key:"color-border-system",category:"border",label:"System Message Border",defaultValue:"65 55 25"},{key:"color-text-system",category:"text",label:"System Message Text",defaultValue:"253 230 138"},{key:"color-text-thinking",category:"text",label:"Thinking Label",defaultValue:"192 132 252"},{key:"color-text-truncated",category:"text",label:"Truncation Warning",defaultValue:"251 191 36"},{key:"color-text-tool-error",category:"text",label:"Tool Error Text",defaultValue:"248 81 73"}],nT=JSON.parse('[{"id":"system","name":"System","tokens":{}},{"id":"dark","name":"Dark","tokens":{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"255 255 255","color-text-link":"88 166 255","color-bg-system":"40 35 28","color-border-system":"65 55 25","color-text-system":"253 230 138","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"light","name":"Light","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225","color-text-heading":"2 132 199","color-text-bold":"217 119 6","color-text-code":"37 99 235","color-text-link":"37 99 235","color-bg-system":"254 243 199","color-border-system":"252 211 77","color-text-system":"146 100 30","color-text-thinking":"147 51 234","color-text-truncated":"217 119 6","color-text-tool-error":"220 38 38"},"mode":"light"},{"id":"monokai","name":"Monokai","tokens":{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"248 248 242","color-text-link":"102 217 239","color-bg-system":"62 57 40","color-border-system":"85 75 40","color-text-system":"230 219 116","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"dracula","name":"Dracula","tokens":{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90","color-text-heading":"189 147 249","color-text-bold":"255 184 108","color-text-code":"189 147 249","color-text-link":"189 147 249","color-bg-system":"68 64 50","color-border-system":"90 80 60","color-text-system":"255 184 108","color-text-thinking":"255 121 198","color-text-truncated":"255 184 108","color-text-tool-error":"255 85 85"},"mode":"dark"},{"id":"nord","name":"Nord","tokens":{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"121 133 160","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"121 133 160","color-text-heading":"129 161 193","color-text-bold":"235 203 139","color-text-code":"129 161 193","color-text-link":"129 161 193","color-bg-system":"67 62 50","color-border-system":"85 80 60","color-text-system":"235 203 139","color-text-thinking":"184 142 173","color-text-truncated":"235 203 139","color-text-tool-error":"191 97 106"},"mode":"dark"},{"id":"rose-pine-dawn","name":"Rose Pine Dawn","tokens":{"color-bg-primary":"250 244 237","color-bg-secondary":"244 237 228","color-bg-tertiary":"235 226 216","color-primary":"250 244 237","color-secondary":"244 237 228","color-text-primary":"87 82 95","color-text-secondary":"111 105 120","color-text-muted":"175 170 180","color-accent-primary":"215 130 126","color-accent-success":"104 157 153","color-accent-warning":"234 157 84","color-accent-error":"215 85 112","color-border":"230 218 206","color-text-heading":"215 130 126","color-text-bold":"234 157 84","color-text-code":"145 117 186","color-text-link":"215 130 126","color-bg-system":"244 237 228","color-border-system":"230 218 206","color-text-system":"162 137 123","color-text-thinking":"145 117 186","color-text-truncated":"234 157 84","color-text-tool-error":"215 85 112"},"mode":"light"},{"id":"everforest-light","name":"Everforest Light","tokens":{"color-bg-primary":"255 248 235","color-bg-secondary":"245 238 220","color-bg-tertiary":"237 228 208","color-primary":"255 248 235","color-secondary":"245 238 220","color-text-primary":"91 105 86","color-text-secondary":"127 139 116","color-text-muted":"179 181 158","color-accent-primary":"100 153 117","color-accent-success":"141 169 73","color-accent-warning":"224 146 66","color-accent-error":"203 97 80","color-border":"230 216 194","color-text-heading":"100 153 117","color-text-bold":"224 146 66","color-text-code":"146 131 176","color-text-link":"100 153 117","color-bg-system":"245 238 220","color-border-system":"230 216 194","color-text-system":"163 147 121","color-text-thinking":"146 131 176","color-text-truncated":"224 146 66","color-text-tool-error":"203 97 80"},"mode":"light"},{"id":"synthwave-84","name":"Synthwave-84","tokens":{"color-bg-primary":"13 15 26","color-bg-secondary":"20 24 41","color-bg-tertiary":"26 31 51","color-primary":"10 12 20","color-secondary":"20 24 41","color-text-primary":"212 230 255","color-text-secondary":"136 153 187","color-text-muted":"68 85 119","color-accent-primary":"0 229 255","color-accent-success":"0 255 65","color-accent-warning":"255 106 0","color-accent-error":"255 0 60","color-border":"26 51 102","color-text-heading":"0 229 255","color-text-bold":"255 140 0","color-text-code":"0 255 170","color-text-link":"0 229 255","color-bg-system":"26 20 10","color-border-system":"51 40 20","color-text-system":"255 170 80","color-text-thinking":"191 0 255","color-text-truncated":"255 140 0","color-text-tool-error":"255 0 60"},"mode":"dark"},{"id":"one-dark-pro","name":"One Dark Pro","tokens":{"color-bg-primary":"40 44 52","color-bg-secondary":"33 37 43","color-bg-tertiary":"47 52 62","color-primary":"28 31 37","color-secondary":"33 37 43","color-text-primary":"171 178 191","color-text-secondary":"150 155 168","color-text-muted":"92 99 112","color-accent-primary":"97 175 239","color-accent-success":"152 195 121","color-accent-warning":"209 154 102","color-accent-error":"224 108 117","color-border":"57 62 72","color-text-heading":"97 175 239","color-text-bold":"209 154 102","color-text-code":"198 120 221","color-text-link":"97 175 239","color-bg-system":"47 42 32","color-border-system":"68 60 46","color-text-system":"224 190 79","color-text-thinking":"198 120 221","color-text-truncated":"209 154 102","color-text-tool-error":"224 108 117"},"mode":"dark"},{"id":"night-owl","name":"Night Owl","tokens":{"color-bg-primary":"1 22 39","color-bg-secondary":"0 30 55","color-bg-tertiary":"11 41 66","color-primary":"1 20 33","color-secondary":"0 30 55","color-text-primary":"214 222 235","color-text-secondary":"162 176 196","color-text-muted":"82 98 126","color-accent-primary":"130 170 255","color-accent-success":"34 218 110","color-accent-warning":"247 140 108","color-accent-error":"239 83 80","color-border":"30 56 85","color-text-heading":"130 170 255","color-text-bold":"247 140 108","color-text-code":"199 146 234","color-text-link":"130 170 255","color-bg-system":"30 25 20","color-border-system":"60 50 40","color-text-system":"247 199 120","color-text-thinking":"199 146 234","color-text-truncated":"247 140 108","color-text-tool-error":"239 83 80"},"mode":"dark"},{"id":"catppuccin-mocha","name":"Catppuccin Mocha","tokens":{"color-bg-primary":"30 30 46","color-bg-secondary":"24 24 37","color-bg-tertiary":"49 50 68","color-primary":"17 17 27","color-secondary":"24 24 37","color-text-primary":"205 214 244","color-text-secondary":"186 194 222","color-text-muted":"108 112 134","color-accent-primary":"137 180 250","color-accent-success":"166 227 161","color-accent-warning":"249 226 175","color-accent-error":"243 139 168","color-border":"69 71 90","color-text-heading":"137 180 250","color-text-bold":"249 226 175","color-text-code":"203 166 247","color-text-link":"137 180 250","color-bg-system":"37 37 54","color-border-system":"69 71 90","color-text-system":"250 179 135","color-text-thinking":"203 166 247","color-text-truncated":"249 226 175","color-text-tool-error":"243 139 168"},"mode":"dark"},{"id":"rose-pine","name":"Rose Pine","tokens":{"color-bg-primary":"25 23 36","color-bg-secondary":"31 29 46","color-bg-tertiary":"38 35 58","color-primary":"20 18 30","color-secondary":"31 29 46","color-text-primary":"224 222 244","color-text-secondary":"196 194 220","color-text-muted":"110 106 134","color-accent-primary":"235 188 186","color-accent-success":"156 207 216","color-accent-warning":"246 193 119","color-accent-error":"235 111 146","color-border":"44 40 67","color-text-heading":"235 188 186","color-text-bold":"246 193 119","color-text-code":"196 167 231","color-text-link":"235 188 186","color-bg-system":"44 38 36","color-border-system":"60 52 50","color-text-system":"246 193 119","color-text-thinking":"196 167 231","color-text-truncated":"246 193 119","color-text-tool-error":"235 111 146"},"mode":"dark"},{"id":"kanagawa-wave","name":"Kanagawa Wave","tokens":{"color-bg-primary":"31 34 44","color-bg-secondary":"25 28 36","color-bg-tertiary":"42 47 58","color-primary":"25 28 36","color-secondary":"25 28 36","color-text-primary":"220 224 206","color-text-secondary":"188 193 178","color-text-muted":"108 112 99","color-accent-primary":"133 189 168","color-accent-success":"157 198 113","color-accent-warning":"226 190 107","color-accent-error":"227 116 102","color-border":"51 59 72","color-text-heading":"133 189 168","color-text-bold":"226 190 107","color-text-code":"194 160 191","color-text-link":"133 189 168","color-bg-system":"42 38 30","color-border-system":"60 54 44","color-text-system":"226 190 107","color-text-thinking":"194 160 191","color-text-truncated":"226 190 107","color-text-tool-error":"227 116 102"},"mode":"dark"},{"id":"light-plus","name":"Light Plus","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"243 244 245","color-bg-tertiary":"233 235 238","color-primary":"255 255 255","color-secondary":"243 244 245","color-text-primary":"0 0 0","color-text-secondary":"80 80 80","color-text-muted":"140 140 140","color-accent-primary":"0 92 197","color-accent-success":"0 128 0","color-accent-warning":"178 110 0","color-accent-error":"204 0 0","color-border":"217 217 217","color-text-heading":"0 0 0","color-text-bold":"0 0 0","color-text-code":"204 0 0","color-text-link":"0 92 197","color-bg-system":"255 243 207","color-border-system":"255 220 150","color-text-system":"130 80 0","color-text-thinking":"130 50 180","color-text-truncated":"178 110 0","color-text-tool-error":"204 0 0"},"mode":"light"}]'),j1={tokens:tT,presets:nT},E1=j1.tokens,zn=j1.presets;function D_(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function rT(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Bt=Mn((e,t)=>{const n=rT();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:D_(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:l}=t(),u=r();if(u)try{const c=JSON.parse(u);c.preset&&c.tokens?(a(c.preset),e({basePreset:c.preset}),l(c.tokens)):c.preset?a(c.preset):c.tokens&&l(c.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(zn.find(l=>l.id===r))if(r==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:u,systemLightPreset:c,userPresets:d}=t(),h=l.matches?u:c,p=d.find(m=>m.id===h);e(p?{basePreset:"system",currentPreset:p.basePreset,customTokens:{...p.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:p.id}:{basePreset:"system",currentPreset:h,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0,activeUserPresetId:null}),t().applyTheme()}else e({currentPreset:r,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1,activeUserPresetId:null}),t().applyTheme()},startCustomizing:()=>{var l;const{currentPreset:r}=t(),a=((l=zn.find(u=>u.id===r))==null?void 0:l.tokens)??{};e({basePreset:r,customTokens:{...a},isCustom:!0,isCustomizing:!0})},setCustomToken:(r,a)=>{e(l=>({customTokens:{...l.customTokens,[r]:a}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:r}=t();t().saveTheme(JSON.stringify({tokens:r})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:r=>{e({customTokens:r,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var c,d;const{basePreset:r,customTokens:a,isCustom:l}=t();if(l&&r)return{...((c=zn.find(p=>p.id===r))==null?void 0:c.tokens)??{},...a};if(l)return{...E1.reduce((h,p)=>({...h,[p.key]:p.defaultValue}),{}),...a};const u=zn.find(h=>h.id===t().currentPreset);return(u==null?void 0:u.tokens)??((d=zn[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([l,u])=>{a.style.setProperty(`--${l}`,u)})},getSavedTheme:()=>{try{const r=localStorage.getItem("openfox:theme");if(!r)return null;if(r[0]!=="{")return JSON.stringify({preset:r});const a=JSON.parse(r);if(a.preset)return JSON.stringify({preset:a.preset});if(a.tokens)return JSON.stringify({tokens:a.tokens})}catch{return null}return null},saveTheme:async r=>{localStorage.setItem("openfox:theme",r);const{useSettingsStore:a}=await te(async()=>{const{useSettingsStore:l}=await Promise.resolve().then(()=>hl);return{useSettingsStore:l}},void 0);await a.getState().setSetting(Te.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),te(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>hl);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_FOLLOW_SYSTEM_THEME,String(r))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const r=window.matchMedia("(prefers-color-scheme: dark)"),a=u=>{const{followSystemTheme:c,systemDarkPreset:d,systemLightPreset:h}=t();if(!c)return;const p=u?d:h;t().applyPreset(p),t().saveTheme(JSON.stringify({preset:p}))},l=u=>a(u.matches);return r.addEventListener("change",l),()=>r.removeEventListener("change",l)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0,systemDarkPreset:"dark",systemLightPreset:"light",activeUserPresetId:null})},addUserPreset:r=>{const{basePreset:a,customTokens:l,currentPreset:u}=t(),c=a||u,d=zn.find(m=>m.id===c),h={id:"custom-"+Date.now(),name:r,basePreset:c,mode:d==null?void 0:d.mode,tokens:{...l}},p=[...t().userPresets,h];e({userPresets:p}),t().saveUserPresets()},applyUserPreset:r=>{const a=t().userPresets[r];a&&(e({currentPreset:a.basePreset,basePreset:a.basePreset,customTokens:{...a.tokens},isCustom:!0,isCustomizing:!1,activeUserPresetId:a.id}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:a.basePreset,tokens:a.tokens})).catch(()=>{}))},deleteUserPreset:r=>{const a=t().userPresets.filter((l,u)=>u!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:D_()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),te(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>hl);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(Te.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),te(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>hl);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset}))}),t().isSystem&&t().applyPreset("system")},setSystemLightPreset:r=>{e({systemLightPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r})),te(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>hl);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r}))}),t().isSystem&&t().applyPreset("system")}}});function sT({canLoad:e,projectId:t,currentProjectId:n}){const r=Wt(u=>u.loadProject),a=Le(u=>u.listSessions),l=Le(u=>u.clearSession);E.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),l())},[e,t,n,r,a,l])}function iT({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const l=Le(h=>h.loadSession),u=Wt(h=>h.loadProject),c=Le(h=>h.listSessions),d=Le(h=>h.pendingSessionCreate);E.useEffect(()=>{e&&t&&r!==t&&u(t)},[e,t,r,u]),E.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&c(t)},[e,n,a,l,c,d,t])}function aT({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function N1({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function oT({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function lT({className:e="w-3 h-3 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function Yi({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function $r({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function T1({className:e="w-3 h-3 text-text-muted",rotate:t,direction:n="down"}){return i.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:n==="up"?"M5 15l7-7 7 7":"M19 9l-7 7-7-7"})})}function dn(e){return i.jsx(T1,{direction:"down",...e})}function cT(e){return i.jsx(T1,{direction:"up",...e})}function uT({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Ml({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function A1({className:e="w-3 h-3"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function L1({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("circle",{cx:"12",cy:"5",r:"2"}),i.jsx("circle",{cx:"12",cy:"12",r:"2"}),i.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function lg({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function Nr({className:e="w-5 h-5 text-accent-primary"}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function dT({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})})}function hT({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function fT({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function cg({className:e="w-3 h-3"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function mT({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function R_({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function D1({className:e="w-[18px] h-[18px]"}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function R1({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),i.jsx("path",{d:"M9.5 2h4.5v4.5"}),i.jsx("path",{d:"M14 2L7.5 8.5"})]})}function O1({className:e="w-3 h-3",color:t}){return i.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M8 5v14l11-7z"})})}function Jr({className:e="w-3 h-3 text-accent-primary"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function pT({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function Td({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function I1({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function gT({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return i.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[i.jsx("title",{children:"Running"}),i.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),i.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function M1({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function P1({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function ug({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function xT({className:e="w-3.5 h-3.5 shrink-0",color:t}){return i.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function yT({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"4 17 10 11 4 5"}),i.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function ta({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function Qi({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function bT({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function _p({className:e="w-2.5 h-2.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Ns({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function dg({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function vT({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function _T({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function O_({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function Sp(){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 I_(e,t){const n=Lt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Sp(),type:e,payload:t}))}const Ir=Mn((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const r=await ye(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const l=Lt.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of a)l.send(JSON.stringify({id:Sp(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await ye("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(a.ok){const l=await a.json();e(c=>({sessions:[...c.sessions,l]}));const u=Lt.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:Sp(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{I_("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{I_("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await ye(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(l=>l.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(a=>{const l=a.sessions.filter(u=>u.id!==r);return l.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:l}});break}}}}));Lt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&Ir.getState().handleMessage(e)});const js=Mn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(Es(`/api/auto-update/check${n?"?force=true":""}`));if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();e({status:a.isUpdateAvailable?"available":"upToDate",current:a.current,latest:a.latest})}catch{e({status:"error"})}}}})),Kr={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},modelSelector:{type:"chord",key:"m",modifiers:["ctrl"]},sessionSearch:{type:"chord",key:"s",modifiers:["ctrl"]},criteriaSidebar:{type:"chord",key:"d",modifiers:["ctrl"]},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function wp(e){if(!e)return structuredClone(Kr);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(Kr[r]):t[r];return{terminalToggle:n("terminalToggle"),quickAction:n("quickAction"),modelSelector:n("modelSelector"),sessionSearch:n("sessionSearch"),criteriaSidebar:n("criteriaSidebar"),agentSwitching:n("agentSwitching")}}catch{return structuredClone(Kr)}}function M_(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Zu(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 ST(e){return e.type==="double-press"}function B1(e){return e.type==="chord"}function wT(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.key.toLowerCase()===t.toLowerCase():t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function $1(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return wT(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===l}function Ql(){const e=Ft(t=>t.settings[Te.KEYBINDINGS]);return wp(e)}function CT(e,t,n){const r=E.useRef(0),a=E.useRef(t);a.current=t,E.useEffect(()=>{if(!e)return;const l=e.threshold??300,u=c=>{if(c.key!==e.key)return;const d=e.key==="Control",h=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!d&&c.ctrlKey||!h&&c.shiftKey||!p&&c.altKey||!m&&c.metaKey)return;const x=Date.now();x-r.current<l?(c.preventDefault(),c.stopPropagation(),a.current(),r.current=0):r.current=x};return window.addEventListener("keydown",u,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",u,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function kT(e,t){const n=E.useRef(t);n.current=t,E.useEffect(()=>{if(!e)return;const r=a=>{$1(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function Pl(e,t,n){CT(e&&ST(e)?e:void 0,t,n),kT(e&&B1(e)?e:void 0,t)}function jT(e,t,n){const r=E.useRef(n);r.current=n,E.useEffect(()=>{const a=l=>{for(let u=0;u<e.length;u++){const c=e[u];if(!c)continue;const d=t[u];if(d&&B1(c)&&$1(l,c)){l.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var pi=l1();const Ad=E.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>i.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Ad.displayName="IconButton";const ET="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",ui=E.forwardRef((e,t)=>i.jsx(Ad,{ref:t,icon:ET,title:"Edit",...e}));ui.displayName="EditButton";const NT="M6 18L18 6M6 6l12 12",hg=E.forwardRef((e,t)=>i.jsx(Ad,{ref:t,icon:NT,...e}));hg.displayName="CloseButton";const TT={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[90vh] flex-1"};function jt({label:e,title:t,headerRight:n,size:r="md",minHeight:a,children:l,footer:u,className:c,onClose:d,isOpen:h,closeOnBackdropClick:p=!0,closeOnEscape:m=!0,showCloseButton:x=!0,scrollable:y=!0}){const[w,C]=E.useState(!1),_=h!==void 0,S=_?h:w,v=E.useCallback(()=>{_||C(!0)},[_]),b=E.useCallback(()=>{_||C(!1),d==null||d()},[_,d]);E.useEffect(()=>{if(!S||!m)return;const N=T=>{if(T.key==="Escape"){const D=document.activeElement;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"))return;T.stopPropagation(),b()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[S,b,m]);const j=e&&(typeof e=="string"?i.jsx("button",{type:"button",onClick:v,className:c,children:e}):i.jsx("span",{onClick:v,className:c,style:{cursor:"pointer"},children:e}));return i.jsxs(i.Fragment,{children:[j,S&&(typeof document<"u"?pi.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p?b:void 0}),i.jsxs("div",{role:"dialog",className:`relative w-full ${TT[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||x)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&i.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),i.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[n,x&&i.jsx(hg,{onClick:b,"aria-label":"Close"})]})]}),i.jsx("div",{className:`p-4 flex-1 min-h-0${y?" overflow-y-auto":" overflow-hidden flex flex-col"}`,style:a?{minHeight:a}:void 0,children:l}),u&&i.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}function AT({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return i.jsxs("div",{className:"relative",children:[i.jsx("select",{value:a,disabled:n,onChange:l=>{const u=l.target.value;r(u===t?null:u)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:MN.map(({url:l,label:u})=>i.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),i.jsx(dn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const P_=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function LT(){const e=Fi(d=>d.settings),t=Fi(d=>d.update),n=Fi(d=>d.updateEvent),r=Fi(d=>d.updateAgentOverride),a=Fi(d=>d.load);E.useEffect(()=>{a()},[a]);const l=async()=>{await BN()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(d,h,p,m)=>{d==="general"?n(h,{[p]:m}):r(d,h,{[p]:m})},c=(d,h,p)=>{d==="general"?n(h,{customSoundUrl:p}):r(d,h,{customSoundUrl:p})};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),i.jsx(B_,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),i.jsx(B_,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:d=>{d&&typeof Notification<"u"&&Notification.permission!=="granted"?l():t({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&i.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),i.jsx("div",{className:"border border-border rounded overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:i.jsxs("tr",{className:"border-b border-border",children:[i.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),P_.map(d=>i.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),i.jsx("tbody",{children:IN.map(d=>i.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[i.jsx("td",{className:"px-3 py-2",children:i.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),P_.map(h=>{const p=C1(e,d.key,h.key==="general"?void 0:h.key),m=S1[d.key];return i.jsx("td",{className:"px-2 py-2 align-top",children:i.jsxs("div",{className:"flex flex-col items-center gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:i.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:x=>u(h.key,d.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),i.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:i.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>u(h.key,d.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&i.jsx(AT,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:x=>c(h.key,d.key,x)})]})},h.key)})]},d.key))})]})})]})]})}function B_({label:e,description:t,checked:n,onChange:r}){return i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),i.jsx("div",{className:"flex-shrink-0 pt-0.5",children:i.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),r(!n)},children:i.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})})]})}const st=E.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},l)=>{const u="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},d={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return i.jsx("button",{ref:l,className:`${u} ${c[e]} ${d[t]} ${n}`,...a,children:r})});st.displayName="Button";async function $_(e,t,n){try{const r=await ye(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}const Nn=Mn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,fetchSkills:async()=>{e({loading:!0});try{const r=await(await ye("/api/skills")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],items:r.items??[],selectedDirectory:r.selectedDirectory??null,diagnostics:r.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await ye(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(l=>({defaults:l.defaults.map(u=>u.id===n?{...u,enabled:a.enabled}:u),userItems:l.userItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),projectItems:l.projectItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),items:l.items.map(u=>u.id===n?{...u,enabled:a.enabled}:u)}))}catch{}},fetchSkill:async n=>{try{const r=await ye(`/api/skills/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ye(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await mi("POST","/api/skills",{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await mi("PUT",`/api/skills/${n}`,r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await ye(`/api/skills/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>Ed(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),r),selectDirectory:async n=>$_("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await ye("/api/skills/library",{method:"DELETE"}),await t().fetchSkills()},installSkill:async n=>{const r=new FormData;r.append("packageName",n.packageName),r.append("paths",JSON.stringify(n.files.map(a=>a.path)));for(const a of n.files)r.append("files",a.file,a.file.name);return $_("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function Jl(){const[e,t]=E.useState({id:null,type:null}),n=E.useCallback(l=>t({id:l,type:"delete"}),[]),r=E.useCallback(()=>t({id:null,type:null}),[]),a=E.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function ed({onConfirm:e,onCancel:t}){return i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),i.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function td({onClick:e}){return i.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:i.jsx(ta,{})})}function Bl({onClick:e}){return i.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:i.jsx(Ml,{})})}function jr({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:l,mono:u}){return i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,l&&i.jsx("span",{className:"text-text-muted ml-1",children:l})]}),i.jsx("input",{value:t,onChange:c=>n(c.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${u?"font-mono":""} ${a?"opacity-60":""}`})]})}function DT({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return i.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[i.jsx(st,{variant:"secondary",onClick:e,children:"Cancel"}),i.jsx(st,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function to({message:e}){return i.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function Ld({value:e,onChange:t}){return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),i.jsxs("select",{value:e,onChange:n=>t(n.target.value),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[i.jsx("option",{value:"user",children:"Global config"}),i.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})}function z1({description:e,onNew:t,loading:n,hasItems:r,children:a}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:e}),i.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:i.jsx(st,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?i.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?a:i.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function H1({label:e="Custom",children:t}){return i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsx("div",{className:"space-y-2",children:t})]})}function U1({description:e,onNew:t,newLabel:n="+ New"}){return i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:e}),i.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:i.jsx(st,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function fg({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?i.jsx("div",{className:"text-text-muted text-sm",children:n}):t?i.jsx("div",{className:"space-y-4",children:a}):r?i.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function F1({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:l="my-item",nameHint:u,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:h,onIdChange:p}){return i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(jr,{label:n,value:e,onChange:h,placeholder:a,hint:u}),i.jsx(jr,{label:r,value:t,onChange:p,readOnly:c,placeholder:l,hint:c?d:void 0,mono:!0})]})}function V1(e={}){const{initialData:t={}}=e,[n,r]=E.useState("list"),[a,l]=E.useState(null),[u,c]=E.useState(""),[d,h]=E.useState(!1),[p,m]=E.useState(t),x=E.useCallback(()=>{m(t),c(""),l(null)},[t]),y=E.useCallback(S=>{r(S),S==="list"&&x()},[x]),w=E.useCallback(S=>{m(v=>typeof S=="function"?S(v):S)},[]),C=E.useCallback((S,v={})=>{l(S),r("edit"),m({...v}),c("")},[]),_=E.useCallback(()=>{l(null),r("edit"),m(t),c("")},[t]);return{view:n,editingId:a,formError:u,saving:d,formData:p,setView:y,setEditingId:l,setFormError:c,setFormData:w,setSaving:h,resetForm:x,startEditing:C,startNew:_}}function $l({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:l="Confirm",confirmVariant:u="primary",disabled:c=!1}){return i.jsx(jt,{isOpen:e,onClose:t,title:r,size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"text-text-secondary",children:a}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(st,{variant:"secondary",onClick:t,disabled:c,children:"Cancel"}),i.jsx(st,{variant:u,onClick:n,disabled:c,autoFocus:!0,children:l})]})]})})}const RT={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function gi({size:e="md",className:t=""}){return i.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${RT[e]} ${t}`})}function OT({text:e,...t}){return i.jsxs("div",{className:"text-center",children:[i.jsx(gi,{...t,className:"mx-auto mb-4"}),e&&i.jsx("div",{className:"text-text-secondary",children:e})]})}function W1(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function IT(e){const t=e.includes("\\")?"\\":"/";return e.split(/[\\/]/).filter(Boolean).map((n,r,a)=>({name:n,path:t==="/"?"/"+a.slice(0,r+1).join("/"):a.slice(0,r+1).join("\\")+(r===0?"\\":"")}))}function G1(e,t=28){if(e.length<=t)return e;const n=e.split("/").filter(Boolean);if(n.length<=2)return e;const r=n[0],a=n[n.length-1],l=n.slice(1,-1).join("/"),u=t-r.length-a.length-3;if(u<0)return e;const c=l.slice(0,Math.floor(u/2)),d=l.slice(-Math.ceil(u/2));return`/${r}/${c}...${d}/${a}`}const di=E.forwardRef(({className:e="",...t},n)=>i.jsx("input",{ref:n,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...t}));di.displayName="Input";function Dd({onSelect:e,onClose:t,initialPath:n}){const[r,a]=E.useState(null),[l,u]=E.useState(!0),[c,d]=E.useState(""),[h,p]=E.useState(-1),m=E.useRef(null),x=E.useRef(null),y=E.useCallback(async b=>{u(!0),d(""),p(-1);try{const j=b?`/api/directories?path=${encodeURIComponent(b)}`:"/api/directories",T=await(await ye(j)).json();a(T)}catch(j){console.error("Failed to load directories:",j)}finally{u(!1)}},[]);E.useEffect(()=>{y(n)},[n,y]);const w=IT((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(b=>c===""||b.name.toLowerCase().includes(c.toLowerCase())))??[],_=[...!c&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(b=>({type:"dir",path:b.path,name:b.name}))];E.useEffect(()=>{p(c?0:-1)},[c,C.length]),E.useEffect(()=>{if(h>=0&&x.current){const b=x.current.querySelector(`[data-index="${h}"]`);b==null||b.scrollIntoView({block:"nearest"})}},[h]);const S=b=>{var j;if(b.key==="ArrowDown")b.preventDefault(),p(N=>Math.min(N+1,_.length-1));else if(b.key==="ArrowUp")b.preventDefault(),p(N=>Math.max(N-1,0));else if(b.key==="Enter"){if(h<0||!_[h]||b.target instanceof HTMLElement&&b.target.dataset.select==="true")return;b.preventDefault(),b.shiftKey?y(_[h].path):e(_[h].path)}else b.key==="Escape"&&(d(""),(j=m.current)==null||j.focus())},v=i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return i.jsx(jt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:v,scrollable:!1,children:i.jsxs("div",{ref:x,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[i.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&i.jsx("div",{className:"px-3 pt-3 pb-1",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((b,j)=>i.jsxs("span",{className:"flex items-center shrink-0",children:[i.jsx("span",{className:"text-text-muted",children:"/"}),i.jsx("button",{onClick:()=>y(b.path),className:`px-1 ${j===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:b.name})]},b.path)),w.length===0&&i.jsx("button",{onClick:()=>y("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&i.jsx("button",{onClick:()=>e(r.current),className:"ml-auto shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90",children:"Select"})]})}),i.jsx("div",{className:"px-4 py-2",children:i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none flex items-center justify-center",children:i.jsx(Qi,{})}),i.jsx(di,{autoFocus:!0,ref:m,value:c,onChange:b=>d(b.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:l?i.jsx("div",{className:"p-8 text-center",children:i.jsx(gi,{size:"sm"})}):_.length===0?i.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:c?"No matching directories":"No subdirectories"}):i.jsx("div",{className:"divide-y divide-border",children:_.map((b,j)=>i.jsxs("div",{"data-index":j,className:`group flex items-center ${j===h?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[i.jsxs("button",{onClick:()=>{y(b.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[b.type==="parent"?i.jsx(aT,{className:"w-5 h-5 text-text-muted shrink-0"}):i.jsx(Nr,{className:"w-5 h-5 shrink-0"}),i.jsx("span",{className:"truncate",children:b.name}),b.type==="dir"&&i.jsx(dn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${j===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),b.type==="dir"&&i.jsx("button",{"data-select":"true",tabIndex:j===h?0:-1,onClick:N=>{N.stopPropagation(),e(b.path)},className:`mr-2 shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90 ${j===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${b.name}`,children:"Select"})]},b.path))})})]})})}function q1(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 MT(e){const t=[...e];if(!t.length)throw new Error("Choose one skill folder.");const n=new Set(t.map(a=>a.webkitRelativePath.split("/")[0]).filter(Boolean));if(n.size!==1)throw new Error("Choose exactly one skill folder.");const r=[...n][0];return q1(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function PT(e){return new Promise((t,n)=>e.file(t,n))}async function K1(e,t=""){const n=e.createReader(),r=[];for(;;){const l=await new Promise((u,c)=>n.readEntries(u,c));if(!l.length)break;r.push(...l)}return(await Promise.all(r.map(async l=>{const u=t?`${t}/${l.name}`:l.name;return l.isDirectory?K1(l,u):[{path:u,file:await PT(l)}]}))).flat()}async function BT(e){const t=[...e.items].filter(r=>r.kind==="file").map(r=>{var a;return((a=r.webkitGetAsEntry)==null?void 0:a.call(r))??null}).filter(r=>!!r);if(t.length!==1||!t[0].isDirectory)throw new Error("Drop exactly one skill folder.");const n=t[0];return q1(n.name,await K1(n))}function $T({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[l,u]=E.useState(!1),[c,d]=E.useState(!1),[h,p]=E.useState(""),[m,x]=E.useState(null),[y,w]=E.useState(!1),C=E.useRef(null);E.useEffect(()=>{var j;(j=C.current)==null||j.setAttribute("webkitdirectory","")},[]);const _=j=>{x(j)},S=async()=>{if(!m||y)return;w(!0);const j=await t(m);if(j&&!j.success){p(j.error??"Cannot use selected folder."),w(!1);return}x(null),u(!1),w(!1)},v=async j=>{d(!0),p("");const N=await a(j);d(!1),N.success||p(N.error??"Failed to install skill package.")},b=async j=>{if(j.preventDefault(),!(!(e!=null&&e.available)||c))try{await v(await BT(j.dataTransfer))}catch(N){p(N instanceof Error?N.message:"Invalid skill folder.")}};return i.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),i.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),i.jsxs("div",{className:"flex shrink-0 gap-2",children:[i.jsx(st,{variant:"secondary",onClick:()=>u(!0),children:"Change folder"}),e&&i.jsxs(i.Fragment,{children:[i.jsx(st,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&i.jsx(st,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),i.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||c,onClick:()=>{var j;return(j=C.current)==null?void 0:j.click()},onDragOver:j=>j.preventDefault(),onDrop:b,className:"mt-3 w-full rounded border border-dashed border-border px-4 py-5 text-center text-xs text-text-secondary disabled:cursor-not-allowed disabled:opacity-50",children:e!=null&&e.available?c?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),i.jsx("input",{ref:C,hidden:!0,type:"file",multiple:!0,onChange:j=>{var N;if((N=j.target.files)!=null&&N.length)try{v(MT(j.target.files))}catch(T){p(T instanceof Error?T.message:"Invalid skill folder.")}finally{j.target.value=""}}}),h&&i.jsx("p",{className:"mt-2 text-xs text-error",children:h}),l&&i.jsx(Dd,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:_,onClose:()=>u(!1)}),i.jsx($l,{isOpen:m!==null,onClose:()=>x(null),onConfirm:S,title:"Trust this folder?",message:"Skills may contain instructions and scripts. Select this folder for discovery without executing package content?",confirmLabel:"Trust folder",disabled:y})]})}function Xr({enabled:e,onClick:t,label:n,disabled:r}){return i.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:r?void 0:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"} ${r?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function Y1({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:l,onCancelDelete:u,actions:c,children:d}){return i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:d}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&i.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:i.jsx(lg,{})}),i.jsx(Bl,{onClick:a}),!e&&r&&i.jsx(ui,{onClick:r}),!e&&l&&(t?i.jsx(ed,{onConfirm:()=>{l==null||l()},onCancel:()=>u==null?void 0:u()}):i.jsx(td,{onClick:()=>l==null?void 0:l()})),c]})]})}function zT({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,actions:p}){return i.jsxs(Y1,{isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,actions:p,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&i.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function z_({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:l,onDelete:u,onToggle:c,readOnly:d=!1}){return i.jsx(zT,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:d?void 0:a,onDuplicate:l,onDelete:d?void 0:u,actions:i.jsx(Xr,{enabled:e.enabled,onClick:c,label:`Activation for ${e.name}`})})}function HT({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return i.jsxs(jt,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(st,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),i.jsx(st,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[i.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),i.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&i.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&i.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function UT({isOpen:e}){const t=Nn(Q=>Q.defaults),n=Nn(Q=>Q.userItems),r=Nn(Q=>Q.projectItems),a=Nn(Q=>Q.items),l=Nn(Q=>Q.selectedDirectory),u=Nn(Q=>Q.diagnostics),c=Nn(Q=>Q.loading),d=Nn(Q=>Q.fetchSkills),h=Nn(Q=>Q.fetchSkill),p=Nn(Q=>Q.fetchDefaultContent),m=Nn(Q=>Q.createSkill),x=Nn(Q=>Q.updateSkill),y=Nn(Q=>Q.deleteSkill),w=Nn(Q=>Q.selectDirectory),C=Nn(Q=>Q.removeDirectory),_=Nn(Q=>Q.installSkill),S=Nn(Q=>Q.toggleSkill),[v,b]=E.useState(null),[j,N]=E.useState(!1),[T,D]=E.useState(""),{view:L,editingId:I,formError:M,saving:G,formData:U,setView:R,setEditingId:H,setFormError:W,setFormData:V,setSaving:ee}=V1(),{clearConfirm:X}=Jl();E.useEffect(()=>{e&&(d(),R("list"),H(null),X())},[e,d,X]);const $=(Q,ae,he,ce)=>{V({name:ce??Q.metadata.name,id:he??Q.metadata.id,description:Q.metadata.description??"",version:Q.metadata.version??"1.0.0",prompt:Q.prompt,isReadOnly:ae,destination:"user"})},O=async Q=>{if(t.some(he=>he.id===Q)){const he=await p(Q);if(!he)return;$(he,!0),H(Q),W(""),R("edit")}else{const he=await h(Q);if(!he)return;$(he,!0),H(Q),W(""),R("edit")}},B=async Q=>{const he=t.some(De=>De.id===Q)?await p(Q):await h(Q);if(!he)return;const ce=`${Q}-copy-${Date.now()}`;$(he,!1,ce,`${he.metadata.name} (copy)`),H(null),W(""),R("edit")},q=()=>{V({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),R("edit")},z=async Q=>{const ae=await h(Q);ae&&($(ae,!1),H(Q),W(""),R("edit"))},re=async()=>{if(!v)return;N(!0),D("");const Q=await y(v.id);if(N(!1),!Q.success){D(Q.error??"Failed to delete skill.");return}await d(),b(null),X()},ne=async()=>{const Q=I??U.id;if(!Q||!U.name||!U.prompt){W("Name, ID, and prompt are required.");return}ee(!0),W("");const ae={metadata:{id:Q,name:U.name,description:U.description,version:U.version},prompt:U.prompt},he=I?await x(I,ae):await m(ae,U.destination);if(ee(!1),!he.success){W(he.error??"Failed to save skill.");return}R("list")},J=Q=>{V(ae=>({...ae,name:Q})),I||V(ae=>({...ae,id:Q.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},K=U.isReadOnly;if(L==="edit")return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-3",children:[i.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:K?U.name:I?"Edit Skill":"New Skill"}),i.jsx("button",{onClick:()=>R("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),M&&i.jsx(to,{message:M}),i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsx(F1,{name:U.name,id:U.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:J,onIdChange:()=>{}}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(jr,{label:"Description",value:U.description,onChange:Q=>V(ae=>({...ae,description:Q})),placeholder:"What this skill does...",readOnly:K}),i.jsx(jr,{label:"Version",value:U.version,onChange:Q=>V(ae=>({...ae,version:Q})),placeholder:"1.0.0",readOnly:K})]})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),i.jsx("textarea",{value:U.prompt,onChange:Q=>V(ae=>({...ae,prompt:Q.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"})]}),!I&&i.jsx(Ld,{value:U.destination,onChange:Q=>V(ae=>({...ae,destination:Q}))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[i.jsx(st,{variant:"secondary",onClick:()=>R("list"),children:"Cancel"}),K?i.jsx(st,{variant:"primary",onClick:()=>{V(Q=>({...Q,name:Q.name+" (copy)",id:`${I}-copy-${Date.now()}`,isReadOnly:!1})),H(null)},children:"Duplicate & Customize"}):i.jsx(st,{variant:"primary",onClick:ne,disabled:G||!U.name||!U.id||!U.prompt,children:G?"Saving...":"Save"})]})]});function P({items:Q}){return Q.map(ae=>i.jsx(z_,{skill:ae,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>O(ae.id),onEdit:()=>z(ae.id),onDuplicate:()=>B(ae.id),onDelete:()=>{D(""),b(ae)},onToggle:()=>S(ae.id),readOnly:ae.readOnly},ae.id))}return i.jsxs("div",{children:[i.jsx(HT,{skill:v,deleting:j,error:T,onClose:()=>{j||b(null)},onConfirm:re}),i.jsx($T,{selectedDirectory:l,onSelect:w,onRemove:C,onRefresh:d,onInstall:_}),u.length>0&&i.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:u.map((Q,ae)=>i.jsx("p",{children:Q},`${Q}-${ae}`))}),i.jsx(U1,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:q}),i.jsxs(fg,{loading:c,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),i.jsx("div",{className:"space-y-2",children:t.map(Q=>i.jsx(z_,{skill:Q,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>O(Q.id),onDuplicate:()=>B(Q.id),onToggle:()=>S(Q.id)},Q.id))})]}),n.length>0&&i.jsx(H1,{children:i.jsx(P,{items:n})}),a.some(Q=>["global-shared","selected","project-shared"].includes(Q.source))&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),i.jsx("div",{className:"space-y-2",children:i.jsx(P,{items:a.filter(Q=>["global-shared","selected","project-shared"].includes(Q.source))})})]}),r.length>0&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),i.jsx("div",{className:"space-y-2",children:i.jsx(P,{items:r})})]})]})]})}function na(){const e=Ft(a=>a.settings),t=Ft(a=>a.loading),n=Ft(a=>a.getSetting),r=Ft(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function FT({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=na(),l=t[Te.GLOBAL_INSTRUCTIONS]??"",u=n[Te.GLOBAL_INSTRUCTIONS]??!1,[c,d]=E.useState(l),[h,p]=E.useState(!1),[m,x]=E.useState(!1);E.useEffect(()=>{e&&r(Te.GLOBAL_INSTRUCTIONS)},[e,r]),E.useEffect(()=>{d(l),p(!1)},[l]);const y=async()=>{x(!0),await a(Te.GLOBAL_INSTRUCTIONS,c),x(!1),p(!1)},w=()=>{d(l),p(!1)},C=u||m;return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),i.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),i.jsx("textarea",{value:c,onChange:_=>{d(_.target.value),p(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(st,{variant:"secondary",onClick:w,disabled:!h,children:"Discard"}),i.jsx(st,{variant:"primary",onClick:y,disabled:!h||C,children:m?"Saving...":"Save"})]})]})}function VT(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),r=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${r} ${a}`}return e}function qu(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 WT({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:l,onClose:u,onSave:c}){const[d,h]=E.useState(l),[p,m]=E.useState(r),[x,y]=E.useState(a);E.useEffect(()=>{h(l),m(r)},[l,r]);const w=(b,j)=>{const N=j.startsWith("#")?VT(j):j;h(T=>({...T,[b]:N}))},C=()=>{c(p.trim()||"Untitled",{...d},x)},_=E1.reduce((b,j)=>{const N=j.category;return b[N]||(b[N]=[]),b[N].push(j),b},{}),S={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},v=zn.find(b=>b.id===n);return i.jsx(jt,{isOpen:e,onClose:u,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:i.jsxs("div",{className:"flex gap-2 justify-end",children:[i.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:C,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),i.jsx("input",{type:"text",value:p,onChange:b=>m(b.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Mode"}),i.jsxs("div",{className:"flex rounded overflow-hidden border border-border",children:[i.jsx("button",{type:"button",onClick:()=>y("dark"),className:`px-3 py-2 text-xs font-medium transition-colors ${x==="dark"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Dark"}),i.jsx("button",{type:"button",onClick:()=>y("light"),className:`px-3 py-2 text-xs font-medium transition-colors ${x==="light"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Light"})]})]})]}),!t&&i.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",i.jsx("span",{className:"text-text-primary",children:v==null?void 0:v.name})]}),Object.entries(_).map(([b,j])=>i.jsxs("div",{className:"space-y-3",children:[i.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:S[b]??b}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:j.map(N=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:N.key,className:"text-xs text-text-muted",children:N.label}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"color",id:N.key,value:qu(d[N.key]??N.defaultValue),onChange:T=>w(N.key,T.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),i.jsx("input",{type:"text",value:d[N.key]??N.defaultValue,onChange:T=>w(N.key,T.target.value),className:"flex-1 min-w-0 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},N.key))})]},b))]})})}function H_({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:l,onDelete:u}){return i.jsxs("div",{className:"relative group",children:[i.jsxs("button",{type:"button",onClick:r,className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${t?"border-accent-primary bg-bg-tertiary text-text-primary":n?"border-dashed border-accent-primary/50 bg-bg-tertiary/50 text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[i.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:e.id==="system"?"transparent":qu(e.tokens["color-bg-primary"]??"#000"),borderColor:qu(e.tokens["color-border"]??"#000")},children:e.id==="system"?i.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):i.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:qu(e.tokens["color-text-primary"]??"#fff")}})}),i.jsx("span",{className:"text-xs",children:e.name})]}),a&&i.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),a()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:i.jsx("span",{className:"text-xs",children:"✎"})}),l&&i.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),l()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:i.jsx("span",{className:"text-xs",children:"✎"})}),u&&i.jsx("button",{type:"button",onClick:c=>u(c),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:i.jsx(Ns,{className:"w-3 h-3"})})]})}function GT(){const[e,t]=E.useState(null),n=Bt(U=>U.currentPreset),r=Bt(U=>U.isCustom),a=Bt(U=>U.basePreset),l=Bt(U=>U.isSystem),u=Bt(U=>U.systemDarkPreset),c=Bt(U=>U.systemLightPreset),d=Bt(U=>U.applyPreset),h=Bt(U=>U.applyUserPreset),p=Bt(U=>U.deleteUserPreset),m=Bt(U=>U.saveTheme),x=Bt(U=>U.setSystemDarkPreset),y=Bt(U=>U.setSystemLightPreset),w=Bt(U=>U.activeUserPresetId),C=Bt(U=>U.userPresets),_=zn.filter(U=>U.mode==="dark"),S=zn.filter(U=>U.mode==="light"),v=U=>{var R;if(l){const H=C[U];if(!H)return;const W=H.mode??((R=zn.find(V=>V.id===H.basePreset))==null?void 0:R.mode);W==="dark"?x(H.id):W==="light"&&y(H.id)}else h(U)},b=U=>{const R=zn.find(H=>H.id===U);R&&t({type:"new",presetIndex:C.length,basePresetId:U,presetName:R.name+" Copy",mode:R.mode??"dark",tokens:{...R.tokens}})},j=U=>{const R=C[U];if(!R)return;const H=zn.find(V=>V.id===R.basePreset),W=H?{...H.tokens,...R.tokens}:R.tokens;t({type:"edit",presetIndex:U,basePresetId:R.basePreset,presetName:R.name,mode:R.mode??"dark",tokens:W})},N=(U,R,H)=>{if(!e)return;const W=[...C];if(e.type==="new"){const V={id:"custom-"+Date.now(),name:U,basePreset:e.basePresetId,mode:H,tokens:R};W.push(V);const ee=W.length-1;Bt.setState({userPresets:W}),Bt.getState().saveUserPresets(),Bt.getState().applyUserPreset(ee)}else{const V=W[e.presetIndex];V&&(W[e.presetIndex]={...V,name:U,mode:H,tokens:R}),Bt.setState({userPresets:W}),Bt.getState().saveUserPresets(),Bt.getState().applyUserPreset(e.presetIndex)}t(null)},T=()=>{t(null)},D=(U,R)=>{U.stopPropagation(),p(R)},L=l?"system":r?a:n,I=()=>{l?(d(n),m(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),m(JSON.stringify({preset:"system"})).catch(()=>{}))},M=U=>{if(l){const R=zn.find(H=>H.id===U);(R==null?void 0:R.mode)==="dark"?x(U):(R==null?void 0:R.mode)==="light"&&y(U)}else d(U),m(JSON.stringify({preset:U})).catch(()=>{})},G=U=>{const R=zn.find(H=>H.id===U.basePreset);return R?{...R.tokens,...U.tokens}:U.tokens};return i.jsxs("div",{className:"space-y-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),i.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[i.jsx("span",{className:"text-sm text-text-primary font-medium",children:"Follow system theme"}),i.jsx("button",{type:"button",onClick:I,className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${l?"bg-accent-primary":"bg-bg-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:U,mode:R})=>{const H=R==="dark"?_:S,W=C.filter(V=>{var X;return(V.mode??((X=zn.find($=>$.id===V.basePreset))==null?void 0:X.mode))===R});return i.jsxs("div",{children:[i.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:U}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[H.map(V=>i.jsx(H_,{preset:V,isActive:V.id===L&&!r,isUnderlying:l&&(V.id===u||V.id===c),onClick:()=>M(V.id),onNewFrom:()=>b(V.id)},V.id)),W.map(V=>{const ee=C.indexOf(V),X=G(V);return i.jsx(H_,{preset:{id:V.id,name:V.name,tokens:X},isActive:w===V.id,isUnderlying:l&&(V.id===u||V.id===c),onClick:()=>v(ee),onEdit:()=>j(ee),onDelete:$=>D($,ee)},V.id)})]})]},U)}),e&&i.jsx(WT,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,mode:e.mode,initialTokens:e.tokens,onClose:T,onSave:N})]})}function qT(){return i.jsx(GT,{})}function KT(){const{settings:e,loading:t,getSetting:n,setSetting:r}=na(),a=t[Te.DISPLAY_SHOW_THINKING]??!1,l=e[Te.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[u,c]=E.useState(l);E.useEffect(()=>{n(Te.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),E.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(Te.DISPLAY_MAX_VISIBLE_ITEMS,String(C))},h=[{key:Te.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Te.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Te.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Te.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Te.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:Te.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews"}],p=Object.fromEntries(h.map(w=>[w.key,e[w.key]??"true"])),[m,x]=E.useState(()=>Object.fromEntries(h.map(w=>[w.key,p[w.key]==="true"])));E.useEffect(()=>{h.forEach(w=>n(w.key))},[n]),E.useEffect(()=>{x(Object.fromEntries(h.map(w=>[w.key,p[w.key]==="true"])))},[JSON.stringify(p)]);const y=async w=>{const C=String(!m[w]);x(_=>({..._,[w]:!_[w]})),await r(w,C)};return a?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):i.jsxs("div",{className:"space-y-6",children:[i.jsx(qT,{}),i.jsxs("div",{className:"border-t border-border pt-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Scrollbar / Custom CSS"}),i.jsx("p",{className:"text-xs text-text-muted mb-3",children:"Scrollbars are quite finicky, so there is no CSS for them in OpenFox. You can add your own below or select one of the options and see if they match your browser needs."}),i.jsx(YT,{})]}),i.jsxs("div",{className:"border-t border-border pt-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),i.jsx("div",{className:"space-y-4",children:h.map(({key:w,label:C,description:_})=>i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary font-medium",children:C}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:_})]}),i.jsx("button",{type:"button",onClick:()=>y(w),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${m[w]?"bg-accent-primary":"bg-bg-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${m[w]?"translate-x-6":"translate-x-1"}`})})]},w))})]}),i.jsx("div",{className:"border-t border-border pt-4",children:i.jsxs("label",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Keep only the last N items in the feed. Set to 0 to show all."})]}),i.jsx("input",{type:"number",min:0,max:9999,value:u,onChange:w=>{const C=w.target.value.replace(/[^0-9]/g,"");c(C)},onBlur:d,onKeyDown:w=>{w.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})})]})}const U_=[{label:"None (browser default)",css:""},{label:"Thin scrollbars",css:["/* Thin scrollbars for Chrome/Safari/Edge */","::-webkit-scrollbar { width: 6px; height: 6px; }","::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.4); border-radius: 3px; }","","/* Thin scrollbars for Firefox */","@-moz-document url-prefix() {"," * { scrollbar-width: thin; }","}"].join(`
|
|
60
|
+
`)},{label:"Stable gutter (prevent layout shift)",css:["/* Reserve scrollbar space so content does not jump when scrollbar appears */",".scrollbar-stable { scrollbar-gutter: stable; }"].join(`
|
|
61
|
+
`)},{label:"Balanced gutter (stable + symmetrical)",css:["/* Reserve space on both sides — keeps content centered */","/* Note: Chrome has a bug where both-edges reserves space but the scrollbar"," may not occupy it properly. Test in your browser. */",".scrollbar-stable { scrollbar-gutter: stable both-edges; }"].join(`
|
|
62
|
+
`)},{label:"Always visible scrollbar",css:["/* Force scrollbar to always show — no layout shift, no surprises */",".scrollbar-stable { overflow-y: scroll; }"].join(`
|
|
63
|
+
`)},{label:"Custom colors",css:["/* Chrome/Safari/Edge */","::-webkit-scrollbar { width: 8px; height: 8px; }","::-webkit-scrollbar-track { background: transparent; }","::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }","::-webkit-scrollbar-thumb:hover { background: #555; }","","/* Firefox */","* { scrollbar-color: #888 transparent; }"].join(`
|
|
64
|
+
`)}];function YT(){const{settings:e,getSetting:t,setSetting:n}=na(),r=e[Te.DISPLAY_CUSTOM_CSS]??"",[a,l]=E.useState(r),[u,c]=E.useState("");E.useEffect(()=>{t(Te.DISPLAY_CUSTOM_CSS)},[t]),E.useEffect(()=>{l(r)},[r]);const d=()=>{n(Te.DISPLAY_CUSTOM_CSS,a)},h=p=>{const m=U_.find(x=>x.label===p.target.value);m&&(c(m.label),l(m.css),n(Te.DISPLAY_CUSTOM_CSS,m.css))};return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("select",{value:u,onChange:h,className:"w-full px-2 py-1.5 text-xs text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",children:[i.jsx("option",{value:"",children:"Try a preset…"}),U_.map(p=>i.jsx("option",{value:p.label,children:p.label},p.label))]}),i.jsx("textarea",{value:a,onChange:p=>l(p.target.value),onBlur:d,placeholder:`/* Paste or edit your custom CSS here */
|
|
65
|
+
/* Example: make Firefox scrollbar thicker */
|
|
66
|
+
@-moz-document url-prefix() {
|
|
67
|
+
* { scrollbar-width: auto; }
|
|
68
|
+
}`,className:"w-full h-32 px-3 py-2 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded resize-y focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})]})}function Cp(){const[e,t]=E.useState("Test"),[n,r]=E.useState(""),[a,l]=E.useState(!1),u=E.useCallback(async c=>{t("Testing..."),r(""),l(!1);try{const d=await c();d.success?(t("Success"),l(!0),setTimeout(()=>{t("Test"),l(!1)},3e3)):(r(d.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,a,u]}function XT(e){try{return new RegExp(e),!0}catch{return!1}}function QT({value:e,onChange:t}){const[n,r]=E.useState({}),a=(d,h)=>{const p=e.patterns.map((m,x)=>x===d?{...m,...h}:m);t({...e,patterns:p})},l=d=>{const h=e.patterns.filter((p,m)=>m!==d);t({...e,patterns:h})},u=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},c=(d,h)=>{r(p=>({...p,[d]:h.length>0&&!XT(h)})),a(d,{pattern:h})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),i.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:d=>{const h=parseInt(d.target.value,10),p=isNaN(h)?10:Math.max(1,Math.min(100,h));t({...e,maxRetriesPerTurn:p})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?i.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[i.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),i.jsx("th",{className:"pb-2 pr-2",children:"Field"}),i.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),i.jsx("th",{className:"pb-2 pr-2",children:"Action"}),i.jsx("th",{className:"pb-2 w-8"})]})}),i.jsx("tbody",{children:e.patterns.map((d,h)=>i.jsxs("tr",{className:"border-b border-border",children:[i.jsx("td",{className:"py-2 pr-2",children:i.jsx("input",{type:"checkbox",checked:d.active,onChange:()=>a(h,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${h+1}`})}),i.jsx("td",{className:"py-2 pr-2",children:i.jsxs("select",{value:d.field,onChange:p=>a(h,{field:p.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[i.jsx("option",{value:"content",children:"content"}),i.jsx("option",{value:"thinking",children:"thinking"}),i.jsx("option",{value:"both",children:"both"})]})}),i.jsx("td",{className:"py-2 pr-2",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"text",value:d.pattern,onChange:p=>c(h,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),d.pattern.length>0&&i.jsx("span",{className:`text-sm ${n[h]?"text-red-500":"text-green-500"}`,children:n[h]?"✗":"✓"})]})}),i.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),i.jsx("td",{className:"py-2",children:i.jsx("button",{onClick:()=>l(h),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},h))})]}),i.jsx(st,{variant:"secondary",onClick:u,children:"Add Pattern"})]})}function X1({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=E.useState("ready"),[l,u]=E.useState(""),[c,d]=E.useState(n),[h,p]=E.useState(null),[m,x]=E.useState(null);E.useEffect(()=>{!e||n||fetch(Es("/api/auto-update/check")).then(S=>S.json()).then(S=>{d({current:S.current,latest:S.latest})}).catch(()=>{})},[e]),E.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const S=setInterval(()=>{u(v=>v.length>=3?"":v+".")},400);return()=>clearInterval(S)},[e,r]);const y=E.useCallback(async()=>{a("updating"),x(null);try{const v=await(await ye("/api/auto-update",{method:"POST"})).json();if(v.success){const b=v.version??"unknown";p(b),localStorage.setItem("openfox_updated_to",b),localStorage.setItem("update_pending","true"),v.isService?(a("restarting"),await ye("/api/auto-update/restart",{method:"POST"}).catch(()=>{}),setTimeout(()=>window.location.reload(),5e3)):a("complete")}else x(v.error??"Update failed"),a("failed")}catch(S){x(S instanceof Error?S.message:"Update request failed"),a("failed")}},[]);E.useEffect(()=>{e&&(a("ready"),u(""),p(null),x(null))},[e]);const w=r!=="updating"&&r!=="restarting",C=S=>S,_=r==="failed"?"Update Failed":r==="complete"||r==="restarting"?"Update Complete":"New OpenFox version available";return i.jsxs(jt,{isOpen:e,onClose:w?t:void 0,title:_,size:"md",closeOnBackdropClick:w,showCloseButton:w,children:[i.jsxs("div",{className:"flex flex-col gap-4",children:[c&&i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-text-muted",children:"Current version"}),i.jsx("span",{className:"text-text-primary font-mono",children:C(c.current)})]}),c&&i.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[i.jsx("span",{className:"text-text-muted",children:"Latest version"}),i.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:c.latest})]}),(r==="updating"||r==="restarting")&&i.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[i.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),i.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",l]})]}),r==="complete"&&i.jsx("div",{className:"flex flex-col gap-3 mt-2",children:i.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h??(c==null?void 0:c.latest),"."," Please restart OpenFox to use the new version."]})}),r==="failed"&&i.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[i.jsx("span",{children:"⚠️"}),i.jsx("p",{className:"text-text-secondary",children:m})]}),i.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),i.jsx("p",{className:"text-xs text-text-muted",children:"Run this command in your terminal to complete the update."})]})]}),r==="ready"&&i.jsx("button",{onClick:y,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="complete"||r==="failed")&&i.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"})]})}function JT(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ZT=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eA=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tA={};function F_(e,t){return(tA.jsx?eA:ZT).test(e)}const nA=/[ \t\n\f\r]/g;function rA(e){return typeof e=="object"?e.type==="text"?V_(e.value):!1:V_(e)}function V_(e){return e.replace(nA,"")===""}let Zl=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Zl.prototype.normal={};Zl.prototype.property={};Zl.prototype.space=void 0;function Q1(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Zl(n,r,t)}function kp(e){return e.toLowerCase()}let Zn=class{constructor(t,n){this.attribute=n,this.property=t}};Zn.prototype.attribute="";Zn.prototype.booleanish=!1;Zn.prototype.boolean=!1;Zn.prototype.commaOrSpaceSeparated=!1;Zn.prototype.commaSeparated=!1;Zn.prototype.defined=!1;Zn.prototype.mustUseProperty=!1;Zn.prototype.number=!1;Zn.prototype.overloadedBoolean=!1;Zn.prototype.property="";Zn.prototype.spaceSeparated=!1;Zn.prototype.space=void 0;let sA=0;const pt=ra(),cn=ra(),jp=ra(),Pe=ra(),Ht=ra(),no=ra(),cr=ra();function ra(){return 2**++sA}const Ep=Object.freeze(Object.defineProperty({__proto__:null,boolean:pt,booleanish:cn,commaOrSpaceSeparated:cr,commaSeparated:no,number:Pe,overloadedBoolean:jp,spaceSeparated:Ht},Symbol.toStringTag,{value:"Module"})),Em=Object.keys(Ep);let mg=class extends Zn{constructor(t,n,r,a){let l=-1;if(super(t,n),W_(this,"space",a),typeof r=="number")for(;++l<Em.length;){const u=Em[l];W_(this,Em[l],(r&Ep[u])===Ep[u])}}};mg.prototype.defined=!0;function W_(e,t,n){n&&(e[t]=n)}function mo(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new mg(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[kp(r)]=r,n[kp(l.attribute)]=r}return new Zl(t,n,e.space)}const J1=mo({properties:{ariaActiveDescendant:null,ariaAtomic:cn,ariaAutoComplete:null,ariaBusy:cn,ariaChecked:cn,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:Ht,ariaCurrent:null,ariaDescribedBy:Ht,ariaDetails:null,ariaDisabled:cn,ariaDropEffect:Ht,ariaErrorMessage:null,ariaExpanded:cn,ariaFlowTo:Ht,ariaGrabbed:cn,ariaHasPopup:null,ariaHidden:cn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ht,ariaLevel:Pe,ariaLive:null,ariaModal:cn,ariaMultiLine:cn,ariaMultiSelectable:cn,ariaOrientation:null,ariaOwns:Ht,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:cn,ariaReadOnly:cn,ariaRelevant:null,ariaRequired:cn,ariaRoleDescription:Ht,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:cn,ariaSetSize:Pe,ariaSort:null,ariaValueMax:Pe,ariaValueMin:Pe,ariaValueNow:Pe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Z1(e,t){return t in e?e[t]:t}function ew(e,t){return Z1(e,t.toLowerCase())}const iA=mo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:no,acceptCharset:Ht,accessKey:Ht,action:null,allow:null,allowFullScreen:pt,allowPaymentRequest:pt,allowUserMedia:pt,alt:null,as:null,async:pt,autoCapitalize:null,autoComplete:Ht,autoFocus:pt,autoPlay:pt,blocking:Ht,capture:null,charSet:null,checked:pt,cite:null,className:Ht,cols:Pe,colSpan:null,content:null,contentEditable:cn,controls:pt,controlsList:Ht,coords:Pe|no,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pt,defer:pt,dir:null,dirName:null,disabled:pt,download:jp,draggable:cn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pt,formTarget:null,headers:Ht,height:Pe,hidden:jp,high:Pe,href:null,hrefLang:null,htmlFor:Ht,httpEquiv:Ht,id:null,imageSizes:null,imageSrcSet:null,inert:pt,inputMode:null,integrity:null,is:null,isMap:pt,itemId:null,itemProp:Ht,itemRef:Ht,itemScope:pt,itemType:Ht,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pt,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:pt,muted:pt,name:null,nonce:null,noModule:pt,noValidate:pt,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:pt,optimum:Pe,pattern:null,ping:Ht,placeholder:null,playsInline:pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pt,referrerPolicy:null,rel:Ht,required:pt,reversed:pt,rows:Pe,rowSpan:Pe,sandbox:Ht,scope:null,scoped:pt,seamless:pt,selected:pt,shadowRootClonable:pt,shadowRootDelegatesFocus:pt,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:cn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Pe,step:null,style:null,tabIndex:Pe,target:null,title:null,translate:null,type:null,typeMustMatch:pt,useMap:null,value:cn,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ht,axis:null,background:null,bgColor:null,border:Pe,borderColor:null,bottomMargin:Pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:pt,declare:pt,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:pt,noHref:pt,noShade:pt,noWrap:pt,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:cn,standby:null,summary:null,text:null,topMargin:Pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:pt,disableRemotePlayback:pt,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:ew}),aA=mo({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:cr,accentHeight:Pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Pe,amplitude:Pe,arabicForm:null,ascent:Pe,attributeName:null,attributeType:null,azimuth:Pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Pe,by:null,calcMode:null,capHeight:Pe,className:Ht,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Pe,diffuseConstant:Pe,direction:null,display:null,dur:null,divisor:Pe,dominantBaseline:null,download:pt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Pe,enableBackground:null,end:null,event:null,exponent:Pe,externalResourcesRequired:null,fill:null,fillOpacity:Pe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:no,g2:no,glyphName:no,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Pe,horizOriginX:Pe,horizOriginY:Pe,id:null,ideographic:Pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Pe,k:Pe,k1:Pe,k2:Pe,k3:Pe,k4:Pe,kernelMatrix:cr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Pe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Pe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Pe,overlineThickness:Pe,paintOrder:null,panose1:null,path:null,pathLength:Pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ht,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:cr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:cr,rev:cr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:cr,requiredFeatures:cr,requiredFonts:cr,requiredFormats:cr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Pe,specularExponent:Pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Pe,strikethroughThickness:Pe,string:null,stroke:null,strokeDashArray:cr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Pe,strokeOpacity:Pe,strokeWidth:null,style:null,surfaceScale:Pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:cr,tabIndex:Pe,tableValues:null,target:null,targetX:Pe,targetY:Pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:cr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Pe,underlineThickness:Pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Pe,values:null,vAlphabetic:Pe,vMathematical:Pe,vectorEffect:null,vHanging:Pe,vIdeographic:Pe,version:null,vertAdvY:Pe,vertOriginX:Pe,vertOriginY:Pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Z1}),tw=mo({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()}}),nw=mo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ew}),rw=mo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),oA={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"},lA=/[A-Z]/g,G_=/-[a-z]/g,cA=/^data[-\w.:]+$/i;function uA(e,t){const n=kp(t);let r=t,a=Zn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&cA.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(G_,hA);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!G_.test(l)){let u=l.replace(lA,dA);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=mg}return new a(r,t)}function dA(e){return"-"+e.toLowerCase()}function hA(e){return e.charAt(1).toUpperCase()}const fA=Q1([J1,iA,tw,nw,rw],"html"),pg=Q1([J1,aA,tw,nw,rw],"svg");function mA(e){return e.join(" ").trim()}var Ua={},Nm,q_;function pA(){if(q_)return Nm;q_=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
69
|
+
`,h="/",p="*",m="",x="comment",y="declaration";function w(_,S){if(typeof _!="string")throw new TypeError("First argument must be a string");if(!_)return[];S=S||{};var v=1,b=1;function j(H){var W=H.match(t);W&&(v+=W.length);var V=H.lastIndexOf(d);b=~V?H.length-V:b+H.length}function N(){var H={line:v,column:b};return function(W){return W.position=new T(H),I(),W}}function T(H){this.start=H,this.end={line:v,column:b},this.source=S.source}T.prototype.content=_;function D(H){var W=new Error(S.source+":"+v+":"+b+": "+H);if(W.reason=H,W.filename=S.source,W.line=v,W.column=b,W.source=_,!S.silent)throw W}function L(H){var W=H.exec(_);if(W){var V=W[0];return j(V),_=_.slice(V.length),W}}function I(){L(n)}function M(H){var W;for(H=H||[];W=G();)W!==!1&&H.push(W);return H}function G(){var H=N();if(!(h!=_.charAt(0)||p!=_.charAt(1))){for(var W=2;m!=_.charAt(W)&&(p!=_.charAt(W)||h!=_.charAt(W+1));)++W;if(W+=2,m===_.charAt(W-1))return D("End of comment missing");var V=_.slice(2,W-2);return b+=2,j(V),_=_.slice(W),b+=2,H({type:x,comment:V})}}function U(){var H=N(),W=L(r);if(W){if(G(),!L(a))return D("property missing ':'");var V=L(l),ee=H({type:y,property:C(W[0].replace(e,m)),value:V?C(V[0].replace(e,m)):m});return L(u),ee}}function R(){var H=[];M(H);for(var W;W=U();)W!==!1&&(H.push(W),M(H));return H}return I(),R()}function C(_){return _?_.replace(c,m):m}return Nm=w,Nm}var K_;function gA(){if(K_)return Ua;K_=1;var e=Ua&&Ua.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ua,"__esModule",{value:!0}),Ua.default=n;const t=e(pA());function n(r,a){let l=null;if(!r||typeof r!="string")return l;const u=(0,t.default)(r),c=typeof a=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:p}=d;c?a(h,p,d):p&&(l=l||{},l[h]=p)}),l}return Ua}var ml={},Y_;function xA(){if(Y_)return ml;Y_=1,Object.defineProperty(ml,"__esModule",{value:!0}),ml.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},u=function(h,p){return p.toUpperCase()},c=function(h,p){return"".concat(p,"-")},d=function(h,p){return p===void 0&&(p={}),l(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(a,c):h=h.replace(r,c),h.replace(t,u))};return ml.camelCase=d,ml}var pl,X_;function yA(){if(X_)return pl;X_=1;var e=pl&&pl.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(gA()),n=xA();function r(a,l){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(u[(0,n.camelCase)(c,l)]=d)}),u}return r.default=r,pl=r,pl}var bA=yA();const vA=Cd(bA),sw=iw("end"),gg=iw("start");function iw(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 _A(e){const t=gg(e),n=sw(e);if(t&&n)return{start:t,end:n}}function Tl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Q_(e.position):"start"in e||"end"in e?Q_(e):"line"in e||"column"in e?Np(e):""}function Np(e){return J_(e&&e.line)+":"+J_(e&&e.column)}function Q_(e){return Np(e&&e.start)+"-"+Np(e&&e.end)}function J_(e){return e&&typeof e=="number"?e:1}class Pn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",l={},u=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?a=t:!l.cause&&t&&(u=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?l.ruleId=r:(l.source=r.slice(0,d),l.ruleId=r.slice(d+1))}if(!l.place&&l.ancestors&&l.ancestors){const d=l.ancestors[l.ancestors.length-1];d&&(l.place=d.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Tl(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}}Pn.prototype.file="";Pn.prototype.name="";Pn.prototype.reason="";Pn.prototype.message="";Pn.prototype.stack="";Pn.prototype.column=void 0;Pn.prototype.line=void 0;Pn.prototype.ancestors=void 0;Pn.prototype.cause=void 0;Pn.prototype.fatal=void 0;Pn.prototype.place=void 0;Pn.prototype.ruleId=void 0;Pn.prototype.source=void 0;const xg={}.hasOwnProperty,SA=new Map,wA=/[A-Z]/g,CA=new Set(["table","tbody","thead","tfoot","tr"]),kA=new Set(["td","th"]),aw="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function jA(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=OA(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=RA(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?pg:fA,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=ow(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function ow(e,t,n){if(t.type==="element")return EA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return NA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return AA(e,t,n);if(t.type==="mdxjsEsm")return TA(e,t);if(t.type==="root")return LA(e,t,n);if(t.type==="text")return DA(e,t)}function EA(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=pg,e.schema=a),e.ancestors.push(t);const l=cw(e,t.tagName,!1),u=IA(e,t);let c=bg(e,t);return CA.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!rA(d):!0})),lw(e,u,l,t),yg(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function NA(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)}zl(e,t.position)}function TA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);zl(e,t.position)}function AA(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=pg,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:cw(e,t.name,!0),u=MA(e,t),c=bg(e,t);return lw(e,u,l,t),yg(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function LA(e,t,n){const r={};return yg(r,bg(e,t)),e.create(t,e.Fragment,r,n)}function DA(e,t){return t.value}function lw(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function yg(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function RA(e,t,n){return r;function r(a,l,u,c){const h=Array.isArray(u.children)?n:t;return c?h(l,u,c):h(l,u)}}function OA(e,t){return n;function n(r,a,l,u){const c=Array.isArray(l.children),d=gg(r);return t(a,l,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function IA(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&xg.call(t.properties,a)){const l=PA(e,a,t.properties[a]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&kA.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 MA(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 zl(e,t.position);else{const a=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else zl(e,t.position);else l=r.value===null?!0:r.value;n[a]=l}return n}function bg(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:SA;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 h=a.get(d)||0;u=d+"-"+h,a.set(d,h+1)}}const c=ow(e,l,u);c!==void 0&&n.push(c)}return n}function PA(e,t,n){const r=uA(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?JT(n):mA(n)),r.property==="style"){let a=typeof n=="object"?n:BA(e,String(n));return e.stylePropertyNameCase==="css"&&(a=$A(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?oA[r.property]||r.property:r.attribute,n]}}function BA(e,t){try{return vA(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new Pn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=aw+"#cannot-parse-style-attribute",a}}function cw(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,u;for(;++l<a.length;){const c=F_(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};u=u?{type:"MemberExpression",object:u,property:c,computed:!!(l&&c.type==="Literal"),optional:!1}:c}r=u}else r=F_(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return xg.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);zl(e)}function zl(e,t){const n=new Pn("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=aw+"#cannot-handle-mdx-estrees-without-createevaluater",n}function $A(e){const t={};let n;for(n in e)xg.call(e,n)&&(t[zA(n)]=e[n]);return t}function zA(e){let t=e.replace(wA,HA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function HA(e){return"-"+e.toLowerCase()}const Tm={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"]},UA={};function vg(e,t){const n=UA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return uw(e,r,a)}function uw(e,t,n){if(FA(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 Z_(e.children,t,n)}return Array.isArray(e)?Z_(e,t,n):""}function Z_(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=uw(e[a],t,n);return r.join("")}function FA(e){return!!(e&&typeof e=="object")}const e0=document.createElement("i");function _g(e){const t="&"+e+";";e0.innerHTML=t;const n=e0.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dr(e,t,n,r){const a=e.length;let l=0,u;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)u=Array.from(r),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<r.length;)u=r.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function wr(e,t){return e.length>0?(dr(e,e.length,0,t),e):t}const t0={}.hasOwnProperty;function dw(e){const t={};let n=-1;for(;++n<e.length;)VA(t,e[n]);return t}function VA(e,t){let n;for(n in t){const a=(t0.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){t0.call(a,u)||(a[u]=[]);const c=l[u];WA(a[u],Array.isArray(c)?c:c?[c]:[])}}}function WA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dr(e,0,0,r)}function hw(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 Pr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Un=xi(/[A-Za-z]/),In=xi(/[\dA-Za-z]/),GA=xi(/[#-'*+\--9=?A-Z^-~]/);function nd(e){return e!==null&&(e<32||e===127)}const Tp=xi(/\d/),qA=xi(/[\dA-Fa-f]/),KA=xi(/[!-/:-@[-`{-~]/);function rt(e){return e!==null&&e<-2}function zt(e){return e!==null&&(e<0||e===32)}function _t(e){return e===-2||e===-1||e===32}const Rd=xi(new RegExp("\\p{P}|\\p{S}","u")),Ji=xi(/\s/);function xi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function po(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&In(e.charCodeAt(n+1))&&In(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const c=e.charCodeAt(n+1);l<56320&&c>56319&&c<57344?(u=String.fromCharCode(l,c),a=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(r,n),encodeURIComponent(u)),r=n+a+1,u=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Et(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(d){return _t(d)?(e.enter(n),c(d)):t(d)}function c(d){return _t(d)&&l++<a?(e.consume(d),c):(e.exit(n),t(d))}}const YA={tokenize:XA};function XA(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Et(e,t,"linePrefix")}function a(c){return e.enter("paragraph"),l(c)}function l(c){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,u(c)}function u(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return rt(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const QA={tokenize:JA},n0={tokenize:ZA};function JA(e){const t=this,n=[];let r=0,a,l,u;return c;function c(b){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,d,h)(b)}return h(b)}function d(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&v();const j=t.events.length;let N=j,T;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){T=t.events[N][1].end;break}S(r);let D=j;for(;D<t.events.length;)t.events[D][1].end={...T},D++;return dr(t.events,N+1,0,t.events.slice(j)),t.events.length=D,h(b)}return c(b)}function h(b){if(r===n.length){if(!a)return x(b);if(a.currentConstruct&&a.currentConstruct.concrete)return w(b);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(n0,p,m)(b)}function p(b){return a&&v(),S(r),x(b)}function m(b){return t.parser.lazy[t.now().line]=r!==n.length,u=t.now().offset,w(b)}function x(b){return t.containerState={},e.attempt(n0,y,w)(b)}function y(b){return r++,n.push([t.currentConstruct,t.containerState]),x(b)}function w(b){if(b===null){a&&v(),S(0),e.consume(b);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),C(b)}function C(b){if(b===null){_(e.exit("chunkFlow"),!0),S(0),e.consume(b);return}return rt(b)?(e.consume(b),_(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(b),C)}function _(b,j){const N=t.sliceStream(b);if(j&&N.push(null),b.previous=l,l&&(l.next=b),l=b,a.defineSkip(b.start),a.write(N),t.parser.lazy[b.start.line]){let T=a.events.length;for(;T--;)if(a.events[T][1].start.offset<u&&(!a.events[T][1].end||a.events[T][1].end.offset>u))return;const D=t.events.length;let L=D,I,M;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(I){M=t.events[L][1].end;break}I=!0}for(S(r),T=D;T<t.events.length;)t.events[T][1].end={...M},T++;dr(t.events,L+1,0,t.events.slice(D)),t.events.length=T}}function S(b){let j=n.length;for(;j-- >b;){const N=n[j];t.containerState=N[1],N[0].exit.call(t,e)}n.length=b}function v(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function ZA(e,t,n){return Et(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function oo(e){if(e===null||zt(e)||Ji(e))return 1;if(Rd(e))return 2}function Od(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const Ap={name:"attention",resolveAll:eL,tokenize:tL};function eL(e,t){let n=-1,r,a,l,u,c,d,h,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;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};r0(m,-d),r0(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...e[r][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},l={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[r][1].end={...u.start},e[n][1].start={...c.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=wr(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=wr(h,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",l,t]]),h=wr(h,Od(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=wr(h,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,h=wr(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,dr(e,r-1,n-r+3,h),n=r+h.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function tL(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=oo(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 h=e.exit("attentionSequence"),p=oo(d),m=!p||p===2&&a||n.includes(d),x=!a||a===2&&p||n.includes(r);return h._open=!!(l===42?m:m&&(a||!x)),h._close=!!(l===42?x:x&&(p||!m)),t(d)}}function r0(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const nL={name:"autolink",tokenize:rL};function rL(e,t,n){let r=0;return a;function a(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return Un(y)?(e.consume(y),u):y===64?n(y):h(y)}function u(y){return y===43||y===45||y===46||In(y)?(r=1,c(y)):h(y)}function c(y){return y===58?(e.consume(y),r=0,d):(y===43||y===45||y===46||In(y))&&r++<32?(e.consume(y),c):(r=0,h(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||nd(y)?n(y):(e.consume(y),d)}function h(y){return y===64?(e.consume(y),p):GA(y)?(e.consume(y),h):n(y)}function p(y){return In(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||In(y))&&r++<63){const w=y===45?x:m;return e.consume(y),w}return n(y)}}const ec={partial:!0,tokenize:sL};function sL(e,t,n){return r;function r(l){return _t(l)?Et(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||rt(l)?t(l):n(l)}}const fw={continuation:{tokenize:aL},exit:oL,name:"blockQuote",tokenize:iL};function iL(e,t,n){const r=this;return a;function a(u){if(u===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return n(u)}function l(u){return _t(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function aL(e,t,n){const r=this;return a;function a(u){return _t(u)?Et(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(fw,t,n)(u)}}function oL(e){e.exit("blockQuote")}const mw={name:"characterEscape",tokenize:lL};function lL(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return KA(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const pw={name:"characterReference",tokenize:cL};function cL(e,t,n){const r=this;let a=0,l,u;return c;function c(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),d}function d(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),l=31,u=In,p(m))}function h(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=qA,p):(e.enter("characterReferenceValue"),l=7,u=Tp,p(m))}function p(m){if(m===59&&a){const x=e.exit("characterReferenceValue");return u===In&&!_g(r.sliceSerialize(x))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(m)&&a++<l?(e.consume(m),p):n(m)}}const s0={partial:!0,tokenize:dL},i0={concrete:!0,name:"codeFenced",tokenize:uL};function uL(e,t,n){const r=this,a={partial:!0,tokenize:N};let l=0,u=0,c;return d;function d(T){return h(T)}function h(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"),_t(T)?Et(e,m,"whitespace")(T):m(T))}function m(T){return T===null||rt(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(s0,C,j)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(T))}function x(T){return T===null||rt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(T)):_t(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Et(e,y,"whitespace")(T)):T===96&&T===c?n(T):(e.consume(T),x)}function y(T){return T===null||rt(T)?m(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||rt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(T)):T===96&&T===c?n(T):(e.consume(T),w)}function C(T){return e.attempt(a,j,_)(T)}function _(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),S}function S(T){return l>0&&_t(T)?Et(e,v,"linePrefix",l+1)(T):v(T)}function v(T){return T===null||rt(T)?e.check(s0,C,j)(T):(e.enter("codeFlowValue"),b(T))}function b(T){return T===null||rt(T)?(e.exit("codeFlowValue"),v(T)):(e.consume(T),b)}function j(T){return e.exit("codeFenced"),t(T)}function N(T,D,L){let I=0;return M;function M(W){return T.enter("lineEnding"),T.consume(W),T.exit("lineEnding"),G}function G(W){return T.enter("codeFencedFence"),_t(W)?Et(T,U,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):U(W)}function U(W){return W===c?(T.enter("codeFencedFenceSequence"),R(W)):L(W)}function R(W){return W===c?(I++,T.consume(W),R):I>=u?(T.exit("codeFencedFenceSequence"),_t(W)?Et(T,H,"whitespace")(W):H(W)):L(W)}function H(W){return W===null||rt(W)?(T.exit("codeFencedFence"),D(W)):L(W)}}}function dL(e,t,n){const r=this;return a;function a(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}const Am={name:"codeIndented",tokenize:fL},hL={partial:!0,tokenize:mL};function fL(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),Et(e,l,"linePrefix",5)(h)}function l(h){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(h):n(h)}function u(h){return h===null?d(h):rt(h)?e.attempt(hL,u,d)(h):(e.enter("codeFlowValue"),c(h))}function c(h){return h===null||rt(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),c)}function d(h){return e.exit("codeIndented"),t(h)}}function mL(e,t,n){const r=this;return a;function a(u){return r.parser.lazy[r.now().line]?n(u):rt(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):Et(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):rt(u)?a(u):n(u)}}const pL={name:"codeText",previous:xL,resolve:gL,tokenize:yL};function gL(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function xL(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function yL(e,t,n){let r=0,a,l;return u;function u(m){return e.enter("codeText"),e.enter("codeTextSequence"),c(m)}function c(m){return m===96?(e.consume(m),r++,c):(e.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),d):m===96?(l=e.enter("codeTextSequence"),a=0,p(m)):rt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(m))}function h(m){return m===null||m===32||m===96||rt(m)?(e.exit("codeTextData"),d(m)):(e.consume(m),h)}function p(m){return m===96?(e.consume(m),a++,p):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",h(m))}}class bL{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&gl(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),gl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),gl(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);gl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);gl(this.left,n.reverse())}}}function gl(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 gw(e){const t={};let n=-1,r,a,l,u,c,d,h;const p=new bL(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,vL(p,n)),n=t[n],h=!0);else if(r[1]._container){for(l=n,a=void 0;l--;)if(u=p.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(p.get(a)[1].type="lineEndingBlank"),u[1].type="lineEnding",a=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;a&&(r[1].end={...p.get(a)[1].start},c=p.slice(a,n),c.unshift(r),p.splice(a,n-a+1,c))}}return dr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function vL(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const l=[];let u=n._tokenizer;u||(u=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const c=u.events,d=[],h={};let p,m,x=-1,y=n,w=0,C=0;const _=[C];for(;y;){for(;e.get(++a)[1]!==y;);l.push(a),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),m&&u.defineSkip(y.start),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(p),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),m=y,y=y.next}for(y=n;++x<c.length;)c[x][0]==="exit"&&c[x-1][0]==="enter"&&c[x][1].type===c[x-1][1].type&&c[x][1].start.line!==c[x][1].end.line&&(C=x+1,_.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(u.events=[],y?(y._tokenizer=void 0,y.previous=void 0):_.pop(),x=_.length;x--;){const S=c.slice(_[x],_[x+1]),v=l.pop();d.push([v,v+S.length-1]),e.splice(v,2,S)}for(d.reverse(),x=-1;++x<d.length;)h[w+d[x][0]]=w+d[x][1],w+=d[x][1]-d[x][0]-1;return h}const _L={resolve:wL,tokenize:CL},SL={partial:!0,tokenize:kL};function wL(e){return gw(e),e}function CL(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?l(c):rt(c)?e.check(SL,u,l)(c):(e.consume(c),a)}function l(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function u(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function kL(e,t,n){const r=this;return a;function a(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Et(e,l,"linePrefix")}function l(u){if(u===null||rt(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 xw(e,t,n,r,a,l,u,c,d){const h=d||Number.POSITIVE_INFINITY;let p=0;return m;function m(S){return S===60?(e.enter(r),e.enter(a),e.enter(l),e.consume(S),e.exit(l),x):S===null||S===32||S===41||nd(S)?n(S):(e.enter(r),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(S))}function x(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(a),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),y(S))}function y(S){return S===62?(e.exit("chunkString"),e.exit(c),x(S)):S===null||S===60||rt(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||zt(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(r),t(S)):p<h&&S===40?(e.consume(S),p++,C):S===41?(e.consume(S),p--,C):S===null||S===32||S===40||nd(S)?n(S):(e.consume(S),S===92?_:C)}function _(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function yw(e,t,n,r,a,l){const u=this;let c=0,d;return h;function h(y){return e.enter(r),e.enter(a),e.consume(y),e.exit(a),e.enter(l),p}function p(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?n(y):y===93?(e.exit(l),e.enter(a),e.consume(y),e.exit(a),e.exit(r),t):rt(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||rt(y)||c++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!_t(y)),y===92?x:m)}function x(y){return y===91||y===92||y===93?(e.consume(y),c++,m):m(y)}}function bw(e,t,n,r,a,l){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(r),e.enter(a),e.consume(x),e.exit(a),u=x===40?41:x,d):n(x)}function d(x){return x===u?(e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):(e.enter(l),h(x))}function h(x){return x===u?(e.exit(l),d(u)):x===null?n(x):rt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Et(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===u||x===null||rt(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?m:p)}function m(x){return x===u||x===92?(e.consume(x),p):p(x)}}function Al(e,t){let n;return r;function r(a){return rt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):_t(a)?Et(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const jL={name:"definition",tokenize:NL},EL={partial:!0,tokenize:TL};function NL(e,t,n){const r=this;let a;return l;function l(y){return e.enter("definition"),u(y)}function u(y){return yw.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=Pr(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 zt(y)?Al(e,h)(y):h(y)}function h(y){return xw(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(EL,m,m)(y)}function m(y){return _t(y)?Et(e,x,"whitespace")(y):x(y)}function x(y){return y===null||rt(y)?(e.exit("definition"),r.parser.defined.push(a),t(y)):n(y)}}function TL(e,t,n){return r;function r(c){return zt(c)?Al(e,a)(c):n(c)}function a(c){return bw(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return _t(c)?Et(e,u,"whitespace")(c):u(c)}function u(c){return c===null||rt(c)?t(c):n(c)}}const AL={name:"hardBreakEscape",tokenize:LL};function LL(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return rt(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const DL={name:"headingAtx",resolve:RL,tokenize:OL};function RL(e,t){let n=e.length-2,r=3,a,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},dr(e,r,n-r+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function OL(e,t,n){let r=0;return a;function a(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),u(p)}function u(p){return p===35&&r++<6?(e.consume(p),u):p===null||zt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||rt(p)?(e.exit("atxHeading"),t(p)):_t(p)?Et(e,c,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),c(p))}function h(p){return p===null||p===35||zt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),h)}}const IL=["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"],a0=["pre","script","style","textarea"],ML={concrete:!0,name:"htmlFlow",resolveTo:$L,tokenize:zL},PL={partial:!0,tokenize:UL},BL={partial:!0,tokenize:HL};function $L(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 zL(e,t,n){const r=this;let a,l,u,c,d;return h;function h(z){return p(z)}function p(z){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(z),m}function m(z){return z===33?(e.consume(z),x):z===47?(e.consume(z),l=!0,C):z===63?(e.consume(z),a=3,r.interrupt?t:O):Un(z)?(e.consume(z),u=String.fromCharCode(z),_):n(z)}function x(z){return z===45?(e.consume(z),a=2,y):z===91?(e.consume(z),a=5,c=0,w):Un(z)?(e.consume(z),a=4,r.interrupt?t:O):n(z)}function y(z){return z===45?(e.consume(z),r.interrupt?t:O):n(z)}function w(z){const re="CDATA[";return z===re.charCodeAt(c++)?(e.consume(z),c===re.length?r.interrupt?t:U:w):n(z)}function C(z){return Un(z)?(e.consume(z),u=String.fromCharCode(z),_):n(z)}function _(z){if(z===null||z===47||z===62||zt(z)){const re=z===47,ne=u.toLowerCase();return!re&&!l&&a0.includes(ne)?(a=1,r.interrupt?t(z):U(z)):IL.includes(u.toLowerCase())?(a=6,re?(e.consume(z),S):r.interrupt?t(z):U(z)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(z):l?v(z):b(z))}return z===45||In(z)?(e.consume(z),u+=String.fromCharCode(z),_):n(z)}function S(z){return z===62?(e.consume(z),r.interrupt?t:U):n(z)}function v(z){return _t(z)?(e.consume(z),v):M(z)}function b(z){return z===47?(e.consume(z),M):z===58||z===95||Un(z)?(e.consume(z),j):_t(z)?(e.consume(z),b):M(z)}function j(z){return z===45||z===46||z===58||z===95||In(z)?(e.consume(z),j):N(z)}function N(z){return z===61?(e.consume(z),T):_t(z)?(e.consume(z),N):b(z)}function T(z){return z===null||z===60||z===61||z===62||z===96?n(z):z===34||z===39?(e.consume(z),d=z,D):_t(z)?(e.consume(z),T):L(z)}function D(z){return z===d?(e.consume(z),d=null,I):z===null||rt(z)?n(z):(e.consume(z),D)}function L(z){return z===null||z===34||z===39||z===47||z===60||z===61||z===62||z===96||zt(z)?N(z):(e.consume(z),L)}function I(z){return z===47||z===62||_t(z)?b(z):n(z)}function M(z){return z===62?(e.consume(z),G):n(z)}function G(z){return z===null||rt(z)?U(z):_t(z)?(e.consume(z),G):n(z)}function U(z){return z===45&&a===2?(e.consume(z),V):z===60&&a===1?(e.consume(z),ee):z===62&&a===4?(e.consume(z),B):z===63&&a===3?(e.consume(z),O):z===93&&a===5?(e.consume(z),$):rt(z)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(PL,q,R)(z)):z===null||rt(z)?(e.exit("htmlFlowData"),R(z)):(e.consume(z),U)}function R(z){return e.check(BL,H,q)(z)}function H(z){return e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),W}function W(z){return z===null||rt(z)?R(z):(e.enter("htmlFlowData"),U(z))}function V(z){return z===45?(e.consume(z),O):U(z)}function ee(z){return z===47?(e.consume(z),u="",X):U(z)}function X(z){if(z===62){const re=u.toLowerCase();return a0.includes(re)?(e.consume(z),B):U(z)}return Un(z)&&u.length<8?(e.consume(z),u+=String.fromCharCode(z),X):U(z)}function $(z){return z===93?(e.consume(z),O):U(z)}function O(z){return z===62?(e.consume(z),B):z===45&&a===2?(e.consume(z),O):U(z)}function B(z){return z===null||rt(z)?(e.exit("htmlFlowData"),q(z)):(e.consume(z),B)}function q(z){return e.exit("htmlFlow"),t(z)}}function HL(e,t,n){const r=this;return a;function a(u){return rt(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 UL(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(ec,t,n)}}const FL={name:"htmlText",tokenize:VL};function VL(e,t,n){const r=this;let a,l,u;return c;function c(O){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(O),d}function d(O){return O===33?(e.consume(O),h):O===47?(e.consume(O),N):O===63?(e.consume(O),b):Un(O)?(e.consume(O),L):n(O)}function h(O){return O===45?(e.consume(O),p):O===91?(e.consume(O),l=0,w):Un(O)?(e.consume(O),v):n(O)}function p(O){return O===45?(e.consume(O),y):n(O)}function m(O){return O===null?n(O):O===45?(e.consume(O),x):rt(O)?(u=m,ee(O)):(e.consume(O),m)}function x(O){return O===45?(e.consume(O),y):m(O)}function y(O){return O===62?V(O):O===45?x(O):m(O)}function w(O){const B="CDATA[";return O===B.charCodeAt(l++)?(e.consume(O),l===B.length?C:w):n(O)}function C(O){return O===null?n(O):O===93?(e.consume(O),_):rt(O)?(u=C,ee(O)):(e.consume(O),C)}function _(O){return O===93?(e.consume(O),S):C(O)}function S(O){return O===62?V(O):O===93?(e.consume(O),S):C(O)}function v(O){return O===null||O===62?V(O):rt(O)?(u=v,ee(O)):(e.consume(O),v)}function b(O){return O===null?n(O):O===63?(e.consume(O),j):rt(O)?(u=b,ee(O)):(e.consume(O),b)}function j(O){return O===62?V(O):b(O)}function N(O){return Un(O)?(e.consume(O),T):n(O)}function T(O){return O===45||In(O)?(e.consume(O),T):D(O)}function D(O){return rt(O)?(u=D,ee(O)):_t(O)?(e.consume(O),D):V(O)}function L(O){return O===45||In(O)?(e.consume(O),L):O===47||O===62||zt(O)?I(O):n(O)}function I(O){return O===47?(e.consume(O),V):O===58||O===95||Un(O)?(e.consume(O),M):rt(O)?(u=I,ee(O)):_t(O)?(e.consume(O),I):V(O)}function M(O){return O===45||O===46||O===58||O===95||In(O)?(e.consume(O),M):G(O)}function G(O){return O===61?(e.consume(O),U):rt(O)?(u=G,ee(O)):_t(O)?(e.consume(O),G):I(O)}function U(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),a=O,R):rt(O)?(u=U,ee(O)):_t(O)?(e.consume(O),U):(e.consume(O),H)}function R(O){return O===a?(e.consume(O),a=void 0,W):O===null?n(O):rt(O)?(u=R,ee(O)):(e.consume(O),R)}function H(O){return O===null||O===34||O===39||O===60||O===61||O===96?n(O):O===47||O===62||zt(O)?I(O):(e.consume(O),H)}function W(O){return O===47||O===62||zt(O)?I(O):n(O)}function V(O){return O===62?(e.consume(O),e.exit("htmlTextData"),e.exit("htmlText"),t):n(O)}function ee(O){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),X}function X(O){return _t(O)?Et(e,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):$(O)}function $(O){return e.enter("htmlTextData"),u(O)}}const Sg={name:"labelEnd",resolveAll:KL,resolveTo:YL,tokenize:XL},WL={tokenize:QL},GL={tokenize:JL},qL={tokenize:ZL};function KL(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&dr(e,0,e.length,n),e}function YL(e,t){let n=e.length,r=0,a,l,u,c;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(u=n);const d={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},h={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",h,t]],c=wr(c,e.slice(l+1,l+r+3)),c=wr(c,[["enter",p,t]]),c=wr(c,Od(t.parser.constructs.insideSpan.null,e.slice(l+r+4,u-3),t)),c=wr(c,[["exit",p,t],e[u-2],e[u-1],["exit",h,t]]),c=wr(c,e.slice(u+1)),c=wr(c,[["exit",d,t]]),dr(e,l,e.length,c),e}function XL(e,t,n){const r=this;let a=r.events.length,l,u;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){l=r.events[a][1];break}return c;function c(x){return l?l._inactive?m(x):(u=r.parser.defined.includes(Pr(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(WL,p,u?p:m)(x):x===91?e.attempt(GL,p,u?h:m)(x):u?p(x):m(x)}function h(x){return e.attempt(qL,p,m)(x)}function p(x){return t(x)}function m(x){return l._balanced=!0,n(x)}}function QL(e,t,n){return r;function r(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return zt(m)?Al(e,l)(m):l(m)}function l(m){return m===41?p(m):xw(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return zt(m)?Al(e,d)(m):p(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?bw(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function h(m){return zt(m)?Al(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 JL(e,t,n){const r=this;return a;function a(c){return yw.call(r,e,l,u,"reference","referenceMarker","referenceString")(c)}function l(c){return r.parser.defined.includes(Pr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function u(c){return n(c)}}function ZL(e,t,n){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const eD={name:"labelStartImage",resolveAll:Sg.resolveAll,tokenize:tD};function tD(e,t,n){const r=this;return a;function a(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),l}function l(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),u):n(c)}function u(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const nD={name:"labelStartLink",resolveAll:Sg.resolveAll,tokenize:rD};function rD(e,t,n){const r=this;return a;function a(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const Lm={name:"lineEnding",tokenize:sD};function sD(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Et(e,t,"linePrefix")}}const Ku={name:"thematicBreak",tokenize:iD};function iD(e,t,n){let r=0,a;return l;function l(h){return e.enter("thematicBreak"),u(h)}function u(h){return a=h,c(h)}function c(h){return h===a?(e.enter("thematicBreakSequence"),d(h)):r>=3&&(h===null||rt(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===a?(e.consume(h),r++,d):(e.exit("thematicBreakSequence"),_t(h)?Et(e,c,"whitespace")(h):c(h))}}const Qn={continuation:{tokenize:cD},exit:dD,name:"list",tokenize:lD},aD={partial:!0,tokenize:hD},oD={partial:!0,tokenize:uD};function lD(e,t,n){const r=this,a=r.events[r.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return c;function c(y){const w=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:Tp(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(Ku,n,h)(y):h(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return Tp(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"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(ec,r.interrupt?n:p,e.attempt(aD,x,m))}function p(y){return r.containerState.initialBlankLine=!0,l++,x(y)}function m(y){return _t(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 cD(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ec,a,l);function a(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Et(e,t,"listItemIndent",r.containerState.size+1)(c)}function l(c){return r.containerState.furtherBlankLines||!_t(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(oD,t,u)(c))}function u(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,Et(e,e.attempt(Qn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function uD(e,t,n){const r=this;return Et(e,a,"listItemIndent",r.containerState.size+1);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===r.containerState.size?t(l):n(l)}}function dD(e){e.exit(this.containerState.type)}function hD(e,t,n){const r=this;return Et(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const u=r.events[r.events.length-1];return!_t(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const o0={name:"setextUnderline",resolveTo:fD,tokenize:mD};function fD(e,t){let n=e.length,r,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",u,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=u,e.push(["exit",u,t]),e}function mD(e,t,n){const r=this;let a;return l;function l(h){let p=r.events.length,m;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){m=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||m)?(e.enter("setextHeadingLine"),a=h,u(h)):n(h)}function u(h){return e.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===a?(e.consume(h),c):(e.exit("setextHeadingLineSequence"),_t(h)?Et(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||rt(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const pD={tokenize:gD};function gD(e){const t=this,n=e.attempt(ec,r,e.attempt(this.parser.constructs.flowInitial,a,Et(e,e.attempt(this.parser.constructs.flow,a,e.attempt(_L,a)),"linePrefix")));return n;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const xD={resolveAll:_w()},yD=vw("string"),bD=vw("text");function vw(e){return{resolveAll:_w(e==="text"?vD:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],l=n.attempt(a,u,c);return u;function u(p){return h(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 h(p)?(n.exit("data"),l(p)):(n.consume(p),d)}function h(p){if(p===null)return!0;const m=a[p];let x=-1;if(m)for(;++x<m.length;){const y=m[x];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function _w(e){return t;function t(n,r){let a=-1,l;for(;++a<=n.length;)l===void 0?n[a]&&n[a][1].type==="data"&&(l=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==l+2&&(n[l][1].end=n[a-1][1].end,n.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(n,r):n}}function vD(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let l=a.length,u=-1,c=0,d;for(;l--;){const h=a[l];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)c++,u--;if(u)break;u=-1}else if(h===-2)d=!0,c++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const h={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={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const _D={42:Qn,43:Qn,45:Qn,48:Qn,49:Qn,50:Qn,51:Qn,52:Qn,53:Qn,54:Qn,55:Qn,56:Qn,57:Qn,62:fw},SD={91:jL},wD={[-2]:Am,[-1]:Am,32:Am},CD={35:DL,42:Ku,45:[o0,Ku],60:ML,61:o0,95:Ku,96:i0,126:i0},kD={38:pw,92:mw},jD={[-5]:Lm,[-4]:Lm,[-3]:Lm,33:eD,38:pw,42:Ap,60:[nL,FL],91:nD,92:[AL,mw],93:Sg,95:Ap,96:pL},ED={null:[Ap,xD]},ND={null:[42,95]},TD={null:[]},AD=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ND,contentInitial:SD,disable:TD,document:_D,flow:CD,flowInitial:wD,insideSpan:ED,string:kD,text:jD},Symbol.toStringTag,{value:"Module"}));function LD(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let u=[],c=[];const d={attempt:D(N),check:D(T),consume:v,enter:b,exit:j,interrupt:D(T,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:m};let p=t.tokenize.call(h,d);return t.resolveAll&&l.push(t),h;function m(G){return u=wr(u,G),_(),u[u.length-1]!==null?[]:(L(t,0),h.events=Od(l,h.events,h),h.events)}function x(G,U){return RD(y(G),U)}function y(G){return DD(u,G)}function w(){const{_bufferIndex:G,_index:U,line:R,column:H,offset:W}=r;return{_bufferIndex:G,_index:U,line:R,column:H,offset:W}}function C(G){a[G.line]=G.column,M()}function _(){let G;for(;r._index<u.length;){const U=u[r._index];if(typeof U=="string")for(G=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===G&&r._bufferIndex<U.length;)S(U.charCodeAt(r._bufferIndex));else S(U)}}function S(G){p=p(G)}function v(G){rt(G)?(r.line++,r.column=1,r.offset+=G===-3?2:1,M()):G!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===u[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=G}function b(G,U){const R=U||{};return R.type=G,R.start=w(),h.events.push(["enter",R,h]),c.push(R),R}function j(G){const U=c.pop();return U.end=w(),h.events.push(["exit",U,h]),U}function N(G,U){L(G,U.from)}function T(G,U){U.restore()}function D(G,U){return R;function R(H,W,V){let ee,X,$,O;return Array.isArray(H)?q(H):"tokenize"in H?q([H]):B(H);function B(J){return K;function K(P){const Q=P!==null&&J[P],ae=P!==null&&J.null,he=[...Array.isArray(Q)?Q:Q?[Q]:[],...Array.isArray(ae)?ae:ae?[ae]:[]];return q(he)(P)}}function q(J){return ee=J,X=0,J.length===0?V:z(J[X])}function z(J){return K;function K(P){return O=I(),$=J,J.partial||(h.currentConstruct=J),J.name&&h.parser.constructs.disable.null.includes(J.name)?ne():J.tokenize.call(U?Object.assign(Object.create(h),U):h,d,re,ne)(P)}}function re(J){return G($,O),W}function ne(J){return O.restore(),++X<ee.length?z(ee[X]):V}}}function L(G,U){G.resolveAll&&!l.includes(G)&&l.push(G),G.resolve&&dr(h.events,U,h.events.length-U,G.resolve(h.events.slice(U),h)),G.resolveTo&&(h.events=G.resolveTo(h.events,h))}function I(){const G=w(),U=h.previous,R=h.currentConstruct,H=h.events.length,W=Array.from(c);return{from:H,restore:V};function V(){r=G,h.previous=U,h.currentConstruct=R,h.events.length=H,c=W,M()}}function M(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function DD(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let u;if(n===a)u=[e[n].slice(r,l)];else{if(u=e.slice(n,a),r>-1){const c=u[0];typeof c=="string"?u[0]=c.slice(r):u.shift()}l>0&&u.push(e[a].slice(0,l))}return u}function RD(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const l=e[n];let u;if(typeof l=="string")u=l;else switch(l){case-5:{u="\r";break}case-4:{u=`
|
|
70
|
+
`;break}case-3:{u=`\r
|
|
71
|
+
`;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&a)continue;u=" ";break}default:u=String.fromCharCode(l)}a=l===-2,r.push(u)}return r.join("")}function OD(e){const r={constructs:dw([AD,...(e||{}).extensions||[]]),content:a(YA),defined:[],document:a(QA),flow:a(pD),lazy:{},string:a(yD),text:a(bD)};return r;function a(l){return u;function u(c){return LD(r,l,c)}}}function ID(e){for(;!gw(e););return e}const l0=/[\0\t\n\r]/g;function MD(){let e=1,t="",n=!0,r;return a;function a(l,u,c){const d=[];let h,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(l0.lastIndex=m,h=l0.exec(l),x=h&&h.index!==void 0?h.index:l.length,y=l.charCodeAt(x),!h){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 PD=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function BD(e){return e.replace(PD,$D)}function $D(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return hw(n.slice(l?2:1),l?16:10)}return _g(n)||e}const Sw={}.hasOwnProperty;function zD(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),HD(n)(ID(OD(n).document().write(MD()(e,t,!0))))}function HD(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(at),autolinkProtocol:I,autolinkEmail:I,atxHeading:l($e),blockQuote:l(ae),characterEscape:I,characterReference:I,codeFenced:l(he),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(he,u),codeText:l(ce,u),codeTextData:I,data:I,codeFlowValue:I,definition:l(De),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(Re),hardBreakEscape:l(Ge),hardBreakTrailing:l(Ge),htmlFlow:l(je,u),htmlFlowData:I,htmlText:l(je,u),htmlTextData:I,image:l(Ye),label:u,link:l(at),listItem:l(ze),listItemValue:x,listOrdered:l(ke,m),listUnordered:l(ke),paragraph:l(lt),reference:z,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l($e),strong:l(we),thematicBreak:l(Ve)},exit:{atxHeading:d(),atxHeadingSequence:N,autolink:d(),autolinkEmail:Q,autolinkProtocol:P,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:J,characterReference:K,codeFenced:d(_),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:M,codeIndented:d(S),codeText:d(W),codeTextData:M,data:M,definition:d(),definitionDestinationString:j,definitionLabelString:v,definitionTitleString:b,emphasis:d(),hardBreakEscape:d(U),hardBreakTrailing:d(U),htmlFlow:d(R),htmlFlowData:M,htmlText:d(H),htmlTextData:M,image:d(ee),label:$,labelText:X,lineEnding:G,link:d(V),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:re,resourceDestinationString:O,resourceTitleString:B,resource:q,setextHeading:d(L),setextHeadingLineSequence:D,setextHeadingText:T,strong:d(),thematicBreak:d()}};ww(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(Z){let oe={type:"root",children:[]};const ie={stack:[oe],tokenStack:[],config:t,enter:c,exit:h,buffer:u,resume:p,data:n},me=[];let Ue=-1;for(;++Ue<Z.length;)if(Z[Ue][1].type==="listOrdered"||Z[Ue][1].type==="listUnordered")if(Z[Ue][0]==="enter")me.push(Ue);else{const Ie=me.pop();Ue=a(Z,Ie,Ue)}for(Ue=-1;++Ue<Z.length;){const Ie=t[Z[Ue][0]];Sw.call(Ie,Z[Ue][1].type)&&Ie[Z[Ue][1].type].call(Object.assign({sliceSerialize:Z[Ue][2].sliceSerialize},ie),Z[Ue][1])}if(ie.tokenStack.length>0){const Ie=ie.tokenStack[ie.tokenStack.length-1];(Ie[1]||c0).call(ie,void 0,Ie[0])}for(oe.position={start:ti(Z.length>0?Z[0][1].start:{line:1,column:1,offset:0}),end:ti(Z.length>0?Z[Z.length-2][1].end:{line:1,column:1,offset:0})},Ue=-1;++Ue<t.transforms.length;)oe=t.transforms[Ue](oe)||oe;return oe}function a(Z,oe,ie){let me=oe-1,Ue=-1,Ie=!1,Ke,ct,et,tt;for(;++me<=ie;){const ot=Z[me];switch(ot[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ot[0]==="enter"?Ue++:Ue--,tt=void 0;break}case"lineEndingBlank":{ot[0]==="enter"&&(Ke&&!tt&&!Ue&&!et&&(et=me),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!Ue&&ot[0]==="enter"&&ot[1].type==="listItemPrefix"||Ue===-1&&ot[0]==="exit"&&(ot[1].type==="listUnordered"||ot[1].type==="listOrdered")){if(Ke){let Ct=me;for(ct=void 0;Ct--;){const dt=Z[Ct];if(dt[1].type==="lineEnding"||dt[1].type==="lineEndingBlank"){if(dt[0]==="exit")continue;ct&&(Z[ct][1].type="lineEndingBlank",Ie=!0),dt[1].type="lineEnding",ct=Ct}else if(!(dt[1].type==="linePrefix"||dt[1].type==="blockQuotePrefix"||dt[1].type==="blockQuotePrefixWhitespace"||dt[1].type==="blockQuoteMarker"||dt[1].type==="listItemIndent"))break}et&&(!ct||et<ct)&&(Ke._spread=!0),Ke.end=Object.assign({},ct?Z[ct][1].start:ot[1].end),Z.splice(ct||me,0,["exit",Ke,ot[2]]),me++,ie++}if(ot[1].type==="listItemPrefix"){const Ct={type:"listItem",_spread:!1,start:Object.assign({},ot[1].start),end:void 0};Ke=Ct,Z.splice(me,0,["enter",Ct,ot[2]]),me++,ie++,et=void 0,tt=!0}}}return Z[oe][1]._spread=Ie,ie}function l(Z,oe){return ie;function ie(me){c.call(this,Z(me),me),oe&&oe.call(this,me)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(Z,oe,ie){this.stack[this.stack.length-1].children.push(Z),this.stack.push(Z),this.tokenStack.push([oe,ie||void 0]),Z.position={start:ti(oe.start),end:void 0}}function d(Z){return oe;function oe(ie){Z&&Z.call(this,ie),h.call(this,ie)}}function h(Z,oe){const ie=this.stack.pop(),me=this.tokenStack.pop();if(me)me[0].type!==Z.type&&(oe?oe.call(this,Z,me[0]):(me[1]||c0).call(this,Z,me[0]));else throw new Error("Cannot close `"+Z.type+"` ("+Tl({start:Z.start,end:Z.end})+"): it’s not open");ie.position.end=ti(Z.end)}function p(){return vg(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function x(Z){if(this.data.expectingFirstListItemValue){const oe=this.stack[this.stack.length-2];oe.start=Number.parseInt(this.sliceSerialize(Z),10),this.data.expectingFirstListItemValue=void 0}}function y(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.lang=Z}function w(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.meta=Z}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.value=Z.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.value=Z.replace(/(\r?\n|\r)$/g,"")}function v(Z){const oe=this.resume(),ie=this.stack[this.stack.length-1];ie.label=oe,ie.identifier=Pr(this.sliceSerialize(Z)).toLowerCase()}function b(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.title=Z}function j(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.url=Z}function N(Z){const oe=this.stack[this.stack.length-1];if(!oe.depth){const ie=this.sliceSerialize(Z).length;oe.depth=ie}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function D(Z){const oe=this.stack[this.stack.length-1];oe.depth=this.sliceSerialize(Z).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function I(Z){const ie=this.stack[this.stack.length-1].children;let me=ie[ie.length-1];(!me||me.type!=="text")&&(me=He(),me.position={start:ti(Z.start),end:void 0},ie.push(me)),this.stack.push(me)}function M(Z){const oe=this.stack.pop();oe.value+=this.sliceSerialize(Z),oe.position.end=ti(Z.end)}function G(Z){const oe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ie=oe.children[oe.children.length-1];ie.position.end=ti(Z.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(oe.type)&&(I.call(this,Z),M.call(this,Z))}function U(){this.data.atHardBreak=!0}function R(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.value=Z}function H(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.value=Z}function W(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.value=Z}function V(){const Z=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";Z.type+="Reference",Z.referenceType=oe,delete Z.url,delete Z.title}else delete Z.identifier,delete Z.label;this.data.referenceType=void 0}function ee(){const Z=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";Z.type+="Reference",Z.referenceType=oe,delete Z.url,delete Z.title}else delete Z.identifier,delete Z.label;this.data.referenceType=void 0}function X(Z){const oe=this.sliceSerialize(Z),ie=this.stack[this.stack.length-2];ie.label=BD(oe),ie.identifier=Pr(oe).toLowerCase()}function $(){const Z=this.stack[this.stack.length-1],oe=this.resume(),ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,ie.type==="link"){const me=Z.children;ie.children=me}else ie.alt=oe}function O(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.url=Z}function B(){const Z=this.resume(),oe=this.stack[this.stack.length-1];oe.title=Z}function q(){this.data.inReference=void 0}function z(){this.data.referenceType="collapsed"}function re(Z){const oe=this.resume(),ie=this.stack[this.stack.length-1];ie.label=oe,ie.identifier=Pr(this.sliceSerialize(Z)).toLowerCase(),this.data.referenceType="full"}function ne(Z){this.data.characterReferenceType=Z.type}function J(Z){const oe=this.sliceSerialize(Z),ie=this.data.characterReferenceType;let me;ie?(me=hw(oe,ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):me=_g(oe);const Ue=this.stack[this.stack.length-1];Ue.value+=me}function K(Z){const oe=this.stack.pop();oe.position.end=ti(Z.end)}function P(Z){M.call(this,Z);const oe=this.stack[this.stack.length-1];oe.url=this.sliceSerialize(Z)}function Q(Z){M.call(this,Z);const oe=this.stack[this.stack.length-1];oe.url="mailto:"+this.sliceSerialize(Z)}function ae(){return{type:"blockquote",children:[]}}function he(){return{type:"code",lang:null,meta:null,value:""}}function ce(){return{type:"inlineCode",value:""}}function De(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Re(){return{type:"emphasis",children:[]}}function $e(){return{type:"heading",depth:0,children:[]}}function Ge(){return{type:"break"}}function je(){return{type:"html",value:""}}function Ye(){return{type:"image",title:null,url:"",alt:null}}function at(){return{type:"link",title:null,url:"",children:[]}}function ke(Z){return{type:"list",ordered:Z.type==="listOrdered",start:null,spread:Z._spread,children:[]}}function ze(Z){return{type:"listItem",spread:Z._spread,checked:null,children:[]}}function lt(){return{type:"paragraph",children:[]}}function we(){return{type:"strong",children:[]}}function He(){return{type:"text",value:""}}function Ve(){return{type:"thematicBreak"}}}function ti(e){return{line:e.line,column:e.column,offset:e.offset}}function ww(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ww(e,r):UD(e,r)}}function UD(e,t){let n;for(n in t)if(Sw.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 c0(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Tl({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Tl({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Tl({start:t.start,end:t.end})+") is still open")}function FD(e){const t=this;t.parser=n;function n(r){return zD(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function VD(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 WD(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
72
|
+
`}]}function GD(e,t){const n=t.value?t.value+`
|
|
73
|
+
`:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let l={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function qD(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function KD(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function YD(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=po(r.toLowerCase()),l=e.footnoteOrder.indexOf(r);let u,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),u=e.footnoteOrder.length):u=l+1,c+=1,e.footnoteCounts.set(r,c);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function XD(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 QD(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Cw(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),l=a[0];l&&l.type==="text"?l.value="["+l.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=r:a.push({type:"text",value:r}),a}function JD(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Cw(e,t);const a={src:po(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,l),e.applyData(t,l)}function ZD(e,t){const n={src:po(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 e3(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 t3(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Cw(e,t);const a={href:po(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function n3(e,t){const n={href:po(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 r3(e,t,n){const r=e.all(t),a=n?s3(n):kw(t),l={},u=[];if(typeof t.checked=="boolean"){const p=r[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},r.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const p=r[c];(a||c!==0||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
|
|
74
|
+
`}),p.type==="element"&&p.tagName==="p"&&!a?u.push(...p.children):u.push(p)}const d=r[r.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&u.push({type:"text",value:`
|
|
75
|
+
`});const h={type:"element",tagName:"li",properties:l,children:u};return e.patch(t,h),e.applyData(t,h)}function s3(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=kw(n[r])}return t}function kw(e){const t=e.spread;return t??e.children.length>1}function i3(e,t){const n={},r=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<r.length;){const u=r[a];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,l),e.applyData(t,l)}function a3(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function o3(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function l3(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function c3(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],u),a.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=gg(t.children[1]),d=sw(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),a.push(u)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,l),e.applyData(t,l)}function u3(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 h=[];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)),h.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,p),e.applyData(t,p)}function d3(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const u0=9,d0=32;function h3(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const l=[];for(;r;)l.push(h0(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return l.push(h0(t.slice(a),a>0,!1)),l.join("")}function h0(e,t,n){let r=0,a=e.length;if(t){let l=e.codePointAt(r);for(;l===u0||l===d0;)r++,l=e.codePointAt(r)}if(n){let l=e.codePointAt(a-1);for(;l===u0||l===d0;)a--,l=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function f3(e,t){const n={type:"text",value:h3(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function m3(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const p3={blockquote:VD,break:WD,code:GD,delete:qD,emphasis:KD,footnoteReference:YD,heading:XD,html:QD,imageReference:JD,image:ZD,inlineCode:e3,linkReference:t3,link:n3,listItem:r3,list:i3,paragraph:a3,root:o3,strong:l3,table:c3,tableCell:d3,tableRow:u3,text:f3,thematicBreak:m3,toml:wu,yaml:wu,definition:wu,footnoteDefinition:wu};function wu(){}const jw=-1,Id=0,Ll=1,rd=2,wg=3,Cg=4,kg=5,jg=6,Ew=7,Nw=8,f0=typeof self=="object"?self:globalThis,g3=(e,t)=>{const n=(a,l)=>(e.set(l,a),a),r=a=>{if(e.has(a))return e.get(a);const[l,u]=t[a];switch(l){case Id:case jw:return n(u,a);case Ll:{const c=n([],a);for(const d of u)c.push(r(d));return c}case rd:{const c=n({},a);for(const[d,h]of u)c[r(d)]=r(h);return c}case wg:return n(new Date(u),a);case Cg:{const{source:c,flags:d}=u;return n(new RegExp(c,d),a)}case kg:{const c=n(new Map,a);for(const[d,h]of u)c.set(r(d),r(h));return c}case jg:{const c=n(new Set,a);for(const d of u)c.add(r(d));return c}case Ew:{const{name:c,message:d}=u;return n(new f0[c](d),a)}case Nw:return n(BigInt(u),a);case"BigInt":return n(Object(BigInt(u)),a);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return n(new DataView(c),u)}}return n(new f0[l](u),a)};return r},m0=e=>g3(new Map,e)(0),Fa="",{toString:x3}={},{keys:y3}=Object,xl=e=>{const t=typeof e;if(t!=="object"||!e)return[Id,t];const n=x3.call(e).slice(8,-1);switch(n){case"Array":return[Ll,Fa];case"Object":return[rd,Fa];case"Date":return[wg,Fa];case"RegExp":return[Cg,Fa];case"Map":return[kg,Fa];case"Set":return[jg,Fa];case"DataView":return[Ll,n]}return n.includes("Array")?[Ll,n]:n.includes("Error")?[Ew,n]:[rd,n]},Cu=([e,t])=>e===Id&&(t==="function"||t==="symbol"),b3=(e,t,n,r)=>{const a=(u,c)=>{const d=r.push(u)-1;return n.set(c,d),d},l=u=>{if(n.has(u))return n.get(u);let[c,d]=xl(u);switch(c){case Id:{let p=u;switch(d){case"bigint":c=Nw,p=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return a([jw],u)}return a([c,p],u)}case Ll:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),a([d,[...x]],u)}const p=[],m=a([c,p],u);for(const x of u)p.push(l(x));return m}case rd:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return l(u.toJSON());const p=[],m=a([c,p],u);for(const x of y3(u))(e||!Cu(xl(u[x])))&&p.push([l(x),l(u[x])]);return m}case wg:return a([c,u.toISOString()],u);case Cg:{const{source:p,flags:m}=u;return a([c,{source:p,flags:m}],u)}case kg:{const p=[],m=a([c,p],u);for(const[x,y]of u)(e||!(Cu(xl(x))||Cu(xl(y))))&&p.push([l(x),l(y)]);return m}case jg:{const p=[],m=a([c,p],u);for(const x of u)(e||!Cu(xl(x)))&&p.push(l(x));return m}}const{message:h}=u;return a([c,{name:d,message:h}],u)};return l},p0=(e,{json:t,lossy:n}={})=>{const r=[];return b3(!(t||n),!!t,new Map,r)(e),r},sd=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?m0(p0(e,t)):structuredClone(e):(e,t)=>m0(p0(e,t));function v3(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 _3(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function S3(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||v3,r=e.options.footnoteBackLabel||_3,a=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[d]);if(!h)continue;const p=e.all(h),m=String(h.identifier).toUpperCase(),x=po(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 v=typeof n=="string"?n:n(d,y);typeof v=="string"&&(v={type:"text",value:v}),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(v)?v:[v]})}const _=p[p.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const v=_.children[_.children.length-1];v&&v.type==="text"?v.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...w)}else p.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(p,!0)};e.patch(h,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...sd(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
|
|
76
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
77
|
+
`}]}}const Md=(function(e){if(e==null)return j3;if(typeof e=="function")return Pd(e);if(typeof e=="object")return Array.isArray(e)?w3(e):C3(e);if(typeof e=="string")return k3(e);throw new Error("Expected function, string, or object as test")});function w3(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Md(e[n]);return Pd(r);function r(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function C3(e){const t=e;return Pd(n);function n(r){const a=r;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function k3(e){return Pd(t);function t(n){return n&&n.type===e}}function Pd(e){return t;function t(n,r,a){return!!(E3(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function j3(){return!0}function E3(e){return e!==null&&typeof e=="object"&&"type"in e}const Tw=[],N3=!0,Lp=!1,T3="skip";function Aw(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const l=Md(a),u=r?-1:1;c(e,void 0,[])();function c(d,h,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=Tw,w,C,_;if((!t||l(d,h,p[p.length-1]||void 0))&&(y=A3(n(d,p)),y[0]===Lp))return y;if("children"in d&&d.children){const S=d;if(S.children&&y[0]!==T3)for(C=(r?S.children.length:-1)+u,_=p.concat(S);C>-1&&C<S.children.length;){const v=S.children[C];if(w=c(v,C,_)(),w[0]===Lp)return w;C=typeof w[1]=="number"?w[1]:C+u}}return y}}}function A3(e){return Array.isArray(e)?e:typeof e=="number"?[N3,e]:e==null?Tw:[e]}function Eg(e,t,n,r){let a,l,u;typeof t=="function"&&typeof n!="function"?(l=void 0,u=t,a=n):(l=t,u=n,a=r),Aw(e,l,c,a);function c(d,h){const p=h[h.length-1],m=p?p.children.indexOf(d):void 0;return u(d,m,p)}}const Dp={}.hasOwnProperty,L3={};function D3(e,t){const n=t||L3,r=new Map,a=new Map,l=new Map,u={...p3,...n.handlers},c={all:h,applyData:O3,definitionById:r,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:u,one:d,options:n,patch:R3,wrap:M3};return Eg(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?r:a,x=String(p.identifier).toUpperCase();m.has(x)||m.set(x,p)}}),c;function d(p,m){const x=p.type,y=c.handlers[x];if(Dp.call(c.handlers,x)&&y)return y(c,p,m);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in p){const{children:C,..._}=p,S=sd(_);return S.children=c.all(p),S}return sd(p)}return(c.options.unknownHandler||I3)(c,p,m)}function h(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=g0(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=g0(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function R3(e,t){e.position&&(t.position=_A(e))}function O3(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,l=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const u="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:u}}n.type==="element"&&l&&Object.assign(n.properties,sd(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function I3(e,t){const n=t.data||{},r="value"in t&&!(Dp.call(n,"hProperties")||Dp.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 M3(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
78
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
79
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
80
|
+
`}),n}function g0(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function x0(e,t){const n=D3(e,t),r=n.one(e,void 0),a=S3(n),l=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
|
|
81
|
+
`},a),l}function P3(e,t){return e&&"run"in e?async function(n,r){const a=x0(n,{file:r,...t});await e.run(a,r)}:function(n,r){return x0(n,{file:r,...e||t})}}function y0(e){if(e)throw e}var Dm,b0;function B3(){if(b0)return Dm;b0=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var p=e.call(h,"constructor"),m=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!p&&!m)return!1;var x;for(x in h);return typeof x>"u"||e.call(h,x)},u=function(h,p){n&&p.name==="__proto__"?n(h,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):h[p.name]=p.newValue},c=function(h,p){if(p==="__proto__")if(e.call(h,p)){if(r)return r(h,p).value}else return;return h[p]};return Dm=function d(){var h,p,m,x,y,w,C=arguments[0],_=1,S=arguments.length,v=!1;for(typeof C=="boolean"&&(v=C,C=arguments[1]||{},_=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});_<S;++_)if(h=arguments[_],h!=null)for(p in h)m=c(C,p),x=c(h,p),C!==x&&(v&&x&&(l(x)||(y=a(x)))?(y?(y=!1,w=m&&a(m)?m:[]):w=m&&l(m)?m:{},u(C,{name:p,newValue:d(v,w,x)})):typeof x<"u"&&u(C,{name:p,newValue:x}));return C},Dm}var $3=B3();const Rm=Cd($3);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 z3(){const e=[],t={run:n,use:r};return t;function n(...a){let l=-1;const u=a.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);c(null,...a);function c(d,...h){const p=e[++l];let m=-1;if(d){u(d);return}for(;++m<a.length;)(h[m]===null||h[m]===void 0)&&(h[m]=a[m]);a=h,p?H3(p,c)(...h):u(null,...h)}}function r(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function H3(e,t){let n;return r;function r(...u){const c=e.length>u.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(h){const p=h;if(c&&n)throw p;return a(p)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,a):d instanceof Error?a(d):l(d))}function a(u,...c){n||(n=!0,t(u,...c))}function l(u){a(null,u)}}const qr={basename:U3,dirname:F3,extname:V3,join:W3,sep:"/"};function U3(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');tc(e);let n=0,r=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else r<0&&(l=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let u=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else u<0&&(l=!0,u=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(r=a):(c=-1,r=u));return n===r?r=u:r<0&&(r=e.length),e.slice(n,r)}function F3(e){if(tc(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 V3(e){tc(e);let t=e.length,n=-1,r=0,a=-1,l=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){r=t+1;break}continue}n<0&&(u=!0,n=t+1),c===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||n<0||l===0||l===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function W3(...e){let t=-1,n;for(;++t<e.length;)tc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":G3(n)}function G3(e){tc(e);const t=e.codePointAt(0)===47;let n=q3(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function q3(e,t){let n="",r=0,a=-1,l=0,u=-1,c,d;for(;++u<=e.length;){if(u<e.length)c=e.codePointAt(u);else{if(c===47)break;c=47}if(c===47){if(!(a===u-1||l===1))if(a!==u-1&&l===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),a=u,l=0;continue}}else if(n.length>0){n="",r=0,a=u,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,u):n=e.slice(a+1,u),r=u-a-1;a=u,l=0}else c===46&&l>-1?l++:l=-1}return n}function tc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const K3={cwd:Y3};function Y3(){return"/"}function Op(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function X3(e){if(typeof e=="string")e=new URL(e);else if(!Op(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 Q3(e)}function Q3(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const Om=["history","path","basename","stem","extname","dirname"];class Lw{constructor(t){let n;t?Op(t)?n={path:t}:typeof t=="string"||J3(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":K3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Om.length;){const l=Om[r];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)Om.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?qr.basename(this.path):void 0}set basename(t){Mm(t,"basename"),Im(t,"basename"),this.path=qr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?qr.dirname(this.path):void 0}set dirname(t){v0(this.basename,"dirname"),this.path=qr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?qr.extname(this.path):void 0}set extname(t){if(Im(t,"extname"),v0(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=qr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Op(t)&&(t=X3(t)),Mm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?qr.basename(this.path,this.extname):void 0}set stem(t){Mm(t,"stem"),Im(t,"stem"),this.path=qr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const a=this.message(t,n,r);throw a.fatal=!0,a}info(t,n,r){const a=this.message(t,n,r);return a.fatal=void 0,a}message(t,n,r){const a=new Pn(t,n,r);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Im(e,t){if(e&&e.includes(qr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+qr.sep+"`")}function Mm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function v0(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function J3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Z3=(function(e){const r=this.constructor.prototype,a=r[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),eR={}.hasOwnProperty;class Ng extends Z3{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=z3()}copy(){const t=new Ng;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Rm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?($m("data",this.frozen),this.namespace[t]=n,this):eR.call(this.namespace,t)&&this.namespace[t]||void 0:t?($m("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const a=n.call(t,...r);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ku(t),r=this.parser||this.Parser;return Pm("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Pm("process",this.parser||this.Parser),Bm("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,u){const c=ku(t),d=r.parse(c);r.run(d,c,function(p,m,x){if(p||!m||!x)return h(p);const y=m,w=r.stringify(y,x);rR(w)?x.value=w:x.result=w,h(p,x)});function h(p,m){p||!m?u(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,r;return this.freeze(),Pm("processSync",this.parser||this.Parser),Bm("processSync",this.compiler||this.Compiler),this.process(t,a),S0("processSync","process",n),r;function a(l,u){n=!0,y0(l),r=u}}run(t,n,r){_0(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?l(void 0,r):new Promise(l);function l(u,c){const d=ku(n);a.run(t,d,h);function h(p,m,x){const y=m||t;p?c(p):u?u(y):r(void 0,y,x)}}}runSync(t,n){let r=!1,a;return this.run(t,n,l),S0("runSync","run",r),a;function l(u,c){y0(u),a=c,r=!0}}stringify(t,n){this.freeze();const r=ku(n),a=this.compiler||this.Compiler;return Bm("stringify",a),_0(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if($m("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(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[p,...m]=h;d(p,m)}else u(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function u(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(h.plugins),h.settings&&(a.settings=Rm(!0,a.settings,h.settings))}function c(h){let p=-1;if(h!=null)if(Array.isArray(h))for(;++p<h.length;){const m=h[p];l(m)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,p){let m=-1,x=-1;for(;++m<r.length;)if(r[m][0]===h){x=m;break}if(x===-1)r.push([h,...p]);else if(p.length>0){let[y,...w]=p;const C=r[x][1];Rp(C)&&Rp(y)&&(y=Rm(!0,C,y)),r[x]=[h,y,...w]}}}}const tR=new Ng().freeze();function Pm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Bm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function $m(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 _0(e){if(!Rp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function S0(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ku(e){return nR(e)?e:new Lw(e)}function nR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function rR(e){return typeof e=="string"||sR(e)}function sR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const iR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",w0=[],C0={allowDangerousHtml:!0},aR=/^(https?|ircs?|mailto|xmpp)$/i,oR=[{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 lR(e){const t=cR(e),n=uR(e);return dR(t.runSync(t.parse(n),n),e)}function cR(e){const t=e.rehypePlugins||w0,n=e.remarkPlugins||w0,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...C0}:C0;return tR().use(FD).use(n).use(P3,r).use(t)}function uR(e){const t=e.children||"",n=new Lw;return typeof t=="string"&&(n.value=t),n}function dR(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||hR;for(const p of oR)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+iR+p.id,void 0);return Eg(e,h),jA(e,{Fragment:i.Fragment,components:a,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function h(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 Tm)if(Object.hasOwn(Tm,y)&&Object.hasOwn(p.properties,y)){const w=p.properties[y],C=Tm[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 hR(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||r!==-1&&t>r||aR.test(e.slice(0,t))?e:""}function k0(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function fR(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function mR(e,t,n){const a=Md((n||{}).ignore||[]),l=pR(t);let u=-1;for(;++u<l.length;)Aw(e,"text",c);function c(h,p){let m=-1,x;for(;++m<p.length;){const y=p[m],w=x?x.children:void 0;if(a(y,w?w.indexOf(y):void 0,x))return;x=y}if(x)return d(h,p)}function d(h,p){const m=p[p.length-1],x=l[u][0],y=l[u][1];let w=0;const _=m.children.indexOf(h);let S=!1,v=[];x.lastIndex=0;let b=x.exec(h.value);for(;b;){const j=b.index,N={index:b.index,input:b.input,stack:[...p,h]};let T=y(...b,N);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=j+1:(w!==j&&v.push({type:"text",value:h.value.slice(w,j)}),Array.isArray(T)?v.push(...T):T&&v.push(T),w=j+b[0].length,S=!0),!x.global)break;b=x.exec(h.value)}return S?(w<h.value.length&&v.push({type:"text",value:h.value.slice(w)}),m.children.splice(_,1,...v)):v=[h],_+v.length}}function pR(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const a=n[r];t.push([gR(a[0]),xR(a[1])])}return t}function gR(e){return typeof e=="string"?new RegExp(fR(e),"g"):e}function xR(e){return typeof e=="function"?e:function(){return e}}const zm="phrasing",Hm=["autolink","link","image","label"];function yR(){return{transforms:[kR],enter:{literalAutolink:vR,literalAutolinkEmail:Um,literalAutolinkHttp:Um,literalAutolinkWww:Um},exit:{literalAutolink:CR,literalAutolinkEmail:wR,literalAutolinkHttp:_R,literalAutolinkWww:SR}}}function bR(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:zm,notInConstruct:Hm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:zm,notInConstruct:Hm},{character:":",before:"[ps]",after:"\\/",inConstruct:zm,notInConstruct:Hm}]}}function vR(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Um(e){this.config.enter.autolinkProtocol.call(this,e)}function _R(e){this.config.exit.autolinkProtocol.call(this,e)}function SR(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 wR(e){this.config.exit.autolinkEmail.call(this,e)}function CR(e){this.exit(e)}function kR(e){mR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,jR],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),ER]],{ignore:["link","linkReference"]})}function jR(e,t,n,r,a){let l="";if(!Dw(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!NR(n)))return!1;const u=TR(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 ER(e,t,n,r){return!Dw(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function NR(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 TR(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=k0(e,"(");let l=k0(e,")");for(;r!==-1&&a>l;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),l++;return[e,n]}function Dw(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ji(n)||Rd(n))&&(!t||n!==47)}Rw.peek=BR;function AR(){this.buffer()}function LR(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function DR(){this.buffer()}function RR(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function OR(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function IR(e){this.exit(e)}function MR(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function PR(e){this.exit(e)}function BR(){return"["}function Rw(e,t,n,r){const a=n.createTracker(r);let l=a.move("[^");const u=n.enter("footnoteReference"),c=n.enter("reference");return l+=a.move(n.safe(n.associationId(e),{after:"]",before:l})),c(),u(),l+=a.move("]"),l}function $R(){return{enter:{gfmFootnoteCallString:AR,gfmFootnoteCall:LR,gfmFootnoteDefinitionLabelString:DR,gfmFootnoteDefinition:RR},exit:{gfmFootnoteCallString:OR,gfmFootnoteCall:IR,gfmFootnoteDefinitionLabelString:MR,gfmFootnoteDefinition:PR}}}function zR(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Rw},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,l,u){const c=l.createTracker(u);let d=c.move("[^");const h=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?`
|
|
82
|
+
`:" ")+l.indentLines(l.containerFlow(r,c.current()),t?Ow:HR))),h(),d}}function HR(e,t,n){return t===0?e:Ow(e,t,n)}function Ow(e,t,n){return(n?"":" ")+e}const UR=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Iw.peek=qR;function FR(){return{canContainEols:["delete"],enter:{strikethrough:WR},exit:{strikethrough:GR}}}function VR(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:UR}],handlers:{delete:Iw}}}function WR(e){this.enter({type:"delete",children:[]},e)}function GR(e){this.exit(e)}function Iw(e,t,n,r){const a=n.createTracker(r),l=n.enter("strikethrough");let u=a.move("~~");return u+=n.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),l(),u}function qR(){return"~"}function KR(e){return e.length}function YR(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||KR,l=[],u=[],c=[],d=[];let h=0,p=-1;for(;++p<e.length;){const C=[],_=[];let S=-1;for(e[p].length>h&&(h=e[p].length);++S<e[p].length;){const v=XR(e[p][S]);if(n.alignDelimiters!==!1){const b=a(v);_[S]=b,(d[S]===void 0||b>d[S])&&(d[S]=b)}C.push(v)}u[p]=C,c[p]=_}let m=-1;if(typeof r=="object"&&"length"in r)for(;++m<h;)l[m]=j0(r[m]);else{const C=j0(r);for(;++m<h;)l[m]=C}m=-1;const x=[],y=[];for(;++m<h;){const C=l[m];let _="",S="";C===99?(_=":",S=":"):C===108?_=":":C===114&&(S=":");let v=n.alignDelimiters===!1?1:Math.max(1,d[m]-_.length-S.length);const b=_+"-".repeat(v)+S;n.alignDelimiters!==!1&&(v=_.length+v+S.length,v>d[m]&&(d[m]=v),y[m]=v),x[m]=b}u.splice(1,0,x),c.splice(1,0,y),p=-1;const w=[];for(;++p<u.length;){const C=u[p],_=c[p];m=-1;const S=[];for(;++m<h;){const v=C[m]||"";let b="",j="";if(n.alignDelimiters!==!1){const N=d[m]-(_[m]||0),T=l[m];T===114?b=" ".repeat(N):T===99?N%2?(b=" ".repeat(N/2+.5),j=" ".repeat(N/2-.5)):(b=" ".repeat(N/2),j=b):j=" ".repeat(N)}n.delimiterStart!==!1&&!m&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&v==="")&&(n.delimiterStart!==!1||m)&&S.push(" "),n.alignDelimiters!==!1&&S.push(b),S.push(v),n.alignDelimiters!==!1&&S.push(j),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||m!==h-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
|
|
83
|
+
`)}function XR(e){return e==null?"":String(e)}function j0(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 QR(e,t,n,r){const a=n.enter("blockquote"),l=n.createTracker(r);l.move("> "),l.shift(2);const u=n.indentLines(n.containerFlow(e,l.current()),JR);return a(),u}function JR(e,t,n){return">"+(n?"":" ")+e}function ZR(e,t){return E0(e,t.inConstruct,!0)&&!E0(e,t.notInConstruct,!1)}function E0(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 N0(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
84
|
+
`&&ZR(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
85
|
+
`}function e5(e,t){const n=String(e);let r=n.indexOf(t),a=r,l=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++l>u&&(u=l):l=1,a=r+t.length,r=n.indexOf(t,a);return u}function t5(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 n5(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 r5(e,t,n,r){const a=n5(n),l=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(t5(e,n)){const m=n.enter("codeIndented"),x=n.indentLines(l,s5);return m(),x}const c=n.createTracker(r),d=a.repeat(Math.max(e5(l,a)+1,3)),h=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:`
|
|
86
|
+
`,encode:["`"],...c.current()})),m()}return p+=c.move(`
|
|
87
|
+
`),l&&(p+=c.move(l+`
|
|
88
|
+
`)),p+=c.move(d),h(),p}function s5(e,t,n){return(n?"":" ")+e}function Tg(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 i5(e,t,n,r){const a=Tg(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("definition");let c=n.enter("label");const d=n.createTracker(r);let h=d.move("[");return h+=d.move(n.safe(n.associationId(e),{before:h,after:"]",...d.current()})),h+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":`
|
|
89
|
+
`,...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),u(),h}function a5(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 Hl(e){return"&#x"+e.toString(16).toUpperCase()+";"}function id(e,t,n){const r=oo(e),a=oo(t);return r===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Mw.peek=o5;function Mw(e,t,n,r){const a=a5(n),l=n.enter("emphasis"),u=n.createTracker(r),c=u.move(a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),p=id(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=Hl(h)+d.slice(1));const m=d.charCodeAt(d.length-1),x=id(r.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+Hl(m));const y=u.move(a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function o5(e,t,n){return n.options.emphasis||"*"}function l5(e,t){let n=!1;return Eg(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Lp}),!!((!e.depth||e.depth<3)&&vg(e)&&(t.options.setext||n))}function c5(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(r);if(l5(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),x=n.containerPhrasing(e,{...l.current(),before:`
|
|
90
|
+
`,after:`
|
|
91
|
+
`});return m(),p(),x+`
|
|
92
|
+
`+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
|
|
93
|
+
`))+1))}const u="#".repeat(a),c=n.enter("headingAtx"),d=n.enter("phrasing");l.move(u+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
|
|
94
|
+
`,...l.current()});return/^[\t ]/.test(h)&&(h=Hl(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,n.options.closeAtx&&(h+=" "+u),d(),c(),h}Pw.peek=u5;function Pw(e){return e.value||""}function u5(){return"<"}Bw.peek=d5;function Bw(e,t,n,r){const a=Tg(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let c=n.enter("label");const d=n.createTracker(r);let h=d.move("![");return h+=d.move(n.safe(e.alt,{before:h,after:"]",...d.current()})),h+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),h+=d.move(")"),u(),h}function d5(){return"!"}$w.peek=h5;function $w(e,t,n,r){const a=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("![");const h=n.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!h||h!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function h5(){return"!"}zw.peek=f5;function zw(e,t,n){let r=e.value||"",a="`",l=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++l<n.unsafe.length;){const u=n.unsafe[l],c=n.compilePattern(u);let d;if(u.atBreak)for(;d=c.exec(r);){let h=d.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(d.index+1)}}return a+r+a}function f5(){return"`"}function Hw(e,t){const n=vg(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=m5;function Uw(e,t,n,r){const a=Tg(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(r);let c,d;if(Hw(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 h=u.move("[");return h+=u.move(n.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(n.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(d=n.enter("destinationRaw"),h+=u.move(n.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=n.enter(`title${l}`),h+=u.move(" "+a),h+=u.move(n.safe(e.title,{before:h,after:a,...u.current()})),h+=u.move(a),d()),h+=u.move(")"),c(),h}function m5(e,t,n){return Hw(e,n)?"<":"["}Fw.peek=p5;function Fw(e,t,n,r){const a=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("[");const h=n.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!h||h!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function p5(){return"["}function Ag(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 g5(e){const t=Ag(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 x5(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 Vw(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 y5(e,t,n,r){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?x5(n):Ag(n);const c=e.ordered?u==="."?")":".":g5(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),Vw(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 h=n.containerFlow(e,r);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),h}function b5(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 v5(e,t,n,r){const a=b5(n);let l=n.bulletCurrent||Ag(n);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let u=l.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=n.createTracker(r);c.move(l+" ".repeat(u-l.length)),c.shift(u);const d=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,c.current()),p);return d(),h;function p(m,x,y){return x?(y?"":" ".repeat(u))+m:(y?l:l+" ".repeat(u-l.length))+m}}function _5(e,t,n,r){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,r);return l(),a(),u}const S5=Md(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function w5(e,t,n,r){return(e.children.some(function(u){return S5(u)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function C5(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ww.peek=k5;function Ww(e,t,n,r){const a=C5(n),l=n.enter("strong"),u=n.createTracker(r),c=u.move(a+a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),p=id(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=Hl(h)+d.slice(1));const m=d.charCodeAt(d.length-1),x=id(r.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+Hl(m));const y=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function k5(e,t,n){return n.options.strong||"*"}function j5(e,t,n,r){return n.safe(e.value,r)}function E5(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 N5(e,t,n){const r=(Vw(n)+(n.options.ruleSpaces?" ":"")).repeat(E5(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Gw={blockquote:QR,break:N0,code:r5,definition:i5,emphasis:Mw,hardBreak:N0,heading:c5,html:Pw,image:Bw,imageReference:$w,inlineCode:zw,link:Uw,linkReference:Fw,list:y5,listItem:v5,paragraph:_5,root:w5,strong:Ww,text:j5,thematicBreak:N5};function T5(){return{enter:{table:A5,tableData:T0,tableHeader:T0,tableRow:D5},exit:{codeText:R5,table:L5,tableData:Fm,tableHeader:Fm,tableRow:Fm}}}function A5(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 L5(e){this.exit(e),this.data.inTable=void 0}function D5(e){this.enter({type:"tableRow",children:[]},e)}function Fm(e){this.exit(e)}function T0(e){this.enter({type:"tableCell",children:[]},e)}function R5(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,O5));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function O5(e,t){return t==="|"?t:e}function I5(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
95
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:c}};function u(y,w,C,_){return h(p(y,C,_),y.align)}function c(y,w,C,_){const S=m(y,C,_),v=h([S]);return v.slice(0,v.indexOf(`
|
|
96
|
+
`))}function d(y,w,C,_){const S=C.enter("tableCell"),v=C.enter("phrasing"),b=C.containerPhrasing(y,{..._,before:l,after:l});return v(),S(),b}function h(y,w){return YR(y,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function p(y,w,C){const _=y.children;let S=-1;const v=[],b=w.enter("table");for(;++S<_.length;)v[S]=m(_[S],w,C);return b(),v}function m(y,w,C){const _=y.children;let S=-1;const v=[],b=w.enter("tableRow");for(;++S<_.length;)v[S]=d(_[S],y,w,C);return b(),v}function x(y,w,C){let _=Gw.inlineCode(y,w,C);return C.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function M5(){return{exit:{taskListCheckValueChecked:A0,taskListCheckValueUnchecked:A0,paragraph:B5}}}function P5(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:$5}}}function A0(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function B5(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let l=-1,u;for(;++l<a.length;){const c=a[l];if(c.type==="paragraph"){u=c;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function $5(e,t,n,r){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);l&&c.move(u);let d=Gw.listItem(e,t,n,{...r,...c.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(p){return p+u}}function z5(){return[yR(),$R(),FR(),T5(),M5()]}function H5(e){return{extensions:[bR(),zR(e),VR(),I5(e),P5()]}}const U5={tokenize:K5,partial:!0},qw={tokenize:Y5,partial:!0},Kw={tokenize:X5,partial:!0},Yw={tokenize:Q5,partial:!0},F5={tokenize:J5,partial:!0},Xw={name:"wwwAutolink",tokenize:G5,previous:Jw},Qw={name:"protocolAutolink",tokenize:q5,previous:Zw},Ts={name:"emailAutolink",tokenize:W5,previous:eC},Zr={};function V5(){return{text:Zr}}let Pi=48;for(;Pi<123;)Zr[Pi]=Ts,Pi++,Pi===58?Pi=65:Pi===91&&(Pi=97);Zr[43]=Ts;Zr[45]=Ts;Zr[46]=Ts;Zr[95]=Ts;Zr[72]=[Ts,Qw];Zr[104]=[Ts,Qw];Zr[87]=[Ts,Xw];Zr[119]=[Ts,Xw];function W5(e,t,n){const r=this;let a,l;return u;function u(m){return!Ip(m)||!eC.call(r,r.previous)||Lg(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(F5,p,h)(m):m===45||m===95||In(m)?(l=!0,e.consume(m),d):p(m)}function h(m){return e.consume(m),a=!0,d}function p(m){return l&&a&&Un(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function G5(e,t,n){const r=this;return a;function a(u){return u!==87&&u!==119||!Jw.call(r,r.previous)||Lg(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(U5,e.attempt(qw,e.attempt(Kw,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function q5(e,t,n){const r=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&Zw.call(r,r.previous)&&!Lg(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),c):n(m)}function c(m){if(Un(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),c;if(m===58){const x=a.toLowerCase();if(x==="http"||x==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?h:(l=!0,d)):n(m)}function h(m){return m===null||nd(m)||zt(m)||Ji(m)||Rd(m)?n(m):e.attempt(qw,e.attempt(Kw,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function K5(e,t,n){let r=0;return a;function a(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),a):u===46&&r===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function Y5(e,t,n){let r,a,l;return u;function u(h){return h===46||h===95?e.check(Yw,d,c)(h):h===null||zt(h)||Ji(h)||h!==45&&Rd(h)?d(h):(l=!0,e.consume(h),u)}function c(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),u}function d(h){return a||r||!l?n(h):t(h)}}function X5(e,t){let n=0,r=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&r<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(Yw,t,l)(u):u===null||zt(u)||Ji(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&r++,e.consume(u),a}}function Q5(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),l):c===93?(e.consume(c),a):c===60||c===null||zt(c)||Ji(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||zt(c)||Ji(c)?t(c):r(c)}function l(c){return Un(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),r):Un(c)?(e.consume(c),u):n(c)}}function J5(e,t,n){return r;function r(l){return e.consume(l),a}function a(l){return In(l)?n(l):t(l)}}function Jw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||zt(e)}function Zw(e){return!Un(e)}function eC(e){return!(e===47||Ip(e))}function Ip(e){return e===43||e===45||e===46||e===95||In(e)}function Lg(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 Z5={tokenize:oO,partial:!0};function eO(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:sO,continuation:{tokenize:iO},exit:aO}},text:{91:{name:"gfmFootnoteCall",tokenize:rO},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:tO,resolveTo:nO}}}}function tO(e,t,n){const r=this;let a=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return n(d);const h=Pr(r.sliceSerialize({start:u.end,end:r.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function nO(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function rO(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l=0,u;return c;function c(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(m){if(l>999||m===93&&!u||m===null||m===91||zt(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Pr(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return zt(m)||(u=!0),l++,e.consume(m),m===92?p:h}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,h):h(m)}}function sO(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l,u=0,c;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(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||zt(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=Pr(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return zt(w)||(c=!0),u++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,p):p(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),Et(e,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return t(w)}}function iO(e,t,n){return e.check(ec,t,e.attempt(Z5,t,n))}function aO(e){e.exit("gfmFootnoteDefinition")}function oO(e,t,n){const r=this;return Et(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function lO(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:l,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(u,c){let d=-1;for(;++d<u.length;)if(u[d][0]==="enter"&&u[d][1].type==="strikethroughSequenceTemporary"&&u[d][1]._close){let h=d;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[d][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[d][1].start)},x=[["enter",p,c],["enter",u[h][1],c],["exit",u[h][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&dr(x,x.length,0,Od(y,u.slice(h+1,d),c)),dr(x,x.length,0,[["exit",m,c],["enter",u[d][1],c],["exit",u[d][1],c],["exit",p,c]]),dr(u,h-1,d-h+3,x),d=h+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 h=this.previous,p=this.events;let m=0;return x;function x(w){return h===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const C=oo(h);if(w===126)return m>1?d(w):(u.consume(w),m++,y);if(m<2&&!n)return d(w);const _=u.exit("strikethroughSequenceTemporary"),S=oo(w);return _._open=!S||S===2&&!!C,_._close=!C||C===2&&!!S,c(w)}}}class cO{constructor(){this.map=[]}add(t,n,r){uO(this,t,n,r)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const l of a)t.push(l);a=r.pop()}this.map.length=0}}function uO(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function dO(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function hO(){return{flow:{null:{name:"table",tokenize:fO,resolveAll:mO}}}}function fO(e,t,n){const r=this;let a=0,l=0,u;return c;function c(M){let G=r.events.length-1;for(;G>-1;){const H=r.events[G][1].type;if(H==="lineEnding"||H==="linePrefix")G--;else break}const U=G>-1?r.events[G][1].type:null,R=U==="tableHead"||U==="tableRow"?T:d;return R===T&&r.parser.lazy[r.now().line]?n(M):R(M)}function d(M){return e.enter("tableHead"),e.enter("tableRow"),h(M)}function h(M){return M===124||(u=!0,l+=1),p(M)}function p(M){return M===null?n(M):rt(M)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),y):n(M):_t(M)?Et(e,p,"whitespace")(M):(l+=1,u&&(u=!1,a+=1),M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),u=!0,p):(e.enter("data"),m(M)))}function m(M){return M===null||M===124||zt(M)?(e.exit("data"),p(M)):(e.consume(M),M===92?x:m)}function x(M){return M===92||M===124?(e.consume(M),m):m(M)}function y(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(e.enter("tableDelimiterRow"),u=!1,_t(M)?Et(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):w(M))}function w(M){return M===45||M===58?_(M):M===124?(u=!0,e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),C):N(M)}function C(M){return _t(M)?Et(e,_,"whitespace")(M):_(M)}function _(M){return M===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),S):M===45?(l+=1,S(M)):M===null||rt(M)?j(M):N(M)}function S(M){return M===45?(e.enter("tableDelimiterFiller"),v(M)):N(M)}function v(M){return M===45?(e.consume(M),v):M===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(M))}function b(M){return _t(M)?Et(e,j,"whitespace")(M):j(M)}function j(M){return M===124?w(M):M===null||rt(M)?!u||a!==l?N(M):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(M)):N(M)}function N(M){return n(M)}function T(M){return e.enter("tableRow"),D(M)}function D(M){return M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),D):M===null||rt(M)?(e.exit("tableRow"),t(M)):_t(M)?Et(e,D,"whitespace")(M):(e.enter("data"),L(M))}function L(M){return M===null||M===124||zt(M)?(e.exit("data"),D(M)):(e.consume(M),M===92?I:L)}function I(M){return M===92||M===124?(e.consume(M),L):L(M)}}function mO(e,t){let n=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,h,p,m;const x=new cO;for(;++n<e.length;){const y=e[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(L0(x,t,d,h,p),p=void 0,d=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",h,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",p,t]])),a=w.type==="tableDelimiterRow"?2:p?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=ju(x,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(u[0]=u[1],m=ju(x,t,l,a,void 0,m)),l=u,u=[l[1],n,0,0])):w.type==="tableHead"?(c=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,l[1]!==0?(u[0]=u[1],m=ju(x,t,l,a,n,m)):u[1]!==0&&(m=ju(x,t,u,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&L0(x,t,d,h,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=dO(t.events,n))}return e}function ju(e,t,n,r,a,l){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(l.end=Object.assign({},Qa(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=Qa(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 h=Qa(t.events,n[2]),p=Qa(t.events,n[3]),m={type:c,start:Object.assign({},h),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const x=t.events[n[2]],y=t.events[n[3]];if(x[1].end=Object.assign({},y[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},Qa(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function L0(e,t,n,r,a){const l=[],u=Qa(t.events,n);a&&(a.end=Object.assign({},u),l.push(["exit",a,t])),r.end=Object.assign({},u),l.push(["exit",r,t]),e.add(n+1,0,l)}function Qa(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const pO={name:"tasklistCheck",tokenize:xO};function gO(){return{text:{91:pO}}}function xO(e,t,n){const r=this;return a;function a(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return zt(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 rt(d)?t(d):_t(d)?e.check({tokenize:yO},t,n)(d):n(d)}}function yO(e,t,n){return Et(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function bO(e){return dw([V5(),eO(),lO(e),hO(),gO()])}const vO={};function _O(e){const t=this,n=e||vO,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(bO(n)),l.push(z5()),u.push(H5(n))}var Mp=Object.defineProperty,SO=Object.getOwnPropertyDescriptor,wO=Object.getOwnPropertyNames,CO=Object.prototype.hasOwnProperty,Dg=(e,t)=>{let n={};for(var r in e)Mp(n,r,{get:e[r],enumerable:!0});return Mp(n,Symbol.toStringTag,{value:"Module"}),n},kO=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=wO(t),l=0,u=a.length,c;l<u;l++)c=a[l],!CO.call(e,c)&&c!==n&&Mp(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(r=SO(t,c))||r.enumerable});return e},tC=(e,t,n)=>(kO(e,t,"default"),n);const Bd=[{id:"abap",name:"ABAP",import:(()=>te(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>te(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>te(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>te(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>te(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>te(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>te(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>te(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>te(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>te(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>te(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>te(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>te(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>te(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>te(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>te(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>te(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>te(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>te(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>te(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>te(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>te(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>te(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>te(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>te(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>te(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>te(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>te(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>te(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>te(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>te(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>te(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>te(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>te(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>te(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>te(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>te(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>te(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>te(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>te(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>te(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>te(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>te(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>te(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>te(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>te(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>te(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>te(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>te(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>te(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>te(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>te(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>te(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>te(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>te(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>te(()=>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:(()=>te(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>te(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>te(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>te(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>te(()=>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:(()=>te(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>te(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>te(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>te(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>te(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>te(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>te(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>te(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>te(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>te(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>te(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>te(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>te(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>te(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>te(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>te(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>te(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>te(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>te(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>te(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>te(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>te(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>te(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>te(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>te(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>te(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>te(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>te(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>te(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>te(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>te(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>te(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>te(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>te(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>te(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>te(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>te(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>te(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>te(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>te(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>te(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>te(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>te(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>te(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>te(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>te(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>te(()=>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:(()=>te(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>te(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>te(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>te(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>te(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>te(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>te(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>te(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>te(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>te(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>te(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>te(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>te(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>te(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>te(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>te(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>te(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>te(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>te(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>te(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>te(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>te(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>te(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>te(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>te(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>te(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>te(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>te(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>te(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>te(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>te(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>te(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>te(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>te(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>te(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>te(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>te(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>te(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>te(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>te(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>te(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>te(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>te(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>te(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>te(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>te(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>te(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>te(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>te(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>te(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>te(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>te(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>te(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>te(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>te(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>te(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>te(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>te(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>te(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>te(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>te(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>te(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>te(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>te(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>te(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>te(()=>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:(()=>te(()=>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:(()=>te(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>te(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>te(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>te(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>te(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>te(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>te(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>te(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>te(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>te(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>te(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>te(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>te(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>te(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>te(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>te(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>te(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>te(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>te(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>te(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>te(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>te(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>te(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>te(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>te(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>te(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>te(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>te(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>te(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>te(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>te(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>te(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>te(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>te(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>te(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>te(()=>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:(()=>te(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>te(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>te(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>te(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>te(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>te(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>te(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>te(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>te(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>te(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>te(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>te(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>te(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>te(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>te(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>te(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>te(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>te(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>te(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>te(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>te(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>te(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>te(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>te(()=>import("./zig-VOosw3JB.js"),[]))}],Rg=Object.fromEntries(Bd.map(e=>[e.id,e.import])),Og=Object.fromEntries(Bd.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),$d={...Rg,...Og},Ig=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>te(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>te(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>te(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>te(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>te(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>te(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>te(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>te(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>te(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>te(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>te(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>te(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>te(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>te(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>te(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>te(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>te(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>te(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>te(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>te(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>te(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>te(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>te(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>te(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>te(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>te(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>te(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>te(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>te(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>te(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>te(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>te(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>te(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>te(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>te(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>te(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>te(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>te(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>te(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>te(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>te(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>te(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>te(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>te(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>te(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>te(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>te(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>te(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>te(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>te(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>te(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>te(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>te(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>te(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>te(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>te(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>te(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>te(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>te(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>te(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>te(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>te(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>te(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>te(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>te(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],Mg=Object.fromEntries(Ig.map(e=>[e.id,e.import]));var Pg=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function jO(){return 2147483648}function EO(){return typeof performance<"u"?performance.now():Date.now()}const NO=(e,t)=>e+(t-e%t)%t;async function TO(e){let t,n;const r={};function a(y){n=y,r.HEAPU8=new Uint8Array(y),r.HEAPU32=new Uint32Array(y)}function l(y,w,C){r.HEAPU8.copyWithin(y,w,w+C)}function u(y){try{return t.grow(y-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function c(y){const w=r.HEAPU8.length;y=y>>>0;const C=jO();if(y>C)return!1;for(let _=1;_<=4;_*=2){let S=w*(1+.2/_);S=Math.min(S,y+100663296);const v=Math.min(C,NO(Math.max(y,S),65536));if(u(v))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(y,w,C=1024){const _=w+C;let S=w;for(;y[S]&&!(S>=_);)++S;if(S-w>16&&y.buffer&&d)return d.decode(y.subarray(w,S));let v="";for(;w<S;){let b=y[w++];if(!(b&128)){v+=String.fromCharCode(b);continue}const j=y[w++]&63;if((b&224)===192){v+=String.fromCharCode((b&31)<<6|j);continue}const N=y[w++]&63;if((b&240)===224?b=(b&15)<<12|j<<6|N:b=(b&7)<<18|j<<12|N<<6|y[w++]&63,b<65536)v+=String.fromCharCode(b);else{const T=b-65536;v+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return v}function p(y,w){return y?h(r.HEAPU8,y,w):""}const m={emscripten_get_now:EO,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function x(){const w=await e({env:m,wasi_snapshot_preview1:m});t=w.memory,a(t.buffer),Object.assign(r,w),r.UTF8ToString=p}return await x(),r}var AO=Object.defineProperty,LO=(e,t,n)=>t in e?AO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pn=(e,t,n)=>LO(e,typeof t!="symbol"?t+"":t,n);let _n=null;function DO(e){throw new Pg(e.UTF8ToString(e.getLastOnigError()))}class zd{constructor(t){pn(this,"utf16Length"),pn(this,"utf8Length"),pn(this,"utf16Value"),pn(this,"utf8Value"),pn(this,"utf16OffsetToUtf8"),pn(this,"utf8OffsetToUtf16");const n=t.length,r=zd._utf8ByteLength(t),a=r!==n,l=a?new Uint32Array(n+1):null;a&&(l[n]=r);const u=a?new Uint32Array(r+1):null;a&&(u[r]=n);const c=new Uint8Array(r);let d=0;for(let h=0;h<n;h++){const p=t.charCodeAt(h);let m=p,x=!1;if(p>=55296&&p<=56319&&h+1<n){const y=t.charCodeAt(h+1);y>=56320&&y<=57343&&(m=(p-55296<<10)+65536|y-56320,x=!0)}a&&(l[h]=d,x&&(l[h+1]=d),m<=127?u[d+0]=h:m<=2047?(u[d+0]=h,u[d+1]=h):m<=65535?(u[d+0]=h,u[d+1]=h,u[d+2]=h):(u[d+0]=h,u[d+1]=h,u[d+2]=h,u[d+3]=h)),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&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=c,this.utf16OffsetToUtf8=l,this.utf8OffsetToUtf16=u}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const l=t.charCodeAt(r);let u=l,c=!1;if(l>=55296&&l<=56319&&r+1<a){const d=t.charCodeAt(r+1);d>=56320&&d<=57343&&(u=(l-55296<<10)+65536|d-56320,c=!0)}u<=127?n+=1:u<=2047?n+=2:u<=65535?n+=3:n+=4,c&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const Hd=class Wr{constructor(t){if(pn(this,"id",++Wr.LAST_ID),pn(this,"_onigBinding"),pn(this,"content"),pn(this,"utf16Length"),pn(this,"utf8Length"),pn(this,"utf16OffsetToUtf8"),pn(this,"utf8OffsetToUtf16"),pn(this,"ptr"),!_n)throw new Pg("Must invoke loadWasm first.");this._onigBinding=_n,this.content=t;const n=new zd(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Wr._sharedPtrInUse?(Wr._sharedPtr||(Wr._sharedPtr=_n.omalloc(1e4)),Wr._sharedPtrInUse=!0,_n.HEAPU8.set(n.utf8Value,Wr._sharedPtr),this.ptr=Wr._sharedPtr):this.ptr=n.createString(_n)}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===Wr._sharedPtr?Wr._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};pn(Hd,"LAST_ID",0);pn(Hd,"_sharedPtr",0);pn(Hd,"_sharedPtrInUse",!1);let nC=Hd;class RO{constructor(t){if(pn(this,"_onigBinding"),pn(this,"_ptr"),!_n)throw new Pg("Must invoke loadWasm first.");const n=[],r=[];for(let c=0,d=t.length;c<d;c++){const h=new zd(t[c]);n[c]=h.createString(_n),r[c]=h.utf8Length}const a=_n.omalloc(4*t.length);_n.HEAPU32.set(n,a/4);const l=_n.omalloc(4*t.length);_n.HEAPU32.set(r,l/4);const u=_n.createOnigScanner(a,l,t.length);for(let c=0,d=t.length;c<d;c++)_n.ofree(n[c]);_n.ofree(l),_n.ofree(a),u===0&&DO(_n),this._onigBinding=_n,this._ptr=u}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let a=0;if(typeof r=="number"&&(a=r),typeof t=="string"){t=new nC(t);const l=this._findNextMatchSync(t,n,!1,a);return t.dispose(),l}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,r,a){const l=this._onigBinding,u=l.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(u===0)return null;const c=l.HEAPU32;let d=u/4;const h=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:h,captureIndices:m}}}function OO(e){return typeof e.instantiator=="function"}function IO(e){return typeof e.default=="function"}function MO(e){return typeof e.data<"u"}function PO(e){return typeof Response<"u"&&e instanceof Response}function BO(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 Eu;function Bg(e){if(Eu)return Eu;async function t(){_n=await TO(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),OO(r)?r=await r.instantiator(n):IO(r)?r=await r.default(n):(MO(r)&&(r=r.data),PO(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await $O(r)(n):r=await zO(r)(n):BO(r)?r=await Vm(r)(n):r instanceof WebAssembly.Module?r=await Vm(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Vm(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Eu=t(),Eu}function Vm(e){return t=>WebAssembly.instantiate(e,t)}function $O(e){return t=>WebAssembly.instantiateStreaming(e,t)}function zO(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let rC;function HO(e){rC=e}function UO(){return rC}async function sC(e){return e&&await Bg(e),{createScanner(t){return new RO(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new nC(t)}}}const FO=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:sC,getDefaultWasmLoader:UO,loadWasm:Bg,setDefaultWasmLoader:HO},Symbol.toStringTag,{value:"Module"}));var iC=Dg({});tC(iC,FO);var Vt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function VO(e){return $g(e)}function $g(e){return Array.isArray(e)?WO(e):e instanceof RegExp?e:typeof e=="object"?GO(e):e}function WO(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=$g(e[n]);return t}function GO(e){let t={};for(let n in e)t[n]=$g(e[n]);return t}function aC(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function oC(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?oC(e.substring(0,e.length-1)):e.substr(~t+1)}var Wm=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Nu=class{static hasCaptures(e){return e===null?!1:(Wm.lastIndex=0,Wm.test(e))}static replaceCaptures(e,t,n){return e.replace(Wm,(r,a,l,u)=>{let c=n[parseInt(a||l,10)];if(c){let d=t.substring(c.start,c.end);for(;d[0]===".";)d=d.substring(1);switch(u){case"downcase":return d.toLowerCase();case"upcase":return d.toUpperCase();default:return d}}else return r})}};function lC(e,t){return e<t?-1:e>t?1:0}function cC(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let a=0;a<n;a++){let l=lC(e[a],t[a]);if(l!==0)return l}return 0}return n-r}function D0(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 uC(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var dC=class{constructor(e){be(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}},ad=class{constructor(e,t,n){be(this,"_cachedMatchRoot",new dC(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(YO(e),t)}static createFromParsedTheme(e,t){return QO(e,t)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(a=>qO(e.parent,a.parentScopes));return r?new hC(r.fontStyle,r.foreground,r.background):null}},Gm=class Yu{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Yu(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Yu(n,t[r]);return n}push(t){return new Yu(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 qO(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],a=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],a=!0}for(;e&&!KO(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function KO(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var hC=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function YO(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let a=0,l=t.length;a<l;a++){let u=t[a];if(!u.settings)continue;let c;if(typeof u.scope=="string"){let m=u.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),c=m.split(",")}else Array.isArray(u.scope)?c=u.scope:c=[""];let d=-1;if(typeof u.settings.fontStyle=="string"){d=0;let m=u.settings.fontStyle.split(" ");for(let x=0,y=m.length;x<y;x++)switch(m[x]){case"italic":d=d|1;break;case"bold":d=d|2;break;case"underline":d=d|4;break;case"strikethrough":d=d|8;break}}let h=null;typeof u.settings.foreground=="string"&&D0(u.settings.foreground)&&(h=u.settings.foreground);let p=null;typeof u.settings.background=="string"&&D0(u.settings.background)&&(p=u.settings.background);for(let m=0,x=c.length;m<x;m++){let w=c[m].trim().split(" "),C=w[w.length-1],_=null;w.length>1&&(_=w.slice(0,w.length-1),_.reverse()),n[r++]=new XO(C,_,a,d,h,p)}}return n}var XO=class{constructor(e,t,n,r,a,l){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=a,this.background=l}},On=(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))(On||{});function QO(e,t){e.sort((d,h)=>{let p=lC(d.scope,h.scope);return p!==0||(p=cC(d.parentScopes,h.parentScopes),p!==0)?p:d.index-h.index});let n=0,r="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let d=e.shift();d.fontStyle!==-1&&(n=d.fontStyle),d.foreground!==null&&(r=d.foreground),d.background!==null&&(a=d.background)}let l=new JO(t),u=new hC(n,l.getId(r),l.getId(a)),c=new e4(new Pp(0,null,-1,0,0),[]);for(let d=0,h=e.length;d<h;d++){let p=e[d];c.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new ad(l,u,c)}var JO=class{constructor(e){be(this,"_isFrozen");be(this,"_lastColorId");be(this,"_id2color");be(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)}},ZO=Object.freeze([]),Pp=class fC{constructor(t,n,r,a,l){be(this,"scopeDepth");be(this,"parentScopes");be(this,"fontStyle");be(this,"foreground");be(this,"background");this.scopeDepth=t,this.parentScopes=n||ZO,this.fontStyle=r,this.foreground=a,this.background=l}clone(){return new fC(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,a=t.length;r<a;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,a){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),a!==0&&(this.background=a)}},e4=class Bp{constructor(t,n=[],r={}){be(this,"_rulesWithParentScopes");this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,a=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[a]===">"&&a++,!(r>=t.parentScopes.length||a>=n.parentScopes.length);){const l=n.parentScopes[a].length-t.parentScopes[r].length;if(l!==0)return l;r++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),a,l;if(r===-1?(a=t,l=""):(a=t.substring(0,r),l=t.substring(r+1)),this._children.hasOwnProperty(a))return this._children[a].match(l)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Bp._cmpBySpecificity),n}insert(t,n,r,a,l,u){if(n===""){this._doInsertHere(t,r,a,l,u);return}let c=n.indexOf("."),d,h;c===-1?(d=n,h=""):(d=n.substring(0,c),h=n.substring(c+1));let p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new Bp(this._mainRule.clone(),Pp.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.insert(t+1,h,r,a,l,u)}_doInsertHere(t,n,r,a,l){if(n===null){this._mainRule.acceptOverwrite(t,r,a,l);return}for(let u=0,c=this._rulesWithParentScopes.length;u<c;u++){let d=this._rulesWithParentScopes[u];if(cC(d.parentScopes,n)===0){d.acceptOverwrite(t,r,a,l);return}}r===-1&&(r=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),l===0&&(l=this._mainRule.background),this._rulesWithParentScopes.push(new Pp(t,n,r,a,l))}},lo=class Sr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Sr.getLanguageId(t),r=Sr.getTokenType(t),a=Sr.getFontStyle(t),l=Sr.getForeground(t),u=Sr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:a,foreground:l,background:u})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,a,l,u,c){let d=Sr.getLanguageId(t),h=Sr.getTokenType(t),p=Sr.containsBalancedBrackets(t)?1:0,m=Sr.getFontStyle(t),x=Sr.getForeground(t),y=Sr.getBackground(t);return n!==0&&(d=n),r!==8&&(h=r),a!==null&&(p=a?1:0),l!==-1&&(m=l),u!==0&&(x=u),c!==0&&(y=c),(d<<0|h<<8|p<<10|m<<11|x<<15|y<<24)>>>0}};function od(e,t){const n=[],r=t4(e);let a=r.next();for(;a!==null;){let d=0;if(a.length===2&&a.charAt(1)===":"){switch(a.charAt(0)){case"R":d=1;break;case"L":d=-1;break;default:console.log(`Unknown priority ${a} in scope selector`)}a=r.next()}let h=u();if(n.push({matcher:h,priority:d}),a!==",")break;a=r.next()}return n;function l(){if(a==="-"){a=r.next();const d=l();return h=>!!d&&!d(h)}if(a==="("){a=r.next();const d=c();return a===")"&&(a=r.next()),d}if(R0(a)){const d=[];do d.push(a),a=r.next();while(R0(a));return h=>t(d,h)}return null}function u(){const d=[];let h=l();for(;h;)d.push(h),h=l();return p=>d.every(m=>m(p))}function c(){const d=[];let h=u();for(;h&&(d.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=u()}return p=>d.some(m=>m(p))}}function R0(e){return!!e&&!!e.match(/[\w\.:]+/)}function t4(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 mC(e){typeof e.dispose=="function"&&e.dispose()}var Ul=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},n4=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},r4=class{constructor(){be(this,"_references",[]);be(this,"_seenReferenceKeys",new Set);be(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))}},s4=class{constructor(e,t){be(this,"seenFullScopeRequests",new Set);be(this,"seenPartialScopeRequests",new Set);be(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Ul(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new r4;for(const n of e)i4(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof Ul){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 i4(e,t,n,r){const a=n.lookup(e.scopeName);if(!a){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const l=n.lookup(t);e instanceof Ul?Xu({baseGrammar:l,selfGrammar:a},r):$p(e.ruleName,{baseGrammar:l,selfGrammar:a,repository:a.repository},r);const u=n.injections(e.scopeName);if(u)for(const c of u)r.add(new Ul(c))}function $p(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];ld([r],t,n)}}function Xu(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ld(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ld(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ld(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?aC({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&ld(r.patterns,{...t,repository:a},n);const l=r.include;if(!l)continue;const u=pC(l);switch(u.kind){case 0:Xu({...t,selfGrammar:t.baseGrammar},n);break;case 1:Xu(t,n);break;case 2:$p(u.ruleName,{...t,repository:a},n);break;case 3:case 4:const c=u.scopeName===t.selfGrammar.scopeName?t.selfGrammar:u.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(c){const d={baseGrammar:t.baseGrammar,selfGrammar:c,repository:a};u.kind===4?$p(u.ruleName,d,n):Xu(d,n)}else u.kind===4?n.add(new n4(u.scopeName,u.ruleName)):n.add(new Ul(u.scopeName));break}}}var a4=class{constructor(){be(this,"kind",0)}},o4=class{constructor(){be(this,"kind",1)}},l4=class{constructor(e){be(this,"kind",2);this.ruleName=e}},c4=class{constructor(e){be(this,"kind",3);this.scopeName=e}},u4=class{constructor(e,t){be(this,"kind",4);this.scopeName=e,this.ruleName=t}};function pC(e){if(e==="$base")return new a4;if(e==="$self")return new o4;const t=e.indexOf("#");if(t===-1)return new c4(e);if(t===0)return new l4(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new u4(n,r)}}var d4=/\\(\d+)/,O0=/\\(\d+)/g,h4=-1,gC=-2;var nc=class{constructor(e,t,n,r){be(this,"$location");be(this,"id");be(this,"_nameIsCapturing");be(this,"_name");be(this,"_contentNameIsCapturing");be(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Nu.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Nu.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${oC(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:Nu.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Nu.replaceCaptures(this._contentName,e,t)}},f4=class extends nc{constructor(t,n,r,a,l){super(t,n,r,a);be(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=l}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,a){throw new Error("Not supported!")}},m4=class extends nc{constructor(t,n,r,a,l){super(t,n,r,null);be(this,"_match");be(this,"captures");be(this,"_cachedCompiledPatterns");this._match=new Fl(a,this.id),this.captures=l,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Vl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},I0=class extends nc{constructor(t,n,r,a,l){super(t,n,r,a);be(this,"hasMissingPatterns");be(this,"patterns");be(this,"_cachedCompiledPatterns");this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Vl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},zp=class extends nc{constructor(t,n,r,a,l,u,c,d,h,p){super(t,n,r,a);be(this,"_begin");be(this,"beginCaptures");be(this,"_end");be(this,"endHasBackReferences");be(this,"endCaptures");be(this,"applyEndPatternLast");be(this,"hasMissingPatterns");be(this,"patterns");be(this,"_cachedCompiledPatterns");this._begin=new Fl(l,this.id),this.beginCaptures=u,this._end=new Fl(c||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=h||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Vl;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}},cd=class extends nc{constructor(t,n,r,a,l,u,c,d,h){super(t,n,r,a);be(this,"_begin");be(this,"beginCaptures");be(this,"whileCaptures");be(this,"_while");be(this,"whileHasBackReferences");be(this,"hasMissingPatterns");be(this,"patterns");be(this,"_cachedCompiledPatterns");be(this,"_cachedCompiledWhilePatterns");this._begin=new Fl(l,this.id),this.beginCaptures=u,this.whileCaptures=d,this._while=new Fl(c,gC),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=h.patterns,this.hasMissingPatterns=h.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,n){return this._while.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Vl;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,n){return this._getCachedCompiledWhilePatterns(t,n).compile(t)}compileWhileAG(t,n,r,a){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,a)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Vl,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},xC=class Dn{static createCaptureRule(t,n,r,a,l){return t.registerRule(u=>new f4(n,u,r,a,l))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new m4(t.$vscodeTextmateLocation,t.id,t.name,t.match,Dn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=aC({},r,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new I0(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Dn._compilePatterns(l,n,r))}return t.while?new cd(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Dn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Dn._compileCaptures(t.whileCaptures||t.captures,n,r),Dn._compilePatterns(t.patterns,n,r)):new zp(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Dn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Dn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Dn._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let a=[];if(t){let l=0;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);c>l&&(l=c)}for(let u=0;u<=l;u++)a[u]=null;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);let d=0;t[u].patterns&&(d=Dn.getCompiledRuleId(t[u],n,r)),a[c]=Dn.createCaptureRule(n,t[u].$vscodeTextmateLocation,t[u].name,t[u].contentName,d)}}return a}static _compilePatterns(t,n,r){let a=[];if(t)for(let l=0,u=t.length;l<u;l++){const c=t[l];let d=-1;if(c.include){const h=pC(c.include);switch(h.kind){case 0:case 1:d=Dn.getCompiledRuleId(r[c.include],n,r);break;case 2:let p=r[h.ruleName];p&&(d=Dn.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=h.scopeName,x=h.kind===4?h.ruleName:null,y=n.getExternalGrammar(m,r);if(y)if(x){let w=y.repository[x];w&&(d=Dn.getCompiledRuleId(w,n,y.repository))}else d=Dn.getCompiledRuleId(y.repository.$self,n,y.repository);break}}else d=Dn.getCompiledRuleId(c,n,r);if(d!==-1){const h=n.getRule(d);let p=!1;if((h instanceof I0||h instanceof zp||h instanceof cd)&&h.hasMissingPatterns&&h.patterns.length===0&&(p=!0),p)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},Fl=class yC{constructor(t,n){be(this,"source");be(this,"ruleId");be(this,"hasAnchor");be(this,"hasBackReferences");be(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,l=[],u=!1;for(let c=0;c<r;c++)if(t.charAt(c)==="\\"&&c+1<r){const h=t.charAt(c+1);h==="z"?(l.push(t.substring(a,c)),l.push("$(?!\\n)(?<!\\n)"),a=c+2):(h==="A"||h==="G")&&(u=!0),c++}this.hasAnchor=u,a===0?this.source=t:(l.push(t.substring(a,r)),this.source=l.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=d4.test(this.source):this.hasBackReferences=!1}clone(){return new yC(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(a=>t.substring(a.start,a.end));return O0.lastIndex=0,this.source.replace(O0,(a,l)=>uC(r[parseInt(l,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],a=[],l,u,c,d;for(l=0,u=this.source.length;l<u;l++)c=this.source.charAt(l),t[l]=c,n[l]=c,r[l]=c,a[l]=c,c==="\\"&&l+1<u&&(d=this.source.charAt(l+1),d==="A"?(t[l+1]="",n[l+1]="",r[l+1]="A",a[l+1]="A"):d==="G"?(t[l+1]="",n[l+1]="G",r[l+1]="",a[l+1]="G"):(t[l+1]=d,n[l+1]=d,r[l+1]=d,a[l+1]=d),l++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:a.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Vl=class{constructor(){be(this,"_items");be(this,"_hasAnchors");be(this,"_cached");be(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 M0(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(a=>a.resolveAnchors(t,n));return new M0(e,r,this._items.map(a=>a.ruleId))}},M0=class{constructor(e,t,n){be(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(`
|
|
97
|
+
`)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},qm=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Cs,p4=(Cs=class{constructor(t,n){be(this,"_defaultAttributes");be(this,"_embeddedLanguagesMatcher");be(this,"_getBasicScopeAttributes",new dC(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new qm(n,r)}));this._defaultAttributes=new qm(t,8),this._embeddedLanguagesMatcher=new g4(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Cs._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(Cs.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!")}},be(Cs,"_NULL_SCOPE_METADATA",new qm(0,0)),be(Cs,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),Cs),g4=class{constructor(e){be(this,"values");be(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>uC(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])}},P0=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function bC(e,t,n,r,a,l,u,c){const d=t.content.length;let h=!1,p=-1;if(u){const y=x4(e,t,n,r,a,l);a=y.stack,r=y.linePos,n=y.isFirstLine,p=y.anchorPosition}const m=Date.now();for(;!h;){if(c!==0&&Date.now()-m>c)return new P0(a,!0);x()}return new P0(a,!1);function x(){const y=y4(e,t,n,r,a,p);if(!y){l.produce(a,d),h=!0;return}const w=y.captureIndices,C=y.matchedRuleId,_=w&&w.length>0?w[0].end>r:!1;if(C===h4){const S=a.getRule(e);l.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),jl(e,t,n,a,l,S.endCaptures,w),l.produce(a,w[0].end);const v=a;if(a=a.parent,p=v.getAnchorPos(),!_&&v.getEnterPos()===r){a=v,l.produce(a,d),h=!0;return}}else{const S=e.getRule(C);l.produce(a,w[0].start);const v=a,b=S.getName(t.content,w),j=a.contentNameScopesList.pushAttributed(b,e);if(a=a.push(C,r,p,w[0].end===d,null,j,j),S instanceof zp){const N=S;jl(e,t,n,a,l,N.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const T=N.getContentName(t.content,w),D=j.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),N.endHasBackReferences&&(a=a.withEndRule(N.getEndWithResolvedBackReferences(t.content,w))),!_&&v.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),h=!0;return}}else if(S instanceof cd){const N=S;jl(e,t,n,a,l,N.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const T=N.getContentName(t.content,w),D=j.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),N.whileHasBackReferences&&(a=a.withEndRule(N.getWhileWithResolvedBackReferences(t.content,w))),!_&&v.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),h=!0;return}}else if(jl(e,t,n,a,l,S.captures,w),l.produce(a,w[0].end),a=a.pop(),!_){a=a.safePop(),l.produce(a,d),h=!0;return}}w[0].end>r&&(r=w[0].end,n=!1)}}function x4(e,t,n,r,a,l){let u=a.beginRuleCapturedEOL?0:-1;const c=[];for(let d=a;d;d=d.pop()){const h=d.getRule(e);h instanceof cd&&c.push({rule:h,stack:d})}for(let d=c.pop();d;d=c.pop()){const{ruleScanner:h,findOptions:p}=_4(d.rule,e,d.stack.endRule,n,r===u),m=h.findNextMatchSync(t,r,p);if(m){if(m.ruleId!==gC){a=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(d.stack,m.captureIndices[0].start),jl(e,t,n,d.stack,l,d.rule.whileCaptures,m.captureIndices),l.produce(d.stack,m.captureIndices[0].end),u=m.captureIndices[0].end,m.captureIndices[0].end>r&&(r=m.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:u,isFirstLine:n}}function y4(e,t,n,r,a,l){const u=b4(e,t,n,r,a,l),c=e.getInjections();if(c.length===0)return u;const d=v4(c,e,t,n,r,a,l);if(!d)return u;if(!u)return d;const h=u.captureIndices[0].start,p=d.captureIndices[0].start;return p<h||d.priorityMatch&&p===h?d:u}function b4(e,t,n,r,a,l){const u=a.getRule(e),{ruleScanner:c,findOptions:d}=vC(u,e,a.endRule,n,r===l),h=c.findNextMatchSync(t,r,d);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function v4(e,t,n,r,a,l,u){let c=Number.MAX_VALUE,d=null,h,p=0;const m=l.contentNameScopesList.getScopeNames();for(let x=0,y=e.length;x<y;x++){const w=e[x];if(!w.matcher(m))continue;const C=t.getRule(w.ruleId),{ruleScanner:_,findOptions:S}=vC(C,t,null,r,a===u),v=_.findNextMatchSync(n,a,S);if(!v)continue;const b=v.captureIndices[0].start;if(!(b>=c)&&(c=b,d=v.captureIndices,h=v.ruleId,p=w.priority,c===a))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:h}:null}function vC(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function _4(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function jl(e,t,n,r,a,l,u){if(l.length===0)return;const c=t.content,d=Math.min(l.length,u.length),h=[],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(;h.length>0&&h[h.length-1].endPos<=y.start;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?a.produceFromScopes(h[h.length-1].scopes,y.start):a.produce(r,y.start),x.retokenizeCapturedWithRuleId){const C=x.getName(c,u),_=r.contentNameScopesList.pushAttributed(C,e),S=x.getContentName(c,u),v=_.pushAttributed(S,e),b=r.push(x.retokenizeCapturedWithRuleId,y.start,-1,!1,null,_,v),j=e.createOnigString(c.substring(0,y.end));bC(e,j,n&&y.start===0,y.start,b,a,!1,0),mC(j);continue}const w=x.getName(c,u);if(w!==null){const _=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);h.push(new S4(_,y.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var S4=class{constructor(e,t){be(this,"scopes");be(this,"endPos");this.scopes=e,this.endPos=t}};function w4(e,t,n,r,a,l,u,c){return new k4(e,t,n,r,a,l,u,c)}function B0(e,t,n,r,a){const l=od(t,ud),u=xC.getCompiledRuleId(n,r,a.repository);for(const c of l)e.push({debugSelector:t,matcher:c.matcher,ruleId:u,grammar:a,priority:c.priority})}function ud(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let a=n;a<t.length;a++)if(C4(t[a],r))return n=a+1,!0;return!1})}function C4(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var k4=class{constructor(e,t,n,r,a,l,u,c){be(this,"_rootId");be(this,"_lastRuleId");be(this,"_ruleId2desc");be(this,"_includedGrammars");be(this,"_grammarRepository");be(this,"_grammar");be(this,"_injections");be(this,"_basicScopeAttributesProvider");be(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new p4(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=$0(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const h=od(d,ud);for(const p of h)this._tokenTypeMatchers.push({matcher:p.matcher,type:a[d]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const a=r.injections;if(a)for(let u in a)B0(t,u,a[u],this,r);const l=this._grammarRepository.injections(n);l&&l.forEach(u=>{const c=this.getExternalGrammar(u);if(c){const d=c.injectionSelector;d&&B0(t,d,c,this,c)}})}return t.sort((a,l)=>a.priority-l.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=$0(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=xC.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===Hp.NULL){a=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=lo.set(0,h.languageId,h.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),x=this.getRule(this._rootId).getName(null,null);let y;x?y=Dl.createRootAndLookUpScopeName(x,m,this):y=Dl.createRoot("unknown",m),t=new Hp(null,this._rootId,-1,-1,!1,null,y,y)}else a=!1,t.reset();e=e+`
|
|
98
|
+
`;const l=this.createOnigString(e),u=l.content.length,c=new E4(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=bC(this,l,a,0,t,c,!0,r);return mC(l),{lineLength:u,lineTokens:c,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function $0(e,t){return e=VO(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 Dl=class Gr{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,a=(t==null?void 0:t.scopePath)??null;for(const l of n)a=Gm.push(a,l.scopeNames),r=new Gr(r,a,l.encodedTokenAttributes);return r}static createRoot(t,n){return new Gr(null,new Gm(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),l=new Gm(null,t),u=r.themeProvider.themeMatch(l),c=Gr.mergeAttributes(n,a,u);return new Gr(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Gr.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let a=-1,l=0,u=0;return r!==null&&(a=r.fontStyle,l=r.foregroundId,u=r.backgroundId),lo.set(t,n.languageId,n.tokenType,null,a,l,u)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Gr._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const l of r)a=Gr._pushAttributed(a,l,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),l=t.scopePath.push(n),u=r.themeProvider.themeMatch(l),c=Gr.mergeAttributes(t.tokenAttributes,a,u);return new Gr(t,l,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((a=r.parent)==null?void 0:a.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},Cr,Hp=(Cr=class{constructor(t,n,r,a,l,u,c,d){be(this,"_stackElementBrand");be(this,"_enterPos");be(this,"_anchorPos");be(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=l,this.endRule=u,this.nameScopesList=c,this.contentNameScopesList=d,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=a}equals(t){return t===null?!1:Cr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Dl.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(){Cr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,l,u,c){return new Cr(this,t,n,r,a,l,u,c)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var r,a;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(a=this.contentNameScopesList)==null?void 0:a.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new Cr(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=Dl.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new Cr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Dl.fromExtension(r,n.contentNameScopesList))}},be(Cr,"NULL",new Cr(null,0,0,0,!1,null,null,null)),Cr),j4=class{constructor(e,t){be(this,"balancedBracketScopes");be(this,"unbalancedBracketScopes");be(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):od(n,ud).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>od(n,ud).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}},E4=class{constructor(e,t,n,r){be(this,"_emitBinaryTokens");be(this,"_lineText");be(this,"_tokens");be(this,"_binaryTokens");be(this,"_lastTokenEndIndex");be(this,"_tokenTypeOverrides");this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var r;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let a=(e==null?void 0:e.tokenAttributes)??0,l=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(l=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const u=(e==null?void 0:e.getScopeNames())??[];for(const c of this._tokenTypeOverrides)c.matcher(u)&&(a=lo.set(a,0,c.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(u))}if(l&&(a=lo.set(a,0,8,l,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===a){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(a),this._lastTokenEndIndex=t;return}const n=(e==null?void 0:e.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,a=this._binaryTokens.length;r<a;r++)n[r]=this._binaryTokens[r];return n}},N4=class{constructor(e,t){be(this,"_grammars",new Map);be(this,"_rawGrammars",new Map);be(this,"_injectionGrammars",new Map);be(this,"_theme");this._onigLib=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,a){if(!this._grammars.has(e)){let l=this._rawGrammars.get(e);if(!l)return null;this._grammars.set(e,w4(e,l,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},T4=class{constructor(t){be(this,"_options");be(this,"_syncRegistry");be(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new N4(ad.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(ad.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 j4(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,l){const u=new s4(this._syncRegistry,t);for(;u.Q.length>0;)u.Q.map(c=>this._loadSingleGrammar(c.scopeName)),u.processQueue();return this._grammarForScopeName(t,n,r,a,l)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,a=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,a)}_grammarForScopeName(t,n=0,r=null,a=null,l=null){return this._syncRegistry.grammarForScopeName(t,n,r,a,l)}},Up=Hp.NULL;function dd(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[a,l]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof l=="string"?n[a]=l:a===r&&Object.assign(n,l);return n}function hi(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function A4(e){return Array.isArray(e)?e:[e]}async function _C(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Ud(e){return!e||["plaintext","txt","text","plain"].includes(e)}function SC(e){return e==="ansi"||Ud(e)}function Fd(e){return e==="none"}function wC(e){return Fd(e)}const L4=/(\r?\n)/g;function Vd(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(L4);let r=0;const a=[];for(let u=0;u<n.length;u+=2){const c=t?n[u]+(n[u+1]||""):n[u];a.push([c,r]),r+=n[u].length,r+=((l=n[u+1])==null?void 0:l.length)||0}return a}const z0={light:"#333333",dark:"#bbbbbb"},H0={light:"#fffffe",dark:"#1e1e1e"},U0="__shiki_resolved";function zg(e){var c,d,h,p,m;if(e!=null&&e[U0])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&&((h=t==null?void 0:t.colors)!=null&&h["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?z0.light:z0.dark),n||(n=t.type==="light"?H0.light:H0.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let a=0;const l=new Map;function u(x){var w;if(l.has(x))return l.get(x);a+=1;const y=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${y}`]?u(x):(l.set(x,y),y)}t.settings=t.settings.map(x=>{var _,S;const y=((_=x.settings)==null?void 0:_.foreground)&&!x.settings.foreground.startsWith("#"),w=((S=x.settings)==null?void 0:S.background)&&!x.settings.background.startsWith("#");if(!y&&!w)return x;const C={...x,settings:{...x.settings}};if(y){const v=u(x.settings.foreground);t.colorReplacements[v]=x.settings.foreground,C.settings.foreground=v}if(w){const v=u(x.settings.background);t.colorReplacements[v]=x.settings.background,C.settings.background=v}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,U0,{enumerable:!1,writable:!1,value:!0}),t}async function CC(e){return[...new Set((await Promise.all(e.filter(t=>!SC(t)).map(async t=>await _C(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function kC(e){return(await Promise.all(e.map(async t=>wC(t)?null:zg(await _C(t))))).filter(t=>!!t)}function jC(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 Vt(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var D4=class extends T4{constructor(t,n,r,a={}){super(t);be(this,"_resolver");be(this,"_themes");be(this,"_langs");be(this,"_alias");be(this,"_resolvedThemes",new Map);be(this,"_resolvedGrammars",new Map);be(this,"_langMap",new Map);be(this,"_langGraph",new Map);be(this,"_textmateThemeCache",new WeakMap);be(this,"_loadedThemesCache",null);be(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=a,this._themes.map(l=>this.loadTheme(l)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=zg(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=ad.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=jC(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(h=>{var p;return(p=h.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(u=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||u.delete(h.scopeName),(d=(c=this._syncRegistry)==null?void 0:c._grammars)==null||d.delete(h.scopeName),this.loadLanguage(this._langMap.get(h.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const a of t)this.resolveEmbeddedLanguages(a);const n=[...this._langGraph.entries()],r=n.filter(([a,l])=>!l);if(r.length){const a=n.filter(([l,u])=>{var c;return u?(c=u.embeddedLanguages||u.embeddedLangs)==null?void 0:c.some(d=>r.map(([h])=>h).includes(d)):!1}).filter(l=>!r.includes(l));throw new Vt(`Missing languages ${r.map(([l])=>`\`${l}\``).join(", ")}, required by ${a.map(([l])=>`\`${l}\``).join(", ")}`)}for(const[a,l]of n)this._resolver.addLanguage(l);for(const[a,l]of n)this.loadLanguage(l)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const n=t.embeddedLanguages??t.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}},R4=class{constructor(e,t){be(this,"_langs",new Map);be(this,"_scopeToLang",new Map);be(this,"_injections",new Map);be(this,"_onigLib");this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const a=t.slice(0,r).join(".");n=[...n,...this._injections.get(a)||[]]}return n}};let yl=0;function O4(e){yl+=1,e.warnings!==!1&&yl>=10&&yl%10===0&&console.warn(`[Shiki] ${yl} 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 Vt("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(zg),a=new D4(new R4(e.engine,n),r,n,e.langAlias);let l;function u(v){return jC(v,e.langAlias)}function c(v){_();const b=a.getGrammar(typeof v=="string"?v:v.name);if(!b)throw new Vt(`Language \`${v}\` not found, you may need to load it first`);return b}function d(v){if(v==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};_();const b=a.getTheme(v);if(!b)throw new Vt(`Theme \`${v}\` not found, you may need to load it first`);return b}function h(v){_();const b=d(v);return l!==v&&(a.setTheme(b),l=v),{theme:b,colorMap:a.getColorMap()}}function p(){return _(),a.getLoadedThemes()}function m(){return _(),a.getLoadedLanguages()}function x(...v){_(),a.loadLanguages(v.flat(1))}async function y(...v){return x(await CC(v))}function w(...v){_();for(const b of v.flat(1))a.loadTheme(b)}async function C(...v){return _(),w(await kC(v))}function _(){if(t)throw new Vt("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),yl-=1)}return{setTheme:h,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 I4(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([kC(e.themes||[]),CC(e.langs||[]),e.engine]);return O4({...e,themes:t,langs:n,engine:r})}const EC=new WeakMap;function Wd(e,t){EC.set(e,t)}function Wl(e){return EC.get(e)}var Gd=class NC{constructor(...t){be(this,"_stacks",{});be(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,a]=t;this.lang=r,this._stacks={[a]:n}}}get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new NC(Object.fromEntries(A4(n).map(r=>[r,Up])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return M4(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function M4(e){const t=[],n=new Set;function r(a){var u;if(n.has(a))return;n.add(a);const l=(u=a==null?void 0:a.nameScopesList)==null?void 0:u.scopeName;l&&t.push(l),a.parent&&r(a.parent)}return r(e),t}function P4(e,t){if(!(e instanceof Gd))throw new Vt("Invalid grammar state");return e.getInternalStack(t)}const B4=/,/,$4=/ /;function TC(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Ud(e.resolveLangAlias(n.lang||"text"))||Fd(r))return Vd(t).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:l}=e.setTheme(r),u=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==u.name)throw new Vt(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(a.name))throw new Vt(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return H4(t,u,a,l,n)}function z4(...e){if(e.length===2)return Wl(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=r;if(Ud(a)||Fd(l))throw new Vt("Plain language does not have grammar state");if(a==="ansi")throw new Vt("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),d=t.getLanguage(a);return new Gd(Hg(n,d,u,c,r).stateStack,d.name,u.name)}function H4(e,t,n,r,a){const l=Hg(e,t,n,r,a),u=new Gd(l.stateStack,t.name,n.name);return Wd(l.tokens,u),l.tokens}function Hg(e,t,n,r,a){const l=dd(n,a),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500}=a,d=Vd(e);let h=a.grammarState?P4(a.grammarState,n.name)??Up:a.grammarContextCode!=null?Hg(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:Up,p=[];const m=[];for(let x=0,y=d.length;x<y;x++){const[w,C]=d[x];if(w===""){p=[],m.push([]);continue}if(u>0&&w.length>=u){p=[],m.push([{content:w,offset:C,color:"",fontStyle:0}]);continue}let _,S,v;a.includeExplanation&&(_=t.tokenizeLine(w,h,c),S=_.tokens,v=0);const b=t.tokenizeLine2(w,h,c),j=b.tokens.length/2;for(let N=0;N<j;N++){const T=b.tokens[2*N],D=N+1<j?b.tokens[2*N+2]:w.length;if(T===D)continue;const L=b.tokens[2*N+1],I=hi(r[lo.getForeground(L)],l),M=lo.getFontStyle(L),G={content:w.substring(T,D),offset:C+T,color:I,fontStyle:M};if(a.includeExplanation){const U=[];if(a.includeExplanation!=="scopeName")for(const H of n.settings){let W;switch(typeof H.scope){case"string":W=H.scope.split(B4).map(V=>V.trim());break;case"object":W=H.scope;break;default:continue}U.push({settings:H,selectors:W.map(V=>V.split($4))})}G.explanation=[];let R=0;for(;T+R<D;){const H=S[v],W=w.substring(H.startIndex,H.endIndex);R+=W.length,G.explanation.push({content:W,scopes:a.includeExplanation==="scopeName"?U4(H.scopes):F4(U,H.scopes)}),v+=1}}p.push(G)}m.push(p),p=[],h=b.ruleStack}return{tokens:m,stateStack:h}}function U4(e){return e.map(t=>({scopeName:t}))}function F4(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const l=t[r];n[r]={scopeName:l,themeMatches:W4(e,l,t.slice(0,r))}}return n}function F0(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function V4(e,t,n){if(!F0(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)F0(e[r],n[a])&&(r-=1),a-=1;return r===-1}function W4(e,t,n){const r=[];for(const{selectors:a,settings:l}of e)for(const u of a)if(V4(u,t,n)){r.push(l);break}return r}function AC(e,t,n,r=TC){const a=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),l=a.map(h=>{const p=r(e,t,{...n,theme:h.theme});return{tokens:p,state:Wl(p),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),u=G4(...l.map(h=>h.tokens)),c=u[0].map((h,p)=>h.map((m,x)=>{const y={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(y.explanation=m.explanation),u.forEach((w,C)=>{const{content:_,explanation:S,offset:v,...b}=w[p][x];y.variants[a[C].color]=b}),y})),d=l[0].state?new Gd(Object.fromEntries(l.map(h=>{var p;return[h.theme,(p=h.state)==null?void 0:p.getInternalStack(h.theme)]})),l[0].state.lang):void 0;return d&&Wd(c,d),c}function G4(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const a=e.map(d=>d[r]),l=t.map(()=>[]);t.forEach((d,h)=>d.push(l[h]));const u=a.map(()=>0),c=a.map(d=>d[0]);for(;c.every(d=>d);){const d=Math.min(...c.map(h=>h.content.length));for(let h=0;h<n;h++){const p=c[h];p.content.length===d?(l[h].push(p),u[h]+=1,c[h]=a[h][u[h]]):(l[h].push({...p,content:p.content.slice(0,d)}),c[h]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const q4=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class rc{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}rc.prototype.normal={};rc.prototype.property={};rc.prototype.space=void 0;function LC(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new rc(n,r,t)}function Fp(e){return e.toLowerCase()}class er{constructor(t,n){this.attribute=n,this.property=t}}er.prototype.attribute="";er.prototype.booleanish=!1;er.prototype.boolean=!1;er.prototype.commaOrSpaceSeparated=!1;er.prototype.commaSeparated=!1;er.prototype.defined=!1;er.prototype.mustUseProperty=!1;er.prototype.number=!1;er.prototype.overloadedBoolean=!1;er.prototype.property="";er.prototype.spaceSeparated=!1;er.prototype.space=void 0;let K4=0;const gt=sa(),un=sa(),Vp=sa(),Be=sa(),Ut=sa(),ro=sa(),ur=sa();function sa(){return 2**++K4}const Wp=Object.freeze(Object.defineProperty({__proto__:null,boolean:gt,booleanish:un,commaOrSpaceSeparated:ur,commaSeparated:ro,number:Be,overloadedBoolean:Vp,spaceSeparated:Ut},Symbol.toStringTag,{value:"Module"})),Km=Object.keys(Wp);class Ug extends er{constructor(t,n,r,a){let l=-1;if(super(t,n),V0(this,"space",a),typeof r=="number")for(;++l<Km.length;){const u=Km[l];V0(this,Km[l],(r&Wp[u])===Wp[u])}}}Ug.prototype.defined=!0;function V0(e,t,n){n&&(e[t]=n)}function go(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new Ug(r,e.transform(e.attributes||{},r),a,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 rc(t,n,e.space)}const DC=go({properties:{ariaActiveDescendant:null,ariaAtomic:un,ariaAutoComplete:null,ariaBusy:un,ariaChecked:un,ariaColCount:Be,ariaColIndex:Be,ariaColSpan:Be,ariaControls:Ut,ariaCurrent:null,ariaDescribedBy:Ut,ariaDetails:null,ariaDisabled:un,ariaDropEffect:Ut,ariaErrorMessage:null,ariaExpanded:un,ariaFlowTo:Ut,ariaGrabbed:un,ariaHasPopup:null,ariaHidden:un,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ut,ariaLevel:Be,ariaLive:null,ariaModal:un,ariaMultiLine:un,ariaMultiSelectable:un,ariaOrientation:null,ariaOwns:Ut,ariaPlaceholder:null,ariaPosInSet:Be,ariaPressed:un,ariaReadOnly:un,ariaRelevant:null,ariaRequired:un,ariaRoleDescription:Ut,ariaRowCount:Be,ariaRowIndex:Be,ariaRowSpan:Be,ariaSelected:un,ariaSetSize:Be,ariaSort:null,ariaValueMax:Be,ariaValueMin:Be,ariaValueNow:Be,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function RC(e,t){return t in e?e[t]:t}function OC(e,t){return RC(e,t.toLowerCase())}const Y4=go({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ro,acceptCharset:Ut,accessKey:Ut,action:null,allow:null,allowFullScreen:gt,allowPaymentRequest:gt,allowUserMedia:gt,alt:null,as:null,async:gt,autoCapitalize:null,autoComplete:Ut,autoFocus:gt,autoPlay:gt,blocking:Ut,capture:null,charSet:null,checked:gt,cite:null,className:Ut,cols:Be,colSpan:null,content:null,contentEditable:un,controls:gt,controlsList:Ut,coords:Be|ro,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gt,defer:gt,dir:null,dirName:null,disabled:gt,download:Vp,draggable:un,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gt,formTarget:null,headers:Ut,height:Be,hidden:Vp,high:Be,href:null,hrefLang:null,htmlFor:Ut,httpEquiv:Ut,id:null,imageSizes:null,imageSrcSet:null,inert:gt,inputMode:null,integrity:null,is:null,isMap:gt,itemId:null,itemProp:Ut,itemRef:Ut,itemScope:gt,itemType:Ut,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gt,low:Be,manifest:null,max:null,maxLength:Be,media:null,method:null,min:null,minLength:Be,multiple:gt,muted:gt,name:null,nonce:null,noModule:gt,noValidate:gt,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:gt,optimum:Be,pattern:null,ping:Ut,placeholder:null,playsInline:gt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gt,referrerPolicy:null,rel:Ut,required:gt,reversed:gt,rows:Be,rowSpan:Be,sandbox:Ut,scope:null,scoped:gt,seamless:gt,selected:gt,shadowRootClonable:gt,shadowRootDelegatesFocus:gt,shadowRootMode:null,shape:null,size:Be,sizes:null,slot:null,span:Be,spellCheck:un,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Be,step:null,style:null,tabIndex:Be,target:null,title:null,translate:null,type:null,typeMustMatch:gt,useMap:null,value:un,width:Be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ut,axis:null,background:null,bgColor:null,border:Be,borderColor:null,bottomMargin:Be,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:gt,declare:gt,event:null,face:null,frame:null,frameBorder:null,hSpace:Be,leftMargin:Be,link:null,longDesc:null,lowSrc:null,marginHeight:Be,marginWidth:Be,noResize:gt,noHref:gt,noShade:gt,noWrap:gt,object:null,profile:null,prompt:null,rev:null,rightMargin:Be,rules:null,scheme:null,scrolling:un,standby:null,summary:null,text:null,topMargin:Be,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Be,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:gt,disableRemotePlayback:gt,prefix:null,property:null,results:Be,security:null,unselectable:null},space:"html",transform:OC}),X4=go({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:ur,accentHeight:Be,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Be,amplitude:Be,arabicForm:null,ascent:Be,attributeName:null,attributeType:null,azimuth:Be,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Be,by:null,calcMode:null,capHeight:Be,className:Ut,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Be,diffuseConstant:Be,direction:null,display:null,dur:null,divisor:Be,dominantBaseline:null,download:gt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Be,enableBackground:null,end:null,event:null,exponent:Be,externalResourcesRequired:null,fill:null,fillOpacity:Be,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ro,g2:ro,glyphName:ro,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Be,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Be,horizOriginX:Be,horizOriginY:Be,id:null,ideographic:Be,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Be,k:Be,k1:Be,k2:Be,k3:Be,k4:Be,kernelMatrix:ur,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Be,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Be,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Be,overlineThickness:Be,paintOrder:null,panose1:null,path:null,pathLength:Be,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ut,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Be,pointsAtY:Be,pointsAtZ:Be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ur,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ur,rev:ur,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ur,requiredFeatures:ur,requiredFonts:ur,requiredFormats:ur,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Be,specularExponent:Be,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Be,strikethroughThickness:Be,string:null,stroke:null,strokeDashArray:ur,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Be,strokeOpacity:Be,strokeWidth:null,style:null,surfaceScale:Be,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ur,tabIndex:Be,tableValues:null,target:null,targetX:Be,targetY:Be,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ur,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Be,underlineThickness:Be,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Be,values:null,vAlphabetic:Be,vMathematical:Be,vectorEffect:null,vHanging:Be,vIdeographic:Be,version:null,vertAdvY:Be,vertOriginX:Be,vertOriginY:Be,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Be,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:RC}),IC=go({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()}}),MC=go({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:OC}),PC=go({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Q4=/[A-Z]/g,W0=/-[a-z]/g,J4=/^data[-\w.:]+$/i;function Z4(e,t){const n=Fp(t);let r=t,a=er;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&J4.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(W0,tI);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!W0.test(l)){let u=l.replace(Q4,eI);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Ug}return new a(r,t)}function eI(e){return"-"+e.toLowerCase()}function tI(e){return e.charAt(1).toUpperCase()}const nI=LC([DC,Y4,IC,MC,PC],"html"),BC=LC([DC,X4,IC,MC,PC],"svg"),G0={}.hasOwnProperty;function rI(e,t){const n=t||{};function r(a,...l){let u=r.invalid;const c=r.handlers;if(a&&G0.call(a,e)){const d=String(a[e]);u=G0.call(c,d)?c[d]:r.unknown}if(u)return u.call(this,a,...l)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const sI=/["&'<>`]/g,iI=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,aI=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,oI=/[|\\{}()[\]^$+*?.]/g,q0=new WeakMap;function lI(e,t){if(e=e.replace(t.subset?cI(t.subset):sI,r),t.subset||t.escapeOnly)return e;return e.replace(iI,n).replace(aI,r);function n(a,l,u){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,u.charCodeAt(l+2),t)}function r(a,l,u){return t.format(a.charCodeAt(0),u.charCodeAt(l+1),t)}}function cI(e){let t=q0.get(e);return t||(t=uI(e),q0.set(e,t)),t}function uI(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(oI,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const dI=/[\dA-Fa-f]/;function hI(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!dI.test(String.fromCharCode(t))?r:r+";"}const fI=/\d/;function mI(e,t,n){const r="&#"+String(e);return n&&t&&!fI.test(String.fromCharCode(t))?r:r+";"}const pI=["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"],Ym={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:"€"},gI=["cent","copy","divide","gt","lt","not","para","times"],$C={}.hasOwnProperty,Gp={};let Tu;for(Tu in Ym)$C.call(Ym,Tu)&&(Gp[Ym[Tu]]=Tu);const xI=/[^\dA-Za-z]/;function yI(e,t,n,r){const a=String.fromCharCode(e);if($C.call(Gp,a)){const l=Gp[a],u="&"+l;return n&&pI.includes(l)&&!gI.includes(l)&&(!r||t&&t!==61&&xI.test(String.fromCharCode(t)))?u:u+";"}return""}function bI(e,t,n){let r=hI(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=yI(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=mI(e,t,n.omitOptionalSemicolons);l.length<r.length&&(r=l)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function so(e,t){return lI(e,Object.assign({format:bI},t))}const vI=/^>|^->|<!--|-->|--!>|<!-$/g,_I=[">"],SI=["<",">"];function wI(e,t,n,r){return r.settings.bogusComments?"<?"+so(e.value,Object.assign({},r.settings.characterReferences,{subset:_I}))+">":"<!--"+e.value.replace(vI,a)+"-->";function a(l){return so(l,Object.assign({},r.settings.characterReferences,{subset:SI}))}}function CI(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function K0(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function kI(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function jI(e){return e.join(" ").trim()}const EI=/[ \t\n\f\r]/g;function Fg(e){return typeof e=="object"?e.type==="text"?Y0(e.value):!1:Y0(e)}function Y0(e){return e.replace(EI,"")===""}const xn=HC(1),zC=HC(-1),NI=[];function HC(e){return t;function t(n,r,a){const l=n?n.children:NI;let u=(r||0)+e,c=l[u];if(!a)for(;c&&Fg(c);)u+=e,c=l[u];return c}}const TI={}.hasOwnProperty;function UC(e){return t;function t(n,r,a){return TI.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const Vg=UC({body:LI,caption:Xm,colgroup:Xm,dd:II,dt:OI,head:Xm,html:AI,li:RI,optgroup:MI,option:PI,p:DI,rp:X0,rt:X0,tbody:$I,td:Q0,tfoot:zI,th:Q0,thead:BI,tr:HI});function Xm(e,t,n){const r=xn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Fg(r.value.charAt(0)))}function AI(e,t,n){const r=xn(n,t);return!r||r.type!=="comment"}function LI(e,t,n){const r=xn(n,t);return!r||r.type!=="comment"}function DI(e,t,n){const r=xn(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function RI(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function OI(e,t,n){const r=xn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function II(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function X0(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function MI(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function PI(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function BI(e,t,n){const r=xn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function $I(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function zI(e,t,n){return!xn(n,t)}function HI(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Q0(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const UI=UC({body:WI,colgroup:GI,head:VI,html:FI,tbody:qI});function FI(e){const t=xn(e,-1);return!t||t.type!=="comment"}function VI(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 WI(e){const t=xn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Fg(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function GI(e,t,n){const r=zC(n,t),a=xn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Vg(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function qI(e,t,n){const r=zC(n,t),a=xn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Vg(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const Au={name:[[`
|
|
99
|
+
\f\r &/=>`.split(""),`
|
|
100
|
+
\f\r "&'/=>\``.split("")],[`\0
|
|
101
|
+
\f\r "&'/<=>`.split(""),`\0
|
|
102
|
+
\f\r "&'/<=>\``.split("")]],unquoted:[[`
|
|
103
|
+
\f\r &>`.split(""),`\0
|
|
104
|
+
\f\r "&'<=>\``.split("")],[`\0
|
|
105
|
+
\f\r "&'<=>\``.split(""),`\0
|
|
106
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function KI(e,t,n,r){const a=r.schema,l=a.space==="svg"?!1:r.settings.omitOptionalTags;let u=a.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const c=[];let d;a.space==="html"&&e.tagName==="svg"&&(r.schema=BC);const h=YI(r,e.properties),p=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,p&&(u=!1),(h||!l||!UI(e,t,n))&&(c.push("<",e.tagName,h?" "+h:""),u&&(a.space==="svg"||r.settings.closeSelfClosing)&&(d=h.charAt(h.length-1),(!r.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(p),!u&&(!l||!Vg(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function YI(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=XI(e,a,t[a]);l&&n.push(l)}}for(;++r<n.length;){const l=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&l!=='"'&&l!=="'"&&(n[r]+=" ")}return n.join("")}function XI(e,t,n){const r=Z4(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,l=e.settings.allowDangerousCharacters?0:1;let u=e.quote,c;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const d=so(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Au.name[a][l]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?kI:jI)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(c=so(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Au.unquoted[a][l]}))),c!==n&&(e.settings.quoteSmart&&K0(n,u)>K0(n,e.alternative)&&(u=e.alternative),c=u+so(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?Au.single:Au.double)[a][l],attribute:!0}))+u),d+(c&&"="+c))}const QI=["<","&"];function FC(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:so(e.value,Object.assign({},r.settings.characterReferences,{subset:QI}))}function JI(e,t,n,r){return r.settings.allowDangerousHtml?e.value:FC(e,t,n,r)}function ZI(e,t,n,r){return r.all(e)}const eM=rI("type",{invalid:tM,unknown:nM,handlers:{comment:wI,doctype:CI,element:KI,raw:JI,root:ZI,text:FC}});function tM(e){throw new Error("Expected node, not `"+e+"`")}function nM(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const rM={},sM={},iM=[];function aM(e,t){const n=t||rM,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:oM,all:lM,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||q4,characterReferences:n.characterReferences||sM,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?BC:nI,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function oM(e,t,n){return eM(e,t,n,this)}function lM(e){const t=[],n=e&&e.children||iM;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const J0=/\s+/g;function VC(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(J0)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(J0);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const cM=/:?lang=["']([^"']+)["']/g,uM=/(?:```|~~~)([\w-]+)/g,dM=/\\begin\{([\w-]+)\}/g,hM=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function fM(e){const t=Vd(e,!0).map(([a])=>a);function n(a){if(a===e.length)return{line:t.length-1,character:t.at(-1).length};let l=a,u=0;for(const c of t){if(l<c.length)break;l-=c.length,u++}return{line:u,character:l}}function r(a,l){let u=0;for(let c=0;c<a;c++)u+=t[c].length;return u+=l,u}return{lines:t,indexToPos:n,posToIndex:r}}function mM(e,t,n){const r=new Set;for(const l of e.matchAll(cM)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(uM)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(dM)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(hM)){const u=l[1].toLowerCase().trim(),c=u.includes("/")?u.split("/").pop():u;c&&r.add(c)}if(!n)return[...r];const a=n.getBundledLanguages();return[...r].filter(l=>l&&a[l])}const pM=["color","background-color"];function gM(e,t){let n=0;const r=[];for(const a of t)a>n&&r.push({...e,content:e.content.slice(n,a),offset:e.offset+n}),n=a;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function xM(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,a)=>r-a);return n.length?e.map(r=>r.flatMap(a=>{const l=n.filter(u=>a.offset<u&&u<a.offset+a.content.length).map(u=>u-a.offset).sort((u,c)=>u-c);return l.length?gM(a,l):a})):e}function yM(e,t,n,r,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(p=>hd(e.variants[p])),c=new Set(u.flatMap(p=>Object.keys(p))),d={},h=(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&&pM.includes(x))if(r==="light-dark()"&&u.length>1){const w=t.findIndex(_=>_==="light"),C=t.findIndex(_=>_==="dark");if(w===-1||C===-1)throw new Vt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[x]=`light-dark(${u[w][x]||"inherit"}, ${u[C][x]||"inherit"})`,a==="css-vars"&&(d[h(m,x)]=y)}else d[x]=y;else a==="css-vars"&&(d[h(m,x)]=y)}}),l.htmlStyle=d,l}function hd(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&On.Italic&&(t["font-style"]="italic"),e.fontStyle&On.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&On.Underline&&n.push("underline"),e.fontStyle&On.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function qp(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function bM(){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 Vt(`Invalid decoration offset: ${c}. Code length: ${n.source.length}`);return{...a.indexToPos(c),offset:c}}else{const d=a.lines[c.line];if(d===void 0)throw new Vt(`Invalid decoration position ${JSON.stringify(c)}. Lines length: ${a.lines.length}`);let h=c.character;if(h<0&&(h=d.length+h),h<0||h>d.length)throw new Vt(`Invalid decoration position ${JSON.stringify(c)}. Line ${c.line} length: ${d.length}`);return{...c,character:h,offset:a.posToIndex(c.line,h)}}};var r=l;const a=fM(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));vM(u),e.set(n.meta,{decorations:u,converter:a,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){var r;if((r=this.options.decorations)!=null&&r.length)return xM(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),a=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(a.length!==r.converter.lines.length)throw new Vt(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function l(m,x,y,w){const C=a[m];let _="",S=-1,v=-1;if(x===0&&(S=0),y===0&&(v=0),y===Number.POSITIVE_INFINITY&&(v=C.children.length),S===-1||v===-1)for(let j=0;j<C.children.length;j++)_+=WC(C.children[j]),S===-1&&_.length===x&&(S=j+1),v===-1&&_.length===y&&(v=j+1);if(S===-1)throw new Vt(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(v===-1)throw new Vt(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const b=C.children.slice(S,v);if(!w.alwaysWrap&&b.length===C.children.length)c(C,w,"line");else if(!w.alwaysWrap&&b.length===1&&b[0].type==="element")c(b[0],w,"token");else{const j={type:"element",tagName:"span",properties:{},children:b};c(j,w,"wrapper"),C.children.splice(S,b.length,j)}}function u(m,x){a[m]=c(a[m],x,"line")}function c(m,x,y){var _;const w=x.properties||{},C=x.transform||(S=>S);return m.tagName=x.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(_=x.properties)!=null&&_.class&&VC(m,x.properties.class),m=C(m,y)||m,m}const d=[],h=r.decorations.sort((m,x)=>x.start.offset-m.start.offset||m.end.offset-x.end.offset);for(const m of h){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 vM(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Vt(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const a=e[r],l=n.start.offset<=a.start.offset&&a.start.offset<n.end.offset,u=n.start.offset<a.end.offset&&a.end.offset<=n.end.offset,c=a.start.offset<=n.start.offset&&n.start.offset<a.end.offset,d=a.start.offset<n.end.offset&&n.end.offset<=a.end.offset;if(l||u||c||d){if(l&&u||c&&d||c&&n.start.offset===n.end.offset||u&&a.start.offset===a.end.offset)continue;throw new Vt(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function WC(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(WC).join(""):""}const _M=[bM()];function fd(e){const t=SM(e.transformers||[]);return[...t.pre,...t.normal,...t.post,..._M]}function SM(e){const t=[],n=[],r=[];for(const a of e)switch(a.enforce){case"pre":t.push(a);break;case"post":n.push(a);break;default:r.push(a)}return{pre:t,post:n,normal:r}}var Wi=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Qm={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function wM(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 Z0(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 CM(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)Qm[r]&&t.push({type:"setDecoration",value:Qm[r]});else if(r<=29){const a=Qm[r-20];a&&(t.push({type:"resetDecoration",value:a}),a==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Wi[r-30]}});else if(r===38){const a=Z0(e);a&&t.push({type:"setForegroundColor",value:a})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Wi[r-40]}});else if(r===48){const a=Z0(e);a&&t.push({type:"setBackgroundColor",value:a})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:Wi[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Wi[r-100+8]}})}return t}function kM(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let l=0;do{const u=wM(r,l),c=u.sequence?r.substring(l,u.startPosition):r.substring(l);if(c.length>0&&a.push({value:c,foreground:e,background:t,decorations:new Set(n)}),u.sequence){const d=CM(u.sequence);for(const h of d)h.type==="resetAll"?(e=null,t=null,n.clear()):h.type==="resetForegroundColor"?e=null:h.type==="resetBackgroundColor"?t=null:h.type==="resetDecoration"&&n.delete(h.value);for(const h of d)h.type==="setForegroundColor"?e=h.value:h.type==="setBackgroundColor"?t=h.value:h.type==="setDecoration"&&n.add(h.value)}l=u.position}while(l<r.length);return a}}}var jM={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 EM(e=jM){function t(c){return e[c]}function n(c){return`#${c.map(d=>Math.max(0,Math.min(d,255)).toString(16).padStart(2,"0")).join("")}`}let r;function a(){if(r)return r;r=[];for(let h=0;h<Wi.length;h++)r.push(t(Wi[h]));let c=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([c[h],c[p],c[m]]));let d=8;for(let h=0;h<24;h++,d+=10)r.push(n([d,d,d]));return r}function l(c){return a()[c]}function u(c){switch(c.type){case"named":return t(c.name);case"rgb":return n(c.rgb);case"table":return l(c.index)}}return{value:u}}const NM=/#([0-9a-f]{3,8})/i,TM=/var\((--[\w-]+-ansi-[\w-]+)\)/,AM={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 LM(e,t,n){const r=dd(e,n),a=Vd(t),l=EM(Object.fromEntries(Wi.map(c=>{var h;const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((h=e.colors)==null?void 0:h[d])||AM[c]]}))),u=kM();return a.map(c=>u.parse(c[0]).map(d=>{let h,p;d.decorations.has("reverse")?(h=d.background?l.value(d.background):e.bg,p=d.foreground?l.value(d.foreground):e.fg):(h=d.foreground?l.value(d.foreground):e.fg,p=d.background?l.value(d.background):void 0),h=hi(h,r),p=hi(p,r),d.decorations.has("dim")&&(h=DM(h));let m=On.None;return d.decorations.has("bold")&&(m|=On.Bold),d.decorations.has("italic")&&(m|=On.Italic),d.decorations.has("underline")&&(m|=On.Underline),d.decorations.has("strikethrough")&&(m|=On.Strikethrough),{content:d.value,offset:c[1],color:h,bgColor:p,fontStyle:m}}))}function DM(e){const t=e.match(NM);if(t){const r=t[1];if(r.length===8){const a=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${a}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const a=r[0],l=r[1],u=r[2],c=r[3];return`#${a}${a}${l}${l}${u}${u}${Math.round(Number.parseInt(`${c}${c}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],l=r[1],u=r[2];return`#${a}${a}${l}${l}${u}${u}80`}}}const n=e.match(TM);return n?`var(${n[1]}-dim)`:e}function Kp(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!Ud(r)&&!Fd(a)&&r==="ansi"){const{theme:l}=e.setTheme(a);return LM(l,t,n)}return TC(e,t,n)}function md(e,t,n){let r,a,l,u,c,d;if("themes"in n){const{defaultColor:h="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,v)=>S.color===h?-1:v.color===h?1:0);if(x.length===0)throw new Vt("`themes` option must not be empty");const y=AC(e,t,n,Kp);if(d=Wl(y),h&&h!=="light-dark()"&&!x.some(S=>S.color===h))throw new Vt(`\`themes\` option must contain the defaultColor key \`${h}\``);const w=x.map(S=>e.getTheme(S.theme)),C=x.map(S=>S.color);l=y.map(S=>S.map(v=>yM(v,C,p,h,m))),d&&Wd(l,d);const _=x.map(S=>dd(S.theme,n));a=eS(x,w,_,p,h,"fg",m),r=eS(x,w,_,p,h,"bg",m),u=`shiki-themes ${w.map(S=>S.name).join(" ")}`,c=h?void 0:[a,r].join(";")}else if("theme"in n){const h=dd(n.theme,n);l=Kp(e,t,n);const p=e.getTheme(n.theme);r=hi(p.bg,h),a=hi(p.fg,h),u=p.name,d=Wl(l)}else throw new Vt("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:r,themeName:u,rootStyle:c,grammarState:d}}function eS(e,t,n,r,a,l,u){return e.map((c,d)=>{const h=hi(t[d][l],n[d])||"inherit",p=`${r+c.color}${l==="bg"?"-bg":""}:${h}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(y=>y.color==="light"),x=e.findIndex(y=>y.color==="dark");if(m===-1||x===-1)throw new Vt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${hi(t[m][l],n[m])||"inherit"}, ${hi(t[x][l],n[x])||"inherit"});${p}`}return h}return u==="css-vars"?p:null}).filter(c=>!!c).join(";")}const GC=/^\s+$/,RM=/^(\s*)(.*?)(\s*)$/;function pd(e,t,n,r={meta:{},options:n,codeToHast:(a,l)=>pd(e,a,l),codeToTokens:(a,l)=>md(e,a,l)}){var w,C;let a=t;for(const _ of fd(n))a=((w=_.preprocess)==null?void 0:w.call(r,a,n))||a;let{tokens:l,fg:u,bg:c,themeName:d,rootStyle:h,grammarState:p}=md(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:x=!1}=n;m===!0?l=IM(l):m==="never"&&(l=MM(l)),x&&(l=PM(l));const y={...r,get source(){return a}};for(const _ of fd(n))l=((C=_.tokens)==null?void 0:C.call(y,l))||l;return OM(l,{...n,fg:u,bg:c,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},y,p)}function OM(e,t,n,r=Wl(e)){var C,_,S,v;const a=fd(t),l=[],u={type:"root",children:[]},{structure:c="classic",tabindex:d="0"}=t,h={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?h.style=t.rootStyle:h.style=`background-color:${t.bg};color:${t.fg}`),d!==!1&&d!=null&&(h.tabindex=d.toString());for(const[b,j]of Object.entries(t.meta||{}))b.startsWith("_")||(h[b]=j);let p={type:"element",tagName:"pre",properties:h,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const x=[],y={...n,structure:c,addClassToHast:VC,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((b,j)=>{var D,L;j&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
|
|
107
|
+
`}));let N={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(const I of b){let M={type:"element",tagName:"span",properties:{...I.htmlAttrs},children:[{type:"text",value:I.content}]};const G=qp(I.htmlStyle||hd(I));G&&(M.properties.style=G);for(const U of a)M=((D=U==null?void 0:U.span)==null?void 0:D.call(y,M,j+1,T,N,I))||M;c==="inline"?u.children.push(M):c==="classic"&&N.children.push(M),T+=I.content.length}if(c==="classic"){for(const I of a)N=((L=I==null?void 0:I.line)==null?void 0:L.call(y,N,j+1))||N;x.push(N),l.push(N)}else c==="inline"&&x.push(N)}),c==="classic"){for(const b of a)m=((C=b==null?void 0:b.code)==null?void 0:C.call(y,m))||m;p.children.push(m);for(const b of a)p=((_=b==null?void 0:b.pre)==null?void 0:_.call(y,p))||p;u.children.push(p)}else if(c==="inline"){const b=[];let j={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const T of u.children)T.type==="element"&&T.tagName==="br"?(b.push(j),j={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(T.type==="element"||T.type==="text")&&j.children.push(T);b.push(j);let N={type:"element",tagName:"code",properties:{},children:b};for(const T of a)N=((S=T==null?void 0:T.code)==null?void 0:S.call(y,N))||N;u.children=[];for(let T=0;T<N.children.length;T++){T>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const D=N.children[T];D.type==="element"&&u.children.push(...D.children)}}let w=u;for(const b of a)w=((v=b==null?void 0:b.root)==null?void 0:v.call(y,w))||w;return r&&Wd(w,r),w}function IM(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((l,u)=>{const c=!(l.fontStyle&&(l.fontStyle&On.Underline||l.fontStyle&On.Strikethrough));c&&GC.test(l.content)&&t[u+1]?(a===void 0&&(a=l.offset),r+=l.content):r?(c?n.push({...l,offset:a,content:r+l.content}):n.push({content:r,offset:a},l),a=void 0,r=""):n.push(l)}),n})}function MM(e){return e.map(t=>t.flatMap(n=>{if(GC.test(n.content))return n;const r=n.content.match(RM);if(!r)return n;const[,a,l,u]=r;if(!a&&!u)return n;const c=[{...n,offset:n.offset+a.length,content:l}];return a&&c.unshift({content:a,offset:n.offset}),u&&c.push({content:u,offset:n.offset+a.length+l.length}),c}))}function PM(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const a=n.at(-1),l=qp(a.htmlStyle||hd(a)),u=qp(r.htmlStyle||hd(r)),c=a.fontStyle&&(a.fontStyle&On.Underline||a.fontStyle&On.Strikethrough),d=r.fontStyle&&(r.fontStyle&On.Underline||r.fontStyle&On.Strikethrough);!c&&!d&&l===u?a.content+=r.content:n.push({...r})}return n})}const BM=aM;function $M(e,t,n){var l;const r={meta:{},options:n,codeToHast:(u,c)=>pd(e,u,c),codeToTokens:(u,c)=>md(e,u,c)};let a=BM(pd(e,t,n,r));for(const u of fd(n))a=((l=u.postprocess)==null?void 0:l.call(r,a,n))||a;return a}async function zM(e){const t=await I4(e);return{getLastGrammarState:(...n)=>z4(t,...n),codeToTokensBase:(n,r)=>Kp(t,n,r),codeToTokensWithThemes:(n,r)=>AC(t,n,r),codeToTokens:(n,r)=>md(t,n,r),codeToHast:(n,r)=>pd(t,n,r),codeToHtml:(n,r)=>$M(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function HM(e){const t=e.langs,n=e.themes,r=e.engine;async function a(l){function u(m){var x;if(typeof m=="string"){if(m=((x=l.langAlias)==null?void 0:x[m])||m,SC(m))return[];const y=t[m];if(!y)throw new Vt(`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(wC(m))return"none";if(typeof m=="string"){const x=n[m];if(!x)throw new Vt(`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)),h=(l.langs??[]).map(m=>u(m)),p=await zM({engine:l.engine??r(),...l,themes:d,langs:h});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(u))},loadTheme(...m){return p.loadTheme(...m.map(c))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function UM(e){let t;async function n(r={}){if(t){const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}else{t=e({...r,themes:[],langs:[]});const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}}return n}function FM(e,t){const n=UM(e);async function r(a,l){var d;const u=await n({langs:[l.lang],themes:"theme"in l?[l.theme]:Object.values(l.themes)}),c=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,a,l.lang,u));return c&&await u.loadLanguage(...c),u}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,l){return(await r(a,l)).codeToHtml(a,l)},async codeToHast(a,l){return(await r(a,l)).codeToHast(a,l)},async codeToTokens(a,l){return(await r(a,l)).codeToTokens(a,l)},async codeToTokensBase(a,l){return(await r(a,l)).codeToTokensBase(a,l)},async codeToTokensWithThemes(a,l){return(await r(a,l)).codeToTokensWithThemes(a,l)},async getLastGrammarState(a,l){return(await n({langs:[l.lang],themes:[l.theme]})).getLastGrammarState(a,l)}}}var VM=Dg({bundledLanguages:()=>$d,bundledLanguagesAlias:()=>Og,bundledLanguagesBase:()=>Rg,bundledLanguagesInfo:()=>Bd,bundledThemes:()=>Mg,bundledThemesInfo:()=>Ig,codeToHast:()=>KC,codeToHtml:()=>qC,codeToTokens:()=>YC,codeToTokensBase:()=>XC,codeToTokensWithThemes:()=>QC,createHighlighter:()=>qd,getLastGrammarState:()=>ZC,getSingletonHighlighter:()=>JC});const qd=HM({langs:$d,themes:Mg,engine:()=>(0,iC.createOnigurumaEngine)(te(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:qC,codeToHast:KC,codeToTokens:YC,codeToTokensBase:XC,codeToTokensWithThemes:QC,getSingletonHighlighter:JC,getLastGrammarState:ZC}=FM(qd,{guessEmbeddedLanguages:mM}),tS=4294967295;var WM=class{constructor(e,t={}){be(this,"patterns");be(this,"options");be(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:a}=t;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(l=>{if(typeof l!="string")return l;const u=r==null?void 0:r.get(l);if(u){if(u instanceof RegExp)return u;if(n)return null;throw u}try{const c=a(l);return r==null||r.set(l,c),c}catch(c){if(r==null||r.set(l,c),n)return null;throw c}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function l(u,c,d=0){return{index:u,captureIndices:c.indices.map(h=>h==null?{start:tS,end:tS,length:0}:{start:h[0]+d,end:h[1]+d,length:h[1]-h[0]})}}for(let u=0;u<this.regexps.length;u++){const c=this.regexps[u];if(c)try{c.lastIndex=t;const d=c.exec(r);if(!d)continue;if(d.index===t)return l(u,d,0);a.push([u,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(a.length){const u=Math.min(...a.map(c=>c[1].index));for(const[c,d,h]of a)if(d.index===u)return l(c,d,h)}return null}};function xo(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function GM(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const Wg=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Sn=String.raw;function yo(e,t){if(e==null)throw new Error(t??"Value expected");return e}const ek=Sn`\[\^?`,tk=`c.? | C(?:-.?)?|${Sn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Sn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Sn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Sn`o\{[^\}]*\}?`}|${Sn`\d{1,3}`}`,Gg=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Lu=new RegExp(Sn`
|
|
108
|
+
\\ (?:
|
|
109
|
+
${tk}
|
|
110
|
+
| [gk]<[^>]*>?
|
|
111
|
+
| [gk]'[^']*'?
|
|
112
|
+
| .
|
|
113
|
+
)
|
|
114
|
+
| \( (?:
|
|
115
|
+
\? (?:
|
|
116
|
+
[:=!>({]
|
|
117
|
+
| <[=!]
|
|
118
|
+
| <[^>]*>
|
|
119
|
+
| '[^']*'
|
|
120
|
+
| ~\|?
|
|
121
|
+
| #(?:[^)\\]|\\.?)*
|
|
122
|
+
| [^:)]*[:)]
|
|
123
|
+
)?
|
|
124
|
+
| \*[^\)]*\)?
|
|
125
|
+
)?
|
|
126
|
+
| (?:${Gg.source})+
|
|
127
|
+
| ${ek}
|
|
128
|
+
| .
|
|
129
|
+
`.replace(/\s+/g,""),"gsu"),Jm=new RegExp(Sn`
|
|
130
|
+
\\ (?:
|
|
131
|
+
${tk}
|
|
132
|
+
| .
|
|
133
|
+
)
|
|
134
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
135
|
+
| ${ek}
|
|
136
|
+
| &&
|
|
137
|
+
| .
|
|
138
|
+
`.replace(/\s+/g,""),"gsu");function qM(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=hP(n.flags),a=[r.extended],l={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(m){a.push(m)},replaceCurrentModX(m){a[a.length-1]=m},singleline:n.rules.singleline};let u=[],c;for(Lu.lastIndex=0;c=Lu.exec(e);){const m=KM(l,e,c[0],Lu.lastIndex);m.tokens?u.push(...m.tokens):m.token&&u.push(m.token),m.lastIndex!==void 0&&(Lu.lastIndex=m.lastIndex)}const d=[];let h=0;u.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++h:m.raw==="("&&d.push(m)}),h||d.forEach((m,x)=>{m.kind="capturing",m.number=x+1});const p=h||d.length;return{tokens:u.map(m=>m.type==="EscapedNumber"?mP(m,p):m).flat(),flags:r}}function KM(e,t,n,r){const[a,l]=n;if(n==="["||n==="[^"){const u=YM(t,n,r);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:nS(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:iP(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:rk(n)}}if(l==="K")return{token:sk("keep",n)};if(l==="N"||l==="R")return{token:Gi("newline",n,{negate:l==="N"})};if(l==="O")return{token:Gi("any",n)};if(l==="X")return{token:Gi("text_segment",n)};const u=nk(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(a==="("){if(l==="*")return{token:cP(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:lP(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Ja("group",n)};if(n==="(?>")return{token:Ja("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Ja(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Ja("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Ja("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:nP(n)}}if(e.getCurrentModX()){if(n==="#"){const u=t.indexOf(`
|
|
139
|
+
`,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:Gi("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":Sn`\A`,$:Sn`\Z`}[n]:n;return{token:nS(u,n)}}return n==="|"?{token:QM(n)}:Gg.test(n)?{tokens:pP(n)}:{token:ks(xo(n),n)}}function YM(e,t,n){const r=[rS(t[1]==="^",t)];let a=1,l;for(Jm.lastIndex=n;l=Jm.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")a++,r.push(rS(u[1]==="^",u));else if(u==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(ks(93,u));else if(a--,r.push(JM(u)),!a)break}else{const c=XM(u);Array.isArray(c)?r.push(...c):r.push(c)}}return{tokens:r,lastIndex:Jm.lastIndex||e.length}}function XM(e){if(e[0]==="\\")return nk(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Wg.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Gi("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?ZM(e):e==="&&"?eP(e):ks(xo(e),e)}function nk(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return oP(e);if("dDhHsSwW".includes(n))return uP(e);if(e.startsWith(Sn`\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 dP(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(u=>parseInt(u,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),l=new TextEncoder;return[...a].map(u=>{const c=[...l.encode(u)].map(d=>`\\x${d.toString(16)}`).join("");return ks(xo(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return ks(fP(e),e);if(sS.has(n))return ks(sS.get(n),e);if(/\d/.test(n))return tP(t,e);if(e==="\\")throw new Error(Sn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return ks(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function QM(e){return{type:"Alternator",raw:e}}function nS(e,t){return{type:"Assertion",kind:e,raw:t}}function rk(e){return{type:"Backreference",raw:e}}function ks(e,t){return{type:"Character",value:e,raw:t}}function JM(e){return{type:"CharacterClassClose",raw:e}}function ZM(e){return{type:"CharacterClassHyphen",raw:e}}function eP(e){return{type:"CharacterClassIntersector",raw:e}}function rS(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Gi(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function sk(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:yo(n.flags),raw:t}}function tP(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function nP(e){return{type:"GroupClose",raw:e}}function Ja(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function rP(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function sP(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function iP(e){return{type:"Subroutine",raw:e}}const aP=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),sS=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function oP(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 ks(xo(t.toUpperCase())-64,e)}function lP(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const a=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),l=aS(n),u=aS(r),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(a),sk("flags",e,{flags:c});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Ja("group",e,{...(l||u)&&{flags:c}});throw new Error(`Unexpected flag modifier "${e}"`)}function cP(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:a}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const l=a?a.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[u,c,d]=l,h=aP.has(n)?n.toLowerCase():"custom";switch(h){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 "${h}"`)}return rP(h,r??null,(a==null?void 0:a.split(","))??null,e)}function iS(e){let t=null,n,r;if(e[0]==="{"){const{minStr:a,maxStr:l}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,u=1e5;if(+a>u||l&&+l>u)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+a,r=l===void 0?+a:l===""?1/0:+l,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return sP(t,n,r,e)}function uP(e){const t=e[1].toLowerCase();return Gi({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function dP(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Gi("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function aS(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 hP(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 fP(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 mP(e,t){const{raw:n,inCharClass:r}=e,a=n.slice(1);if(!r&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[rk(n)];const l=[],u=a.match(/^[0-7]+|\d/g);for(let c=0;c<u.length;c++){const d=u[c];let h;if(c===0&&d!=="8"&&d!=="9"){if(h=parseInt(d,8),h>127)throw new Error(Sn`Octal encoded byte above 177 unsupported "${n}"`)}else h=xo(d);l.push(ks(h,(c===0?"\\":"")+d))}return l}function pP(e){const t=[],n=new RegExp(Gg,"gy");let r;for(;r=n.exec(e);){const a=r[0];if(a[0]==="{"){const l=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(l){const{min:u,max:c}=l.groups;if(+u>+c&&a.endsWith("?")){n.lastIndex--,t.push(iS(a.slice(0,-1)));continue}}}t.push(iS(a))}return t}function ik(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 gP(e){return xP.has(e.type)}const xP=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function ak(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=qM(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(x,y)=>{const w=r.tokens[l.nextIndex];switch(l.parent=x,l.nextIndex++,w.type){case"Alternator":return Zi();case"Assertion":return yP(w);case"Backreference":return bP(w,l);case"Character":return Kd(w.value,{useLastValid:!!y.isCheckingRangeEnd});case"CharacterClassHyphen":return vP(w,l,y);case"CharacterClassOpen":return _P(w,l,y);case"CharacterSet":return SP(w,l);case"Directive":return NP(w.kind,{flags:w.flags});case"GroupOpen":return wP(w,l,y);case"NamedCallout":return AP(w.kind,w.tag,w.arguments);case"Quantifier":return CP(w,l);case"Subroutine":return kP(w,l);default:throw new Error(`Unexpected token type "${w.type}"`)}},l={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},u=DP(TP(r.flags));let c=u.body[0];for(;l.nextIndex<r.tokens.length;){const x=a(c,{});x.type==="Alternative"?(u.body.push(x),c=x):c.body.push(x)}const{capturingGroups:d,hasNumberedRef:h,namedGroupsByName:p,subroutines:m}=l;if(h&&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(Sn`Subroutine uses a duplicate group name "\g<${x}>"`);p.get(x)[0].isSubroutined=!0}else throw new Error(Sn`Subroutine uses a group name that's not defined "\g<${x}>"`);return u}function yP({kind:e}){return Yp(yo({"^":"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===Sn`\B`||e===Sn`\Y`})}function bP({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),a=(l,u=!1)=>{const c=t.capturingGroups.length;let d=!1;if(l>c)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Xp(u?c+1-l:l,{orphan:d})};if(n){const l=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(l)return a(+l.groups.num,!!l.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return Xp(r)}return a(+r)}function vP(e,t,n){const{tokens:r,walk:a}=t,l=t.parent,u=l.body.at(-1),c=r[t.nextIndex];if(!n.isCheckingRangeEnd&&u&&u.type!=="CharacterClass"&&u.type!=="CharacterClassRange"&&c&&c.type!=="CharacterClassOpen"&&c.type!=="CharacterClassClose"&&c.type!=="CharacterClassIntersector"){const d=a(l,{...n,isCheckingRangeEnd:!0});if(u.type==="Character"&&d.type==="Character")return l.body.pop(),EP(u,d);throw new Error("Invalid character class range")}return Kd(xo("-"))}function _P({negate:e},t,n){const{tokens:r,walk:a}=t,l=[Qu()],u=r[t.nextIndex];let c=cS(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(Qu()),t.nextIndex++;else{const h=l.at(-1);h.body.push(a(h,n))}c=cS(r[t.nextIndex],u)}const d=Qu({negate:e});return l.length===1?d.body=l[0].body:(d.kind="intersection",d.body=l.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,d}function SP({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u}=r;if(e==="property"){const c=Yd(n);if(Wg.has(c)&&!(u!=null&&u.has(c)))e="posix",n=c;else return Za(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u})}return e==="posix"?LP(n,{negate:t}):Qp(e,{negate:t})}function wP(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,d=RP(e),h=d.type==="AbsenceFunction",p=lS(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&GM(l,d.name,[]).push(d)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let x=uS(r[t.nextIndex]);for(;x.type!=="GroupClose";){if(x.type==="Alternator")d.body.push(Zi()),t.nextIndex++;else{const y=d.body.at(-1),w=c(y,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,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(oS(w)||w.type==="CapturingGroup")throw new Error(C)}else if(oS(w)||lS(w)&&w.negate)throw new Error(C)}}x=uS(r[t.nextIndex])}return t.nextIndex++,d}function CP({kind:e,min:t,max:n},r){const a=r.parent,l=a.body.at(-1);if(!l||!gP(l))throw new Error("Quantifier requires a repeatable token");const u=lk(e,t,n,l);return a.body.pop(),u}function kP({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let a=e.slice(3,-1);const l=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(l){const c=+l.groups.num,d=n.length;if(t.hasNumberedRef=!0,a={"":c,"+":d+c,"-":d+1-c}[l.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const u=ck(a);return r.push(u),u}function jP(e,t){return{type:"AbsenceFunction",kind:e,body:sc(t==null?void 0:t.body)}}function Zi(e){return{type:"Alternative",body:uk(e==null?void 0:e.body)}}function Yp(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function Xp(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function ok(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!OP(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:sc(t==null?void 0:t.body)}}function Kd(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 Qu(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:uk(e==null?void 0:e.body)}}function EP(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Qp(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 NP(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:yo(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function TP(e){return{type:"Flags",...e}}function Mr(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:sc(e==null?void 0:e.body)}}function Vi(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:sc(e==null?void 0:e.body)}}function AP(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function LP(e,t){const n=!!(t!=null&&t.negate);if(!Wg.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function lk(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 DP(e,t){return{type:"Regex",body:sc(t==null?void 0:t.body),flags:e}}function ck(e){return{type:"Subroutine",ref:e}}function Za(e,t){var a;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(a=n.unicodePropertyMap)==null?void 0:a.get(Yd(e));if(!r){if(n.normalizeUnknownPropertyNames)r=IP(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Sn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function RP({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return jP("repeater");case"atomic":return Mr({atomic:!0});case"capturing":return ok(a,{name:n});case"group":return Mr({flags:e});case"lookahead":case"lookbehind":return Vi({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function sc(e){if(e===void 0)e=[Zi()];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 uk(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 oS(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function lS(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function OP(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function IP(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 Yd(e){return e.replace(/[- _]+/g,"").toLowerCase()}function cS(e,t){const n=t;return yo(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function uS(e){return yo(e,"Unclosed group")}function Rl(e,t,n=null){function r(l,u){for(let c=0;c<l.length;c++){const d=a(l[c],u,c,l);c=Math.max(-1,c+d)}}function a(l,u=null,c=null,d=null){var S,v;let h=0,p=!1;const m={node:l,parent:u,key:c,container:d,root:e,remove(){Du(d).splice(Math.max(0,Va(c)+h),1),h--,p=!0},removeAllNextSiblings(){return Du(d).splice(Va(c)+1)},removeAllPrevSiblings(){const b=Va(c)+h;return h-=b,Du(d).splice(0,Math.max(0,b))},replaceWith(b,j={}){const N=!!j.traverse;d?d[Math.max(0,Va(c)+h)]=b:yo(u,"Can't replace root node")[c]=b,N&&a(b,u,c,d),p=!0},replaceWithMultiple(b,j={}){const N=!!j.traverse;if(Du(d).splice(Math.max(0,Va(c)+h),1,...b),h+=b.length-1,N){let T=0;for(let D=0;D<b.length;D++)T+=a(b[D],u,Va(c)+D+T,d)}p=!0},skip(){p=!0}},{type:x}=l,y=t["*"],w=t[x],C=typeof y=="function"?y:y==null?void 0:y.enter,_=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(m,n),_==null||_(m,n),!p)switch(x){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(l.body,l);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(l.min,l,"min"),a(l.max,l,"max");break;case"Quantifier":a(l.body,l,"body");break;case"Regex":r(l.body,l),a(l.flags,l,"flags");break;default:throw new Error(`Unexpected node type "${x}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,m,n),(v=y==null?void 0:y.exit)==null||v.call(y,m,n),h}return a(e),e}function Du(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Va(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const MP=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function PP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function BP(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const Er=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function qg(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let u=0,c="";for(const d of e.matchAll(a)){const{0:h,groups:{$skip:p}}=d;if(!p&&(!r||r===Er.DEFAULT==!u)){n instanceof Function?c+=n(d,{context:u?Er.CHAR_CLASS:Er.DEFAULT,negated:l[l.length-1]}):c+=n;continue}h[0]==="["?(u++,l.push(h[1]==="^")):h==="]"&&u&&(u--,l.pop()),c+=h}return c}function dk(e,t,n,r){qg(e,t,n,r)}function $P(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=n;let l=0,u;for(;u=a.exec(e);){const{0:c,groups:{$skip:d}}=u;if(!d&&(!r||r===Er.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,a.lastIndex==u.index&&a.lastIndex++}return null}function Ru(e,t,n){return!!$P(e,t,0,n)}function zP(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,a=0,l=1,u;for(;u=n.exec(e);){const[c]=u;if(c==="[")a++;else if(a)c==="]"&&a--;else if(c==="(")l++;else if(c===")"&&(l--,!l)){r=u.index;break}}return e.slice(t,r)}const dS=new RegExp(String.raw`(?<noncapturingStart>${MP})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function HP(e,t){const n=(t==null?void 0:t.hiddenCaptures)??[];let r=(t==null?void 0:t.captureTransfers)??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const a="(?>",l="(?:(?=(",u=[0],c=[];let d=0,h=0,p=NaN,m;do{m=!1;let x=0,y=0,w=!1,C;for(dS.lastIndex=Number.isNaN(p)?0:p+l.length;C=dS.exec(e);){const{0:_,index:S,groups:{capturingStart:v,noncapturingStart:b}}=C;if(_==="[")x++;else if(x)_==="]"&&x--;else if(_===a&&!w)p=S,w=!0;else if(w&&b)y++;else if(v)w?y++:(d++,u.push(d+h));else if(_===")"&&w){if(!y){h++;const j=d+h;if(e=`${e.slice(0,p)}${l}${e.slice(p+a.length,S)}))<$$${j}>)${e.slice(S+1)}`,m=!0,c.push(j),PP(n,j),r.size){const N=new Map;r.forEach((T,D)=>{N.set(D>=j?D+1:D,T.map(L=>L>=j?L+1:L))}),r=N}break}y--}}}while(m);return n.push(...c),e=qg(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}`},Er.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const hk=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Zm=new RegExp(String.raw`
|
|
140
|
+
\\(?: \d+
|
|
141
|
+
| c[A-Za-z]
|
|
142
|
+
| [gk]<[^>]+>
|
|
143
|
+
| [pPu]\{[^\}]+\}
|
|
144
|
+
| u[A-Fa-f\d]{4}
|
|
145
|
+
| x[A-Fa-f\d]{2}
|
|
146
|
+
)
|
|
147
|
+
| \((?: \? (?: [:=!>]
|
|
148
|
+
| <(?:[=!]|[^>]+>)
|
|
149
|
+
| [A-Za-z\-]+:
|
|
150
|
+
| \(DEFINE\)
|
|
151
|
+
))?
|
|
152
|
+
| (?<qBase>${hk})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
153
|
+
| \\?.
|
|
154
|
+
`.replace(/\s+/g,""),"gsu");function UP(e){if(!new RegExp(`${hk}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",l=0,u;for(Zm.lastIndex=0;u=Zm.exec(e);){const{0:c,index:d,groups:{qBase:h,qMod:p,invalidQ:m}}=u;if(c==="[")l||(r=d),l++;else if(c==="]")l?l--:r=null;else if(!l)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${c}"`);let x=-1;if(/^\{\d+\}$/.test(h))e=BP(e,d+h.length,p,"");else{if(a===")"||a==="]"){const y=a===")"?n:r;if(y===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,y)}(?>${e.slice(y,d)}${h})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${h})${e.slice(d+c.length)}`;x+=4}Zm.lastIndex+=x}else c[0]==="("?t.push(d):c===")"&&(n=t.length?t.pop():null);a=c}return{pattern:e}}const kr=String.raw,FP=kr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Jp=kr`\(\?R=(?<rDepth>[^\)]+)\)|${FP}`,Xd=kr`\(\?<(?![=!])(?<captureName>[^>]+)>`,fk=kr`${Xd}|(?<unnamed>\()(?!\?)`,Bi=new RegExp(kr`${Xd}|${Jp}|\(\?|\\?.`,"gsu"),ep="Cannot use multiple overlapping recursions";function VP(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(Jp,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&Ru(e,kr`\(\?\(DEFINE\)`,Er.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=Ru(e,kr`\\[1-9]`,Er.DEFAULT),c=new Map,d=[];let h=!1,p=0,m=0,x;for(Bi.lastIndex=0;x=Bi.exec(e);){const{0:y,groups:{captureName:w,rDepth:C,gRNameOrNum:_,gRDepth:S}}=x;if(y==="[")p++;else if(p)y==="]"&&p--;else if(C){if(hS(C),h)throw new Error(ep);if(u)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const v=e.slice(0,x.index),b=e.slice(Bi.lastIndex);if(Ru(b,Jp,Er.DEFAULT))throw new Error(ep);const j=+C-1;e=fS(v,b,j,!1,n,l,m),a=pS(a,v,j,l.length,0,m);break}else if(_){hS(S);let v=!1;for(const U of d)if(U.name===_||U.num===+_){if(v=!0,U.hasRecursedWithin)throw new Error(ep);break}if(!v)throw new Error(kr`Recursive \g cannot be used outside the referenced group "${r==="external"?_:kr`\g<${_}&R=${S}>`}"`);const b=c.get(_),j=zP(e,b);if(u&&Ru(j,kr`${Xd}|\((?!\?)`,Er.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const N=e.slice(b,x.index),T=j.slice(N.length+y.length),D=l.length,L=+S-1,I=fS(N,T,L,!0,n,l,m);a=pS(a,N,L,l.length-D,D,m);const M=e.slice(0,b),G=e.slice(b+j.length);e=`${M}${I}${G}`,Bi.lastIndex+=I.length-y.length-N.length-T.length,d.forEach(U=>U.hasRecursedWithin=!0),h=!0}else if(w)m++,c.set(String(m),Bi.lastIndex),c.set(w,Bi.lastIndex),d.push({num:m,name:w});else if(y[0]==="("){const v=y==="(";v&&(m++,c.set(String(m),Bi.lastIndex)),d.push(v?{num:m}:{})}else y===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function hS(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 fS(e,t,n,r,a,l,u){const c=new Set;r&&dk(e+t,Xd,({groups:{captureName:h}})=>{c.add(h)},Er.DEFAULT);const d=[n,r?c:null,a,l,u];return`${e}${mS(`(?:${e}`,"forward",...d)}(?:)${mS(`${t})`,"backward",...d)}${t}`}function mS(e,t,n,r,a,l,u){const d=p=>t==="forward"?p+2:n-p+2-1;let h="";for(let p=0;p<n;p++){const m=d(p);h+=qg(e,kr`${fk}|\\k<(?<backref>[^>]+)>`,({0:x,groups:{captureName:y,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return x;const _=`_$${m}`;if(w||y){const S=u+l.length+1;return l.push(S),WP(a,S),w?x:`(?<${y}${_}>`}return kr`\k<${C}${_}>`},Er.DEFAULT)}return h}function WP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function pS(e,t,n,r,a,l){if(e.size&&r){let u=0;dk(t,fk,()=>u++,Er.DEFAULT);const c=l-u+a,d=new Map;return e.forEach((h,p)=>{const m=(r-u*n)/n,x=u*n,y=p>c+u?p+r:p,w=[];for(const C of h)if(C<=c)w.push(C);else if(C>c+u+m)w.push(C+r);else if(C<=c+u)for(let _=0;_<=n;_++)w.push(C+u*_);else for(let _=0;_<=n;_++)w.push(C+x+m*_);d.set(y,w)}),d}return e}var gn=String.fromCodePoint,ht=String.raw,Br={},Qd=globalThis.RegExp;Br.flagGroups=(()=>{try{new Qd("(?i:)")}catch{return!1}return!0})();Br.unicodeSets=(()=>{try{new Qd("[[]]","v")}catch{return!1}return!0})();Br.bugFlagVLiteralHyphenIsRange=Br.unicodeSets?(()=>{try{new Qd(ht`[\d\-a]`,"v")}catch{return!0}return!1})():!1;Br.bugNestedClassIgnoresNegation=Br.unicodeSets&&new Qd("[[^a]]","v").test("a");function gd(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 Gl(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Zp(e,t){return gS[e]>=gS[t]}function GP(e,t){if(e==null)throw new Error(t??"Value expected");return e}var gS={ES2025:2025,ES2024:2024,ES2018:2018},qP={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function mk(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!qP[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=Br.flagGroups?"ES2025":Br.unicodeSets?"ES2024":"ES2018"),t}var KP="[ -\r ]",YP=new Set([gn(304),gn(305)]),ys=ht`[\p{L}\p{M}\p{N}\p{Pc}]`;function pk(e){if(YP.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=JP.get(n),l=XP.get(n),u=QP.get(n);return[...r].length===1&&t.add(r),u&&t.add(u),a&&t.add(a),t.add(n),l&&t.add(l),[...t]}var Kg=new Map(`C Other
|
|
155
|
+
Cc Control cntrl
|
|
156
|
+
Cf Format
|
|
157
|
+
Cn Unassigned
|
|
158
|
+
Co Private_Use
|
|
159
|
+
Cs Surrogate
|
|
160
|
+
L Letter
|
|
161
|
+
LC Cased_Letter
|
|
162
|
+
Ll Lowercase_Letter
|
|
163
|
+
Lm Modifier_Letter
|
|
164
|
+
Lo Other_Letter
|
|
165
|
+
Lt Titlecase_Letter
|
|
166
|
+
Lu Uppercase_Letter
|
|
167
|
+
M Mark Combining_Mark
|
|
168
|
+
Mc Spacing_Mark
|
|
169
|
+
Me Enclosing_Mark
|
|
170
|
+
Mn Nonspacing_Mark
|
|
171
|
+
N Number
|
|
172
|
+
Nd Decimal_Number digit
|
|
173
|
+
Nl Letter_Number
|
|
174
|
+
No Other_Number
|
|
175
|
+
P Punctuation punct
|
|
176
|
+
Pc Connector_Punctuation
|
|
177
|
+
Pd Dash_Punctuation
|
|
178
|
+
Pe Close_Punctuation
|
|
179
|
+
Pf Final_Punctuation
|
|
180
|
+
Pi Initial_Punctuation
|
|
181
|
+
Po Other_Punctuation
|
|
182
|
+
Ps Open_Punctuation
|
|
183
|
+
S Symbol
|
|
184
|
+
Sc Currency_Symbol
|
|
185
|
+
Sk Modifier_Symbol
|
|
186
|
+
Sm Math_Symbol
|
|
187
|
+
So Other_Symbol
|
|
188
|
+
Z Separator
|
|
189
|
+
Zl Line_Separator
|
|
190
|
+
Zp Paragraph_Separator
|
|
191
|
+
Zs Space_Separator
|
|
192
|
+
ASCII
|
|
193
|
+
ASCII_Hex_Digit AHex
|
|
194
|
+
Alphabetic Alpha
|
|
195
|
+
Any
|
|
196
|
+
Assigned
|
|
197
|
+
Bidi_Control Bidi_C
|
|
198
|
+
Bidi_Mirrored Bidi_M
|
|
199
|
+
Case_Ignorable CI
|
|
200
|
+
Cased
|
|
201
|
+
Changes_When_Casefolded CWCF
|
|
202
|
+
Changes_When_Casemapped CWCM
|
|
203
|
+
Changes_When_Lowercased CWL
|
|
204
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
205
|
+
Changes_When_Titlecased CWT
|
|
206
|
+
Changes_When_Uppercased CWU
|
|
207
|
+
Dash
|
|
208
|
+
Default_Ignorable_Code_Point DI
|
|
209
|
+
Deprecated Dep
|
|
210
|
+
Diacritic Dia
|
|
211
|
+
Emoji
|
|
212
|
+
Emoji_Component EComp
|
|
213
|
+
Emoji_Modifier EMod
|
|
214
|
+
Emoji_Modifier_Base EBase
|
|
215
|
+
Emoji_Presentation EPres
|
|
216
|
+
Extended_Pictographic ExtPict
|
|
217
|
+
Extender Ext
|
|
218
|
+
Grapheme_Base Gr_Base
|
|
219
|
+
Grapheme_Extend Gr_Ext
|
|
220
|
+
Hex_Digit Hex
|
|
221
|
+
IDS_Binary_Operator IDSB
|
|
222
|
+
IDS_Trinary_Operator IDST
|
|
223
|
+
ID_Continue IDC
|
|
224
|
+
ID_Start IDS
|
|
225
|
+
Ideographic Ideo
|
|
226
|
+
Join_Control Join_C
|
|
227
|
+
Logical_Order_Exception LOE
|
|
228
|
+
Lowercase Lower
|
|
229
|
+
Math
|
|
230
|
+
Noncharacter_Code_Point NChar
|
|
231
|
+
Pattern_Syntax Pat_Syn
|
|
232
|
+
Pattern_White_Space Pat_WS
|
|
233
|
+
Quotation_Mark QMark
|
|
234
|
+
Radical
|
|
235
|
+
Regional_Indicator RI
|
|
236
|
+
Sentence_Terminal STerm
|
|
237
|
+
Soft_Dotted SD
|
|
238
|
+
Terminal_Punctuation Term
|
|
239
|
+
Unified_Ideograph UIdeo
|
|
240
|
+
Uppercase Upper
|
|
241
|
+
Variation_Selector VS
|
|
242
|
+
White_Space space
|
|
243
|
+
XID_Continue XIDC
|
|
244
|
+
XID_Start XIDS`.split(/\s/).map(e=>[Yd(e),e])),XP=new Map([["s",gn(383)],[gn(383),"s"]]),QP=new Map([[gn(223),gn(7838)],[gn(107),gn(8490)],[gn(229),gn(8491)],[gn(969),gn(8486)]]),JP=new Map([ri(453),ri(456),ri(459),ri(498),...tp(8072,8079),...tp(8088,8095),...tp(8104,8111),ri(8124),ri(8140),ri(8188)]),ZP=new Map([["alnum",ht`[\p{Alpha}\p{Nd}]`],["alpha",ht`\p{Alpha}`],["ascii",ht`\p{ASCII}`],["blank",ht`[\p{Zs}\t]`],["cntrl",ht`\p{Cc}`],["digit",ht`\p{Nd}`],["graph",ht`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",ht`\p{Lower}`],["print",ht`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",ht`[\p{P}\p{S}]`],["space",ht`\p{space}`],["upper",ht`\p{Upper}`],["word",ht`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",ht`\p{AHex}`]]);function e6(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function ri(e){const t=gn(e);return[t.toLowerCase(),t]}function tp(e,t){return e6(e,t).map(n=>ri(n))}var gk=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function t6(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};xk(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Zp(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};Rl(e,n6,r);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},l={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};Rl(e,r6,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return Rl(e,s6,u),e._originMap=l.groupOriginByCopy,e._strategy=r.strategy,e}var n6={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const l=Mr();l.body[0].body.push(Vi({negate:!0,body:r}),Za("Any"));const u=Mr();u.body[0].body.push(lk("greedy",0,1/0,l)),n(nn(u,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const a=e.body.filter(l=>l.kind==="flags");for(let l=n+1;l<t.body.length;l++){const u=t.body[l];Gl(r,u,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=bk(t.get(e));if(r){const a=Mr({flags:r});a.body[0].body=e.body,e.body=[nn(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:l,replaceWith:u},c){const{kind:d,negate:h}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:x,wordIsAscii:y}=c;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(d==="line_end")u(nn(Vi({body:[Zi({body:[Yp("string_end")]}),Zi({body:[Kd(10)]})]}),t));else if(d==="line_start")u(nn(bs(ht`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(x.has(e))a.flags.sticky=!0,l();else{const w=r[n-1];if(w&&u6(w))u(nn(Vi({negate:!0}),t));else{if(m)throw new Error(ht`Uses "\G" in a way that requires a subclass`);u(si(Yp("string_start"),t)),c.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")u(nn(bs(ht`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!y&&!p){const w=`(?:(?<=${ys})(?!${ys})|(?<!${ys})(?=${ys}))`,C=`(?:(?<=${ys})(?=${ys})|(?<!${ys})(?!${ys}))`;u(nn(bs(h?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!rp(n)&&(n=np(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!rp(r)&&(r=np(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=Qu({body:[e]});n(nn(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:d,negate:h,value:p}=e;if(l&&(d==="digit"||p==="digit")){n(si(Qp("digit",{negate:h}),t));return}if(u&&(d==="space"||p==="space")){n(nn(sp(bs(KP),h),t));return}if(c&&(d==="word"||p==="word")){n(si(Qp("word",{negate:h}),t));return}if(d==="any")n(si(Za("Any"),t));else if(d==="digit")n(si(Za("Nd",{negate:h}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(ht`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",x=ht`\p{RI}{2}|${m}(?:\u200D${m})*`;n(nn(bs(ht`(?>\r\n|${a?ht`\p{RGI_Emoji}`:x}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(si(Za("AHex",{negate:h}),t));else if(d==="newline")n(nn(bs(h?`[^
|
|
245
|
+
]`:`(?>\r
|
|
246
|
+
?|[
|
|
247
|
+
\v\f
\u2028\u2029])`),t));else if(d==="posix")if(!a&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];h&&(m=`\0-${gn(m.codePointAt(0)-1)}${gn(m.codePointAt(2)+1)}-`),n(nn(bs(`[${m}]`),t))}else n(nn(sp(bs(ZP.get(p)),h),t));else if(d==="property")Kg.has(Yd(p))||(e.key="sc");else if(d==="space")n(si(Za("space",{negate:h}),t));else if(d==="word")n(nn(sp(bs(ys),h),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:a,removeAllPrevSiblings:l,removeAllNextSiblings:u}){const{kind:c,flags:d}=e;if(c==="flags")if(!d.enable&&!d.disable)r();else{const h=Mr({flags:d});h.body[0].body=u(),a(nn(h,t),{traverse:!0})}else if(c==="keep"){const h=n.body[0],m=n.body.length===1&&ik(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(ht`Uses "\K" in a way that's unsupported`);const x=Vi({behind:!0});x.body[0].body=l(),a(nn(x,t))}else throw new Error(`Unexpected directive kind "${c}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(nn(Vi({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=Mr();t.body[0].body.push(e.body),e.body=nn(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,a=!1;for(const l of e.body)if(l.body.length===1&&l.body[0].kind==="search_start")l.body.pop();else{const u=_k(l.body);u?(r=!0,Array.isArray(u)?n.push(...u):n.push(u)):a=!0}r&&!a&&n.forEach(l=>t.add(l))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(ht`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!rp(n)&&(n=np(n,t),e.ref=n)}},r6={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:a}=e;r||n.set(e,[...t.get(a).map(({node:l})=>l)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:a,groupsByName:l,multiplexCapturesToLeftByRef:u,openRefs:c,reffedNodesByReferencer:d}){const h=a.get(e);if(h&&c.has(e.number)){const m=si(xS(e.number),t);d.set(m,c.get(e.number)),n(m);return}c.set(e.number,e),u.set(e.number,[]),e.name&&Gl(u,e.name,[]);const p=u.get(e.name??e.number);for(let m=0;m<p.length;m++){const x=p[m];if(h===x.node||h&&h===x.origin||e===x.origin){p.splice(m,1);break}}if(u.get(e.number).push({node:e,origin:h}),e.name&&u.get(e.name).push({node:e,origin:h}),e.name){const m=Gl(l,e.name,new Map);let x=!1;if(h)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=gd(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:a,ref:l}=e;if(a){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===l||p.number===l)););r.reffedNodesByReferencer.set(e,p);return}const u=r.subroutineRefMap.get(l),c=l===0,d=c?xS(0):yk(u,r.groupOriginByCopy,null);let h=d;if(!c){const p=bk(o6(u,x=>x.type==="Group"&&!!x.flags)),m=p?gd(r.globalFlags,p):r.globalFlags;i6(m,r.currentFlags)||(h=Mr({flags:l6(m)}),h.body[0].body.push(d))}n(nn(h,t),{traverse:!c})}},s6={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=>a6(u,e));if(!l.length)n(nn(Vi({negate:!0}),t));else if(l.length>1){const u=Mr({atomic:!0,body:l.reverse().map(c=>Zi({body:[Xp(c.number)]}))});n(nn(u,t))}else e.ref=l[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const a=ok();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function xk(e){Rl(e,{"*"({node:t,parent:n}){t.parent=n}})}function i6(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function a6(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=vk(n.parent);for(const a of r){if(a===n)break;if(a===e||Sk(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function yk(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[l,u]of Object.entries(e))l==="parent"?a.parent=Array.isArray(n)?r:n:u&&typeof u=="object"?a[l]=yk(u,t,a,n):(l==="type"&&u==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=u);return a}function xS(e){const t=ck(e);return t.isRecursive=!0,t}function o6(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function np(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 bk(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var l,u;(l=r.enable)!=null&&l[a]&&(delete n.disable[a],n.enable[a]=!0),(u=r.disable)!=null&&u[a]&&(n.disable[a]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function l6({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 vk(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function _k(e){const t=e.find(n=>n.kind==="search_start"||d6(n,{negate:!1})||!c6(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const a=_k(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function Sk(e,t){const n=vk(e)??[];for(const r of n)if(r===t||Sk(r,t))return!0;return!1}function c6({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function u6(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function d6(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&ik(e.body[0],{type:"Assertion",kind:"search_start"})}function rp(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function bs(e,t){const r=ak(e,{...t,unicodePropertyMap:Kg}).body;return r.length>1||r[0].body.length>1?Mr({body:r}):r[0].body[0]}function sp(e,t){return e.negate=t,e}function si(e,t){return e.parent=t,e}function nn(e,t){return xk(e),e.parent=t,e}function h6(e,t){const n=mk(t),r=Zp(n.target,"ES2024"),a=Zp(n.target,"ES2025"),l=n.rules.recursionLimit;if(!Number.isInteger(l)||l<2||l>20)throw new Error("Invalid recursionLimit; use 2-20");let u=null,c=null;if(!a){const y=[e.flags.ignoreCase];Rl(e,f6,{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 h=e;const p={accuracy:n.accuracy,appliedGlobalFlags:d,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:h,originMap:e._originMap,recursionLimit:l,useAppliedIgnoreCase:!!(!a&&u&&c),useFlagMods:a,useFlagV:r,verbose:n.verbose};function m(y){return p.lastNode=h,h=y,GP(m6[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&&Gl(x._captureTransfers,y.transferTo,[]).push(w)}),x}var f6={"*":{enter({node:e},t){if(bS(e)){const n=t.getCurrentModI();t.pushModI(e.flags?gd({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){bS(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Yg(gn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),wk(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&gk.has(e.value)&&t.setHasCasedChar()}},m6={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?ht`\B`:ht`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:a,number:l}=e,u={ignoreCase:t.currentFlags.ignoreCase},c=t.originMap.get(e);return c&&(u.hidden=!0,l>c.number&&(u.transferTo=c.number)),t.captureMap.set(l,u),`(${a?`?<${a}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=gn(e),r=Wa(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Yg(n)){const a=pk(n);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:a,parent:l}=e;let{body:u}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Br.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&u.some(vS)&&(u=[Kd(45),...u.filter(h=>!vS(h))]);const c=()=>`[${a?"^":""}${u.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Br.bugNestedClassIgnoresNegation)&&!a){const p=u.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=Mr(),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=Zi({body:[y]});y.parent=w,w.parent=m,m.body.push(w)}),n(m)}}t.inCharClass=!0;const h=c();return t.inCharClass=!1,h}const d=u[0];if(r==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(Br.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&l.kind==="intersection"&&u.length===1&&d.type!=="CharacterClassRange"))return u.map(n).join("");if(!t.useFlagV&&l.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return c()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=Wa(n,a),u=Wa(r,a),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=wk(e);b6(d).forEach(p=>{c.add(Array.isArray(p)?`${Wa(p[0],a)}-${Wa(p[1],a)}`:Wa(p,a))})}return`${l}-${u}${[...c].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":ht`[^\n]`;if(e==="digit")return t?ht`\D`:ht`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&gk.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?ht`\P`:ht`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?ht`\W`:ht`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},a,l){const u=a.currentFlags;n&&(a.currentFlags=gd(u,n));const c=t.map(l).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?c:`(?${v6(e,n,a.useFlagMods)}${c})`;return a.currentFlags=u,d},LookaroundAssertion({body:e,kind:t,negate:n},r,a){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,t,n){return n(e.body)+_6(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})`:ht`\g<${t}&R=${r}>`}},p6=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),g6=new Set(["-","\\","]","^","["]),x6=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),yS=new Map([[9,ht`\t`],[10,ht`\n`],[11,ht`\v`],[12,ht`\f`],[13,ht`\r`],[8232,ht`\u2028`],[8233,ht`\u2029`],[65279,ht`\uFEFF`]]),y6=new RegExp("^\\p{Cased}$","u");function Yg(e){return y6.test(e)}function wk(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,a=e.max.value,l=[];if(r<65&&(a===65535||a>=131071)||r===65536&&a>=131071)return l;for(let u=r;u<=a;u++){const c=gn(u);if(!Yg(c))continue;const d=pk(c).filter(h=>{const p=h.codePointAt(0);return p<r||p>a});if(d.length&&(l.push(...d),n))break}return l}function Wa(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(yS.has(e))return yS.get(e);if(e<32||e>126&&e<160||e>262143||t&&S6(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?x6:g6:p6,l=gn(e);return(a.has(l)?"\\":"")+l}function b6(e){const t=e.map(a=>a.codePointAt(0)).sort((a,l)=>a-l),n=[];let r=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?r??(r=t[a]):r===null?n.push(t[a]):(n.push([r,t[a]]),r=null);return n}function v6(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:a,disable:l}=t;r=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(l?"-":"")+(l!=null&&l.ignoreCase?"i":"")+(l!=null&&l.dotAll?"s":"")}return`${r}:`}function _6({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 bS({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function S6(e){return e>47&&e<58}function vS({type:e,value:t}){return e==="Character"&&t===45}var ii,ws,qi,ai,Ki,Yl,eg,fi,w6=(fi=class extends RegExp{constructor(n,r,a){var t=(...az)=>(super(...az),Mi(this,Yl),Mi(this,ii,new Map),Mi(this,ws,null),Mi(this,qi),Mi(this,ai,null),Mi(this,Ki,null),be(this,"rawOptions",{}),this);const l=!!(a!=null&&a.lazyCompile);if(n instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const u=n;t(u,r),Dr(this,qi,u.source),u instanceof fi&&(Dr(this,ii,$n(u,ii)),Dr(this,ai,$n(u,ai)),Dr(this,Ki,$n(u,Ki)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,r),Dr(this,qi,n),Dr(this,ii,k6(u.hiddenCaptures,u.transfers)),Dr(this,Ki,u.strategy),this.rawOptions=a??{}}l||Dr(this,ws,this)}get source(){return $n(this,qi)||"(?:)"}exec(n){if(!$n(this,ws)){const{lazyCompile:l,...u}=this.rawOptions;Dr(this,ws,new fi($n(this,qi),this.flags,u))}const r=this.global||this.sticky,a=this.lastIndex;if($n(this,Ki)==="clip_search"&&r&&a){this.lastIndex=0;const l=hm(this,Yl,eg).call(this,n.slice(a));return l&&(C6(l,a,n,this.hasIndices),this.lastIndex+=a),l}return hm(this,Yl,eg).call(this,n)}},ii=new WeakMap,ws=new WeakMap,qi=new WeakMap,ai=new WeakMap,Ki=new WeakMap,Yl=new WeakSet,eg=function(n){$n(this,ws).lastIndex=this.lastIndex;const r=e_(fi.prototype,this,"exec").call($n(this,ws),n);if(this.lastIndex=$n(this,ws).lastIndex,!r||!$n(this,ii).size)return r;const a=[...r];r.length=1;let l;this.hasIndices&&(l=[...r.indices],r.indices.length=1);const u=[0];for(let c=1;c<a.length;c++){const{hidden:d,transferTo:h}=$n(this,ii).get(c)??{};if(d?u.push(null):(u.push(r.length),r.push(a[c]),this.hasIndices&&r.indices.push(l[c])),h&&a[c]!==void 0){const p=u[h];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=a[c],this.hasIndices&&(r.indices[p]=l[c]),r.groups){$n(this,ai)||Dr(this,ai,j6(this.source));const m=$n(this,ai).get(h);m&&(r.groups[m]=a[c],this.hasIndices&&(r.indices.groups[m]=l[c]))}}}return r},fi);function C6(e,t,n,r){if(e.index+=t,e.input=n,r){const a=e.indices;for(let u=0;u<a.length;u++){const c=a[u];c&&(a[u]=[c[0]+t,c[1]+t])}const l=a.groups;l&&Object.keys(l).forEach(u=>{const c=l[u];c&&(l[u]=[c[0]+t,c[1]+t])})}}function k6(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,a]of t)for(const l of a)Gl(n,l,{}).transferTo=r;return n}function j6(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,l;for(;l=t.exec(e);){const{0:u,groups:{capture:c,name:d}}=l;u==="["?r++:r?u==="]"&&r--:c&&(a++,d&&n.set(a,d))}return n}function E6(e,t){const n=N6(e,t);return n.options?new w6(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function N6(e,t){const n=mk(t),r=ak(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Kg}),a=t6(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=h6(a,n),u=VP(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=UP(u.pattern),d=HP(c.pattern,{captureTransfers:u.captureTransfers,hiddenCaptures:u.hiddenCaptures}),h={pattern:d.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${l.flags}${l.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=d.hiddenCaptures.sort((w,C)=>w-C),m=Array.from(d.captureTransfers),x=a._strategy,y=h.pattern.length>=n.lazyCompileLength;(p.length||m.length||x||y)&&(h.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...x&&{strategy:x},...y&&{lazyCompile:y}})}return h}function Ck(e,t){return E6(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function T6(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>Ck(n,{target:t.target})),{createScanner(n){return new WM(n,t)},createString(n){return{content:n}}}}tC(Dg({bundledLanguages:()=>$d,bundledLanguagesAlias:()=>Og,bundledLanguagesBase:()=>Rg,bundledLanguagesInfo:()=>Bd,bundledThemes:()=>Mg,bundledThemesInfo:()=>Ig,codeToHast:()=>KC,codeToHtml:()=>qC,codeToTokens:()=>YC,codeToTokensBase:()=>XC,codeToTokensWithThemes:()=>QC,createHighlighter:()=>qd,createJavaScriptRegexEngine:()=>T6,createOnigurumaEngine:()=>sC,defaultJavaScriptRegexConstructor:()=>Ck,getLastGrammarState:()=>ZC,getSingletonHighlighter:()=>JC,loadWasm:()=>Bg}),VM);let ip=null;const Ol=new Set,Ou=new Map,_S=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],A6=["github-dark-default","vitesse-light","monokai","dracula","nord","everforest-light","rose-pine-dawn","synthwave-84","one-dark-pro","night-owl","catppuccin-mocha","rose-pine","kanagawa-wave","light-plus"],ap={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord","rose-pine-dawn":"rose-pine-dawn","everforest-light":"everforest-light","synthwave-84":"synthwave-84","one-dark-pro":"one-dark-pro","night-owl":"night-owl","catppuccin-mocha":"catppuccin-mocha","rose-pine":"rose-pine","kanagawa-wave":"kanagawa-wave","light-plus":"light-plus"};function L6(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function kk(){return ip||(ip=qd({themes:A6,langs:_S}).then(e=>(_S.forEach(t=>Ol.add(t)),e))),ip}async function D6(e){if(Ol.has(e))return;if(Ou.has(e))return Ou.get(e);const t=(async()=>{const n=await kk(),r=$d[e];if(r){await n.loadLanguage(r),Ol.add(e);return}try{const a=await te(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),Ol.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();Ou.set(e,t),await t,Ou.delete(e)}const bl=new Map,R6=50;function O6(e,t,n){return`${e}|${t}|${n}`}async function jk(e,t,n="github-dark-default"){t!=="text"&&!Ol.has(t)&&await D6(t);const r=O6(e,t,n),a=bl.get(r);if(a)return a;const u=(await kk()).codeToHtml(e,{lang:t,theme:n,transformers:[L6()]});if(bl.size>=R6){const c=bl.keys().next().value;c&&bl.delete(c)}return bl.set(r,u),u}const I6={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 a;if(!e)return"text";const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return r?I6[r]??"text":"text"}function Ek(){const e=Bt(r=>r.currentPreset),t=Bt(r=>r.isCustom),n=Bt(r=>r.basePreset);return M6(e,t,n)}function M6(e,t,n){return t?n&&n!=="system"&&ap[n]?ap[n]??"github-dark-default":"github-dark-default":ap[e]??"github-dark-default"}function Nk(e=2e3){const[t,n]=E.useState(!1),r=E.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const l=document.createElement("textarea");l.value=a,l.style.position="fixed",l.style.left="-9999px",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}n(!0),setTimeout(()=>n(!1),e)}catch(l){console.error("Failed to copy:",l)}},[e]);return{copied:t,copy:r}}const P6=E.memo(function({language:t,codeString:n,showSyntaxHighlighting:r}){const{copied:a,copy:l}=Nk(),[u,c]=E.useState(null),d=Ek(),h=E.useRef(n);return E.useEffect(()=>{r&&(h.current=n,jk(n,t,d).then(p=>{h.current===n&&c(p)}))},[n,t,d,r]),i.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[i.jsxs("div",{className:"absolute bottom-0 right-0 flex items-center gap-2 px-2 py-1 text-xs text-text-muted/70 bg-bg-tertiary/60 rounded-tl rounded-tr z-10",children:[i.jsx("span",{children:t}),i.jsx("button",{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),l(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:a?i.jsx($r,{}):i.jsx(Ml,{})})]}),r&&u?i.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):i.jsx("div",{className:"overflow-x-auto",children:i.jsx("pre",{className:"my-0 px-4 py-3 overflow-x-auto font-mono text-sm whitespace-pre-wrap break-word",children:i.jsx("code",{className:`language-${t}`,children:n})})})]})});function B6(e,t){const n=e?"text-text-muted":"text-text-heading",r=e?"text-text-secondary":"text-text-bold";return{code({className:a,children:l,...u}){const c=/language-(\w+)/.exec(a||"");if(!c&&!String(l).includes(`
|
|
248
|
+
`)){const m=e?"text-text-muted":"text-text-code";return i.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${m} font-mono text-xs`,...u,children:l})}const h=(c==null?void 0:c[1])||"text",p=String(l).replace(/\n$/,"");return i.jsx(P6,{language:h,codeString:p,showSyntaxHighlighting:t})},p({children:a}){const l=e?"text-text-muted":"text-text-primary";return i.jsx("p",{className:`${l} mb-1.5 last:mb-0 leading-tight break-words`,children:a})},ul({children:a}){return i.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a})},ol({children:a}){return i.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a})},li({children:a}){const l=e?"text-text-muted":"text-text-primary";return i.jsx("li",{className:`${l} text-sm list-item`,children:a})},h1({children:a}){return i.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h2({children:a}){return i.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h3({children:a}){return i.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},h4({children:a}){return i.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},strong({children:a}){return i.jsx("strong",{className:`font-bold ${r}`,children:a})},em({children:a}){return i.jsx("em",{className:e?"italic text-text-secondary":"italic",children:a})},a({href:a,children:l}){return i.jsx("a",{href:a,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:l})},blockquote({children:a}){const l=e?"text-text-muted":"text-text-secondary";return i.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${l} italic text-sm`,children:a})},table({children:a}){return i.jsx("div",{className:"overflow-x-auto my-1.5",children:i.jsx("table",{className:"min-w-full border border-border",children:a})})},th({children:a}){return i.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:a})},td({children:a}){return i.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:a})},hr(){return i.jsx("hr",{className:"border-border my-2"})},input({checked:a,...l}){return i.jsx("input",{type:"checkbox",checked:a,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...l})}}}const Hn=E.memo(function({content:t,className:n="",muted:r=!1}){const{showSyntaxHighlighting:a}=ea(),l=E.useMemo(()=>{let c=$6(t);return c=z6(c),c},[t]),u=E.useMemo(()=>B6(r,a),[r,a]);return i.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:i.jsx(lR,{remarkPlugins:[_O],components:u,children:l})})});function $6(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 z6(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const a=e.lastIndexOf("```");return e.slice(a+3).includes(`
|
|
249
|
+
`),e+"\n```"}return e}function Tk({isOpen:e,onClose:t}){const[n,r]=E.useState(null),[a,l]=E.useState(!1),{settings:u,getSetting:c,setSetting:d}=na(),h=u[Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";E.useEffect(()=>{e&&c(Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,c]),E.useEffect(()=>{e&&(l(!0),ye("/api/changelog").then(m=>m.json()).then(m=>{r(m.content)}).catch(()=>{r(`# Changelog
|
|
250
|
+
|
|
251
|
+
Failed to load changelog.`)}).finally(()=>l(!1)))},[e]);const p=E.useCallback(()=>{const m=h?"false":"true";d(Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,m)},[h,d]);return i.jsx(jt,{isOpen:e,onClose:t,title:"What's New in OpenFox",size:"xl",closeOnBackdropClick:!0,showCloseButton:!0,footer:i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx(Xr,{enabled:h,onClick:p}),i.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:i.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:a?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):i.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:i.jsx(Hn,{content:n??""})})})})}async function Ak(e,t,n){t({loading:!0});try{const a=await(await ye(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const H6="#6b7280";function ql(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??H6}const xt=Mn(e=>{const t=async()=>{await Ak("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await ye(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ye(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const a=await mi("POST","/api/agents",{...n,destination:r});return a.success&&await t(),a},updateAgent:async(n,r)=>{const a=await mi("PUT",`/api/agents/${n}`,r);return a.success&&await t(),a},deleteAgent:async n=>{try{const r=await ye(`/api/agents/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n),projectItems:l.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r)=>Ed(`/api/agents/${n}/duplicate`,t,r)}});function U6({onClose:e}){const[,t]=Tn(),{settings:n,getSetting:r,setSetting:a}=na(),l=n[Te.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[Te.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",c=n[Te.CACHE_WARMING]==="true",[d,h]=E.useState({openInEditor:l,dynamicPrompt:u,cacheWarming:c}),[p,m]=E.useState({patterns:[],maxRetriesPerTurn:10}),[x,y]=E.useState(""),[w,C]=E.useState(""),[_,S]=E.useState(!1),[v,b,j,N]=Cp(),[T,D]=E.useState(!1),[L,I]=E.useState(!1),M=Qt(P=>P.version),G=js(P=>P.status),U=js(P=>P.latest),R=js(P=>P.check),H=M&&U?{current:M,latest:U}:null,[W,V]=E.useState(!1),ee=xt(P=>P.defaults),X=xt(P=>P.userItems),$=xt(P=>P.fetchAgents),O=[...ee,...X].filter(P=>!P.subagent);E.useEffect(()=>{h({openInEditor:l,dynamicPrompt:u,cacheWarming:c})},[l,u,c]),E.useEffect(()=>{r(Te.DISPLAY_SHOW_OPEN_IN_EDITOR),r(Te.LLM_DYNAMIC_SYSTEM_PROMPT),r(Te.CACHE_WARMING),r(Te.RETRY_PATTERNS),r(Te.PROXY_URL)},[r]),E.useEffect(()=>{const P=n[Te.RETRY_PATTERNS];if(P)try{m(JSON.parse(P))}catch{}},[n]),E.useEffect(()=>{const P=n[Te.PROXY_URL];P!==void 0&&y(P)},[n]),E.useEffect(()=>{$().catch(()=>{})},[$]),E.useEffect(()=>{r(Te.DEFAULT_AGENT)},[r]),E.useEffect(()=>{const P=n[Te.DEFAULT_AGENT];P!==void 0&&(C(P),S(!0))},[n]);const B=E.useCallback(P=>{m(P),a(Te.RETRY_PATTERNS,JSON.stringify(P))},[a]),q=P=>{y(P),a(Te.PROXY_URL,P)};function z(){N(async()=>(await ye("/api/proxy/test",{method:"POST"})).json())}const re=()=>{const P=!d.openInEditor;h(Q=>({...Q,openInEditor:P})),a(Te.DISPLAY_SHOW_OPEN_IN_EDITOR,String(P))},ne=()=>{const P=!d.dynamicPrompt;h(Q=>({...Q,dynamicPrompt:P})),a(Te.LLM_DYNAMIC_SYSTEM_PROMPT,String(P))},J=()=>{const P=!d.cacheWarming;h(Q=>({...Q,cacheWarming:P})),a(Te.CACHE_WARMING,String(P))};function K(){e(),t("/onboarding")}return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[G==="available"&&i.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),i.jsx("p",{className:"text-sm text-text-muted mb-4",children:M?i.jsxs(i.Fragment,{children:["Current version: ",i.jsxs("span",{className:"font-mono",children:["v",M]})]}):"Check for a new OpenFox version."}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(st,{variant:"secondary",onClick:()=>{V(!0),R()},disabled:G==="checking",children:G==="checking"?"Checking…":"Check for Updates"}),W&&G==="upToDate"&&i.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),G==="error"&&i.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),G==="available"&&i.jsxs("button",{onClick:()=>D(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",U," →"]})]})]}),i.jsx(X1,{isOpen:T,onClose:()=>D(!1),versionInfo:H}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsx("button",{onClick:()=>I(!0),className:"text-sm text-accent-primary hover:underline",children:"View Changelog →"}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("span",{className:"text-xs text-text-muted",children:"Show on update"}),i.jsx(Xr,{enabled:(n[Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const Q=(n[Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,Q)}})]})]}),i.jsx(Tk,{isOpen:L,onClose:()=>I(!1)}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Default Agent"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Choose which agent is used by default for new sessions. The stock Planner is read-only; custom agents can have broader capabilities."}),i.jsxs("select",{value:_?w:"",onChange:P=>{const Q=P.target.value;C(Q),a(Te.DEFAULT_AGENT,Q)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",children:[!_&&i.jsx("option",{value:"",children:"Loading…"}),_&&i.jsx("option",{value:"",children:"System default (planner)"}),O.map(P=>i.jsx("option",{value:P.id,children:P.name},P.id))]}),O.length===0&&_&&i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),i.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),i.jsx(st,{variant:"secondary",onClick:K,children:"Launch Onboarding"})]}),i.jsx("hr",{className:"border-border"}),i.jsx("div",{children:i.jsx(op,{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:re})}),i.jsx("hr",{className:"border-border"}),i.jsx(op,{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:J,boldTitle:!0}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Network"}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"HTTP Proxy"}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(di,{type:"text",value:x,onChange:P=>q(P.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),i.jsx(st,{variant:"secondary",onClick:z,style:j?{color:"rgb(63, 185, 80)"}:void 0,children:v})]}),b&&i.jsx("p",{className:"text-xs text-red-500 mt-1",children:b}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Proxy server all OpenFox network requests (AI, model fetching, web search, terminal). Leave empty for direct connection."})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Define regex patterns that, when matched against LLM responses mid-stream, trigger an automatic retry with a "continue" prompt. The content that triggered the match is preserved in the chat feed.'}),i.jsx(QT,{value:p,onChange:B})]}),i.jsx("hr",{className:"border-border"}),i.jsx(op,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:ne,boldTitle:!0})]})}function op({title:e,description:t,enabled:n,onToggle:r,boldTitle:a}){return i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),i.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),i.jsx("div",{className:"flex-shrink-0",children:i.jsx(Xr,{enabled:n,onClick:r})})]})}function F6(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function V6({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:l,onClear:u,onReset:c,onCancelRecording:d}){const h=E.useRef(null),p=E.useRef(0),m=E.useRef("");return E.useEffect(()=>{if(!r)return;const x=new Set(["Control","Shift","Alt","Meta"]);let y=[];const w=_=>{if(_.preventDefault(),_.stopPropagation(),_.key==="Escape"){d();return}if(x.has(_.key)){const b=Date.now();if(_.key===m.current&&b-p.current<400){l({type:"double-press",key:_.key,threshold:300});return}p.current=b,m.current=_.key,_.ctrlKey&&!y.includes("ctrl")&&y.push("ctrl"),_.metaKey&&!y.includes("meta")&&y.push("meta"),_.altKey&&!y.includes("alt")&&y.push("alt"),_.shiftKey&&!y.includes("shift")&&y.push("shift");return}if(y.length>0||_.ctrlKey||_.metaKey||_.altKey||_.shiftKey){const b=[...y];_.ctrlKey&&!b.includes("ctrl")&&b.push("ctrl"),_.metaKey&&!b.includes("meta")&&b.push("meta"),_.altKey&&!b.includes("alt")&&b.push("alt"),_.shiftKey&&!b.includes("shift")&&b.push("shift"),l({type:"chord",key:M_(_),modifiers:b});return}const S=Date.now(),v=M_(_);if(v===m.current&&S-p.current<400){l({type:"double-press",key:v,threshold:300});return}p.current=S,m.current=v},C=_=>{_.key==="Control"&&(y=y.filter(S=>S!=="ctrl")),_.key==="Shift"&&(y=y.filter(S=>S!=="shift")),_.key==="Alt"&&(y=y.filter(S=>S!=="alt")),_.key==="Meta"&&(y=y.filter(S=>S!=="meta"))};return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",C,!0)}},[r,l,d]),i.jsxs("div",{ref:h,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${r?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[i.jsx("span",{className:"text-sm text-text-primary",children:e}),i.jsx("div",{className:"flex items-center gap-2",children:r?i.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:t?Zu(t):"None"}),t&&i.jsx("button",{type:"button",onClick:u,title:"Remove shortcut","aria-label":`Remove shortcut for ${e}`,className:"p-1 text-text-muted rounded hover:text-accent-error hover:bg-bg-tertiary transition-colors",children:i.jsx(dg,{className:"w-3.5 h-3.5"})}),!F6(t,n)&&i.jsx("button",{type:"button",onClick:c,title:"Reset to default","aria-label":`Reset ${e} to default`,className:"p-1 text-text-muted rounded hover:text-accent-primary hover:bg-bg-tertiary transition-colors",children:i.jsx(Td,{className:"w-3.5 h-3.5"})})]})})]})}function W6(){const{settings:e,loading:t,setSetting:n}=na(),r=e[Te.KEYBINDINGS],a=t[Te.KEYBINDINGS]??!1,l=wp(r),[u,c]=E.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle,defaultBinding:Kr.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction,defaultBinding:Kr.quickAction},{id:"modelSelector",label:"Select Model",binding:l.modelSelector,defaultBinding:Kr.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:l.sessionSearch,defaultBinding:Kr.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:l.criteriaSidebar,defaultBinding:Kr.criteriaSidebar},...l.agentSwitching.map((y,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:y,defaultBinding:Kr.agentSwitching[w]??null}))],h=y=>{c(y)},p=E.useCallback((y,w)=>{const C=wp(r);if(y.startsWith("agentSwitching.")){const _=parseInt(y.split(".")[1],10);C.agentSwitching[_]=w}else y==="terminalToggle"?C.terminalToggle=w:y==="quickAction"?C.quickAction=w:y==="modelSelector"?C.modelSelector=w:y==="sessionSearch"?C.sessionSearch=w:y==="criteriaSidebar"&&(C.criteriaSidebar=w);n(Te.KEYBINDINGS,JSON.stringify(C))},[r,n]),m=E.useCallback(y=>{u&&(c(null),p(u,y))},[u,p]),x=()=>{n(Te.KEYBINDINGS,JSON.stringify(Kr))};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),i.jsx("button",{type:"button",onClick:x,disabled:a,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),a?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):i.jsx("div",{className:"space-y-1",children:d.map(y=>i.jsx(V6,{label:y.label,binding:y.binding,defaultBinding:y.defaultBinding,isRecording:u===y.id,onStartRecording:()=>h(y.id),onBindingRecorded:m,onClear:()=>p(y.id,null),onReset:()=>p(y.id,y.defaultBinding),onCancelRecording:()=>c(null)},y.id))})]})}function Xg(e){switch(e){case"connected":return"text-accent-success";case"error":return"text-accent-error";case"disabled":return"text-text-muted";default:return"text-text-muted"}}function Qg(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function xd(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function Lk({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:l,onToolToggle:u,statusDot:c,statusColor:d,actions:h}){var y;const[p,m]=E.useState(new Set),x=e.name;return i.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-bg-primary/50 transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer",onClick:()=>n(x),children:[i.jsx("span",{className:`text-sm ${d}`,children:c}),i.jsx("span",{className:"text-sm font-medium text-text-primary",children:x}),i.jsx("span",{className:"text-xs text-text-muted",children:e.config.transport}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",l.length," tools)"]}),i.jsxs("span",{className:"text-xs text-text-muted",children:[xd(e.estimatedTokens)," tokens"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Xr,{enabled:r,onClick:a}),h,i.jsx("span",{className:"text-xs text-text-muted",children:t?"▲":"▼"})]})]}),t&&i.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[e.config.command&&i.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[e.config.command," ",((y=e.config.args)==null?void 0:y.join(" "))??""]}),e.config.url&&i.jsx("div",{className:"text-xs text-text-muted font-mono",children:e.config.url}),l.length===0?i.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):i.jsx("div",{className:"space-y-1",children:l.map(w=>i.jsxs("div",{className:"py-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[i.jsx("span",{className:"text-xs text-text-primary font-mono",children:w.name}),w.description&&w.description.length>80?i.jsxs("button",{onClick:()=>{const C=w.name;m(_=>{const S=new Set(_);return S.has(C)?S.delete(C):S.add(C),S})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[i.jsx("span",{className:"truncate max-w-[300px]",children:w.description}),i.jsx(dn,{rotate:p.has(w.name)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):w.description?i.jsx("span",{className:"text-xs text-text-muted ml-2",children:w.description}):null]}),i.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:xd(w.estimatedTokens)}),i.jsx(Xr,{enabled:w.enabled,onClick:()=>u(w.name)})]}),w.description&&w.description.length>80&&p.has(w.name)&&i.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:w.description})]},w.name))})]})]},x)}function SS(e){const t={};return e.split(`
|
|
252
|
+
`).filter(Boolean).forEach(n=>{const r=n.indexOf("=");r>0&&(t[n.slice(0,r).trim()]=n.slice(r+1).trim())}),t}function wS({formData:e,onChange:t}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>t({...e,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),i.jsx("button",{onClick:()=>t({...e,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),e.transport==="stdio"?i.jsxs(i.Fragment,{children:[i.jsx(jr,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),i.jsx(jr,{label:"Arguments",value:e.args,onChange:n=>t({...e,args:n}),placeholder:"space-separated args"}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",i.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),i.jsx("textarea",{value:e.env,onChange:n=>t({...e,env:n.target.value}),placeholder:"API_KEY=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}):i.jsxs(i.Fragment,{children:[i.jsx(jr,{label:"URL",value:e.url,onChange:n=>t({...e,url:n}),placeholder:"e.g. https://mcp.example.com/mcp"}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",i.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),i.jsx("textarea",{value:e.headers,onChange:n=>t({...e,headers:n.target.value}),placeholder:"X-API-Key=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}),i.jsx(jr,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}function lp(e,t,n,r=250){const a=E.useRef(!0);E.useEffect(()=>{if(a.current){a.current=!1;return}const l=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(l)},[e,t,r,n])}function CS({saving:e,saveLabel:t,savingLabel:n,onCancel:r,onSave:a}){return i.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[i.jsx(st,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),i.jsx(st,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function G6(){const{settings:e,getSetting:t,setSetting:n}=na(),[r,a]=E.useState(""),[l,u]=E.useState(""),[c,d]=E.useState(""),[h,p]=E.useState("");lp(l,Te.SEARCH_TAVILY_API_KEY,n),lp(c,Te.SEARCH_SEARXNG_URL,n),lp(h,Te.SEARCH_SEARXNG_API_KEY,n);const[m,x,y,w]=Cp(),[C,_,S,v]=Cp();E.useEffect(()=>{t(Te.SEARCH_ENGINE),t(Te.SEARCH_TAVILY_API_KEY),t(Te.SEARCH_SEARXNG_URL),t(Te.SEARCH_SEARXNG_API_KEY),t(Te.TOOLS_USE_RTK),t(Te.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),E.useEffect(()=>{e[Te.SEARCH_ENGINE]!==void 0&&(a(e[Te.SEARCH_ENGINE]??""),u(e[Te.SEARCH_TAVILY_API_KEY]??""),d(e[Te.SEARCH_SEARXNG_URL]??""),p(e[Te.SEARCH_SEARXNG_API_KEY]??""))},[e]);function b(we){a(we),n(Te.SEARCH_ENGINE,we)}function j(){w(async()=>(await ye("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:l||void 0})})).json())}function N(){v(async()=>(await ye("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:c||void 0,searxngApiKey:h||void 0})})).json())}const[T,D]=E.useState("checking");E.useEffect(()=>{ye("/api/tools/rtk-check").then(we=>we.json()).then(we=>D(we.available?"available":"unavailable")).catch(()=>D("unavailable"))},[]);const[L,I]=E.useState([]);E.useEffect(()=>{t(Te.TOOLS_SHELL),ye("/api/tools/shells").then(we=>we.json()).then(we=>I(we.shells??[])).catch(()=>I([]))},[t]);const M=e[Te.TOOLS_SHELL]||"cmd",[G,U]=E.useState([]),[R,H]=E.useState(!0),[W,V]=E.useState(!1),[ee,X]=E.useState(null),[$,O]=E.useState(new Set),[B,q]=E.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",timeout:""}),[z,re]=E.useState(""),[ne,J]=E.useState(""),[K,P]=E.useState(!1),{requestDelete:Q,clearConfirm:ae,isConfirming:he}=Jl(),ce=E.useCallback(async()=>{try{const Ve=((await(await ye("/api/mcp/servers")).json()).servers??[]).sort((Z,oe)=>Z.name.localeCompare(oe.name));U(Ve)}catch{}H(!1)},[]);E.useEffect(()=>{ce()},[ce]),E.useEffect(()=>{const we=()=>ce();return window.addEventListener("mcp-servers-changed",we),()=>window.removeEventListener("mcp-servers-changed",we)},[ce]);const De=we=>{O(He=>{const Ve=new Set(He);return Ve.has(we)?(Ve.delete(we),Ve):(Ve.add(we),Ve)})};function Re(){if(B.transport==="stdio"&&!B.command)return"Command is required for stdio transport";if(B.transport==="http"&&!B.url)return"URL is required for HTTP transport";if(B.timeout){const we=parseFloat(B.timeout);if(isNaN(we)||we<=0)return"Timeout must be a positive number"}return null}function $e(we){const He=we?{name:B.name,transport:B.transport}:{transport:B.transport};if(B.transport==="stdio"?(He.command=B.command,He.args=B.args?B.args.split(" ").filter(Boolean):[],He.env=SS(B.env)):(He.url=B.url,He.headers=SS(B.headers)),B.timeout){const Ve=parseFloat(B.timeout);!isNaN(Ve)&&Ve>0&&(He.timeout=Ve)}return He}const Ge={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",timeout:""},je=async()=>{if(re(""),!B.name){re("Name is required");return}const we=Re();if(we){re(we);return}P(!0);try{const He=$e(!0),Ve=await ye("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(He)});if(!Ve.ok){const Z=await Ve.json();throw new Error(Z.error??"Failed to add server")}V(!1),q(Ge),await ce()}catch(He){re(He instanceof Error?He.message:String(He))}finally{P(!1)}},Ye=we=>{var He;q({name:we.name,transport:we.config.transport,command:we.config.command??"",args:((He=we.config.args)==null?void 0:He.join(" "))??"",env:we.config.env?Object.entries(we.config.env).map(([Ve,Z])=>`${Ve}=${Z}`).join(`
|
|
253
|
+
`):"",url:we.config.url??"",headers:we.config.headers?Object.entries(we.config.headers).map(([Ve,Z])=>`${Ve}=${Z}`).join(`
|
|
254
|
+
`):"",timeout:we.config.timeout!==void 0?String(we.config.timeout):""}),re(""),X(we.name)},at=async()=>{re("");const we=Re();if(we){re(we);return}P(!0);try{const He=$e(!1),Ve=await ye(`/api/mcp/servers/${encodeURIComponent(ee)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(He)});if(!Ve.ok){const Z=await Ve.json();throw new Error(Z.error??"Failed to update server")}X(null),q(Ge),await ce()}catch(He){re(He instanceof Error?He.message:String(He))}finally{P(!1)}},ke=async we=>{try{const He=await ye(`/api/mcp/servers/${encodeURIComponent(we)}`,{method:"DELETE"});if(!He.ok){const Ve=await He.json().catch(()=>({}));throw new Error(Ve.error??"Failed to remove server")}ae(),J(""),await ce()}catch(He){J(He instanceof Error?He.message:String(He))}},ze=async(we,He,Ve)=>{try{const Z=await ye(`/api/mcp/servers/${encodeURIComponent(we)}/tools/${encodeURIComponent(He)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ve})});if(!Z.ok){const oe=await Z.json().catch(()=>({}));throw new Error(oe.error??"Failed to toggle tool")}J(""),await ce()}catch(Z){J(Z instanceof Error?Z.message:String(Z))}},lt=async(we,He)=>{try{const Ve=await ye(`/api/mcp/servers/${encodeURIComponent(we)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:He})});if(!Ve.ok){const Z=await Ve.json().catch(()=>({}));throw new Error(Z.error??"Failed to toggle server")}J(""),await ce()}catch(Ve){J(Ve instanceof Error?Ve.message:String(Ve))}};return i.jsxs("div",{className:"space-y-8",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),i.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(we=>i.jsx("button",{onClick:()=>b(we),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===we?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:we||"Off"},we))})]}),r==="tavily"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(di,{type:"password",value:l,onChange:we=>u(we.target.value),placeholder:"tvly-...",className:"flex-1"}),i.jsx(st,{variant:"secondary",onClick:j,style:y?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),x&&i.jsx("p",{className:"text-xs text-red-500 mt-1",children:x}),i.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",i.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),i.jsx(di,{type:"url",value:c,onChange:we=>d(we.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsx(di,{type:"password",value:h,onChange:we=>p(we.target.value),placeholder:"Optional API key",className:"w-full"})]}),i.jsx(st,{variant:"secondary",onClick:N,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),_&&i.jsx("p",{className:"text-xs text-red-500",children:_})]})]})]}),L.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Shell used to run agent commands and integrated terminals. Git Bash gives the agent a Unix-like toolset (grep, sed, ls…) and usually works better than cmd.exe."}),i.jsx("div",{className:"flex gap-2",children:L.map(we=>i.jsxs("button",{onClick:()=>n(Te.TOOLS_SHELL,we.id),disabled:!we.available,title:we.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${M===we.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":we.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[we.label,!we.available&&" (not found)"]},we.id))}),i.jsx("p",{className:"text-xs text-text-muted mt-2",children:"Applies to new commands and newly opened terminals. Running terminals keep their current shell."})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",i.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),T==="checking"&&i.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),T==="available"&&i.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),T==="unavailable"&&i.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),i.jsx(Xr,{enabled:e[Te.TOOLS_USE_RTK]==="true",onClick:()=>n(Te.TOOLS_USE_RTK,e[Te.TOOLS_USE_RTK]==="true"?"false":"true")})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Agent Confirmations"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Require confirmation for workspace changes and git mutations. When disabled, the agent proceeds without interruption."}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsx("span",{className:"text-sm text-text-primary",children:"Confirm on workspace & git actions"})}),i.jsx(Xr,{enabled:e[Te.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(Te.CONFIRM_ON_WORKSPACE_ACTIONS,e[Te.CONFIRM_ON_WORKSPACE_ACTIONS]==="true"?"false":"true")})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary","data-testid":"mcp-servers-heading",children:"MCP Servers"}),i.jsx(st,{variant:"primary",size:"sm",onClick:()=>V(!0),children:"+ Add Server"})]}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsx("span",{className:"text-sm text-text-primary",children:"Show per-conversation MCP toggle in chat bar"})}),i.jsx(Xr,{enabled:e[Te.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(Te.FEATURES_PER_SESSION_MCP,e[Te.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),ne&&i.jsx(to,{message:ne}),i.jsx(fg,{loading:R,hasItems:G.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:G.map(we=>{const He=$.has(we.name)?he(we.name,"delete")?i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:Z=>{Z.stopPropagation(),ke(we.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),i.jsx("button",{onClick:Z=>{Z.stopPropagation(),ae()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:Z=>{Z.stopPropagation(),Ye(we)},className:"px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",children:"Edit"}),i.jsx("button",{onClick:Z=>{Z.stopPropagation(),Q(we.name)},className:"px-2 py-1 rounded text-xs font-medium text-accent-error/80 hover:text-accent-error hover:bg-accent-error/10 transition-colors",children:"Remove"})]}):null,Ve=we.status==="error"&&we.error?i.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:we.error,children:we.error}):null;return i.jsx(Lk,{server:we,expanded:$.has(we.name),onToggleExpand:De,serverToggleEnabled:!we.config.disabled,onServerToggle:()=>lt(we.name,!we.config.disabled),tools:we.tools,onToolToggle:Z=>{var oe;return ze(we.name,Z,!((oe=we.tools.find(ie=>ie.name===Z))!=null&&oe.enabled))},statusDot:Qg(we.status),statusColor:Xg(we.status),actions:i.jsxs(i.Fragment,{children:[Ve,He]})},we.name)})}),W&&i.jsx(jt,{isOpen:W,onClose:()=>{V(!1),re("")},title:"Add MCP Server",size:"sm",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx(jr,{label:"Name",value:B.name,onChange:we=>q({...B,name:we}),placeholder:"e.g. filesystem"}),i.jsx(wS,{formData:B,onChange:q}),z&&i.jsx(to,{message:z}),i.jsx(CS,{saving:K,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{V(!1),re(""),P(!1),q(Ge)},onSave:je})]})}),ee!==null&&i.jsx(jt,{isOpen:!0,onClose:()=>{X(null),re("")},title:`Edit MCP Server: ${ee}`,size:"sm",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx(wS,{formData:B,onChange:q}),z&&i.jsx(to,{message:z}),i.jsx(CS,{saving:K,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{X(null),re(""),P(!1),q(Ge)},onSave:at})]})})]})]})}const Dk="openfox_user_plugins";function q6(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function cp(e){const t=q6(e);if(!t)return null;try{const n=await fetch(`https://api.github.com/repos/${t.owner}/${t.repo}/releases/latest`,{signal:AbortSignal.timeout(5e3)});return n.ok?(await n.json()).tag_name??null:null}catch{return null}}function Iu(){try{return JSON.parse(localStorage.getItem(Dk)??"[]")}catch{return[]}}function kS(e){localStorage.setItem(Dk,JSON.stringify(e))}function K6({onAdd:e}){const[t,n]=E.useState(""),[r,a]=E.useState(""),[l,u]=E.useState(!1),c=d=>{d.preventDefault(),!(!t.trim()||!r.trim())&&(e({name:t.trim(),displayName:t.trim(),description:"User-added plugin",githubUrl:r.trim()}),n(""),a(""),u(!0),setTimeout(()=>u(!1),2e3))};return i.jsxs("form",{onSubmit:c,className:"flex gap-2 items-end",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),i.jsx("input",{type:"text",value:t,onChange:d=>n(d.target.value),placeholder:"my-plugin",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),i.jsxs("div",{className:"flex-[2]",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"GitHub URL"}),i.jsx("input",{type:"text",value:r,onChange:d=>a(d.target.value),placeholder:"https://github.com/user/repo",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),i.jsx(st,{type:"submit",variant:"primary",size:"sm",children:l?"Added":"Add"})]})}function Y6({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[l,u]=E.useState(t?"installed":"idle"),[c,d]=E.useState(!1),[h,p]=E.useState(""),[m,x]=E.useState(n),[y,w]=E.useState(!1),[C,_]=E.useState(!1);E.useEffect(()=>{x(n)},[n]);const S=E.useCallback(async()=>{const M=await ye("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),G=await M.json();if(M.ok)u("installed"),e.latestVersion&&x(e.latestVersion),G.loaded||p(G.loadError??"Plugin installed but failed to load");else throw new Error(G.error??"Install failed")},[e.githubUrl,e.name]),v=async()=>{u("installing"),p("");try{await S()}catch(M){u("error"),p(M instanceof Error?M.message:"Connection error")}},b=()=>{w(!0)},j=async()=>{_(!0);try{(await ye(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(u("idle"),r(e.name))}catch{}_(!1),w(!1)},N=async()=>{d(!0),p("");try{await S()}catch(M){p(M instanceof Error?M.message:"Update failed")}d(!1)},T=m??n,D=e.latestVersion&&T&&T!=="unknown"&&e.latestVersion!==T,L=l==="installing"?"Installing…":c?"Updating…":l==="installed"?"Installed ✓":"Install",I=l==="installing"||l==="installed"||c;return i.jsxs("div",{className:"border border-border rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&i.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?i.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?i.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,T&&T!=="unknown"&&i.jsxs("span",{className:"text-text-muted",children:["installed: v",T]})]}),l==="error"&&h&&i.jsx("p",{className:"text-xs text-accent-error mt-1",children:h})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1",children:[i.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&i.jsx(st,{variant:l==="installed"?"secondary":"primary",size:"sm",onClick:v,disabled:I,children:L}),D&&i.jsx(st,{variant:"primary",size:"sm",onClick:N,children:"Update"}),l==="installed"&&i.jsx(st,{variant:"danger",size:"sm",onClick:b,children:"Remove"})]}),l==="installed"&&i.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),i.jsx($l,{isOpen:y,onClose:()=>w(!1),onConfirm:j,title:`Remove "${e.displayName}"?`,message:`Remove the "${e.displayName}" plugin from your installation.`,confirmLabel:"Remove",confirmVariant:"danger",disabled:C})]})}function X6(){const[e,t]=E.useState([]),[n,r]=E.useState([]),[a,l]=E.useState({}),[u,c]=E.useState(!0),[d,h]=E.useState(""),[p,m]=E.useState("");E.useEffect(()=>{let S=!1;Promise.all([ye("/api/plugins/registry").then(b=>{if(!b.ok)throw new Error(`HTTP ${b.status}`);return b.json()}),ye("/api/plugins/installed").then(b=>b.ok?b.json():{installed:[]})]).then(([b,j])=>{if(S)return;const N={},T=j.installed;for(const G of T)N[G.name]=G.version;l(N);const D=b.plugins.map(G=>({...G,latestVersion:null,versionLoading:!0}));t(D),D.forEach(G=>{cp(G.githubUrl).then(U=>{S||t(R=>R.map(H=>H.name===G.name?{...H,latestVersion:U,versionLoading:!1}:H))})});const L=new Set(D.map(G=>G.name)),I=Iu(),M=[];for(const G of T)!L.has(G.name)&&!I.some(U=>U.name===G.name)&&M.push({name:G.name,displayName:G.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});M.length>0&&r(G=>[...G,...M])}).catch(b=>{S||h(b instanceof Error?b.message:"Failed to load plugins")}).finally(()=>{S||c(!1)});const v=Iu();return v.length>0&&(r(v.map(b=>({...b,latestVersion:null,versionLoading:!0}))),v.forEach(b=>{cp(b.githubUrl).then(j=>{S||r(N=>N.map(T=>T.name===b.name?{...T,latestVersion:j,versionLoading:!1}:T))})})),()=>{S=!0}},[]);const x=async S=>{try{S?await ye(`/api/plugins/${S}/open-folder`):await ye("/api/plugins/open-folder")}catch{}},y=E.useCallback(S=>{l(j=>{const N={...j};return delete N[S],N});const v=Iu(),b=v.filter(j=>j.name!==S);b.length!==v.length&&kS(b),r(j=>j.filter(N=>N.name!==S))},[]),w=E.useCallback(S=>{if(new Set(e.map(j=>j.name)).has(S.name)){m(`"${S.displayName}" is already listed in the registry and won't be added again.`);return}const b=Iu();kS([...b,S]),r(j=>[...j,{...S,latestVersion:null,versionLoading:!0}]),cp(S.githubUrl).then(j=>{r(N=>N.map(T=>T.name===S.name?{...T,latestVersion:j,versionLoading:!1}:T))})},[e]),C=new Set,_=[...e,...n].filter(S=>C.has(S.name)?!1:(C.add(S.name),!0));return u?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading plugins..."}):i.jsxs("div",{className:"space-y-4",children:[d&&i.jsxs("div",{className:"text-sm text-accent-error bg-accent-error/10 border border-accent-error/30 rounded-lg p-3",children:["Failed to load plugin registry: ",d]}),p&&i.jsxs("div",{className:"text-sm text-accent-warning bg-accent-warning/10 border border-accent-warning/30 rounded-lg p-3 flex justify-between items-center",children:[i.jsx("span",{children:p}),i.jsx("button",{onClick:()=>m(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),i.jsxs("div",{className:"border border-border rounded-lg p-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),i.jsx(K6,{onAdd:w})]}),_.length===0&&!d&&i.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),_.map(S=>i.jsx(Y6,{plugin:S,initiallyInstalled:S.name in a,installedVersion:a[S.name]??null,onRemove:y,onOpenFolder:x},S.name))]})}function Q6({isOpen:e,onClose:t}){const[n,r]=E.useState("instructions"),a=js(u=>u.status==="available"),l=()=>{try{Lt.send("context.checkDynamic",{})}catch{}t()};return i.jsx(jt,{isOpen:e,onClose:l,title:"Settings",size:"xl",minHeight:"500px",scrollable:!1,children:i.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full min-h-0 -m-4",children:[i.jsxs("div",{className:"flex border-b border-border mb-4 overflow-x-auto scrollbar-hide flex-shrink-0 px-4 pt-4",children:[i.jsx(ni,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),i.jsx(ni,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),i.jsx(ni,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),i.jsx(ni,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),i.jsx(ni,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),i.jsx(ni,{label:"Display",active:n==="display",onClick:()=>r("display")}),i.jsx(ni,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),i.jsx(ni,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-4 pb-4",children:[n==="instructions"&&i.jsx(FT,{isOpen:e}),n==="skills"&&i.jsx(UT,{isOpen:e}),n==="plugins"&&i.jsx(X6,{}),n==="notifications"&&i.jsx(LT,{}),n==="display"&&i.jsx(KT,{}),n==="keybindings"&&i.jsx(W6,{}),n==="tools"&&i.jsx(G6,{}),n==="advanced"&&i.jsx(U6,{onClose:t})]})]})})}function ni({label:e,active:t,onClick:n,showDot:r}){return i.jsxs("button",{onClick:n,className:`relative px-4 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:[e,r&&i.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]})}var up={exports:{}},jS;function J6(){return jS||(jS=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(u,c,d){var h=this&&this.__decorate||function(v,b,j,N){var T,D=arguments.length,L=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,j):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(v,b,j,N);else for(var I=v.length-1;I>=0;I--)(T=v[I])&&(L=(D<3?T(L):D>3?T(b,j,L):T(b,j))||L);return D>3&&L&&Object.defineProperty(b,j,L),L},p=this&&this.__param||function(v,b){return function(j,N){b(j,N,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),x=d(9924),y=d(844),w=d(4725),C=d(2585),_=d(3656);let S=c.AccessibilityManager=class extends y.Disposable{constructor(v,b,j,N){super(),this._terminal=v,this._coreBrowserService=j,this._renderService=N,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(`
|
|
255
|
+
`)))),this.register(this._terminal.onA11yTab((T=>this._handleTab(T)))),this.register(this._terminal.onKey((T=>this._handleKey(T.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,_.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(v){for(let b=0;b<v;b++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
|
|
256
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,b){this._liveRegionDebouncer.refresh(v,b,this._terminal.rows)}_renderRows(v,b){const j=this._terminal.buffer,N=j.lines.length.toString();for(let T=v;T<=b;T++){const D=j.lines.get(j.ydisp+T),L=[],I=(D==null?void 0:D.translateToString(!0,void 0,void 0,L))||"",M=(j.ydisp+T+1).toString(),G=this._rowElements[T];G&&(I.length===0?(G.innerText=" ",this._rowColumns.set(G,[0,1])):(G.textContent=I,this._rowColumns.set(G,L)),G.setAttribute("aria-posinset",M),G.setAttribute("aria-setsize",N))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,b){const j=v.target,N=this._rowElements[b===0?1:this._rowElements.length-2];if(j.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==N)return;let T,D;if(b===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),b===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(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){var I;if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:v.anchorNode,offset:v.anchorOffset},j={node:v.focusNode,offset:v.focusOffset};if((b.node.compareDocumentPosition(j.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===j.node&&b.offset>j.offset)&&([b,j]=[j,b]),b.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(b={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(b.node))return;const N=this._rowElements.slice(-1)[0];if(j.node.compareDocumentPosition(N)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(j={node:N,offset:((I=N.textContent)==null?void 0:I.length)??0}),!this._rowContainer.contains(j.node))return;const T=({node:M,offset:G})=>{const U=M instanceof Text?M.parentNode:M;let R=parseInt(U==null?void 0:U.getAttribute("aria-posinset"),10)-1;if(isNaN(R))return console.warn("row is invalid. Race condition?"),null;const H=this._rowColumns.get(U);if(!H)return console.warn("columns is null. Race condition?"),null;let W=G<H.length?H[G]:H.slice(-1)[0]+1;return W>=this._terminal.cols&&(++R,W=0),{row:R,column:W}},D=T(b),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(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_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 v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=S=h([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 h(x,y){return y?"\x1B[200~"+x+"\x1B[201~":x}function p(x,y,w,C){x=h(x=d(x),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(x,!0),y.value=""}function m(x,y,w){const C=w.getBoundingClientRect(),_=x.clientX-C.left-10,S=x.clientY-C.top-10;y.style.width="20px",y.style.height="20px",y.style.left=`${_}px`,y.style.top=`${S}px`,y.style.zIndex="1000",y.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=d,c.bracketTextForPaste=h,c.copyHandler=function(x,y){x.clipboardData&&x.clipboardData.setData("text/plain",y.selectionText),x.preventDefault()},c.handlePasteEvent=function(x,y,w,C){x.stopPropagation(),x.clipboardData&&p(x.clipboardData.getData("text/plain"),y,w,C)},c.paste=p,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(x,y,w,C,_){m(x,y,w),_&&C.rightClickSelect(x),y.value=C.selectionText,y.select()}},7239:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const h=d(1505);c.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.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,h,p,m){d.addEventListener(h,p,m);let x=!1;return{dispose:()=>{x||(x=!0,d.removeEventListener(h,p,m))}}}},3551:function(u,c,d){var h=this&&this.__decorate||function(S,v,b,j){var N,T=arguments.length,D=T<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,v,b,j);else for(var L=S.length-1;L>=0;L--)(N=S[L])&&(D=(T<3?N(D):T>3?N(v,b,D):N(v,b))||D);return T>3&&D&&Object.defineProperty(v,b,D),D},p=this&&this.__param||function(S,v){return function(b,j){v(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 _=c.Linkifier=class extends y.Disposable{get currentLink(){return this._currentLink}constructor(S,v,b,j,N){super(),this._element=S,this._mouseService=v,this._renderService=b,this._bufferService=j,this._linkProviderService=N,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 v=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const b=S.composedPath();for(let j=0;j<b.length;j++){const N=b[j];if(N.classList.contains("xterm"))break;if(N.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_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,v){var j,N;this._activeProviderReplies&&v||((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 b=!1;for(const[T,D]of this._linkProviderService.linkProviders.entries())v?(N=this._activeProviderReplies)!=null&&N.get(T)&&(b=this._checkLinkProviderResult(T,S,b)):D.provideLinks(S.y,(L=>{var M,G;if(this._isMouseOut)return;const I=L==null?void 0:L.map((U=>({link:U})));(M=this._activeProviderReplies)==null||M.set(T,I),b=this._checkLinkProviderResult(T,S,b),((G=this._activeProviderReplies)==null?void 0:G.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,v){const b=new Set;for(let j=0;j<v.size;j++){const N=v.get(j);if(N)for(let T=0;T<N.length;T++){const D=N[T],L=D.link.range.start.y<S?0:D.link.range.start.x,I=D.link.range.end.y>S?this._bufferService.cols:D.link.range.end.x;for(let M=L;M<=I;M++){if(b.has(M)){N.splice(T--,1);break}b.add(M)}}}}_checkLinkProviderResult(S,v,b){var T;if(!this._activeProviderReplies)return b;const j=this._activeProviderReplies.get(S);let N=!1;for(let D=0;D<S;D++)this._activeProviderReplies.has(D)&&!this._activeProviderReplies.get(D)||(N=!0);if(!N&&j){const D=j.find((L=>this._linkAtPosition(L.link,v)));D&&(b=!0,this._handleNewLink(D))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!b)for(let D=0;D<this._activeProviderReplies.size;D++){const L=(T=this._activeProviderReplies.get(D))==null?void 0:T.find((I=>this._linkAtPosition(I.link,v)));if(L){b=!0,this._handleNewLink(L);break}}return b}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const v=this._positionFromMouseEvent(S,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,v){this._currentLink&&this._lastMouseEvent&&(!S||!v||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=v)&&(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 v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(S.link,v)&&(this._currentLink=S,this._currentLink.state={decorations:{underline:S.link.decorations===void 0||S.link.decorations.underline,pointerCursor:S.link.decorations===void 0||S.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,S.link,this._lastMouseEvent),S.link.decorations={},Object.defineProperties(S.link.decorations,{pointerCursor:{get:()=>{var b,j;return(j=(b=this._currentLink)==null?void 0:b.state)==null?void 0:j.decorations.pointerCursor},set:b=>{var j;(j=this._currentLink)!=null&&j.state&&this._currentLink.state.decorations.pointerCursor!==b&&(this._currentLink.state.decorations.pointerCursor=b,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",b))}},underline:{get:()=>{var b,j;return(j=(b=this._currentLink)==null?void 0:b.state)==null?void 0:j.decorations.underline},set:b=>{var j,N,T;(j=this._currentLink)!=null&&j.state&&((T=(N=this._currentLink)==null?void 0:N.state)==null?void 0:T.decorations.underline)!==b&&(this._currentLink.state.decorations.underline=b,this._currentLink.state.isHovered&&this._fireUnderlineEvent(S.link,b))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((b=>{if(!this._currentLink)return;const j=b.start===0?0:b.start+1+this._bufferService.buffer.ydisp,N=this._bufferService.buffer.ydisp+1+b.end;if(this._currentLink.link.range.start.y>=j&&this._currentLink.link.range.end.y<=N&&(this._clearCurrentLink(j,N),this._lastMouseEvent)){const T=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);T&&this._askForLink(T,!1)}}))))}_linkHover(S,v,b){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(b,v.text)}_fireUnderlineEvent(S,v){const b=S.range,j=this._bufferService.buffer.ydisp,N=this._createLinkUnderlineEvent(b.start.x-1,b.start.y-j-1,b.end.x,b.end.y-j-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(N)}_linkLeave(S,v,b){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(b,v.text)}_linkAtPosition(S,v){const b=S.range.start.y*this._bufferService.cols+S.range.start.x,j=S.range.end.y*this._bufferService.cols+S.range.end.x,N=v.y*this._bufferService.cols+v.x;return b<=N&&N<=j}_positionFromMouseEvent(S,v,b){const j=b.getCoords(S,v,this._bufferService.cols,this._bufferService.rows);if(j)return{x:j[0],y:j[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,v,b,j,N){return{x1:S,y1:v,x2:b,y2:j,cols:this._bufferService.cols,fg:N}}};c.Linkifier=_=h([p(1,C.IMouseService),p(2,C.IRenderService),p(3,w.IBufferService),p(4,C.ILinkProviderService)],_)},9042:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(u,c,d){var h=this&&this.__decorate||function(C,_,S,v){var b,j=arguments.length,N=j<3?_:v===null?v=Object.getOwnPropertyDescriptor(_,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,_,S,v);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(N=(j<3?b(N):j>3?b(_,S,N):b(_,S))||N);return j>3&&N&&Object.defineProperty(_,S,N),N},p=this&&this.__param||function(C,_){return function(S,v){_(S,v,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=d(511),x=d(2585);let y=c.OscLinkProvider=class{constructor(C,_,S){this._bufferService=C,this._optionsService=_,this._oscLinkService=S}provideLinks(C,_){var I;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void _(void 0);const v=[],b=this._optionsService.rawOptions.linkHandler,j=new m.CellData,N=S.getTrimmedLength();let T=-1,D=-1,L=!1;for(let M=0;M<N;M++)if(D!==-1||S.hasContent(M)){if(S.loadCell(M,j),j.hasExtendedAttrs()&&j.extended.urlId){if(D===-1){D=M,T=j.extended.urlId;continue}L=j.extended.urlId!==T}else D!==-1&&(L=!0);if(L||D!==-1&&M===N-1){const G=(I=this._oscLinkService.getLinkData(T))==null?void 0:I.uri;if(G){const U={start:{x:D+1,y:C},end:{x:M+(L||M!==N-1?0:1),y:C}};let R=!1;if(!(b!=null&&b.allowNonHttpProtocols))try{const H=new URL(G);["http:","https:"].includes(H.protocol)||(R=!0)}catch{R=!0}R||v.push({text:G,range:U,activate:(H,W)=>b?b.activate(H,W,U):w(0,W),hover:(H,W)=>{var V;return(V=b==null?void 0:b.hover)==null?void 0:V.call(b,H,W,U)},leave:(H,W)=>{var V;return(V=b==null?void 0:b.leave)==null?void 0:V.call(b,H,W,U)}})}L=!1,j.hasExtendedAttrs()&&j.extended.urlId?(D=M,T=j.extended.urlId):(D=-1,T=-1)}}_(v)}};function w(C,_){if(confirm(`Do you want to navigate to ${_}?
|
|
257
|
+
|
|
258
|
+
WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=_}else console.warn("Opening link blocked as opener could not be cleared")}}c.OscLinkProvider=y=h([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,h){this._renderCallback=d,this._coreBrowserService=h,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,h,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h: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,h):h,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const d=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,h),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 h=d(3614),p=d(3656),m=d(3551),x=d(9042),y=d(3730),w=d(1680),C=d(3107),_=d(5744),S=d(2950),v=d(1296),b=d(428),j=d(4269),N=d(5114),T=d(8934),D=d(3230),L=d(9312),I=d(4725),M=d(6731),G=d(8055),U=d(8969),R=d(8460),H=d(844),W=d(6114),V=d(8437),ee=d(2584),X=d(7399),$=d(5941),O=d(9074),B=d(2585),q=d(5435),z=d(4567),re=d(779);class ne extends U.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=W,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new H.MutableDisposable),this._onCursorMove=this.register(new R.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new R.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new R.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new R.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new R.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new R.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new R.EventEmitter),this._onBlur=this.register(new R.EventEmitter),this._onA11yCharEmitter=this.register(new R.EventEmitter),this._onA11yTabEmitter=this.register(new R.EventEmitter),this._onWillOpen=this.register(new R.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(re.LinkProviderService),this._instantiationService.setService(I.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(y.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((P,Q)=>this.refresh(P,Q)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((P=>this._reportWindowsOptions(P)))),this.register(this._inputHandler.onColor((P=>this._handleColorEvent(P)))),this.register((0,R.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,R.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((P=>this._afterResize(P.cols,P.rows)))),this.register((0,H.toDisposable)((()=>{var P,Q;this._customKeyEventHandler=void 0,(Q=(P=this.element)==null?void 0:P.parentNode)==null||Q.removeChild(this.element)})))}_handleColorEvent(K){if(this._themeService)for(const P of K){let Q,ae="";switch(P.index){case 256:Q="foreground",ae="10";break;case 257:Q="background",ae="11";break;case 258:Q="cursor",ae="12";break;default:Q="ansi",ae="4;"+P.index}switch(P.type){case 0:const he=G.color.toColorRGB(Q==="ansi"?this._themeService.colors.ansi[P.index]:this._themeService.colors[Q]);this.coreService.triggerDataEvent(`${ee.C0.ESC}]${ae};${(0,$.toRgbString)(he)}${ee.C1_ESCAPED.ST}`);break;case 1:if(Q==="ansi")this._themeService.modifyColors((ce=>ce.ansi[P.index]=G.channels.toColor(...P.color)));else{const ce=Q;this._themeService.modifyColors((De=>De[ce]=G.channels.toColor(...P.color)))}break;case 2:this._themeService.restoreColor(P.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(z.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(K){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ee.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(ee.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,P=this.buffer.lines.get(K);if(!P)return;const Q=Math.min(this.buffer.x,this.cols-1),ae=this._renderService.dimensions.css.cell.height,he=P.getWidth(Q),ce=this._renderService.dimensions.css.cell.width*he,De=this.buffer.y*this._renderService.dimensions.css.cell.height,Re=Q*this._renderService.dimensions.css.cell.width;this.textarea.style.left=Re+"px",this.textarea.style.top=De+"px",this.textarea.style.width=ce+"px",this.textarea.style.height=ae+"px",this.textarea.style.lineHeight=ae+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(P=>{this.hasSelection()&&(0,h.copyHandler)(P,this._selectionService)})));const K=P=>(0,h.handlePasteEvent)(P,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",K)),this.register((0,p.addDisposableDomListener)(this.element,"paste",K)),W.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(P=>{P.button===2&&(0,h.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(P=>{(0,h.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),W.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(P=>{P.button===1&&(0,h.moveTextAreaUnderMouseCursor)(P,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 Q;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"),((Q=this.element)==null?void 0:Q.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 P=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),P.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",(ae=>this.updateCursorStyle(ae)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),P.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",x.promptLabel),W.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(N.CoreBrowserService,this.textarea,K.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(I.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(ae=>this._handleTextAreaFocus(ae)))),this.register((0,p.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(b.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(I.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(M.ThemeService),this._instantiationService.setService(I.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(j.CharacterJoinerService),this._instantiationService.setService(I.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(D.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(I.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((ae=>this._onRender.fire(ae)))),this.onResize((ae=>this._renderService.resize(ae.cols,ae.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(I.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(P);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((ae=>this.scrollLines(ae.amount,ae.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(I.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((ae=>this.scrollLines(ae.amount,ae.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((ae=>this._renderService.handleSelectionChanged(ae.start,ae.end,ae.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((ae=>{this.textarea.value=ae,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((ae=>{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",(ae=>this._selectionService.handleMouseDown(ae)))),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(z.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(ae=>this._handleScreenReaderModeOptionChange(ae)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(ae=>{!this._overviewRulerRenderer&&ae&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(v.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const K=this,P=this.element;function Q(ce){const De=K._mouseService.getMouseReportCoords(ce,K.screenElement);if(!De)return!1;let Re,$e;switch(ce.overrideType||ce.type){case"mousemove":$e=32,ce.buttons===void 0?(Re=3,ce.button!==void 0&&(Re=ce.button<3?ce.button:3)):Re=1&ce.buttons?0:4&ce.buttons?1:2&ce.buttons?2:3;break;case"mouseup":$e=0,Re=ce.button<3?ce.button:3;break;case"mousedown":$e=1,Re=ce.button<3?ce.button:3;break;case"wheel":if(K._customWheelEventHandler&&K._customWheelEventHandler(ce)===!1||K.viewport.getLinesScrolled(ce)===0)return!1;$e=ce.deltaY<0?0:1,Re=4;break;default:return!1}return!($e===void 0||Re===void 0||Re>4)&&K.coreMouseService.triggerMouseEvent({col:De.col,row:De.row,x:De.x,y:De.y,button:Re,action:$e,ctrl:ce.ctrlKey,alt:ce.altKey,shift:ce.shiftKey})}const ae={mouseup:null,wheel:null,mousedrag:null,mousemove:null},he={mouseup:ce=>(Q(ce),ce.buttons||(this._document.removeEventListener("mouseup",ae.mouseup),ae.mousedrag&&this._document.removeEventListener("mousemove",ae.mousedrag)),this.cancel(ce)),wheel:ce=>(Q(ce),this.cancel(ce,!0)),mousedrag:ce=>{ce.buttons&&Q(ce)},mousemove:ce=>{ce.buttons||Q(ce)}};this.register(this.coreMouseService.onProtocolChange((ce=>{ce?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ce)),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&ce?ae.mousemove||(P.addEventListener("mousemove",he.mousemove),ae.mousemove=he.mousemove):(P.removeEventListener("mousemove",ae.mousemove),ae.mousemove=null),16&ce?ae.wheel||(P.addEventListener("wheel",he.wheel,{passive:!1}),ae.wheel=he.wheel):(P.removeEventListener("wheel",ae.wheel),ae.wheel=null),2&ce?ae.mouseup||(ae.mouseup=he.mouseup):(this._document.removeEventListener("mouseup",ae.mouseup),ae.mouseup=null),4&ce?ae.mousedrag||(ae.mousedrag=he.mousedrag):(this._document.removeEventListener("mousemove",ae.mousedrag),ae.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(P,"mousedown",(ce=>{if(ce.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ce))return Q(ce),ae.mouseup&&this._document.addEventListener("mouseup",ae.mouseup),ae.mousedrag&&this._document.addEventListener("mousemove",ae.mousedrag),this.cancel(ce)}))),this.register((0,p.addDisposableDomListener)(P,"wheel",(ce=>{if(!ae.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(ce)===!1)return!1;if(!this.buffer.hasScrollback){const De=this.viewport.getLinesScrolled(ce);if(De===0)return;const Re=ee.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ce.deltaY<0?"A":"B");let $e="";for(let Ge=0;Ge<Math.abs(De);Ge++)$e+=Re;return this.coreService.triggerDataEvent($e,!0),this.cancel(ce,!0)}return this.viewport.handleWheel(ce)?this.cancel(ce):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(P,"touchstart",(ce=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ce),this.cancel(ce)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(P,"touchmove",(ce=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ce)?void 0:this.cancel(ce)}),{passive:!1}))}refresh(K,P){var Q;(Q=this._renderService)==null||Q.refreshRows(K,P)}updateCursorStyle(K){var P;(P=this._selectionService)!=null&&P.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,P,Q=0){var ae;Q===1?(super.scrollLines(K,P,Q),this.refresh(0,this.rows-1)):(ae=this.viewport)==null||ae.scrollLines(K)}paste(K){(0,h.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 P=this._characterJoinerService.register(K);return this.refresh(0,this.rows-1),P}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,P,Q){this._selectionService.setSelection(K,P,Q)}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,P){var Q;(Q=this._selectionService)==null||Q.selectLines(K,P)}_keyDown(K){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;const P=this.browser.isMac&&this.options.macOptionIsMeta&&K.altKey;if(!P&&!this._compositionHelper.keydown(K))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;P||K.key!=="Dead"&&K.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const Q=(0,X.evaluateKeyboardEvent)(K,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(K),Q.type===3||Q.type===2){const ae=this.rows-1;return this.scrollLines(Q.type===2?-ae:ae),this.cancel(K,!0)}return Q.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,K)||(Q.cancel&&this.cancel(K,!0),!Q.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):(Q.key!==ee.C0.ETX&&Q.key!==ee.C0.CR||(this.textarea.value=""),this._onKey.fire({key:Q.key,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(Q.key,!0),!this.optionsService.rawOptions.screenReaderMode||K.altKey||K.ctrlKey?this.cancel(K,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(K,P){const Q=K.isMac&&!this.options.macOptionIsMeta&&P.altKey&&!P.ctrlKey&&!P.metaKey||K.isWindows&&P.altKey&&P.ctrlKey&&!P.metaKey||K.isWindows&&P.getModifierState("AltGraph");return P.type==="keypress"?Q:Q&&(!P.keyCode||P.keyCode>47)}_keyUp(K){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1||((function(P){return P.keyCode===16||P.keyCode===17||P.keyCode===18})(K)||this.focus(),this.updateCursorStyle(K),this._keyPressHandled=!1)}_keyPress(K){let P;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;if(this.cancel(K),K.charCode)P=K.charCode;else if(K.which===null||K.which===void 0)P=K.keyCode;else{if(K.which===0||K.charCode===0)return!1;P=K.which}return!(!P||(K.altKey||K.ctrlKey||K.metaKey)&&!this._isThirdLevelShift(this.browser,K)||(P=String.fromCharCode(P),this._onKey.fire({key:P,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(P,!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 P=K.data;return this.coreService.triggerDataEvent(P,!0),this.cancel(K),!0}return!1}resize(K,P){K!==this.cols||P!==this.rows?super.resize(K,P):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(K,P){var Q,ae;(Q=this._charSizeService)==null||Q.measure(),(ae=this.viewport)==null||ae.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 P=1;P<this.rows;P++)this.buffer.lines.push(this.buffer.getBlankLine(V.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 P,Q;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(P=this._selectionService)==null||P.reset(),this._decorationService.reset(),(Q=this.viewport)==null||Q.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(ee.C0.ESC+"[I"):this.coreService.triggerDataEvent(ee.C0.ESC+"[O")}_reportWindowsOptions(K){if(this._renderService)switch(K){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const P=this._renderService.dimensions.css.canvas.width.toFixed(0),Q=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ee.C0.ESC}[4;${Q};${P}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const ae=this._renderService.dimensions.css.cell.width.toFixed(0),he=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ee.C0.ESC}[6;${he};${ae}t`)}}cancel(K,P){if(this.options.cancelEvents||P)return K.preventDefault(),K.stopPropagation(),!1}}c.Terminal=ne},9924:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TimeBasedDebouncer=void 0,c.TimeBasedDebouncer=class{constructor(d,h=1e3){this._renderCallback=d,this._debounceThresholdMS=h,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(d,h,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h: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,h):h;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),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,h)}}},1680:function(u,c,d){var h=this&&this.__decorate||function(S,v,b,j){var N,T=arguments.length,D=T<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,v,b,j);else for(var L=S.length-1;L>=0;L--)(N=S[L])&&(D=(T<3?N(D):T>3?N(v,b,D):N(v,b))||D);return T>3&&D&&Object.defineProperty(v,b,D),D},p=this&&this.__param||function(S,v){return function(b,j){v(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 _=c.Viewport=class extends w.Disposable{constructor(S,v,b,j,N,T,D,L){super(),this._viewportElement=S,this._scrollArea=v,this._bufferService=b,this._optionsService=j,this._charSizeService=N,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((I=>this._activeBuffer=I.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((I=>this._renderDimensions=I))),this._handleThemeChange(L.colors),this.register(L.onChangeColors((I=>this._handleThemeChange(I)))),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 v=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==v&&(this._lastRecordedBufferHeight=v,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 v=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:v,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,v){const b=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(v<0&&this._viewportElement.scrollTop!==0||v>0&&b<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const v=this._getPixelsScrolled(S);return v!==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+v:this._smoothScrollState.target+=v,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=v,this._bubbleScroll(S,v))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const v=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+v,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 v=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?v*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._currentRowHeight*this._bufferService.rows),v}getBufferElements(S,v){var L;let b,j="";const N=[],T=v??this._bufferService.buffer.lines.length,D=this._bufferService.buffer.lines;for(let I=S;I<T;I++){const M=D.get(I);if(!M)continue;const G=(L=D.get(I+1))==null?void 0:L.isWrapped;if(j+=M.translateToString(!G),!G||I===D.length-1){const U=document.createElement("div");U.textContent=j,N.push(U),j.length>0&&(b=U),j=""}}return{bufferElements:N,cursorElement:b}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let v=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(v/=this._currentRowHeight+0,this._wheelPartialScroll+=v,v=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._bufferService.rows),v}_applyScrollModifier(S,v){const b=this._optionsService.rawOptions.fastScrollModifier;return b==="alt"&&v.altKey||b==="ctrl"&&v.ctrlKey||b==="shift"&&v.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 v=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,v!==0&&(this._viewportElement.scrollTop+=v,this._bubbleScroll(S,v))}};c.Viewport=_=h([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,x.ICharSizeService),p(5,x.IRenderService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],_)},3107:function(u,c,d){var h=this&&this.__decorate||function(C,_,S,v){var b,j=arguments.length,N=j<3?_:v===null?v=Object.getOwnPropertyDescriptor(_,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,_,S,v);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(N=(j<3?b(N):j>3?b(_,S,N):b(_,S))||N);return j>3&&N&&Object.defineProperty(_,S,N),N},p=this&&this.__param||function(C,_){return function(S,v){_(S,v,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const m=d(4725),x=d(844),y=d(2585);let w=c.BufferDecorationRenderer=class extends x.Disposable{constructor(C,_,S,v,b){super(),this._screenElement=C,this._bufferService=_,this._coreBrowserService=S,this._decorationService=v,this._renderService=b,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((j=>this._removeDecoration(j)))),this.register((0,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 v;const _=this._coreBrowserService.mainDocument.createElement("div");_.classList.add("xterm-decoration"),_.classList.toggle("xterm-decoration-top-layer",((v=C==null?void 0:C.options)==null?void 0:v.layer)==="top"),_.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,_.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",_.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",_.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=C.options.x??0;return S&&S>this._bufferService.cols&&(_.style.display="none"),this._refreshXPosition(C,_),_}_refreshStyle(C){const _=C.marker.line-this._bufferService.buffers.active.ydisp;if(_<0||_>=this._bufferService.rows)C.element&&(C.element.style.display="none",C.onRenderEmitter.fire(C.element));else{let S=this._decorationElements.get(C);S||(S=this._createElement(C),C.element=S,this._decorationElements.set(C,S),this._container.appendChild(S),C.onDispose((()=>{this._decorationElements.delete(C),S.remove()}))),S.style.top=_*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(S)}}_refreshXPosition(C,_=C.element){if(!_)return;const S=C.options.x??0;(C.options.anchor||"left")==="right"?_.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":_.style.left=S?S*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var _;(_=this._decorationElements.get(C))==null||_.remove(),this._decorationElements.delete(C),C.dispose()}};c.BufferDecorationRenderer=w=h([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 h of this._zones)if(h.color===d.options.overviewRulerOptions.color&&h.position===d.options.overviewRulerOptions.position){if(this._lineIntersectsZone(h,d.marker.line))return;if(this._lineAdjacentToZone(h,d.marker.line,d.options.overviewRulerOptions.position))return void this._addLineToZone(h,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,h){return h>=d.startBufferLine&&h<=d.endBufferLine}_lineAdjacentToZone(d,h,p){return h>=d.startBufferLine-this._linePadding[p||"full"]&&h<=d.endBufferLine+this._linePadding[p||"full"]}_addLineToZone(d,h){d.startBufferLine=Math.min(d.startBufferLine,h),d.endBufferLine=Math.max(d.endBufferLine,h)}}},5744:function(u,c,d){var h=this&&this.__decorate||function(b,j,N,T){var D,L=arguments.length,I=L<3?j:T===null?T=Object.getOwnPropertyDescriptor(j,N):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(b,j,N,T);else for(var M=b.length-1;M>=0;M--)(D=b[M])&&(I=(L<3?D(I):L>3?D(j,N,I):D(j,N))||I);return L>3&&I&&Object.defineProperty(j,N,I),I},p=this&&this.__param||function(b,j){return function(N,T){j(N,T,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const m=d(5871),x=d(4725),y=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},_={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let v=c.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,j,N,T,D,L,I){var G;super(),this._viewportElement=b,this._screenElement=j,this._bufferService=N,this._decorationService=T,this._renderService=D,this._optionsService=L,this._coreBrowserService=I,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(),(G=this._viewportElement.parentElement)==null||G.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var U;(U=this._canvas)==null||U.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),j=Math.ceil(this._canvas.width/3);_.full=this._canvas.width,_.left=b,_.center=j,_.right=b,this._refreshDrawHeightConstants(),S.full=0,S.left=0,S.center=_.left,S.right=_.left+_.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,j=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowserService.dpr);C.left=j,C.center=j,C.right=j}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const j of this._decorationService.decorations)this._colorZoneStore.addDecoration(j);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const j of b)j.position!=="full"&&this._renderColorZone(j);for(const j of b)j.position==="full"&&this._renderColorZone(j);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(S[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-C[b.position||"full"]/2),_[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[b.position||"full"]))}_queueRefresh(b,j){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=j||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};c.OverviewRulerRenderer=v=h([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,x.IRenderService),p(5,w.IOptionsService),p(6,x.ICoreBrowserService)],v)},2950:function(u,c,d){var h=this&&this.__decorate||function(C,_,S,v){var b,j=arguments.length,N=j<3?_:v===null?v=Object.getOwnPropertyDescriptor(_,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,_,S,v);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(N=(j<3?b(N):j>3?b(_,S,N):b(_,S))||N);return j>3&&N&&Object.defineProperty(_,S,N),N},p=this&&this.__param||function(C,_){return function(S,v){_(S,v,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const m=d(4725),x=d(2585),y=d(2584);let w=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,_,S,v,b,j){this._textarea=C,this._compositionView=_,this._bufferService=S,this._optionsService=v,this._coreService=b,this._renderService=j,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(C){this._compositionView.textContent=C.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(C){if(this._isComposing||this._isSendingComposition){if(C.keyCode===229||C.keyCode===16||C.keyCode===17||C.keyCode===18)return!1;this._finalizeComposition(!1)}return C.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(C){if(this._compositionView.classList.remove("active"),this._isComposing=!1,C){const _={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let S;this._isSendingComposition=!1,_.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(_.start,_.end):this._textarea.value.substring(_.start),S.length>0&&this._coreService.triggerDataEvent(S,!0)}}),0)}else{this._isSendingComposition=!1;const _=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(_,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const _=this._textarea.value,S=_.replace(C,"");this._dataAlreadySent=S,_.length>C.length?this._coreService.triggerDataEvent(S,!0):_.length<C.length?this._coreService.triggerDataEvent(`${y.C0.DEL}`,!0):_.length===C.length&&_!==C&&this._coreService.triggerDataEvent(_,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const _=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),S=this._renderService.dimensions.css.cell.height,v=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,b=_*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=b+"px",this._compositionView.style.top=v+"px",this._compositionView.style.height=S+"px",this._compositionView.style.lineHeight=S+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const j=this._compositionView.getBoundingClientRect();this._textarea.style.left=b+"px",this._textarea.style.top=v+"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=h([p(2,x.IBufferService),p(3,x.IOptionsService),p(4,x.ICoreService),p(5,m.IRenderService)],w)},9806:(u,c)=>{function d(h,p,m){const x=m.getBoundingClientRect(),y=h.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(h,p,m,x,y,w,C,_,S){if(!w)return;const v=d(h,p,m);return v?(v[0]=Math.ceil((v[0]+(S?C/2:0))/C),v[1]=Math.ceil(v[1]/_),v[0]=Math.min(Math.max(v[0],1),x+(S?1:0)),v[1]=Math.min(Math.max(v[1],1),y),v):void 0}},9504:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const h=d(2584);function p(_,S,v,b){const j=_-m(_,v),N=S-m(S,v),T=Math.abs(j-N)-(function(D,L,I){let M=0;const G=D-m(D,I),U=L-m(L,I);for(let R=0;R<Math.abs(G-U);R++){const H=x(D,L)==="A"?-1:1,W=I.buffer.lines.get(G+H*R);W!=null&&W.isWrapped&&M++}return M})(_,S,v);return C(T,w(x(_,S),b))}function m(_,S){let v=0,b=S.buffer.lines.get(_),j=b==null?void 0:b.isWrapped;for(;j&&_>=0&&_<S.rows;)v++,b=S.buffer.lines.get(--_),j=b==null?void 0:b.isWrapped;return v}function x(_,S){return _>S?"A":"B"}function y(_,S,v,b,j,N){let T=_,D=S,L="";for(;T!==v||D!==b;)T+=j?1:-1,j&&T>N.cols-1?(L+=N.buffer.translateBufferLineToString(D,!1,_,T),T=0,_=0,D++):!j&&T<0&&(L+=N.buffer.translateBufferLineToString(D,!1,0,_+1),T=N.cols-1,_=T,D--);return L+N.buffer.translateBufferLineToString(D,!1,_,T)}function w(_,S){const v=S?"O":"[";return h.C0.ESC+v+_}function C(_,S){_=Math.floor(_);let v="";for(let b=0;b<_;b++)v+=S;return v}c.moveToCellSequence=function(_,S,v,b){const j=v.buffer.x,N=v.buffer.y;if(!v.buffer.hasScrollback)return(function(L,I,M,G,U,R){return p(I,G,U,R).length===0?"":C(y(L,I,L,I-m(I,U),!1,U).length,w("D",R))})(j,N,0,S,v,b)+p(N,S,v,b)+(function(L,I,M,G,U,R){let H;H=p(I,G,U,R).length>0?G-m(G,U):I;const W=G,V=(function(ee,X,$,O,B,q){let z;return z=p($,O,B,q).length>0?O-m(O,B):X,ee<$&&z<=O||ee>=$&&z<O?"C":"D"})(L,I,M,G,U,R);return C(y(L,H,M,W,V==="C",U).length,w(V,R))})(j,N,_,S,v,b);let T;if(N===S)return T=j>_?"D":"C",C(Math.abs(j-_),w(T,b));T=N>S?"D":"C";const D=Math.abs(N-S);return C((function(L,I){return I.cols-L})(N>S?_:j,v)+(D-1)*v.cols+1+((N>S?j:_)-1),w(T,b))}},1296:function(u,c,d){var h=this&&this.__decorate||function(R,H,W,V){var ee,X=arguments.length,$=X<3?H:V===null?V=Object.getOwnPropertyDescriptor(H,W):V;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")$=Reflect.decorate(R,H,W,V);else for(var O=R.length-1;O>=0;O--)(ee=R[O])&&($=(X<3?ee($):X>3?ee(H,W,$):ee(H,W))||$);return X>3&&$&&Object.defineProperty(H,W,$),$},p=this&&this.__param||function(R,H){return function(W,V){H(W,V,R)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const m=d(3787),x=d(2550),y=d(2223),w=d(6171),C=d(6052),_=d(4725),S=d(8055),v=d(8460),b=d(844),j=d(2585),N="xterm-dom-renderer-owner-",T="xterm-rows",D="xterm-fg-",L="xterm-bg-",I="xterm-focus",M="xterm-selection";let G=1,U=c.DomRenderer=class extends b.Disposable{constructor(R,H,W,V,ee,X,$,O,B,q,z,re,ne){super(),this._terminal=R,this._document=H,this._element=W,this._screenElement=V,this._viewportElement=ee,this._helperContainer=X,this._linkifier2=$,this._charSizeService=B,this._optionsService=q,this._bufferService=z,this._coreBrowserService=re,this._themeService=ne,this._terminalClass=G++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new v.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(T),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(M),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((J=>this._injectCss(J)))),this._injectCss(this._themeService.colors),this._rowFactory=O.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(N+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((J=>this._handleLinkHover(J)))),this.register(this._linkifier2.onHideLinkUnderline((J=>this._handleLinkLeave(J)))),this.register((0,b.toDisposable)((()=>{this._element.classList.remove(N+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new x.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const W of this._rowElements)W.style.width=`${this.dimensions.css.canvas.width}px`,W.style.height=`${this.dimensions.css.cell.height}px`,W.style.lineHeight=`${this.dimensions.css.cell.height}px`,W.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(R){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let H=`${this._terminalSelector} .${T} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;H+=`${this._terminalSelector} .${T} .xterm-dim { color: ${S.color.multiplyOpacity(R.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 W=`blink_underline_${this._terminalClass}`,V=`blink_bar_${this._terminalClass}`,ee=`blink_block_${this._terminalClass}`;H+=`@keyframes ${W} { 50% { border-bottom-style: hidden; }}`,H+=`@keyframes ${V} { 50% { box-shadow: none; }}`,H+=`@keyframes ${ee} { 0% { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,H+=`${this._terminalSelector} .${T}.${I} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${W} 1s step-end infinite;}${this._terminalSelector} .${T}.${I} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${T}.${I} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${ee} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${R.cursor.css} !important; color: ${R.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,H+=`${this._terminalSelector} .${M} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${M} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${M} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[X,$]of R.ansi.entries())H+=`${this._terminalSelector} .${D}${X} { color: ${$.css}; }${this._terminalSelector} .${D}${X}.xterm-dim { color: ${S.color.multiplyOpacity($,.5).css}; }${this._terminalSelector} .${L}${X} { background-color: ${$.css}; }`;H+=`${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(R.background).css}; }${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${L}${y.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=H}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,H){for(let W=this._rowElements.length;W<=H;W++){const V=this._document.createElement("div");this._rowContainer.appendChild(V),this._rowElements.push(V)}for(;this._rowElements.length>H;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,H){this._refreshRowElements(R,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(I),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(I),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,H,W){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,H,W),this.renderRows(0,this._bufferService.rows-1),!R||!H)return;this._selectionRenderModel.update(this._terminal,R,H,W);const V=this._selectionRenderModel.viewportStartRow,ee=this._selectionRenderModel.viewportEndRow,X=this._selectionRenderModel.viewportCappedStartRow,$=this._selectionRenderModel.viewportCappedEndRow;if(X>=this._bufferService.rows||$<0)return;const O=this._document.createDocumentFragment();if(W){const B=R[0]>H[0];O.appendChild(this._createSelectionElement(X,B?H[0]:R[0],B?R[0]:H[0],$-X+1))}else{const B=V===X?R[0]:0,q=X===ee?H[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(X,B,q));const z=$-X-1;if(O.appendChild(this._createSelectionElement(X+1,0,this._bufferService.cols,z)),X!==$){const re=ee===$?H[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement($,0,re))}}this._selectionContainer.appendChild(O)}_createSelectionElement(R,H,W,V=1){const ee=this._document.createElement("div"),X=H*this.dimensions.css.cell.width;let $=this.dimensions.css.cell.width*(W-H);return X+$>this.dimensions.css.canvas.width&&($=this.dimensions.css.canvas.width-X),ee.style.height=V*this.dimensions.css.cell.height+"px",ee.style.top=R*this.dimensions.css.cell.height+"px",ee.style.left=`${X}px`,ee.style.width=`${$}px`,ee}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const R of this._rowElements)R.replaceChildren()}renderRows(R,H){const W=this._bufferService.buffer,V=W.ybase+W.y,ee=Math.min(W.x,this._bufferService.cols-1),X=this._optionsService.rawOptions.cursorBlink,$=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let B=R;B<=H;B++){const q=B+W.ydisp,z=this._rowElements[B],re=W.lines.get(q);if(!z||!re)break;z.replaceChildren(...this._rowFactory.createRow(re,q,q===V,$,O,ee,X,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${N}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,H,W,V,ee,X){W<0&&(R=0),V<0&&(H=0);const $=this._bufferService.rows-1;W=Math.max(Math.min(W,$),0),V=Math.max(Math.min(V,$),0),ee=Math.min(ee,this._bufferService.cols);const O=this._bufferService.buffer,B=O.ybase+O.y,q=Math.min(O.x,ee-1),z=this._optionsService.rawOptions.cursorBlink,re=this._optionsService.rawOptions.cursorStyle,ne=this._optionsService.rawOptions.cursorInactiveStyle;for(let J=W;J<=V;++J){const K=J+O.ydisp,P=this._rowElements[J],Q=O.lines.get(K);if(!P||!Q)break;P.replaceChildren(...this._rowFactory.createRow(Q,K,K===B,re,ne,q,z,this.dimensions.css.cell.width,this._widthCache,X?J===W?R:0:-1,X?(J===V?H:ee)-1:-1))}}};c.DomRenderer=U=h([p(7,j.IInstantiationService),p(8,_.ICharSizeService),p(9,j.IOptionsService),p(10,j.IBufferService),p(11,_.ICoreBrowserService),p(12,_.IThemeService)],U)},3787:function(u,c,d){var h=this&&this.__decorate||function(T,D,L,I){var M,G=arguments.length,U=G<3?D:I===null?I=Object.getOwnPropertyDescriptor(D,L):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(T,D,L,I);else for(var R=T.length-1;R>=0;R--)(M=T[R])&&(U=(G<3?M(U):G>3?M(D,L,U):M(D,L))||U);return G>3&&U&&Object.defineProperty(D,L,U),U},p=this&&this.__param||function(T,D){return function(L,I){D(L,I,T)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const m=d(2223),x=d(643),y=d(511),w=d(2585),C=d(8055),_=d(4725),S=d(4269),v=d(6171),b=d(3734);let j=c.DomRendererRowFactory=class{constructor(T,D,L,I,M,G,U){this._document=T,this._characterJoinerService=D,this._optionsService=L,this._coreBrowserService=I,this._coreService=M,this._decorationService=G,this._themeService=U,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,I,M,G,U,R,H,W,V){const ee=[],X=this._characterJoinerService.getJoinedCharacters(D),$=this._themeService.colors;let O,B=T.getNoBgTrimmedLength();L&&B<G+1&&(B=G+1);let q=0,z="",re=0,ne=0,J=0,K=!1,P=0,Q=!1,ae=0;const he=[],ce=W!==-1&&V!==-1;for(let De=0;De<B;De++){T.loadCell(De,this._workCell);let Re=this._workCell.getWidth();if(Re===0)continue;let $e=!1,Ge=De,je=this._workCell;if(X.length>0&&De===X[0][0]){$e=!0;const Ke=X.shift();je=new S.JoinedCellData(this._workCell,T.translateToString(!0,Ke[0],Ke[1]),Ke[1]-Ke[0]),Ge=Ke[1]-1,Re=je.getWidth()}const Ye=this._isCellInSelection(De,D),at=L&&De===G,ke=ce&&De>=W&&De<=V;let ze=!1;this._decorationService.forEachDecorationAtCell(De,D,void 0,(Ke=>{ze=!0}));let lt=je.getChars()||x.WHITESPACE_CELL_CHAR;if(lt===" "&&(je.isUnderline()||je.isOverline())&&(lt=" "),ae=Re*R-H.get(lt,je.isBold(),je.isItalic()),O){if(q&&(Ye&&Q||!Ye&&!Q&&je.bg===re)&&(Ye&&Q&&$.selectionForeground||je.fg===ne)&&je.extended.ext===J&&ke===K&&ae===P&&!at&&!$e&&!ze){je.isInvisible()?z+=x.WHITESPACE_CELL_CHAR:z+=lt,q++;continue}q&&(O.textContent=z),O=this._document.createElement("span"),q=0,z=""}else O=this._document.createElement("span");if(re=je.bg,ne=je.fg,J=je.extended.ext,K=ke,P=ae,Q=Ye,$e&&G>=De&&G<=Ge&&(G=De),!this._coreService.isCursorHidden&&at&&this._coreService.isCursorInitialized){if(he.push("xterm-cursor"),this._coreBrowserService.isFocused)U&&he.push("xterm-cursor-blink"),he.push(I==="bar"?"xterm-cursor-bar":I==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(M)switch(M){case"outline":he.push("xterm-cursor-outline");break;case"block":he.push("xterm-cursor-block");break;case"bar":he.push("xterm-cursor-bar");break;case"underline":he.push("xterm-cursor-underline")}}if(je.isBold()&&he.push("xterm-bold"),je.isItalic()&&he.push("xterm-italic"),je.isDim()&&he.push("xterm-dim"),z=je.isInvisible()?x.WHITESPACE_CELL_CHAR:je.getChars()||x.WHITESPACE_CELL_CHAR,je.isUnderline()&&(he.push(`xterm-underline-${je.extended.underlineStyle}`),z===" "&&(z=" "),!je.isUnderlineColorDefault()))if(je.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${b.AttributeData.toColorRGB(je.getUnderlineColor()).join(",")})`;else{let Ke=je.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&je.isBold()&&Ke<8&&(Ke+=8),O.style.textDecorationColor=$.ansi[Ke].css}je.isOverline()&&(he.push("xterm-overline"),z===" "&&(z=" ")),je.isStrikethrough()&&he.push("xterm-strikethrough"),ke&&(O.style.textDecoration="underline");let we=je.getFgColor(),He=je.getFgColorMode(),Ve=je.getBgColor(),Z=je.getBgColorMode();const oe=!!je.isInverse();if(oe){const Ke=we;we=Ve,Ve=Ke;const ct=He;He=Z,Z=ct}let ie,me,Ue,Ie=!1;switch(this._decorationService.forEachDecorationAtCell(De,D,void 0,(Ke=>{Ke.options.layer!=="top"&&Ie||(Ke.backgroundColorRGB&&(Z=50331648,Ve=Ke.backgroundColorRGB.rgba>>8&16777215,ie=Ke.backgroundColorRGB),Ke.foregroundColorRGB&&(He=50331648,we=Ke.foregroundColorRGB.rgba>>8&16777215,me=Ke.foregroundColorRGB),Ie=Ke.options.layer==="top")})),!Ie&&Ye&&(ie=this._coreBrowserService.isFocused?$.selectionBackgroundOpaque:$.selectionInactiveBackgroundOpaque,Ve=ie.rgba>>8&16777215,Z=50331648,Ie=!0,$.selectionForeground&&(He=50331648,we=$.selectionForeground.rgba>>8&16777215,me=$.selectionForeground)),Ie&&he.push("xterm-decoration-top"),Z){case 16777216:case 33554432:Ue=$.ansi[Ve],he.push(`xterm-bg-${Ve}`);break;case 50331648:Ue=C.channels.toColor(Ve>>16,Ve>>8&255,255&Ve),this._addStyle(O,`background-color:#${N((Ve>>>0).toString(16),"0",6)}`);break;default:oe?(Ue=$.foreground,he.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):Ue=$.background}switch(ie||je.isDim()&&(ie=C.color.multiplyOpacity(Ue,.5)),He){case 16777216:case 33554432:je.isBold()&&we<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(we+=8),this._applyMinimumContrast(O,Ue,$.ansi[we],je,ie,void 0)||he.push(`xterm-fg-${we}`);break;case 50331648:const Ke=C.channels.toColor(we>>16&255,we>>8&255,255&we);this._applyMinimumContrast(O,Ue,Ke,je,ie,me)||this._addStyle(O,`color:#${N(we.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,Ue,$.foreground,je,ie,me)||oe&&he.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}he.length&&(O.className=he.join(" "),he.length=0),at||$e||ze?O.textContent=z:q++,ae!==this.defaultSpacing&&(O.style.letterSpacing=`${ae}px`),ee.push(O),De=Ge}return O&&q&&(O.textContent=z),ee}_applyMinimumContrast(T,D,L,I,M,G){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,v.treatGlyphAsBackgroundColor)(I.getCode()))return!1;const U=this._getContrastCache(I);let R;if(M||G||(R=U.getColor(D.rgba,L.rgba)),R===void 0){const H=this._optionsService.rawOptions.minimumContrastRatio/(I.isDim()?2:1);R=C.color.ensureContrastRatio(M||D,G||L,H),U.setColor((M||D).rgba,(G||L).rgba,R??null)}return!!R&&(this._addStyle(T,`color:${R.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,D){T.setAttribute("style",`${T.getAttribute("style")||""}${D};`)}_isCellInSelection(T,D){const L=this._selectionStart,I=this._selectionEnd;return!(!L||!I)&&(this._columnSelectMode?L[0]<=I[0]?T>=L[0]&&D>=L[1]&&T<I[0]&&D<=I[1]:T<L[0]&&D>=L[1]&&T>=I[0]&&D<=I[1]:D>L[1]&&D<I[1]||L[1]===I[1]&&D===L[1]&&T>=L[0]&&T<I[0]||L[1]<I[1]&&D===I[1]&&T<I[0]||L[1]<I[1]&&D===L[1]&&T>=L[0])}};function N(T,D,L){for(;T.length<L;)T=D+T;return T}c.DomRendererRowFactory=j=h([p(1,_.ICharacterJoinerService),p(2,w.IOptionsService),p(3,_.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(6,_.IThemeService)],j)},2550:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WidthCache=void 0,c.WidthCache=class{constructor(d,h){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),h.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(d,h,p,m){d===this._font&&h===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=d,this._fontSize=h,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,h,p){let m=0;if(!h&&!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;h&&(x+="B"),p&&(x+="I");let y=this._holey.get(x);if(y===void 0){let w=0;h&&(w|=1),p&&(w|=2),y=this._measure(d,w),y>0&&this._holey.set(x,y)}return y}_measure(d,h){const p=this._measureElements[h];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 h=d(6114);c.INVERTED_DEFAULT_COLOR=257,c.DIM_OPACITY=.5,c.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(u,c)=>{function d(p){return 57508<=p&&p<=57558}function h(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=h,c.allowRescaling=function(p,m,x,y){return m===1&&x>Math.ceil(1.5*y)&&p!==void 0&&p>255&&!h(p)&&!d(p)&&!(function(w){return 57344<=w&&w<=63743})(p)},c.treatGlyphAsBackgroundColor=function(p){return d(p)||(function(m){return 9472<=m&&m<=9631})(p)},c.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},c.computeNextVariantOffset=function(p,m,x=0){return(p-(2*Math.round(m)-x))%(2*Math.round(m))}},6052:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createSelectionRenderModel=void 0;class d{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(p,m,x,y=!1){if(this.selectionStart=m,this.selectionEnd=x,!m||!x||m[0]===x[0]&&m[1]===x[1])return void this.clear();const w=p.buffers.active.ydisp,C=m[1]-w,_=x[1]-w,S=Math.max(C,0),v=Math.min(_,p.rows-1);S>=p.rows||v<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=y,this.viewportStartRow=C,this.viewportEndRow=_,this.viewportCappedStartRow=S,this.viewportCappedEndRow=v,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,h=this.selectionEnd;return!(!d||!h)&&(d[1]>h[1]||d[1]===h[1]&&d[0]>h[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 h=this&&this.__decorate||function(v,b,j,N){var T,D=arguments.length,L=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,j):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(v,b,j,N);else for(var I=v.length-1;I>=0;I--)(T=v[I])&&(L=(D<3?T(L):D>3?T(b,j,L):T(b,j))||L);return D>3&&L&&Object.defineProperty(b,j,L),L},p=this&&this.__param||function(v,b){return function(j,N){b(j,N,v)}};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(v,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 v=this._measureStrategy.measure();v.width===this.width&&v.height===this.height||(this.width=v.width,this.height=v.height,this._onCharSizeChange.fire())}};c.CharSizeService=w=h([p(2,m.IOptionsService)],w);class C extends y.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(b,j){b!==void 0&&b>0&&j!==void 0&&j>0&&(this._result.width=b,this._result.height=j)}}class _ extends C{constructor(b,j,N){super(),this._document=b,this._parentElement=j,this._optionsService=N,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class S extends C{constructor(b){super(),this._optionsService=b,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const j=this._ctx.measureText("W");if(!("width"in j&&"fontBoundingBoxAscent"in j&&"fontBoundingBoxDescent"in j))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const b=this._ctx.measureText("W");return this._validateAndSet(b.width,b.fontBoundingBoxAscent+b.fontBoundingBoxDescent),this._result}}},4269:function(u,c,d){var h=this&&this.__decorate||function(S,v,b,j){var N,T=arguments.length,D=T<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,v,b,j);else for(var L=S.length-1;L>=0;L--)(N=S[L])&&(D=(T<3?N(D):T>3?N(v,b,D):N(v,b))||D);return T>3&&D&&Object.defineProperty(v,b,D),D},p=this&&this.__param||function(S,v){return function(b,j){v(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(v,b,j){super(),this.content=0,this.combinedData="",this.fg=v.fg,this.bg=v.bg,this.combinedData=b,this._width=j}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(v){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=C;let _=c.CharacterJoinerService=class Rk{constructor(v){this._bufferService=v,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new y.CellData}register(v){const b={id:this._nextCharacterJoinerId++,handler:v};return this._characterJoiners.push(b),b.id}deregister(v){for(let b=0;b<this._characterJoiners.length;b++)if(this._characterJoiners[b].id===v)return this._characterJoiners.splice(b,1),!0;return!1}getJoinedCharacters(v){if(this._characterJoiners.length===0)return[];const b=this._bufferService.buffer.lines.get(v);if(!b||b.length===0)return[];const j=[],N=b.translateToString(!0);let T=0,D=0,L=0,I=b.getFg(0),M=b.getBg(0);for(let G=0;G<b.getTrimmedLength();G++)if(b.loadCell(G,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==I||this._workCell.bg!==M){if(G-T>1){const U=this._getJoinedRanges(N,L,D,b,T);for(let R=0;R<U.length;R++)j.push(U[R])}T=G,L=D,I=this._workCell.fg,M=this._workCell.bg}D+=this._workCell.getChars().length||x.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const G=this._getJoinedRanges(N,L,D,b,T);for(let U=0;U<G.length;U++)j.push(G[U])}return j}_getJoinedRanges(v,b,j,N,T){const D=v.substring(b,j);let L=[];try{L=this._characterJoiners[0].handler(D)}catch(I){console.error(I)}for(let I=1;I<this._characterJoiners.length;I++)try{const M=this._characterJoiners[I].handler(D);for(let G=0;G<M.length;G++)Rk._mergeRanges(L,M[G])}catch(M){console.error(M)}return this._stringRangesToCellRanges(L,N,T),L}_stringRangesToCellRanges(v,b,j){let N=0,T=!1,D=0,L=v[N];if(L){for(let I=j;I<this._bufferService.cols;I++){const M=b.getWidth(I),G=b.getString(I).length||x.WHITESPACE_CELL_CHAR.length;if(M!==0){if(!T&&L[0]<=D&&(L[0]=I,T=!0),L[1]<=D){if(L[1]=I,L=v[++N],!L)break;L[0]<=D?(L[0]=I,T=!0):T=!1}D+=G}}L&&(L[1]=this._bufferService.cols)}}static _mergeRanges(v,b){let j=!1;for(let N=0;N<v.length;N++){const T=v[N];if(j){if(b[1]<=T[0])return v[N-1][1]=b[1],v;if(b[1]<=T[1])return v[N-1][1]=Math.max(b[1],T[1]),v.splice(N,1),v;v.splice(N,1),N--}else{if(b[1]<=T[0])return v.splice(N,0,b),v;if(b[1]<=T[1])return T[0]=Math.min(b[0],T[0]),v;b[0]<T[1]&&(T[0]=Math.min(b[0],T[0]),j=!0)}}return j?v[v.length-1][1]=b[1]:v.push(b),v}};c.CharacterJoinerService=_=h([p(0,w.IBufferService)],_)},5114:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const h=d(844),p=d(8460),m=d(3656);class x extends h.Disposable{constructor(C,_,S){super(),this._textarea=C,this._window=_,this.mainDocument=S,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new y(this._window),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new p.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((v=>this._screenDprMonitor.setWindow(v)))),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 h.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new h.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,h.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 h=d(844);class p extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.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 h=this&&this.__decorate||function(w,C,_,S){var v,b=arguments.length,j=b<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(w,C,_,S);else for(var N=w.length-1;N>=0;N--)(v=w[N])&&(j=(b<3?v(j):b>3?v(C,_,j):v(C,_))||j);return b>3&&j&&Object.defineProperty(C,_,j),j},p=this&&this.__param||function(w,C){return function(_,S){C(_,S,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const m=d(4725),x=d(9806);let y=c.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,_,S,v){return(0,x.getCoords)(window,w,C,_,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,v)}getMouseReportCoords(w,C){const _=(0,x.getCoordsRelativeToElement)(window,w,C);if(this._charSizeService.hasValidSize)return _[0]=Math.min(Math.max(_[0],0),this._renderService.dimensions.css.canvas.width-1),_[1]=Math.min(Math.max(_[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(_[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(_[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(_[0]),y:Math.floor(_[1])}}};c.MouseService=y=h([p(0,m.IRenderService),p(1,m.ICharSizeService)],y)},3230:function(u,c,d){var h=this&&this.__decorate||function(v,b,j,N){var T,D=arguments.length,L=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,j):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(v,b,j,N);else for(var I=v.length-1;I>=0;I--)(T=v[I])&&(L=(D<3?T(L):D>3?T(b,j,L):T(b,j))||L);return D>3&&L&&Object.defineProperty(b,j,L),L},p=this&&this.__param||function(v,b){return function(j,N){b(j,N,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const m=d(6193),x=d(4725),y=d(8460),w=d(844),C=d(7226),_=d(2585);let S=c.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(v,b,j,N,T,D,L,I){super(),this._rowCount=v,this._charSizeService=N,this._renderer=this.register(new w.MutableDisposable),this._pausedResizeTask=new C.DebouncedIdleTask,this._observerDisposable=this.register(new w.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(((M,G)=>this._renderRows(M,G)),L),this.register(this._renderDebouncer),this.register(L.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(D.onResize((()=>this._fullRefresh()))),this.register(D.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)==null?void 0:M.clear()}))),this.register(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(I.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(L.window,b),this.register(L.onWindowChange((M=>this._registerIntersectionObserver(M,b))))}_registerIntersectionObserver(v,b){if("IntersectionObserver"in v){const j=new v.IntersectionObserver((N=>this._handleIntersectionChange(N[N.length-1])),{threshold:0});j.observe(b),this._observerDisposable.value=(0,w.toDisposable)((()=>j.disconnect()))}}_handleIntersectionChange(v){this._isPaused=v.isIntersecting===void 0?v.intersectionRatio===0:!v.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(v,b,j=!1){this._isPaused?this._needsFullRefresh=!0:(j||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(v,b,this._rowCount))}_renderRows(v,b){this._renderer.value&&(v=Math.min(v,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(v,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:v,end:b}),this._onRender.fire({start:v,end:b}),this._isNextRenderRedrawOnly=!0)}resize(v,b){this._rowCount=b,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(v){this._renderer.value=v,this._renderer.value&&(this._renderer.value.onRequestRedraw((b=>this.refreshRows(b.start,b.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(v){return this._renderDebouncer.addRefreshCallback(v)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var v,b;this._renderer.value&&((b=(v=this._renderer.value).clearTextureAtlas)==null||b.call(v),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(v,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var j;return(j=this._renderer.value)==null?void 0:j.handleResize(v,b)})):this._renderer.value.handleResize(v,b),this._fullRefresh())}handleCharSizeChanged(){var v;(v=this._renderer.value)==null||v.handleCharSizeChanged()}handleBlur(){var v;(v=this._renderer.value)==null||v.handleBlur()}handleFocus(){var v;(v=this._renderer.value)==null||v.handleFocus()}handleSelectionChanged(v,b,j){var N;this._selectionState.start=v,this._selectionState.end=b,this._selectionState.columnSelectMode=j,(N=this._renderer.value)==null||N.handleSelectionChanged(v,b,j)}handleCursorMove(){var v;(v=this._renderer.value)==null||v.handleCursorMove()}clear(){var v;(v=this._renderer.value)==null||v.clear()}};c.RenderService=S=h([p(2,_.IOptionsService),p(3,x.ICharSizeService),p(4,_.IDecorationService),p(5,_.IBufferService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],S)},9312:function(u,c,d){var h=this&&this.__decorate||function(L,I,M,G){var U,R=arguments.length,H=R<3?I:G===null?G=Object.getOwnPropertyDescriptor(I,M):G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(L,I,M,G);else for(var W=L.length-1;W>=0;W--)(U=L[W])&&(H=(R<3?U(H):R>3?U(I,M,H):U(I,M))||H);return R>3&&H&&Object.defineProperty(I,M,H),H},p=this&&this.__param||function(L,I){return function(M,G){I(M,G,L)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const m=d(9806),x=d(9504),y=d(456),w=d(4725),C=d(8460),_=d(844),S=d(6114),v=d(4841),b=d(511),j=d(2585),N=" ",T=new RegExp(N,"g");let D=c.SelectionService=class extends _.Disposable{constructor(L,I,M,G,U,R,H,W,V){super(),this._element=L,this._screenElement=I,this._linkifier=M,this._bufferService=G,this._coreService=U,this._mouseService=R,this._optionsService=H,this._renderService=W,this._coreBrowserService=V,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new b.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new C.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new C.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=ee=>this._handleMouseMove(ee),this._mouseUpListener=ee=>this._handleMouseUp(ee),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((ee=>this._handleTrim(ee))),this.register(this._bufferService.buffers.onBufferActivate((ee=>this._handleBufferActivate(ee)))),this.enable(),this._model=new y.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,_.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const L=this._model.finalSelectionStart,I=this._model.finalSelectionEnd;return!(!L||!I||L[0]===I[0]&&L[1]===I[1])}get selectionText(){const L=this._model.finalSelectionStart,I=this._model.finalSelectionEnd;if(!L||!I)return"";const M=this._bufferService.buffer,G=[];if(this._activeSelectionMode===3){if(L[0]===I[0])return"";const U=L[0]<I[0]?L[0]:I[0],R=L[0]<I[0]?I[0]:L[0];for(let H=L[1];H<=I[1];H++){const W=M.translateBufferLineToString(H,!0,U,R);G.push(W)}}else{const U=L[1]===I[1]?I[0]:void 0;G.push(M.translateBufferLineToString(L[1],!0,L[0],U));for(let R=L[1]+1;R<=I[1]-1;R++){const H=M.lines.get(R),W=M.translateBufferLineToString(R,!0);H!=null&&H.isWrapped?G[G.length-1]+=W:G.push(W)}if(L[1]!==I[1]){const R=M.lines.get(I[1]),H=M.translateBufferLineToString(I[1],!0,0,I[0]);R&&R.isWrapped?G[G.length-1]+=H:G.push(H)}}return G.map((U=>U.replace(T," "))).join(S.isWindows?`\r
|
|
259
|
+
`:`
|
|
260
|
+
`)}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 I=this._getMouseBufferCoords(L),M=this._model.finalSelectionStart,G=this._model.finalSelectionEnd;return!!(M&&G&&I)&&this._areCoordsInSelection(I,M,G)}isCellInSelection(L,I){const M=this._model.finalSelectionStart,G=this._model.finalSelectionEnd;return!(!M||!G)&&this._areCoordsInSelection([L,I],M,G)}_areCoordsInSelection(L,I,M){return L[1]>I[1]&&L[1]<M[1]||I[1]===M[1]&&L[1]===I[1]&&L[0]>=I[0]&&L[0]<M[0]||I[1]<M[1]&&L[1]===M[1]&&L[0]<M[0]||I[1]<M[1]&&L[1]===I[1]&&L[0]>=I[0]}_selectWordAtCursor(L,I){var U,R;const M=(R=(U=this._linkifier.currentLink)==null?void 0:U.link)==null?void 0:R.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,v.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const G=this._getMouseBufferCoords(L);return!!G&&(this._selectWordAt(G,I),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(L,I){this._model.clearSelection(),L=Math.max(L,0),I=Math.min(I,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,L],this._model.selectionEnd=[this._bufferService.cols,I],this.refresh(),this._onSelectionChange.fire()}_handleTrim(L){this._model.handleTrim(L)&&this.refresh()}_getMouseBufferCoords(L){const I=this._mouseService.getCoords(L,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(I)return I[0]--,I[1]--,I[1]+=this._bufferService.buffer.ydisp,I}_getMouseEventScrollAmount(L){let I=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,L,this._screenElement)[1];const M=this._renderService.dimensions.css.canvas.height;return I>=0&&I<=M?0:(I>M&&(I-=M),I=Math.min(Math.max(I,-50),50),I/=50,I/Math.abs(I)+Math.round(14*I))}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 I=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);I&&I.length!==this._model.selectionStart[0]&&I.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(L){this._selectWordAtCursor(L,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(L){const I=this._getMouseBufferCoords(L);I&&(this._activeSelectionMode=2,this._selectLineAt(I[1]))}shouldColumnSelect(L){return L.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(L){if(L.stopImmediatePropagation(),!this._model.selectionStart)return;const I=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(L),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(L),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const M=this._bufferService.buffer;if(this._model.selectionEnd[1]<M.lines.length){const G=M.lines.get(this._model.selectionEnd[1]);G&&G.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}I&&I[0]===this._model.selectionEnd[0]&&I[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 I=L.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&I<500&&L.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const M=this._mouseService.getCoords(L,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(M&&M[0]!==void 0&&M[1]!==void 0){const G=(0,x.moveToCellSequence)(M[0]-1,M[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(G,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const L=this._model.finalSelectionStart,I=this._model.finalSelectionEnd,M=!(!L||!I||L[0]===I[0]&&L[1]===I[1]);M?L&&I&&(this._oldSelectionStart&&this._oldSelectionEnd&&L[0]===this._oldSelectionStart[0]&&L[1]===this._oldSelectionStart[1]&&I[0]===this._oldSelectionEnd[0]&&I[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(L,I,M)):this._oldHasSelection&&this._fireOnSelectionChange(L,I,M)}_fireOnSelectionChange(L,I,M){this._oldSelectionStart=L,this._oldSelectionEnd=I,this._oldHasSelection=M,this._onSelectionChange.fire()}_handleBufferActivate(L){this.clearSelection(),this._trimListener.dispose(),this._trimListener=L.activeBuffer.lines.onTrim((I=>this._handleTrim(I)))}_convertViewportColToCharacterIndex(L,I){let M=I;for(let G=0;I>=G;G++){const U=L.loadCell(G,this._workCell).getChars().length;this._workCell.getWidth()===0?M--:U>1&&I!==G&&(M+=U-1)}return M}setSelection(L,I,M){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[L,I],this._model.selectionStartLength=M,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(L){this._isClickInSelection(L)||(this._selectWordAtCursor(L,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(L,I,M=!0,G=!0){if(L[0]>=this._bufferService.cols)return;const U=this._bufferService.buffer,R=U.lines.get(L[1]);if(!R)return;const H=U.translateBufferLineToString(L[1],!1);let W=this._convertViewportColToCharacterIndex(R,L[0]),V=W;const ee=L[0]-W;let X=0,$=0,O=0,B=0;if(H.charAt(W)===" "){for(;W>0&&H.charAt(W-1)===" ";)W--;for(;V<H.length&&H.charAt(V+1)===" ";)V++}else{let re=L[0],ne=L[0];R.getWidth(re)===0&&(X++,re--),R.getWidth(ne)===2&&($++,ne++);const J=R.getString(ne).length;for(J>1&&(B+=J-1,V+=J-1);re>0&&W>0&&!this._isCharWordSeparator(R.loadCell(re-1,this._workCell));){R.loadCell(re-1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===0?(X++,re--):K>1&&(O+=K-1,W-=K-1),W--,re--}for(;ne<R.length&&V+1<H.length&&!this._isCharWordSeparator(R.loadCell(ne+1,this._workCell));){R.loadCell(ne+1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===2?($++,ne++):K>1&&(B+=K-1,V+=K-1),V++,ne++}}V++;let q=W+ee-X+O,z=Math.min(this._bufferService.cols,V-W+X+$-O-B);if(I||H.slice(W,V).trim()!==""){if(M&&q===0&&R.getCodePoint(0)!==32){const re=U.lines.get(L[1]-1);if(re&&R.isWrapped&&re.getCodePoint(this._bufferService.cols-1)!==32){const ne=this._getWordAt([this._bufferService.cols-1,L[1]-1],!1,!0,!1);if(ne){const J=this._bufferService.cols-ne.start;q-=J,z+=J}}}if(G&&q+z===this._bufferService.cols&&R.getCodePoint(this._bufferService.cols-1)!==32){const re=U.lines.get(L[1]+1);if(re!=null&&re.isWrapped&&re.getCodePoint(0)!==32){const ne=this._getWordAt([0,L[1]+1],!1,!1,!0);ne&&(z+=ne.length)}}return{start:q,length:z}}}_selectWordAt(L,I){const M=this._getWordAt(L,I);if(M){for(;M.start<0;)M.start+=this._bufferService.cols,L[1]--;this._model.selectionStart=[M.start,L[1]],this._model.selectionStartLength=M.length}}_selectToWordAt(L){const I=this._getWordAt(L,!0);if(I){let M=L[1];for(;I.start<0;)I.start+=this._bufferService.cols,M--;if(!this._model.areSelectionValuesReversed())for(;I.start+I.length>this._bufferService.cols;)I.length-=this._bufferService.cols,M++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?I.start:I.start+I.length,M]}}_isCharWordSeparator(L){return L.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(L.getChars())>=0}_selectLineAt(L){const I=this._bufferService.buffer.getWrappedRangeForLine(L),M={start:{x:0,y:I.first},end:{x:this._bufferService.cols-1,y:I.last}};this._model.selectionStart=[0,I.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,v.getRangeLength)(M,this._bufferService.cols)}};c.SelectionService=D=h([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 h=d(8343);c.ICharSizeService=(0,h.createDecorator)("CharSizeService"),c.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),c.IMouseService=(0,h.createDecorator)("MouseService"),c.IRenderService=(0,h.createDecorator)("RenderService"),c.ISelectionService=(0,h.createDecorator)("SelectionService"),c.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),c.IThemeService=(0,h.createDecorator)("ThemeService"),c.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(u,c,d){var h=this&&this.__decorate||function(D,L,I,M){var G,U=arguments.length,R=U<3?L:M===null?M=Object.getOwnPropertyDescriptor(L,I):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(D,L,I,M);else for(var H=D.length-1;H>=0;H--)(G=D[H])&&(R=(U<3?G(R):U>3?G(L,I,R):G(L,I))||R);return U>3&&R&&Object.defineProperty(L,I,R),R},p=this&&this.__param||function(D,L){return function(I,M){L(I,M,D)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const m=d(7239),x=d(8055),y=d(8460),w=d(844),C=d(2585),_=x.css.toColor("#ffffff"),S=x.css.toColor("#000000"),v=x.css.toColor("#ffffff"),b=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 I=0;I<216;I++){const M=L[I/36%6|0],G=L[I/6%6|0],U=L[I%6];D.push({css:x.channels.toCss(M,G,U),rgba:x.channels.toRgba(M,G,U)})}for(let I=0;I<24;I++){const M=8+10*I;D.push({css:x.channels.toCss(M,M,M),rgba:x.channels.toRgba(M,M,M)})}return D})());let N=c.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(D){super(),this._optionsService=D,this._contrastCache=new m.ColorContrastCache,this._halfContrastCache=new m.ColorContrastCache,this._onChangeColors=this.register(new y.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_,background:S,cursor:v,cursorAccent:b,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,_),L.background=T(D.background,S),L.cursor=T(D.cursor,v),L.cursorAccent=T(D.cursorAccent,b),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 I=Math.min(L.ansi.length-16,D.extendedAnsi.length);for(let M=0;M<I;M++)L.ansi[M+16]=T(D.extendedAnsi[M],c.DEFAULT_ANSI_COLORS[M+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(D){this._restoreColor(D),this._onChangeColors.fire(this.colors)}_restoreColor(D){if(D!==void 0)switch(D){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[D]=this._restoreColors.ansi[D]}else for(let L=0;L<this._restoreColors.ansi.length;++L)this._colors.ansi[L]=this._restoreColors.ansi[L]}modifyColors(D){D(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function T(D,L){if(D!==void 0)try{return x.css.toColor(D)}catch{}return L}c.ThemeService=N=h([p(0,C.IOptionsService)],N)},6349:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const h=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._maxLength=y,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(y){if(this._maxLength===y)return;const w=new Array(y);for(let C=0;C<Math.min(y,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=y,this._startIndex=0}get length(){return this._length}set length(y){if(y>this._length)for(let w=this._length;w<y;w++)this._array[w]=void 0;this._length=y}get(y){return this._array[this._getCyclicIndex(y)]}set(y,w){this._array[this._getCyclicIndex(y)]=w}push(y){this._array[this._getCyclicIndex(this._length)]=y,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(y,w,...C){if(w){for(let _=y;_<this._length-w;_++)this._array[this._getCyclicIndex(_)]=this._array[this._getCyclicIndex(_+w)];this._length-=w,this.onDeleteEmitter.fire({index:y,amount:w})}for(let _=this._length-1;_>=y;_--)this._array[this._getCyclicIndex(_+C.length)]=this._array[this._getCyclicIndex(_)];for(let _=0;_<C.length;_++)this._array[this._getCyclicIndex(y+_)]=C[_];if(C.length&&this.onInsertEmitter.fire({index:y,amount:C.length}),this._length+C.length>this._maxLength){const _=this._length+C.length-this._maxLength;this._startIndex+=_,this._length=this._maxLength,this.onTrimEmitter.fire(_)}else this._length+=C.length}trimStart(y){y>this._length&&(y=this._length),this._startIndex+=y,this._length-=y,this.onTrimEmitter.fire(y)}shiftElements(y,w,C){if(!(w<=0)){if(y<0||y>=this._length)throw new Error("start argument out of range");if(y+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(y+S+C,this.get(y+S));const _=y+w+C-this._length;if(_>0)for(this._length+=_;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let _=0;_<w;_++)this.set(y+_+C,this.get(y+_))}}_getCyclicIndex(y){return(this._startIndex+y)%this._maxLength}}c.CircularList=m},1439:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.clone=void 0,c.clone=function d(h,p=5){if(typeof h!="object")return h;const m=Array.isArray(h)?[]:{};for(const x in h)m[x]=p<=1?h[x]:h[x]&&d(h[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,h=0,p=0,m=0;var x,y,w,C,_;function S(b){const j=b.toString(16);return j.length<2?"0"+j:j}function v(b,j){return b<j?(j+.05)/(b+.05):(b+.05)/(j+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(b){b.toCss=function(j,N,T,D){return D!==void 0?`#${S(j)}${S(N)}${S(T)}${S(D)}`:`#${S(j)}${S(N)}${S(T)}`},b.toRgba=function(j,N,T,D=255){return(j<<24|N<<16|T<<8|D)>>>0},b.toColor=function(j,N,T,D){return{css:b.toCss(j,N,T,D),rgba:b.toRgba(j,N,T,D)}}})(x||(c.channels=x={})),(function(b){function j(N,T){return m=Math.round(255*T),[d,h,p]=_.toChannels(N.rgba),{css:x.toCss(d,h,p,m),rgba:x.toRgba(d,h,p,m)}}b.blend=function(N,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,I=T.rgba>>8&255,M=N.rgba>>24&255,G=N.rgba>>16&255,U=N.rgba>>8&255;return d=M+Math.round((D-M)*m),h=G+Math.round((L-G)*m),p=U+Math.round((I-U)*m),{css:x.toCss(d,h,p),rgba:x.toRgba(d,h,p)}},b.isOpaque=function(N){return(255&N.rgba)==255},b.ensureContrastRatio=function(N,T,D){const L=_.ensureContrastRatio(N.rgba,T.rgba,D);if(L)return x.toColor(L>>24&255,L>>16&255,L>>8&255)},b.opaque=function(N){const T=(255|N.rgba)>>>0;return[d,h,p]=_.toChannels(T),{css:x.toCss(d,h,p),rgba:T}},b.opacity=j,b.multiplyOpacity=function(N,T){return m=255&N.rgba,j(N,m*T/255)},b.toColorRGB=function(N){return[N.rgba>>24&255,N.rgba>>16&255,N.rgba>>8&255]}})(y||(c.color=y={})),(function(b){let j,N;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",N=j.createLinearGradient(0,0,1,1))}catch{}b.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),h=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),x.toColor(d,h,p);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),h=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,h,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]),h=parseInt(D[2]),p=parseInt(D[3]),m=Math.round(255*(D[5]===void 0?1:parseFloat(D[5]))),x.toColor(d,h,p,m);if(!j||!N)throw new Error("css.toColor: Unsupported css format");if(j.fillStyle=N,j.fillStyle=T,typeof j.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(j.fillRect(0,0,1,1),[d,h,p,m]=j.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:x.toRgba(d,h,p,m),css:T}}})(w||(c.css=w={})),(function(b){function j(N,T,D){const L=N/255,I=T/255,M=D/255;return .2126*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.7152*(I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}b.relativeLuminance=function(N){return j(N>>16&255,N>>8&255,255&N)},b.relativeLuminance2=j})(C||(c.rgb=C={})),(function(b){function j(T,D,L){const I=T>>24&255,M=T>>16&255,G=T>>8&255;let U=D>>24&255,R=D>>16&255,H=D>>8&255,W=v(C.relativeLuminance2(U,R,H),C.relativeLuminance2(I,M,G));for(;W<L&&(U>0||R>0||H>0);)U-=Math.max(0,Math.ceil(.1*U)),R-=Math.max(0,Math.ceil(.1*R)),H-=Math.max(0,Math.ceil(.1*H)),W=v(C.relativeLuminance2(U,R,H),C.relativeLuminance2(I,M,G));return(U<<24|R<<16|H<<8|255)>>>0}function N(T,D,L){const I=T>>24&255,M=T>>16&255,G=T>>8&255;let U=D>>24&255,R=D>>16&255,H=D>>8&255,W=v(C.relativeLuminance2(U,R,H),C.relativeLuminance2(I,M,G));for(;W<L&&(U<255||R<255||H<255);)U=Math.min(255,U+Math.ceil(.1*(255-U))),R=Math.min(255,R+Math.ceil(.1*(255-R))),H=Math.min(255,H+Math.ceil(.1*(255-H))),W=v(C.relativeLuminance2(U,R,H),C.relativeLuminance2(I,M,G));return(U<<24|R<<16|H<<8|255)>>>0}b.blend=function(T,D){if(m=(255&D)/255,m===1)return D;const L=D>>24&255,I=D>>16&255,M=D>>8&255,G=T>>24&255,U=T>>16&255,R=T>>8&255;return d=G+Math.round((L-G)*m),h=U+Math.round((I-U)*m),p=R+Math.round((M-R)*m),x.toRgba(d,h,p)},b.ensureContrastRatio=function(T,D,L){const I=C.relativeLuminance(T>>8),M=C.relativeLuminance(D>>8);if(v(I,M)<L){if(M<I){const R=j(T,D,L),H=v(I,C.relativeLuminance(R>>8));if(H<L){const W=N(T,D,L);return H>v(I,C.relativeLuminance(W>>8))?R:W}return R}const G=N(T,D,L),U=v(I,C.relativeLuminance(G>>8));if(U<L){const R=j(T,D,L);return U>v(I,C.relativeLuminance(R>>8))?G:R}return G}},b.reduceLuminance=j,b.increaseLuminance=N,b.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(_||(c.rgba=_={})),c.toPaddedHex=S,c.contrastRatio=v},8969:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const h=d(844),p=d(2585),m=d(4348),x=d(7866),y=d(744),w=d(7302),C=d(6975),_=d(8460),S=d(1753),v=d(1480),b=d(7994),j=d(9282),N=d(5435),T=d(5981),D=d(2660);let L=!1;class I extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new _.EventEmitter),this._onScroll.event((G=>{var U;(U=this._onScrollApi)==null||U.fire(G.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(G){for(const U in G)this.optionsService.options[U]=G[U]}constructor(G){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new _.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new _.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new _.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new _.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new _.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new _.EventEmitter),this._instantiationService=new m.InstantiationService,this.optionsService=this.register(new w.OptionsService(G)),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(v.UnicodeService)),this._instantiationService.setService(p.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(b.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 N.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,_.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,_.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,_.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,_.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((U=>{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((U=>{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(((U,R)=>this._inputHandler.parse(U,R)))),this.register((0,_.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(G,U){this._writeBuffer.write(G,U)}writeSync(G,U){this._logService.logLevel<=p.LogLevelEnum.WARN&&!L&&(this._logService.warn("writeSync is unreliable and will be removed soon."),L=!0),this._writeBuffer.writeSync(G,U)}input(G,U=!0){this.coreService.triggerDataEvent(G,U)}resize(G,U){isNaN(G)||isNaN(U)||(G=Math.max(G,y.MINIMUM_COLS),U=Math.max(U,y.MINIMUM_ROWS),this._bufferService.resize(G,U))}scroll(G,U=!1){this._bufferService.scroll(G,U)}scrollLines(G,U,R){this._bufferService.scrollLines(G,U,R)}scrollPages(G){this.scrollLines(G*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(G){const U=G-this._bufferService.buffer.ydisp;U!==0&&this.scrollLines(U)}registerEscHandler(G,U){return this._inputHandler.registerEscHandler(G,U)}registerDcsHandler(G,U){return this._inputHandler.registerDcsHandler(G,U)}registerCsiHandler(G,U){return this._inputHandler.registerCsiHandler(G,U)}registerOscHandler(G,U){return this._inputHandler.registerOscHandler(G,U)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let G=!1;const U=this.optionsService.rawOptions.windowsPty;U&&U.buildNumber!==void 0&&U.buildNumber!==void 0?G=U.backend==="conpty"&&U.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(G=!0),G?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const G=[];G.push(this.onLineFeed(j.updateWindowsModeWrappedState.bind(null,this._bufferService))),G.push(this.registerCsiHandler({final:"H"},(()=>((0,j.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const U of G)U.dispose()}))}}}c.CoreTerminal=I},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 h=0;h<this._listeners.length;h++)if(this._listeners[h]===d)return void this._listeners.splice(h,1)}}})),this._event}fire(d,h){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,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(d,h){return d((p=>h.fire(p)))},c.runAndSubscribe=function(d,h){return h(void 0),d((p=>h(p)))}},5435:function(u,c,d){var h=this&&this.__decorate||function(X,$,O,B){var q,z=arguments.length,re=z<3?$:B===null?B=Object.getOwnPropertyDescriptor($,O):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")re=Reflect.decorate(X,$,O,B);else for(var ne=X.length-1;ne>=0;ne--)(q=X[ne])&&(re=(z<3?q(re):z>3?q($,O,re):q($,O))||re);return z>3&&re&&Object.defineProperty($,O,re),re},p=this&&this.__param||function(X,$){return function(O,B){$(O,B,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),_=d(8437),S=d(8460),v=d(643),b=d(511),j=d(3734),N=d(2585),T=d(1480),D=d(6242),L=d(6351),I=d(5941),M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},G=131072;function U(X,$){if(X>24)return $.setWinLines||!1;switch(X){case 1:return!!$.restoreWin;case 2:return!!$.minimizeWin;case 3:return!!$.setWinPosition;case 4:return!!$.setWinSizePixels;case 5:return!!$.raiseWin;case 6:return!!$.lowerWin;case 7:return!!$.refreshWin;case 8:return!!$.setWinSizeChars;case 9:return!!$.maximizeWin;case 10:return!!$.fullscreenWin;case 11:return!!$.getWinState;case 13:return!!$.getWinPosition;case 14:return!!$.getWinSizePixels;case 15:return!!$.getScreenSizePixels;case 16:return!!$.getCellSizePixels;case 18:return!!$.getWinSizeChars;case 19:return!!$.getScreenSizeChars;case 20:return!!$.getIconTitle;case 21:return!!$.getWinTitle;case 22:return!!$.pushTitle;case 23:return!!$.popTitle;case 24:return!!$.setWinLines}return!1}var R;(function(X){X[X.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",X[X.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(c.WindowsOptionsReportType=R={}));let H=0;class W extends w.Disposable{getAttrData(){return this._curAttrData}constructor($,O,B,q,z,re,ne,J,K=new y.EscapeSequenceParser){super(),this._bufferService=$,this._charsetService=O,this._coreService=B,this._logService=q,this._optionsService=z,this._oscLinkService=re,this._coreMouseService=ne,this._unicodeService=J,this._parser=K,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new b.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new S.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new S.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new S.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new S.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new S.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new S.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new S.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new S.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new S.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new S.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new S.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new S.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new S.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new V(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((P=>this._activeBuffer=P.activeBuffer))),this._parser.setCsiHandlerFallback(((P,Q)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(P),params:Q.toArray()})})),this._parser.setEscHandlerFallback((P=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(P)})})),this._parser.setExecuteHandlerFallback((P=>{this._logService.debug("Unknown EXECUTE code: ",{code:P})})),this._parser.setOscHandlerFallback(((P,Q,ae)=>{this._logService.debug("Unknown OSC code: ",{identifier:P,action:Q,data:ae})})),this._parser.setDcsHandlerFallback(((P,Q,ae)=>{Q==="HOOK"&&(ae=ae.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(P),action:Q,payload:ae})})),this._parser.setPrintHandler(((P,Q,ae)=>this.print(P,Q,ae))),this._parser.registerCsiHandler({final:"@"},(P=>this.insertChars(P))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(P=>this.scrollLeft(P))),this._parser.registerCsiHandler({final:"A"},(P=>this.cursorUp(P))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(P=>this.scrollRight(P))),this._parser.registerCsiHandler({final:"B"},(P=>this.cursorDown(P))),this._parser.registerCsiHandler({final:"C"},(P=>this.cursorForward(P))),this._parser.registerCsiHandler({final:"D"},(P=>this.cursorBackward(P))),this._parser.registerCsiHandler({final:"E"},(P=>this.cursorNextLine(P))),this._parser.registerCsiHandler({final:"F"},(P=>this.cursorPrecedingLine(P))),this._parser.registerCsiHandler({final:"G"},(P=>this.cursorCharAbsolute(P))),this._parser.registerCsiHandler({final:"H"},(P=>this.cursorPosition(P))),this._parser.registerCsiHandler({final:"I"},(P=>this.cursorForwardTab(P))),this._parser.registerCsiHandler({final:"J"},(P=>this.eraseInDisplay(P,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(P=>this.eraseInDisplay(P,!0))),this._parser.registerCsiHandler({final:"K"},(P=>this.eraseInLine(P,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(P=>this.eraseInLine(P,!0))),this._parser.registerCsiHandler({final:"L"},(P=>this.insertLines(P))),this._parser.registerCsiHandler({final:"M"},(P=>this.deleteLines(P))),this._parser.registerCsiHandler({final:"P"},(P=>this.deleteChars(P))),this._parser.registerCsiHandler({final:"S"},(P=>this.scrollUp(P))),this._parser.registerCsiHandler({final:"T"},(P=>this.scrollDown(P))),this._parser.registerCsiHandler({final:"X"},(P=>this.eraseChars(P))),this._parser.registerCsiHandler({final:"Z"},(P=>this.cursorBackwardTab(P))),this._parser.registerCsiHandler({final:"`"},(P=>this.charPosAbsolute(P))),this._parser.registerCsiHandler({final:"a"},(P=>this.hPositionRelative(P))),this._parser.registerCsiHandler({final:"b"},(P=>this.repeatPrecedingCharacter(P))),this._parser.registerCsiHandler({final:"c"},(P=>this.sendDeviceAttributesPrimary(P))),this._parser.registerCsiHandler({prefix:">",final:"c"},(P=>this.sendDeviceAttributesSecondary(P))),this._parser.registerCsiHandler({final:"d"},(P=>this.linePosAbsolute(P))),this._parser.registerCsiHandler({final:"e"},(P=>this.vPositionRelative(P))),this._parser.registerCsiHandler({final:"f"},(P=>this.hVPosition(P))),this._parser.registerCsiHandler({final:"g"},(P=>this.tabClear(P))),this._parser.registerCsiHandler({final:"h"},(P=>this.setMode(P))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(P=>this.setModePrivate(P))),this._parser.registerCsiHandler({final:"l"},(P=>this.resetMode(P))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(P=>this.resetModePrivate(P))),this._parser.registerCsiHandler({final:"m"},(P=>this.charAttributes(P))),this._parser.registerCsiHandler({final:"n"},(P=>this.deviceStatus(P))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(P=>this.deviceStatusPrivate(P))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(P=>this.softReset(P))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(P=>this.setCursorStyle(P))),this._parser.registerCsiHandler({final:"r"},(P=>this.setScrollRegion(P))),this._parser.registerCsiHandler({final:"s"},(P=>this.saveCursor(P))),this._parser.registerCsiHandler({final:"t"},(P=>this.windowOptions(P))),this._parser.registerCsiHandler({final:"u"},(P=>this.restoreCursor(P))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(P=>this.insertColumns(P))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(P=>this.deleteColumns(P))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(P=>this.selectProtected(P))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(P=>this.requestMode(P,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(P=>this.requestMode(P,!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((P=>(this.setTitle(P),this.setIconName(P),!0)))),this._parser.registerOscHandler(1,new D.OscHandler((P=>this.setIconName(P)))),this._parser.registerOscHandler(2,new D.OscHandler((P=>this.setTitle(P)))),this._parser.registerOscHandler(4,new D.OscHandler((P=>this.setOrReportIndexedColor(P)))),this._parser.registerOscHandler(8,new D.OscHandler((P=>this.setHyperlink(P)))),this._parser.registerOscHandler(10,new D.OscHandler((P=>this.setOrReportFgColor(P)))),this._parser.registerOscHandler(11,new D.OscHandler((P=>this.setOrReportBgColor(P)))),this._parser.registerOscHandler(12,new D.OscHandler((P=>this.setOrReportCursorColor(P)))),this._parser.registerOscHandler(104,new D.OscHandler((P=>this.restoreIndexedColor(P)))),this._parser.registerOscHandler(110,new D.OscHandler((P=>this.restoreFgColor(P)))),this._parser.registerOscHandler(111,new D.OscHandler((P=>this.restoreBgColor(P)))),this._parser.registerOscHandler(112,new D.OscHandler((P=>this.restoreCursorColor(P)))),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 P in x.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:P},(()=>this.selectCharset("("+P))),this._parser.registerEscHandler({intermediates:")",final:P},(()=>this.selectCharset(")"+P))),this._parser.registerEscHandler({intermediates:"*",final:P},(()=>this.selectCharset("*"+P))),this._parser.registerEscHandler({intermediates:"+",final:P},(()=>this.selectCharset("+"+P))),this._parser.registerEscHandler({intermediates:"-",final:P},(()=>this.selectCharset("-"+P))),this._parser.registerEscHandler({intermediates:".",final:P},(()=>this.selectCharset("."+P))),this._parser.registerEscHandler({intermediates:"/",final:P},(()=>this.selectCharset("/"+P)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((P=>(this._logService.error("Parsing error: ",P),P))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new L.DcsHandler(((P,Q)=>this.requestStatusString(P,Q))))}_preserveStack($,O,B,q){this._parseStack.paused=!0,this._parseStack.cursorStartX=$,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=B,this._parseStack.position=q}_logSlowResolvingAsync($){this._logService.logLevel<=N.LogLevelEnum.WARN&&Promise.race([$,new Promise(((O,B)=>setTimeout((()=>B("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse($,O){let B,q=this._activeBuffer.x,z=this._activeBuffer.y,re=0;const ne=this._parseStack.paused;if(ne){if(B=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(B),B;q=this._parseStack.cursorStartX,z=this._parseStack.cursorStartY,this._parseStack.paused=!1,$.length>G&&(re=this._parseStack.position+G)}if(this._logService.logLevel<=N.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof $=="string"?` "${$}"`:` "${Array.prototype.map.call($,(P=>String.fromCharCode(P))).join("")}"`),typeof $=="string"?$.split("").map((P=>P.charCodeAt(0))):$),this._parseBuffer.length<$.length&&this._parseBuffer.length<G&&(this._parseBuffer=new Uint32Array(Math.min($.length,G))),ne||this._dirtyRowTracker.clearRange(),$.length>G)for(let P=re;P<$.length;P+=G){const Q=P+G<$.length?P+G:$.length,ae=typeof $=="string"?this._stringDecoder.decode($.substring(P,Q),this._parseBuffer):this._utf8Decoder.decode($.subarray(P,Q),this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,ae))return this._preserveStack(q,z,ae,P),this._logSlowResolvingAsync(B),B}else if(!ne){const P=typeof $=="string"?this._stringDecoder.decode($,this._parseBuffer):this._utf8Decoder.decode($,this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,P))return this._preserveStack(q,z,P,0),this._logSlowResolvingAsync(B),B}this._activeBuffer.x===q&&this._activeBuffer.y===z||this._onCursorMove.fire();const J=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(J,this._bufferService.rows-1))}print($,O,B){let q,z;const re=this._charsetService.charset,ne=this._optionsService.rawOptions.screenReaderMode,J=this._bufferService.cols,K=this._coreService.decPrivateModes.wraparound,P=this._coreService.modes.insertMode,Q=this._curAttrData;let ae=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&B-O>0&&ae.getWidth(this._activeBuffer.x-1)===2&&ae.setCellFromCodepoint(this._activeBuffer.x-1,0,1,Q);let he=this._parser.precedingJoinState;for(let ce=O;ce<B;++ce){if(q=$[ce],q<127&&re){const Ge=re[String.fromCharCode(q)];Ge&&(q=Ge.charCodeAt(0))}const De=this._unicodeService.charProperties(q,he);z=T.UnicodeService.extractWidth(De);const Re=T.UnicodeService.extractShouldJoin(De),$e=Re?T.UnicodeService.extractWidth(he):0;if(he=De,ne&&this._onA11yChar.fire((0,C.stringFromCodePoint)(q)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+z-$e>J){if(K){const Ge=ae;let je=this._activeBuffer.x-$e;for(this._activeBuffer.x=$e,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),ae=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),$e>0&&ae instanceof _.BufferLine&&ae.copyCellsFrom(Ge,je,0,$e,!1);je<J;)Ge.setCellFromCodepoint(je++,0,1,Q)}else if(this._activeBuffer.x=J-1,z===2)continue}if(Re&&this._activeBuffer.x){const Ge=ae.getWidth(this._activeBuffer.x-1)?1:2;ae.addCodepointToCell(this._activeBuffer.x-Ge,q,z);for(let je=z-$e;--je>=0;)ae.setCellFromCodepoint(this._activeBuffer.x++,0,0,Q)}else if(P&&(ae.insertCells(this._activeBuffer.x,z-$e,this._activeBuffer.getNullCell(Q)),ae.getWidth(J-1)===2&&ae.setCellFromCodepoint(J-1,v.NULL_CELL_CODE,v.NULL_CELL_WIDTH,Q)),ae.setCellFromCodepoint(this._activeBuffer.x++,q,z,Q),z>0)for(;--z;)ae.setCellFromCodepoint(this._activeBuffer.x++,0,0,Q)}this._parser.precedingJoinState=he,this._activeBuffer.x<J&&B-O>0&&ae.getWidth(this._activeBuffer.x)===0&&!ae.hasContent(this._activeBuffer.x)&&ae.setCellFromCodepoint(this._activeBuffer.x,0,1,Q),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler($,O){return $.final!=="t"||$.prefix||$.intermediates?this._parser.registerCsiHandler($,O):this._parser.registerCsiHandler($,(B=>!U(B.params[0],this._optionsService.rawOptions.windowOptions)||O(B)))}registerDcsHandler($,O){return this._parser.registerDcsHandler($,new L.DcsHandler(O))}registerEscHandler($,O){return this._parser.registerEscHandler($,O)}registerOscHandler($,O){return this._parser.registerOscHandler($,new D.OscHandler(O))}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 $;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&&(($=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&$.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const $=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-$),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor($=this._bufferService.cols-1){this._activeBuffer.x=Math.min($,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($,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=$,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=$,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor($,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+$,this._activeBuffer.y+O)}cursorUp($){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,$.params[0]||1)):this._moveCursor(0,-($.params[0]||1)),!0}cursorDown($){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,$.params[0]||1)):this._moveCursor(0,$.params[0]||1),!0}cursorForward($){return this._moveCursor($.params[0]||1,0),!0}cursorBackward($){return this._moveCursor(-($.params[0]||1),0),!0}cursorNextLine($){return this.cursorDown($),this._activeBuffer.x=0,!0}cursorPrecedingLine($){return this.cursorUp($),this._activeBuffer.x=0,!0}cursorCharAbsolute($){return this._setCursor(($.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition($){return this._setCursor($.length>=2?($.params[1]||1)-1:0,($.params[0]||1)-1),!0}charPosAbsolute($){return this._setCursor(($.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative($){return this._moveCursor($.params[0]||1,0),!0}linePosAbsolute($){return this._setCursor(this._activeBuffer.x,($.params[0]||1)-1),!0}vPositionRelative($){return this._moveCursor(0,$.params[0]||1),!0}hVPosition($){return this.cursorPosition($),!0}tabClear($){const O=$.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab($){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=$.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab($){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=$.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected($){const O=$.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine($,O,B,q=!1,z=!1){const re=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);re.replaceCells(O,B,this._activeBuffer.getNullCell(this._eraseAttrData()),z),q&&(re.isWrapped=!1)}_resetBufferLine($,O=!1){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);B&&(B.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+$),B.isWrapped=!1)}eraseInDisplay($,O=!1){let B;switch(this._restrictCursor(this._bufferService.cols),$.params[0]){case 0:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);B<this._bufferService.rows;B++)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(B);break;case 1:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(B+1).isWrapped=!1);B--;)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(B=this._bufferService.rows,this._dirtyRowTracker.markDirty(B-1);B--;)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(0);break;case 3:const q=this._activeBuffer.lines.length-this._bufferService.rows;q>0&&(this._activeBuffer.lines.trimStart(q),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-q,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-q,0),this._onScroll.fire(0))}return!0}eraseInLine($,O=!1){switch(this._restrictCursor(this._bufferService.cols),$.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines($){this._restrictCursor();let O=$.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y,q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,z=this._bufferService.rows-1+this._activeBuffer.ybase-q+1;for(;O--;)this._activeBuffer.lines.splice(z-1,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines($){this._restrictCursor();let O=$.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y;let q;for(q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-q;O--;)this._activeBuffer.lines.splice(B,1),this._activeBuffer.lines.splice(q,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars($){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,$.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars($){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,$.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp($){let O=$.params[0]||1;for(;O--;)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($){let O=$.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(_.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=$.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=$.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=$.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=$.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars($){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+($.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter($){const O=this._parser.precedingJoinState;if(!O)return!0;const B=$.params[0]||1,q=T.UnicodeService.extractWidth(O),z=this._activeBuffer.x-q,re=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(z),ne=new Uint32Array(re.length*B);let J=0;for(let P=0;P<re.length;){const Q=re.codePointAt(P)||0;ne[J++]=Q,P+=Q>65535?2:1}let K=J;for(let P=1;P<B;++P)ne.copyWithin(K,0,J),K+=J;return this.print(ne,0,K),!0}sendDeviceAttributesPrimary($){return $.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($){return $.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($.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is($){return(this._optionsService.rawOptions.termName+"").indexOf($)===0}setMode($){for(let O=0;O<$.length;O++)switch($.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate($){for(let O=0;O<$.length;O++)switch($.params[O]){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($){for(let O=0;O<$.length;O++)switch($.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate($){for(let O=0;O<$.length;O++)switch($.params[O]){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(),$.params[O]===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($,O){const B=this._coreService.decPrivateModes,{activeProtocol:q,activeEncoding:z}=this._coreMouseService,re=this._coreService,{buffers:ne,cols:J}=this._bufferService,{active:K,alt:P}=ne,Q=this._optionsService.rawOptions,ae=Re=>Re?1:2,he=$.params[0];return ce=he,De=O?he===2?4:he===4?ae(re.modes.insertMode):he===12?3:he===20?ae(Q.convertEol):0:he===1?ae(B.applicationCursorKeys):he===3?Q.windowOptions.setWinLines?J===80?2:J===132?1:0:0:he===6?ae(B.origin):he===7?ae(B.wraparound):he===8?3:he===9?ae(q==="X10"):he===12?ae(Q.cursorBlink):he===25?ae(!re.isCursorHidden):he===45?ae(B.reverseWraparound):he===66?ae(B.applicationKeypad):he===67?4:he===1e3?ae(q==="VT200"):he===1002?ae(q==="DRAG"):he===1003?ae(q==="ANY"):he===1004?ae(B.sendFocus):he===1005?4:he===1006?ae(z==="SGR"):he===1015?4:he===1016?ae(z==="SGR_PIXELS"):he===1048?1:he===47||he===1047||he===1049?ae(K===P):he===2004?ae(B.bracketedPasteMode):0,re.triggerDataEvent(`${m.C0.ESC}[${O?"":"?"}${ce};${De}$y`),!0;var ce,De}_updateAttrColor($,O,B,q,z){return O===2?($|=50331648,$&=-16777216,$|=j.AttributeData.fromColorRGB([B,q,z])):O===5&&($&=-50331904,$|=33554432|255&B),$}_extractColor($,O,B){const q=[0,0,-1,0,0,0];let z=0,re=0;do{if(q[re+z]=$.params[O+re],$.hasSubParams(O+re)){const ne=$.getSubParams(O+re);let J=0;do q[1]===5&&(z=1),q[re+J+1+z]=ne[J];while(++J<ne.length&&J+re+1+z<q.length);break}if(q[1]===5&&re+z>=2||q[1]===2&&re+z>=5)break;q[1]&&(z=1)}while(++re+O<$.length&&re+z<q.length);for(let ne=2;ne<q.length;++ne)q[ne]===-1&&(q[ne]=0);switch(q[0]){case 38:B.fg=this._updateAttrColor(B.fg,q[1],q[3],q[4],q[5]);break;case 48:B.bg=this._updateAttrColor(B.bg,q[1],q[3],q[4],q[5]);break;case 58:B.extended=B.extended.clone(),B.extended.underlineColor=this._updateAttrColor(B.extended.underlineColor,q[1],q[3],q[4],q[5])}return re}_processUnderline($,O){O.extended=O.extended.clone(),(!~$||$>5)&&($=1),O.extended.underlineStyle=$,O.fg|=268435456,$===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0($){$.fg=_.DEFAULT_ATTR_DATA.fg,$.bg=_.DEFAULT_ATTR_DATA.bg,$.extended=$.extended.clone(),$.extended.underlineStyle=0,$.extended.underlineColor&=-67108864,$.updateExtended()}charAttributes($){if($.length===1&&$.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=$.length;let B;const q=this._curAttrData;for(let z=0;z<O;z++)B=$.params[z],B>=30&&B<=37?(q.fg&=-50331904,q.fg|=16777216|B-30):B>=40&&B<=47?(q.bg&=-50331904,q.bg|=16777216|B-40):B>=90&&B<=97?(q.fg&=-50331904,q.fg|=16777224|B-90):B>=100&&B<=107?(q.bg&=-50331904,q.bg|=16777224|B-100):B===0?this._processSGR0(q):B===1?q.fg|=134217728:B===3?q.bg|=67108864:B===4?(q.fg|=268435456,this._processUnderline($.hasSubParams(z)?$.getSubParams(z)[0]:1,q)):B===5?q.fg|=536870912:B===7?q.fg|=67108864:B===8?q.fg|=1073741824:B===9?q.fg|=2147483648:B===2?q.bg|=134217728:B===21?this._processUnderline(2,q):B===22?(q.fg&=-134217729,q.bg&=-134217729):B===23?q.bg&=-67108865:B===24?(q.fg&=-268435457,this._processUnderline(0,q)):B===25?q.fg&=-536870913:B===27?q.fg&=-67108865:B===28?q.fg&=-1073741825:B===29?q.fg&=2147483647:B===39?(q.fg&=-67108864,q.fg|=16777215&_.DEFAULT_ATTR_DATA.fg):B===49?(q.bg&=-67108864,q.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):B===38||B===48||B===58?z+=this._extractColor($,z,q):B===53?q.bg|=1073741824:B===55?q.bg&=-1073741825:B===59?(q.extended=q.extended.clone(),q.extended.underlineColor=-1,q.updateExtended()):B===100?(q.fg&=-67108864,q.fg|=16777215&_.DEFAULT_ATTR_DATA.fg,q.bg&=-67108864,q.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",B);return!0}deviceStatus($){switch($.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${O};${B}R`)}return!0}deviceStatusPrivate($){if($.params[0]===6){const O=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${O};${B}R`)}return!0}softReset($){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=_.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle($){const O=$.params[0]||1;switch(O){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 B=O%2==1;return this._optionsService.options.cursorBlink=B,!0}setScrollRegion($){const O=$.params[0]||1;let B;return($.length<2||(B=$.params[1])>this._bufferService.rows||B===0)&&(B=this._bufferService.rows),B>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=B-1,this._setCursor(0,0)),!0}windowOptions($){if(!U($.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=$.length>1?$.params[1]:0;switch($.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor($){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($){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($){return this._windowTitle=$,this._onTitleChange.fire($),!0}setIconName($){return this._iconName=$,!0}setOrReportIndexedColor($){const O=[],B=$.split(";");for(;B.length>1;){const q=B.shift(),z=B.shift();if(/^\d+$/.exec(q)){const re=parseInt(q);if(ee(re))if(z==="?")O.push({type:0,index:re});else{const ne=(0,I.parseColor)(z);ne&&O.push({type:1,index:re,color:ne})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink($){const O=$.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink($,O){this._getCurrentLinkId()&&this._finishHyperlink();const B=$.split(":");let q;const z=B.findIndex((re=>re.startsWith("id=")));return z!==-1&&(q=B[z].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:q,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor($,O){const B=$.split(";");for(let q=0;q<B.length&&!(O>=this._specialColors.length);++q,++O)if(B[q]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const z=(0,I.parseColor)(B[q]);z&&this._onColor.fire([{type:1,index:this._specialColors[O],color:z}])}return!0}setOrReportFgColor($){return this._setOrReportSpecialColor($,0)}setOrReportBgColor($){return this._setOrReportSpecialColor($,1)}setOrReportCursorColor($){return this._setOrReportSpecialColor($,2)}restoreIndexedColor($){if(!$)return this._onColor.fire([{type:2}]),!0;const O=[],B=$.split(";");for(let q=0;q<B.length;++q)if(/^\d+$/.exec(B[q])){const z=parseInt(B[q]);ee(z)&&O.push({type:2,index:z})}return O.length&&this._onColor.fire(O),!0}restoreFgColor($){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor($){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor($){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($){return $.length!==2?(this.selectDefaultCharset(),!0):($[0]==="/"||this._charsetService.setgCharset(M[$[0]],x.CHARSETS[$[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 $=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,$,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel($){return this._charsetService.setgLevel($),!0}screenAlignmentPattern(){const $=new b.CellData;$.content=4194373,$.fg=this._curAttrData.fg,$.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const B=this._activeBuffer.ybase+this._activeBuffer.y+O,q=this._activeBuffer.lines.get(B);q&&(q.fill($),q.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString($,O){const B=this._bufferService.buffer,q=this._optionsService.rawOptions;return(z=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${z}${m.C0.ESC}\\`),!0))($==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:$==='"p'?'P1$r61;1"p':$==="r"?`P1$r${B.scrollTop+1};${B.scrollBottom+1}r`:$==="m"?"P1$r0m":$===" q"?`P1$r${{block:2,underline:4,bar:6}[q.cursorStyle]-(q.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty($,O){this._dirtyRowTracker.markRangeDirty($,O)}}c.InputHandler=W;let V=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,$){X>$&&(H=X,X=$,$=H),X<this.start&&(this.start=X),$>this.end&&(this.end=$)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function ee(X){return 0<=X&&X<256}V=h([p(0,N.IBufferService)],V)},844:(u,c)=>{function d(h){for(const p of h)p.dispose();h.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 h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const p=this._disposables.indexOf(h);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(h){var p;this._isDisposed||h===this._value||((p=this._value)==null||p.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){var h;this._isDisposed=!0,(h=this._value)==null||h.dispose(),this._value=void 0}},c.toDisposable=function(h){return{dispose:h}},c.disposeArray=d,c.getDisposeArrayDisposable=function(h){return{dispose:()=>d(h)}}},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(h,p,m,x,y){this._data.get(h,p)||this._data.set(h,p,new d),this._data.get(h,p).set(m,x,y)}get(h,p,m,x){var y;return(y=this._data.get(h,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,h=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(h),c.isIpad=h==="iPad",c.isIphone=h==="iPhone",c.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),c.isLinux=h.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(h){this._getKey=h,this._array=[]}clear(){this._array.length=0}insert(h){this._array.length!==0?(d=this._search(this._getKey(h)),this._array.splice(d,0,h)):this._array.push(h)}delete(h){if(this._array.length===0)return!1;const p=this._getKey(h);if(p===void 0||(d=this._search(p),d===-1)||this._getKey(this._array[d])!==p)return!1;do if(this._array[d]===h)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===p);return!1}*getKeyIterator(h){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===h)}forEachByKey(h,p){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do p(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===h)}values(){return[...this._array].values()}_search(h){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>h)m=x-1;else{if(!(y<h)){for(;x>0&&this._getKey(this._array[x-1])===h;)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 h=d(6114);class p{constructor(){this._tasks=[],this._i=0}enqueue(y){this._tasks.push(y),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(y){this._idleCallback=void 0;let w=0,C=0,_=y.timeRemaining(),S=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),S=y.timeRemaining(),1.5*C>S)return _-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(_-w))}ms`),void this._start();_=S}this.clear()}}class m extends p{_requestCallback(y){return setTimeout((()=>y(this._createDeadline(16))))}_cancelCallback(y){clearTimeout(y)}_createDeadline(y){const w=Date.now()+y;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}c.PriorityTaskQueue=m,c.IdleTaskQueue=!h.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 h=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[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&x[h.CHAR_DATA_CODE_INDEX]!==h.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 h}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 h{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 h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}c.ExtendedAttrs=h},9092:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Buffer=c.MAX_BUFFER_SIZE=void 0;const h=d(6349),p=d(7226),m=d(3734),x=d(8437),y=d(4634),w=d(511),C=d(643),_=d(4863),S=d(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(v,b,j){this._hasScrollback=v,this._optionsService=b,this._bufferService=j,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=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 h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(v){return v?(this._nullCell.fg=v.fg,this._nullCell.bg=v.bg,this._nullCell.extended=v.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(v){return v?(this._whitespaceCell.fg=v.fg,this._whitespaceCell.bg=v.bg,this._whitespaceCell.extended=v.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(v,b){return new x.BufferLine(this._bufferService.cols,this.getNullCell(v),b)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const v=this.ybase+this.y-this.ydisp;return v>=0&&v<this._rows}_getCorrectBufferLength(v){if(!this._hasScrollback)return v;const b=v+this._optionsService.rawOptions.scrollback;return b>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:b}fillViewportRows(v){if(this.lines.length===0){v===void 0&&(v=x.DEFAULT_ATTR_DATA);let b=this._rows;for(;b--;)this.lines.push(this.getBlankLine(v))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(v,b){const j=this.getNullCell(x.DEFAULT_ATTR_DATA);let N=0;const T=this._getCorrectBufferLength(b);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<v)for(let L=0;L<this.lines.length;L++)N+=+this.lines.get(L).resize(v,j);let D=0;if(this._rows<b)for(let L=this._rows;L<b;L++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new x.BufferLine(v,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(v,j)));else for(let L=this._rows;L>b;L--)this.lines.length>b+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,v-1),this.y=Math.min(this.y,b-1),D&&(this.y+=D),this.savedX=Math.min(this.savedX,v-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(v,b),this._cols>v))for(let D=0;D<this.lines.length;D++)N+=+this.lines.get(D).resize(v,j);this._cols=v,this._rows=b,this._memoryCleanupQueue.clear(),N>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let v=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,v=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if(b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),b>100)return!0;return v}get _isReflowEnabled(){const v=this._optionsService.rawOptions.windowsPty;return v&&v.buildNumber?this._hasScrollback&&v.backend==="conpty"&&v.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(v,b){this._cols!==v&&(v>this._cols?this._reflowLarger(v,b):this._reflowSmaller(v,b))}_reflowLarger(v,b){const j=(0,y.reflowLargerGetLinesToRemove)(this.lines,this._cols,v,this.ybase+this.y,this.getNullCell(x.DEFAULT_ATTR_DATA));if(j.length>0){const N=(0,y.reflowLargerCreateNewLayout)(this.lines,j);(0,y.reflowLargerApplyNewLayout)(this.lines,N.layout),this._reflowLargerAdjustViewport(v,b,N.countRemoved)}}_reflowLargerAdjustViewport(v,b,j){const N=this.getNullCell(x.DEFAULT_ATTR_DATA);let T=j;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new x.BufferLine(v,N))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-j,0)}_reflowSmaller(v,b){const j=this.getNullCell(x.DEFAULT_ATTR_DATA),N=[];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()<=v)continue;const I=[L];for(;L.isWrapped&&D>0;)L=this.lines.get(--D),I.unshift(L);const M=this.ybase+this.y;if(M>=D&&M<D+I.length)continue;const G=I[I.length-1].getTrimmedLength(),U=(0,y.reflowSmallerGetNewLineLengths)(I,this._cols,v),R=U.length-I.length;let H;H=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+R):Math.max(0,this.lines.length-this.lines.maxLength+R);const W=[];for(let B=0;B<R;B++){const q=this.getBlankLine(x.DEFAULT_ATTR_DATA,!0);W.push(q)}W.length>0&&(N.push({start:D+I.length+T,newLines:W}),T+=W.length),I.push(...W);let V=U.length-1,ee=U[V];ee===0&&(V--,ee=U[V]);let X=I.length-R-1,$=G;for(;X>=0;){const B=Math.min($,ee);if(I[V]===void 0)break;if(I[V].copyCellsFrom(I[X],$-B,ee-B,B,!0),ee-=B,ee===0&&(V--,ee=U[V]),$-=B,$===0){X--;const q=Math.max(X,0);$=(0,y.getWrappedLineTrimmedLength)(I,q,this._cols)}}for(let B=0;B<I.length;B++)U[B]<v&&I[B].setCell(U[B],j);let O=R-H;for(;O-- >0;)this.ybase===0?this.y<b-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+R,this.ybase+b-1)}if(N.length>0){const D=[],L=[];for(let V=0;V<this.lines.length;V++)L.push(this.lines.get(V));const I=this.lines.length;let M=I-1,G=0,U=N[G];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let R=0;for(let V=Math.min(this.lines.maxLength-1,I+T-1);V>=0;V--)if(U&&U.start>M+R){for(let ee=U.newLines.length-1;ee>=0;ee--)this.lines.set(V--,U.newLines[ee]);V++,D.push({index:M+1,amount:U.newLines.length}),R+=U.newLines.length,U=N[++G]}else this.lines.set(V,L[M--]);let H=0;for(let V=D.length-1;V>=0;V--)D[V].index+=H,this.lines.onInsertEmitter.fire(D[V]),H+=D[V].amount;const W=Math.max(0,I+T-this.lines.maxLength);W>0&&this.lines.onTrimEmitter.fire(W)}}translateBufferLineToString(v,b,j=0,N){const T=this.lines.get(v);return T?T.translateToString(b,j,N):""}getWrappedRangeForLine(v){let b=v,j=v;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;j+1<this.lines.length&&this.lines.get(j+1).isWrapped;)j++;return{first:b,last:j}}setupTabStops(v){for(v!=null?this.tabs[v]||(v=this.prevStop(v)):(this.tabs={},v=0);v<this._cols;v+=this._optionsService.rawOptions.tabStopWidth)this.tabs[v]=!0}prevStop(v){for(v==null&&(v=this.x);!this.tabs[--v]&&v>0;);return v>=this._cols?this._cols-1:v<0?0:v}nextStop(v){for(v==null&&(v=this.x);!this.tabs[++v]&&v<this._cols;);return v>=this._cols?this._cols-1:v<0?0:v}clearMarkers(v){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].line===v&&(this.markers[b].dispose(),this.markers.splice(b--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].dispose(),this.markers.splice(v--,1);this._isClearing=!1}addMarker(v){const b=new _.Marker(v);return this.markers.push(b),b.register(this.lines.onTrim((j=>{b.line-=j,b.line<0&&b.dispose()}))),b.register(this.lines.onInsert((j=>{b.line>=j.index&&(b.line+=j.amount)}))),b.register(this.lines.onDelete((j=>{b.line>=j.index&&b.line<j.index+j.amount&&b.dispose(),b.line>j.index&&(b.line-=j.amount)}))),b.register(b.onDispose((()=>this._removeMarker(b)))),b}_removeMarker(v){this._isClearing||this.markers.splice(this.markers.indexOf(v),1)}}},8437:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const h=d(3734),p=d(511),m=d(643),x=d(482);c.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let y=0;class w{constructor(_,S,v=!1){this.isWrapped=v,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*_);const b=S||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let j=0;j<_;++j)this.setCell(j,b);this.length=_}get(_){const S=this._data[3*_+0],v=2097151&S;return[this._data[3*_+1],2097152&S?this._combined[_]:v?(0,x.stringFromCodePoint)(v):"",S>>22,2097152&S?this._combined[_].charCodeAt(this._combined[_].length-1):v]}set(_,S){this._data[3*_+1]=S[m.CHAR_DATA_ATTR_INDEX],S[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[_]=S[1],this._data[3*_+0]=2097152|_|S[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*_+0]=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(_){return this._data[3*_+0]>>22}hasWidth(_){return 12582912&this._data[3*_+0]}getFg(_){return this._data[3*_+1]}getBg(_){return this._data[3*_+2]}hasContent(_){return 4194303&this._data[3*_+0]}getCodePoint(_){const S=this._data[3*_+0];return 2097152&S?this._combined[_].charCodeAt(this._combined[_].length-1):2097151&S}isCombined(_){return 2097152&this._data[3*_+0]}getString(_){const S=this._data[3*_+0];return 2097152&S?this._combined[_]:2097151&S?(0,x.stringFromCodePoint)(2097151&S):""}isProtected(_){return 536870912&this._data[3*_+2]}loadCell(_,S){return y=3*_,S.content=this._data[y+0],S.fg=this._data[y+1],S.bg=this._data[y+2],2097152&S.content&&(S.combinedData=this._combined[_]),268435456&S.bg&&(S.extended=this._extendedAttrs[_]),S}setCell(_,S){2097152&S.content&&(this._combined[_]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[_]=S.extended),this._data[3*_+0]=S.content,this._data[3*_+1]=S.fg,this._data[3*_+2]=S.bg}setCellFromCodepoint(_,S,v,b){268435456&b.bg&&(this._extendedAttrs[_]=b.extended),this._data[3*_+0]=S|v<<22,this._data[3*_+1]=b.fg,this._data[3*_+2]=b.bg}addCodepointToCell(_,S,v){let b=this._data[3*_+0];2097152&b?this._combined[_]+=(0,x.stringFromCodePoint)(S):2097151&b?(this._combined[_]=(0,x.stringFromCodePoint)(2097151&b)+(0,x.stringFromCodePoint)(S),b&=-2097152,b|=2097152):b=S|4194304,v&&(b&=-12582913,b|=v<<22),this._data[3*_+0]=b}insertCells(_,S,v){if((_%=this.length)&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,v),S<this.length-_){const b=new p.CellData;for(let j=this.length-_-S-1;j>=0;--j)this.setCell(_+S+j,this.loadCell(_+j,b));for(let j=0;j<S;++j)this.setCell(_+j,v)}else for(let b=_;b<this.length;++b)this.setCell(b,v);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,v)}deleteCells(_,S,v){if(_%=this.length,S<this.length-_){const b=new p.CellData;for(let j=0;j<this.length-_-S;++j)this.setCell(_+j,this.loadCell(_+S+j,b));for(let j=this.length-S;j<this.length;++j)this.setCell(j,v)}else for(let b=_;b<this.length;++b)this.setCell(b,v);_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,v),this.getWidth(_)!==0||this.hasContent(_)||this.setCellFromCodepoint(_,0,1,v)}replaceCells(_,S,v,b=!1){if(b)for(_&&this.getWidth(_-1)===2&&!this.isProtected(_-1)&&this.setCellFromCodepoint(_-1,0,1,v),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,v);_<S&&_<this.length;)this.isProtected(_)||this.setCell(_,v),_++;else for(_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,v),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,v);_<S&&_<this.length;)this.setCell(_++,v)}resize(_,S){if(_===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const v=3*_;if(_>this.length){if(this._data.buffer.byteLength>=4*v)this._data=new Uint32Array(this._data.buffer,0,v);else{const b=new Uint32Array(v);b.set(this._data),this._data=b}for(let b=this.length;b<_;++b)this.setCell(b,S)}else{this._data=this._data.subarray(0,v);const b=Object.keys(this._combined);for(let N=0;N<b.length;N++){const T=parseInt(b[N],10);T>=_&&delete this._combined[T]}const j=Object.keys(this._extendedAttrs);for(let N=0;N<j.length;N++){const T=parseInt(j[N],10);T>=_&&delete this._extendedAttrs[T]}}return this.length=_,4*v*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const _=new Uint32Array(this._data.length);return _.set(this._data),this._data=_,1}return 0}fill(_,S=!1){if(S)for(let v=0;v<this.length;++v)this.isProtected(v)||this.setCell(v,_);else{this._combined={},this._extendedAttrs={};for(let v=0;v<this.length;++v)this.setCell(v,_)}}copyFrom(_){this.length!==_.length?this._data=new Uint32Array(_._data):this._data.set(_._data),this.length=_.length,this._combined={};for(const S in _._combined)this._combined[S]=_._combined[S];this._extendedAttrs={};for(const S in _._extendedAttrs)this._extendedAttrs[S]=_._extendedAttrs[S];this.isWrapped=_.isWrapped}clone(){const _=new w(0);_._data=new Uint32Array(this._data),_.length=this.length;for(const S in this._combined)_._combined[S]=this._combined[S];for(const S in this._extendedAttrs)_._extendedAttrs[S]=this._extendedAttrs[S];return _.isWrapped=this.isWrapped,_}getTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0])return _+(this._data[3*_+0]>>22);return 0}getNoBgTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0]||50331648&this._data[3*_+2])return _+(this._data[3*_+0]>>22);return 0}copyCellsFrom(_,S,v,b,j){const N=_._data;if(j)for(let D=b-1;D>=0;D--){for(let L=0;L<3;L++)this._data[3*(v+D)+L]=N[3*(S+D)+L];268435456&N[3*(S+D)+2]&&(this._extendedAttrs[v+D]=_._extendedAttrs[S+D])}else for(let D=0;D<b;D++){for(let L=0;L<3;L++)this._data[3*(v+D)+L]=N[3*(S+D)+L];268435456&N[3*(S+D)+2]&&(this._extendedAttrs[v+D]=_._extendedAttrs[S+D])}const T=Object.keys(_._combined);for(let D=0;D<T.length;D++){const L=parseInt(T[D],10);L>=S&&(this._combined[L-S+v]=_._combined[L])}}translateToString(_,S,v,b){S=S??0,v=v??this.length,_&&(v=Math.min(v,this.getTrimmedLength())),b&&(b.length=0);let j="";for(;S<v;){const N=this._data[3*S+0],T=2097151&N,D=2097152&N?this._combined[S]:T?(0,x.stringFromCodePoint)(T):m.WHITESPACE_CELL_CHAR;if(j+=D,b)for(let L=0;L<D.length;++L)b.push(S);S+=N>>22||1}return b&&b.push(S),j}}c.BufferLine=w},4841:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getRangeLength=void 0,c.getRangeLength=function(d,h){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 h*(d.end.y-d.start.y)+(d.end.x-d.start.x+1)}},4634:(u,c)=>{function d(h,p,m){if(p===h.length-1)return h[p].getTrimmedLength();const x=!h[p].hasContent(m-1)&&h[p].getWidth(m-1)===1,y=h[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(h,p,m,x,y){const w=[];for(let C=0;C<h.length-1;C++){let _=C,S=h.get(++_);if(!S.isWrapped)continue;const v=[h.get(C)];for(;_<h.length&&S.isWrapped;)v.push(S),S=h.get(++_);if(x>=C&&x<_){C+=v.length-1;continue}let b=0,j=d(v,b,p),N=1,T=0;for(;N<v.length;){const L=d(v,N,p),I=L-T,M=m-j,G=Math.min(I,M);v[b].copyCellsFrom(v[N],T,j,G,!1),j+=G,j===m&&(b++,j=0),T+=G,T===L&&(N++,T=0),j===0&&b!==0&&v[b-1].getWidth(m-1)===2&&(v[b].copyCellsFrom(v[b-1],m-1,j++,1,!1),v[b-1].setCell(m-1,y))}v[b].replaceCells(j,m,y);let D=0;for(let L=v.length-1;L>0&&(L>b||v[L].getTrimmedLength()===0);L--)D++;D>0&&(w.push(C+v.length-D),w.push(D)),C+=v.length-1}return w},c.reflowLargerCreateNewLayout=function(h,p){const m=[];let x=0,y=p[x],w=0;for(let C=0;C<h.length;C++)if(y===C){const _=p[++x];h.onDeleteEmitter.fire({index:C-w,amount:_}),C+=_-1,w+=_,y=p[++x]}else m.push(C);return{layout:m,countRemoved:w}},c.reflowLargerApplyNewLayout=function(h,p){const m=[];for(let x=0;x<p.length;x++)m.push(h.get(p[x]));for(let x=0;x<m.length;x++)h.set(x,m[x]);h.length=p.length},c.reflowSmallerGetNewLineLengths=function(h,p,m){const x=[],y=h.map(((S,v)=>d(h,v,p))).reduce(((S,v)=>S+v));let w=0,C=0,_=0;for(;_<y;){if(y-_<m){x.push(y-_);break}w+=m;const S=d(h,C,p);w>S&&(w-=S,C++);const v=h[C].getWidth(w-1)===2;v&&w--;const b=v?m-1:m;x.push(b),_+=b}return x},c.getWrappedLineTrimmedLength=d},5295:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const h=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 h.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new 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 h=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,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[p.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[p.CHAR_DATA_CHAR_INDEX].length===2){const _=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=_&&_<=56319){const S=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(_-55296)+S-56320+65536|w[p.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[p.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[p.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.CellData=x},643:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WHITESPACE_CELL_CODE=c.WHITESPACE_CELL_WIDTH=c.WHITESPACE_CELL_CHAR=c.NULL_CELL_CODE=c.NULL_CELL_WIDTH=c.NULL_CELL_CHAR=c.CHAR_DATA_CODE_INDEX=c.CHAR_DATA_WIDTH_INDEX=c.CHAR_DATA_CHAR_INDEX=c.CHAR_DATA_ATTR_INDEX=c.DEFAULT_EXT=c.DEFAULT_ATTR=c.DEFAULT_COLOR=void 0,c.DEFAULT_COLOR=0,c.DEFAULT_ATTR=256|c.DEFAULT_COLOR<<9,c.DEFAULT_EXT=0,c.CHAR_DATA_ATTR_INDEX=0,c.CHAR_DATA_CHAR_INDEX=1,c.CHAR_DATA_WIDTH_INDEX=2,c.CHAR_DATA_CODE_INDEX=3,c.NULL_CELL_CHAR="",c.NULL_CELL_WIDTH=1,c.NULL_CELL_CODE=0,c.WHITESPACE_CELL_CHAR=" ",c.WHITESPACE_CELL_WIDTH=1,c.WHITESPACE_CELL_CODE=32},4863:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Marker=void 0;const h=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 h.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,h,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=`
|
|
261
|
+
`,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=""})(h||(c.C1=h={})),(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 h=d(2584),p={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};c.evaluateKeyboardEvent=function(m,x,y,w){const C={type:0,cancel:!1,key:void 0},_=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?C.key=x?h.C0.ESC+"OA":h.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=x?h.C0.ESC+"OD":h.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=x?h.C0.ESC+"OC":h.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=x?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:C.key=m.ctrlKey?"\b":h.C0.DEL,m.altKey&&(C.key=h.C0.ESC+C.key);break;case 9:if(m.shiftKey){C.key=h.C0.ESC+"[Z";break}C.key=h.C0.HT,C.cancel=!0;break;case 13:C.key=m.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,C.cancel=!0;break;case 27:C.key=h.C0.ESC,m.altKey&&(C.key=h.C0.ESC+h.C0.ESC),C.cancel=!0;break;case 37:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"D",C.key===h.C0.ESC+"[1;3D"&&(C.key=h.C0.ESC+(y?"b":"[1;5D"))):C.key=x?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"C",C.key===h.C0.ESC+"[1;3C"&&(C.key=h.C0.ESC+(y?"f":"[1;5C"))):C.key=x?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"A",y||C.key!==h.C0.ESC+"[1;3A"||(C.key=h.C0.ESC+"[1;5A")):C.key=x?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"B",y||C.key!==h.C0.ESC+"[1;3B"||(C.key=h.C0.ESC+"[1;5B")):C.key=x?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:m.shiftKey||m.ctrlKey||(C.key=h.C0.ESC+"[2~");break;case 46:C.key=_?h.C0.ESC+"[3;"+(_+1)+"~":h.C0.ESC+"[3~";break;case 36:C.key=_?h.C0.ESC+"[1;"+(_+1)+"H":x?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:C.key=_?h.C0.ESC+"[1;"+(_+1)+"F":x?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:m.shiftKey?C.type=2:m.ctrlKey?C.key=h.C0.ESC+"[5;"+(_+1)+"~":C.key=h.C0.ESC+"[5~";break;case 34:m.shiftKey?C.type=3:m.ctrlKey?C.key=h.C0.ESC+"[6;"+(_+1)+"~":C.key=h.C0.ESC+"[6~";break;case 112:C.key=_?h.C0.ESC+"[1;"+(_+1)+"P":h.C0.ESC+"OP";break;case 113:C.key=_?h.C0.ESC+"[1;"+(_+1)+"Q":h.C0.ESC+"OQ";break;case 114:C.key=_?h.C0.ESC+"[1;"+(_+1)+"R":h.C0.ESC+"OR";break;case 115:C.key=_?h.C0.ESC+"[1;"+(_+1)+"S":h.C0.ESC+"OS";break;case 116:C.key=_?h.C0.ESC+"[15;"+(_+1)+"~":h.C0.ESC+"[15~";break;case 117:C.key=_?h.C0.ESC+"[17;"+(_+1)+"~":h.C0.ESC+"[17~";break;case 118:C.key=_?h.C0.ESC+"[18;"+(_+1)+"~":h.C0.ESC+"[18~";break;case 119:C.key=_?h.C0.ESC+"[19;"+(_+1)+"~":h.C0.ESC+"[19~";break;case 120:C.key=_?h.C0.ESC+"[20;"+(_+1)+"~":h.C0.ESC+"[20~";break;case 121:C.key=_?h.C0.ESC+"[21;"+(_+1)+"~":h.C0.ESC+"[21~";break;case 122:C.key=_?h.C0.ESC+"[23;"+(_+1)+"~":h.C0.ESC+"[23~";break;case 123:C.key=_?h.C0.ESC+"[24;"+(_+1)+"~":h.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=h.C0.US),m.key==="@"&&(C.key=h.C0.NUL)):m.keyCode===65&&(C.type=1);else{const S=p[m.keyCode],v=S==null?void 0:S[m.shiftKey?1:0];if(v)C.key=h.C0.ESC+v;else if(m.keyCode>=65&&m.keyCode<=90){const b=m.ctrlKey?m.keyCode-64:m.keyCode+32;let j=String.fromCharCode(b);m.shiftKey&&(j=j.toUpperCase()),C.key=h.C0.ESC+j}else if(m.keyCode===32)C.key=h.C0.ESC+(m.ctrlKey?h.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let b=m.code.slice(3,4);m.shiftKey||(b=b.toLowerCase()),C.key=h.C0.ESC+b,C.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?C.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?C.key=h.C0.NUL:m.keyCode>=51&&m.keyCode<=55?C.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?C.key=h.C0.DEL:m.keyCode===219?C.key=h.C0.ESC:m.keyCode===220?C.key=h.C0.FS:m.keyCode===221&&(C.key=h.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,h=0,p=d.length){let m="";for(let x=h;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,h){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?h[m++]=1024*(this._interim-55296)+y-56320+65536:(h[m++]=this._interim,h[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?h[m++]=1024*(w-55296)+C-56320+65536:(h[m++]=w,h[m++]=C)}else w!==65279&&(h[m++]=w)}return m}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,h){const p=d.length;if(!p)return 0;let m,x,y,w,C=0,_=0,S=0;if(this.interim[0]){let j=!1,N=this.interim[0];N&=(224&N)==192?31:(240&N)==224?15:7;let T,D=0;for(;(T=63&this.interim[++D])&&D<4;)N<<=6,N|=T;const L=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,I=L-D;for(;S<I;){if(S>=p)return 0;if(T=d[S++],(192&T)!=128){S--,j=!0;break}this.interim[D++]=T,N<<=6,N|=63&T}j||(L===2?N<128?S--:h[C++]=N:L===3?N<2048||N>=55296&&N<=57343||N===65279||(h[C++]=N):N<65536||N>1114111||(h[C++]=N)),this.interim.fill(0)}const v=p-4;let b=S;for(;b<p;){for(;!(!(b<v)||128&(m=d[b])||128&(x=d[b+1])||128&(y=d[b+2])||128&(w=d[b+3]));)h[C++]=m,h[C++]=x,h[C++]=y,h[C++]=w,b+=4;if(m=d[b++],m<128)h[C++]=m;else if((224&m)==192){if(b>=p)return this.interim[0]=m,C;if(x=d[b++],(192&x)!=128){b--;continue}if(_=(31&m)<<6|63&x,_<128){b--;continue}h[C++]=_}else if((240&m)==224){if(b>=p)return this.interim[0]=m,C;if(x=d[b++],(192&x)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[b++],(192&y)!=128){b--;continue}if(_=(15&m)<<12|(63&x)<<6|63&y,_<2048||_>=55296&&_<=57343||_===65279)continue;h[C++]=_}else if((248&m)==240){if(b>=p)return this.interim[0]=m,C;if(x=d[b++],(192&x)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[b++],(192&y)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=x,this.interim[2]=y,C;if(w=d[b++],(192&w)!=128){b--;continue}if(_=(7&m)<<18|(63&x)<<12|(63&y)<<6|63&w,_<65536||_>1114111)continue;h[C++]=_}}return C}}},225:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const h=d(1480),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],m=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let x;c.UnicodeV6=class{constructor(){if(this.version="6",!x){x=new Uint8Array(65536),x.fill(1),x[0]=0,x.fill(0,1,32),x.fill(0,127,160),x.fill(2,4352,4448),x[9001]=2,x[9002]=2,x.fill(2,11904,42192),x[12351]=1,x.fill(2,44032,55204),x.fill(2,63744,64256),x.fill(2,65040,65050),x.fill(2,65072,65136),x.fill(2,65280,65377),x.fill(2,65504,65511);for(let y=0;y<p.length;++y)x.fill(0,p[y][0],p[y][1]+1)}}wcwidth(y){return y<32?0:y<127?1:y<65536?x[y]:(function(w,C){let _,S=0,v=C.length-1;if(w<C[0][0]||w>C[v][1])return!1;for(;v>=S;)if(_=S+v>>1,w>C[_][1])S=_+1;else{if(!(w<C[_][0]))return!0;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),_=C===0&&w!==0;if(_){const S=h.UnicodeService.extractWidth(w);S===0?_=!1:S>C&&(C=S)}return h.UnicodeService.createPropertyValue(0,C,_)}}},5981:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const h=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 h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(y,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const _=this._callbacks.shift();_&&_()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(y,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(w)}_innerWrite(y=0,w=!0){const C=y||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const _=this._writeBuffer[this._bufferOffset],S=this._action(_,w);if(S){const b=j=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,j))):this._innerWrite(C,j);return void S.catch((j=>(queueMicrotask((()=>{throw j})),Promise.resolve(!1)))).then(b)}const v=this._callbacks[this._bufferOffset];if(v&&v(),this._bufferOffset++,this._pendingData-=_.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}c.WriteBuffer=m},5941:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.toRgbString=c.parseColor=void 0;const d=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,h=/^[\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),h.exec(x)&&[3,6,9,12].includes(x.length))){const y=x.length/3,w=[0,0,0];for(let C=0;C<3;++C){const _=parseInt(x.slice(y*C,y*C+y),16);w[C]=y===1?_<<4:y===2?_:y===3?_>>4:_>>8}return w}},c.toRgbString=function(m,x=16){const[y,w,C]=m;return`rgb:${p(y,x)}/${p(w,x)}/${p(C,x)}`}},5770:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.PAYLOAD_LIMIT=void 0,c.PAYLOAD_LIMIT=1e7},6351:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DcsHandler=c.DcsParser=void 0;const h=d(482),p=d(8742),m=d(5770),x=[];c.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=x,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=x}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const _=this._handlers[w];return _.push(C),{dispose:()=>{const S=_.indexOf(C);S!==-1&&_.splice(S,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=x,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||x,this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,_){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,C,_);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(w,C,_))}unhook(w,C=!0){if(this._active.length){let _=!1,S=this._active.length-1,v=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,_=C,v=this._stack.fallThrough,this._stack.paused=!1),!v&&_===!1){for(;S>=0&&(_=this._active[S].unhook(w),_!==!0);S--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,_;S--}for(;S>=0;S--)if(_=this._active[S].unhook(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,_}else this._handlerFb(this._ident,"UNHOOK",w);this._active=x,this._ident=0}};const y=new p.Params;y.addParam(0),c.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=y,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():y,this._data="",this._hitLimit=!1}put(w,C,_){this._hitLimit||(this._data+=(0,h.utf32ToString)(w,C,_),this._data.length>m.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((_=>(this._params=y,this._data="",this._hitLimit=!1,_)));return this._params=y,this._data="",this._hitLimit=!1,C}}},2015:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.EscapeSequenceParser=c.VT500_TRANSITION_TABLE=c.TransitionTable=void 0;const h=d(844),p=d(8742),m=d(6242),x=d(6351);class y{constructor(S){this.table=new Uint8Array(S)}setDefault(S,v){this.table.fill(S<<4|v)}add(S,v,b,j){this.table[v<<8|S]=b<<4|j}addMany(S,v,b,j){for(let N=0;N<S.length;N++)this.table[v<<8|S[N]]=b<<4|j}}c.TransitionTable=y;const w=160;c.VT500_TRANSITION_TABLE=(function(){const _=new y(4095),S=Array.apply(null,Array(256)).map(((D,L)=>L)),v=(D,L)=>S.slice(D,L),b=v(32,127),j=v(0,24);j.push(25),j.push.apply(j,v(28,32));const N=v(0,14);let T;for(T in _.setDefault(1,0),_.addMany(b,0,2,0),N)_.addMany([24,26,153,154],T,3,0),_.addMany(v(128,144),T,3,0),_.addMany(v(144,152),T,3,0),_.add(156,T,0,0),_.add(27,T,11,1),_.add(157,T,4,8),_.addMany([152,158,159],T,0,7),_.add(155,T,11,3),_.add(144,T,11,9);return _.addMany(j,0,3,0),_.addMany(j,1,3,1),_.add(127,1,0,1),_.addMany(j,8,0,8),_.addMany(j,3,3,3),_.add(127,3,0,3),_.addMany(j,4,3,4),_.add(127,4,0,4),_.addMany(j,6,3,6),_.addMany(j,5,3,5),_.add(127,5,0,5),_.addMany(j,2,3,2),_.add(127,2,0,2),_.add(93,1,4,8),_.addMany(b,8,5,8),_.add(127,8,5,8),_.addMany([156,27,24,26,7],8,6,0),_.addMany(v(28,32),8,0,8),_.addMany([88,94,95],1,0,7),_.addMany(b,7,0,7),_.addMany(j,7,0,7),_.add(156,7,0,0),_.add(127,7,0,7),_.add(91,1,11,3),_.addMany(v(64,127),3,7,0),_.addMany(v(48,60),3,8,4),_.addMany([60,61,62,63],3,9,4),_.addMany(v(48,60),4,8,4),_.addMany(v(64,127),4,7,0),_.addMany([60,61,62,63],4,0,6),_.addMany(v(32,64),6,0,6),_.add(127,6,0,6),_.addMany(v(64,127),6,0,0),_.addMany(v(32,48),3,9,5),_.addMany(v(32,48),5,9,5),_.addMany(v(48,64),5,0,6),_.addMany(v(64,127),5,7,0),_.addMany(v(32,48),4,9,5),_.addMany(v(32,48),1,9,2),_.addMany(v(32,48),2,9,2),_.addMany(v(48,127),2,10,0),_.addMany(v(48,80),1,10,0),_.addMany(v(81,88),1,10,0),_.addMany([89,90,92],1,10,0),_.addMany(v(96,127),1,10,0),_.add(80,1,11,9),_.addMany(j,9,0,9),_.add(127,9,0,9),_.addMany(v(28,32),9,0,9),_.addMany(v(32,48),9,9,12),_.addMany(v(48,60),9,8,10),_.addMany([60,61,62,63],9,9,10),_.addMany(j,11,0,11),_.addMany(v(32,128),11,0,11),_.addMany(v(28,32),11,0,11),_.addMany(j,10,0,10),_.add(127,10,0,10),_.addMany(v(28,32),10,0,10),_.addMany(v(48,60),10,8,10),_.addMany([60,61,62,63],10,0,11),_.addMany(v(32,48),10,9,12),_.addMany(j,12,0,12),_.add(127,12,0,12),_.addMany(v(28,32),12,0,12),_.addMany(v(32,48),12,9,12),_.addMany(v(48,64),12,0,11),_.addMany(v(64,127),12,12,13),_.addMany(v(64,127),10,12,13),_.addMany(v(64,127),9,12,13),_.addMany(j,13,13,13),_.addMany(b,13,13,13),_.add(127,13,0,13),_.addMany([27,156,24,26],13,14,0),_.add(w,0,2,0),_.add(w,8,5,8),_.add(w,6,0,6),_.add(w,11,0,11),_.add(w,13,13,13),_})();class C extends h.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=(v,b,j)=>{},this._executeHandlerFb=v=>{},this._csiHandlerFb=(v,b)=>{},this._escHandlerFb=v=>{},this._errorHandlerFb=v=>v,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new m.OscParser),this._dcsParser=this.register(new x.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,v=[64,126]){let b=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(b=S.prefix.charCodeAt(0),b&&60>b||b>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(S.intermediates){if(S.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let N=0;N<S.intermediates.length;++N){const T=S.intermediates.charCodeAt(N);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");b<<=8,b|=T}}if(S.final.length!==1)throw new Error("final must be a single byte");const j=S.final.charCodeAt(0);if(v[0]>j||j>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return b<<=8,b|=j,b}identToString(S){const v=[];for(;S;)v.push(String.fromCharCode(255&S)),S>>=8;return v.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,v){const b=this._identifier(S,[48,126]);this._escHandlers[b]===void 0&&(this._escHandlers[b]=[]);const j=this._escHandlers[b];return j.push(v),{dispose:()=>{const N=j.indexOf(v);N!==-1&&j.splice(N,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,v){this._executeHandlers[S.charCodeAt(0)]=v}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,v){const b=this._identifier(S);this._csiHandlers[b]===void 0&&(this._csiHandlers[b]=[]);const j=this._csiHandlers[b];return j.push(v),{dispose:()=>{const N=j.indexOf(v);N!==-1&&j.splice(N,1)}}}clearCsiHandler(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,v){return this._dcsParser.registerHandler(this._identifier(S),v)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,v){return this._oscParser.registerHandler(S,v)}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,v,b,j,N){this._parseStack.state=S,this._parseStack.handlers=v,this._parseStack.handlerPos=b,this._parseStack.transition=j,this._parseStack.chunkPos=N}parse(S,v,b){let j,N=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(b===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const L=this._parseStack.handlers;let I=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(b===!1&&I>-1){for(;I>=0&&(j=L[I](this._params),j!==!0);I--)if(j instanceof Promise)return this._parseStack.handlerPos=I,j}this._parseStack.handlers=[];break;case 4:if(b===!1&&I>-1){for(;I>=0&&(j=L[I](),j!==!0);I--)if(j instanceof Promise)return this._parseStack.handlerPos=I,j}this._parseStack.handlers=[];break;case 6:if(N=S[this._parseStack.chunkPos],j=this._dcsParser.unhook(N!==24&&N!==26,b),j)return j;N===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(N=S[this._parseStack.chunkPos],j=this._oscParser.end(N!==24&&N!==26,b),j)return j;N===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<v;++L){switch(N=S[L],T=this._transitions.table[this.currentState<<8|(N<160?N:w)],T>>4){case 2:for(let R=L+1;;++R){if(R>=v||(N=S[R])<32||N>126&&N<w){this._printHandler(S,L,R),L=R-1;break}if(++R>=v||(N=S[R])<32||N>126&&N<w){this._printHandler(S,L,R),L=R-1;break}if(++R>=v||(N=S[R])<32||N>126&&N<w){this._printHandler(S,L,R),L=R-1;break}if(++R>=v||(N=S[R])<32||N>126&&N<w){this._printHandler(S,L,R),L=R-1;break}}break;case 3:this._executeHandlers[N]?this._executeHandlers[N]():this._executeHandlerFb(N),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:L,code:N,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const I=this._csiHandlers[this._collect<<8|N];let M=I?I.length-1:-1;for(;M>=0&&(j=I[M](this._params),j!==!0);M--)if(j instanceof Promise)return this._preserveStack(3,I,M,T,L),j;M<0&&this._csiHandlerFb(this._collect<<8|N,this._params),this.precedingJoinState=0;break;case 8:do switch(N){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(N-48)}while(++L<v&&(N=S[L])>47&&N<60);L--;break;case 9:this._collect<<=8,this._collect|=N;break;case 10:const G=this._escHandlers[this._collect<<8|N];let U=G?G.length-1:-1;for(;U>=0&&(j=G[U](),j!==!0);U--)if(j instanceof Promise)return this._preserveStack(4,G,U,T,L),j;U<0&&this._escHandlerFb(this._collect<<8|N),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|N,this._params);break;case 13:for(let R=L+1;;++R)if(R>=v||(N=S[R])===24||N===26||N===27||N>127&&N<w){this._dcsParser.put(S,L,R),L=R-1;break}break;case 14:if(j=this._dcsParser.unhook(N!==24&&N!==26),j)return this._preserveStack(6,[],0,T,L),j;N===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let R=L+1;;R++)if(R>=v||(N=S[R])<32||N>127&&N<w){this._oscParser.put(S,L,R),L=R-1;break}break;case 6:if(j=this._oscParser.end(N!==24&&N!==26),j)return this._preserveStack(5,[],0,T,L),j;N===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 h=d(5770),p=d(482),m=[];c.OscParser=class{constructor(){this._state=0,this._active=m,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(x,y){this._handlers[x]===void 0&&(this._handlers[x]=[]);const w=this._handlers[x];return w.push(y),{dispose:()=>{const C=w.indexOf(y);C!==-1&&w.splice(C,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].end(!1);this._stack.paused=!1,this._active=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].start();else this._handlerFb(this._id,"START")}_put(x,y,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(x,y,w);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(x,y,w))}start(){this.reset(),this._state=1}put(x,y,w){if(this._state!==3){if(this._state===1)for(;y<w;){const C=x[y++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-y>0&&this._put(x,y,w)}}end(x,y=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,_=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=y,_=this._stack.fallThrough,this._stack.paused=!1),!_&&w===!1){for(;C>=0&&(w=this._active[C].end(x),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",x);this._active=m,this._id=-1,this._state=0}}},c.OscHandler=class{constructor(x){this._handler=x,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(x,y,w){this._hitLimit||(this._data+=(0,p.utf32ToString)(x,y,w),this._data.length>h.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 h{static fromArray(m){const x=new h;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 h(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=h},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,h){const p={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(p),h.dispose=()=>this._wrappedAddonDispose(p),h.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let h=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===d){h=p;break}if(h===-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(h,1)}}},8771:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferApiView=void 0;const h=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 h.BufferLineApiView(x)}getNullCell(){return new p.CellData}}},3785:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const h=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 h.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 h=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 h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}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,h){return this._core.registerCsiHandler(d,(p=>h(p.toArray())))}addCsiHandler(d,h){return this.registerCsiHandler(d,h)}registerDcsHandler(d,h){return this._core.registerDcsHandler(d,((p,m)=>h(p,m.toArray())))}addDcsHandler(d,h){return this.registerDcsHandler(d,h)}registerEscHandler(d,h){return this._core.registerEscHandler(d,h)}addEscHandler(d,h){return this.registerEscHandler(d,h)}registerOscHandler(d,h){return this._core.registerOscHandler(d,h)}addOscHandler(d,h){return this.registerOscHandler(d,h)}}},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 h=this&&this.__decorate||function(_,S,v,b){var j,N=arguments.length,T=N<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,v):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,v,b);else for(var D=_.length-1;D>=0;D--)(j=_[D])&&(T=(N<3?j(T):N>3?j(S,v,T):j(S,v))||T);return N>3&&T&&Object.defineProperty(S,v,T),T},p=this&&this.__param||function(_,S){return function(v,b){S(v,b,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const m=d(8460),x=d(844),y=d(5295),w=d(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let C=c.BufferService=class extends x.Disposable{get buffer(){return this.buffers.active}constructor(_){super(),this.isUserScrolling=!1,this._onResize=this.register(new m.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new m.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(_.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(_.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new y.BufferSet(_,this))}resize(_,S){this.cols=_,this.rows=S,this.buffers.resize(_,S),this._onResize.fire({cols:_,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(_,S=!1){const v=this.buffer;let b;b=this._cachedBlankLine,b&&b.length===this.cols&&b.getFg(0)===_.fg&&b.getBg(0)===_.bg||(b=v.getBlankLine(_,S),this._cachedBlankLine=b),b.isWrapped=S;const j=v.ybase+v.scrollTop,N=v.ybase+v.scrollBottom;if(v.scrollTop===0){const T=v.lines.isFull;N===v.lines.length-1?T?v.lines.recycle().copyFrom(b):v.lines.push(b.clone()):v.lines.splice(N+1,0,b.clone()),T?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const T=N-j+1;v.lines.shiftElements(j+1,T-1,-1),v.lines.set(N,b.clone())}this.isUserScrolling||(v.ydisp=v.ybase),this._onScroll.fire(v.ydisp)}scrollLines(_,S,v){const b=this.buffer;if(_<0){if(b.ydisp===0)return;this.isUserScrolling=!0}else _+b.ydisp>=b.ybase&&(this.isUserScrolling=!1);const j=b.ydisp;b.ydisp=Math.max(Math.min(b.ydisp+_,b.ybase),0),j!==b.ydisp&&(S||this._onScroll.fire(b.ydisp))}};c.BufferService=C=h([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,h){this._charsets[d]=h,this.glevel===d&&(this.charset=h)}}},1753:function(u,c,d){var h=this&&this.__decorate||function(b,j,N,T){var D,L=arguments.length,I=L<3?j:T===null?T=Object.getOwnPropertyDescriptor(j,N):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(b,j,N,T);else for(var M=b.length-1;M>=0;M--)(D=b[M])&&(I=(L<3?D(I):L>3?D(j,N,I):D(j,N))||I);return L>3&&I&&Object.defineProperty(j,N,I),I},p=this&&this.__param||function(b,j){return function(N,T){j(N,T,b)}};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:b=>b.button!==4&&b.action===1&&(b.ctrl=!1,b.alt=!1,b.shift=!1,!0)},VT200:{events:19,restrict:b=>b.action!==32},DRAG:{events:23,restrict:b=>b.action!==32||b.button!==3},ANY:{events:31,restrict:b=>!0}};function C(b,j){let N=(b.ctrl?16:0)|(b.shift?4:0)|(b.alt?8:0);return b.button===4?(N|=64,N|=b.action):(N|=3&b.button,4&b.button&&(N|=64),8&b.button&&(N|=128),b.action===32?N|=32:b.action!==0||j||(N|=3)),N}const _=String.fromCharCode,S={DEFAULT:b=>{const j=[C(b,!1)+32,b.col+32,b.row+32];return j[0]>255||j[1]>255||j[2]>255?"":`\x1B[M${_(j[0])}${_(j[1])}${_(j[2])}`},SGR:b=>{const j=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.col};${b.row}${j}`},SGR_PIXELS:b=>{const j=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.x};${b.y}${j}`}};let v=c.CoreMouseService=class extends y.Disposable{constructor(b,j){super(),this._bufferService=b,this._coreService=j,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new x.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const N of Object.keys(w))this.addProtocol(N,w[N]);for(const N of Object.keys(S))this.addEncoding(N,S[N]);this.reset()}addProtocol(b,j){this._protocols[b]=j}addEncoding(b,j){this._encodings[b]=j}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(b){if(!this._protocols[b])throw new Error(`unknown protocol "${b}"`);this._activeProtocol=b,this._onProtocolChange.fire(this._protocols[b].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(b){if(!this._encodings[b])throw new Error(`unknown encoding "${b}"`);this._activeEncoding=b}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(b){if(b.col<0||b.col>=this._bufferService.cols||b.row<0||b.row>=this._bufferService.rows||b.button===4&&b.action===32||b.button===3&&b.action!==32||b.button!==4&&(b.action===2||b.action===3)||(b.col++,b.row++,b.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,b,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(b))return!1;const j=this._encodings[this._activeEncoding](b);return j&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(j):this._coreService.triggerDataEvent(j,!0)),this._lastEvent=b,!0}explainEvents(b){return{down:!!(1&b),up:!!(2&b),drag:!!(4&b),move:!!(8&b),wheel:!!(16&b)}}_equalEvents(b,j,N){if(N){if(b.x!==j.x||b.y!==j.y)return!1}else if(b.col!==j.col||b.row!==j.row)return!1;return b.button===j.button&&b.action===j.action&&b.ctrl===j.ctrl&&b.alt===j.alt&&b.shift===j.shift}};c.CoreMouseService=v=h([p(0,m.IBufferService),p(1,m.ICoreService)],v)},6975:function(u,c,d){var h=this&&this.__decorate||function(v,b,j,N){var T,D=arguments.length,L=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,j):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(v,b,j,N);else for(var I=v.length-1;I>=0;I--)(T=v[I])&&(L=(D<3?T(L):D>3?T(b,j,L):T(b,j))||L);return D>3&&L&&Object.defineProperty(b,j,L),L},p=this&&this.__param||function(v,b){return function(j,N){b(j,N,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const m=d(1439),x=d(8460),y=d(844),w=d(2585),C=Object.freeze({insertMode:!1}),_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let S=c.CoreService=class extends y.Disposable{constructor(v,b,j){super(),this._bufferService=v,this._logService=b,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)(_)}reset(){this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(_)}triggerDataEvent(v,b=!1){if(this._optionsService.rawOptions.disableStdin)return;const j=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&j.ybase!==j.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${v}"`,(()=>v.split("").map((N=>N.charCodeAt(0))))),this._onData.fire(v)}triggerBinaryEvent(v){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${v}"`,(()=>v.split("").map((b=>b.charCodeAt(0))))),this._onBinary.fire(v))}};c.CoreService=S=h([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 h=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((v=>v==null?void 0:v.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(v){if(v.marker.isDisposed)return;const b=new _(v);if(b){const j=b.marker.onDispose((()=>b.dispose()));b.onDispose((()=>{b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),j.dispose())})),this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(const v of this._decorations.values())v.dispose();this._decorations.clear()}*getDecorationsAtCell(v,b,j){let N=0,T=0;for(const D of this._decorations.getKeyIterator(b))N=D.options.x??0,T=N+(D.options.width??1),v>=N&&v<T&&(!j||(D.options.layer??"bottom")===j)&&(yield D)}forEachDecorationAtCell(v,b,j,N){this._decorations.forEachByKey(b,(T=>{y=T.options.x??0,w=y+(T.options.width??1),v>=y&&v<w&&(!j||(T.options.layer??"bottom")===j)&&N(T)}))}}c.DecorationService=C;class _ extends m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(v){super(),this.options=v,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=v.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 h=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(h.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,v)=>S.index-v.index)),C=[];for(const S of w){const v=this._services.get(S.id);if(!v)throw new Error(`[createInstance] ${x.name} depends on UNKNOWN service ${S.id}.`);C.push(v)}const _=w.length>0?w[0].index:y.length;if(y.length!==_)throw new Error(`[createInstance] First service dependency of ${x.name} at position ${_+1} conflicts with ${y.length} static arguments`);return new x(...y,...C)}}},7866:function(u,c,d){var h=this&&this.__decorate||function(_,S,v,b){var j,N=arguments.length,T=N<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,v):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,v,b);else for(var D=_.length-1;D>=0;D--)(j=_[D])&&(T=(N<3?j(T):N>3?j(S,v,T):j(S,v))||T);return N>3&&T&&Object.defineProperty(S,v,T),T},p=this&&this.__param||function(_,S){return function(v,b){S(v,b,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const m=d(844),x=d(2585),y={trace:x.LogLevelEnum.TRACE,debug:x.LogLevelEnum.DEBUG,info:x.LogLevelEnum.INFO,warn:x.LogLevelEnum.WARN,error:x.LogLevelEnum.ERROR,off:x.LogLevelEnum.OFF};let w,C=c.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(_){super(),this._optionsService=_,this._logLevel=x.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=y[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(_){for(let S=0;S<_.length;S++)typeof _[S]=="function"&&(_[S]=_[S]())}_log(_,S,v){this._evalLazyOptionalParams(v),_.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...v)}trace(_,...S){var v;this._logLevel<=x.LogLevelEnum.TRACE&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.trace.bind(this._optionsService.options.logger))??console.log,_,S)}debug(_,...S){var v;this._logLevel<=x.LogLevelEnum.DEBUG&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.debug.bind(this._optionsService.options.logger))??console.log,_,S)}info(_,...S){var v;this._logLevel<=x.LogLevelEnum.INFO&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.info.bind(this._optionsService.options.logger))??console.info,_,S)}warn(_,...S){var v;this._logLevel<=x.LogLevelEnum.WARN&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.warn.bind(this._optionsService.options.logger))??console.warn,_,S)}error(_,...S){var v;this._logLevel<=x.LogLevelEnum.ERROR&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.error.bind(this._optionsService.options.logger))??console.error,_,S)}};c.LogService=C=h([p(0,x.IOptionsService)],C),c.setTraceLogger=function(_){w=_},c.traceCall=function(_,S,v){if(typeof v.value!="function")throw new Error("not supported");const b=v.value;v.value=function(...j){if(w.logLevel!==x.LogLevelEnum.TRACE)return b.apply(this,j);w.trace(`GlyphRenderer#${b.name}(${j.map((T=>JSON.stringify(T))).join(", ")})`);const N=b.apply(this,j);return w.trace(`GlyphRenderer#${b.name} return`,N),N}}},7302:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const h=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 h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const _={...c.DEFAULT_OPTIONS};for(const S in C)if(S in _)try{const v=C[S];_[S]=this._sanitizeAndValidateOption(S,v)}catch(v){console.error(v)}this.rawOptions=_,this.options={..._},this._setupOptions(),this.register((0,p.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,_){return this.onOptionChange((S=>{S===C&&_(this.rawOptions[C])}))}onMultipleOptionChange(C,_){return this.onOptionChange((S=>{C.indexOf(S)!==-1&&_()}))}_setupOptions(){const C=S=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},_=(S,v)=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);v=this._sanitizeAndValidateOption(S,v),this.rawOptions[S]!==v&&(this.rawOptions[S]=v,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const v={get:C.bind(this,S),set:_.bind(this,S)};Object.defineProperty(this.options,S,v)}}_sanitizeAndValidateOption(C,_){switch(C){case"cursorStyle":if(_||(_=c.DEFAULT_OPTIONS[C]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(_))throw new Error(`"${_}" is not a valid value for ${C}`);break;case"wordSeparator":_||(_=c.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof _=="number"&&1<=_&&_<=1e3)break;_=x.includes(_)?_:c.DEFAULT_OPTIONS[C];break;case"cursorWidth":_=Math.floor(_);case"lineHeight":case"tabStopWidth":if(_<1)throw new Error(`${C} cannot be less than 1, value: ${_}`);break;case"minimumContrastRatio":_=Math.max(1,Math.min(21,Math.round(10*_)/10));break;case"scrollback":if((_=Math.min(_,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${_}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(_<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${_}`);break;case"rows":case"cols":if(!_&&_!==0)throw new Error(`${C} must be numeric, value: ${_}`);break;case"windowsPty":_=_??{}}return _}}c.OptionsService=y},2660:function(u,c,d){var h=this&&this.__decorate||function(y,w,C,_){var S,v=arguments.length,b=v<3?w:_===null?_=Object.getOwnPropertyDescriptor(w,C):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,w,C,_);else for(var j=y.length-1;j>=0;j--)(S=y[j])&&(b=(v<3?S(b):v>3?S(w,C,b):S(w,C))||b);return v>3&&b&&Object.defineProperty(w,C,b),b},p=this&&this.__param||function(y,w){return function(C,_){w(C,_,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const m=d(2585);let x=c.OscLinkService=class{constructor(y){this._bufferService=y,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(y){const w=this._bufferService.buffer;if(y.id===void 0){const j=w.addMarker(w.ybase+w.y),N={data:y,id:this._nextId++,lines:[j]};return j.onDispose((()=>this._removeMarkerFromLink(N,j))),this._dataByLinkId.set(N.id,N),N.id}const C=y,_=this._getEntryIdKey(C),S=this._entriesWithId.get(_);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const v=w.addMarker(w.ybase+w.y),b={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(b,v))),this._entriesWithId.set(b.key,b),this._dataByLinkId.set(b.id,b),b.id}addLineToLink(y,w){const C=this._dataByLinkId.get(y);if(C&&C.lines.every((_=>_.line!==w))){const _=this._bufferService.buffer.addMarker(w);C.lines.push(_),_.onDispose((()=>this._removeMarkerFromLink(C,_)))}}getLinkData(y){var w;return(w=this._dataByLinkId.get(y))==null?void 0:w.data}_getEntryIdKey(y){return`${y.id};;${y.uri}`}_removeMarkerFromLink(y,w){const C=y.lines.indexOf(w);C!==-1&&(y.lines.splice(C,1),y.lines.length===0&&(y.data.id!==void 0&&this._entriesWithId.delete(y.key),this._dataByLinkId.delete(y.id)))}};c.OscLinkService=x=h([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",h="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(p){return p[h]||[]},c.createDecorator=function(p){if(c.serviceRegistry.has(p))return c.serviceRegistry.get(p);const m=function(x,y,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,_,S){_[d]===_?_[h].push({id:C,index:S}):(_[h]=[{id:C,index:S}],_[d]=_)})(m,x,w)};return m.toString=()=>p,c.serviceRegistry.set(p,m),m}},2585:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.IDecorationService=c.IUnicodeService=c.IOscLinkService=c.IOptionsService=c.ILogService=c.LogLevelEnum=c.IInstantiationService=c.ICharsetService=c.ICoreService=c.ICoreMouseService=c.IBufferService=void 0;const h=d(8343);var p;c.IBufferService=(0,h.createDecorator)("BufferService"),c.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),c.ICoreService=(0,h.createDecorator)("CoreService"),c.ICharsetService=(0,h.createDecorator)("CharsetService"),c.IInstantiationService=(0,h.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,h.createDecorator)("LogService"),c.IOptionsService=(0,h.createDecorator)("OptionsService"),c.IOscLinkService=(0,h.createDecorator)("OscLinkService"),c.IUnicodeService=(0,h.createDecorator)("UnicodeService"),c.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const h=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 h.EventEmitter,this.onChange=this._onChange.event;const y=new p.UnicodeV6;this.register(y),this._active=y.version,this._activeProvider=y}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(y){if(!this._providers[y])throw new Error(`unknown Unicode version "${y}"`);this._active=y,this._activeProvider=this._providers[y],this._onChange.fire(y)}register(y){this._providers[y.version]=y}wcwidth(y){return this._activeProvider.wcwidth(y)}getStringCellWidth(y){let w=0,C=0;const _=y.length;for(let S=0;S<_;++S){let v=y.charCodeAt(S);if(55296<=v&&v<=56319){if(++S>=_)return w+this.wcwidth(v);const N=y.charCodeAt(S);56320<=N&&N<=57343?v=1024*(v-55296)+N-56320+65536:w+=this.wcwidth(N)}const b=this.charProperties(v,C);let j=m.extractWidth(b);m.extractShouldJoin(b)&&(j-=m.extractWidth(C)),w+=j,C=b}return w}charProperties(y,w){return this._activeProvider.charProperties(y,w)}}c.UnicodeService=m}},r={};function a(u){var c=r[u];if(c!==void 0)return c.exports;var d=r[u]={exports:{}};return n[u].call(d.exports,d,d.exports,a),d.exports}var l={};return(()=>{var u=l;Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const c=a(9042),d=a(3236),h=a(844),p=a(5741),m=a(8285),x=a(7975),y=a(7090),w=["cols","rows"];class C extends h.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 v=j=>this._core.options[j],b=(j,N)=>{this._checkReadonlyOptions(j),this._core.options[j]=N};for(const j in this._core.options){const N={get:v.bind(this,j),set:b.bind(this,j)};Object.defineProperty(this._publicOptions,j,N)}}_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 v="none";switch(this._core.coreMouseService.activeProtocol){case"X10":v="x10";break;case"VT200":v="vt200";break;case"DRAG":v="drag";break;case"ANY":v="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:v,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const v in S)this._publicOptions[v]=S[v]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,v=!0){this._core.input(S,v)}resize(S,v){this._verifyIntegers(S,v),this._core.resize(S,v)}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,v,b){this._verifyIntegers(S,v,b),this._core.select(S,v,b)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,v){this._verifyIntegers(S,v),this._core.selectLines(S,v)}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,v){this._core.write(S,v)}writeln(S,v){this._core.write(S),this._core.write(`\r
|
|
262
|
+
`,v)}paste(S){this._core.paste(S)}refresh(S,v){this._verifyIntegers(S,v),this._core.refresh(S,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return c}_verifyIntegers(...S){for(const v of S)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const v of S)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}u.Terminal=C})(),l})()))})(up)),up.exports}var Z6=J6();/**
|
|
263
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
264
|
+
* @license MIT
|
|
265
|
+
*
|
|
266
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
267
|
+
* @license MIT
|
|
268
|
+
*
|
|
269
|
+
* Originally forked from (with the author's permission):
|
|
270
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
271
|
+
* http://bellard.org/jslinux/
|
|
272
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
273
|
+
*/var eB=2,tB=1,nB=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},c=u.top+u.bottom,d=u.right+u.left,h=r-c,p=a-d-t;return{cols:Math.max(eB,Math.floor(p/e.css.cell.width)),rows:Math.max(tB,Math.floor(h/e.css.cell.height))}}};function rB({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=E.useRef(null),l=E.useRef(e),u=E.useRef(null),c=E.useRef(null),d=Ir(p=>p.writeSession),h=Ir(p=>p.resizeSession);return E.useEffect(()=>{l.current=e},[e]),E.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]),E.useEffect(()=>{if(!a.current)return;const p=new Z6.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),m=new nB;p.loadAddon(m),u.current={term:p,fitAddon:m},a.current.addEventListener("keydown",C=>{C.key==="Escape"&&n&&(C.preventDefault(),C.stopPropagation(),n())}),p.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),m.fit(),r&&setTimeout(()=>{p.focus()},150);const y=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var _;m.fit&&m.fit();const C=(_=u.current)==null?void 0:_.term;C&&C.cols>0&&C.rows>0&&h(l.current,C.cols,C.rows)})},100)});y.observe(a.current),p.onData(C=>{if(C==="\x1B"&&n){n();return}d(l.current,C)}),p.onKey(C=>{C.key==="\x1B"&&n&&(C.domEvent.stopPropagation(),n())});const w=Lt.subscribe(C=>{const _=C.payload;if(C.type==="terminal.output"&&(_==null?void 0:_.sessionId)===l.current){const S=_==null?void 0:_.data;S&&p.write(S)}});return()=>{w(),y.disconnect(),c.current&&clearTimeout(c.current),p.dispose(),u.current=null}},[e,d,h]),i.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[i.jsx("div",{}),i.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:i.jsx(dg,{})})]}),i.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),n())}})]})}const Ok="openfox-chat-textarea";function Kl(e){const t=document.getElementById(Ok);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function sB(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 iB({isOpen:e,onClose:t}){const n=Ir(C=>C.createSession),r=Ir(C=>C.killSession),a=Ir(C=>C.sessions),l=Ir(C=>C.setWorkdir),u=Ir(C=>C.fetchSessions),c=Wt(C=>C.currentProject),d=Le(C=>C.currentSession),[h,p]=E.useState(!0),m=E.useRef(null),x=E.useRef(!1),y=E.useRef(!1),w=E.useCallback(()=>{t()},[t]);return E.useEffect(()=>{const C=(d==null?void 0:d.workspace)??(c==null?void 0:c.workdir);C&&l(C)},[d==null?void 0:d.workspace,c==null?void 0:c.workdir,l]),E.useEffect(()=>{e?(p(!0),u(c==null?void 0:c.id).finally(()=>p(!1))):Kl()},[e,u,c==null?void 0:c.id]),E.useEffect(()=>{e&&a.length===0&&!h&&!y.current&&(y.current=!0,n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)))},[e,a.length,h,n,d==null?void 0:d.projectId,c==null?void 0:c.id]),E.useEffect(()=>{e?(x.current=!0,setTimeout(()=>{var C;(C=m.current)==null||C.focus(),setTimeout(()=>{x.current=!1},200)},100)):y.current=!1},[e]),E.useEffect(()=>{if(!e)return;const C=_=>{x.current||_.key==="Escape"&&(_.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:w}),i.jsxs("div",{ref:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),w())},children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:i.jsx(pT,{})}),i.jsx("button",{onClick:t,className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:i.jsx(Ns,{})})]})]}),i.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:h?i.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?i.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"mb-4",children:"No terminal sessions"}),i.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):i.jsx("div",{className:`grid ${sB(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>i.jsx(rB,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1},C.id))})})]})]}):null}function ic({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",isOpen:a,onOpenChange:l}){const[u,c]=E.useState(!1),d=a!==void 0,h=d?a:u,p=R=>{if(d){const H=typeof R=="function"?R(u):R;l==null||l(H)}else c(R)},[m,x]=E.useState(null),y=E.useRef(null),w=E.useRef(null),[C,_]=E.useState(0),S=E.useRef(0),v=E.useMemo(()=>[...e,...t],[e,t]),b=E.useRef(v),j=E.useCallback(()=>{if(!y.current)return;const R=y.current.getBoundingClientRect(),H=200,V=window.innerHeight-R.bottom<H;x({top:V?R.top-H-4:R.bottom+4,left:R.left,alignToTop:V})},[]);E.useEffect(()=>{b.current=v},[v]),E.useEffect(()=>{function R(H){if(w.current){const W=H.target;w.current.contains(W)||p(!1)}}return h&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[h]),E.useEffect(()=>{h&&j()},[h,j]),E.useEffect(()=>{if(!h)return;setTimeout(()=>{var H;(H=w.current)==null||H.focus()},0);function R(H){const W=b.current,V=W.filter(X=>!N(X)),ee=T(S.current,W);switch(H.key){case"ArrowDown":if(H.preventDefault(),H.stopPropagation(),ee<V.length-1){const X=D(S.current+1,W);S.current=X,_(X)}break;case"ArrowUp":if(H.preventDefault(),H.stopPropagation(),ee>0){const X=L(S.current-1,W);S.current=X,_(X)}break;case"Enter":H.preventDefault(),H.stopPropagation(),I(S.current,W);break;case"Escape":H.preventDefault(),H.stopPropagation(),p(!1);break}}return window.addEventListener("keydown",R,!0),()=>window.removeEventListener("keydown",R,!0)},[h,v]);function N(R){var V;const H=R.label;return H?String(((V=H.props)==null?void 0:V.className)??"").includes("cursor-default"):!1}function T(R,H){let W=0;for(let V=0;V<R;V++){const ee=H[V];ee&&!N(ee)&&W++}return W}function D(R,H){for(let W=R;W<H.length;W++){const V=H[W];if(V&&!N(V))return W}return R}function L(R,H){for(let W=R;W>=0;W--){const V=H[W];if(V&&!N(V))return W}return R}function I(R,H){var V;const W=H[R];!W||N(W)||((V=W.onClick)==null||V.call(W),W.href&&(window.history.pushState(null,"",W.href),window.dispatchEvent(new PopStateEvent("popstate"))),p(!1))}E.useEffect(()=>{h&&(_(v.findIndex(R=>!N(R))),S.current=v.findIndex(R=>!N(R)))},[h,v]);const M=R=>{R.stopPropagation(),h||j(),p(!h)};function G(R,H,W,V){const X=!N(R)&&V===C,$=i.jsxs(i.Fragment,{children:[R.icon&&i.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:R.icon}),R.label]}),O=H!==W-1;return R.href?i.jsx(Jn,{href:R.href,onClick:B=>{var q;(q=R.onClick)==null||q.call(R,B),p(!1)},onAuxClick:()=>p(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${R.danger?"text-accent-error hover:bg-accent-error/10":X?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${O?"border-b border-border":""}`,children:$},V):i.jsx("button",{onClick:B=>{var q;(q=R.onClick)==null||q.call(R,B),R.closeOnClick!==!1&&p(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${R.danger?"text-accent-error hover:bg-accent-error/10":X?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${O?"border-b border-border":""}`,children:$},V)}const U=m&&i.jsxs("div",{ref:w,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${m.alignToTop?"mb-1":"mt-1"}`,style:{top:m.top,left:m.left,minWidth:r},tabIndex:-1,children:[i.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.map((R,H)=>G(R,H,e.length,H))}),t.length>0&&i.jsx("div",{className:"border-t border-border",children:t.map((R,H)=>G(R,H,t.length,e.length+H))})]});return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"relative",children:i.jsx("div",{ref:y,onClick:M,children:n})}),h&&pi.createPortal(U,document.body)]})}function aB(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 Ik({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(null);E.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const j=await(await ye("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:j.sudoAvailable,userInGroup:j.userInGroup,groupHasWrite:j.groupHasWrite,groupName:j.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=E.useCallback(async b=>{l(!0),c(null);try{const N=await(await ye("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:b})})).json();N.success?(r(),t()):N.sudoAvailable?c("Failed to fix permissions: "+(N.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
|
|
274
|
+
|
|
275
|
+
`+(b==="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)??"",_=x&&!y,S=!x&&y,v=!x&&!y;return i.jsx(jt,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"text-sm text-text-secondary",children:[i.jsx("p",{children:_?i.jsxs(i.Fragment,{children:["The group ",i.jsx("strong",{children:C})," doesn't have write access:"]}):S?i.jsxs(i.Fragment,{children:["You're not a member of group ",i.jsx("strong",{children:C}),":"]}):i.jsxs(i.Fragment,{children:["You're not a member of group ",i.jsx("strong",{children:C})," and it doesn't have write access:"]})}),i.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),u?i.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:u}):d?i.jsxs("div",{className:"flex flex-col gap-2",children:[_&&i.jsxs(i.Fragment,{children:[i.jsx(st,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&i.jsxs(i.Fragment,{children:[i.jsx(st,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),v&&i.jsxs(i.Fragment,{children:[i.jsx(st,{type:"button",variant:"primary",onClick:()=>m("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",i.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!u&&i.jsxs("div",{className:"text-xs text-text-secondary",children:[i.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),i.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx(st,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function Mk({isOpen:e,onClose:t}){const[,n]=Tn(),r=Wt(N=>N.listProjects),[a,l]=E.useState(""),[u,c]=E.useState(null),[d,h]=E.useState(!1),[p,m]=E.useState(""),[x,y]=E.useState(null),w=E.useRef(null);E.useEffect(()=>{e&&(ye("/api/config").then(N=>N.json()).then(N=>{N.workdir&&m(N.workdir)}),l(""),c(null),h(!1),y(null),setTimeout(()=>{var N;(N=w.current)==null||N.focus()},100))},[e]);const C=E.useCallback(async N=>{N.preventDefault();const T=aB(a);if(!T.valid){c(T.error);return}const D=`${p}/${a}`;await v(D)},[a,n,t,p]),_=E.useCallback(()=>{y(null)},[]),S=E.useCallback(async()=>{const N=`${p}/${a}`;await v(N)},[p,a,n,t,y,c,h]);async function v(N){h(!0),c(null),y(null);try{const T=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:N})});if(!T.ok){const I=await T.json().catch(()=>({}));if(I.code==="EACCES"){y(N),h(!1);return}throw new Error(I.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"),h(!1)}}const b=E.useCallback(()=>{l(""),c(null),t()},[t]),j=a?`${p}/${a}`:"";return i.jsxs(i.Fragment,{children:[i.jsx(jt,{isOpen:e,onClose:b,title:"Create New Project",size:"sm",children:i.jsxs("form",{onSubmit:C,className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),i.jsx(di,{ref:w,id:"project-name",value:a,onChange:N=>{l(N.target.value),c(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),a&&i.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",i.jsx("span",{className:"font-mono",children:j})]}),u&&i.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(st,{type:"button",variant:"secondary",onClick:b,disabled:d,children:"Cancel"}),i.jsx(st,{type:"submit",variant:"primary",disabled:d||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Jr,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),x&&i.jsx(Ik,{isOpen:!!x,onClose:_,path:x,onRetry:S})]})}function Pk(){const[e,t]=E.useState(null);return E.useEffect(()=>{ye("/api/config").then(n=>n.json()).then(n=>{n.workdir&&t(n.workdir)})},[]),e}function ES({projects:e,currentProject:t}){const[,n]=Tn(),r=Wt(_=>_.loadProject),a=Wt(_=>_.toggleStar),l=Wt(_=>_.createProject),u=Wt(_=>_.listProjects),[c,d]=E.useState(!1),[h,p]=E.useState(!1),m=Pk(),x=E.useCallback(async _=>{const S=W1(_),v=await l(S,_);return v&&"id"in v?(await u(),p(!1),n(`/p/${v.id}`),!0):!1},[l,u,n]),w=E.useMemo(()=>{const _=e.filter(v=>v.isStarred).sort((v,b)=>v.name.localeCompare(b.name)),S=e.filter(v=>!v.isStarred).sort((v,b)=>v.name.localeCompare(b.name));return[..._,...S]},[e]).map(_=>({label:i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i.jsx("span",{className:"truncate flex-1",children:_.name}),i.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),a(_.id,!_.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:_.isStarred?"Unstar project":"Star project",children:_.isStarred?i.jsx(M1,{className:"w-3.5 h-3.5 text-yellow-500"}):i.jsx(P1,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:_.id===(t==null?void 0:t.id)?i.jsx($r,{}):void 0,href:`/p/${_.id}`,closeOnClick:!0,onClick:()=>{r(_.id)}})),C=[{label:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Nr,{className:"w-4 h-4"}),i.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:i.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[i.jsx(Jr,{className:"w-4 h-4"}),i.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return i.jsxs(i.Fragment,{children:[i.jsx(ic,{items:w,footerItems:C,trigger:i.jsxs("button",{className:`text-text-secondary hover:text-text-primary text-sm truncate flex items-center gap-1 ${t?"hover:underline":""}`,title:(t==null?void 0:t.name)??"Select project",children:[(t==null?void 0:t.name)??i.jsx("span",{className:"text-text-muted",children:"Select project..."}),i.jsx(dn,{})]}),minWidth:"250px"}),c&&i.jsx(Mk,{isOpen:c,onClose:()=>d(!1)}),h&&i.jsx(Dd,{initialPath:m??void 0,onSelect:x,onClose:()=>p(!1)})]})}function Bk(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${l}/${u}`}function Zd(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function oB(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),u=Zd(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"),h=String(t.getDate()).padStart(2,"0");return`${c}/${d}/${h} ${u}`}}function $k(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 lB(e){const{year:t,month:n,day:r}=$k(e);return`${t}-${n}-${r}`}function zk(e){const t=new Map;for(const a of e){const l=lB(a.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(a)}for(const[a,l]of t)l.sort((u,c)=>{const d=new Date(u.updatedAt).getTime();return new Date(c.updatedAt).getTime()-d});const n=Array.from(t.keys()).sort((a,l)=>l.localeCompare(a)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function cB(e){const{year:t,month:n,day:r}=$k(e);return`${t}/${n}/${r} ${Zd(e)}`}function yd(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function uB({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var x;const l=Le(y=>y.loadSession),u=50,c=e.filter(y=>y.projectId===t.id).slice(0,15),d=zk(c),h=E.useMemo(()=>{const y=[];y.push({label:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Jr,{className:"w-4 h-4 text-accent-primary"}),i.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[w,C]of d){const _=C[0];if(_){y.push({label:i.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:Bk(_.updatedAt)}),onClick:()=>{}});for(const S of C)y.push({label:i.jsxs("div",{className:"min-w-[160px]",children:[i.jsx("div",{className:"truncate text-sm",children:yd(S.title??S.id.slice(0,8),u)}),i.jsx("div",{className:"text-text-muted text-xs",children:Zd(S.updatedAt)})]}),icon:S.id===(n==null?void 0:n.id)?i.jsx($r,{}):void 0,href:`/p/${t.id}/s/${S.id}`,onClick:()=>{l(S.id)}})}}return y},[t.id,d,n==null?void 0:n.id]),p=((x=n==null?void 0:n.metadata)==null?void 0:x.title)??(n?n.id.slice(0,8):null),m=p?yd(p,u):"No session selected";return i.jsx(ic,{items:h,isOpen:r,onOpenChange:a,trigger:i.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:p??"","data-testid":"header-session-dropdown",children:[m,i.jsx(dn,{})]}),minWidth:"280px"})}function dB({items:e,trigger:t,isActive:n=!1}){const[r,a]=E.useState(!1),l=E.useRef(null);return E.useEffect(()=>{function u(c){l.current&&!l.current.contains(c.target)&&a(!1)}if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),i.jsxs("div",{className:"relative",ref:l,children:[i.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?i.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,i.jsx(dn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&i.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((u,c)=>{const d=u.label&&typeof u.label=="object"&&u.label.type===Jn?u.label:null;if(d){const h=d.props.href||"";return i.jsxs(Jn,{href:h,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,d.props.children]},c)}return u.href?i.jsxs("a",{href:u.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c):i.jsxs("button",{type:"button",onClick:()=>{var h;(h=u.onClick)==null||h.call(u),a(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c)})})]})}function hB({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const a=t.filter(u=>u.projectId===e.id).sort((u,c)=>new Date(c.updatedAt).getTime()-new Date(u.updatedAt).getTime()).slice(0,5),l=[{label:i.jsxs(Jn,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[i.jsx(Jr,{className:"w-3 h-3 text-accent-primary"}),i.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(u=>({label:i.jsx(Jn,{href:`/p/${e.id}/s/${u.id}`,className:"flex items-center gap-2 truncate text-sm",children:i.jsx("span",{children:yd(u.title??u.id.slice(0,8),50)})}),icon:u.id===(n==null?void 0:n.id)?i.jsx($r,{className:"w-3 h-3"}):void 0})),{label:i.jsxs(Jn,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[i.jsx(lT,{className:"w-3 h-3"}),i.jsx("span",{className:"text-sm",children:"Projects"})]})}];return i.jsx(dB,{items:l,trigger:i.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function fB({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=E.useState(!1),[a,l]=E.useState(!1),[u,c]=E.useState(!!document.fullscreenElement),[d,h]=Tn();E.useEffect(()=>{const D=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",D),()=>document.removeEventListener("fullscreenchange",D)},[]);const p=d.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),x=Le(D=>D.currentSession),y=Le(D=>D.sessions),w=Wt(D=>D.currentProject),C=Wt(D=>D.projects),_=Qt(D=>D.startAutoRefresh),S=Qt(D=>D.stopAutoRefresh),v=Ir(D=>D.setOpen),b=Ir(D=>D.isOpen),j=js(D=>D.status==="available"),N=js(D=>D.check);E.useEffect(()=>{js.getState().status==="idle"&&N()},[N]),E.useEffect(()=>{const D=()=>l(!0);return window.addEventListener("open-session-dropdown",D),()=>window.removeEventListener("open-session-dropdown",D)},[]);const T=Ql();return Pl(T.terminalToggle,()=>{Ir.getState().toggleOpen()},{capture:!0}),E.useEffect(()=>(_(),()=>S()),[_,S]),i.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&m&&i.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:T.sessionSearch?`Toggle session list (${Zu(T.sessionSearch)})`:"Toggle session list",children:i.jsx(R_,{})}),i.jsx(Jn,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),w&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),i.jsx("span",{className:"hidden md:inline",children:i.jsx(ES,{projects:C,currentProject:w})}),i.jsx("span",{className:"md:hidden",children:i.jsx(hB,{currentProject:w,sessions:y,currentSession:x,projectIdFromUrl:p&&d.split("/")[2]||null},w==null?void 0:w.id)}),i.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),i.jsx("span",{className:"hidden md:inline",children:i.jsx(uB,{sessions:y,currentProject:w,currentSession:x,isOpen:a,onOpenChange:l})})]}),!w&&i.jsx("span",{className:"hidden md:inline",children:i.jsx(ES,{projects:C})})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&i.jsx("button",{onClick:()=>{var D,L,I;document.fullscreenElement?(D=document.exitFullscreen)==null||D.call(document):(I=(L=document.documentElement).requestFullscreen)==null||I.call(L)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:u?"Exit fullscreen":"Enter fullscreen",children:u?i.jsx(dT,{}):i.jsx(hT,{})}),p&&i.jsx("button",{onClick:()=>v(!b),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${b?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:i.jsx(yT,{})}),p&&w&&i.jsx("button",{onClick:()=>ye(`/api/projects/${w.id}/open-folder`).catch(()=>{}),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Open project folder",children:i.jsx(Nr,{className:"w-4 h-4"})}),i.jsxs("button",{onClick:()=>r(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:j?"Settings — update available":"Settings",children:[i.jsx(I1,{}),j&&i.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),i.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:i.jsx(mT,{})}),t&&m&&i.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:T.criteriaSidebar?`Toggle criteria sidebar (${Zu(T.criteriaSidebar)})`:"Toggle criteria sidebar",children:i.jsx(R_,{})})]}),i.jsx(Q6,{isOpen:n,onClose:()=>r(!1)}),i.jsx(iB,{isOpen:b,onClose:()=>v(!1)})]})}function Hk({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:l=n?"Saving...":"Save"}){return i.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[i.jsx(st,{variant:"secondary",onClick:e,children:a}),i.jsx(st,{variant:"primary",onClick:t,disabled:r??n,children:l})]})}const Mu=Mn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await ye(`/api/workspace/config?workdir=${encodeURIComponent(t)}`)).json();e({config:r.config??null,loading:!1})}catch{e({loading:!1})}},saveConfig:async(t,n)=>{const r=await ye(`/api/workspace/config?workdir=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error("Failed to save workspace config");const a=await r.json();e({config:a.config??n})}})),mB=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],pB=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"];function gB(e,t=mB,n=pB){if(!e)return null;const r=e.replace(/\/+$/,"")||"/";if(t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function xB({isOpen:e,onClose:t,project:n}){const r=Wt(Z=>Z.updateProject),a=Mu(Z=>Z.config),l=Mu(Z=>Z.loading),u=Mu(Z=>Z.fetchConfig),c=Mu(Z=>Z.saveConfig),d=()=>{try{Lt.send("context.checkDynamic",{})}catch{}t()},[h,p]=E.useState(n.customInstructions??""),[m,x]=E.useState(n.dangerLevel??""),[y,w]=E.useState(!1),[C,_]=E.useState(!1),[S,v]=E.useState(!1),[b,j]=E.useState(null),[N,T]=E.useState(""),[D,L]=E.useState(!1),[I,M]=E.useState(""),[G,U]=E.useState(!1),[R,H]=E.useState(""),[W,V]=E.useState(!1),[ee,X]=E.useState(!1),[$,O]=E.useState([]),[B,q]=E.useState(""),[z,re]=E.useState({}),[ne,J]=E.useState(!1),[K,P]=E.useState(new Set),Q=y||C||D||G||ne;E.useEffect(()=>{e&&(p(n.customInstructions??""),x(n.dangerLevel??""),w(!1),_(!1),L(!1),U(!1),J(!1),P(new Set),u(n.workdir))},[e,n,u]),E.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?T(a.setup.join(" && ")):T(""),M((a==null?void 0:a.rootDir)??""),re((a==null?void 0:a.mcpOverrides)??{})},[a]);const ae=Il(Z=>Z.servers),he=Z=>z[Z]??{},ce=Z=>{var me;const oe=he(Z);if(oe.disabled!==void 0)return oe.disabled;const ie=ae.find(Ue=>Ue.name===Z);return!!((me=ie==null?void 0:ie.config)!=null&&me.disabled)},De=(Z,oe)=>{var me;return((me=he(Z).disabledTools)==null?void 0:me.includes(oe))??!1},Re=Z=>{re(oe=>({...oe,[Z]:{...oe[Z],disabled:!ce(Z)}})),J(!0)},$e=(Z,oe)=>{re(ie=>{const me=ie[Z]??{},Ue=me.disabledTools??[],Ie=Ue.includes(oe)?Ue.filter(Ke=>Ke!==oe):[...Ue,oe];return{...ie,[Z]:{...me,disabledTools:Ie.length>0?Ie:void 0}}}),J(!0)},Ge=Z=>{P(oe=>{if(oe.has(Z)){const me=new Set(oe);return me.delete(Z),me}const ie=new Set(oe);return ie.add(Z),ie})},je=Z=>{p(Z.target.value),w(!0)},Ye=Z=>{x(Z),_(!0)},at=Z=>{T(Z.target.value),L(!0)},ke=Z=>{M(Z.target.value),U(!0)},ze=E.useCallback(async()=>{const Z=m===""?null:m;await r(n.id,{customInstructions:h||null,dangerLevel:Z});const oe=N.trim()?N.split("&&").map(ie=>ie.trim()).filter(Boolean):[];await c(n.workdir,{...oe.length>0?{setup:oe}:{},rootDir:I.trim(),...Object.keys(z).length>0?{mcpOverrides:z}:{mcpOverrides:void 0}}),w(!1),_(!1),L(!1),U(!1),J(!1),d()},[n.id,m,h,N,I,z,r,c,n.workdir,d]),lt=async()=>{const Z=I.trim(),oe=(a==null?void 0:a.rootDir)??"";if(Z){const ie=gB(Z);if(ie==="exact"){const me=Z.replace(/\/+$/,"")||"/";j(`Cannot use "${me}" directly as workspace root. Use a subdirectory like "${me}/${n.name}" instead.`);return}if(ie==="virtual_fs"){j(`Cannot use paths under "${Z}" for workspaces.`);return}}if(!G||!Z||Z===oe){v(!0),j(null);try{await ze()}catch(ie){j(ie instanceof Error?ie.message:"Failed to save settings")}finally{v(!1)}return}H(Z),v(!0),j(null);try{const ie=await ye(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:Z,workdir:n.workdir,projectName:n.name})});if(!ie.ok){const Ue=await ie.json().catch(()=>({}));j((Ue==null?void 0:Ue.error)??"Failed to validate workspace root directory"),v(!1);return}const me=await ie.json();if(!me.exists){q(me.resolvedPath),v(!1),V(!0);return}if(me.workspaces&&me.workspaces.length>0){O(me.workspaces),v(!1),X(!0);return}j(null),await ze()}catch(ie){j(ie instanceof Error?ie.message:"Failed to validate settings"),v(!1)}},we=async()=>{V(!1),v(!0);try{const Z=await ye(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:R,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!Z.ok){const ie=await Z.json().catch(()=>({}));j((ie==null?void 0:ie.error)??"Failed to create directory"),v(!1);return}const oe=await Z.json();if(oe.workspaces&&oe.workspaces.length>0){O(oe.workspaces),X(!0),v(!1);return}await ze()}catch(Z){j(Z instanceof Error?Z.message:"Failed to create directory")}finally{v(!1)}},He=async()=>{X(!1),v(!0),j(null);try{await ze()}catch(Z){j(Z instanceof Error?Z.message:"Failed to save settings")}finally{v(!1)}},Ve=()=>{V(!1),X(!1),p(n.customInstructions??""),x(n.dangerLevel??""),w(!1),_(!1),L(!1),U(!1),d()};return i.jsxs(jt,{isOpen:e,onClose:Ve,title:`${n.name} Settings`,size:"lg",footer:i.jsx(Hk,{onCancel:Ve,onSave:lt,saving:S,saveDisabled:!Q||S}),children:[i.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Default danger level for new sessions in this project. Existing sessions are not affected."}),i.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[i.jsx("button",{type:"button",onClick:()=>Ye(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m===""?"bg-bg-tertiary text-text-primary border border-border":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Use global default (Normal)",children:"Default"}),i.jsx("button",{type:"button",onClick:()=>Ye("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="normal"?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),i.jsx("button",{type:"button",onClick:()=>Ye("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="dangerous"?"bg-red-500/20 text-red-400 border border-red-500/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),i.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),i.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files."}),i.jsx("textarea",{value:h,onChange:je,placeholder:"Enter project-specific instructions...",className:"w-full h-32 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:S})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),l&&i.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),i.jsx("input",{type:"text",value:N,onChange:at,placeholder:"npm install --prefer-offline",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||S})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Root Directory"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Override the default workspace location. Leave empty to use the global directory"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"~/.local/share/openfox/workspaces/"}),". Supports absolute paths or paths relative to the project."]}),i.jsx("input",{type:"text",value:I,onChange:ke,placeholder:"/absolute/or/relative/path",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||S})]}),ae.length>0&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"MCP Servers"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Override MCP server availability for this project. These overrides apply to new conversations in this project and can be further overridden per conversation from the chat MCP selector."}),i.jsx("div",{className:"space-y-2",children:ae.map(Z=>{const oe=ce(Z.name);return i.jsx(Lk,{server:Z,expanded:K.has(Z.name),onToggleExpand:Ge,serverToggleEnabled:!oe,onServerToggle:()=>Re(Z.name),tools:Z.tools.map(ie=>({...ie,enabled:!De(Z.name,ie.name)})),onToolToggle:ie=>$e(Z.name,ie),statusDot:Qg(oe?"disabled":Z.status),statusColor:Xg(oe?"disabled":Z.status)},Z.name)})})]}),b&&i.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:b})]}),W&&i.jsxs(jt,{isOpen:W,onClose:()=>V(!1),title:"Directory not found",size:"md",footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>V(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:we,className:"px-4 py-2 text-sm font-medium rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:"Create"})]}),children:[i.jsxs("p",{className:"text-sm text-text-primary",children:["The directory ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:B})," does not exist."]}),i.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),ee&&i.jsxs(jt,{isOpen:ee,onClose:()=>X(!1),title:"Orphaned workspaces",size:"md",footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>X(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:He,className:"px-4 py-2 text-sm font-medium rounded bg-red-500 text-white hover:opacity-90 transition-colors",children:"Confirm change"})]}),children:[i.jsxs("p",{className:"text-sm text-text-primary",children:[$.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),i.jsx("ul",{className:"mt-2 space-y-1",children:$.map(Z=>i.jsx("li",{className:"text-sm font-mono text-text-muted",children:Z.name},Z.name))}),i.jsx("p",{className:"text-sm text-text-muted mt-3",children:"Existing workspaces will remain in the old location but will no longer be accessible from this project."})]})]})}const yB={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},bB="M6 18L18 6M6 6l12 12";function ac({onClick:e,className:t="",size:n="md",variant:r="default"}){const a=r==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":r==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":r==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return i.jsx(Ad,{onClick:e,icon:bB,iconSize:yB[n],className:`${a} ${t}`,title:"Close"})}function Yr(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function tg(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),a=new Array(e.length).fill(!1),l=n.indexOf(r);if(l>=0)for(let p=l;p<l+r.length;p++)a[p]=!0;else{let p=0;for(let m=0;m<e.length&&p<r.length;m++)n[m]===r[p]&&(a[m]=!0,p++)}const u=Array.from(e),c=[];let d="",h=a[0]??!1;for(let p=0;p<u.length;p++){const m=u[p]??"";a[p]===h?d+=m:(c.push(h?i.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),d=m,h=a[p]??!1)}return c.push(h?i.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),i.jsx(i.Fragment,{children:c})}function ci(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const l of r){let u=0;for(let c=0;c<l.length&&u<a.length;c++)l[c]===a[u]&&u++;if(u===a.length)return!0}return!1})}function Uk(e,t,n,r,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(l=>Math.min(l+1,t));break;case"ArrowUp":e.preventDefault(),n(l=>Math.max(l-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),a();break}}function Fk({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Tn(),[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(null),[p,m]=E.useState(""),[x,y]=E.useState(!1),w=Le(ce=>ce.sessions),C=Le(ce=>ce.currentSession),_=Le(ce=>ce.unreadSessionIds),S=Le(ce=>ce.deleteSession),v=Le(ce=>ce.deleteAllSessions),b=Le(ce=>ce.loadMoreSessions),j=Le(ce=>ce.sessionsHasMore),N=Le(ce=>ce.sessionsPaginationLoading),T=Le(ce=>ce.sessionsWithPendingConfirmations),D=Le(ce=>ce.pendingPathConfirmations),L=Wt(ce=>ce.currentProject),[I,M]=E.useState(""),[G,U]=E.useState(-1),R=E.useRef(null),H=E.useRef(null),W=E.useRef(!1),V=Ql();Pl(V.sessionSearch,()=>{var ce;if(t&&document.activeElement===R.current){n==null||n();return}t||(W.current=!0,n==null||n()),(ce=R.current)==null||ce.focus()});const ee=E.useRef(null),X=E.useCallback(()=>{j&&!N&&L&&b(L.id)},[j,N,L,b]);E.useEffect(()=>{if(!ee.current||!j)return;const ce=new IntersectionObserver(De=>{const Re=De[0];Re&&Re.isIntersecting&&X()},{threshold:.1});return ce.observe(ee.current),()=>ce.disconnect()},[j,X]);const $=w.filter(ce=>ce.projectId===(L==null?void 0:L.id)),O=E.useMemo(()=>I?$.filter(ce=>{var $e;const De=ce.title??"",Re=((($e=ce.recentUserPrompts)==null?void 0:$e.map(Ge=>Ge.content))??[]).join(" ");return ci(De,I)||ci(Re,I)}):$,[$,I]),B=I.length>0,q=B&&O.length===0;E.useEffect(()=>{U(O.length>0?0:-1)},[O.length]),E.useEffect(()=>{var De;if(G<0)return;const ce=(De=H.current)==null?void 0:De.querySelector(`[data-sidx="${G}"]`);ce==null||ce.scrollIntoView({block:"nearest"})},[G]);const z=(ce,De)=>{De==null||De.stopPropagation(),c(ce)},re=()=>{u&&(S(u),(C==null?void 0:C.id)===u&&r(`/p/${e}`),c(null))},ne=(ce,De)=>{De==null||De.stopPropagation();const Re=w.find(Ge=>Ge.id===ce),$e=(Re==null?void 0:Re.title)??ce.slice(0,6);m($e),h(ce)},J=()=>{if(!d||p.trim()==="")return;const ce=Le.getState().renameSession;ce(d,p.trim()),h(null),m("")},K=()=>{y(!0)},P=()=>{v(e),r(`/p/${e}`),y(!1)},Q=ce=>{if(!W.current)return;ce.target.closest('a[href*="/s/"]')&&(W.current=!1,n==null||n())},ae=()=>{var ce;M(""),(ce=R.current)==null||ce.focus()},he=ce=>{var De;switch(ce.key){case"Escape":M(""),(De=R.current)==null||De.blur();break;case"ArrowDown":ce.preventDefault(),U(Re=>Re<O.length-1?Re+1:Re);break;case"ArrowUp":ce.preventDefault(),U(Re=>Re>0?Re-1:0);break;case"Enter":{ce.preventDefault();const Re=O[G];Re&&(r(`/p/${e}/s/${Re.id}`),W.current&&(W.current=!1,n==null||n()));break}}};return i.jsxs(i.Fragment,{children:[t&&n&&i.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),(()=>{const ce=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[i.jsx(Jn,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),i.jsx(ic,{items:[{label:"Edit project settings",onClick:()=>l(!0)},{label:"Delete all sessions",onClick:K,danger:!0}],trigger:i.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:i.jsx(L1,{})})}),n&&i.jsx(ac,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),i.jsxs("div",{className:"px-4 py-2 border-b border-border",children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx(Qi,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),i.jsx("input",{ref:R,type:"text",value:I,onChange:De=>M(De.target.value),onKeyDown:he,placeholder:"Search sessions...",className:"w-full bg-bg-tertiary border border-border rounded pl-8 pr-8 py-1.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),I&&i.jsx("button",{type:"button",onClick:ae,className:"absolute right-1.5 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:i.jsx(Ns,{className:"w-3.5 h-3.5"})})]}),B&&!q&&i.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[O.length," ",O.length===1?"match":"matches"]})]}),L&&i.jsx(xB,{isOpen:a,onClose:()=>l(!1),project:L}),i.jsx($l,{isOpen:u!==null,onClose:()=>c(null),onConfirm:re,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),i.jsx($l,{isOpen:x,onClose:()=>y(!1),onConfirm:P,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),i.jsx(jt,{isOpen:d!==null,onClose:()=>{h(null),m("")},title:"Rename session",size:"sm",footer:i.jsx(Hk,{onCancel:()=>{h(null),m("")},onSave:J,saving:!1,saveDisabled:p.trim()==="",saveLabel:"Rename"}),children:i.jsx("input",{type:"text",value:p,onChange:De=>m(De.target.value),onKeyDown:De=>{De.key==="Enter"&&J()},onFocus:De=>De.target.select(),className:"w-full px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:!0})}),i.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-stable",children:O.length===0?i.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:B?"No matching sessions":"No sessions"}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"divide-y divide-border",ref:H,onClick:Q,children:vB(O,C,_,z,ne,e,T,D,I,G)}),N&&i.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),i.jsx("div",{ref:ee,className:"h-px"})]})})]});return i.jsx("aside",{className:`
|
|
276
|
+
${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden md:border-r-0"}
|
|
277
|
+
md:relative md:h-auto md:translate-x-0
|
|
278
|
+
|
|
279
|
+
fixed z-50 h-[calc(100vh-32px)]
|
|
280
|
+
w-[300px] bg-secondary border-r border-border flex flex-col
|
|
281
|
+
transition-transform duration-300 ease-in-out
|
|
282
|
+
${t?"translate-x-0":"-translate-x-full"}
|
|
283
|
+
`,children:ce})})()]})}function vB(e,t,n,r,a,l,u,c,d,h){const p=zk(e);let m=0;return Array.from(p).map(([x,y])=>{const w=y[0];return w?i.jsxs("div",{children:[i.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:Bk(w.updatedAt)}),y.map(C=>{const _=m++,S=(t==null?void 0:t.id)===C.id,v=_===h,b=n.includes(C.id),j=C.isRunning,N=u.includes(C.id)||S&&c.length>0;return i.jsx("div",{"data-sidx":_,className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${S?"bg-bg-tertiary":""} ${v?"bg-accent-primary/10":""}`,children:i.jsxs(Jn,{href:`/p/${l}/s/${C.id}`,className:`block ${S?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[i.jsxs("div",{className:"flex justify-between items-center mb-1",children:[i.jsx("span",{className:`font-medium truncate text-sm ${S?"text-accent-primary":"text-text-primary"}`,children:d?tg(C.title??C.id.slice(0,6),d):C.title??C.id.slice(0,6)}),i.jsx(ic,{items:[{label:"Rename session",onClick:T=>a(C.id,T)},{label:"Delete session",onClick:T=>r(C.id,T),danger:!0}],trigger:i.jsx("button",{onClick:T=>T.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:i.jsx(L1,{})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[N?i.jsx("span",{title:"Awaiting confirmation",children:i.jsx(ug,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):j?i.jsx(gT,{}):b&&!S?i.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,i.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Zd(C.updatedAt)}),i.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)})]},x):null})}const NS=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function _B(){var u;const e=Wt(c=>c.currentProject),t=Le(c=>c.currentSession),n=Nd(),r=E.useRef(0),a=E.useRef(null);E.useEffect(()=>(n?(a.current||(r.current=0),a.current=window.setInterval(()=>{r.current=(r.current+1)%NS.length,l()},150),l()):(a.current&&(clearInterval(a.current),a.current=null),l()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t]);const l=()=>{var p;const d=(p=t==null?void 0:t.metadata)==null?void 0:p.title,h=n?`${NS[r.current]} `:"";e&&d?document.title=`${h}${e.name} - ${d} | OpenFox`:e?document.title=`${h}${e.name} | OpenFox`:document.title=`${h}OpenFox`};return typeof window<"u"&&((u=t==null?void 0:t.metadata)!=null&&u.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function Vk({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return i.jsx($l,{isOpen:e,onClose:t,onConfirm:a,title:"Delete Project",confirmLabel:"Delete",confirmVariant:"danger",message:i.jsxs(i.Fragment,{children:["This will permanently delete the project"," ",i.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]})})}function SB({isOpen:e,onClose:t}){const[,n]=Tn(),[r,a]=E.useState(!1),l=Pk(),[u,c]=E.useState(!1),d=Wt(L=>L.projects),h=Wt(L=>L.createProject),p=Wt(L=>L.listProjects),m=Wt(L=>L.deleteProject),[x,y]=E.useState(null),[w,C]=E.useState(null);E.useEffect(()=>{e&&p()},[e,p]);const _=L=>{n(`/p/${L}`),t()},S=(L,I)=>{I.stopPropagation(),y(L)},v=()=>{x&&(m(x.id),y(null))},b=async L=>N(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 N(L){const I=W1(L),M=await h(I,L);return p(),j(M)?(C(M.error.path||L),!1):M&&"id"in M?(n(`/p/${M.id}`),t(),!0):!1}const T=E.useCallback(()=>{C(null)},[]),D=E.useCallback(async()=>{const L=w;C(null),L&&await N(L)},[w]);return e?i.jsxs(jt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(st,{variant:"secondary",onClick:t,children:"Close"})}),children:[i.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[i.jsxs("div",{className:"w-full sm:w-1/2 border-b sm:border-b-0 sm:border-r border-border flex flex-col max-h-[40vh] sm:max-h-[50vh]",children:[i.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:i.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:d.length===0?i.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[i.jsx("p",{className:"mb-2",children:"No recent projects"}),i.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):i.jsx("div",{className:"divide-y divide-border",children:d.map(L=>i.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[i.jsxs("button",{onClick:()=>_(L.id),className:"flex-1 flex items-center gap-3 text-left",children:[i.jsx(Nr,{className:"w-5 h-5 text-accent-primary"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"font-medium truncate",children:L.name}),i.jsx("div",{className:"text-xs text-text-muted truncate",children:G1(L.workdir,32)})]})]}),i.jsx("button",{onClick:I=>S(L,I),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:i.jsx(ta,{className:"w-4 h-4"})})]},L.id))})})]}),i.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:i.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[i.jsx(st,{variant:"primary",onClick:()=>c(!0),children:"Select existing project"}),i.jsx(st,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&i.jsx(Mk,{isOpen:r,onClose:()=>a(!1)}),x&&i.jsx(Vk,{isOpen:!0,onClose:()=>y(null),projectName:x.name,onConfirm:v}),u&&i.jsx(Dd,{initialPath:l??void 0,onSelect:L=>{b(L)},onClose:()=>c(!1)}),w&&i.jsx(Ik,{isOpen:!0,onClose:T,path:w,onRetry:D})]}):null}function wB(){const[e,t]=E.useState(!1),[n,r]=E.useState(null),[a,l]=E.useState(""),[u,c]=E.useState(""),d=E.useRef(null),h=Le(H=>H.sessions),p=Wt(H=>H.projects),m=Wt(H=>H.loading),x=Wt(H=>H.listProjects),y=Le(H=>H.listSessions),w=Wt(H=>H.deleteProject),C=Le(H=>H.connectionStatus);E.useEffect(()=>{C==="connected"&&(x(),y())},[C,x,y]),E.useEffect(()=>{const H=setTimeout(()=>c(a),150);return()=>clearTimeout(H)},[a]);const{matchCount:_,filteredSessionIds:S,relevanceScores:v,matchTypes:b,promptSnippets:j}=E.useMemo(()=>{if(!u)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const H=new Map(p.map($=>[$.id,$])),W=new Map,V=new Map,ee=new Map,X=h.filter($=>{var K;const O=H.get($.projectId),B=(O==null?void 0:O.name)??"",q=$.title??"",z=((K=$.recentUserPrompts)==null?void 0:K.map(P=>P.content))??[],re=z.join(" ");let ne=0,J="";if(ci(q,u)&&(ne+=10,J="title"),ci(re,u)){ne+=3,J=J==="title"?"title":"prompts";const P=z.find(Q=>ci(Q,u));if(P){const Q=P.toLowerCase().indexOf(u.toLowerCase());if(Q>=0){const ae=Math.max(0,Q-30),he=Math.min(P.length,Q+u.length+30);ee.set($.id,(ae>0?"…":"")+P.slice(ae,he)+(he<P.length?"…":""))}else ee.set($.id,P.slice(0,80)+(P.length>80?"…":""))}}return ci(B,u)&&(ne+=1,J=J||"project"),W.set($.id,ne),V.set($.id,J),ne>0});return{matchCount:X.length,filteredSessionIds:new Set(X.map($=>$.id)),relevanceScores:W,matchTypes:V,promptSnippets:ee}},[h,u,p]),N=E.useMemo(()=>{const H=new Map;for(const W of h){const V=new Date(W.updatedAt).getTime(),ee=H.get(W.projectId)??0;V>ee&&H.set(W.projectId,V)}return H},[h]),T=E.useMemo(()=>{const H=new Map;for(const W of h){const V=H.get(W.projectId);V?V.push(W):H.set(W.projectId,[W])}for(const[,W]of H)W.sort((V,ee)=>new Date(ee.updatedAt).getTime()-new Date(V.updatedAt).getTime());return H},[h]),D=E.useMemo(()=>{let H=p;return u&&S&&(H=p.filter(W=>{const V=T.get(W.id);return V==null?void 0:V.some(ee=>S.has(ee.id))})),[...H].sort((W,V)=>{const ee=N.get(W.id)??new Date(W.updatedAt).getTime();return(N.get(V.id)??new Date(V.updatedAt).getTime())-ee})},[p,T,u,S,N]),L=E.useCallback(H=>{const W=T.get(H);return W?u&&S&&v?W.filter(V=>S.has(V.id)).sort((V,ee)=>{const X=(v.get(ee.id)??0)-(v.get(V.id)??0);return X!==0?X:new Date(ee.updatedAt).getTime()-new Date(V.updatedAt).getTime()}):W.slice(0,5):[]},[T,u,S,v]),I=()=>{t(!0)},M=()=>{var H;l(""),c(""),(H=d.current)==null||H.focus()},G=H=>{var W;H.key==="Escape"&&(M(),(W=d.current)==null||W.blur())},U=u.length>0,R=U&&_===0;return i.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[i.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[i.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),i.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),i.jsx(st,{variant:"primary",onClick:I,children:"Open Project"})]}),h.length>0&&i.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx(Qi,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),i.jsx("input",{ref:d,type:"text",value:a,onChange:H=>l(H.target.value),onKeyDown:G,placeholder:"Search sessions by title or keyword...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-10 pr-10 py-2.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),a&&i.jsx("button",{type:"button",onClick:M,className:"absolute right-3 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:i.jsx(Ns,{className:"w-4 h-4"})})]}),U&&!R&&i.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[_," ",_===1?"match":"matches"]})]}),R?i.jsxs("div",{className:"text-center py-16 text-text-muted",children:[i.jsx(Qi,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),i.jsxs("p",{className:"text-lg",children:["No sessions matching ",i.jsxs("span",{className:"text-text-primary font-medium",children:["“",u,"”"]})]}),i.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):D.map(H=>{const W=L(H.id);return i.jsx("div",{className:"mb-6 md:mb-8",children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[i.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[i.jsxs(Jn,{href:`/p/${H.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[i.jsx(Nr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),i.jsx("span",{className:"text-text-primary font-semibold",children:H.name})]}),i.jsx(Jn,{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"}),i.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:i.jsx(ta,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"divide-y divide-border",children:W.length>0?W.map(V=>{const ee=p.find(B=>V.projectId===B.id),X=ee?`/p/${ee.id}/s/${V.id}`:"#",$=V.title??V.id.slice(0,8),O=b==null?void 0:b.get(V.id);return i.jsx(Jn,{href:X,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-muted truncate",children:U&&O==="title"?tg($,u):$}),U&&O&&O!=="title"&&i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[i.jsx("span",{className:"text-[10px] font-medium text-accent-primary border border-accent-primary/30 bg-accent-primary/8 rounded px-1 py-0.5 leading-none",children:O==="prompts"?"prompts":"project"}),O==="prompts"&&(j==null?void 0:j.get(V.id))&&i.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:tg(j.get(V.id),u)})]})]})}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[i.jsx("span",{className:"text-text-muted text-xs",children:oB(V.updatedAt)}),i.jsxs("span",{className:"text-text-muted text-xs",children:[V.messageCount," msgs"]})]})]})},V.id)}):i.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},H.id)}),!U&&D.length===0&&!m&&i.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),m&&i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(gi,{})})]}),e&&i.jsx(SB,{isOpen:e,onClose:()=>t(!1)}),n&&i.jsx(Vk,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>w(n.id)})]})}function CB(){const[,e]=fo("/p/:projectId/new"),[,t]=Tn(),n=e==null?void 0:e.projectId,r=Le(u=>u.createSession),a=Le(u=>u.resetPendingSessionCreate),l=E.useCallback(async()=>{if(!n)return;const u=await r(n);u?(t(`/p/${n}/s/${u.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return E.useEffect(()=>{l()},[l]),i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx(gi,{})})}function kB(){const e=Wt(t=>t.currentProject);return i.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:i.jsxs("div",{className:"max-w-md",children:[i.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),i.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),i.jsxs("div",{className:"flex flex-col gap-3",children:[e&&i.jsx(Jn,{href:`/p/${e.id}/new`,"data-testid":"create-new-session-button",className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),i.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const vl=e=>Math.round(e*10)/10;function jB(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function ng(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function EB(e){return`${e.providerId}::${e.model}`}function NB(e){return`${e.providerName} > ${e.model}`}function TS(e){let t=0,n=0,r=0,a=0,l=0,u=0;const c=[],d=[];let h=0;for(const[x,y]of e.entries()){const w=y.stats,C=ng(w);t+=w.totalTime,n+=w.toolTime,r+=w.prefillTokens,a+=w.generationTokens;const _=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;l+=_,u+=S,c.push({messageId:y.id,timestamp:y.timestamp,...C,mode:w.mode,responseIndex:x+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const v=w.llmCalls??[];for(const b of v)h+=1,d.push({messageId:y.id,timestamp:b.timestamp??y.timestamp,providerId:b.providerId,providerName:b.providerName,backend:b.backend,model:b.model,mode:w.mode,responseIndex:x+1,sessionCallIndex:h,callIndex:b.callIndex,promptTokens:b.promptTokens,completionTokens:b.completionTokens,ttft:b.ttft,completionTime:b.completionTime,prefillSpeed:b.prefillSpeed,generationSpeed:b.generationSpeed,totalTime:b.totalTime,...b.temperature!==void 0&&{temperature:b.temperature},...b.topP!==void 0&&{topP:b.topP},...b.topK!==void 0&&{topK:b.topK},...b.maxTokens!==void 0&&{maxTokens:b.maxTokens}})}const p=l>0?vl(r/l):0,m=u>0?vl(a/u):0;return{totalTime:vl(t),aiTime:vl(t-n),toolTime:vl(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:c,callDataPoints:d}}function TB(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&jB(a.stats)).sort((a,l)=>new Date(a.timestamp).getTime()-new Date(l.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const l=EB(ng(a.stats)),u=n.get(l)??[];n.set(l,[...u,a])}const r=Array.from(n.entries()).map(([a,l])=>{const u=ng(l[0].stats),c=TS(l);return{...u,key:a,label:NB(u),...c}});return{...TS(t),modelGroups:r}}function AB(e){return E.useMemo(()=>TB(e),[e])}function Jg(){var a;const e=Le(l=>l.gitStatus),t=Le(l=>l.currentSession),[n,r]=E.useState(!0);return E.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((a=e==null?void 0:e.diff)==null?void 0:a.files)??[],loading:n,error:null}}}function co(e){return e.toLocaleString("en-US").replace(/,/g," ")}function AS(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Qr(e){if(!Number.isFinite(e))return"0s";if(e<10)return`${e.toFixed(1)}s`;const t=Math.round(e);if(t<60)return`${t}s`;if(t<3600){const u=Math.floor(t/60),c=t%60;return`${u}m ${c}s`}const n=Math.floor(t/3600),r=t%3600,a=Math.floor(r/60),l=r%60;return`${n}h ${a}m ${l}s`}const LS=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),DS=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function io(e){return Object.hasOwn(LS,e)?LS[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function LB(e){return Object.hasOwn(DS,e)?DS[e]:e.replace(/_/g," ")}const RS=["▁","▂","▃","▄","▅","▆","▇","█"];function DB(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 RB(e,t){if(e===t){const a=Math.max(Math.abs(e)*.05,1);return{minY:e-a,maxY:t+a}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function OB(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((x,y)=>x.x-y.x),r=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(x=>x.y)),u=Math.max(...n.map(x=>x.y)),{minY:c,maxY:d}=RB(l,u),h=Math.max(0,c),p=Array.from({length:t},()=>" "),m=new Map;for(const x of n){const y=a===r?0:Math.round((x.x-r)/(a-r)*(t-1)),w=m.get(y)??[];m.set(y,[...w,x.y])}for(const[x,y]of m){const w=Math.max(...y);p[x]=RS[DB(w,c,d)]??RS[0]}return{blocks:p.join(""),minX:r,maxX:a,minY:h,maxY:d}}function OS(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function IS({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:l,showAxes:u=!0,formatY:c=OS,formatX:d=OS}){const h=E.useMemo(()=>{const p=OB(e,t),m=Math.max(t*6,240),x=10,y=8,C=[...e].sort((b,j)=>b.x-j.x).map(b=>{const j=p.maxX===p.minX?m/2:x+(b.x-p.minX)/(p.maxX-p.minX)*(m-x*2),N=p.maxY===p.minY?n/2:y+(p.maxY-b.y)/(p.maxY-p.minY)*(n-y*2);return{...b,cx:j,cy:N,leftPercent:j/m*100,topPercent:N/n*100}}),_=C.map((b,j)=>`${j===0?"M":"L"} ${b.cx.toFixed(1)} ${b.cy.toFixed(1)}`).join(" "),v=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(b=>({value:b,y:p.maxY===p.minY?n/2:y+(p.maxY-b)/(p.maxY-p.minY)*(n-y*2)}));return{...p,chartWidth:m,points:C,path:_,gridLines:v}},[e,n,t]);return e.length===0?i.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&i.jsx("div",{className:"mb-1",children:r}),i.jsx("div",{children:"No data"})]}):i.jsxs("div",{className:"font-mono text-xs",children:[r&&i.jsx("div",{className:"text-text-secondary mb-2",children:r}),i.jsxs("div",{className:"flex gap-3",children:[u&&i.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(p=>i.jsx("span",{children:c(p.value)},`${p.value}-${p.y}`))}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"relative h-[78px]",children:[i.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(p=>i.jsx("line",{x1:"0",x2:h.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),h.points.map(p=>i.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),h.points.length>1&&i.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(p=>i.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${c(p.y)}`,children:i.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:i.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),u&&i.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[i.jsx("span",{className:"w-12"}),i.jsxs("span",{className:"flex-1 flex justify-between",children:[i.jsx("span",{children:d(h.minX)}),i.jsx("span",{children:a}),i.jsx("span",{children:d(h.maxX)})]})]}),l&&u&&i.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function IB({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:a=60}){const l=e.map(c=>({x:c.x,y:c.ppSpeed})),u=e.map(c=>({x:c.x,y:c.tgSpeed}));return i.jsxs("div",{className:"space-y-5",children:[i.jsx(IS,{data:l,width:a,label:t,xLabel:r}),i.jsx(IS,{data:u,width:a,label:n,xLabel:r})]})}function MB(e){const t=new Map;for(const n of e.callDataPoints){const r=t.get(n.messageId)??[];t.set(n.messageId,[...r,n])}return e.dataPoints.map(n=>{const r=[...t.get(n.messageId)??[]].sort((a,l)=>a.callIndex-l.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function PB(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 BB(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 $B(e){return e.callDataPoints.length>0?BB(e):PB(e)}function Xi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function El(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function zB(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Xi(t)} ctx`:`${Xi(t)}-${Xi(n)} ctx`}function bd(e){return`${El(e)} t/s`}function Wk(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function HB(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 UB({isOpen:e,onClose:t,stats:n}){const r=E.useRef(null),[a,l]=E.useState({}),[u,c]=E.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});E.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=E.useMemo(()=>n.modelGroups.find(w=>w.key===u)??n.modelGroups[0],[u,n.modelGroups]),h=E.useMemo(()=>d?MB(d):[],[d]),p=E.useMemo(()=>d?$B(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=E.useCallback(w=>{l(C=>({...C,[w]:!C[w]}))},[]),x=E.useCallback(()=>{if(!d)return;const w=HB(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),y=E.useCallback(async()=>{if(r.current)try{const w=(await te(async()=>{const{default:S}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:S}},[])).default,C=await w(r.current,{backgroundColor:"#1a1a1a",scale:2}),_=document.createElement("a");_.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,_.href=C.toDataURL("image/png"),_.click()}catch(w){console.error("Failed to export PNG:",w),x()}},[x]);return i.jsx(jt,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:i.jsxs("div",{ref:r,className:"space-y-6",children:[i.jsx("section",{children:i.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>i.jsx("button",{onClick:()=>c(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.key===(d==null?void 0:d.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:w.label,children:w.label},w.key))})}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[i.jsx(vs,{label:"AI Time",value:Qr(d.aiTime)}),i.jsx(vs,{label:"Total Time",value:Qr(d.totalTime)}),i.jsx(vs,{label:"Tool Time",value:Qr(d.toolTime)}),i.jsx(vs,{label:"Responses",value:d.responseCount.toString()}),i.jsx(vs,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[i.jsx(vs,{label:"Prefill Tokens",value:Xi(d.prefillTokens),subValue:`@ ${El(d.avgPrefillSpeed)} tok/s`}),i.jsx(vs,{label:"Gen Tokens",value:Xi(d.generationTokens),subValue:`@ ${El(d.avgGenerationSpeed)} tok/s`}),i.jsx(vs,{label:"Avg PP Speed",value:`${El(d.avgPrefillSpeed)}`,subValue:"tok/s"}),i.jsx(vs,{label:"Avg TG Speed",value:`${El(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.points.length>1&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),i.jsx("button",{onClick:y,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),i.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:i.jsx(IB,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),d&&i.jsxs("section",{children:[i.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.responseCount," responses)"]}),i.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:i.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[i.jsxs("colgroup",{children:[i.jsx("col",{className:"w-[7%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[10%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[11%]"}),i.jsx("col",{className:"w-[2%]"})]}),i.jsx("thead",{children:i.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[i.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),i.jsx("th",{className:"px-2 py-2"})]})}),i.jsx("tbody",{children:h.map((w,C)=>i.jsxs(E.Fragment,{children:[i.jsx(FB,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((_,S)=>i.jsx(VB,{dataPoint:_,index:S},`${_.messageId}-${_.callIndex}`))]},w.messageId))})]})})]})]})})}function vs({label:e,value:t,subValue:n}){return i.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[i.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),i.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&i.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function FB({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?zB(e.calls.map(l=>l.promptTokens)):`${Xi(e.prefillTokens)} ctx`;return i.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[i.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:Wk(e.timestamp)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Qr(e.totalTime)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:bd(e.prefillSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:bd(e.generationSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function VB({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[i.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:Wk(e.timestamp)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Qr(e.totalTime)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Xi(e.promptTokens)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:bd(e.prefillSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:bd(e.generationSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),i.jsx("td",{className:"px-2 py-2"})]}),n&&i.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:i.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:i.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&i.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&i.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&i.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&i.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const WB={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"}},Gk=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function GB(e){return WB[e]??{icon:"○",color:"text-text-muted"}}function Zg(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const bo=E.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=GB(t);return i.jsx("span",{className:`${a} ${n}`,children:r})});function vd({entries:e,title:t}){const n=E.useMemo(()=>e.reduce((r,a)=>(r[a.status]=(r[a.status]??0)+1,r),{}),[e]);return i.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[i.jsx("span",{children:t}),Object.keys(n).length>0&&i.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:Gk.map(r=>{const a=n[r];return a?i.jsxs("span",{className:"flex items-center gap-0.5",children:[i.jsx(bo,{status:r}),i.jsx("span",{children:a})]},r):null})})]})}const qk=E.memo(function({entries:t,title:n,onClearAll:r}){const[a,l]=E.useState(!1),u=E.useCallback(()=>{l(!1),r==null||r()},[r]);return t.length===0?null:i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&i.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),i.jsx("div",{className:"bg-primary",children:t.map((c,d)=>i.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[i.jsx(bo,{status:c.status}),i.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[i.jsxs("span",{className:"text-text-muted",children:["[",c.id,"]"]})," ",Zg(c.description)]})]},c.id??d))}),r&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:i.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all",children:[i.jsx(ta,{className:"w-3 h-3"}),"Clear all"]})}),a&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[i.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:u,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),i.jsx("button",{onClick:()=>l(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),qB={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},KB=["pending","completed","failed","dismissed"];function YB(e){return qB[e]??KB}function XB(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function Kk({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:l}){const[u,c]=E.useState(e),[d,h]=E.useState(null),[p,m]=E.useState(""),[x,y]=E.useState(!1),[w,C]=E.useState(""),_=E.useRef(null),S=E.useRef(null),v=E.useCallback(()=>{const U=S.current;U&&(U.style.height="auto",U.style.height=U.scrollHeight+"px")},[]);E.useEffect(()=>{c(e)},[e]),E.useEffect(()=>{var U;d&&(v(),(U=S.current)==null||U.focus())},[d,v]),E.useEffect(()=>{var U;x&&((U=_.current)==null||U.focus())},[x]);const b=E.useCallback(U=>{c(U),ye(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:U})}).catch(R=>console.error(`Failed to sync ${n}:`,R))},[t,n]),j=E.useCallback(U=>{const R=YB(n),H=u.map(W=>W.id===U?{...W,status:XB(W.status,R)}:W);b(H)},[u,n,b]),N=E.useCallback((U,R)=>{h(U),m(R)},[]),T=E.useCallback((U,R,H)=>{var ee;const W=(R.trim()||((ee=H.find(X=>X.id===U))==null?void 0:ee.description))??"",V=H.map(X=>X.id===U?{...X,description:W}:X);b(V)},[b]),D=E.useCallback(()=>{d&&(T(d,p,u),h(null))},[d,p,u,T]),L=E.useCallback(U=>{U.key==="Enter"&&D(),U.key==="Escape"&&(U.stopPropagation(),h(null))},[D]),I=E.useCallback(U=>{b(u.filter(R=>R.id!==U))},[u,b]),M=E.useCallback(()=>{const U=w.trim();if(!U)return;const R=u.map(W=>Number(W.id)).filter(W=>Number.isInteger(W)&&W>=0),H=String(Math.max(-1,...R)+1);b([...u,{id:H,description:U,status:"pending"}]),C("")},[w,u,b]),G=E.useCallback(U=>{U.key==="Enter"&&(U.preventDefault(),M()),U.key==="Escape"&&(y(!1),C(""))},[M]);return i.jsxs(jt,{isOpen:a,onClose:l,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[i.jsxs("ul",{className:"space-y-1",children:[u.map((U,R)=>{const H=d===U.id,W=i.jsxs("button",{onClick:()=>N(U.id,U.description),className:"text-sm text-text-primary text-left hover:text-accent-primary transition-colors w-full cursor-pointer",title:"Click to edit",children:[i.jsxs("span",{className:"text-text-muted",children:["[",U.id,"]"]})," ",i.jsx("span",{children:Zg(U.description)})]}),V=H?i.jsx("textarea",{ref:S,value:p,onChange:ee=>{m(ee.target.value),v()},onBlur:D,onKeyDown:L,className:"w-full bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary resize-none",rows:1}):W;return i.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${R>0?"border-t border-border":""}`,children:[i.jsx("button",{onClick:()=>j(U.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:i.jsx(bo,{status:U.status})}),i.jsx("div",{className:"flex-1 min-w-0",children:V}),i.jsx("button",{onClick:()=>I(U.id),className:"flex-shrink-0 text-text-muted hover:text-accent-error transition-colors cursor-pointer mt-0.5 ml-auto",title:"Delete entry",children:i.jsx("span",{className:"flex",children:i.jsx(Ns,{className:"w-4 h-4"})})})]},U.id)}),u.length===0&&i.jsx("p",{className:"text-sm text-text-muted italic text-center py-4",children:"No entries yet."})]}),i.jsx("div",{className:"mt-4 pt-3 border-t border-border",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight",children:"○"}),i.jsx("input",{ref:_,value:w,onChange:U=>C(U.target.value),onKeyDown:G,placeholder:"New entry...",className:"flex-1 bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"}),i.jsxs("button",{onClick:M,className:"flex items-center gap-1 text-sm text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add entry",children:[i.jsx(Jr,{className:"w-4 h-4"}),"Add"]})]})})]})}const vt=Mn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const r=await(await ye("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const r=await(await ye("/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 ye(`/api/workflows/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ye(`/api/workflows/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createWorkflow:async(n,r)=>{const a=await mi("POST","/api/workflows",{...n,destination:r});return a.success&&await t().fetchWorkflows(),a},updateWorkflow:async(n,r)=>{const a=await mi("PUT",`/api/workflows/${n}`,r);return a.success&&await t().fetchWorkflows(),a},deleteWorkflow:async n=>{try{const r=await ye(`/api/workflows/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n),projectItems:l.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r)=>Ed(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),r)})),QB={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function JB(e,t){await ye(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function Pu({id:e,agents:t}){const n=ql(t,e),r=t.find(a=>a.id===e);return i.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function ZB({id:e}){const t=vt(u=>u.defaults),n=vt(u=>u.userItems),a=E.useMemo(()=>[...t,...n],[t,n]).find(u=>u.id===e),l=(a==null?void 0:a.color)??"#3b82f6";return i.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${l}20`,color:l},children:(a==null?void 0:a.name)??e})}function Yk({entries:e,sessionId:t}){const[n,r]=E.useState(e),[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(""),[p,m]=E.useState(""),[x,y]=E.useState(!1),[w,C]=E.useState(!1),_=xt(X=>X.defaults),S=xt(X=>X.userItems),v=xt(X=>X.projectItems),b=E.useMemo(()=>[..._,...S,...v],[_,S,v]),j=E.useRef(null),N=E.useRef(null);E.useEffect(()=>{r(e)},[e]),E.useEffect(()=>{var X;a&&((X=j.current)==null||X.focus())},[a]),E.useEffect(()=>{var X;u&&((X=N.current)==null||X.focus())},[u]);const T=E.useCallback(X=>{r(X),JB(t,X)},[t]),D=E.useCallback(X=>{var z;const $=X.map(re=>re.trim()).filter(Boolean);if($.length===0)return;const O=n.map(re=>Number(re.id)).filter(re=>Number.isInteger(re)&&re>=0),B=Math.max(-1,...O)+1,q=$.map((re,ne)=>({id:String(B+ne),description:re,status:"pending"}));T([...n,...q]),h(""),(z=j.current)==null||z.focus()},[n,T]),L=E.useCallback(()=>{D([d])},[D,d]),I=E.useCallback(X=>{const $=X.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);$.length<2||(X.preventDefault(),D($))},[D]),M=E.useCallback(()=>{l(!1),h("")},[]),G=E.useCallback((X,$)=>{c(X),m($)},[]),U=E.useCallback(()=>{if(!u)return;const X=p.trim(),$=n.map(O=>O.id===u?{...O,description:X||O.description}:O);T($),c(null)},[u,p,n,T]),R=E.useCallback(X=>{const $=n.map(O=>O.id===X?{...O,status:QB[O.status]??"pending"}:O);T($)},[n,T]),H=E.useCallback(X=>{T(n.filter($=>$.id!==X))},[n,T]),W=E.useCallback(()=>{T([]),y(!1)},[T]),V=E.useCallback(X=>{X.key==="Enter"&&(X.preventDefault(),L()),X.key==="Escape"&&M()},[L,M]),ee=E.useCallback(X=>{X.key==="Enter"&&U(),X.key==="Escape"&&c(null)},[U]);return i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[i.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&i.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",i.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((X,$)=>{const O=X.status,B=u===X.id;return i.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${$>0?"border-t border-border":""}`,children:[i.jsx("button",{onClick:()=>R(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:i.jsx(bo,{status:O})}),i.jsx("div",{className:"flex-1 min-w-0",children:B?i.jsx("input",{ref:N,value:p,onChange:q=>m(q.target.value),onBlur:U,onKeyDown:ee,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):i.jsxs("button",{onClick:()=>G(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,"] ",Zg(X.description)]})}),i.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:i.jsx(Ns,{className:"w-4 h-4"})})]},X.id)})]}),a&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),i.jsx("input",{ref:j,value:d,onChange:X=>h(X.target.value),onKeyDown:V,onPaste:I,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),i.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?i.jsxs(i.Fragment,{children:[i.jsxs("button",{onClick:L,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[i.jsx(Jr,{className:"w-3 h-3"}),"Add"]}),i.jsx("button",{onClick:M,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[i.jsx(Jr,{className:"w-3 h-3"}),"Add"]}),n.length>0&&i.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[i.jsx(ta,{className:"w-3 h-3"}),"Clear all"]}),i.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:i.jsx(cg,{className:"w-3 h-3"})})]}),x&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[i.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:W,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),i.jsx("button",{onClick:()=>y(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),i.jsx(jt,{isOpen:w,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:i.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[i.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),i.jsxs("p",{children:["To use this feature, start in ",i.jsx(Pu,{id:"planner",agents:b})," mode and",i.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",i.jsx(ZB,{id:"default"})," builtin workflow to launch the automation part."]}),i.jsx("p",{children:"This workflow will automatically:"}),i.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[i.jsxs("li",{children:["Launch the ",i.jsx(Pu,{id:"builder",agents:b}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),i.jsxs("li",{children:["Then launch the ",i.jsx(Pu,{id:"verifier",agents:b})," subagent, that will verify each criterion. If every criterion is fulfilled, then it goes to the next step, otherwise, it gives feedback to the main agent until 100% of the criteria are met."]}),i.jsxs("li",{children:["Launch a ",i.jsx(Pu,{id:"code_reviewer",agents:b})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),i.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:i.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function Xk({isOpen:e,onClose:t}){const n=Rn(C=>C.config),r=Rn(C=>C.saveConfig),[a,l]=E.useState(""),[u,c]=E.useState(""),[d,h]=E.useState(!1),[p,m]=E.useState(!1),[x,y]=E.useState(!1);E.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),h((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!a.trim()||!u.trim()||(y(!0),await r({command:a.trim(),url:u.trim(),hotReload:d,disableInspect:p}),y(!1),t())};return i.jsx(jt,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),i.jsx("input",{className:"input w-full",type:"text",value:a,onChange:C=>l(C.target.value),placeholder:"npm run dev"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),i.jsx("input",{className:"input w-full",type:"text",value:u,onChange:C=>c(C.target.value),placeholder:"http://localhost:3000"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>h(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),i.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:C=>m(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),i.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),i.jsx("button",{className:"btn btn-primary",onClick:w,disabled:x||!a.trim()||!u.trim(),children:x?"Saving...":"Save"})]})]})})}const MS={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"},e8={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"},PS={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},t8="text-text-primary";function n8(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",l;try{for(;(l=n.exec(e))!==null;){if(l.index>r){const h=e.slice(r,l.index);h&&t.push({text:h,className:a})}const u=l[1];if(!u)continue;const c=u.split(";").map(Number);if(c.length===0||c[0]===0){a="text-text-primary";continue}const d=[];for(const h of c)if(h>=30&&h<=37){const p=MS[h];p&&d.push(p)}else if(h>=40&&h<=47){const p=e8[h];p&&d.push(p)}else if(h>=90&&h<=97){const p=MS[h];p&&d.push(p)}else if(h in PS){const p=PS[h];p&&d.push(p)}else h===39?d.push(t8):h===49&&(a=a.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));d.length>0&&(a=d.join(" ")),r=n.lastIndex}if(r<e.length){const u=e.slice(r);u&&t.push({text:u,className:a})}return t}catch(u){return console.warn("ANSI parsing failed, stripping codes:",u),[{text:r8(e),className:"text-text-primary"}]}}function r8(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function _d(e){const t=n8(e),n=[];return t.forEach((r,a)=>{const l=r.text.split(`
|
|
284
|
+
`);l.forEach((u,c)=>{n.push(oi.createElement("span",{key:`${a}-${c}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push(oi.createElement("br",{key:`${a}-${c}-br`}))})}),n.length===1?n[0]:n}function Qk({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return i.jsx("pre",{ref:t,className:n,children:e.length===0?i.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((r,a)=>r.type==="marker"?i.jsx(E.Fragment,{children:i.jsx("hr",{className:"border-t border-border my-1"})},a):i.jsx("span",{className:r.stream==="stderr"?"text-accent-warning":"",children:_d(r.content)},a))})}function ex({isActive:e,onToggle:t,className:n,style:r}){return i.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):i.jsx(dn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const eh=(e,t)=>{const n=E.useRef(!0),r=E.useRef(null),[a,l]=E.useState(!0),u=()=>{const c=e.current;c&&(c.scrollTop=c.scrollHeight)};return E.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)},h=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",h,{passive:!0}),c.addEventListener("touchmove",p,{passive:!0}),m.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{c.removeEventListener("wheel",d),c.removeEventListener("touchstart",h),c.removeEventListener("touchmove",p),m.disconnect(),clearInterval(x)}},[t==null?void 0:t.id]),{force_scroll_to_bottom:()=>{n.current=!0,l(!0),u()},isAutoScrollActive:a,setAutoScroll:c=>{n.current=c,l(c),c&&u()}}},tx=E.memo(function({title:t,logs:n,onClose:r,onClear:a,onInsertMarker:l,preClassName:u}){const c=E.useRef(null),{isAutoScrollActive:d,setAutoScroll:h}=eh(c,null);return i.jsx(jt,{isOpen:!0,onClose:r,title:t,size:"full",scrollable:!1,headerRight:i.jsx(ex,{isActive:d,onToggle:h,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),footer:i.jsxs("div",{className:"flex items-center gap-2",children:[l&&i.jsxs("button",{onClick:l,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Insert marker",children:[i.jsx(Jr,{className:"w-3.5 h-3.5"}),"Marker"]}),a&&i.jsxs("button",{onClick:a,className:"text-xs text-text-muted hover:text-accent-error flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Clear logs",children:[i.jsx(ta,{className:"w-3.5 h-3.5"}),"Clear"]})]}),children:i.jsx("div",{ref:c,className:"flex-1 overflow-y-auto scrollbar-stable -m-4 p-4",children:i.jsx(Qk,{logs:n,preClassName:u})})})}),s8=E.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:l}){const[u,c]=E.useState(null),d=E.useRef(null),h=E.useRef(l);return h.current=l,E.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]),E.useEffect(()=>{const p=d.current;if(!p)return;const m=x=>{if(x.deltaY<0){h.current(!1);return}x.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{p.scrollHeight-p.scrollTop-p.offsetHeight<100&&h.current(!0)}))};return p.addEventListener("wheel",m,{passive:!0}),()=>p.removeEventListener("wheel",m)},[]),E.useEffect(()=>{d.current&&a&&(d.current.scrollTop=d.current.scrollHeight)},[t,a,u]),i.jsx("div",{className:`relative ${u?"":"hidden"}`,children:i.jsx("pre",{ref:d,className:"fixed z-40 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border overflow-auto transition-all duration-150 ease-out select-text",style:u?{bottom:u.bottom,right:u.right,width:u.width*2,maxHeight:u.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:t.map((p,m)=>i.jsx("span",{className:p.stream==="stderr"?"text-accent-warning":"",children:_d(p.content)},m))})})}),Jk=E.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const l=Rn(X=>X.setWorkdir),u=Rn(X=>X.status),c=Rn(X=>X.config),d=Rn(X=>X.logs),h=Rn(X=>X.start),p=Rn(X=>X.stop),m=Rn(X=>X.fetchLogs),x=Rn(X=>X.clearLogs),y=Rn(X=>X.insertMarker),w=()=>{window.confirm("Clear all dev server logs?")&&x()},[C,_]=E.useState(!1),[S,v]=E.useState(!1),[b,j]=E.useState(!1),[N,T]=E.useState(!1),D=E.useRef(null),{isAutoScrollActive:L,setAutoScroll:I}=eh(D,null),M=E.useRef(null),G=E.useRef(null),U=E.useRef(null),R=()=>{const X=u==null?void 0:u.inspectProxyPort;if(!X){u!=null&&u.url&&window.open(u.url,"_blank");return}const $=`${window.location.protocol}//${window.location.hostname}:${X}`;window.open($,"_blank")},H=(u==null?void 0:u.state)??"off",W=c!==null,V=H==="running"||H==="warning";E.useEffect(()=>{l(t??null)},[t,l]),E.useEffect(()=>{V&&m()},[V,m]);const ee=()=>{V?p():h()};return i.jsxs("div",{className:`space-y-3 ${n?"":"mt-2 pt-3 border-t border-border"}`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${H==="running"?"bg-accent-success":H==="warning"?"bg-accent-warning":H==="error"?"bg-accent-error":"bg-text-muted"}`}),i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),i.jsx("button",{onClick:()=>{a?a():_(!0)},className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:i.jsx(fT,{})})]}),W?i.jsx(i.Fragment,{children:H==="running"||H==="warning"?i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{onClick:ee,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[i.jsx(ug,{}),"Stop"]}),(u==null?void 0:u.url)&&i.jsxs("button",{onClick:()=>R(),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:u.url,children:[i.jsx(R1,{}),"Open"]})]}):i.jsx("button",{onClick:ee,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"})}):i.jsx("button",{onClick:()=>{a?a():_(!0)},className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),i.jsxs("div",{ref:U,className:`relative ${W&&V?"":"hidden"}`,onMouseEnter:()=>{!W||!V||n||(G.current&&clearTimeout(G.current),M.current=setTimeout(()=>{j(!0),T(!1)},500))},onMouseLeave:()=>{M.current&&clearTimeout(M.current),T(!0),G.current=setTimeout(()=>j(!1),150)},children:[i.jsx(Qk,{logs:d,preRef:D,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),W&&V&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[!n&&(b||N)&&i.jsx(ex,{isActive:L,onToggle:I,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),i.jsx("button",{onClick:()=>n?r==null?void 0:r():v(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),!n&&(b||N)&&U.current&&pi.createPortal(i.jsx(s8,{logs:d,anchorRef:U,isHiding:N,isAutoScrollActive:L,onSetAutoScroll:I}),document.body)]})]}),!a&&i.jsx(Xk,{isOpen:C,onClose:()=>_(!1)}),S&&i.jsx(tx,{title:"Dev Server Logs",logs:d,onClose:()=>v(!1),onClear:w,onInsertMarker:y})]})}),i8=E.memo(function({sessionId:t}){var y;const n=Nl(w=>w.processes),r=Nl(w=>w.stopProcess),[a,l]=E.useState(null),[u,c]=E.useState([]),d=n.filter(w=>w.status!=="exited"),h=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=Nl.getState().logs[w]??[];c(C.map(_=>({content:_.content,stream:_.stream}))),l(w)},x=w=>{t&&r(w,t)};return i.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),i.jsx("div",{className:"space-y-2",children:d.map(w=>i.jsx("div",{className:"border border-border rounded p-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(w.status)}`}),i.jsx("span",{className:"text-sm text-text-primary truncate",title:w.name,children:w.name}),i.jsxs("span",{className:"text-xs text-text-muted",children:["[",w.status,"]"]})]}),i.jsxs("div",{className:"flex gap-1 ml-2",children:[i.jsx("button",{onClick:()=>m(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),i.jsx("button",{onClick:()=>x(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},w.id))}),a&&i.jsx(tx,{title:((y=d.find(w=>w.id===a))==null?void 0:y.name)??"",logs:u,onClose:()=>{l(null),c([])}})]})});function Zk(){return Qt.getState().platform??null}function ej(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function tj(e,t,n){const r=Zk(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,l=ej(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${l}`}:${t??1}`;const u=`vscode://file/${l}`;return t?`${u}:${t}`:u}function a8(e){const t=Zk(),n=ej(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function o8({file:e,showEditorLink:t,workdir:n}){const r=G1(e.path,28),a=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",l=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"",u=t&&n?tj(e.path,void 0,n):void 0,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),l&&i.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:l})]});return u?i.jsx("a",{href:u,className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0 hover:bg-bg-tertiary rounded px-1 transition-colors no-underline",title:`Open ${e.path} in VSCode`,children:c}):i.jsx("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:c})}function l8(){const{diff:e}=Jg(),t=Ft(a=>a.settings[Te.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",n=Le(a=>a.currentSession),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?i.jsx("div",{className:"mt-3",children:i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[i.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),i.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?i.jsx("div",{className:"mt-3",children:i.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):i.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:i.jsx("div",{className:"pr-1",children:e.files.map((a,l)=>i.jsx(o8,{file:a,showEditorLink:t,workdir:r},l))})})}function nj(e){const[t,n]=E.useState(!1),[r,a]=E.useState(null),[l,u]=E.useState(!1),[c,d]=E.useState(""),h=E.useCallback(()=>{t||e()},[t,e]),p=c.trim().length>0&&!t,m=E.useCallback(()=>{a(null),n(!1),d(""),u(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:l,setLoading:u,newName:c,setNewName:d,handleClose:h,canCreate:p,resetState:m}}function rj({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:l}){const u=i.jsx("div",{className:"flex gap-2 justify-end",children:i.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Cancel"})});return i.jsx(jt,{isOpen:e,onClose:t,title:n,size:"md",footer:u,children:a||r?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(gi,{})}):l})}function sj({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:l,onCreate:u,canCreate:c,busy:d}){return i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:t}),i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded border border-border bg-bg-primary focus-within:border-accent-primary mb-3",children:[i.jsx("span",{className:"w-4 h-4 shrink-0 text-text-muted flex items-center",children:e}),i.jsx("input",{type:"text",value:a,onChange:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&c&&u()},placeholder:n,className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),i.jsx("button",{onClick:u,disabled:!c||d,className:"w-full px-4 py-2 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-50",children:r})]})}function ij({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:l}){const u=Le(R=>R.loadSession),{busy:c,setBusy:d,error:h,setError:p,loading:m,setLoading:x,newName:y,setNewName:w,handleClose:C,canCreate:_,resetState:S}=nj(t),[v,b]=E.useState([]),[j,N]=E.useState(null),[T,D]=E.useState(null),[L,I]=E.useState(!1);E.useEffect(()=>{e&&(S(),N(null),D(null),I(!1),ye(`/api/projects/${n}/workspaces`).then(R=>R.json()).then(R=>{b(R.workspaces),x(!1)}).catch(()=>{b([]),x(!1)}))},[e,n,S,x]);const M=E.useCallback(async R=>{p(null),d(!0);try{const H=await ye(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:R})});if(!H.ok){const W=await H.json().catch(()=>({error:"Failed to switch workspace"}));p(W.error),d(!1);return}await u(r),t()}catch(H){p(H instanceof Error?H.message:"Failed to switch workspace"),d(!1)}},[r,u,t,p,d]),G=E.useCallback(async(R,H)=>{p(null),D(null),I((H==null?void 0:H.force)===!0),d(!0);try{const W=await ye(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:R,force:(H==null?void 0:H.force)===!0})});if(!W.ok){const X=await W.json().catch(()=>({error:"Failed to delete workspace"}));p(X.error),X.conflictingSessionIds&&D(X.conflictingSessionIds),I(!1),d(!1);return}N(null),I(!1),await u(r);const ee=await(await ye(`/api/projects/${n}/workspaces`)).json();b(ee.workspaces),d(!1),x(!1)}catch(W){p(W instanceof Error?W.message:"Failed to delete workspace"),I(!1),d(!1)}},[r,n,u,p,d]),U=E.useCallback(async()=>{p(null),d(!0);try{const R=await ye(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:y.trim()})});if(!R.ok){const H=await R.json().catch(()=>({error:"Failed to create workspace"}));p(H.error),d(!1);return}await u(r),t()}catch(R){p(R instanceof Error?R.message:"Failed to create workspace"),d(!1)}},[y,r,u,t,p,d]);return i.jsx(rj,{isOpen:e,onClose:C,title:"Switch Workspace",busy:c,loading:m,children:i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),i.jsxs("div",{className:"max-h-48 overflow-y-auto space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[i.jsxs("button",{onClick:()=>M("original"),disabled:c,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${a?"hover:bg-bg-tertiary text-text-secondary":"bg-accent-primary/10 text-accent-primary cursor-default"}`,children:[i.jsx(Nr,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:"original"}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:l??"unknown"}),!a&&i.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),v.slice().sort((R,H)=>R.name===a?-1:H.name===a?1:R.name.localeCompare(H.name)).map(R=>i.jsx("div",{className:"group relative",children:j===R.name?i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[i.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",R.name,"?"]}),i.jsx("button",{onClick:()=>G(R.name),disabled:c,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),i.jsx("button",{onClick:()=>N(null),disabled:c,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):i.jsxs("div",{className:"relative",children:[i.jsxs("button",{onClick:()=>{!c&&R.name!==a&&M(R.name)},disabled:c||R.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${R.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${c?"opacity-70":""}`,children:[i.jsx(Nr,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:R.name}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:R.branch??"unknown"}),R.name===a&&i.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),R.name!==a&&!c&&i.jsx("button",{onClick:H=>{H.stopPropagation(),p(null),D(null),N(R.name)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 text-xs text-text-muted hover:text-accent-error transition-opacity px-1 py-0.5 rounded",title:"Delete workspace",children:"✕"})]})},R.path))]}),i.jsx(sj,{icon:i.jsx(Nr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:y,onChange:w,onCreate:U,canCreate:_,busy:c}),h&&i.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[i.jsx("p",{className:"text-accent-error",children:h}),T&&T.length>0&&i.jsxs("div",{className:"mt-2 space-y-1",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),i.jsx("ul",{className:"space-y-0.5",children:T.map(R=>i.jsx("li",{children:i.jsx(Jn,{href:`/p/${n}/s/${R}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:R})},R))}),i.jsx("button",{onClick:()=>G(j??"",{force:!0}),disabled:c||!j,className:"mt-2 text-xs px-2 py-1 rounded bg-accent-warning text-black hover:opacity-90 disabled:opacity-50","aria-label":"Force delete workspace, switching other sessions to original",children:L?"Processing...":"Force Delete (switch other sessions to original)"})]})]})]})})}function aj({isOpen:e,onClose:t,sessionId:n}){const r=Le(D=>D.loadSession),{busy:a,setBusy:l,error:u,setError:c,loading:d,setLoading:h,newName:p,setNewName:m,handleClose:x,canCreate:y,resetState:w}=nj(t),[C,_]=E.useState([]),[S,v]=E.useState(""),[b,j]=E.useState("");E.useEffect(()=>{e&&(w(),v(""),_([]),j(""),ye(`/api/sessions/${n}/branches`).then(D=>D.json()).then(D=>{_(D.branches),j(D.defaultBranch??""),h(!1)}).catch(()=>{_([]),h(!1)}))},[e,n,w,h]);const N=E.useCallback(async D=>{c(null),l(!0);try{const L=await ye(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:D})});if(!L.ok){const I=await L.json().catch(()=>({error:"Failed to switch branch"}));c(I.error),l(!1);return}await r(n),t()}catch(L){c(L instanceof Error?L.message:"Failed to switch branch"),l(!1)}},[n,r,t,c,l]),T=E.useCallback(async()=>{c(null),l(!0);try{const D={name:p.trim()};S&&(D.sourceBranch=S);const L=await ye(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(!L.ok){const I=await L.json().catch(()=>({error:"Failed to create branch"}));c(I.error),l(!1);return}await r(n),t()}catch(D){c(D instanceof Error?D.message:"Failed to create branch"),l(!1)}},[p,S,n,r,t,c,l]);return i.jsx(rj,{isOpen:e,onClose:x,title:"Switch Branch",busy:a,loading:d,children:i.jsxs("div",{children:[C.length>0&&i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Branches"}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(D=>i.jsxs("button",{onClick:()=>{D.current||N(D.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${D.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[i.jsx(Yi,{className:"w-3.5 h-3.5 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:D.name}),D.current&&i.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!D.current&&i.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},D.name))})]}),i.jsx(sj,{icon:i.jsx(Yi,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:p,onChange:m,onCreate:T,canCreate:y,busy:a}),p.trim()&&i.jsxs("div",{className:"mt-2",children:[i.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",b||"project default",")"]}),i.jsxs("div",{className:"relative",children:[i.jsx(Yi,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted pointer-events-none"}),i.jsx("input",{type:"text",value:S,onChange:D=>v(D.target.value),placeholder:b||"main",className:"w-full text-sm bg-bg-primary border border-border-default rounded pl-8 pr-2 py-1.5 text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),u&&i.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})})}function oj({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:l,onEditWorkspace:u,onEditBranch:c}){const[d,h]=E.useState(!1),[p,m]=E.useState(!1);return t===null?null:i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r&&n?i.jsxs("a",{href:a8(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[i.jsx(Nr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary group-hover:text-accent-primary transition-colors",children:e})]}):i.jsxs(i.Fragment,{children:[i.jsx(Nr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary",children:e})]}),i.jsx("button",{onClick:()=>{u?u():h(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]}),i.jsx("div",{className:"h-px bg-border"}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Yi,{}),i.jsx("span",{className:"truncate text-text-secondary",children:t}),i.jsx("button",{onClick:()=>{c?c():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"})]})]}),i.jsx(l8,{}),!u&&i.jsx(ij,{isOpen:d,onClose:()=>h(!1),projectId:l,sessionId:a,currentWorkspace:e,currentBranch:t}),!c&&i.jsx(aj,{isOpen:p,onClose:()=>m(!1),sessionId:a})]})}function c8(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function u8(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function nx({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",l=n==="sm"?"h-1":"h-1.5";return i.jsx("div",{className:`${l} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:i.jsx("div",{className:`h-full transition-all duration-300 ${u8(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function d8({dangerZone:e,size:t="md"}){return e?i.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function h8({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return i.jsx(n,{className:"language-",children:i.jsx("code",{className:"language-",children:e})})}const uo=E.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:l=1}){const{showSyntaxHighlighting:u}=ea(),[c,d]=E.useState(null),h=Ek(),p=E.useRef(t);if(E.useEffect(()=>{u&&(p.current=t,jk(t,n,h).then(x=>{p.current===t&&d(x)}))},[t,n,h,u]),!u||!c)return i.jsx(h8,{code:t,variant:r});if(r==="inline")return i.jsx("span",{dangerouslySetInnerHTML:{__html:c}});const m=a?"":"shiki-plain";return i.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:c}})});function lj({src:e,alt:t,isOpen:n,onClose:r}){return n?i.jsx(jt,{isOpen:n,onClose:r,title:"",size:"full",children:i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const Sd=E.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",a=t==="removed"?"line-through decoration-red-400/30":"";return i.jsx("div",{className:`border-l-[3px] ${r}`,children:i.jsx("div",{className:`min-w-0 py-3 ${a}`,children:i.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),f8=E.memo(function({oldString:t,newString:n,filePath:r}){const a=E.useMemo(()=>Jd(r),[r]),l=t.length>0,u=n.length>0;return!l&&!u?i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):i.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[l&&i.jsx(Sd,{type:"removed",children:i.jsx(uo,{code:t,language:a,variant:"block",showLineNumbers:!0})}),u&&i.jsx(Sd,{type:"added",children:i.jsx(uo,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),m8=E.memo(function({content:t,filePath:n}){const r=E.useMemo(()=>Jd(n),[n]);return i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:i.jsx(Sd,{type:"added",children:i.jsx(uo,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),p8=E.memo(function({regions:t,filePath:n}){const r=E.useMemo(()=>Jd(n),[n]);return t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):i.jsx("div",{className:"space-y-2",children:t.map((a,l)=>i.jsx(x8,{region:a,language:r},l))})});function g8(e){const t=[];function n(r,a,l){const u=t[t.length-1];u&&u.type===r&&u.startLine+u.lines.length===a?u.lines.push(l):t.push({type:r,startLine:a,lines:[l]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const a=r.oldContent.split(`
|
|
285
|
+
`);for(let u=0;u<a.length;u++)n("removed",r.startLine+u,a[u]);const l=r.newContent.split(`
|
|
286
|
+
`);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 x8=E.memo(function({region:t,language:n}){const r=g8(t);return i.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,l)=>i.jsx(y8,{section:a,language:n},l))})}),y8=E.memo(function({section:t,language:n}){const r=t.lines.join(`
|
|
287
|
+
`);return t.type==="context"?i.jsx("div",{children:i.jsx("div",{className:"min-w-0 py-3",children:i.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:i.jsx(uo,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):i.jsx(Sd,{type:t.type,children:i.jsx(uo,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function BS(e){return e.split(`
|
|
288
|
+
`).filter(t=>!t.startsWith(`
|
|
289
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
|
|
290
|
+
`)}const b8=E.memo(function({result:t,metadata:n,filePath:r}){const[a,l]=E.useState(!1),u=E.useMemo(()=>Jd(r),[r]),c=n==null?void 0:n.mimeType,d=n==null?void 0:n.base64Data;if(c!=null&&c.startsWith("image/")&&d){const w=`data:${c};base64,${d}`;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors",onClick:()=>l(!0),children:i.jsx("img",{src:w,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),i.jsx(lj,{src:w,alt:r,isOpen:a,onClose:()=>l(!1)})]})}if(!t)return i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const h=t;if(u==="markdown"){const w=BS(h);return i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto p-2",children:i.jsx(Hn,{content:w})})}const p=BS(h),m=h.split(`
|
|
291
|
+
`)[0],x=m==null?void 0:m.match(/^(\d+)\|/),y=x?parseInt(x[1],10):1;return i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:i.jsx(uo,{code:p,language:u,variant:"block",showLineNumbers:!0,startLine:y})})});function v8({type:e,content:t}){const n=e==="added"?"diff-added-bg":e==="removed"?"diff-removed-bg":"bg-transparent",r=e==="added"?"+":e==="removed"?"-":" ";return i.jsxs("div",{className:`${n} px-2`,children:[i.jsx("span",{className:"select-none text-text-muted w-6 inline-block",children:r}),i.jsx("span",{className:"whitespace-pre-wrap break-words",children:t||" "})]})}function _8({diff:e}){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!r||r.type==="unchanged"){n++;continue}if(r.type==="removed"){for(;n<e.length;){const a=e[n];if(!a||a.type!=="removed")break;t.push({type:"removed",content:a.content}),n++}for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}else if(r.type==="added")for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}return t.length===0?i.jsx("div",{className:"py-8 text-center text-text-muted",children:"No changes detected."}):i.jsxs("div",{children:[i.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Changes:"}),i.jsx("div",{className:"font-mono text-xs leading-5",children:t.map((r,a)=>i.jsx(v8,{type:r.type,content:r.content},a))})]})}function rx({isOpen:e,onClose:t,isRunning:n,onApply:r}){const[a,l]=E.useState(null),[u,c]=E.useState(!1),d=E.useRef(null),h=E.useCallback(()=>{c(!0);const p=Lt.send("context.applyDynamic.preview",{});d.current=p;const m=Lt.subscribe(x=>{if(x.id===p&&x.type==="context.preview"){const y=x.payload;l(y.diff??[]),c(!1),d.current=null,m()}});setTimeout(()=>{d.current===p&&(c(!1),d.current=null,m())},5e3)},[]);return E.useEffect(()=>{e&&(l(null),c(!0),h())},[e,h]),i.jsxs(jt,{isOpen:e,onClose:t,title:"Update system prompt",size:"lg",children:[i.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix.",n&&i.jsxs(i.Fragment,{children:[" ","Since the session is currently running, the update will be queued and applied at the start of the next turn."]})]}),u?i.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):a&&a.length>0?i.jsx("div",{className:"max-h-[60vh] overflow-auto border border-border rounded-lg",children:i.jsx(_8,{diff:a})}):i.jsx("p",{className:"text-sm text-text-tertiary mb-4",children:"The system prompt hash has changed (e.g., due to tool or skill changes), but the actual prompt text appears identical. Applying the update will still rebuild the cached prompt to ensure consistency."}),i.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[i.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:n?"Queue update":"Update"})]})]})}function cj({variant:e="popover",onUpdateSystemPrompt:t}){const n=Le(D=>D.contextState),r=Le(D=>D.currentSession),a=Le(D=>D.compactContext),l=Le(D=>D.queueUpdate),[u,c]=E.useState(!1),[d,h]=E.useState(!1);if(!n||!r)return null;const{currentTokens:p,maxTokens:m,compactionCount:x,dangerZone:y,dynamicContextChanged:w}=n,C=Math.round(p/m*100),_=r.isRunning,S=()=>{_?l():Lt.send("context.applyDynamic",{}),c(!1)},v=e==="sidebar",b=i.jsxs("span",{className:c8(C,y),children:[co(p)," / ",co(m)," (",C,"%)"]}),j=i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(nx,{percent:C,dangerZone:y,className:"flex-1"}),i.jsx(d8,{dangerZone:y}),x>0&&i.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),N=i.jsxs("div",{className:"relative",children:[i.jsx("button",{onClick:()=>h(!d),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:i.jsx(D1,{})}),d&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>h(!1)}),i.jsxs("div",{className:"absolute right-0 top-full mt-1.5 z-50 bg-bg-secondary border border-border rounded-lg shadow-xl py-1 min-w-[160px]",children:[i.jsx("button",{onClick:()=>{_||a(),h(!1)},disabled:_,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:_?"Cannot compact while running":"Compact context",children:i.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),w&&i.jsx("button",{onClick:()=>{h(!1),t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors",title:"Preview and apply system prompt changes",children:i.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]}),T=t?null:i.jsx(rx,{isOpen:u,onClose:()=>c(!1),isRunning:_,onApply:S});return v?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[i.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[i.jsx("div",{className:"text-sm",children:b}),j]}),i.jsx("div",{className:"shrink-0 pt-0.5",children:N})]}),T]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("div",{className:"flex items-center justify-between text-sm",children:b}),j]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("button",{onClick:()=>{_||a()},disabled:_,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed rounded",title:_?"Cannot compact while running":"Compact context",children:i.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),w&&i.jsx("button",{onClick:()=>{t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors rounded",title:"Preview and apply system prompt changes",children:i.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]}),T]})}function $S({messages:e,workdir:t}){var v,b,j;const[n,r]=E.useState(!1),[a,l]=E.useState(!1),[u,c]=E.useState(null),d=AB(e),{branch:h}=Jg(),p=Qt(N=>N.version),m=Le(N=>N.currentSession),x=m!=null&&m.workspace?m.workspace.split("/").pop()??null:null,y=Ft(N=>N.settings[Te.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",w=js(N=>N.status),C=js(N=>N.check),[_,S]=E.useState(!1);return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx(cj,{variant:"sidebar"}),d&&i.jsxs("div",{className:"mb-4",children:[i.jsx("button",{onClick:()=>r(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[i.jsx("span",{className:"text-text-secondary",children:Qr(d.aiTime)}),i.jsx("span",{className:"w-px h-3 bg-border"}),i.jsx("span",{className:"text-text-secondary",children:AS(d.avgPrefillSpeed)}),i.jsx("span",{children:"pp"}),i.jsx("span",{className:"w-px h-3 bg-border"}),i.jsx("span",{className:"text-text-secondary",children:AS(d.avgGenerationSpeed)}),i.jsx("span",{children:"tg"})]})}),i.jsx(UB,{isOpen:n,onClose:()=>r(!1),stats:d})]}),i.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto scrollbar-stable",children:i.jsxs("div",{children:[i.jsx("button",{onClick:()=>c("criteria"),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(vd,{entries:((v=m==null?void 0:m.metadataEntries)==null?void 0:v.criteria)??[],title:"Acceptance Criteria"})}),m&&i.jsx(Yk,{entries:((b=m==null?void 0:m.metadataEntries)==null?void 0:b.criteria)??[],sessionId:m.id}),m&&(()=>{const N=["review_findings","todos"],T=m.metadataEntries??{},D=N.filter(I=>I in T),L=Object.keys(T).filter(I=>I!=="criteria"&&!N.includes(I)).sort();return[...D,...L].filter(I=>{var M;return(((M=T[I])==null?void 0:M.length)??0)>0}).map(I=>i.jsxs("div",{className:"mt-6",children:[i.jsx("button",{onClick:()=>c(I),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(vd,{entries:T[I],title:io(I)})}),i.jsx(qk,{entries:T[I],onClearAll:async()=>{try{await ye(`/api/sessions/${m.id}/metadata/${I}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(M){console.error(`Failed to clear ${I}:`,M)}}})]},I))})()]})}),i.jsx(oj,{workspaceName:x??"original",branch:h,workdir:t,showEditorLink:y,sessionId:(m==null?void 0:m.id)??"",projectId:(m==null?void 0:m.projectId)??""}),i.jsx(Jk,{workdir:t}),i.jsx(i8,{sessionId:m==null?void 0:m.id}),p&&i.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[i.jsxs("div",{className:"flex items-center justify-center gap-1",children:[i.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",i.jsxs("span",{className:"font-mono",children:["v",p]}),i.jsx("button",{onClick:()=>{S(!0),C(!0)},disabled:w==="checking",className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:i.jsx(Td,{className:`w-3 h-3 ${w==="checking"?"animate-spin":""}`})})]}),w==="available"&&i.jsx("button",{onClick:()=>l(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),_&&w==="upToDate"&&i.jsx("div",{className:"mt-1",children:"Up to date"}),w==="error"&&i.jsx("div",{className:"mt-1",children:"Update check failed"})]}),i.jsx(X1,{isOpen:a,onClose:()=>l(!1),versionInfo:null}),i.jsx(Kk,{isOpen:u!==null,onClose:()=>c(null),entries:((j=m==null?void 0:m.metadataEntries)==null?void 0:j[u??""])??[],sessionId:(m==null?void 0:m.id)??"",metadataKey:u??"",title:io(u??"")})]})}function S8({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const a=Le(l=>l.currentSession);return i.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&i.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),i.jsxs("div",{className:"flex h-full",children:[i.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?i.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary scrollbar-stable",children:i.jsx($S,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})}):i.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),i.jsx("aside",{className:`
|
|
292
|
+
md:hidden
|
|
293
|
+
p-4 overflow-y-auto bg-secondary
|
|
294
|
+
transition-all duration-300 ease-in-out
|
|
295
|
+
fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
|
|
296
|
+
${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
|
|
297
|
+
`,children:i.jsx($S,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})]})]})}function w8(){const e=Le(w=>w.contextState),t=Le(w=>w.currentSession),n=Le(w=>w.pendingUpdate),r=Le(w=>w.triggerPendingUpdate),a=Le(w=>w.queueUpdate),[l,u]=E.useState(!1),[c,d]=E.useState(!1),h=E.useRef(!1),p=E.useRef(!1);if(E.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!h.current&&u(!1),h.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),E.useEffect(()=>{const w=(t==null?void 0:t.isRunning)??!1;p.current&&!w&&n&&r(),p.current=w},[t==null?void 0:t.isRunning,n,r]),!e||!t)return null;const{dynamicContextChanged:m}=e,x=t.isRunning,y=()=>{x?a():Lt.send("context.applyDynamic",{}),u(!0),d(!1)};return i.jsxs(i.Fragment,{children:[m&&!l&&i.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[i.jsx("span",{children:"System prompt has changed —"}),i.jsx("button",{onClick:()=>d(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),i.jsx("button",{onClick:()=>u(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:i.jsx(Ns,{})})]})}),i.jsx(rx,{isOpen:c,onClose:()=>d(!1),isRunning:x,onApply:y})]})}function C8({stats:e,onClose:t}){var c;const n=xt(d=>d.defaults),r=xt(d=>d.userItems),l=[...n,...r].find(d=>d.id===e.mode),u=(l==null?void 0:l.name)??e.mode;return i.jsx(jt,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex items-center gap-3",children:i.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",u]})}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[i.jsx(Bu,{label:"Total Time",value:Qr(e.totalTime)}),i.jsx(Bu,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),i.jsx(Bu,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),i.jsx(Bu,{label:"LLM Calls",value:String(((c=e.llmCalls)==null?void 0:c.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((d,h)=>i.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",h+1]}),i.jsxs("span",{className:"text-xs text-text-muted",children:[d.ttft.toFixed(2),"s TTFT · ",d.completionTime.toFixed(2),"s gen"]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",i.jsxs("span",{className:"text-text-primary",children:[d.promptTokens," → ",d.completionTokens]})]}),i.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[d.temperature!==void 0&&i.jsx($u,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&i.jsx($u,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&i.jsx($u,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&i.jsx($u,{label:"maxTok",value:String(d.maxTokens)})]})]})]},h))]})]})})}function Bu({label:e,value:t}){return i.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[i.jsx("div",{className:"text-xs text-text-muted",children:e}),i.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function $u({label:e,value:t}){return i.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[i.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const k8=E.memo(function({content:t,variant:n="default"}){return n==="labeled"?i.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[i.jsx("span",{className:"text-text-thinking",children:"thinking:"}),i.jsx("div",{className:"ml-1.5 mt-0.5 overflow-x-auto",children:i.jsx(Hn,{content:t})})]}):i.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item overflow-x-auto",children:i.jsx(Hn,{content:t,muted:!0})})});function uj({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}):e==="run_command"||e==="bash"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e==="workspace"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}const j8={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"}},zS=E.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(l=>l.severity==="error"),r=t.filter(l=>l.severity==="warning"),a=t.filter(l=>l.severity==="info"||l.severity==="hint");return i.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[i.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[i.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&i.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&i.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&i.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),i.jsx("div",{className:"max-h-48 overflow-y-auto",children:t.map((l,u)=>{const c=j8[l.severity];return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${c.bg} border-b border-border last:border-b-0`,children:[i.jsx("span",{className:`${c.color} text-xs flex-shrink-0 w-4 text-center`,children:c.icon}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",l.range.start.line+1,":",l.range.start.character+1]}),l.code&&i.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",l.code,"]"]})]}),i.jsx("div",{className:"text-xs text-text-primary break-words",children:l.message})]})]},u)})})]})}),E8=E.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:l,result:u,error:c,durationMs:d}){const h=E.useRef(null),[p,m]=E.useState(0);E.useEffect(()=>{h.current&&l==="pending"&&(h.current.scrollTop=h.current.scrollHeight)},[a,l]),E.useEffect(()=>{if(l!=="pending"||!r)return;const C=setInterval(()=>{m(Date.now()-r)},100);return()=>clearInterval(C)},[l,r]);const x=n/1e3,y=l==="pending"?p/1e3:(d??0)/1e3,w=l==="pending"?(a==null?void 0:a.map(C=>C.content).join(""))??"":u??"";return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[i.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),i.jsx("code",{className:"text-text-primary break-all",children:t})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[l==="pending"&&i.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),l==="interrupted"&&i.jsx("span",{className:"text-red-400",children:"interrupted"}),i.jsxs("span",{className:l==="pending"?"text-text-secondary":"text-text-muted",children:[y.toFixed(1),"s / ",x,"s"]})]})]}),l==="pending"&&i.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(w||l==="pending")&&i.jsx("pre",{ref:h,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&a?a.map((C,_)=>i.jsx("span",{className:C.stream==="stderr"?"text-accent-warning":"",children:_d(C.content)},_)):_d(w)}),l==="error"&&c&&i.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:c})]})}),_l=E.memo(function({className:t=""}){return i.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})}),N8=E.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return console.warn("DevServerView: failed to parse result JSON",t.slice(0,200)),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}return n==="logs"?T8(r):A8(r)});function T8(e){if(!e.logs)return i.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
|
|
298
|
+
`);return i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] overflow-y-auto break-words",children:t.map((n,r)=>{const a=n.startsWith("[stderr] ");return i.jsx("div",{className:a?"text-accent-warning":"",children:a?n.slice(9):n},r)})}),e.hasMore&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function A8(e){const t=String(e.state??""),n=String(e.url??""),r=e.error?String(e.error):void 0,a=t==="running"?"text-accent-success":t==="stopped"?"text-text-muted":t==="error"?"text-accent-error":"text-text-muted";return i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"State:"}),i.jsx("span",{className:`font-medium ${a}`,children:t})]}),n&&n!=="undefined"&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"URL:"}),i.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&i.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const L8=E.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return console.warn("BackgroundProcessView: failed to parse result JSON",t.slice(0,200)),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}return n==="logs"?D8(r):n==="list"?R8(r):n==="status"?O8(r):n==="start"||n==="stop"?I8(r):i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})]})});function D8(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] overflow-y-auto break-words",children:t.map((a,l)=>i.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},l))}),n&&r!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function R8(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):i.jsxs("div",{className:"space-y-2",children:[t.map(a=>i.jsx(dj,{process:a},a.id)),n!=null&&r!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function O8(e){const t=e.process,n=e.uptime;return t?i.jsxs("div",{className:"space-y-2",children:[i.jsx(dj,{process:t}),n!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",M8(n)]})]}):i.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function I8(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,l=a==="running"?"text-accent-success":"text-text-muted";return i.jsxs("div",{className:"space-y-2 text-xs",children:[n&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"Name:"}),i.jsx("span",{className:"font-medium",children:n})]}),t&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"ID:"}),i.jsx("span",{className:"font-mono",children:t})]}),r!=null&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"PID:"}),i.jsx("span",{className:"font-mono",children:r})]}),a&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"Status:"}),i.jsx("span",{className:`font-medium ${l}`,children:a})]})]})}function dj({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return i.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-medium",children:e.name}),i.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&i.jsxs("div",{className:"text-text-muted",children:["PID: ",i.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&i.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function M8(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 P8=E.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}switch(n){case"list":return B8(r);case"switch":case"delete":return $8(r);default:return i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}});function B8(e){const t=e.workspaces??[];return t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No workspaces found"}):i.jsxs("div",{className:"space-y-1 text-xs",children:[i.jsx("div",{className:"text-text-muted mb-1",children:"Workspaces:"}),t.map(n=>i.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[i.jsx("span",{className:n.active?"text-accent-success":"text-text-muted",children:n.active?"●":"○"}),i.jsx("span",{className:n.active?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.branch&&i.jsxs("span",{className:"text-text-muted",children:["· ",n.branch]}),n.active&&i.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function dp({label:e,value:t,mono:n}){return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-text-muted",children:[e,":"]}),i.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function $8(e){return i.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&i.jsx("div",{className:"text-text-primary",children:e.message}),e.workspace&&i.jsx(dp,{label:"Name",value:e.workspace,mono:!0}),e.path&&i.jsx(dp,{label:"Path",value:e.path,mono:!0}),e.branch&&i.jsx(dp,{label:"Branch",value:e.branch,mono:!0})]})}function z8(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 H8({confirmation:e}){const t=Le(m=>m.confirmPath),n=Le(m=>m.currentSession),r=Le(m=>m.switchDangerLevel),{title:a,description:l}=z8(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",h=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return i.jsxs("div",{className:`border ${c} ${d} rounded p-3 my-2`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(_p,{}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:a}),i.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),i.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[i.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),i.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:i.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,x)=>i.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:m},x))})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),i.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),i.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${h?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function U8(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,l=t.limit,u=[];return a!==void 0&&a!==1&&u.push(`offset=${a}`),l!==void 0&&u.push(`limit=${l}`),u.length>0?`${r} [${u.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}if(e==="call_sub_agent")return String(t.subAgentType??"");if(e==="load_skill")return String(t.skillId??"");if(e==="web_fetch")return String(t.url??"");if(e==="web_search"){const r=String(t.query??"");return r.length>60?r.slice(0,57)+"...":r}if(e==="dev_server")return String(t.action??"");if(e==="background_process"){const r=String(t.action??""),a=t.name?String(t.name):"";return a?`${r}: ${a}`:r}if(e==="mcp_config")return String(t.action??"");const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function HS(e,t,n){var a;const r=U8(e,t);if(e==="read_file"&&n){const l=n.format,u=n.pageCount;if(l==="pdf"&&u!=null)return`${r} (PDF, ${u}p)`;if(l==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const l=n.contentType;if(l){const u=((a=l.split(";")[0])==null?void 0:a.trim())??"";if(u&&u!=="text/html")return`${r} (${u})`}}return r}function F8(e){return JSON.stringify(e,null,2)}const V8={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},W8=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),G8=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]);function q8(e){return e.split(/[\\/]/).pop()??e}function K8(e){const t=[];let n=null,r=!1;for(let a=0;a<e.length;a+=1){const l=e[a];if(r){r=!1;continue}if(l==="\\"&&n!=="'"){r=!0;continue}if(l==="'"||l==='"'){n=n===l?null:n===null?l:n;continue}if(n)continue;if(l==="#"&&(a===0||/\s|[;&|(){}]/.test(e[a-1])))break;if(l!=="<"||e[a-1]==="<"||e[a+1]!=="<"||e[a+2]==="<")continue;let u=a+2;const c=e[u]==="-";for(c&&(u+=1);/\s/.test(e[u]??"");)u+=1;let d="",h=null,p=!1,m=!0;for(;u<e.length;){const x=e[u];if(!h&&/\s|[;&|(){}<>]/.test(x))break;if(x==="'"||x==='"'){m=!1,h===x?(h=null,p=!1):h===null&&(h=x),u+=1;continue}if(!h&&x==="$"&&e[u+1]==="'"){m=!1,p=!0,h="'",u+=2;continue}if(x==="\\"&&u+1<e.length){if(m=!1,p){const y=e.slice(u).match(/^\\(?:x([0-9A-Fa-f]{1,2})|([0-7]{1,3})|([abefnrtv\\'"?]))/);if(y){y[1]?d+=String.fromCharCode(Number.parseInt(y[1],16)):y[2]?d+=String.fromCharCode(Number.parseInt(y[2],8)):d+={a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
299
|
+
`,r:"\r",t:" ",v:"\v"}[y[3]]??y[3],u+=y[0].length;continue}}(h!=='"'||["$","`",'"',"\\",`
|
|
300
|
+
`].includes(e[u+1]))&&(u+=1)}d+=e[u],u+=1}d&&t.push({delimiter:d,stripTabs:c,expandable:m}),a=u}return t}function Y8(e){const t=e.split(`
|
|
301
|
+
`),n=[],r=[],a=[];for(const l of t){if(a.length>0){const u=a[0],c=u.stripTabs?l.replace(/^\t+/,""):l;c===u.delimiter?a.shift():u.expandable&&r.push(c);continue}n.push(l),a.push(...K8(l))}return{command:n.join(`
|
|
302
|
+
`),expandableBodies:r}}function US(e,t=!0){const n=[];let r=null,a=!1,l=!1,u=!1;for(let c=0;c<e.length;c+=1){const d=e[c];if(l){(d===`
|
|
303
|
+
`||d==="\r")&&(l=!1);continue}if(a){a=!1;continue}if(d==="\\"&&r!=="'"){u=!0,a=!0;continue}if(d==="'"){u=!0,r=r==="'"?null:r===null?"'":r;continue}if(d==='"'){u=!0,r=r==='"'?null:r===null?'"':r;continue}if(r!=="'"){if(!r&&/\s|[;&|(){}]/.test(d)?u=!1:d!=="#"&&(u=!0),t&&d==="#"&&!u){l=!0;continue}if(d==="`"){const h=e.indexOf("`",c+1);h!==-1&&(n.push(e.slice(c+1,h)),c=h);continue}if(d==="$"&&e[c+1]==="("&&e[c+2]!=="("){let h=1,p=null,m=!1;for(let x=c+2;x<e.length;x+=1){const y=e[x];if(m){m=!1;continue}if(y==="\\"&&p!=="'"){m=!0;continue}if(y==="'"||y==='"'){p=p===y?null:p===null?y:p;continue}if(!p&&(y==="("&&(h+=1),y===")"&&(h-=1),h===0)){n.push(e.slice(c+2,x)),c=x;break}}}}}return n}function X8(e){const t=[];let n="",r=!1,a=null,l=!1,u=!1;const c=()=>{r&&t.push(n),n="",r=!1};for(let d=0;d<e.length;d+=1){const h=e[d];if(u){(h===`
|
|
304
|
+
`||h==="\r")&&(u=!1,t.at(-1)!==";"&&t.push(";"));continue}if(l){r=!0,n+=h,l=!1;continue}if(h==="\\"&&a!=="'"){l=!0;continue}if(a){h===a?a=null:n+=h;continue}if(h==="'"||h==='"'){r=!0,a=h;continue}if(h==="$"&&e.slice(d,d+3)==="$(("){let p=1;const m=d;for(let x=d+3;x<e.length-1;x+=1)if(e.slice(x,x+2)==="(("&&(p+=1),e.slice(x,x+2)==="))"&&(p-=1),p===0){r=!0,n+=e.slice(m,x+2),d=x+1;break}continue}if(h==="#"&&!r){u=!0;continue}if(/\s/.test(h)){c(),(h===`
|
|
305
|
+
`||h==="\r")&&t.push(";");continue}if(h===";"||h==="|"||h==="&"||h==="("||h===")"||h==="{"||h==="}"){c(),e[d+1]===h&&(d+=1),t.push(h);continue}r=!0,n+=h}return l&&(n+="\\"),c(),t}function Sl(e,t,n){for(;t<e.length;){const r=e[t];if(r==="--")return t+1;if(!r.startsWith("-")||r==="-")return t;t+=1,!r.includes("=")&&n.has(r)&&(t+=1)}return t}function Or(e,t=0){if(t>8)return null;let n=0;for(;n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;const r=q8(e[n]??"").toLowerCase();if(r==="env"){for(let u=n+1;u<e.length;u+=1){const c=e[u];if(c==="-S"||c==="--split-string"){const h=e[u+1];return h?ao(h,t+1):null}const d=c.match(/^--split-string=(.*)$/s);if(d)return ao(d[1],t+1)}for(n=Sl(e,n+1,G8);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return Or(e.slice(n),t+1)}if(r==="sudo")return n=Sl(e,n+1,W8),Or(e.slice(n),t+1);const a=r,l=V8[a];if(l)return l;if(a==="command"){if(e.slice(n+1).some(c=>c==="-v"||c==="-V"))return null;const u=Sl(e,n+1,new Set);return Or(e.slice(u),t+1)}if(a==="setsid"||a==="nohup"){const u=Sl(e,n+1,new Set);return Or(e.slice(u),t+1)}if(a==="timeout"){const u=Sl(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return Or(e.slice(u+1),t+1)}if(a==="bash"||a==="sh"||a==="zsh"||a==="fish")for(let u=n+1;u<e.length;u+=1){const c=e[u];if(c!=="--"){if(/^-[^-]*n/.test(c))return null;if(/^-[^-]*c/.test(c)){const d=e[u+1]==="--"?2:1,h=e[u+d];return h?ao(h,t+1):null}if(!c.startsWith("-"))break}}return null}function ao(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=Y8(e),a=[...US(n),...r.flatMap(m=>US(m,!1))];for(const m of a){const x=ao(m,t+1);if(x)return x}const l=X8(n);let u=[];const c=new Set([";","|","&","(",")","{","}"]),d=new Set(["then","do","else","elif","if","while","until"]);let h=!1,p=!1;for(const m of l){if(m==="for"||m==="select"){const x=Or(u,t);if(x)return x;u=[],h=!0;continue}if(m==="case"){const x=Or(u,t);if(x)return x;u=[],p=!0;continue}if(h){m==="do"&&(h=!1);continue}if(p&&m===")"){u=[];continue}if(c.has(m)){const x=Or(u,t);if(x)return x;u=[]}else if(d.has(m)){const x=Or(u,t);if(x)return x;u=[]}else if(m==="fi"||m==="done"||m==="esac"){const x=Or(u,t);if(x)return x;u=[],m==="esac"&&(p=!1)}else u.push(m)}return Or(u,t)}function Q8(e,t){return e!=="run_command"||typeof t.command!="string"?null:ao(t.command)}const J8={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-text-tool-error",animate:!1}},Z8=E.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:l,result:u,error:c,durationMs:d,diagnostics:h,editContext:p,startedAt:m,streamingOutput:x,metadata:y,truncated:w,callId:C}){var I;const _=!l,[S,v]=E.useState(_),b=J8[r],j=Q8(t,n),N=Ft(M=>M.settings[Te.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",T=t==="edit_file"?(I=p==null?void 0:p.regions[0])==null?void 0:I.startLine:t==="read_file"?(()=>{const M=u==null?void 0:u.split(`
|
|
306
|
+
`)[0],G=M==null?void 0:M.match(/^(\d+): /);return G?parseInt(G[1],10):void 0})():void 0,D=Le(M=>M.pendingPathConfirmations),L=C?D.find(M=>M.callId===C||M.callId.startsWith(C+"-"))??null:null;return t==="step_done"?i.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary border border-border rounded px-2 py-1.5 my-1",children:[i.jsx("span",{className:`${b.color} ${b.animate?"animate-pulse":""}`,children:b.icon}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t})]}):a==="compact"?i.jsxs("div",{className:`flex items-center gap-1.5 text-xs rounded px-2 py-1.5 border ${j?"border-text-thinking/60 bg-text-thinking/10":"border-transparent bg-secondary"}`,children:[i.jsx(uj,{tool:t}),i.jsx("span",{className:"text-accent-primary font-medium",children:t}),i.jsx("span",{className:"text-text-muted truncate flex-1",children:HS(t,n,y)}),i.jsx("span",{className:`${b.color} ${b.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):i.jsxs("div",{className:`border rounded overflow-hidden my-1 min-w-0 ${j?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:[i.jsxs("button",{className:`w-full flex items-center gap-1.5 p-2 text-left ${j?"bg-text-thinking/10 hover:bg-text-thinking/15":"bg-secondary hover:bg-secondary/80"}`,onClick:()=>v(!S),children:[i.jsx("span",{className:`${b.color} ${b.animate?"animate-pulse":""}`,children:b.icon}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),i.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:HS(t,n,y)}),i.jsx("span",{className:"text-text-muted text-xs",children:S?"▼":"▶"})]}),S&&i.jsxs("div",{className:`p-2 border-t space-y-2 min-w-0 ${j?"border-text-thinking/40 bg-text-thinking/5":"border-border bg-primary"}`,children:[t==="run_command"&&i.jsx(E8,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:x,status:r,result:u,error:c,durationMs:d}),t==="edit_file"&&r==="success"&&i.jsxs(i.Fragment,{children:[p&&p.regions.length>0?i.jsx(p8,{regions:p.regions,filePath:String(n.path??"")}):i.jsx(f8,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&i.jsx(zS,{diagnostics:h})]}),t==="write_file"&&r==="success"&&i.jsxs(i.Fragment,{children:[i.jsx(m8,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&i.jsx(zS,{diagnostics:h})]}),t==="read_file"&&r==="success"&&i.jsx(b8,{result:u,metadata:y,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const M=(x==null?void 0:x.map(U=>U.content).join(""))??"",G=r==="pending"&&M?M:String(n.content??"");return i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:i.jsx(Hn,{content:G})})]})})(),t==="call_sub_agent"&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Hn,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&i.jsxs("div",{children:[i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Hn,{content:u??""})}),w&&i.jsx(_l,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Hn,{content:u??""})}),w&&i.jsx(_l,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&i.jsxs("div",{className:"space-y-2",children:[!!(y!=null&&y.url)&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[i.jsx("span",{children:"Source:"}),i.jsx("a",{href:String(y.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(y.url)}),!!(y!=null&&y.contentType)&&i.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(y.contentType),")"]}),(y==null?void 0:y.pageCount)!=null&&i.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(y.pageCount)," pages"]})]}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Hn,{content:u??""})}),w&&i.jsx(_l,{})]}),t==="dev_server"&&r==="success"&&u&&i.jsx(N8,{result:u,action:String(n.action??"")}),t==="workspace"&&r==="success"&&u&&i.jsx(P8,{result:u,action:String(n.action??"")}),t==="background_process"&&r==="success"&&u&&i.jsx(L8,{result:u,action:String(n.action??"")}),t==="mcp_config"&&r==="success"&&i.jsxs("div",{children:[i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Hn,{content:u??""})}),w&&i.jsx(_l,{className:"mt-1"})]}),t==="step_done"&&null,t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&t!=="call_sub_agent"&&t!=="web_search"&&t!=="load_skill"&&t!=="web_fetch"&&t!=="dev_server"&&t!=="workspace"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&i.jsxs(i.Fragment,{children:[Object.keys(n).length>0&&i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto break-words",children:F8(n)})]}),r==="success"&&u!==void 0&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}ms)`,":"]}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:u||"No output"}),w&&i.jsx(_l,{className:"mt-1"})]})]}),(j||r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file"))&&i.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file")&&i.jsxs("span",{children:["Completed in ",(d/1e3).toFixed(2),"s"]}),i.jsx("span",{className:"flex-1"}),N&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((y==null?void 0:y.path)??n.path??"")&&i.jsx("a",{href:tj(String((y==null?void 0:y.path)??n.path),T),className:"text-accent-primary hover:underline",children:"Open in VSCode"}),j&&i.jsxs("span",{className:"shrink-0 rounded border border-text-thinking/50 bg-text-thinking/15 px-1.5 py-0.5 font-semibold tracking-wide text-text-thinking",children:["REMOTE · ",j]})]}),r==="error"&&c&&t!=="run_command"&&i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:c})]}),L&&i.jsx(H8,{confirmation:L})]})]})}),e$={read_file:"Reading file",write_file:"Writing file",edit_file:"Editing file",run_command:"Running command",glob:"Searching files",grep:"Searching content",ask_user:"Asking user",criterion:"Managing criterion",session_metadata:"Managing",todo_write:"Updating tasks"};function t$(e,t){const n=e$[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=LB(a);return`${n} ${l}`}}catch{}return n}function n$(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 r$=E.memo(function({name:t,arguments:n}){let a=t$(t,n)+"...",l=null;if(t==="run_command"&&n){const u=n$(n);u&&(a=u,l=ao(u))}return i.jsx("div",{className:`border rounded overflow-hidden my-1 min-w-0 animate-pulse ${l?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:i.jsxs("div",{className:`flex items-center gap-1.5 p-2 ${l?"bg-text-thinking/10":"bg-bg-tertiary"}`,children:[i.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),i.jsx(uj,{tool:t}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?i.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):i.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),s$={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},i$=E.memo(function({todos:t}){return Array.isArray(t)?t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):i.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[i.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),i.jsx("div",{children:t.map((n,r)=>{const a=s$[n.status];return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[i.jsx("span",{className:`${(a==null?void 0:a.color)??"text-text-muted"} ${a!=null&&a.animate?"animate-pulse":""} text-sm leading-tight`,children:(a==null?void 0:a.icon)??"○"}),i.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):i.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function a$({toolCall:e}){var j;const t=Le(N=>N.pendingQuestions),n=Le(N=>N.answerQuestion),[r,a]=E.useState(""),l=E.useRef(null),u=E.useRef(null),c=t.find(N=>N.callId===e.id),d=e.arguments.question??(c==null?void 0:c.question)??"",h=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]";E.useEffect(()=>{x&&l.current&&l.current.focus()},[x]),E.useEffect(()=>{x&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const C=E.useCallback(()=>{c&&n(c.callId,r)},[c,r,n]),_=E.useCallback(()=>{c&&n(c.callId,"",!0)},[c,n]),S=E.useCallback(N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),C()),N.key==="Escape"&&!N.shiftKey&&(N.preventDefault(),_())},[C,_]),v=E.useCallback(N=>{c&&n(c.callId,N)},[c,n]),b="px-3 py-1.5 text-xs font-medium rounded transition-colors";return i.jsxs("div",{ref:u,className:"my-1",children:[i.jsx("div",{className:"text-sm text-text-primary",children:d}),x&&i.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:i.jsx("div",{className:"p-3 bg-primary space-y-2",children:h==="confirm"?i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>v("yes"),className:`${b} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),i.jsx("button",{onClick:()=>v("no"),className:`${b} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),i.jsx("button",{onClick:_,className:`${b} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):h==="choice"&&Array.isArray(p)&&p.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col gap-1.5",children:p.map(N=>i.jsx("button",{onClick:()=>v(N),className:`${b} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:N},N))}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("textarea",{ref:l,value:r,onChange:N=>a(N.target.value),onKeyDown:S,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),i.jsx("button",{onClick:C,disabled:!r.trim(),className:`${b} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),i.jsx("button",{onClick:_,className:`${b} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("textarea",{ref:l,value:r,onChange:N=>a(N.target.value),onKeyDown:S,placeholder:"Type your answer here... (Enter to submit, Shift+Enter for new line)",className:"w-full min-h-[80px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:!0}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{onClick:_,className:`${b} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),i.jsx("button",{onClick:C,disabled:!r.trim(),className:`${b} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),m&&i.jsx("div",{className:"mt-1 flex items-center gap-2",children:i.jsx("span",{className:`text-xs ${w?"text-amber-400":"text-accent-success"}`,children:w?"Skipped":`Answered: ${y}`})})]})}const FS={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"}},o$=E.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(c=>[c.id,c]))??[]),a=t.find(c=>{var d,h;return c.arguments.action==="get"&&((d=c.result)==null?void 0:d.success)&&((h=c.result)==null?void 0:h.output)}),l=t.some(c=>c.name==="session_metadata"),u=(()=>{if(!l)return"Acceptance Criteria";const c=new Set(t.map(d=>d.arguments.key).filter(Boolean));if(c.size===1){const d=c.values().next().value;return d?io(d):"Session Data"}return"Session Data"})();return i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[i.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:u})}),i.jsx("div",{className:"bg-primary",children:a?(()=>{const c=a.result.output;if(c==="No criteria defined yet.")return i.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),i.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(c).map((h,p)=>i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${p>0?"border-t border-border":""}`,children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx(Hn,{content:`[${h.id}] ${h.description}`})})]},h.id??p))}catch{return t.map((d,h)=>i.jsx(VS,{tc:d,index:h,criteriaMap:r},d.id??h))}})():t.map((c,d)=>i.jsx(VS,{tc:c,index:d,criteriaMap:r},c.id??d))})]})});function VS({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,a=e.arguments,l=e.name==="session_metadata",u=r==="remove",c=a.id,d=a.description,h=c?n.get(c):void 0,p=d??(h==null?void 0:h.description)??(u&&c?`[${c}]`:"Criterion updated"),m=a.reason,x=r==="fail";return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l?i.jsx(bo,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const y=r&&FS[r]?FS[r]:{icon:"○",color:"text-text-muted"};return i.jsx("span",{className:`${y.color} text-sm leading-tight flex-shrink-0`,children:y.icon})})(),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:u?"line-through text-text-muted":"",children:i.jsx(Hn,{content:p})}),m&&i.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[i.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function l$(e){return e==="criterion"||e==="session_metadata"}async function hj(e){if(navigator.clipboard){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function c$({items:e,position:t,onClose:n}){const r=E.useRef(null),[a,l]=E.useState(-1);if(E.useEffect(()=>{t&&l(-1)},[t]),E.useEffect(()=>{var p;if(!t)return;function d(m){r.current&&!r.current.contains(m.target)&&n()}function h(m){var x;switch(m.key){case"Escape":m.preventDefault(),n();break;case"ArrowDown":m.preventDefault(),l(y=>y<e.length-1?y+1:0);break;case"ArrowUp":m.preventDefault(),l(y=>y>0?y-1:e.length-1);break;case"Enter":m.preventDefault(),(x=e[a])==null||x.onClick(),n();break}}return document.addEventListener("mousedown",d),window.addEventListener("keydown",h,!0),window.addEventListener("blur",n),(p=r.current)==null||p.focus(),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",h,!0),window.removeEventListener("blur",n)}},[t,e,a,n]),!t)return null;let u=Math.min(t.x,window.innerWidth-190),c=Math.min(t.y,window.innerHeight-100);return u=Math.max(8,u),c=Math.max(8,c),pi.createPortal(i.jsx("div",{ref:r,tabIndex:-1,className:"fixed bg-bg-secondary border border-border rounded shadow-lg z-50 min-w-[160px] outline-none",style:{left:u,top:c},children:i.jsx("div",{className:"max-h-[60vh] overflow-y-auto",onMouseLeave:()=>l(-1),children:e.map((d,h)=>i.jsxs("button",{onClick:()=>{d.onClick(),n()},onMouseEnter:()=>l(h),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${h<e.length-1?"border-b border-border":""} ${d.danger?"text-accent-error hover:bg-accent-error/10":h===a?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,children:[d.icon&&i.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:d.icon}),d.label]},h))})}),document.body)}function fj(){const[e,t]=E.useState(null);return{onContextMenu:E.useCallback((a,l)=>{var u;l&&((u=window.getSelection())!=null&&u.toString()||(a.preventDefault(),t({x:a.clientX,y:a.clientY})))},[]),contextMenu:a=>i.jsx(c$,{position:e,onClose:()=>t(null),items:a})}}function u$(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const a of e)a.type==="tool_call"&&l$(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function d$(e,t){if(e.segments&&e.segments.length>0)return h$(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 h$(e,t,n,r,a){const l=[],u=new Map(t.map(c=>[c.id,c]));for(const c of e)switch(c.type){case"text":l.push({type:"text",content:c.content});break;case"thinking":c.content&&c.content.trim().length>0&&l.push({type:"thinking",content:c.content});break;case"tool_call":{const d=u.get(c.toolCallId);d&&l.push({type:"tool_call",toolCall:d});break}}for(const c of n)l.push({type:"preparing_tool_call",preparing:c});return a&&r&&l.push({type:"stats",stats:r}),l}const sx=E.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:l}){const u=Le(T=>{var D,L;return(L=(D=T.currentSession)==null?void 0:D.metadataEntries)==null?void 0:L.criteria}),c=xt(T=>T.defaults),d=xt(T=>T.userItems),h=[...c,...d],p=d$(t,n),m=r?p:p.filter(T=>T.type!=="thinking"),x=u$(m),[y,w]=E.useState(!1),[C,_]=E.useState(null),[,S]=Tn(),{onContextMenu:v,contextMenu:b}=fj();if(x.length===0)return null;const j=()=>{hj(t.content)},N=async()=>{if(!l||y)return;w(!0),_(null);const T=await b1(l,t.id);w(!1),T!=null&&T.session?S(`/p/${T.session.projectId}/s/${T.session.id}`):_("Failed to fork session")};return i.jsxs("div",{className:"feed-item",onContextMenu:T=>v(T,!!l),children:[i.jsxs("div",{className:"min-w-0",children:[C&&i.jsx("p",{className:"text-xs text-accent-error mb-1 ml-0.5",children:C}),x.map((T,D)=>{var L;switch(T.type){case"thinking":return i.jsx(k8,{content:T.content},D);case"text":return i.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:i.jsx(Hn,{content:T.content})},D);case"preparing_tool_call":return i.jsx(r$,{name:T.preparing.name,arguments:T.preparing.arguments},`preparing-${T.preparing.index}`);case"tool_call":{const I=T.toolCall,M=I.result;if(I.name==="ask_user")return i.jsx(a$,{toolCall:I},D);if(I.name==="todo_write"){const R=I.arguments.todos,H=Array.isArray(R)?R:[];return i.jsx(i$,{todos:H},D)}const G=(L=M==null?void 0:M.output)==null?void 0:L.includes("[interrupted by user]"),U=M?G?"interrupted":M.success?"success":"error":"pending";return i.jsx(Z8,{tool:I.name,args:I.arguments,status:U,variant:"expandable",forceCompact:!a,result:M==null?void 0:M.output,error:M==null?void 0:M.error,durationMs:M==null?void 0:M.durationMs,diagnostics:M==null?void 0:M.diagnostics,editContext:M==null?void 0:M.editContext,startedAt:I.startedAt,streamingOutput:I.streamingOutput,metadata:M==null?void 0:M.metadata,truncated:(M==null?void 0:M.truncated)??!1,callId:I.id},D)}case"criteria_group":return i.jsx(o$,{toolCalls:T.toolCalls,criteria:u},D);case"stats":{const I=T.stats;if(!I||"error"in I)return null;const M=I.model.split("/").pop()??I.model,G=ql(h,I.mode),U=h.find(V=>V.id===I.mode),R=(U==null?void 0:U.name)??I.mode,H=V=>V>=1e3?`${(V/1e3).toFixed(1)}k`:V.toString(),W=V=>V>=1e3?`${(V/1e3).toFixed(1)}k`:V.toFixed(1);return i.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[i.jsx("span",{className:"flex-1 h-px bg-border"}),i.jsx("span",{className:"text-text-secondary",children:M}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{style:{color:G},children:R}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{children:Qr(I.totalTime)}),I.toolTime>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[Qr(I.toolTime)," tools"]})]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[H(I.prefillTokens)," @ ",W(I.prefillSpeed)," pp"]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[H(I.generationTokens)," @ ",W(I.generationSpeed)," tg"]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const V=new CustomEvent("open-turn-stats",{detail:{stats:I}});window.dispatchEvent(V)},children:i.jsx(cg,{className:"w-3 h-3"})}),i.jsx("span",{className:"flex-1 h-px bg-border"})]},D)}}}),t.partial&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[i.jsx(_p,{}),i.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-text-truncated mt-1",children:[i.jsx(_p,{}),i.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),b([{label:"Copy",icon:i.jsx(Ml,{className:"w-4 h-4"}),onClick:()=>j()},{label:"Fork session from here",icon:i.jsx(Yi,{className:"w-4 h-4"}),onClick:()=>void N()}])]})});function wd(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${a},${t})`}function f$(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const m$=E.memo(function({data:t}){var u;const n=vt(c=>c.defaults),r=vt(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#8b949e";return i.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:wd(l,.3),backgroundColor:wd(l,.08)},children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(xT,{color:l}),i.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName??"Task Completed"})]}),i.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[i.jsx(wl,{label:"Iterations",value:String(t.iterations)}),i.jsx(wl,{label:"Total time",value:Qr(t.totalTimeSeconds)}),i.jsx(wl,{label:"Tool calls",value:String(t.totalToolCalls)}),i.jsx(wl,{label:"Tokens",value:f$(t.totalTokensGenerated)}),i.jsx(wl,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function wl({label:e,value:t}){return i.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[i.jsx("div",{className:"text-sm text-text-muted",children:e}),i.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const p$=E.memo(function({data:t}){var u;const n=vt(c=>c.defaults),r=vt(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#6b7280";return i.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:wd(l,.3),backgroundColor:wd(l,.08)},children:[i.jsx(O1,{className:"w-3 h-3 shrink-0",color:l}),i.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName}),i.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})}),g$=["text/"],x$=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function Ju(e){return e.startsWith("image/")}function mj(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function ix(e){return x$.includes(e)||g$.some(t=>e.startsWith(t))}function eo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pj(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const y$={"text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/javascript":"js","text/xml":"xml","text/x-yaml":"yaml","text/x-sh":"sh","text/tab-separated-values":"tsv","text/x-python":"py","text/x-java-source":"java","text/x-json":"json","text/x-typescript":"ts","text/css":"css","application/json":"json","application/xml":"xml","application/yaml":"yaml","application/x-yaml":"yaml","application/javascript":"js","application/xhtml+xml":"xhtml","application/x-sh":"sh","application/pdf":"pdf","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/svg+xml":"svg"};function b$(e){var t;return y$[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function v$(e){return Ju(e)||ix(e)||e==="application/pdf"}function _$({attachments:e,messageId:t}){const[n,r]=E.useState(null),a=Le(p=>p.visionFallbackByMessage),l=Le(p=>p.messages),u=E.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)},h=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(u){const x=`${u}-${p}`;return a[x]}return null};return e.length===0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=h(p.id);return mj(p.mimeType)?i.jsxs("div",{className:"relative inline-block",children:[i.jsxs("button",{onClick:()=>c(p.data),className:"group relative inline-block",title:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,disabled:(m==null?void 0:m.type)==="start",children:[i.jsx("img",{src:p.data,alt:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(m==null?void 0:m.type)==="start"&&i.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:i.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&i.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[m.description.slice(0,200),m.description.length>200?"...":""]})]},p.id):i.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[i.jsx("div",{className:"w-10 h-10 flex items-center justify-center rounded-md bg-bg-secondary text-sm font-bold text-text-muted shrink-0",children:pj(p.filename)}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:p.filename,children:p.filename}),i.jsx("div",{className:"text-[10px] text-text-muted",children:eo(p.size)}),ix(p.mimeType)&&p.data&&i.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[p.data.slice(0,200),p.data.length>200?"...":""]})]})]},p.id)})}),n&&i.jsx(lj,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function S$({message:e}){const[t,n]=E.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,a=(r==null?void 0:r.color)??"#6b7280",l=(r==null?void 0:r.type)??"agent",u=l==="workspace"?"Workspace":(r==null?void 0:r.name)??"Agent",d={agent:(r==null?void 0:r.kind)==="reminder"?"reminder":"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions",workspace:`${(r==null?void 0:r.workspaceName)??""} · ${(r==null?void 0:r.branchName)??""}`,branch:`🌿 ${(r==null?void 0:r.branchName)??""}`}[l]??"injected",h=l==="workflow"||l==="subagent";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[i.jsx("span",{className:"flex-1 h-px bg-border"}),i.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!h&&n(!0)}),i.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!h&&n(!0),children:u}),i.jsx("span",{children:"·"}),i.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:d}),i.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&i.jsx("div",{className:"flex justify-center feed-item mb-4",children:i.jsx("div",{className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm overflow-x-auto",style:{borderLeft:`3px solid ${a}`},children:i.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),i.jsx(jt,{isOpen:t,onClose:()=>n(!1),title:`${u} Prompt`,size:"lg",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),i.jsx("span",{className:"text-sm text-text-primary font-medium",children:u}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",l,")"]})]}),i.jsx("div",{className:"h-full min-h-96",children:i.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap break-words bg-bg-tertiary rounded p-4 h-full min-h-96 overflow-auto font-mono",children:e.content})})]})})]})}function w$({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",l=e.isSystemGenerated,u=Le($=>$.loadSession),[,c]=Tn(),[d,h]=E.useState(!1),[p,m]=E.useState(!1),[x,y]=E.useState(!1),[w,C]=E.useState(e.content),[_,S]=E.useState(!1),[v,b]=E.useState(!1),[j,N]=E.useState(null),[T,D]=E.useState(null),L=E.useRef(null),{onContextMenu:I,contextMenu:M}=fj(),G=E.useCallback(()=>{const $=L.current;$&&($.style.height="auto",$.style.height=`${$.scrollHeight}px`)},[]),U=async()=>{try{await hj(e.content),m(!0),window.setTimeout(()=>m(!1),1500)}catch{}},R=async()=>{if(!n||!t||v)return;b(!0),N(null);const $=await b1(n,t);if(b(!1),$!=null&&$.session){const O=$.session.projectId;c(`/p/${O}/s/${$.session.id}`)}else N("Failed to fork session")},H=async()=>{if(!n||!t||_)return;S(!0),D(null);const $=await __(n,t);S(!1),$?u(n):D("Failed to replay")},W=async()=>{if(!n||!t||!w.trim()||_)return;S(!0),D(null);const $=await __(n,t,w);S(!1),$?(u(n),y(!1)):D("Failed to send")},V=()=>{C(e.content),y(!1),D(null)},X=`flex items-center gap-0.5 self-end transition-[visibility,opacity] focus-within:visible focus-within:opacity-100 ${d&&!x&&!_?"visible opacity-100":"invisible opacity-0"}`;return i.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onContextMenu:$=>I($,!!n&&!!t),children:[!l&&i.jsxs("div",{className:X,children:[i.jsx("button",{onClick:()=>{U()},title:"Copy",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:p?i.jsx($r,{className:"w-3.5 h-3.5 text-accent-success"}):i.jsx(Ml,{className:"w-3.5 h-3.5"})}),n&&t&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>{D(null),C(e.content),y(!0)},title:"Edit & resend",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:i.jsx(A1,{className:"w-3.5 h-3.5"})}),i.jsx("button",{onClick:()=>{H()},title:"Replay",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:i.jsx(Td,{className:"w-3.5 h-3.5"})})]})]}),i.jsxs("div",{className:`max-w-[75%] ${x?"w-full":""} rounded p-2 ${l?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[l&&i.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),x?i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("textarea",{ref:$=>{L.current=$,$&&($.style.height="auto",$.style.height=`${$.scrollHeight}px`)},className:"w-full bg-bg-primary border border-border rounded p-1.5 text-sm text-text-primary resize-none focus:outline-none focus:border-accent-primary min-h-[60px] overflow-hidden disabled:opacity-50",value:w,onChange:$=>{C($.target.value),G()},onKeyDown:$=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),W()),$.key==="Escape"&&V()},disabled:_,autoFocus:!0}),T&&i.jsx("p",{className:"text-xs text-accent-error",children:T}),i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:V,disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",title:"Cancel",children:i.jsx(Ns,{className:"w-3.5 h-3.5"})}),i.jsx("button",{onClick:()=>{W()},disabled:_||!w.trim(),className:"p-1 rounded hover:bg-bg-tertiary text-accent-primary hover:text-accent-primary disabled:opacity-50",title:"Confirm (Ctrl+Enter)",children:i.jsx($r,{className:"w-3.5 h-3.5"})})]})]}):i.jsxs(i.Fragment,{children:[(T||j)&&i.jsx("p",{className:"text-xs text-accent-error mb-1",children:T??j}),i.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${l?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&i.jsx(_$,{attachments:e.attachments,messageId:e.id})]})]}),M([{label:"Copy",icon:i.jsx(Ml,{className:"w-4 h-4"}),onClick:()=>void U()},{label:"Fork session from here",icon:i.jsx(Yi,{className:"w-4 h-4"}),onClick:()=>void R()}])]})}const gj=E.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const l=t.role==="user",u=t.role==="assistant",c=t.role==="system",d=t.role==="tool";if(u)return i.jsx(sx,{message:t,showStats:n});if(c&&t.isCompacted)return i.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[i.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),i.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
|
|
307
|
+
`,"")})]});if(d)return i.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[i.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),i.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap break-words overflow-x-auto max-h-32",children:[t.content.slice(0,500),t.content.length>500&&"..."]})]});if(t.messageKind==="workflow-started")try{const h=JSON.parse(t.content);return i.jsx(p$,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return i.jsx(m$,{data:h})}catch{}return t.messageKind==="context-reset"?i.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[i.jsx("div",{className:"flex-1 border-t border-border"}),i.jsx("span",{children:t.content}),i.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?i.jsx(S$,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?i.jsx("div",{className:"flex justify-end feed-item",children:i.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[i.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),i.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):l?i.jsx(w$,{message:t,messageId:r,sessionId:a}):i.jsx("div",{className:"flex justify-start feed-item",children:i.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:i.jsx(Hn,{content:t.content})})})}),C$={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function k$(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function WS(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function j$({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,l=Math.round(t/n*100);return i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[i.jsxs("span",{className:WS(l,a),children:[co(t),"/",co(n)]}),i.jsxs("span",{className:WS(l,a),children:["(",l,"%)"]}),i.jsx(nx,{percent:l,dangerZone:a,size:"sm"}),a&&i.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&i.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const E$=E.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const l=E.useRef(null),u=E.useRef(null),[c,d]=E.useState(!1),h=xt(D=>D.defaults),p=xt(D=>D.userItems),m=[...h,...p],x=Le(D=>D.subAgentContextStates[r]),{showThinking:y,showVerboseToolOutput:w}=ea(),{isAutoScrollActive:C,setAutoScroll:_}=eh(u,null),S=E.useCallback(()=>{const D=!c;d(D),D&&setTimeout(()=>{var L;(L=l.current)==null||L.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),v=m.find(D=>D.id===n),b=(v==null?void 0:v.name)??C$[n]??n,j=ql(m,n),N=k$(j),T=t.filter(D=>D.role!=="tool");return i.jsxs("div",{ref:l,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[i.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:N,children:[i.jsx("span",{className:"text-xs font-medium",children:b}),i.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:x&&i.jsx(j$,{contextState:x})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>_(!C),children:[i.jsx("span",{className:`w-1 h-1 rounded-full ${C?"bg-accent-success":"border border-text-muted"}`}),"live"]}),i.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:S,children:[c?"▼":"▶"," Expand"]})]})]}),i.jsx("div",{ref:u,className:`${c?"max-h-[calc(100vh-10rem)]":"max-h-80"} overflow-y-auto p-2 transition-[max-height] duration-200`,children:T.map(D=>D.role==="assistant"?i.jsx(sx,{message:D,showStats:!0,showThinking:y,showVerboseToolOutput:w},D.id):i.jsx(gj,{message:D,isLastAssistantMessage:!1},D.id))})]})}),hp={contentVisibility:"auto",containIntrinsicSize:"auto 200px"};function zu(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 xj=E.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,showThinking:a=!0,showVerboseToolOutput:l=!0,showStats:u=!0,showAgentDefinitions:c=!0,showWorkflowBars:d=!0}){return i.jsx(i.Fragment,{children:t.map((h,p)=>{if(h.type==="context-divider")return i.jsxs("div",{"data-item-index":p,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[i.jsx("div",{className:"flex-1 border-t border-border"}),i.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),i.jsx("div",{className:"flex-1 border-t border-border"})]},zu(h));if(h.type==="subagent"){const w=h.messages.some(C=>C.isStreaming);return i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:hp,children:i.jsx(E$,{messages:h.messages,subAgentType:h.subAgentType,subAgentId:h.subAgentId,isStreaming:w})},zu(h))}const m=h.message;if(m.role==="assistant")return i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:hp,children:i.jsx(sx,{message:m,showStats:u,showThinking:a,showVerboseToolOutput:l,sessionId:r??void 0})},zu(h));const x=!c&&m.messageKind==="auto-prompt",y=!d&&(m.messageKind==="workflow-started"||m.messageKind==="task-completed");return x||y?null:i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:hp,children:i.jsx("div",{"data-message-id":m.id,className:n===m.id?"rounded animate-highlight-fade":void 0,children:i.jsx(gj,{message:m,messageId:m.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},zu(h))})})});function th(e,t,n=!0){E.useEffect(()=>{if(!n)return;const r=a=>{var l;(l=e.current)!=null&&l.contains(a.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const N$=[],T$=E.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:l,hiddenCount:u=0}){const c=Le(J=>{var K,P;return((P=(K=J.currentSession)==null?void 0:K.metadataEntries)==null?void 0:P.criteria)??N$}),d=Le(J=>{var K;return(K=J.currentSession)==null?void 0:K.id}),h=Le(J=>{var K;return(K=J.currentSession)==null?void 0:K.mode}),p=Le(J=>{var K;return(K=J.currentSession)==null?void 0:K.phase}),m=Le(J=>J.error),x=Le(J=>J.clearError),y=Nd(),w=Le(J=>J.activeWorkflowExecution),C=Le(J=>J.continueWorkflow),{showThinking:_,showVerboseToolOutput:S,showStats:v,showAgentDefinitions:b,showWorkflowBars:j}=ea(),N=vt(J=>J.defaults),T=vt(J=>J.userItems),D=[...N,...T],L=h==="planner",I=c.length>0,M=p==="done",G=t.some(J=>J.type==="message"&&J.message.role==="assistant"),U=L&&I&&!y&&G&&!M,R=(w==null?void 0:w.status)==="waiting"&&!y,H=Le(J=>{var K;return(K=J.currentSession)==null?void 0:K.projectId}),[W,V]=E.useState(!1),[ee,X]=E.useState(!1),[$,O]=E.useState(!1);E.useLayoutEffect(()=>{const J=n.current;J&&X(J.scrollHeight>J.clientHeight+1)},[n,t]),E.useEffect(()=>{const J=n.current;if(!J)return;const K=()=>O(J.scrollTop>4);return K(),J.addEventListener("scroll",K,{passive:!0}),()=>J.removeEventListener("scroll",K)},[n]);const B=()=>{if(!H||!d)return;V(!1),window.open(`/p/${H}/s/${d}/readonly`,"_blank")||V(!0)},[q,z]=E.useState(!1),re=E.useCallback(()=>{q||(z(!0),C(),setTimeout(()=>z(!1),5e3))},[q,C]),ne=E.useCallback(()=>{var J;l==null||l(),(J=n.current)==null||J.scrollTo({top:0,behavior:"smooth"})},[n,l]);return i.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[i.jsxs("div",{ref:n,"data-testid":"chat-scroll-container",className:"absolute inset-0 overflow-y-auto bg-primary scrollbar-stable",children:[i.jsxs("div",{className:"pt-4",children:[u>0&&i.jsxs("div",{className:"px-2 md:px-4 pb-2 space-y-1",children:[i.jsxs("button",{onClick:B,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:[u," older item",u!==1?"s":""," hidden — View full history"]}),W&&i.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",i.jsx("a",{href:H&&d?`/p/${H}/s/${d}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),i.jsx(xj,{displayItems:t,highlightedMessageId:r,sessionId:d,showThinking:_,showVerboseToolOutput:S,showStats:v,showAgentDefinitions:b,showWorkflowBars:j})]}),i.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[m&&i.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:m.code}),i.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:m.message})]}),i.jsx(ac,{onClick:x,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),R&&w&&i.jsx("div",{className:"flex justify-center gap-2 feed-item",children:i.jsx("button",{onClick:re,disabled:q,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/15 text-accent-primary border border-accent-primary/25 hover:bg-accent-primary/25 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:q?"⏳ Continuing...":`▶ Continue ${w.workflowName} (${w.currentStepName??"..."})`})}),U&&i.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:D.map(J=>{const K=J.color??"#3b82f6",P=parseInt(K.slice(1,3),16),Q=parseInt(K.slice(3,5),16),ae=parseInt(K.slice(5,7),16),he=`rgba(${P},${Q},${ae},0.12)`,ce=`rgba(${P},${Q},${ae},0.22)`,De=`rgba(${P},${Q},${ae},0.25)`;return i.jsx(A$,{workflowName:J.name,color:K,bg:he,bgHover:ce,border:De,subGroups:J.subGroups,onLaunch:Re=>a(J.id,Re)},J.id)})})]})]}),ee&&$&&i.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-10 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:i.jsxs("button",{type:"button",onClick:ne,className:"pointer-events-auto text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors backdrop-blur-sm bg-bg-secondary/60",children:[i.jsx(cT,{className:"w-3 h-3"}),"scroll to top"]})})]})});function A$({workflowName:e,color:t,bg:n,bgHover:r,border:a,subGroups:l,onLaunch:u}){const[c,d]=E.useState(!1),h=E.useRef(null);th(h,()=>d(!1),c);const p=l&&l.length>0;return i.jsxs("div",{className:"relative flex",children:[i.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:`px-4 py-1.5 text-sm font-medium transition-colors ${p?"rounded-l":"rounded"}`,style:{backgroundColor:n,color:t,border:`1px solid ${a}`,...p?{borderRight:"none"}:{}},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=r},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),p&&i.jsxs("div",{ref:h,className:"relative",children:[i.jsx("button",{onClick:()=>d(!c),className:"px-2.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${a}`},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=r},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n},children:"⋮"}),c&&i.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[i.jsx("button",{onClick:()=>{u(),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),i.jsx("div",{className:"border-t border-border/50"}),l.map(m=>i.jsx("button",{onClick:()=>{u(m),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:m},m))]})]})]})}function L$(){const e=Le(r=>r.connectionStatus),t=Le(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return i.jsxs("div",{className:`
|
|
308
|
+
flex items-center justify-between px-4 py-2
|
|
309
|
+
text-sm font-medium
|
|
310
|
+
${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"}
|
|
311
|
+
`,children:[i.jsx("div",{className:"flex items-center gap-2",children:n?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex gap-1",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),i.jsx("span",{children:"Reconnecting to server..."})]}):i.jsxs(i.Fragment,{children:[i.jsx(bT,{}),i.jsx("span",{children:"Connection lost"})]})}),i.jsx("button",{onClick:()=>t(),disabled:n,className:`
|
|
312
|
+
px-3 py-1 rounded text-xs font-medium
|
|
313
|
+
transition-colors
|
|
314
|
+
${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"}
|
|
315
|
+
`,children:n?"Reconnecting...":"Reconnect"})]})}const Xt=Mn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await Ak("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await ye(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ye(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const a=await mi("POST","/api/commands",{...n,destination:r});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,r)=>{const a=await mi("PUT",`/api/commands/${n}`,r);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const r=await ye(`/api/commands/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r)=>Ed(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function D$(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function R$({onClick:e}){return i.jsx("button",{type:"button",onClick:e,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:i.jsx(lg,{})})}function yj({isOpen:e,onClose:t,initialEditId:n}){const r=Xt(ke=>ke.defaults),a=Xt(ke=>ke.userItems),l=Xt(ke=>ke.projectItems),u=Xt(ke=>ke.loading),c=Xt(ke=>ke.fetchCommands),d=Xt(ke=>ke.fetchCommand),h=Xt(ke=>ke.fetchDefaultContent),p=Xt(ke=>ke.createCommand),m=Xt(ke=>ke.updateCommand),x=Xt(ke=>ke.deleteCommand),[y,w]=E.useState(null),[C,_]=E.useState(null),{view:S,editingId:v,formError:b,saving:j,formData:N,setView:T,setEditingId:D,setFormError:L,setFormData:I,setSaving:M}=V1(),{requestDelete:G,clearConfirm:U,isConfirming:R}=Jl(),H=E.useRef(!1),W=xt(ke=>ke.defaults),V=xt(ke=>ke.userItems),ee=xt(ke=>ke.fetchAgents),$=[...W,...V].filter(ke=>!ke.subagent),O=E.useRef(c),B=E.useRef(ee),q=E.useRef(d),z=E.useRef(h),re=E.useRef(n),ne=E.useRef(T),J=E.useRef(D),K=E.useRef(L),P=E.useRef(U);E.useEffect(()=>{O.current=c,B.current=ee,q.current=d,z.current=h,re.current=n,ne.current=T,J.current=D,K.current=L,P.current=U}),E.useEffect(()=>{if(e)if(O.current(),B.current(),H.current||(P.current(),H.current=!0),re.current){const ke=r.some(ze=>ze.id===re.current);ne.current("edit"),J.current(re.current),K.current(""),ke?z.current(re.current).then(ze=>{ze&&I({name:ze.metadata.name+" (copy)",id:`${re.current}-copy-${Date.now()}`,prompt:ze.prompt,agentMode:ze.metadata.agentMode??"",isDefault:!0,destination:"user"})}):q.current(re.current).then(ze=>{ze&&I({name:ze.metadata.name,id:ze.metadata.id,prompt:ze.prompt,agentMode:ze.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else ne.current("list"),J.current(null);else H.current=!1},[e]);const Q=async ke=>{w(ke);const ze=await h(ke);_((ze==null?void 0:ze.prompt)??null)},ae=async ke=>{if(r.some(lt=>lt.id===ke)){const lt=await h(ke);lt&&(D(null),I({name:`${lt.metadata.name} (copy)`,id:`${ke}-copy-${Date.now()}`,prompt:lt.prompt,agentMode:lt.metadata.agentMode??"",isDefault:!0,destination:"user"}),L(""),T("edit"))}else{const lt=await d(ke);lt&&(D(null),I({name:`${lt.metadata.name} (copy)`,id:`${ke}-copy-${Date.now()}`,prompt:lt.prompt,agentMode:lt.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))}},he=()=>{I({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),D(null),T("edit")},ce=async ke=>{const ze=await d(ke);ze&&(D(ke),I({name:ze.metadata.name,id:ze.metadata.id,prompt:ze.prompt,agentMode:ze.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))},De=async ke=>{await x(ke),U()},Re=async()=>{const ke=v??N.id;if(!ke||!N.name||!N.prompt){L("Name and message are required.");return}M(!0),L("");const ze={metadata:{id:ke,name:N.name,...N.agentMode?{agentMode:N.agentMode}:{}},prompt:N.prompt},lt=v?await m(v,ze):await p(ze,N.destination);if(M(!1),!lt.success){L(lt.error??"Failed to save command.");return}n?t():T("list")},$e=()=>{n?t():(T("list"),w(null),_(null))},Ge=ke=>{I(ze=>({...ze,name:ke})),(!v||N.isDefault)&&I(ze=>({...ze,id:D$(ke)}))},je=()=>{w(null),_(null),T("list")},Ye=()=>{y&&(w(null),T("edit"),D(y),h(y).then(ke=>{ke&&I({name:`${ke.metadata.name} (copy)`,id:`${y}-copy-${Date.now()}`,prompt:ke.prompt,agentMode:ke.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(y){const ke=r.find(ze=>ze.id===y);return i.jsx(jt,{isOpen:e,onClose:je,title:`Default: ${(ke==null?void 0:ke.name)??y}`,size:"xl",children:i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),i.jsx("span",{className:"font-mono",children:y})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),i.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:ke==null?void 0:ke.name})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),i.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(ke==null?void 0:ke.agentMode)||"None"})]})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),i.jsx("textarea",{value:C??"",readOnly:!0,placeholder:"...",className:"flex-1 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none opacity-60"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[i.jsx(st,{variant:"secondary",onClick:je,children:"Close"}),i.jsx(st,{variant:"primary",onClick:Ye,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return i.jsx(jt,{isOpen:e,onClose:$e,title:v?"Edit Command":"New Command",size:"xl",children:i.jsxs("div",{className:"flex flex-col h-full",children:[b&&i.jsx(to,{message:b}),i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsx(F1,{name:N.name,id:N.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!v&&!N.isDefault,onNameChange:Ge,onIdChange:ke=>I(ze=>({...ze,id:ke}))}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsxs("select",{value:N.agentMode,onChange:ke=>I(ze=>({...ze,agentMode:ke.target.value})),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[i.jsx("option",{value:"",children:"None (keep current mode)"}),$.map(ke=>i.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),!v&&i.jsx(Ld,{value:N.destination,onChange:ke=>I(ze=>({...ze,destination:ke}))})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),i.jsx("textarea",{value:N.prompt,onChange:ke=>I(ze=>({...ze,prompt:ke.target.value})),placeholder:"The message that will be sent when this command is triggered...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[i.jsx(st,{variant:"secondary",onClick:$e,children:"Cancel"}),i.jsx(st,{variant:"primary",onClick:Re,disabled:j||!N.name||!N.prompt,children:j?"Saving...":"Save"})]})]})});const at=ke=>ke.map(ze=>i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("span",{className:"text-text-primary text-sm font-medium",children:ze.name})})}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(ui,{onClick:()=>ce(ze.id)}),i.jsx(Bl,{onClick:()=>ae(ze.id)}),R(ze.id,"delete")?i.jsx(ed,{onConfirm:()=>De(ze.id),onCancel:U}):i.jsx(td,{onClick:()=>G(ze.id)})]})]},ze.id));return i.jsxs(jt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[i.jsx(U1,{description:"Commands are pre-defined messages you can send with a single click.",onNew:he}),i.jsxs(fg,{loading:u,hasItems:r.length>0||a.length>0||l.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),i.jsx("div",{className:"space-y-2",children:r.map(ke=>i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:i.jsx("span",{className:"text-text-primary text-sm font-medium",children:ke.name})}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(R$,{onClick:()=>Q(ke.id)}),i.jsx(Bl,{onClick:()=>ae(ke.id)})]})]},ke.id))})]}),a.length>0&&i.jsx(H1,{children:at(a)}),l.length>0&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),i.jsx("div",{className:"space-y-2",children:at(l)})]})]})]})}function O$({title:e,defaultOpen:t=!1,children:n,className:r=""}){return i.jsxs("details",{className:`group ${r}`,open:t,children:[i.jsxs("summary",{className:"text-[11px] text-text-secondary uppercase tracking-wider font-medium cursor-pointer select-none hover:text-text-primary transition-colors list-none flex items-center gap-1",children:[i.jsx(dn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),e]}),i.jsx("div",{className:"mt-2 space-y-2",children:n})]})}const $i=150,_s=54,Hu=80,Rr=30,Ga=70,GS=100,zi=50,Uu=50,qS=4,bj={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},vj=[{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)"}],I$=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"},{value:"user",label:"User (pause)"}];function ax(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.agentId);return{name:(n==null?void 0:n.name)??(e.agentId||"Agent"),color:(n==null?void 0:n.color)||"#3b82f6"}}if(e.type==="sub_agent"){const n=t.find(r=>r.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return e.type==="user"?{name:"User",color:"#f59e0b"}:{name:"Shell",color:"#22c55e"}}function M$(e,t,n,r){const a=Uu+zi+$i+GS+$i+zi+Uu,l=a/2,u=Uu+zi+$i/2,c=Uu+zi+$i+GS+$i/2,d=[],h=[],p=new Map,m=e.filter(W=>W.type==="agent"||W.type==="shell"||W.type==="user"),x=e.filter(W=>W.type==="sub_agent"),y=x.length>0,w=y?u:l,C=m.length>0?c:l,_=zi+Rr/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:_,w:Hu,h:Rr}),p.set("$start",{cx:w,cy:_,w:Hu,h:Rr});const S=W=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:W,w:Hu,h:Rr}),p.set("$done",{cx:w,cy:W,w:Hu,h:Rr})};if(e.length===0){const W=_+Rr/2+Ga*2+Rr/2;return S(W),{nodes:d,edges:h,width:a,height:W+Rr/2+zi,posMap:p}}const v=_+Rr/2+Ga,b=(W,V)=>{W.forEach((ee,X)=>{const $=v+X*(_s+Ga)+_s/2,{name:O,color:B}=ax(ee,r);d.push({id:ee.id,type:"step",label:O,color:B,cx:V,cy:$,w:$i,h:_s}),p.set(ee.id,{cx:V,cy:$,w:$i,h:_s})})};b(m,w),b(x,C);const j=m.length>0?v+(m.length-1)*(_s+Ga)+_s/2:_,N=y?v+(x.length-1)*(_s+Ga)+_s/2:_,T=Math.max(j,N)+_s/2+Ga+Rr/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 W of e)W.transitions.forEach((V,ee)=>{var z;if(!V.goto||!p.has(V.goto))return;const X=p.get(W.id),$=p.get(V.goto),O=V.when.type==="step_result"?`${V.when.result}`:V.when.type==="metadata_all_match"?`${V.when.key??"?"}=${V.when.value??"?"}`:V.when.type==="metadata_all_in"?`${V.when.key??"?"} in [${((z=V.when.values)==null?void 0:z.join(","))??"?"}]`:bj[V.when.type]??V.when.type,B=W.id===V.goto;let q;B?q="back":$.cy>X.cy+1?q="down":$.cy<X.cy-1?q="back":q="same",D.push({from:W.id,to:V.goto,label:O,edgeKey:`${W.id}:${ee}`,direction:q,backEdgeIndex:q==="back"?L++:0})});const I=new Map,M=new Map,G=new Map,U=new Map;for(const W of D)W.direction==="down"&&(I.set(W.from,(I.get(W.from)??0)+1),M.set(W.to,(M.get(W.to)??0)+1));const R=new Map,H=new Map;for(const W of D){if(W.direction!=="same")continue;const V=[W.from,W.to].sort().join("|");R.set(V,(R.get(V)??0)+1)}for(const W of D){if(W.direction==="back"||W.direction==="same"){let q=0;if(W.direction==="same"){const z=[W.from,W.to].sort().join("|");q=H.get(z)??0,H.set(z,q+1)}h.push({...W,fromPort:0,toPort:0,sameEdgeIndex:q});continue}const V=I.get(W.from)??1,ee=M.get(W.to)??1,X=G.get(W.from)??0,$=U.get(W.to)??0;G.set(W.from,X+1),U.set(W.to,$+1);const O=V===1?0:-.6+1.2*X/(V-1),B=ee===1?0:-.6+1.2*$/(ee-1);h.push({...W,fromPort:O,toPort:B,sameEdgeIndex:0})}return{nodes:d,edges:h,width:a,height:T+Rr/2+zi,posMap:p}}function P$({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:d,onRemoveStep:h,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:x,onDeleteTransition:y}){const w=E.useRef(null),C=E.useRef(!1),[_,S]=E.useState(null),[v,b]=E.useState(null),[j,N]=E.useState(null),{nodes:T,edges:D,width:L,height:I,posMap:M}=E.useMemo(()=>M$(e,t,a,l),[e,t,a,l]),G=E.useCallback(ne=>{var ae;const J=w.current;if(!J)return{x:0,y:0};const K=J.createSVGPoint();K.x=ne.clientX,K.y=ne.clientY;const P=(ae=J.getScreenCTM())==null?void 0:ae.inverse();if(!P)return{x:0,y:0};const Q=K.matrixTransform(P);return{x:Q.x,y:Q.y}},[]),U=E.useCallback(ne=>!ne||!v||ne==="$start"?!1:v.type==="reconnect-from"?ne!=="$done":!0,[v]),R=E.useCallback((ne,J)=>{if(u)return;ne.stopPropagation(),ne.preventDefault();const K=G(ne);b({type:"new",fromNodeId:J,mouseX:K.x,mouseY:K.y})},[G,u]),H=E.useCallback((ne,J)=>{if(u)return;ne.stopPropagation(),ne.preventDefault();const K=G(ne);b({type:"reconnect-to",fromNodeId:J.from,edgeKey:J.edgeKey,mouseX:K.x,mouseY:K.y})},[G,u]),W=E.useCallback((ne,J)=>{if(u)return;ne.stopPropagation(),ne.preventDefault();const K=G(ne);b({type:"reconnect-from",fromNodeId:J.from,fixedTargetId:J.to,edgeKey:J.edgeKey,mouseX:K.x,mouseY:K.y})},[G,u]),V=E.useCallback(ne=>{if(!v)return;const J=G(ne);b(K=>K?{...K,mouseX:J.x,mouseY:J.y}:null)},[v,G]),ee=E.useCallback(()=>{v&&(C.current=!0,j&&U(j)&&(v.type==="new"?p(v.fromNodeId,j):v.type==="reconnect-to"?m(v.edgeKey,j):v.type==="reconnect-from"&&x(v.edgeKey,j)),b(null),N(null))},[v,j,U,p,m,x]),X=E.useCallback(()=>{if(C.current){C.current=!1;return}c(null),d(null)},[c,d]);E.useEffect(()=>{if(u)return;const ne=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||(J.key==="Delete"||J.key==="Backspace")&&r&&r!=="start"&&(J.preventDefault(),y(r),d(null))};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[u,r,y,d]);const $=ne=>{const J=M.get(ne.from),K=M.get(ne.to);if(!J||!K)return null;let P,Q,ae,he="middle",ce,De;if(ne.direction==="down"){const Re=J.cx+ne.fromPort*(J.w/2-10),$e=J.cy+J.h/2,Ge=K.cx+ne.toPort*(K.w/2-10),je=K.cy-K.h/2,Ye=je-$e,at=Ge-Re;P=`M ${Re} ${$e} C ${Re} ${$e+Ye*.4}, ${Ge-at*.2} ${je-Ye*.1}, ${Ge} ${je}`,Q=Re+(Ge-Re)*.5,ae=$e+Ye*.6,ce={x:Re,y:$e},De={x:Ge,y:je}}else if(ne.direction==="back"){const Re=ne.from===ne.to,$e=J.cx>=L/2,Ge=ne.backEdgeIndex*16,je=$e?L-20-Ge:20+Ge;if(Re){const Ye=J.cx>=L/2,at=30+ne.backEdgeIndex*14,ke=J.cy-J.h/2,ze=Ye?J.cx+J.w/2:J.cx-J.w/2,lt=Ye?ze+at:ze-at,we=J.cx+(Ye?J.w/4:-J.w/4),He=ke-20-ne.backEdgeIndex*10;P=`M ${ze} ${J.cy} C ${lt} ${J.cy}, ${lt} ${He}, ${we} ${ke}`,Q=lt+10,ae=He+4,he="middle",ce={x:ze,y:J.cy},De={x:we,y:ke}}else{const Ye=$e?J.cx+J.w/2:J.cx-J.w/2,at=K.cx+($e?K.w/4:-K.w/4),ke=Math.min(J.cy,K.cy)-K.h/2-18-ne.backEdgeIndex*14;P=`M ${Ye} ${J.cy} L ${je} ${J.cy} L ${je} ${ke} L ${at} ${ke} L ${at} ${K.cy-K.h/2}`,Q=je,ae=(J.cy+ke)/2,he=$e?"start":"end",ce={x:Ye,y:J.cy},De={x:at,y:K.cy-K.h/2}}}else{const Re=K.cx>J.cx,$e=ne.sameEdgeIndex===0?-12:12,Ge=Re?J.cx+J.w/2:J.cx-J.w/2,je=Re?K.cx-K.w/2:K.cx+K.w/2,Ye=J.cy+$e,at=K.cy+$e,ke=(Ge+je)/2;P=`M ${Ge} ${Ye} C ${ke} ${Ye}, ${ke} ${at}, ${je} ${at}`,Q=ke,ae=(Ye+at)/2-6,ce={x:Ge,y:Ye},De={x:je,y:at}}return{path:P,labelX:Q,labelY:ae,labelAnchor:he,fromPt:ce,toPt:De}},O=(ne,J)=>{const K=$(ne);if(!K)return null;const{path:P,labelX:Q,labelY:ae,labelAnchor:he}=K,ce=r===ne.edgeKey,De=ne.label&&ne.label!=="otherwise";return i.jsxs("g",{children:[i.jsx("path",{d:P,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Re=>{Re.stopPropagation(),u||d(ce?null:ne.edgeKey)}}),i.jsx("path",{d:P,fill:"none",stroke:ce?"#58a6ff":"#484f58",strokeWidth:ce?2.2:1.2,markerEnd:ce?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),De&&i.jsx("text",{x:Q+(he==="start"?5:he==="end"?-5:0),y:ae+3,textAnchor:he,className:"text-[8px]",fill:ce?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:ne.label})]},J)},B=()=>{if(!r||v)return null;const ne=D.find(ae=>ae.edgeKey===r);if(!ne)return null;const J=$(ne);if(!J)return null;const{fromPt:K,toPt:P}=J,Q=6;return i.jsxs(i.Fragment,{children:[ne.edgeKey!=="start"&&i.jsx("circle",{cx:K.x,cy:K.y,r:Q,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>W(ae,ne)}),i.jsx("circle",{cx:P.x,cy:P.y,r:Q,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>H(ae,ne)})]})},q=()=>{if(!v)return null;let ne,J,K,P;if(v.type==="reconnect-from"){const he=M.get(v.fixedTargetId);if(!he)return null;ne=v.mouseX,J=v.mouseY,K=he.cx,P=he.cy-he.h/2}else{const he=M.get(v.fromNodeId);if(!he)return null;ne=he.cx,J=he.cy+he.h/2,K=v.mouseX,P=v.mouseY}const Q=P-J,ae=Math.abs(Q)>10?`M ${ne} ${J} C ${ne} ${J+Q*.4}, ${K} ${P-Q*.4}, ${K} ${P}`:`M ${ne} ${J} L ${K} ${P}`;return i.jsx("path",{d:ae,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},z=ne=>{const J=ne.cy+ne.h/2,K=(v==null?void 0:v.fromNodeId)===ne.id;return i.jsx("circle",{cx:ne.cx,cy:J,r:qS,fill:K?"#58a6ff":"#1c2128",stroke:K?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5,className:"cursor-crosshair",onMouseDown:P=>R(P,ne.id)})},re=ne=>{const J=ne.cy-ne.h/2,K=v&&j===ne.id&&U(ne.id);return i.jsx("circle",{cx:ne.cx,cy:J,r:qS,fill:K?"#3fb950":"#1c2128",stroke:K?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5})};return i.jsxs("svg",{ref:w,viewBox:`0 0 ${L} ${I}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:V,onMouseUp:ee,onClick:X,children:[i.jsxs("defs",{children:[i.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),i.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),D.map((ne,J)=>O(ne,J)),T.map(ne=>{const J=n===ne.id,K=ne.cx-ne.w/2,P=ne.cy-ne.h/2,Q=_===ne.id,ae=v&&j===ne.id&&U(ne.id);if(ne.type==="terminal"){const ce=ne.id==="$start",De=ce?"#58a6ff":"#3fb950",Re=ce,$e=!ce;return i.jsxs("g",{onClick:Ge=>{Ge.stopPropagation(),ce&&!u&&d("start")},className:ce&&!u?"cursor-pointer":void 0,children:[ae&&i.jsx("rect",{x:K-3,y:P-3,width:ne.w+6,height:ne.h+6,rx:ne.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ce&&r==="start"&&i.jsx("rect",{x:K-3,y:P-3,width:ne.w+6,height:ne.h+6,rx:ne.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),i.jsx("rect",{x:K,y:P,width:ne.w,height:ne.h,rx:ne.h/2,fill:De,fillOpacity:.08,stroke:De,strokeOpacity:.4,strokeWidth:1.5}),i.jsx("text",{x:ne.cx,y:ne.cy+4,textAnchor:"middle",fill:De,className:"text-[10px] font-medium",pointerEvents:"none",children:ne.label}),Re&&z(ne),$e&&re(ne)]},ne.id)}const he=ne.color??"#6b7280";return i.jsxs("g",{onClick:ce=>{ce.stopPropagation(),u||c(J?null:ne.id)},onMouseEnter:()=>S(ne.id),onMouseLeave:()=>S(null),className:u?void 0:"cursor-pointer",children:[ae&&i.jsx("rect",{x:K-3,y:P-3,width:ne.w+6,height:ne.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),J&&i.jsx("rect",{x:K-3,y:P-3,width:ne.w+6,height:ne.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),i.jsx("rect",{x:K,y:P,width:ne.w,height:ne.h,rx:10,fill:he,fillOpacity:.08,stroke:he,strokeOpacity:.6,strokeWidth:J?2:1.5}),i.jsx("text",{x:ne.cx,y:ne.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:ne.label}),!u&&z(ne),!u&&re(ne),Q&&!v&&!u&&i.jsxs("g",{onClick:ce=>{ce.stopPropagation(),h(ne.id)},className:"cursor-pointer",children:[i.jsx("circle",{cx:K+ne.w-2,cy:P+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),i.jsx("line",{x1:K+ne.w-5,y1:P-1,x2:K+ne.w+1,y2:P+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),i.jsx("line",{x1:K+ne.w+1,y1:P-1,x2:K+ne.w-5,y2:P+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},ne.id)}),v&&T.map(ne=>U(ne.id)?i.jsx("rect",{x:ne.cx-ne.w/2-8,y:ne.cy-ne.h/2-8,width:ne.w+16,height:ne.h+16,fill:"transparent",rx:12,onMouseEnter:()=>N(ne.id),onMouseLeave:()=>N(null),onMouseUp:J=>{J.stopPropagation(),ee()}},`drop-${ne.id}`):null),q(),B()]})}const Fu="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",Cl="block text-[11px] text-text-secondary mb-0.5";function B$({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:l,onNameChange:u,onDescriptionChange:c,onMaxIterationsChange:d,onColorChange:h}){return i.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[i.jsxs("div",{className:"min-w-[140px]",children:[i.jsx("label",{className:Cl,children:"Name"}),i.jsx("input",{value:e,onChange:p=>u(p.target.value),placeholder:"Workflow name",className:`${Fu} ${l?"opacity-50":""}`,readOnly:l})]}),i.jsxs("div",{className:"min-w-[100px]",children:[i.jsx("label",{className:Cl,children:"ID"}),i.jsx("input",{value:t,readOnly:!0,className:`${Fu} font-mono opacity-50`})]}),i.jsxs("div",{className:"flex-1 min-w-[140px]",children:[i.jsx("label",{className:Cl,children:"Description"}),i.jsx("input",{value:n,onChange:p=>!l&&c(p.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${Fu} ${l?"opacity-50":""}`})]}),i.jsxs("div",{className:"w-20",children:[i.jsx("label",{className:Cl,children:"Max Iter."}),i.jsx("input",{type:"number",value:r,onChange:p=>!l&&d(Number(p.target.value)),readOnly:l,className:`${Fu} font-mono ${l?"opacity-50":""}`})]}),i.jsxs("div",{children:[i.jsx("label",{className:Cl,children:"Color"}),i.jsx("input",{type:"color",value:a,onChange:p=>!l&&h(p.target.value),disabled:l,className:`w-8 h-8 rounded border border-border bg-transparent ${l?"opacity-50":"cursor-pointer"}`})]})]})}function $$({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:l}){return i.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),i.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&i.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),i.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:l})]})}function fp({title:e,items:t,renderActions:n}){return t.length===0?null:i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsx("div",{className:"space-y-2",children:t.map(r=>i.jsx($$,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const qa="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",mp="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",Ss="block text-[11px] text-text-secondary mb-0.5";function pp({variables:e,onInsert:t}){return e.length===0?null:i.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>i.jsx("button",{type:"button",onClick:()=>t(n.name),title:n.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${n.name}}}`},n.name))})}function z$({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:d,name:h}=ax(e,n);return i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:d+"20",color:d},children:h}),t&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[!t&&i.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),i.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Type"}),i.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,x=m==="sub_agent"?"verification":"build";if(m==="agent"){const y=n.find(w=>!w.subagent);l({...e,type:m,phase:x,agentId:(y==null?void 0:y.id)??"builder",name:(y==null?void 0:y.name)??"Agent"})}else if(m==="sub_agent"){const y=n.find(w=>w.subagent);l({...e,type:m,phase:x,subAgentType:(y==null?void 0:y.id)??"",name:(y==null?void 0:y.name)??"Sub-Agent"})}else l(m==="user"?{...e,type:m,phase:x,name:"User"}:{...e,type:m,phase:x,name:"Shell"})},className:mp,children:I$.map(p=>i.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Agent Type"}),i.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:mp,children:n.filter(p=>!p.subagent).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Sub-Agent Type"}),i.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:mp,children:[i.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Prompt"}),i.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${qa} resize-y text-xs`,placeholder:"Injected on first entry..."}),i.jsx(pp,{variables:a,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Nudge Prompt"}),i.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${qa} resize-y text-xs`,placeholder:"Injected on re-entry..."}),i.jsx(pp,{variables:a,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Command"}),i.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${qa} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),i.jsx(pp,{variables:a,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Timeout (ms)"}),i.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${qa} font-mono text-xs`})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Success Codes"}),i.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>l({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${qa} font-mono text-xs`})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ss,children:"Sub-group"}),i.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:qa})]}),i.jsx("div",{className:"pt-1 border-t border-border/50",children:i.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Ka="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",KS="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",Hi="block text-[11px] text-text-secondary mb-0.5";function H$({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:d,onUpdateSubGroup:h,onDelete:p,onMoveUp:m,onMoveDown:x}){var C;const y=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(_=>_.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(y==null?void 0:y.results)&&y.results.length>0;return i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",u+1]}),c>1&&i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx("button",{onClick:m,disabled:u===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:i.jsx(dn,{className:"w-3 h-3",rotate:180})}),i.jsx("button",{onClick:x,disabled:u===c-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:i.jsx(dn,{className:"w-3 h-3"})})]})]}),i.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[i.jsx("span",{className:"font-medium text-text-primary",children:e}),i.jsx(N1,{}),i.jsx("span",{className:"font-medium text-text-primary",children:t})]}),i.jsxs("div",{children:[i.jsx("label",{className:Hi,children:"Condition"}),i.jsx("select",{value:n.type,onChange:_=>{d(_.target.value==="step_result"?{type:"step_result",result:"success"}:{type:_.target.value})},className:KS,children:vj.map(_=>i.jsx("option",{value:_.value,children:_.label},_.value))})]}),n.type==="step_result"&&i.jsxs("div",{children:[i.jsx("label",{className:Hi,children:"Result"}),w?i.jsx("select",{value:n.result??y.results[0],onChange:_=>{d({type:"step_result",result:_.target.value})},className:KS,children:y.results.map(_=>i.jsx("option",{value:_,children:_},_))}):i.jsx("input",{type:"text",value:n.result??"success",onChange:_=>d({type:"step_result",result:_.target.value}),placeholder:"e.g. success, passed, failed",className:Ka})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:Hi,children:"Metadata Key"}),i.jsx("input",{type:"text",value:n.key??"",onChange:_=>d({...n,key:_.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Ka})]}),i.jsxs("div",{children:[i.jsx("label",{className:Hi,children:"Field"}),i.jsx("input",{type:"text",value:n.field??"",onChange:_=>d({...n,field:_.target.value}),placeholder:"e.g. status",className:Ka})]}),n.type==="metadata_all_match"?i.jsxs("div",{children:[i.jsx("label",{className:Hi,children:"Value"}),i.jsx("input",{type:"text",value:n.value??"",onChange:_=>d({...n,value:_.target.value}),placeholder:"e.g. passed, resolved",className:Ka})]}):i.jsxs("div",{children:[i.jsx("label",{className:Hi,children:"Values (comma-separated)"}),i.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:_=>d({...n,values:_.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Ka})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:Hi,children:"Sub-group"}),i.jsx("input",{type:"text",value:r??"",onChange:_=>h(_.target.value||void 0),placeholder:"e.g. build, verify",className:Ka})]}),i.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function U$(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function F$(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const kl="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",YS="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",Ya="block text-[11px] text-text-secondary mb-0.5",XS=[];function _j({isOpen:e,onClose:t,initialEditId:n}){var As,Ls;const r=vt(_e=>_e.defaults),a=vt(_e=>_e.userItems),l=vt(_e=>_e.projectItems),u=vt(_e=>_e.loading),c=vt(_e=>_e.templateVariables),d=vt(_e=>_e.fetchWorkflows),h=vt(_e=>_e.fetchWorkflow),p=vt(_e=>_e.fetchDefaultContent),m=vt(_e=>_e.fetchTemplateVariables),x=vt(_e=>_e.createWorkflow),y=vt(_e=>_e.updateWorkflow),w=vt(_e=>_e.deleteWorkflow),{requestDelete:C,clearConfirm:_,isConfirming:S}=Jl(),[v,b]=E.useState("list"),[j,N]=E.useState(null),[T,D]=E.useState(!1),[L,I]=E.useState(null),[M,G]=E.useState(null),[U,R]=E.useState(""),[H,W]=E.useState(""),[V,ee]=E.useState(""),[X,$]=E.useState("1.0.0"),[O,B]=E.useState("#3b82f6"),[q,z]=E.useState(""),[re,ne]=E.useState(50),[J,K]=E.useState(XS),[P,Q]=E.useState({type:"always"}),[ae,he]=E.useState([]),[ce,De]=E.useState("user"),[Re,$e]=E.useState(""),[Ge,je]=E.useState(!1),Ye=xt(_e=>_e.defaults),at=xt(_e=>_e.userItems),ke=xt(_e=>_e.projectItems),ze=E.useMemo(()=>[...Ye,...at,...ke],[Ye,at,ke]),lt=xt(_e=>_e.fetchAgents),[we]=E.useState(null);E.useEffect(()=>{e&&(d(),m(),lt(),I(null),G(null),n?r.some(Se=>Se.id===n)?p(n).then(Se=>{Se&&He({...Se,metadata:{...Se.metadata,name:Se.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):h(n).then(Se=>{Se&&He(Se,{editingId:n,isReadOnly:!1})}):(b("list"),N(null),D(!1)))},[e,d,h,p,m,n]);const He=(_e,Se)=>{R(_e.metadata.name),W(_e.metadata.id),ee(_e.metadata.description),$(_e.metadata.version),B(_e.metadata.color??"#3b82f6"),z(_e.entryStep),ne(_e.settings.maxIterations),K(_e.steps),Q(_e.startCondition??{type:"always"}),he(_e.metadata.parameters??[]),$e(""),(Se==null?void 0:Se.editingId)!==void 0&&N(Se.editingId),(Se==null?void 0:Se.isReadOnly)!==void 0&&D(Se.isReadOnly),(Se==null?void 0:Se.selectedNodeKey)!==void 0&&I(null),(Se==null?void 0:Se.selectedEdgeKey)!==void 0&&G(null),b("edit")},Ve=async _e=>{const Se=await h(_e);Se&&He(Se,{editingId:_e,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},Z=async()=>{var Qe;const _e=j??H;if(!_e||!U)return $e("Name is required."),!1;if(J.length===0)return $e("Add at least one step."),!1;const Se=ae.find(nt=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(nt.id));if(Se)return $e(`Invalid parameter ID "${Se.id}". Use letters, digits, and underscores only.`),!1;let Me=q;if(!Me||!J.some(nt=>nt.id===Me)){if(Me=((Qe=J.find(nt=>nt.id))==null?void 0:Qe.id)??"",!Me)return $e("All steps need an ID."),!1;z(Me)}je(!0),$e("");const We={metadata:{id:_e,name:U,description:V,version:X||"1.0.0",color:O,...ae.length>0?{parameters:ae}:{}},entryStep:Me,settings:{maxIterations:re},steps:J,startCondition:P},Fe=j?await y(j,We):await x(We,ce);return je(!1),Fe.success?(j||N(_e),!0):($e(Fe.error??"Failed to save."),!1)},oe=async()=>{await Z()},ie=async()=>{await Z()&&(n?t():b("list"))},me=()=>{n?t():b("list")},Ue=_e=>{R(_e),j||W(U$(_e))},Ie=async _e=>r.some(Me=>Me.id===_e)?await p(_e):await h(_e),Ke=async _e=>{const Se=await Ie(_e);Se&&He({...Se,metadata:{...Se.metadata,name:Se.metadata.name+" (copy)",id:`${_e}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},ct=()=>{N(null),R(""),W(""),ee(""),$("1.0.0"),B("#3b82f6"),z(""),ne(50),K(structuredClone(XS)),Q({type:"always"}),he([]),De("user"),$e(""),I(null),G(null),D(!1),b("edit")},et=async _e=>{await w(_e),_()},tt=E.useCallback(_e=>{I(_e),G(null)},[]),ot=E.useCallback(_e=>{G(_e),I(null)},[]),Ct=L!==null?Number(L):-1,dt=Ct>=0?J[Ct]??null:null,hn=E.useCallback(_e=>{K(Se=>Se.map((Me,We)=>We===Ct?_e:Me))},[Ct]),yn=P.type==="step_result"?`${P.result}`:P.type==="metadata_all_match"?`${P.key??"?"}=${P.value??"?"}`:P.type==="metadata_all_in"?`${P.key??"?"} in [${((As=P.values)==null?void 0:As.join(","))??"?"}]`:bj[P.type]??P.type,Fn=()=>{const _e=J.length,Se=F$(J),Me=ze.find(We=>!We.subagent);K([...J,{id:Se,name:(Me==null?void 0:Me.name)??"Agent",type:"agent",phase:"build",agentId:(Me==null?void 0:Me.id)??"builder",transitions:[]}]),q||z(Se),tt(String(_e))},Vn=E.useCallback((_e,Se)=>{_e==="$start"?(z(Se),ot("start")):K(Me=>{const We=Me.find(Qe=>Qe.id===_e),Fe=We?We.transitions.length:0;return ot(`${_e}:${Fe}`),Me.map(Qe=>Qe.id===_e?{...Qe,transitions:[...Qe.transitions,{when:{type:"always"},goto:Se}]}:Qe)})},[ot]),se=_e=>{if(_e==="start")return null;const Se=_e.lastIndexOf(":"),Me=_e.slice(0,Se),We=parseInt(_e.slice(Se+1));return{stepId:Me,transIdx:We}},ve=E.useCallback((_e,Se)=>{const Me=se(_e);Me&&K(We=>We.map(Fe=>Fe.id===Me.stepId?{...Fe,transitions:Fe.transitions.map((Qe,nt)=>nt===Me.transIdx?Se(Qe):Qe)}:Fe))},[]),Ne=E.useCallback((_e,Se)=>{if(_e==="start"){z(Se);return}ve(_e,Me=>({...Me,goto:Se}))},[ve]),Oe=E.useCallback((_e,Se)=>{const Me=se(_e);Me&&(K(We=>{const Fe=We.find(nt=>nt.id===Me.stepId);if(!Fe)return We;const Qe=Fe.transitions[Me.transIdx];return Qe?We.map(nt=>nt.id===Me.stepId?{...nt,transitions:nt.transitions.filter((Kt,fn)=>fn!==Me.transIdx)}:nt.id===Se?{...nt,transitions:[...nt.transitions,Qe]}:nt):We}),G(null))},[]),Je=E.useCallback(_e=>{if(_e==="start"){z(""),G(null);return}const Se=se(_e);Se&&(K(Me=>Me.map(We=>We.id===Se.stepId?{...We,transitions:We.transitions.filter((Fe,Qe)=>Qe!==Se.transIdx)}:We)),G(null))},[]),Dt=E.useCallback((_e,Se)=>{if(_e==="start"){Q(Se);return}ve(_e,Me=>({...Me,when:Se}))},[ve]),wn=E.useCallback((_e,Se)=>{_e!=="start"&&ve(_e,Me=>({...Me,subGroup:Se||void 0}))},[ve]),An=_e=>ax(_e,ze).name,yi=()=>{if(!M)return null;if(M==="start"){const Kt=J.find(fn=>fn.id===q);return{type:"start",fromLabel:"Start",toLabel:Kt?An(Kt):"(none)",condition:P}}const _e=M.lastIndexOf(":"),Se=M.slice(0,_e),Me=parseInt(M.slice(_e+1)),We=J.find(Kt=>Kt.id===Se);if(!We)return null;const Fe=We.transitions[Me];if(!Fe)return null;const Qe=J.find(Kt=>Kt.id===Fe.goto),nt=Fe.goto==="$done"?"Done":Qe?An(Qe):Fe.goto;return{type:"step",fromLabel:An(We),toLabel:nt,condition:Fe.when,subGroup:Fe.subGroup}};if(v==="edit"){const _e=yi();return i.jsxs(jt,{isOpen:e,onClose:me,title:T?U:j?"Edit Workflow":"New Workflow",size:"full",children:[Re&&i.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:Re}),i.jsx(B$,{formName:U,formId:H,formDescription:V,formMaxIterations:re,formColor:O,isReadOnly:T,onNameChange:Ue,onDescriptionChange:ee,onMaxIterationsChange:ne,onColorChange:B}),!T&&i.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:i.jsxs(O$,{title:`Parameters (${ae.length})`,children:[ae.map((Se,Me)=>i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{value:Se.id,onChange:We=>{const Fe=[...ae];Fe[Me]={...Se,id:We.target.value},he(Fe)},placeholder:"ID",className:"w-28 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),i.jsx("input",{value:Se.label,onChange:We=>{const Fe=[...ae];Fe[Me]={...Se,label:We.target.value},he(Fe)},placeholder:"Label",className:"w-36 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),i.jsx("input",{value:Se.description??"",onChange:We=>{const Fe=[...ae];Fe[Me]={...Se,description:We.target.value||void 0},he(Fe)},placeholder:"Description",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),i.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[i.jsx("input",{type:"checkbox",checked:Se.required??!1,onChange:We=>{const Fe=[...ae];Fe[Me]={...Se,required:We.target.checked||void 0},he(Fe)},className:"rounded border-border"}),"Req."]}),i.jsxs("div",{className:"flex gap-0.5",children:[i.jsx("button",{onClick:()=>{Me!==0&&he(ae.map((We,Fe)=>Fe===Me?{...ae[Me-1],position:Fe}:Fe===Me-1?{...ae[Me],position:Fe}:{...We,position:Fe}))},disabled:Me===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${Se.label||Se.id} up`,children:"▲"}),i.jsx("button",{onClick:()=>{Me!==ae.length-1&&he(ae.map((We,Fe)=>Fe===Me?{...ae[Me+1],position:Fe}:Fe===Me+1?{...ae[Me],position:Fe}:{...We,position:Fe}))},disabled:Me===ae.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${Se.label||Se.id} down`,children:"▼"})]}),i.jsx("button",{onClick:()=>he(ae.filter((We,Fe)=>Fe!==Me)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},Se.id)),i.jsx("button",{onClick:()=>{const Se=`param_${ae.length+1}`;he([...ae,{id:Se,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!j&&!T&&i.jsx(Ld,{value:ce,onChange:De}),i.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[i.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[i.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!T&&i.jsx("button",{onClick:Fn,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),i.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[i.jsx(P$,{steps:J,entryStep:q,selectedNodeId:(dt==null?void 0:dt.id)??null,selectedEdgeKey:M,startConditionLabel:yn,agentTypes:ze,isReadOnly:T,onSelectNode:Se=>{if(Se===null){tt(null);return}const Me=J.findIndex(We=>We.id===Se);tt(Me>=0?String(Me):null)},onSelectEdge:ot,onRemoveStep:Se=>{var We;const Me=J.findIndex(Fe=>Fe.id===Se);if(K(Fe=>Fe.filter(Qe=>Qe.id!==Se)),Ct===Me&&tt(null),q===Se){const Fe=J.filter(Qe=>Qe.id!==Se);z(((We=Fe[0])==null?void 0:We.id)??"")}},onCreateTransition:Vn,onReconnectTo:Ne,onReconnectFrom:Oe,onDeleteTransition:Je}),J.length===0&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[i.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),i.jsx("button",{onClick:Fn,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),i.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[i.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:i.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),i.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:T&&(_e||dt)?i.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):_e?_e.type==="start"?i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),q&&i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[i.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),i.jsx(N1,{}),i.jsx("span",{className:"text-text-primary font-medium",children:_e.toLabel})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ya,children:"Activation Condition"}),i.jsx("select",{value:P.type,onChange:Se=>Q(Se.target.value==="step_result"?{type:"step_result",result:"success"}:Se.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Se.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Se.target.value}),className:YS,children:vj.map(Se=>i.jsx("option",{value:Se.value,children:Se.label},Se.value))})]}),P.type==="step_result"&&i.jsxs("div",{children:[i.jsx("label",{className:Ya,children:"Result"}),q&&(()=>{const Se=J.find(Qe=>Qe.id===q),Me=Se&&(Se.type==="sub_agent"||Se.type==="agent")?ze.find(Qe=>Qe.id===(Se.type==="sub_agent"?Se.subAgentType:Se.agentId)):void 0,We=(Me==null?void 0:Me.results)&&Me.results.length>0,Fe=(Me==null?void 0:Me.results)??[];return We?i.jsx("select",{value:P.result??Fe[0],onChange:Qe=>Q({type:"step_result",result:Qe.target.value}),className:YS,children:Fe.map(Qe=>i.jsx("option",{value:Qe,children:Qe},Qe))}):i.jsx("input",{type:"text",value:P.result??"success",onChange:Qe=>Q({type:"step_result",result:Qe.target.value}),placeholder:"e.g. success, passed, failed",className:kl})})()]}),(P.type==="metadata_all_match"||P.type==="metadata_all_in")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:Ya,children:"Metadata Key"}),i.jsx("input",{type:"text",value:P.key??"",onChange:Se=>Q({...P,key:Se.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:kl})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ya,children:"Field"}),i.jsx("input",{type:"text",value:P.field??"",onChange:Se=>Q({...P,field:Se.target.value}),placeholder:"e.g. status",className:kl})]}),P.type==="metadata_all_match"?i.jsxs("div",{children:[i.jsx("label",{className:Ya,children:"Value"}),i.jsx("input",{type:"text",value:P.value??"",onChange:Se=>Q({...P,value:Se.target.value}),placeholder:"e.g. passed, resolved",className:kl})]}):i.jsxs("div",{children:[i.jsx("label",{className:Ya,children:"Values (comma-separated)"}),i.jsx("input",{type:"text",value:((Ls=P.values)==null?void 0:Ls.join(", "))??"",onChange:Se=>Q({...P,values:Se.target.value.split(",").map(Me=>Me.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:kl})]})]}),i.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):(()=>{const Se=se(M),Me=Se==null?void 0:Se.stepId,We=(Se==null?void 0:Se.transIdx)??0,Fe=Me?J.find(nt=>nt.id===Me):void 0,Qe=(Fe==null?void 0:Fe.transitions.length)??0;return i.jsx(H$,{fromLabel:_e.fromLabel,toLabel:_e.toLabel,condition:_e.condition,subGroup:"subGroup"in _e?_e.subGroup:void 0,fromStep:_e.type==="step"?J.find(nt=>nt.id===_e.fromLabel):void 0,agentTypes:ze,transitionIndex:We,totalTransitions:Qe,onUpdateCondition:nt=>Dt(M,nt),onUpdateSubGroup:nt=>wn(M,nt),onDelete:()=>Je(M),onMoveUp:()=>{K(nt=>{const Kt=nt.find(tr=>tr.id===Me);if(!Kt||We===0)return nt;const fn=[...Kt.transitions];return[fn[We-1],fn[We]]=[fn[We],fn[We-1]],nt.map(tr=>tr.id===Me?{...tr,transitions:fn}:tr)}),G(`${Me}:${We-1}`)},onMoveDown:()=>{K(nt=>{const Kt=nt.find(tr=>tr.id===Me);if(!Kt||We===Kt.transitions.length-1)return nt;const fn=[...Kt.transitions];return[fn[We],fn[We+1]]=[fn[We+1],fn[We]],nt.map(tr=>tr.id===Me?{...tr,transitions:fn}:tr)}),G(`${Me}:${We+1}`)}})})():dt?i.jsx(z$,{step:dt,isEntry:dt.id===q,agentTypes:ze,transitionCount:dt.transitions.length,templateVariables:c,onUpdate:hn,onRemove:()=>{var Se;if(dt&&(K(J.filter((Me,We)=>We!==Ct)),tt(null),q===dt.id)){const Me=J.filter((We,Fe)=>Fe!==Ct);z(((Se=Me[0])==null?void 0:Se.id)??"")}},onSetEntry:()=>z(dt.id)}):i.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",i.jsx("br",{}),"Drag from a port to connect."]})})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[i.jsx(st,{variant:"secondary",onClick:me,children:"Close"}),T?i.jsx(st,{variant:"primary",onClick:()=>{R(U+" (copy)"),W(`${j}-copy-${Date.now()}`),N(null),D(!1)},children:"Duplicate & Customize"}):i.jsxs(i.Fragment,{children:[i.jsx(st,{variant:"primary",onClick:oe,children:"Save"}),i.jsx(st,{variant:"primary",onClick:ie,children:"Save & Close"})]})]})]})}return i.jsx(jt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:i.jsx(z1,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:ct,loading:u,hasItems:r.length>0||a.length>0||l.length>0,children:i.jsxs("div",{className:"space-y-4",children:[i.jsx(fp,{title:"Built-in",items:r,renderActions:_e=>i.jsx(i.Fragment,{children:i.jsx(ui,{onClick:()=>Ke(_e.id),children:i.jsx(lg,{})})})}),i.jsx(fp,{title:"Custom",items:a,renderActions:_e=>i.jsxs(i.Fragment,{children:[i.jsx(ui,{onClick:()=>Ve(_e.id),children:i.jsx("span",{className:"text-[10px]",children:"Edit"})}),i.jsx(Bl,{onClick:()=>Ke(_e.id)}),S(_e.id,"delete")?i.jsx(ed,{onConfirm:()=>et(_e.id),onCancel:_}):i.jsx(td,{onClick:()=>C(_e.id)})]})}),l.length>0&&i.jsx(fp,{title:"Project",items:l,renderActions:_e=>i.jsxs(i.Fragment,{children:[i.jsx(ui,{onClick:()=>Ve(_e.id),children:i.jsx("span",{className:"text-[10px]",children:"Edit"})}),i.jsx(Bl,{onClick:()=>Ke(_e.id)}),S(_e.id,"delete")?i.jsx(ed,{onConfirm:()=>et(_e.id),onCancel:_}):i.jsx(td,{onClick:()=>C(_e.id)})]})})]})})})}function V$(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function W$({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:d,isAutoScrollActive:h}){const[,p]=Tn(),m=Xt(z=>z.fetchCommands),x=vt(z=>z.fetchWorkflows),y=xt(z=>z.fetchAgents),w=Xt(z=>z.defaults),C=Xt(z=>z.userItems),_=Xt(z=>z.projectItems),S=vt(z=>z.defaults),v=vt(z=>z.userItems),b=vt(z=>z.projectItems),j=xt(z=>z.defaults),N=xt(z=>z.userItems),T=xt(z=>z.projectItems),D=Le(z=>{var re;return(re=z.currentSession)==null?void 0:re.mode}),L=Le(z=>{var re;return((re=z.currentSession)==null?void 0:re.dangerLevel)??"normal"}),I=Le(z=>z.switchMode),M=Le(z=>z.switchDangerLevel),G=Le(z=>{var re;return(re=z.currentSession)==null?void 0:re.projectId}),U=E.useRef(void 0),[R,H]=E.useState(""),[W,V]=E.useState(0),ee=E.useRef(null),X=E.useRef(!1);E.useEffect(()=>{e&&(X.current=!0)},[e]),E.useEffect(()=>{if(e){m(),x(),y(),H(""),V(0);const z=setTimeout(()=>{var re;return(re=ee.current)==null?void 0:re.focus()},50);return()=>clearTimeout(z)}},[e,m,x,y]),E.useEffect(()=>{var z;!e&&X.current&&(n==null||n(),(z=U.current)==null||z.call(U),U.current=void 0)},[e,n]);const O=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const z=G??V$(window.location.pathname);z&&p(`/p/${z}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{U.current=l,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),c==null||c()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!h)}},...Yr(Yr(j,N),T).filter(z=>!z.subagent&&z.id!==D).map(z=>({id:z.id,name:z.name,prefix:"Agent > Switch to",action:()=>I(z.id)})),...Yr(Yr(w,C),_).map(z=>({id:z.id,name:z.name,prefix:"Command > Launch",action:()=>r(z.id,u)})),...Yr(Yr(S,v),b).map(z=>({id:z.id,name:z.name,prefix:"Workflow > Run",action:()=>a(z.id)})),...["normal","dangerous"].filter(z=>z!==L).map(z=>({id:z,name:z.charAt(0).toUpperCase()+z.slice(1),prefix:"Mode > Switch to",action:()=>M(z)}))].filter(z=>ci(`${z.prefix} ${z.name}`,R)),B=O.length-1,q=z=>{Uk(z,B,V,()=>{var re;(re=O[W])==null||re.action(),t()},t)};return e?pi.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),i.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[i.jsx("input",{ref:ee,type:"text",value:R,onChange:z=>{H(z.target.value),V(0)},onKeyDown:q,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),i.jsx(hg,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),i.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:O.length===0?i.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+v.length>0?"No matches":"No agents, commands, or workflows yet"}):O.map((z,re)=>i.jsxs("button",{type:"button",onClick:()=>{z.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${re===W?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[i.jsxs("span",{className:"text-text-muted font-normal",children:[z.prefix," "]}),i.jsx("span",{children:z.name})]},z.id))})]})]}),document.body):null}const Sj="openfox-message-search-filters",G$=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function q$(){try{const e=localStorage.getItem(Sj);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function K$(e){localStorage.setItem(Sj,JSON.stringify([...e]))}function Y$(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 X$(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0"),c=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${a}/${l}/${u} ${c}:${d}`}function Q$(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 J$(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const a=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!a?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function Z$(e){var n,r;if(e.type!=="message")return i.jsx(O_,{className:"w-3.5 h-3.5"});const t=e.message;return t.role==="assistant"?(n=t.thinkingContent)!=null&&n.trim()&&!((r=t.content)!=null&&r.trim())?i.jsx(_T,{className:"w-3.5 h-3.5"}):i.jsx(O_,{className:"w-3.5 h-3.5"}):i.jsx(vT,{className:"w-3.5 h-3.5"})}function QS(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",a=r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(n.messageKind==="workflow-started")try{return`Workflow: ${JSON.parse(r).workflowName}`}catch{return"Workflow started"}if(n.messageKind==="task-completed")return"Task completed";if(n.messageKind==="auto-prompt")return"Auto-prompt";if(n.messageKind==="correction")return"Correction";if(n.messageKind==="context-reset")return"Context reset";if(n.messageKind==="command")return"Command executed";if(n.role==="assistant")return a?a.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const l=a.slice(0,200);return l.length<a.length?`${l}...`:l}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function e7({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,l]=E.useState(""),[u,c]=E.useState(0),[d,h]=E.useState(q$),p=E.useRef(null),m=E.useRef(null),x=E.useRef(null),y=N=>{h(T=>{const D=new Set(T);return D.has(N)?D.delete(N):D.add(N),K$(D),D})},w=E.useMemo(()=>n.filter(N=>{var T,D;return!(N.type==="context-divider"||N.type==="message"&&(N.message.messageKind==="auto-prompt"||N.message.role==="assistant"&&!((T=N.message.content)!=null&&T.trim())&&!((D=N.message.thinkingContent)!=null&&D.trim())))}),[n]),C=E.useMemo(()=>w.filter(N=>{const T=Y$(N);return!(T&&!d.has(T))}),[w,d]),_=E.useMemo(()=>a?w.filter(N=>{const T=QS(N);return ci(T,a)}):C,[C,a]),S=_.length-1;E.useEffect(()=>{if(e){l(""),c(0);const N=setTimeout(()=>{var T;return(T=p.current)==null?void 0:T.focus()},50);return()=>clearTimeout(N)}},[e]),E.useEffect(()=>{e&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[e]),E.useEffect(()=>{x.current&&x.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[u]);const v=N=>{Uk(N,S,c,()=>{const T=_[u];if(T){const D=n.indexOf(T);D>=0&&r(D),t()}},t)},b=N=>{const T=n.indexOf(N);T>=0&&r(T),t()},j=N=>n.indexOf(N);return e?pi.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),i.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[i.jsx(Qi,{}),i.jsx("input",{ref:p,type:"text",value:a,onChange:N=>{l(N.target.value),c(0)},onKeyDown:v,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),i.jsx("button",{type:"button",onClick:t,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Close",children:i.jsx(Ns,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:G$.map(N=>{const T=d.has(N.key);return i.jsx("button",{type:"button",onClick:()=>y(N.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:N.label},N.key)})}),i.jsx("div",{ref:m,className:"overflow-y-auto max-h-[60vh] p-2",children:_.length===0?i.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:C.length>0?"No matches":"No messages yet"}):_.map((N,T)=>{const D=j(N),L=Z$(N),I=QS(N),M=J$(N),G=Q$(N),U=N.type==="message"&&N.message.role==="user";return i.jsx("button",{ref:T===u?x:null,type:"button",onClick:()=>b(N),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${T===u?"bg-accent-primary/20 text-text-primary":U?"bg-accent-primary/5 text-text-secondary hover:bg-accent-primary/10 hover:text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[i.jsx("span",{className:"flex-shrink-0",children:L}),i.jsx("span",{className:`truncate flex-1 ${M}`,children:I})]}),G&&i.jsx("span",{className:"text-text-muted text-xs shrink-0",children:X$(G)})]})},`${D}-${N.type}`)})})]})]}),document.body):null}function wj(e){const t=new Set,n=[],r=/\{\{(\w+)\}\}/g;let a;for(;(a=r.exec(e))!==null;){const l=a[1];t.has(l)||(t.add(l),n.push(l))}return n}function t7(e,t,n){const r=e.trim();if(!r.startsWith("/"))return null;const a=r.slice(1).split(/\s+/),l=a[0];if(!l)return null;const u=a.slice(1),c={},d=t.find(h=>h.id===l);return d?(d.parameters&&d.parameters.length>0?[...d.parameters].sort((p,m)=>(p.position??0)-(m.position??0)).forEach((p,m)=>{u[m]!==void 0&&(c[p.id]=u[m])}):u.forEach((h,p)=>{c[String(p)]=h}),{workflowId:l,params:c}):n&&n.find(p=>p.id===l)?(u.forEach((p,m)=>{c[String(m)]=p}),{commandId:l,params:c}):null}function n7({attachment:e,onRemove:t}){const n=pj(e.filename);return i.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[i.jsx(ac,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),mj(e.mimeType)?i.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):i.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-md bg-bg-secondary text-xs font-bold text-text-muted",children:n}),i.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),i.jsx("div",{className:"text-[10px] text-text-muted",children:eo(e.size)})]})}function r7({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const l=E.useRef(null),u=E.useRef(null);E.useEffect(()=>{u.current&&l.current&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const c=h=>{switch(h.key){case"Enter":h.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":h.preventDefault(),r();break;case"ArrowUp":h.preventDefault(),a("up");break;case"ArrowDown":h.preventDefault(),a("down");break}},d=h=>{n(h)};return i.jsx("div",{ref:l,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg overflow-y-auto max-h-64",onKeyDown:c,children:e.map((h,p)=>i.jsxs("div",{ref:p===t?u:null,role:"listitem",onClick:()=>d(h.content),className:`
|
|
316
|
+
p-2 rounded cursor-pointer transition-colors
|
|
317
|
+
${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
|
|
318
|
+
`,children:[i.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&i.jsxs(i.Fragment,{children:[" | ",i.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),i.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function s7(){const e=QN(),t=e?"bg-amber-400":"bg-accent-primary";return i.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("span",{className:"flex gap-0.5",children:[i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),i.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&i.jsx("span",{className:"text-text-muted hidden sm:inline",children:"esc to interrupt"})]})}function i7(){const e=Le(u=>u.activeWorkflowExecution),t=Le(u=>u.exitWorkflow),[n,r]=E.useState(!1);E.useEffect(()=>{r(!1)},[e==null?void 0:e.id]);const a=E.useCallback(()=>{n||(r(!0),t())},[n,t]);if(!e||e.status!=="running"&&e.status!=="waiting")return null;const l=e.workflowColor&&/^#[0-9a-fA-F]{6}$/.test(e.workflowColor)?e.workflowColor:"#3b82f6";return i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border",children:[i.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l}}),i.jsx("span",{className:"font-medium text-text-primary truncate",children:e.workflowName}),e.currentStepName&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{className:"text-text-muted truncate",children:e.currentStepName})]}),i.jsx("div",{className:"ml-auto shrink-0",children:i.jsx("button",{onClick:a,disabled:n,className:"text-xs px-2 py-0.5 rounded text-text-tool-error hover:bg-text-tool-error/10 transition-colors disabled:opacity-50",children:n?"Exiting...":"✕ Exit"})})]})}const a7={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function o7(e,t={}){const n={...a7,...t};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=n.maxSizeBytes){const a=await e.arrayBuffer(),l=m7(a),u=`data:${e.type};base64,${l}`,c=await Cj(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await l7(e,n)}async function l7(e,t){const n=await u7(e),r=await Cj(n),{width:a,height:l}=c7(r.width,r.height,t.maxWidth,t.maxHeight),u=d7();u.width=a,u.height=l;const c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(r,0,0,a,l);let d=t.quality,h="";for(let m=0;m<10&&(h=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(JS(h)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=JS(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:l}}function c7(e,t,n,r){const a=e/t;return e>t&&e>n?{width:n,height:Math.round(n/a)}:t>e&&t>r?{width:Math.round(r*a),height:r}:{width:e,height:t}}function u7(e){return new Promise((t,n)=>{const r=f7(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function Cj(e){return new Promise((t,n)=>{const r=h7(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function d7(){var t;const e=ox();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function h7(){const e=ox();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function f7(){const e=ox();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function ox(){return globalThis}function m7(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const a=t[r];a!==void 0&&(n+=String.fromCharCode(a))}return btoa(n)}function JS(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const ZS=50*1024*1024,e1=1024*1024,p7=["image/png","image/jpeg","image/gif"];function g7(e){return e==="application/pdf"}function x7(e){return p7.includes(e.type)}async function y7(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(e)})}async function t1(e,t,n){try{if(ix(e.type)){if(e.size>e1){n(`Text file too large (${eo(e.size)}). Maximum is ${eo(e1)}.`);return}const r=await e.text(),a={id:Wu(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(Ju(e.type)||g7(e.type)){if(e.size>ZS){const r=Ju(e.type)?"Image":"PDF";n(`${r} file too large (${eo(e.size)}). Maximum is ${eo(ZS)}.`);return}if(Ju(e.type)&&x7(e)){const r=await o7(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:Wu(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await y7(e),a={id:Wu(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}}else n(`Unsupported file type: ${e.type}. Supported types: images (PNG, JPG, GIF, WebP, BMP, SVG), PDF, text files, JSON, XML, YAML, and other common text-based formats.`)}catch(r){const a=r instanceof Error?r.message??"Failed to process file":"Failed to process file";n(a)}}function kj(e){const t=Le(l=>l.sendMessage),n=Le(l=>l.launchWorkflow),r=E.useCallback((l,u,c)=>{e(!0),t(l,u,c)},[e,t]),a=E.useCallback((l,u,c,d,h)=>{e(!0),n(l,u,c,d,h)},[e,n]);return{sendMessage:r,launchWorkflow:a}}function b7({children:e}){return pi.createPortal(e,document.body)}function v7(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 _7({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:l,textareaContent:u,attachments:c}){const[d,h]=E.useState(!1),[p,m]=E.useState("commands"),[x,y]=E.useState(""),[w,C]=E.useState(0),[_,S]=E.useState(null),[v,b]=E.useState(null),j=E.useRef(null),N=E.useRef(null),T=Xt(re=>re.defaults),D=Xt(re=>re.userItems),L=Xt(re=>re.projectItems),I=Xt(re=>re.fetchCommands),M=vt(re=>re.defaults),G=vt(re=>re.userItems),U=vt(re=>re.projectItems),R=vt(re=>re.fetchWorkflows),H=Yr(Yr(T,D),L),W=Yr(Yr(M,G),U);E.useEffect(()=>{d&&(p==="commands"?I():p==="workflows"&&R())},[d,p,I,R]),E.useEffect(()=>{d&&(y(""),C(0),requestAnimationFrame(()=>{var re;return(re=j.current)==null?void 0:re.focus()}))},[d,p]),E.useEffect(()=>{if(!d)return;const re=ne=>{var J;(J=N.current)!=null&&J.contains(ne.target)||h(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[d]);const V=re=>{switch(re.key){case"ArrowDown":re.preventDefault(),C(ne=>{const K=(p==="commands"?H:W).filter(P=>{const Q=x.toLowerCase();return!Q||P.name.toLowerCase().includes(Q)});return Math.min(ne+1,K.length-1)});break;case"ArrowUp":re.preventDefault(),C(ne=>Math.max(ne-1,0));break;case"Enter":re.preventDefault();break;case"Escape":re.preventDefault(),h(!1);break}},ee=re=>{y(re),C(0)},X=H.filter(re=>!x||re.name.toLowerCase().includes(x.toLowerCase())),$=W.filter(re=>!x||re.name.toLowerCase().includes(x.toLowerCase())),O=async re=>{const ne=await Xt.getState().fetchCommand(re);ne&&e(ne.prompt,ne.metadata.agentMode,u,c),h(!1)},B=re=>{t(re),h(!1)},q=(re,ne)=>{ne.stopPropagation(),h(!1),S(re)},z=(re,ne)=>{ne.stopPropagation(),h(!1),b(re)};return i.jsxs("div",{ref:N,className:"relative",children:[i.jsx("button",{type:"button",onClick:()=>h(!d),className:"px-1.5 py-2 rounded-r bg-bg-secondary text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors border-l border-border/50",title:"More options",children:i.jsx(D1,{className:"w-4 h-4"})}),d&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 max-w-[calc(100vw-2rem)] bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[i.jsxs("div",{className:"flex border-b border-border",children:[i.jsx("button",{type:"button",onClick:()=>{m("commands"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),i.jsx("button",{type:"button",onClick:()=>{m("workflows"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),i.jsx("button",{type:"button",onClick:()=>m("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&i.jsx("div",{className:"p-2 border-b border-border",children:i.jsx("input",{ref:j,value:x,onChange:re=>ee(re.target.value),onKeyDown:V,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),i.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:p==="commands"?X.length===0?i.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:H.length===0?"No commands yet":"No matches"}):X.map((re,ne)=>i.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${ne===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[i.jsx("button",{type:"button",onClick:()=>O(re.id),className:"flex-1 text-left",children:i.jsx("div",{className:"text-sm text-text-primary font-medium",children:re.name})}),i.jsx(ui,{className:"opacity-0 group-hover:opacity-100",onClick:J=>q(re.id,J)})]},re.id)):p==="workflows"?$.length===0?i.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:W.length===0?"No workflows yet":"No matches"}):$.map((re,ne)=>{const J=v7(re),K=re.color??"#3b82f6";return i.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${ne===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[i.jsxs("button",{type:"button",onClick:()=>B(re.id),className:"flex-1 text-left flex items-center gap-2",children:[i.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:K}}),i.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:re.name}),J!==null&&i.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:J?"#22c55e":"#6b7280"},title:J?"Entry condition met":"Entry condition not met"})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[re.subGroups&&re.subGroups.length>0&&i.jsx(S7,{subGroups:re.subGroups,onSelect:P=>{h(!1),n(re.id,P)}}),i.jsx(ui,{className:"opacity-0 group-hover:opacity-100",onClick:P=>z(re.id,P)})]})]},re.id)}):i.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[i.jsxs("button",{type:"button",onClick:()=>{l(),h(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[i.jsx(oT,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),i.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&i.jsx("div",{className:"border-t border-border p-1",children:i.jsx("button",{type:"button",onClick:()=>{h(!1),p==="commands"?r():a()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),i.jsx(yj,{isOpen:!!_,onClose:()=>S(null),initialEditId:_}),i.jsx(_j,{isOpen:!!v,onClose:()=>b(null),initialEditId:v})]})}function S7({subGroups:e,onSelect:t}){const[n,r]=E.useState(!1),[a,l]=E.useState({top:0,right:0}),u=E.useRef(null),c=E.useRef(null);th(c,()=>r(!1),n);const d=h=>{if(h.stopPropagation(),!n&&u.current){const p=u.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:u,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&i.jsx(b7,{children:i.jsx("div",{ref:c,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(h=>i.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(h)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:h},h))})})]})}function w7({messages:e,onCancel:t}){return e.length===0?null:i.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>i.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${n.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[i.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),i.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),i.jsx(ac,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function C7({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,onView:a,onEdit:l,onDuplicate:u,onDelete:c,onCancelDelete:d}){const h=e.allowedTools.filter(p=>!(r!=null&&r.has(p)));return i.jsxs(Y1,{isBuiltIn:t,isConfirmingDelete:n,onView:a,onEdit:l,onDuplicate:u,onDelete:c,onCancelDelete:d,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),i.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),e.description&&i.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[h.slice(0,5).map(p=>i.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:p},p)),h.length>5&&i.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",h.length-5," more"]})]})]})}function n1({title:e,agents:t,subagents:n,isBuiltIn:r,alwaysAllowedNames:a,onView:l,onDuplicate:u,onEdit:c,onDelete:d,onCancelDelete:h,isConfirmingDelete:p}){if(t.length===0&&n.length===0)return null;const m=x=>i.jsx(C7,{agent:x,isBuiltIn:r,isConfirmingDelete:(p==null?void 0:p(x.id))??!1,alwaysAllowedNames:a,onView:()=>l(x.id),onEdit:r?void 0:()=>c==null?void 0:c(x.id),onDuplicate:()=>u(x.id),onDelete:r?void 0:()=>d==null?void 0:d(x.id),onCancelDelete:r?void 0:()=>h==null?void 0:h(x.id)},x.id);return i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsxs("div",{className:"space-y-2",children:[t.map(m),n.length>0&&i.jsxs("div",{className:"mt-3",children:[i.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:"Sub-agents"}),i.jsx("div",{className:"space-y-2",children:n.map(m)})]})]})]})}function k7(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const a=n.slice(0,r),u=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(u))}}return t}function gp(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function j7({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:l,formPrompt:u,formError:c,saving:d,isReadOnly:h,availableTools:p,onNameChange:m,onIdChange:x,onDescriptionChange:y,onSubagentChange:w,onToolsChange:C,onColorChange:_,onPromptChange:S,onSave:v,onCancel:b,onDuplicate:j}){const N=k7(a),T=p.filter(I=>!(r&&I.topLevelOnly)),D=(I,M)=>{const G=new Map(N),U=G.get(I)||new Set,R=new Set(U);R.has(M)?R.delete(M):R.add(M),R.size===0?G.set(I,new Set):G.set(I,R),C(gp(G))},L=I=>{const M=new Map(N);M.has(I)?M.delete(I):M.set(I,new Set),C(gp(M))};return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"space-y-3",children:[c&&i.jsx(to,{message:c}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(jr,{label:"Name",value:e,onChange:m,placeholder:"My Agent",readOnly:h}),i.jsx(jr,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(jr,{label:"Description",value:n,onChange:y,placeholder:"What this agent does",readOnly:h}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),i.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[i.jsx("button",{onClick:()=>!h&&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"} ${h?"pointer-events-none opacity-60":""}`,children:"Agent"}),i.jsx("button",{onClick:()=>!h&&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"} ${h?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),i.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),i.jsx("input",{type:"color",value:l,onChange:I=>!h&&_(I.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),i.jsx("div",{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32 overflow-y-auto",children:T.map(I=>{const M=N.has(I.name),G=I.actions.length>0,U=N.get(I.name)||new Set;return G?h?i.jsxs("button",{className:"px-1.5 py-0.5 rounded text-xs font-mono flex items-center gap-1 bg-bg-primary text-text-muted pointer-events-none opacity-60",children:[i.jsx("span",{children:I.name}),i.jsx("span",{className:"text-[10px]",children:"*"})]},I.name):i.jsx(ic,{trigger:i.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${M?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[i.jsx("span",{children:I.name}),G&&i.jsx("span",{className:`text-[10px] ${M&&U.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...I.actions.map(R=>({label:i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${I.name}-${R}`,children:[i.jsx("input",{type:"checkbox",id:`${I.name}-${R}`,checked:U.has(R),onChange:()=>D(I.name,R),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),i.jsx("span",{children:R})]}),closeOnClick:!1})),{label:M?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(M)L(I.name);else{const R=new Map(N);R.set(I.name,new Set(I.actions)),C(gp(R))}}}]},I.name):i.jsx("button",{onClick:()=>!h&&L(I.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${M?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:i.jsx("span",{children:I.name})},I.name)})})]})]}),i.jsxs("div",{className:"flex-1 min-h-[150px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),i.jsx("textarea",{value:u,onChange:I=>!h&&S(I.target.value),readOnly:h,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"opacity-60":""}`})]}),i.jsx(DT,{onCancel:b,onSave:v,saving:d,saveDisabled:!e||!u||h}),h&&i.jsx("div",{className:"flex justify-end mt-2",children:i.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 E7(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function N7({isOpen:e,onClose:t,initialEditId:n}){const r=xt(oe=>oe.defaults),a=xt(oe=>oe.userItems),l=xt(oe=>oe.projectItems),u=xt(oe=>oe.loading),c=xt(oe=>oe.fetchAgents),d=xt(oe=>oe.fetchAgent),h=xt(oe=>oe.fetchDefaultContent),p=xt(oe=>oe.createAgent),m=xt(oe=>oe.updateAgent),x=xt(oe=>oe.deleteAgent),[y,w]=E.useState("list"),[C,_]=E.useState(null),[S,v]=E.useState(!1),[b,j]=E.useState(""),[N,T]=E.useState(""),[D,L]=E.useState(""),[I,M]=E.useState(!0),[G,U]=E.useState([]),[R,H]=E.useState("#6b7280"),[W,V]=E.useState(""),[ee,X]=E.useState("user"),[$,O]=E.useState(""),[B,q]=E.useState(!1),[z,re]=E.useState([]),[ne,J]=E.useState(new Set),{requestDelete:K,clearConfirm:P,isConfirming:Q}=Jl(),ae=oe=>{j(oe.metadata.name),T(oe.metadata.id),L(oe.metadata.description),M(oe.metadata.subagent),U(oe.metadata.allowedTools),H(oe.metadata.color??"#6b7280"),V(oe.prompt),O("")},he=(oe,ie,me)=>{j(oe.metadata.name+" (copy)"),T(`${ie}-copy-${Date.now()}`),L(oe.metadata.description),M(oe.metadata.subagent),U(oe.metadata.allowedTools),H(oe.metadata.color??"#6b7280"),V(oe.prompt),O(""),_(null),v(!1),w("edit")},ce=(oe,ie)=>{ae(oe),_(ie),v(!0),w("edit")};E.useEffect(()=>{e&&(c(),ye("/api/tools").then(oe=>oe.json()).then(oe=>{const ie=oe.tools||[];J(new Set(ie.filter(me=>me.alwaysAllowed).map(me=>me.name))),re(ie.filter(me=>!me.alwaysAllowed))}).catch(()=>{re([]),J(new Set)}),n?r.some(ie=>ie.id===n)?h(n).then(ie=>{ie&&he(ie,n)}):d(n).then(ie=>{ie&&(ae(ie),_(n),v(!1),w("edit"))}):(w("list"),_(null),v(!1)))},[e,c,d,h,n]);const De=async oe=>{if(r.some(me=>me.id===oe)){const me=await h(oe);if(!me)return;ce(me,oe)}else{const me=await d(oe);if(!me)return;ce(me,oe)}},Re=async oe=>{let ie=await h(oe);ie||(ie=await d(oe)),ie&&he(ie,oe)},$e=()=>{_(null),j(""),T(""),L(""),M(!0),U(["read_file"]),H("#6b7280"),V(""),X("user"),O(""),v(!1),w("edit")},Ge=async oe=>{const ie=await d(oe);ie&&(ae(ie),_(oe),v(!1),w("edit"))},je=async oe=>{await x(oe)},Ye=async()=>{const oe=C??N;if(!oe||!b||!W){O("Name and prompt are required.");return}q(!0),O("");const ie={metadata:{id:oe,name:b,description:D,subagent:I,allowedTools:G.filter(Ue=>!ne.has(Ue)),color:R},prompt:W},me=C?await m(C,ie):await p(ie,ee);if(q(!1),!me.success){O(me.error??"Failed to save agent.");return}n?t():w("list")},at=()=>{n?t():(w("list"),v(!1))},ke=oe=>{j(oe),C||T(E7(oe))},ze=r.filter(oe=>oe.subagent),lt=r.filter(oe=>!oe.subagent),we=a.filter(oe=>oe.subagent),He=a.filter(oe=>!oe.subagent),Ve=l.filter(oe=>oe.subagent),Z=l.filter(oe=>!oe.subagent);return y==="edit"?i.jsxs(jt,{isOpen:e,onClose:at,title:S?`${b}`:C?"Edit Agent":"New Agent",size:"xl",children:[!C&&!S&&i.jsx(Ld,{value:ee,onChange:X}),i.jsx(j7,{formName:b,formId:N,formDescription:D,formSubagent:I,formTools:G,formColor:R,formPrompt:W,formError:$,saving:B,isReadOnly:S,availableTools:z,onNameChange:ke,onIdChange:T,onDescriptionChange:L,onSubagentChange:oe=>{M(oe),oe&&U(ie=>ie.filter(me=>{var Ue;return!((Ue=z.find(Ie=>Ie.name===me))!=null&&Ue.topLevelOnly)}))},onToolsChange:U,onColorChange:H,onPromptChange:V,onSave:Ye,onCancel:at,onDuplicate:()=>{j(b+" (copy)"),T(`${C}-copy-${Date.now()}`),_(null),v(!1)}})]}):i.jsx(jt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:i.jsx(z1,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:$e,loading:u,hasItems:r.length>0||a.length>0||l.length>0,children:i.jsxs("div",{className:"space-y-4",children:[r.length>0&&i.jsx(n1,{title:"Built-in",agents:lt,subagents:ze,isBuiltIn:!0,alwaysAllowedNames:ne,onView:De,onDuplicate:Re}),[{title:"Custom",agents:He,subagents:we},{title:"Project",agents:Z,subagents:Ve}].map(oe=>oe.agents.length>0&&i.jsx(n1,{title:oe.title,agents:oe.agents,subagents:oe.subagents,isBuiltIn:!1,alwaysAllowedNames:ne,isConfirmingDelete:ie=>Q(ie,"delete"),onView:De,onDuplicate:Re,onEdit:Ge,onDelete:ie=>{Q(ie,"delete")?(je(ie),P()):K(ie)},onCancelDelete:P},oe.title))]})})})}function T7(){const e=Le(v=>{var b;return(b=v.currentSession)==null?void 0:b.mode}),t=Le(v=>v.switchMode),n=xt(v=>v.defaults),r=xt(v=>v.userItems),a=xt(v=>v.fetchAgents),l=[...n,...r],[u,c]=E.useState(!1),[d,h]=E.useState(!1),[p,m]=E.useState(null),x=E.useRef(null);E.useEffect(()=>{a()},[a]),th(x,()=>c(!1));const y=Ql();if(!e)return null;const w=l.filter(v=>!v.subagent),C=w.find(v=>v.id===e),_=(C==null?void 0:C.name)??e,S=ql(l,e);return i.jsxs("div",{className:"relative",ref:x,children:[i.jsxs("button",{type:"button",onClick:()=>c(!u),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[i.jsx("span",{className:"text-sm font-medium",style:{color:S},children:_}),i.jsx(dn,{className:`w-3 h-3 text-text-muted transition-transform ${u?"rotate-180":""}`})]}),u&&w.length>0&&i.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[w.map((v,b)=>{const j=v.id===e,N=ql(l,v.id),T=y.agentSwitching[b],D=T?Zu(T):null;return i.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:[i.jsxs("button",{type:"button",onClick:()=>{j||t(v.id),c(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:"font-medium truncate",style:{color:N},children:v.name}),j&&i.jsx($r,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),D&&i.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:D})]},v.id)}),i.jsx("div",{className:"border-t border-border p-1",children:i.jsx("button",{type:"button",onClick:()=>{c(!1),h(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),i.jsx(N7,{isOpen:d,onClose:()=>{h(!1),m(null)},initialEditId:p})]})}function A7(){const e=Le(r=>r.currentSession),t=Le(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return i.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[i.jsx("button",{type:"button",onClick:()=>t("normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),i.jsx("button",{type:"button",onClick:()=>t("dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})}function r1({value:e,onChange:t}){return i.jsxs("div",{children:[i.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",i.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),i.jsx("input",{type:"text",value:e??"",onChange:n=>t(n.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]})}const L7=[8080,11434,8e3,1234];function rg(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function jj(e){return{name:e.name,url:e.url,backend:e.backend,apiKey:e.apiKey,isLocal:e.isLocal,thinkingField:e.thinkingField,sendReasoningInMessages:e.sendReasoningInMessages,authAdapter:e.authAdapter,transportAdapter:e.transportAdapter,models:e.models}}function D7({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:l,onTestParams:u,onShowRaw:c}){var d,h,p,m,x,y,w,C,_,S,v,b,j,N,T,D,L,I,M,G,U,R,H,W,V,ee,X,$,O,B,q,z,re,ne,J,K,P,Q,ae,he,ce,De,Re,$e,Ge;return i.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>l(e.id),disabled:n.progress[e.id]==="probing",className:"px-4 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:n.progress[e.id]==="probing"?"Probing...":"Auto-config"}),n.progress[e.id]==="done"&&i.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&i.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),i.jsxs("div",{className:"flex gap-3 items-end",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),i.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:je=>a(e.id,{contextWindow:parseInt(je.target.value)||e.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),i.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[i.jsx("input",{type:"checkbox",checked:((h=t[e.id])==null?void 0:h.supportsVision)??!1,onChange:je=>a(e.id,{supportsVision:je.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>u(e.id,"thinking"),disabled:(p=r[e.id+"-thinking"])==null?void 0:p.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(m=r[e.id+"-thinking"])!=null&&m.loading?"Testing...":"Test thinking"}),((x=r[e.id+"-thinking"])==null?void 0:x.result)&&i.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((y=r[e.id+"-thinking"])==null?void 0:y.error)&&i.jsx("span",{className:"text-xs text-red-500",title:(w=r[e.id+"-thinking"])==null?void 0:w.error,children:"Fail"}),((C=r[e.id+"-thinking"])==null?void 0:C.result)&&i.jsx("button",{onClick:()=>c(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>u(e.id,"non-thinking"),disabled:(_=r[e.id+"-non-thinking"])==null?void 0:_.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(S=r[e.id+"-non-thinking"])!=null&&S.loading?"Testing...":"Test non-thinking"}),((v=r[e.id+"-non-thinking"])==null?void 0:v.result)&&i.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.error)&&i.jsx("span",{className:"text-xs text-red-500",title:(j=r[e.id+"-non-thinking"])==null?void 0:j.error,children:"Fail"}),((N=r[e.id+"-non-thinking"])==null?void 0:N.result)&&i.jsx("button",{onClick:()=>c(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),i.jsxs("details",{className:"group",children:[i.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[i.jsx(dn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:((T=t[e.id])==null?void 0:T.thinkingEnabled)??!1,onChange:je=>a(e.id,{thinkingEnabled:je.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),i.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((D=t[e.id])==null?void 0:D.thinkingEnabled)&&i.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(L=e.reasoningEfforts)!=null&&L.length?i.jsx("select",{"aria-label":"Reasoning effort",value:((I=t[e.id])==null?void 0:I.thinkingLevel)??rg(e.reasoningEfforts),onChange:je=>a(e.id,{thinkingLevel:je.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary",children:e.reasoningEfforts.map(je=>i.jsx("option",{value:je,children:je},je))}):i.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((M=t[e.id])==null?void 0:M.thinkingLevel)??"",onChange:je=>a(e.id,{thinkingLevel:je.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),i.jsx(r1,{value:(G=t[e.id])==null?void 0:G.thinkingQueryParams,onChange:je=>a(e.id,{thinkingQueryParams:je})})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:((U=t[e.id])==null?void 0:U.nonThinkingEnabled)??!1,onChange:je=>a(e.id,{nonThinkingEnabled:je.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),i.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((R=t[e.id])==null?void 0:R.nonThinkingEnabled)&&i.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:i.jsx(r1,{value:(H=t[e.id])==null?void 0:H.nonThinkingQueryParams,onChange:je=>a(e.id,{nonThinkingQueryParams:je})})})]}),i.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),i.jsx("input",{type:"number",step:"0.1",value:((W=t[e.id])==null?void 0:W.temperature)??"",onChange:je=>a(e.id,{temperature:je.target.value?parseFloat(je.target.value):void 0}),placeholder:((ee=(V=t[e.id])==null?void 0:V.defaultTemperature)==null?void 0:ee.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&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",($=t[e.id])==null?void 0:$.defaultTemperature]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),i.jsx("input",{type:"number",step:"0.05",value:((O=t[e.id])==null?void 0:O.topP)??"",onChange:je=>a(e.id,{topP:je.target.value?parseFloat(je.target.value):void 0}),placeholder:((q=(B=t[e.id])==null?void 0:B.defaultTopP)==null?void 0:q.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((z=t[e.id])==null?void 0:z.defaultTopP)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(re=t[e.id])==null?void 0:re.defaultTopP]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),i.jsx("input",{type:"number",value:((ne=t[e.id])==null?void 0:ne.topK)??"",onChange:je=>a(e.id,{topK:je.target.value?parseInt(je.target.value):void 0}),placeholder:((K=(J=t[e.id])==null?void 0:J.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"}),((P=t[e.id])==null?void 0:P.defaultTopK)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Q=t[e.id])==null?void 0:Q.defaultTopK]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),i.jsx("input",{type:"number",value:((ae=t[e.id])==null?void 0:ae.maxTokens)??"",onChange:je=>a(e.id,{maxTokens:je.target.value?parseInt(je.target.value):void 0}),placeholder:((ce=(he=t[e.id])==null?void 0:he.defaultMaxTokens)==null?void 0:ce.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((De=t[e.id])==null?void 0:De.defaultMaxTokens)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Re=t[e.id])==null?void 0:Re.defaultMaxTokens]})]})]})]}),i.jsx("div",{className:"pt-3 border-t border-border",children:i.jsx(R7,{value:($e=t[e.id])==null?void 0:$e.compactionThreshold,maxTokens:((Ge=t[e.id])==null?void 0:Ge.contextWindow)??e.contextWindow,onChange:je=>a(e.id,{compactionThreshold:je})})})]})]})}function R7({value:e,maxTokens:t,onChange:n}){const l=Math.min(95,Math.floor((t-5e3)/t*100)),u=Math.min(l,Math.ceil(15e3/t*100)),c=Math.min(e??.85,l/100),[d,h]=E.useState(Math.round(c*100));E.useEffect(()=>{const m=Math.min(e??.85,l/100);h(Math.round(m*100))},[e,l]);const p=Math.floor(t*(d/100));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Auto-compaction threshold"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-mono text-xs text-text-primary",children:[d,"% · ",co(p)]}),i.jsx("button",{type:"button",onClick:()=>{n(void 0),h(Math.round(.85*100))},disabled:e===void 0,className:"text-xs text-accent-primary hover:underline disabled:text-text-muted disabled:no-underline",children:"Default"})]})]}),i.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:u,max:l,step:"1",value:d,onChange:m=>h(Number(m.target.value)),onMouseUp:()=>n(d/100),onTouchEnd:()=>n(d/100),onBlur:()=>n(d/100),onKeyUp:()=>n(d/100),className:"w-full"}),i.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",co(15e3)," tokens · maximum ",l,"% · default 85%"]})]})}function Ej({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:l}){const[u,c]=E.useState(r),[d,h]=E.useState(""),[p,m]=E.useState(""),[x,y]=E.useState("unknown"),[w,C]=E.useState(""),[_,S]=E.useState(!1),[v,b]=E.useState(),[j,N]=E.useState(),[T,D]=E.useState(!1),[L,I]=E.useState(null),[M,G]=E.useState([]),[U,R]=E.useState(null),[H,W]=E.useState(!1),[V,ee]=E.useState(""),[X,$]=E.useState(!0),[O,B]=E.useState({}),[q,z]=E.useState({loading:!1,progress:{}}),[re,ne]=E.useState({}),[J,K]=E.useState(null),[P,Q]=E.useState(new Set),[ae,he]=E.useState(""),[ce,De]=E.useState(null),[Re,$e]=E.useState("disconnected"),[Ge,je]=E.useState(!1),[Ye,at]=E.useState(null),[ke,ze]=E.useState([]),[lt,we]=E.useState(!1),[He,Ve]=E.useState(!1),Z=E.useRef(null),oe=E.useRef(!1),ie=E.useRef(null);E.useEffect(()=>{u===1&&e&&requestAnimationFrame(()=>{var se;return(se=ie.current)==null?void 0:se.focus()})},[u,e]),E.useEffect(()=>()=>{Z.current!==null&&window.clearTimeout(Z.current)},[]),E.useEffect(()=>{e&&ye("/api/provider-presets").then(async se=>se.ok?await se.json():{presets:[]}).then(se=>ze(se.presets)).catch(()=>ze([]))},[e]);function me(se,ve){B(Ne=>({...Ne,[se]:{...Ne[se],...ve}}))}function Ue(se){Q(ve=>new Set(ve).add(se.id)),B(ve=>({...ve,[se.id]:{contextWindow:se.contextWindow,...ve[se.id]}}))}function Ie(se){if(!se.trim())return M;const ve=se.toLowerCase().split(/\s+/).filter(Boolean);return M.filter(Ne=>ve.every(Oe=>Ne.id.toLowerCase().includes(Oe)))}E.useEffect(()=>{var se,ve;if(e)if(c(r),h((a==null?void 0:a.name)??""),m((a==null?void 0:a.url)??""),y((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),b(a==null?void 0:a.authAdapter),N(a==null?void 0:a.transportAdapter),I(null),ee((a==null?void 0:a.thinkingField)??""),$((a==null?void 0:a.sendReasoningInMessages)??!0),ne({}),K(null),De(null),$e("disconnected"),at(null),we(!1),Ve(!1),(se=a==null?void 0:a.models)!=null&&se.length){const Ne={},Oe=new Set;for(const Je of a.models)Ne[Je.id]={contextWindow:Je.contextWindow,supportsVision:Je.supportsVision,thinkingEnabled:Je.thinkingEnabled,thinkingLevel:Je.thinkingLevel??rg(Je.reasoningEfforts),nonThinkingEnabled:Je.nonThinkingEnabled,thinkingQueryParams:Je.thinkingQueryParams,nonThinkingQueryParams:Je.nonThinkingQueryParams,defaultTemperature:Je.defaultTemperature,defaultTopP:Je.defaultTopP,defaultTopK:Je.defaultTopK,defaultMaxTokens:Je.defaultMaxTokens,temperature:Je.temperature,topP:Je.topP,topK:Je.topK,maxTokens:Je.maxTokens,compactionThreshold:Je.compactionThreshold},Je.selected&&Oe.add(Je.id);if(Oe.size===0)for(const Je of a.models)Oe.add(Je.id);Q(Oe),B(Ne),G(a.models),R(l??((ve=a.models[0])==null?void 0:ve.id)??null)}else G([]),B({}),R(null),Q(new Set)},[e,r,a==null?void 0:a.id,l]),E.useEffect(()=>{const se=!!v;u===2&&p&&M.length===0&&!T&&!L&&(!se||Re==="connected")&&Ct(p)},[u,Re]),E.useEffect(()=>{!e||!v||!(a!=null&&a.id)||ct(a.id)},[e,j,a==null?void 0:a.id]),E.useEffect(()=>{if(!Ye)return;const se=(a==null?void 0:a.id)??ce;if(!se)return;let ve=!1;const Ne=async()=>{const Je=await ct(se);ve||Je!=="connected"||(at(null),we(!1),Ve(!1),await Ct(p))};Ne();const Oe=window.setInterval(()=>void Ne(),2e3);return()=>{ve=!0,window.clearInterval(Oe)}},[Ye,ce,a==null?void 0:a.id]);async function Ke(){if(a!=null&&a.id)return a.id;if(ce)return ce;const se=await ye("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:p,backend:x,authAdapter:v,transportAdapter:j,isLocal:!1,models:[]})});if(!se.ok)throw new Error("Unable to create provider");const ve=await se.json();return De(ve.provider.id),ve.provider.id}async function ct(se){const ve=await ye(`/api/provider-auth/${se}/status`);if(!ve.ok)return"error";const Ne=await ve.json(),Oe=Ne.state==="connected"?"connected":Ne.state==="pending"?"pending":Ne.state==="error"?"error":"disconnected";return $e(Oe),Oe}async function et(){je(!0),$e("pending");try{const se=await Ke(),ve=await ye(`/api/provider-auth/${se}/login`,{method:"POST"});if(!ve.ok)throw new Error("Unable to start provider sign-in");const Ne=await ve.json();at(Ne)}catch{$e("error")}finally{je(!1)}}async function tt(){var se;Ye!=null&&Ye.userCode&&(await((se=navigator.clipboard)==null?void 0:se.writeText(Ye.userCode)),Z.current!==null&&window.clearTimeout(Z.current),Ve(!1),requestAnimationFrame(()=>Ve(!0)),Z.current=window.setTimeout(()=>{Ve(!1),Z.current=null},1500))}function ot(){Ye&&(window.open(Ye.directUrl??Ye.verificationUrl,"_blank","noopener,noreferrer"),we(!0))}async function Ct(se){var ve,Ne;D(!0),I(null),G([]);try{const Oe=new URLSearchParams({url:se});w&&Oe.set("apiKey",w),x&&Oe.set("backend",x);const Je=j?await ye(`/api/providers/${await Ke()}/models`):await ye(`/api/providers/models?${Oe.toString()}`);if(Je.ok){const Dt=await Je.json();if((ve=Dt.models)!=null&&ve.length){G(Dt.models),R(((Ne=Dt.models[0])==null?void 0:Ne.id)??null);const wn={};for(const An of Dt.models)wn[An.id]={contextWindow:An.contextWindow,thinkingEnabled:!0,thinkingLevel:rg(An.reasoningEfforts),defaultTemperature:An.defaultTemperature,defaultTopP:An.defaultTopP,defaultTopK:An.defaultTopK,defaultMaxTokens:An.defaultMaxTokens};B(wn),Dt.models.length===1&&(Q(new Set([Dt.models[0].id])),R(Dt.models[0].id),dt(Dt.models[0].id))}}else{const Dt=await Je.json();I(Dt.error??`Failed to fetch models from ${se}`)}}catch(Oe){I(`Failed to fetch models from ${se}: ${Oe instanceof Error?Oe.message:"Unknown error"}`)}D(!1)}async function dt(se){z(ve=>({loading:!0,progress:{...ve.progress,[se]:"probing"}}));try{const ve=await ye("/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:se}]})});if(!ve.ok){const Oe=await ve.json();throw new Error(Oe.error??"Auto-config failed")}const Ne=await ve.json();for(const Oe of Ne.models){const Je={};Oe.contextSource!=="default"&&(Je.contextWindow=Oe.contextWindow,Je.supportsVision=Oe.supportsVision),Oe.thinkingConfig&&(Je.thinkingEnabled=!0,Je.thinkingQueryParams=JSON.stringify(Oe.thinkingConfig)),Oe.nonThinkingConfig&&(Je.nonThinkingEnabled=!0,Je.nonThinkingQueryParams=JSON.stringify(Oe.nonThinkingConfig)),me(Oe.id,Je),z(Dt=>({...Dt,progress:{...Dt.progress,[Oe.id]:"done"}}))}}catch(ve){console.error("Auto-config error:",ve),z(Ne=>({...Ne,progress:{...Ne.progress,[se]:"error"}}))}finally{z(ve=>({...ve,loading:!1}))}}async function hn(se,ve){const Ne=se+"-"+ve;ne(Oe=>({...Oe,[Ne]:{loading:!0}}));try{const Oe=O[se],Je=await ye("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,providerId:(a==null?void 0:a.id)??ce??void 0,transportAdapter:j,model:se,apiKey:w||void 0,backend:x||"unknown",thinkingField:V||void 0,mode:ve,modelConfig:{temperature:Oe==null?void 0:Oe.temperature,topP:Oe==null?void 0:Oe.topP,topK:Oe==null?void 0:Oe.topK,maxTokens:Oe==null?void 0:Oe.maxTokens,supportsVision:Oe==null?void 0:Oe.supportsVision,thinkingEnabled:Oe==null?void 0:Oe.thinkingEnabled,thinkingLevel:Oe==null?void 0:Oe.thinkingLevel,nonThinkingEnabled:Oe==null?void 0:Oe.nonThinkingEnabled,thinkingQueryParams:Oe==null?void 0:Oe.thinkingQueryParams,nonThinkingQueryParams:Oe==null?void 0:Oe.nonThinkingQueryParams}})}),Dt=await Je.json();Je.ok?ne(wn=>({...wn,[Ne]:{loading:!1,result:JSON.stringify(Dt,null,2),message:Dt.message}})):ne(wn=>({...wn,[Ne]:{loading:!1,error:Dt.error??"Test failed"}}))}catch(Oe){ne(Je=>({...Je,[Ne]:{loading:!1,error:Oe instanceof Error?Oe.message:"Request failed"}}))}}function yn(){G([]),B({}),z({loading:!1,progress:{}}),ne({}),K(null),Q(new Set),he("")}function Fn(){ce&&!oe.current&&ye(`/api/providers/${ce}`,{method:"DELETE"}).catch(se=>{console.warn("Failed to clean up draft provider",se)}),t()}function Vn(){const se=d||"Provider",ve=(a==null?void 0:a.id)??ce??`temp-${Date.now()}`;n({id:ve,name:se,url:p,backend:x||"unknown",apiKey:w||void 0,isLocal:_,thinkingField:V||void 0,sendReasoningInMessages:X,authAdapter:v,transportAdapter:j,models:M.map(Ne=>{var Oe,Je,Dt,wn,An,yi,As,Ls,_e,Se,Me,We,Fe,Qe,nt,Kt;return{id:Ne.id,name:Ne.name,apiModelId:Ne.apiModelId,requestBody:Ne.requestBody,reasoningEfforts:Ne.reasoningEfforts,contextWindow:((Oe=O[Ne.id])==null?void 0:Oe.contextWindow)??Ne.contextWindow,selected:P.has(Ne.id)||void 0,supportsVision:(Je=O[Ne.id])==null?void 0:Je.supportsVision,thinkingEnabled:(Dt=O[Ne.id])==null?void 0:Dt.thinkingEnabled,thinkingLevel:(wn=O[Ne.id])==null?void 0:wn.thinkingLevel,nonThinkingEnabled:(An=O[Ne.id])==null?void 0:An.nonThinkingEnabled,thinkingQueryParams:(yi=O[Ne.id])==null?void 0:yi.thinkingQueryParams,nonThinkingQueryParams:(As=O[Ne.id])==null?void 0:As.nonThinkingQueryParams,temperature:(Ls=O[Ne.id])==null?void 0:Ls.temperature,topP:(_e=O[Ne.id])==null?void 0:_e.topP,topK:(Se=O[Ne.id])==null?void 0:Se.topK,maxTokens:(Me=O[Ne.id])==null?void 0:Me.maxTokens,defaultMaxTokens:(We=O[Ne.id])==null?void 0:We.defaultMaxTokens,defaultTemperature:(Fe=O[Ne.id])==null?void 0:Fe.defaultTemperature,defaultTopP:(Qe=O[Ne.id])==null?void 0:Qe.defaultTopP,defaultTopK:(nt=O[Ne.id])==null?void 0:nt.defaultTopK,compactionThreshold:(Kt=O[Ne.id])==null?void 0:Kt.compactionThreshold}})}),oe.current=!0,t()}return e?i.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] overflow-y-auto shadow-2xl",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[i.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),i.jsx("button",{onClick:Fn,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(se=>i.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${se<u?"bg-accent-success":se===u?"bg-accent-primary":"bg-border"}`},se))}),u===1&&i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),i.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[ke.map(se=>i.jsx("button",{type:"button",onClick:()=>{h(se.defaults.name??se.name),m(se.defaults.url),y(se.defaults.backend),S(!1),C(""),b(se.authAdapter),N(se.transportAdapter),I(null),yn()},className:`p-2 rounded border text-center text-sm transition-colors ${j&&j===se.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:se.name},se.id)),i.jsx("button",{type:"button",onClick:()=>{y("unknown"),S(!1),b(void 0),N(void 0),I(null),yn()},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"),L7.map(se=>{const ve={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},Ne={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return i.jsx("button",{type:"button",onClick:()=>{h(Oe=>Oe||(Ne[se]??"")),m(Oe=>Oe||`http://localhost:${se}`),y(ve[se]??""),S(!0),b(void 0),N(void 0),I(null),yn()},className:`p-2 rounded border text-center text-sm transition-colors ${x===ve[se]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Ne[se]??`localhost:${se}`},se)})]})]}),!v&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),i.jsx("input",{ref:ie,type:"text",value:p,"data-testid":"provider-modal-url",onChange:se=>{m(se.target.value),I(null),G([]),B({})},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),i.jsx("input",{type:"text",autoComplete:"off",value:d,onChange:se=>h(se.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"})]}),!v&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsx("input",{type:"text",autoComplete:"off",value:w,onChange:se=>C(se.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"})]}),!v&&i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:_,onChange:se=>S(se.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),i.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),u===2&&i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Test & Configure Models"}),i.jsx("button",{type:"button",onClick:()=>W(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:i.jsx(I1,{className:"w-4 h-4"})})]}),!!v&&i.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),i.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),Re==="connected"?i.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):i.jsx("button",{type:"button",onClick:()=>void et(),disabled:Ge||Re==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:Ge||Re==="pending"?"Connecting...":Re==="error"?"Retry":"Connect"})]}),Ye&&i.jsx("div",{className:"mt-4 border-t border-border pt-4",children:Ye.mode!=="browser"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),i.jsx("button",{type:"button",onClick:()=>void tt(),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:Ye.userCode??"Continue"}),i.jsxs("div",{className:"mt-3 flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>void tt(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:He?"Copied":"Copy code"}),i.jsx("button",{type:"button",onClick:ot,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:lt?"Reopen authorization":"Open authorization"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-xs text-text-muted mb-3",children:Ye.instructions}),i.jsx("button",{type:"button",onClick:ot,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:lt?"Reopen authorization":"Open authorization"})]})})]}),T&&i.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[i.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),L&&i.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[i.jsx("p",{children:L}),i.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),i.jsxs("div",{className:"flex gap-2 mt-2",children:[i.jsx("button",{onClick:()=>Ct(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),i.jsx("button",{onClick:()=>{yn(),c(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"})]})]}),M.length>0&&x&&(!v||Re==="connected")&&i.jsxs(i.Fragment,{children:[P.size>0&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",P.size,")"]}),i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),i.jsx("div",{className:"space-y-2",children:M.filter(se=>P.has(se.id)).map(se=>{var ve;return i.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[i.jsxs("div",{onClick:()=>R(U===se.id?null:se.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:"text-sm font-medium text-text-primary",children:se.name??se.id.split("/").pop()}),i.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((ve=O[se.id])==null?void 0:ve.contextWindow)??se.contextWindow).toLocaleString()," ctx"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[q.progress[se.id]==="probing"?i.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):q.progress[se.id]==="done"?i.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):q.progress[se.id]==="error"?i.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):v?null:i.jsx("button",{onClick:Ne=>{Ne.stopPropagation(),dt(se.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),M.length>1&&i.jsx("button",{onClick:Ne=>{Ne.stopPropagation();const Oe=new Set(P);Oe.delete(se.id),Q(Oe),U===se.id&&R(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),i.jsx(dn,{className:`w-4 h-4 text-text-muted transition-transform ${U===se.id?"rotate-180":""}`})]})]}),U===se.id&&i.jsx(D7,{model:se,modelConfigs:O,autoConfigState:q,testResults:re,onUpdateConfig:me,onRunAutoConfig:dt,onTestParams:hn,onShowRaw:K})]},se.id)})})]}),M.length>1&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),P.size===0&&i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"This provider has many models available. Select the ones you want to use below."}),i.jsxs("div",{className:"relative mb-2",children:[i.jsx("input",{type:"text",value:ae,onChange:se=>he(se.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"}),ae&&i.jsx("button",{onClick:()=>he(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",Ie(ae).length," of ",M.length," models"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>{const se=new Set(P),ve=Ie(ae);for(const Ne of ve)se.add(Ne.id);if(Q(se),B(Ne=>{const Oe={...Ne};for(const Je of ve)Oe[Je.id]={contextWindow:Je.contextWindow,...Oe[Je.id]};return Oe}),!v)for(const Ne of ve)q.progress[Ne.id]!=="probing"&&q.progress[Ne.id]!=="done"&&dt(Ne.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),i.jsx("button",{onClick:()=>{const se=new Set(P),ve=Ie(ae);for(const Ne of ve)se.delete(Ne.id);Q(se)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),i.jsxs("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-border rounded-lg bg-bg-primary",children:[Ie(ae).map(se=>{var Ne;const ve=P.has(se.id);return i.jsxs("div",{role:"checkbox","aria-checked":ve,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${ve?"bg-accent-primary/5":""}`,onClick:()=>{if(ve){const Oe=new Set(P);Oe.delete(se.id),Q(Oe)}else Ue(se),v||dt(se.id)},onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),Oe.currentTarget.click())},children:[i.jsx("input",{type:"checkbox",checked:ve,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),i.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:se.name??se.id.split("/").pop()}),i.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Ne=O[se.id])==null?void 0:Ne.contextWindow)??se.contextWindow).toLocaleString()," ctx"]}),q.progress[se.id]==="probing"&&i.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),q.progress[se.id]==="done"&&i.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),q.progress[se.id]==="error"&&i.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},se.id)}),Ie(ae).length===0&&i.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",ae,"”"]})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[i.jsx("div",{children:u>1&&i.jsx("button",{onClick:()=>{u===2&&yn(),c(u-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:Fn,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),u===1?i.jsx("button",{onClick:()=>c(2),disabled:!p,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):i.jsx("button",{onClick:Vn,disabled:q.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:q.loading?"Configuring...":"Save Provider"})]})]})]}),H&&i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:se=>{se.target===se.currentTarget&&W(!1)},children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[i.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),i.jsx("button",{onClick:()=>W(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),i.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),i.jsx("input",{type:"text",defaultValue:'reasoning_effort: "low"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",i.jsx("span",{className:"text-text-muted",children:"(override)"})]}),i.jsx("input",{type:"text",value:V,onChange:se=>ee(se.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Field name the backend uses for reasoning/thinking content (e.g. reasoning, reasoning_content, thinking)."})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:X,onChange:se=>$(se.target.checked),className:"rounded border-border bg-bg-primary text-accent-primary focus:ring-accent-primary"}),i.jsx("span",{className:"text-sm text-text-secondary",children:"Send reasoning in messages"}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:"When disabled, strips reasoning/thinking content from assistant messages sent to this provider"})]})]}),i.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:i.jsx("button",{onClick:()=>W(!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"})})]})}),J&&i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:se=>{se.target===se.currentTarget&&K(null)},children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[i.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),i.jsx("button",{onClick:()=>K(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsx("pre",{className:"px-6 py-4 overflow-y-auto text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:J})]})})]}):null}function O7(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function I7(e,t){const n=t.toLowerCase(),r=(e.name??"").toLowerCase(),a=e.id.toLowerCase(),l=a.replace(/-/g," ");return r.includes(n)||a.includes(n)||l.includes(n)}function s1({activeProvider:e,shortModelName:t}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-accent-primary",children:e?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"hidden sm:inline",children:[e.name," • "]}),t]}):t}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${e!=null&&e.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:e!=null&&e.isLocal?"local":"api"})]})}function M7({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:l,settingDefault:u,highlighted:c,onModelClick:d,onSetDefault:h,onEditModel:p}){var m;return i.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${c?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[i.jsx("button",{type:"button",onClick:()=>d(e,t.id),disabled:a,className:"flex-1 truncate text-left",children:t.name??((m=t.id.split("/").pop())==null?void 0:m.replace(/-/g," "))??t.id}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[i.jsx("span",{className:"text-xs text-text-muted",children:O7(t.contextWindow)}),l&&i.jsx("button",{type:"button",onClick:x=>h(x,e,t.id),disabled:u,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:r?"Default model":"Set as default model",children:r?i.jsx(M1,{className:"w-3.5 h-3.5 text-accent-warning"}):i.jsx(P1,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),i.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),p(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:i.jsx(A1,{className:"w-3 h-3 text-text-muted"})}),n&&i.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:i.jsx($r,{className:"w-3.5 h-3.5"})})]})]})}function P7(){var Vn;const[,e]=Tn(),t=Le(se=>se.currentSession),n=Le(se=>se.setSessionProvider),[r,a]=E.useState(!1),[l,u]=E.useState([]),[c,d]=E.useState(null),h=E.useRef(null),[p,m]=E.useState(null),[x,y]=E.useState(!1),[w,C]=E.useState({}),[_,S]=E.useState(null),[v,b]=E.useState(null),[j,N]=E.useState(!1),T=E.useRef(null),[D,L]=E.useState(!1),I=E.useRef(new Set),[M,G]=E.useState(-1),U=E.useRef(null),R=Qt(se=>se.providers),H=Qt(se=>se.activeProviderId),W=Qt(se=>se.defaultModelSelection),V=Qt(se=>se.activating),ee=Qt(se=>se.activateProvider),X=Qt(se=>se.refreshModel),$=Qt(se=>se.refreshProviderModels),O=Qt(se=>se.setDefaultModel),B=Qt(se=>se.fetchConfig),q=Ql();Pl(q.modelSelector,()=>a(se=>!se));const z=(t==null?void 0:t.providerId)??null,re=(t==null?void 0:t.providerModel)??null,ne=(W==null?void 0:W.split("/")[0])??null,J=(W==null?void 0:W.split("/").slice(1).join("/"))??null,K=z??ne,P=re??J,Q=P?((Vn=P.split("/").pop())==null?void 0:Vn.replace(/-/g," "))??P:"No model",[ae,he]=E.useState(!1),[ce,De]=E.useState(""),Re=E.useRef(null);E.useEffect(()=>{function se(ve){h.current&&!h.current.contains(ve.target)&&(a(!1),u([]),I.current=new Set)}return document.addEventListener("mousedown",se),()=>document.removeEventListener("mousedown",se)},[]),E.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current)},[]),E.useEffect(()=>{r||(De(""),G(-1))},[r]),E.useEffect(()=>{var se;r&&((se=Re.current)==null||se.focus())},[r]),E.useEffect(()=>{M>=0&&U.current&&U.current.scrollIntoView({block:"nearest"})},[M]),E.useEffect(()=>{if(r){const se=R.map(ve=>ve.id);u(se),R.filter(ve=>!!ve.authAdapter).forEach(ve=>void He(ve.id)),se.forEach(ve=>{I.current.has(ve)||(I.current.add(ve),at(ve))})}},[r,R]),E.useEffect(()=>{if(!v)return;let se=!1;const ve=async()=>{const Oe=await He(v.providerId);se||Oe==="connected"&&(b(null),N(!1),L(!1),await B(),I.current.delete(v.providerId),await at(v.providerId))};ve();const Ne=window.setInterval(()=>void ve(),2e3);return()=>{se=!0,window.clearInterval(Ne)}},[v]);const $e=R.find(se=>se.id===K),Ge=($e==null?void 0:$e.status)==="disconnected",je=(se,ve)=>t?t.providerId===se&&t.providerModel===ve:!1,Ye=(se,ve)=>W?W===`${se}/${ve}`:!1,at=async se=>{d(se);try{await $(se)}catch{}finally{d(null)}},ke=se=>{l.includes(se.id)?u(l.filter(ve=>ve!==se.id)):(u([...l,se.id]),at(se.id))},ze=async se=>{if(se.id===H){ke(se);return}t?(n(se.id,void 0),a(!1),u([])):await ee(se.id)&&(a(!1),u([]))},lt=se=>{ke(se)},we=async(se,ve)=>{se.stopPropagation(),I.current.delete(ve),await at(ve)},He=async se=>{const ve=await ye(`/api/provider-auth/${se}/status`);if(!ve.ok)return"error";const Ne=await ve.json();return C(Oe=>({...Oe,[se]:Ne.state})),Ne.state},Ve=async(se,ve)=>{se.stopPropagation(),S(ve),C(Ne=>({...Ne,[ve]:"pending"})),N(!1),L(!1);try{const Ne=await ye(`/api/provider-auth/${ve}/login`,{method:"POST"});if(!Ne.ok)throw new Error("Unable to start provider sign-in");const Oe=await Ne.json();b({providerId:ve,...Oe})}catch{C(Ne=>({...Ne,[ve]:"error"}))}finally{S(null)}},Z=async()=>{var se;v!=null&&v.userCode&&(await((se=navigator.clipboard)==null?void 0:se.writeText(v.userCode)),T.current!==null&&window.clearTimeout(T.current),N(!1),requestAnimationFrame(()=>N(!0)),T.current=window.setTimeout(()=>{N(!1),T.current=null},1500))},oe=()=>{v&&(window.open(v.directUrl??v.verificationUrl,"_blank","noopener,noreferrer"),L(!0))},ie=()=>{b(null),N(!1),L(!1)},me=async(se,ve)=>{se.stopPropagation(),S(ve);try{if(!(await ye(`/api/provider-auth/${ve}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");C(Oe=>({...Oe,[ve]:"disconnected"})),await B()}finally{S(null)}},Ue=(se,ve)=>{m({providerId:se,model:ve}),y(!0)},Ie=p?R.find(se=>se.id===p.providerId):void 0,Ke=()=>{m(null),y(!1)},ct=async se=>{try{if(!(await ye(`/api/providers/${se.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(jj(se))})).ok)throw new Error("Failed to update provider");await Qt.getState().fetchConfig()}catch{}m(null),y(!1)},et=async(se,ve)=>{if(t){Le.setState(Oe=>({currentSession:Oe.currentSession?{...Oe.currentSession,providerId:se,providerModel:ve}:null})),n(se,ve),u([]),a(!1),Kl();return}await ee(se)&&(u([]),a(!1),Kl())},tt=async(se,ve,Ne)=>{se.stopPropagation(),he(!0);try{await O(ve,Ne)}catch{}finally{he(!1)}};function ot(se){return se.models.some(Ne=>Ne.selected)?se.models.filter(Ne=>Ne.selected):se.models}const Ct=E.useMemo(()=>ce.trim()?R.map(se=>({provider:se,models:ot(se).filter(ve=>I7(ve,ce))})).filter(se=>se.models.length>0):R.map(se=>({provider:se,models:ot(se)})),[R,ce]),dt=E.useMemo(()=>Ct.flatMap(se=>se.models.map(ve=>({providerId:se.provider.id,modelConfig:ve}))),[Ct]),hn=dt.length+1,yn=M===dt.length;E.useEffect(()=>{hn===1?G(-1):M>=hn?G(hn-1):M<0&&ce.trim()&&G(0)},[hn,M,ce]);const Fn=se=>{switch(se.key){case"Escape":a(!1);break;case"ArrowDown":se.preventDefault(),hn>0&&G(ve=>ve<hn-1?ve+1:0);break;case"ArrowUp":se.preventDefault(),hn>0&&G(ve=>ve>0?ve-1:hn-1);break;case"Home":se.preventDefault(),G(0);break;case"End":se.preventDefault(),G(hn-1);break;case"Enter":if(se.preventDefault(),M===dt.length)e("/onboarding"),a(!1);else if(M>=0&&M<dt.length){const ve=dt[M];ve&&et(ve.providerId,ve.modelConfig.id)}break}};return R.length===0?i.jsxs("button",{type:"button",onClick:()=>X(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:Ge?"LLM server is offline. Click to retry.":Q??"Click to refresh model",children:[Ge?i.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):i.jsx(s1,{activeProvider:$e,shortModelName:Q}),i.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):i.jsxs("div",{className:"relative",ref:h,children:[i.jsxs("button",{type:"button",onClick:()=>a(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[Ge?i.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):i.jsx(s1,{activeProvider:$e,shortModelName:Q}),i.jsx(dn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[i.jsx(Qi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("input",{ref:Re,type:"text",value:ce,onInput:se=>{De(se.currentTarget.value),G(-1)},onKeyDown:Fn,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),i.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:i.jsxs("div",{children:[Ct.map(se=>{const ve=ce.trim().length>0||l.includes(se.provider.id);return i.jsxs("div",{children:[i.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${se.provider.id===K?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${V?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[i.jsxs("div",{onClick:()=>!V&&ze(se.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[i.jsx("span",{className:`text-sm font-medium truncate ${se.provider.id===K?"text-accent-primary":"text-text-primary"}`,children:se.provider.name}),i.jsx("span",{className:"text-xs text-text-muted truncate",children:se.provider.backend!=="unknown"&&v1(se.provider.backend)})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!se.provider.authAdapter&&(w[se.provider.id]==="connected"||se.provider.credentialRef?i.jsx("button",{type:"button",onClick:Ne=>me(Ne,se.provider.id),disabled:_===se.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-success/40 text-accent-success hover:bg-accent-success/10 disabled:opacity-50",title:"Disconnect provider account",children:"Connected"}):i.jsx("button",{type:"button",onClick:Ne=>Ve(Ne,se.provider.id),disabled:_===se.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-primary/40 text-accent-primary hover:bg-accent-primary/10 disabled:opacity-50",title:"Connect provider account",children:_===se.provider.id?"Starting…":w[se.provider.id]==="error"||w[se.provider.id]==="expired"?"Retry":"Connect"})),se.provider.id===K?i.jsx("span",{className:"text-accent-success",title:"Active provider",children:i.jsx($r,{className:"w-4 h-4"})}):i.jsx("span",{className:"w-4"}),i.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),we(Ne,se.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:i.jsx(Td,{className:`w-4 h-4 ${c===se.provider.id?"animate-spin":""} ${se.provider.id===H?"text-accent-primary":"text-text-muted"}`})}),i.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),lt(se.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:i.jsx(dn,{className:`w-4 h-4 transition-transform ${ve?"rotate-180":""} ${se.provider.id===H?"text-accent-primary":"text-text-muted"}`})})]})]}),ve&&i.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:c===se.provider.id?i.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):se.models.length>0?se.models.map(Ne=>{const Je=dt.findIndex(Dt=>Dt.providerId===se.provider.id&&Dt.modelConfig.id===Ne.id)===M;return i.jsx("div",{ref:Je?U:void 0,children:i.jsx(M7,{providerId:se.provider.id,modelConfig:Ne,isActive:je(se.provider.id,Ne.id),isDefault:Ye(se.provider.id,Ne.id),disabled:c==="activating",hasSession:!!t,settingDefault:ae,highlighted:Je,onModelClick:et,onSetDefault:tt,onEditModel:Ue})},`${se.provider.id}/${Ne.id}`)}):i.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},se.provider.id)}),Ct.length===0&&ce.trim()&&i.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})}),i.jsx("div",{className:`border-t border-border px-3 py-2 ${yn?"bg-bg-tertiary":""} flex-shrink-0`,children:i.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),v&&i.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 px-4",role:"dialog","aria-modal":"true","aria-labelledby":"provider-device-title",onMouseDown:se=>{se.target===se.currentTarget&&ie()},children:i.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),i.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),i.jsx("button",{type:"button",onClick:ie,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:"×"})]}),v.mode!=="browser"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:Z,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:v.userCode??"Continue"}),i.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:j?"Copied to clipboard":"Click the code to copy it"}),i.jsxs("div",{className:"mt-6 flex gap-3",children:[i.jsx("button",{type:"button",onClick:Z,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"}),i.jsx("button",{type:"button",onClick:oe,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})]}),i.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:D?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:v.instructions}),i.jsx("div",{className:"mt-6 flex gap-3",children:i.jsx("button",{type:"button",onClick:oe,className:"w-full rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})})]})]})}),p&&x&&i.jsx(Ej,{isOpen:!0,onClose:Ke,onSave:ct,initialStep:2,editProvider:{id:p.providerId,name:(Ie==null?void 0:Ie.name)??"",url:(Ie==null?void 0:Ie.url)??"",backend:(Ie==null?void 0:Ie.backend)??"unknown",apiKey:Ie==null?void 0:Ie.apiKey,isLocal:Ie==null?void 0:Ie.isLocal,thinkingField:Ie==null?void 0:Ie.thinkingField,sendReasoningInMessages:Ie==null?void 0:Ie.sendReasoningInMessages,authAdapter:Ie==null?void 0:Ie.authAdapter,transportAdapter:Ie==null?void 0:Ie.transportAdapter,models:Ie==null?void 0:Ie.models},editModelId:p.model.id})]})}function B7(){const e=Il(j=>j.servers),t=Il(j=>j.fetchServers),n=Le(j=>j.currentSession),r=n==null?void 0:n.id,[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(new Set),[p,m]=E.useState(new Set),x=E.useRef(null),y=E.useCallback(async()=>{if(r)try{const j=await ye(`/api/sessions/${r}/mcp/overrides`);if(j.ok){const N=await j.json();m(new Set(N.disabledServers??[]))}}catch{}},[r]),w=E.useCallback(async()=>{await t(),await y()},[t,y]);E.useEffect(()=>{const j=()=>w();return window.addEventListener("mcp-servers-changed",j),()=>window.removeEventListener("mcp-servers-changed",j)},[w]),E.useEffect(()=>{y()},[y]),E.useEffect(()=>{a&&y()},[a,y]),th(x,()=>l(!1));const C=j=>p.has(j.name),_=e.filter(j=>j.status==="connected"&&!C(j)),S=_.length,v=_.reduce((j,N)=>j+N.estimatedTokens,0),b=async(j,N)=>{if(r){c(null),h(T=>new Set(T).add(j));try{const T=new Set(p);N?T.add(j):T.delete(j);const D=await ye(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(T)})});if(!D.ok){const L=await D.json().catch(()=>({}));throw new Error(L.error??"Toggle failed")}m(T),await t()}catch(T){c(T instanceof Error?T.message:String(T))}finally{h(T=>{const D=new Set(T);return D.delete(j),D})}}};return i.jsxs("div",{className:"relative",ref:x,children:[i.jsxs("button",{type:"button",onClick:()=>l(!a),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:S>0?`${S} MCP server(s) active`:"No MCP server active",children:[i.jsx("span",{className:"text-sm text-accent-primary whitespace-nowrap",children:S>0?`● ${S} MCP (${xd(v)})`:"MCP"}),i.jsx(dn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[i.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:e.length===0?i.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No MCP servers configured"}):e.map(j=>{const N=C(j),T=d.has(j.name);return i.jsx("div",{children:i.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-bg-tertiary",children:[i.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[i.jsx("span",{className:`text-sm ${Xg(N?"disabled":j.status)}`,children:Qg(N?"disabled":j.status)}),i.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:j.name})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted ml-3.5",children:[i.jsxs("span",{children:[j.tools.length," tools"]}),j.estimatedTokens>0&&i.jsxs("span",{children:[xd(j.estimatedTokens)," tokens"]})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[T&&i.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"..."}),i.jsx(Xr,{enabled:!N,onClick:()=>b(j.name,!N)})]})]})},j.name)})}),i.jsx("div",{className:"border-t border-border px-3 py-2 flex-shrink-0",children:u?i.jsx("div",{className:"text-xs text-accent-error",children:u}):i.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," server(s) configured"]})})]})]})}function $7(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return null;const a=n.slice(r+1);return a.includes(" ")||a.includes(`
|
|
319
|
+
`)||a.includes(" ")?null:{query:a,startIndex:r}}const z7=E.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},l){const u=$7(t,n),[c,d]=E.useState([]),[h,p]=E.useState(!1),[m,x]=E.useState(0),y=E.useRef(null),w=E.useRef([]),C=E.useRef(0),_=E.useRef([]);E.useEffect(()=>{C.current=m},[m]),E.useEffect(()=>{_.current=c},[c]),E.useEffect(()=>{if(!u){d([]);return}const b=setTimeout(()=>{S(u.query)},150);return()=>clearTimeout(b)},[u==null?void 0:u.query,r]);const S=async b=>{p(!0);try{const j=new URLSearchParams({q:b});r&&j.set("workdir",r);const T=await(await ye(`/api/files?${j.toString()}`)).json();d(T),x(0),C.current=0}catch(j){console.error("File search failed:",j),d([])}finally{p(!1)}},v=E.useCallback(b=>{if(!u)return!1;switch(b.key){case"ArrowDown":return b.preventDefault(),x(j=>{var T;const N=Math.min(j+1,_.current.length-1);return w.current[N]&&((T=w.current[N])==null||T.scrollIntoView({block:"nearest"})),N}),C.current=Math.min(C.current+1,_.current.length-1),!0;case"ArrowUp":return b.preventDefault(),x(j=>{var T;const N=Math.max(j-1,0);return w.current[N]&&((T=w.current[N])==null||T.scrollIntoView({block:"nearest"})),N}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const j=_.current;return j[C.current]?(b.preventDefault(),a(j[C.current],u.startIndex),!0):!1}case"Escape":return b.preventDefault(),d([]),!0}return!1},[u,a]);return E.useImperativeHandle(l,()=>({handleKeyDown:v}),[v]),E.useEffect(()=>{if(!u)return;const b=j=>{y.current&&!y.current.contains(j.target)&&d([])};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[u]),u?h?i.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:i.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:i.jsx("div",{className:"p-4 text-center",children:i.jsx(gi,{size:"sm"})})})}):c.length===0?null:i.jsx("div",{ref:y,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:i.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64 overflow-y-auto",children:i.jsx("ul",{children:c.map((b,j)=>i.jsxs("li",{ref:N=>{w.current[j]=N},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&&a(b,u.startIndex)},children:[b.type==="directory"?i.jsx(Nr,{className:"w-4 h-4 shrink-0"}):i.jsx("span",{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"truncate",children:b.path})]},b.path))})})}):null});function H7(e,t){const n=e.slice(0,t);if(n.length===0||n[0]!=="/")return null;const r=n.slice(1);return r.includes(" ")||r.includes(`
|
|
320
|
+
`)||r.includes(" ")?null:{query:r,startIndex:0}}const U7=E.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:l},u){const c=H7(t,n),[d,h]=E.useState(0),p=E.useRef(null),m=E.useRef([]),x=E.useRef(0),y=E.useRef([]);E.useEffect(()=>{x.current=d},[d]),E.useEffect(()=>{y.current=C});const w=(c==null?void 0:c.query)??"",C=(()=>{if(!c)return[];const S=w.toLowerCase(),v=r.filter(j=>j.id.toLowerCase().includes(S)||j.name.toLowerCase().includes(S)).map(j=>({type:"workflow",id:j.id,name:j.name,paramCount:(j.parameters??[]).length})),b=a.filter(j=>j.id.toLowerCase().includes(S)||j.name.toLowerCase().includes(S)).map(j=>({type:"command",id:j.id,name:j.name,paramCount:0}));return[...v,...b]})();E.useEffect(()=>{h(0),x.current=0},[C.length]);const _=E.useCallback(S=>{if(!c||C.length===0)return!1;switch(S.key){case"ArrowDown":return S.preventDefault(),h(v=>{var j;const b=Math.min(v+1,C.length-1);return(j=m.current[b])==null||j.scrollIntoView({block:"nearest"}),b}),!0;case"ArrowUp":return S.preventDefault(),h(v=>{var j;const b=Math.max(v-1,0);return(j=m.current[b])==null||j.scrollIntoView({block:"nearest"}),b}),!0;case"Enter":case"Tab":{const v=C[x.current];return v?(S.preventDefault(),l(v,c.startIndex),!0):!1}case"Escape":return S.preventDefault(),!0}return!1},[c,C,l]);return E.useImperativeHandle(u,()=>({handleKeyDown:_}),[_]),!c||C.length===0?null:i.jsx("div",{ref:p,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:i.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64 overflow-y-auto",children:i.jsx("div",{children:C.map((S,v)=>i.jsxs("button",{ref:b=>{m.current[v]=b},role:"option","aria-selected":v===d,className:`w-full text-left px-3 py-2 flex items-center gap-2 text-sm ${v===d?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{c&&l(S,c.startIndex)},children:[i.jsxs("span",{className:`font-medium ${S.type==="workflow"?"text-accent-primary":"text-accent-warning"}`,children:["/",S.id]}),i.jsx("span",{className:"truncate flex-1",children:S.name}),S.paramCount>0&&i.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:[S.paramCount," param",S.paramCount>1?"s":""]})]},`${S.type}-${S.id}`))})})})});function F7({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollContainerRef:d,sessionId:h,showHistory:p,history:m,selectedIndex:x,openHistory:y,closeHistory:w,navigateUp:C,navigateDown:_,selectCurrent:S,isAutoScrollActive:v,setAutoScroll:b,onOpenMessageSearch:j,onOpenCommandsModal:N,onOpenWorkflowsModal:T,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:L,onSendCommand:I,clearInput:M}){const G=E.useRef(null),U=E.useRef(null),R=E.useRef(0),H=E.useRef(0),W=E.useRef(null),V=E.useRef(null),ee=Nd(),X=Le(ie=>ie.stopGeneration),$=Le(ie=>ie.cancelQueued),O=Le(ie=>ie.queuedMessages),B=Le(ie=>ie.restoredInput),q=Le(ie=>ie.clearRestoredInput),z=Le(ie=>{var me;return(me=ie.currentSession)==null?void 0:me.workdir}),re=Le(ie=>ie.currentSession),ne=E.useRef(!1),J=E.useRef(!1),K=E.useRef(!1),[P,Q]=E.useState([]),{sendMessage:ae,launchWorkflow:he}=kj(b);E.useEffect(()=>{if(J.current)return;J.current=!0;const ie=vt.getState();ie.defaults.length===0&&ie.userItems.length===0&&ie.projectItems.length===0&&ie.fetchWorkflows();const me=Xt.getState();me.defaults.length===0&&me.userItems.length===0&&me.projectItems.length===0&&me.fetchCommands()},[]),E.useEffect(()=>{e||Q([])},[e]),E.useEffect(()=>{var ie;B!==null&&(t(B),q(),(ie=G.current)==null||ie.focus())},[B,t,q]);const ce=E.useCallback(()=>{const ie=G.current;if(!ie)return;const me=e.length>=R.current;R.current=e.length,me||(ie.style.height="auto"),ie.style.height=`${Math.min(200,ie.scrollHeight)}px`},[e]);E.useEffect(()=>{if(!h)return;const ie=`openfox:draft:${h}`,me=localStorage.getItem(ie);me!==null&&t(me)},[h,t]),E.useEffect(()=>{var ie;(ie=G.current)==null||ie.focus(),ce()},[h,ce]),E.useEffect(()=>{if(!h)return;const ie=`openfox:draft:${h}`,me=setTimeout(()=>{e?localStorage.setItem(ie,e):localStorage.removeItem(ie)},500);return()=>clearTimeout(me)},[h,e]),E.useEffect(()=>{ce()},[e,ce]),E.useEffect(()=>{const ie=G.current;if(!ie)return;const me=async Ue=>{var ct;if(document.activeElement!==ie)return;const Ie=(ct=Ue.clipboardData)==null?void 0:ct.items;if(!Ie)return;const Ke=[];for(const et of Array.from(Ie)){let tt=et.getAsFile();if(tt&&v$(tt.type)){if(Ue.preventDefault(),!tt.name){const ot=b$(tt.type);tt=new File([tt],`pasted-file.${ot}`,{type:tt.type})}await t1(tt,ot=>Ke.push(ot),c)}}Ke.length>0&&r(et=>[...et,...Ke])};return ie.addEventListener("paste",me),()=>ie.removeEventListener("paste",me)},[r,c]);const De=ie=>{ie.preventDefault(),!(!e.trim()&&n.length===0)&<()},Re=ie=>{var me,Ue;if(!((me=V.current)!=null&&me.handleKeyDown(ie))&&!((Ue=W.current)!=null&&Ue.handleKeyDown(ie))){if(p)switch(ie.key){case"Enter":{ie.preventDefault();const Ie=S();Ie&&(t(Ie),w());return}case"Escape":ie.preventDefault(),w(),ee&&X();return;case"ArrowUp":ie.preventDefault(),C();return;case"ArrowDown":ie.preventDefault(),_();return}if(ie.key==="ArrowUp"&&e.trim()===""&&!p){ie.preventDefault(),y();return}ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),De(ie))}};async function $e(ie,me,Ue){const Ie=[];for(const Ke of Array.from(ie))await t1(Ke,ct=>Ie.push(ct),Ue);Ie.length>0&&me(Ke=>[...Ke,...Ie])}const Ge=E.useCallback(async ie=>{const me=ie.target.files;!me||me.length===0||(c(null),await $e(me,r,c),U.current&&(U.current.value=""))},[r,c]),je=E.useCallback(ie=>{var me;(me=ie.dataTransfer.types)!=null&&me.includes("Files")&&(ie.preventDefault(),ie.stopPropagation(),l(!0))},[l]),Ye=E.useCallback(ie=>{ie.preventDefault(),ie.stopPropagation(),l(!1)},[l]),at=E.useCallback(async ie=>{ie.preventDefault(),ie.stopPropagation(),l(!1),c(null);const me=ie.dataTransfer.files;!me||me.length===0||await $e(me,r,c)},[r,l,c]),ke=E.useCallback(ie=>{r(n.filter(me=>me.id!==ie))},[n,r]),ze=E.useCallback(()=>{var ie;(ie=U.current)==null||ie.click()},[]),lt=()=>{var me;if(K.current||!e.trim()&&n.length===0)return;if(K.current=!0,(me=d.current)==null||me.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),e.trim().startsWith("/")){const Ue=vt.getState(),Ie=[...Ue.defaults,...Ue.userItems,...Ue.projectItems],Ke=Xt.getState(),ct=[...Ke.defaults,...Ke.userItems,...Ke.projectItems],et=t7(e,Ie,ct);if(et!=null&&et.workflowId){const tt=Ie.find(Ct=>Ct.id===et.workflowId),ot=((tt==null?void 0:tt.parameters)??[]).filter(Ct=>Ct.required&&!(Ct.id in et.params));if(ot.length>0){const Ct=ot.map(dt=>dt.label||dt.id).join(", ");c(`Missing required parameter${ot.length>1?"s":""}: ${Ct}`),K.current=!1;return}he(void 0,void 0,et.workflowId,void 0,et.params),M(),K.current=!1;return}if(et!=null&&et.commandId){Ke.fetchCommand(et.commandId).then(tt=>{if(tt){const ot=wj(tt.prompt),Ct={};for(const[hn,yn]of Object.entries(et.params)){const Fn=parseInt(hn,10),Vn=ot[Fn];Vn&&(Ct[Vn]=yn)}let dt=tt.prompt;for(const[hn,yn]of Object.entries(Ct))dt=dt.replaceAll(`{{${hn}}}`,yn);ae(dt,void 0),M()}K.current=!1});return}M(),K.current=!1;return}ae(e,n),M(),K.current=!1},we=E.useCallback((ie,me)=>{const Ie=ie.type==="directory"?"/":" ",Ke=e.slice(0,me),ct=e.slice(H.current),et=`${Ke}@${ie.path}${Ie}${ct}`;t(et);const tt=me+ie.path.length+2;H.current=tt,G.current&&(G.current.selectionStart=tt,G.current.selectionEnd=tt,G.current.focus())},[e,t]),He=E.useCallback((ie,me)=>{const Ue=e.slice(0,me),Ie=e.slice(H.current),Ke=`${Ue}/${ie.id} ${Ie}`;t(Ke);const ct=me+ie.id.length+2;if(H.current=ct,G.current&&(G.current.selectionStart=ct,G.current.selectionEnd=ct,G.current.focus()),ie.type==="workflow"){const et=[...vt.getState().defaults,...vt.getState().userItems,...vt.getState().projectItems].find(tt=>tt.id===ie.id);Q(((et==null?void 0:et.parameters)??[]).map(tt=>tt.id))}else{const et=Xt.getState(),tt=[...et.defaults,...et.userItems,...et.projectItems].find(ot=>ot.id===ie.id);Q((tt==null?void 0:tt.paramNames)??[])}},[e,t]),Ve=E.useCallback(ie=>{const me=ie.target.value;t(me),p&&w(),H.current=ie.target.selectionStart,P.length>0&&(!me.startsWith("/")||!me.includes(" "))&&Q([]),!ne.current&&h&&me&&re&&re.messages.length===0&&(ne.current=!0,ye(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,p,w,h,re,P]),Z=E.useCallback(ie=>{H.current=ie.target.selectionStart},[]),oe=E.useCallback(ie=>{H.current=ie.currentTarget.selectionStart},[]);return i.jsxs("div",{className:"relative",children:[ee&&i.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:i.jsx(s7,{})}),i.jsxs("div",{className:`absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2 border${v?" border-transparent":" rounded backdrop-blur-xl saturate-150 border-border"}`,children:[i.jsx(ex,{isActive:v,onToggle:b,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),i.jsxs("button",{type:"button",onClick:j,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[i.jsx(Qi,{}),"Browse history"]})]}),i.jsx(i7,{}),i.jsxs("form",{onSubmit:De,className:"p-2 md:p-4 bg-secondary rounded-lg",children:[i.jsx("input",{ref:U,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:Ge,className:"hidden",multiple:!0}),u&&i.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:u}),n.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(ie=>i.jsx(n7,{attachment:ie,onRemove:ke},ie.id))}),p&&i.jsx(r7,{history:m,selectedIndex:x,onSelect:ie=>{t(ie),w()},onEscape:w,onNavigate:ie=>{ie==="up"?C():_()}}),i.jsx(w7,{messages:O,onCancel:$}),i.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:je,onDragLeave:Ye,onDrop:at,children:[i.jsxs("div",{className:"relative flex-1 min-w-0",children:[i.jsx("textarea",{id:Ok,ref:G,value:e,onChange:Ve,onKeyDown:Re,onSelect:Z,onKeyUp:oe,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),i.jsx(z7,{ref:W,text:e,cursorPos:H.current,workdir:z,onSelect:we}),i.jsx(U7,{ref:V,text:e,cursorPos:H.current,workflows:(()=>{const ie=vt.getState();return[...ie.defaults,...ie.userItems,...ie.projectItems]})(),commands:(()=>{const ie=Xt.getState();return[...ie.defaults,...ie.userItems,...ie.projectItems]})(),onSelect:He}),P.length>0&&(()=>{const ie=e.match(/\/(\w+)\s+(.*)$/),Ue=(ie?ie[2].trim().split(/\s+/):[]).filter(Boolean).length,Ie=P[Ue];return Ie?i.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[Ie,"=?"]}):null})()]}),i.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[ee&&i.jsxs("button",{type:"button",onClick:()=>X(),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[i.jsx(ug,{}),"Abort"]}),i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{type:"button",onClick:lt,disabled:!e.trim()&&n.length===0,"data-testid":"chat-send-button",className:"px-4 py-1.5 rounded-l bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"}),i.jsx(_7,{onSendCommand:I,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:L,onOpenCommandsManager:N,onOpenWorkflowsManager:T,onAttach:ze,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),i.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(T7,{}),i.jsx(A7,{})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[Ft(ie=>ie.settings)[Te.FEATURES_PER_SESSION_MCP]==="true"&&i.jsx(B7,{}),i.jsx(P7,{})]})]})]})]})}function i1({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[l,u]=E.useState({}),c=[...t].sort((p,m)=>(p.position??0)-(m.position??0)),d=()=>{var m;const p={};for(const x of c){const y=(m=l[x.id])==null?void 0:m.trim();y&&(p[x.id]=y)}n(p)},h=c.every(p=>{var m;return!p.required||(((m=l[p.id])==null?void 0:m.trim())??"")!==""});return i.jsxs(jt,{isOpen:!0,onClose:r,title:`Run: ${e}`,size:"sm",closeOnEscape:!0,closeOnBackdropClick:!0,children:[i.jsx("div",{className:"space-y-3 py-2",children:c.map(p=>i.jsxs("label",{className:"block",children:[i.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[p.label||p.id,p.required&&i.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),p.description&&i.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:p.description}),i.jsx("input",{value:l[p.id]??"",onChange:m=>u(x=>({...x,[p.id]:m.target.value})),placeholder:p.label||p.id,className:"mt-1 w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:p.position===0||p===c[0]})]},p.id))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border",children:[i.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm text-text-muted hover:text-text-primary transition-colors",children:"Cancel"}),i.jsx("button",{onClick:d,disabled:!h,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a})]})]})}const a1=9999,Vu=E.forwardRef(function({trigger:t,children:n},r){const[a,l]=E.useState(!1),u=E.useRef(null),c=E.useRef(null),d=E.useRef(null),h=E.useCallback(()=>{l(!1)},[]);E.useImperativeHandle(r,()=>({close:h}),[h]);const p=E.useCallback(m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a?h():(d.current=document.activeElement,l(!0))),m.key==="Escape"&&a&&h()},[a,h]);return E.useEffect(()=>{var w;if(!a){(w=d.current)==null||w.focus(),d.current=null;return}const m=C=>{c.current&&!c.current.contains(C.target)&&u.current&&!u.current.contains(C.target)&&h()},x=C=>{C.key==="Escape"&&h()},y=()=>h();return document.addEventListener("mousedown",m),document.addEventListener("keydown",x),window.addEventListener("blur",y),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",x),window.removeEventListener("blur",y)}},[a,h]),i.jsxs(i.Fragment,{children:[i.jsx("span",{ref:u,role:"button",tabIndex:0,"aria-expanded":a,className:"inline-flex cursor-pointer text-text-muted hover:text-text-primary transition-colors outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/50 rounded",onClick:()=>{a||(d.current=document.activeElement),l(m=>!m)},onKeyDown:p,children:t}),a&&pi.createPortal(i.jsx("div",{ref:c,role:"dialog","aria-modal":"true",className:"fixed bg-bg-secondary border border-border rounded-lg shadow-xl p-3 w-[320px] max-w-[calc(100vw-16px)] max-h-[60vh] overflow-y-auto",style:(()=>{if(!u.current)return{zIndex:a1,top:0,left:0};const m=u.current.getBoundingClientRect(),x=320,y=8;let w=m.left;return w+x>window.innerWidth-y&&(w=m.right-x),w=Math.max(y,Math.min(w,window.innerWidth-x-y)),{zIndex:a1,top:m.bottom+4,left:w}})(),children:n}),document.body)]})});function V7({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=Gk.filter(r=>(t.get(r)??0)>0);return n.length===0?i.jsx("span",{className:"text-text-muted text-sm",children:"None"}):i.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:n.map(r=>i.jsxs("span",{className:"flex items-center gap-0.5",children:[i.jsx(bo,{status:r}),i.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function W7({visible:e}){const t=Le(P=>P.currentSession),n=Rn(P=>P.status),r=Rn(P=>P.config),a=Rn(P=>P.start),l=Le(P=>P.contextState),u=Le(P=>P.queueUpdate),c=Rn(P=>P.logs),{branch:d,diff:h}=Jg(),[p,m]=E.useState(!1),[x,y]=E.useState(!1),[w,C]=E.useState(!1),[_,S]=E.useState(null),[v,b]=E.useState(!1),[j,N]=E.useState(!1),T=E.useRef(null),D=E.useRef(null),L=E.useRef(null),I=E.useRef(null),M=Ft(P=>P.settings[Te.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!t)return null;const G=t.workspace?t.workspace.split("/").pop()??"original":"original",U=t.workspace??t.workdir,R=t.metadataEntries??{},H=R.criteria??[],W=["review_findings","todos"],V=W.filter(P=>{var Q;return P in R&&(((Q=R[P])==null?void 0:Q.length)??0)>0}),ee=Object.keys(R).filter(P=>P!=="criteria"&&!W.includes(P)).filter(P=>{var Q;return(((Q=R[P])==null?void 0:Q.length)??0)>0}),X=[...V,...ee].reduce((P,Q)=>{var ae;return P+(((ae=R[Q])==null?void 0:ae.length)??0)},0),$=[...V,...ee].map(io),O=h.files,B=O.reduce((P,Q)=>P+Q.additions,0),q=O.reduce((P,Q)=>P+Q.deletions,0),z=(n==null?void 0:n.state)??"off",re=z==="running"||z==="warning",ne=r!==null,J=P=>{P.stopPropagation(),a()},K=P=>{P.stopPropagation(),n!=null&&n.url&&window.open(n.url,"_blank")};return i.jsxs("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:[i.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:items-center sm:justify-between gap-x-2 gap-y-1 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-1 min-w-0 sm:shrink-0",children:[i.jsx(Nr,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:G}),i.jsx("span",{className:"text-text-muted",children:"/"}),i.jsx(Yi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:d??"-"}),O.length>0?i.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",B," -",q]}):i.jsx("span",{className:"shrink-0"}),i.jsx(Vu,{ref:I,trigger:i.jsx(dn,{className:"w-3 h-3"}),children:i.jsx(oj,{workspaceName:G,branch:d,workdir:U,showEditorLink:M,sessionId:t.id,projectId:t.projectId,onEditWorkspace:()=>{var P;(P=I.current)==null||P.close(),b(!0)},onEditBranch:()=>{var P;(P=I.current)==null||P.close(),N(!0)}})})]}),i.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),i.jsxs("div",{className:"flex-1 flex items-center sm:justify-center justify-self-end gap-1 min-w-0",children:[i.jsx(V7,{entries:H}),X>0&&i.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:$.join(", "),children:["+",X]}),i.jsx(Vu,{ref:L,trigger:i.jsx(dn,{className:"w-3 h-3"}),children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("button",{onClick:()=>{var P;(P=L.current)==null||P.close(),S("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(vd,{entries:H,title:"Acceptance Criteria"})}),i.jsx(Yk,{entries:H,sessionId:t.id})]}),[...V,...ee].map(P=>{const Q=R[P];return i.jsxs("div",{children:[i.jsx("button",{onClick:()=>{var ae;(ae=L.current)==null||ae.close(),S(P)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(vd,{entries:Q,title:io(P)})}),i.jsx(qk,{entries:Q})]},P)})]})})]}),i.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),i.jsx("div",{className:"col-span-2 border-t border-border sm:hidden -mx-4"}),i.jsx("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:l&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:l.currentTokens>=1e3?`${Math.round(l.currentTokens/1e3)}K`:l.currentTokens}),i.jsx(nx,{percent:Math.round(l.currentTokens/l.maxTokens*100),dangerZone:l.dangerZone,size:"sm"}),i.jsx(Vu,{ref:D,trigger:i.jsx(dn,{className:"w-3 h-3"}),children:i.jsx(cj,{onUpdateSystemPrompt:()=>{var P;(P=D.current)==null||P.close(),C(!0)}})})]})}),i.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0 justify-self-end",children:[i.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${z==="running"?"bg-accent-success":z==="warning"?"bg-accent-warning":z==="error"?"bg-accent-error":"bg-text-muted"}`}),ne?re?i.jsx("button",{onClick:K,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Open dev server",children:i.jsx(R1,{className:"w-3.5 h-3.5"})}):i.jsx("button",{onClick:J,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Start dev server",children:i.jsx(O1,{className:"w-3.5 h-3.5"})}):i.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),i.jsx(Vu,{ref:T,trigger:i.jsx(dn,{className:"w-3 h-3"}),children:i.jsx(Jk,{workdir:U,compact:!0,onExpand:()=>m(!0),onConfigure:()=>{var P;(P=T.current)==null||P.close(),y(!0)}})})]})]}),p&&i.jsx(tx,{title:"Dev Server Logs",logs:c,onClose:()=>m(!1)}),x&&i.jsx(Xk,{isOpen:!0,onClose:()=>y(!1)}),_&&t&&i.jsx(Kk,{isOpen:!0,onClose:()=>S(null),entries:R[_]??[],sessionId:t.id,metadataKey:_,title:io(_)}),v&&i.jsx(ij,{isOpen:!0,onClose:()=>b(!1),projectId:t.projectId,sessionId:t.id,currentWorkspace:G,currentBranch:d}),j&&i.jsx(aj,{isOpen:!0,onClose:()=>N(!1),sessionId:t.id}),w&&l&&i.jsx(rx,{isOpen:!0,onClose:()=>C(!1),isRunning:t.isRunning,onApply:()=>{t.isRunning?u():Lt.send("context.applyDynamic",{}),C(!1)}})]})}function G7(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function Nj(e,t=[]){const n=new Map,r=new Map;for(const h of t)h.type==="message"?n.set(h.message.id,h):h.type==="subagent"&&r.set(h.subAgentId,h);const a=[];let l,u=1,c=null;const d=()=>{if(!c||c.size===0)return;const h=new Map;let p=0;for(const x of e)x.role!=="tool"&&x.contextWindowId===l&&(x.subAgentId&&!h.has(x.subAgentId)&&h.set(x.subAgentId,p),p++);const m=[...c.entries()].sort((x,y)=>(h.get(x[0])??0)-(h.get(y[0])??0));for(const[x,y]of m){const w=r.get(x);(w==null?void 0:w.type)==="subagent"&&w.messages.length===y.messages.length&&w.messages.every((_,S)=>_===y.messages[S])?a.push(w):a.push({type:"subagent",subAgentId:x,subAgentType:y.subAgentType,messages:y.messages})}c=null};for(let h=0;h<e.length;h++){const p=e[h];if(p.role!=="tool")if(p.contextWindowId&&l&&p.contextWindowId!==l&&(d(),u++,a.push({type:"context-divider",windowSequence:u})),l=p.contextWindowId,p.subAgentId&&p.subAgentType){c||(c=new Map);let m=c.get(p.subAgentId);m||(m={subAgentType:p.subAgentType,messages:[]},c.set(p.subAgentId,m)),m.messages.push(p)}else{d();const m=n.get(p.id);(m==null?void 0:m.type)==="message"&&m.message===p?a.push(m):a.push({type:"message",message:p})}}return d(),a}const q7=10,K7=150;function Y7(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 X7(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,q7).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:cB(r.timestamp),trimmedContent:yd(r.content,K7),sessionId:r.sessionId,sessionName:r.sessionName}))}function Q7(e,t,n){const r=[],a=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of a)r.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:n??"",sessionName:"This session"});for(const l of t)n&&l.id===n||r.push(...Y7(l));return X7(r)}function J7(e,t=[],n=null){const[r,a]=E.useState(0),[l,u]=E.useState(!1),c=E.useMemo(()=>Q7(e,t,n),[e,t,n]),d=E.useCallback(()=>{c.length>0&&(a(c.length-1),u(!0))},[c.length]),h=E.useCallback(()=>{u(!1),a(0)},[]),p=E.useCallback(()=>{a(y=>c.length===0?y:y===0?c.length-1:y-1)},[c.length]),m=E.useCallback(()=>{a(y=>c.length===0?y:y===c.length-1?0:y+1)},[c.length]),x=E.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:h,navigateUp:p,navigateDown:m,selectCurrent:x}}E.memo(function({item:t}){const[n,r]=E.useState(!1);return t.type==="start"?i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[i.jsx("span",{className:"animate-pulse",children:"●"}),i.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&i.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):i.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[i.jsx("span",{className:"text-accent-success",children:"✓"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),i.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&i.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:i.jsx(Hn,{content:t.description})})]})]})});function Z7({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r}={}){const a=e??!0,[l,u]=E.useState(""),[c,d]=E.useState([]),[h,p]=E.useState(!1),[m,x]=E.useState(null),[y,w]=E.useState(!1),[C,_]=E.useState(!1),[S,v]=E.useState(!1),[b,j]=E.useState(!1),[N,T]=E.useState(null),D=E.useRef(null),L=Le(Z=>Z.currentSession),I=Le(Z=>Z.messages),M=Le(Z=>Z.sessions),G=Nd(),U=Le(Z=>Z.stopGeneration),R=n??I,{maxVisibleItems:H}=ea(),W=xt(Z=>Z.defaults),V=xt(Z=>Z.userItems),ee=[...W,...V].filter(Z=>!Z.subagent),{history:X,selectedIndex:$,showHistory:O,openHistory:B,closeHistory:q,navigateUp:z,navigateDown:re,selectCurrent:ne}=J7(R,M,L==null?void 0:L.id);E.useEffect(()=>{const Z=oe=>{T(oe.detail.stats)};return window.addEventListener("open-turn-stats",Z),()=>window.removeEventListener("open-turn-stats",Z)},[]),E.useEffect(()=>{vt.getState().fetchWorkflows()},[]),E.useEffect(()=>{const Z=oe=>{G7(oe)&&(oe.preventDefault(),j(!0))};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[]);const J=E.useRef([]),{displayItems:K,hiddenCount:P}=E.useMemo(()=>{const Z=Nj(R,J.current);return J.current=Z,H>0&&Z.length>H?{displayItems:Z.slice(-H),hiddenCount:Z.length-H}:{displayItems:Z,hiddenCount:0}},[R,H]),Q=r??P,{isAutoScrollActive:ae,setAutoScroll:he}=eh(D,L),{sendMessage:ce,launchWorkflow:De}=kj(he),[Re,$e]=E.useState(null),[Ge,je]=E.useState(null),Ye=E.useCallback((Z,oe,ie)=>{const me=vt.getState(),Ie=[...me.defaults,...me.userItems,...me.projectItems].find(ct=>ct.id===Z);((Ie==null?void 0:Ie.parameters)??[]).filter(ct=>ct.position!==void 0||ct.required).length>0?$e({id:Z,name:(Ie==null?void 0:Ie.name)??Z,subGroup:oe}):De(void 0,void 0,Z,oe,ie)},[De]),at=E.useCallback((Z,oe,ie)=>{Ye(Z,oe,ie)},[Ye]),ke=E.useCallback(Z=>{he(!1);const oe=document.querySelector(`[data-item-index="${Z}"]`);oe&&oe.scrollIntoView({behavior:"smooth",block:"center"})},[he]);E.useEffect(()=>{const Z=oe=>{const ie=S||y||C||b||N;oe.key==="Escape"&&G&&!ie&&U(),oe.key==="ScrollLock"&&he(!ae)};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[G,U,ae,S,y,C,b,N]);const ze=Ql();Pl(ze.quickAction,()=>{v(!0)}),Pl(ze.criteriaSidebar,()=>{t==null||t()}),jT(ze.agentSwitching,ee,Z=>{Le.getState().switchMode(Z)});const lt=Z=>{Ye(Z),He()},we=(Z,oe)=>{Ye(Z,oe),He()},He=()=>{u(""),d([]),L!=null&&L.id&&localStorage.removeItem(`openfox:draft:${L.id}`)},Ve=E.useCallback(async(Z,oe,ie,me)=>{const Ue=wj(Z);if(Ue.length>0)je({prompt:Z,paramKeys:Ue,agentMode:oe,textareaContent:ie,attachments:me});else{oe&&(L==null?void 0:L.mode)!==oe&&await Le.getState().switchMode(oe);const Ie=ie&&ie.trim()?`${ie.trim()}
|
|
321
|
+
|
|
322
|
+
${Z}`:Z;ce(Ie,me!=null&&me.length?me:void 0,{messageKind:"command",isSystemGenerated:!0}),He()}},[ce,He,L]);return i.jsxs(i.Fragment,{children:[i.jsxs(S8,{criteriaSidebarOpen:a,onCriteriaSidebarToggle:t,messages:R,children:[i.jsx(W7,{visible:!a}),i.jsx(w8,{}),N&&i.jsx(C8,{stats:N,onClose:()=>T(null)}),i.jsx(L$,{}),i.jsx(T$,{displayItems:K,scrollContainerRef:D,highlightedMessageId:null,onLaunchWorkflow:at,onScrollToTop:()=>he(!1),hiddenCount:Q}),i.jsx(F7,{input:l,setInput:u,attachments:c,setAttachments:d,dragOver:h,setDragOver:p,errorMessage:m,setErrorMessage:x,scrollContainerRef:D,sessionId:L==null?void 0:L.id,showHistory:O,history:X,selectedIndex:$,openHistory:B,closeHistory:q,navigateUp:z,navigateDown:re,selectCurrent:ne,isAutoScrollActive:ae,setAutoScroll:he,onOpenMessageSearch:()=>j(!0),onOpenCommandsModal:()=>w(!0),onOpenWorkflowsModal:()=>_(!0),onSelectWorkflow:lt,onSelectWorkflowWithSubGroup:we,onSendCommand:Ve,clearInput:He}),i.jsx(yj,{isOpen:y,onClose:()=>w(!1)}),i.jsx(_j,{isOpen:C,onClose:()=>_(!1)}),i.jsx(W$,{isOpen:S,onClose:()=>v(!1),onSearchMessages:()=>j(!0),isAutoScrollActive:ae,onToggleAutoScroll:he,textareaContent:l,onCloseComplete:Kl,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(Z,oe)=>{const ie=await Xt.getState().fetchCommand(Z);ie&&Ve(ie.prompt,ie.metadata.agentMode,oe)},onSelectWorkflow:Z=>{Ye(Z),He()}}),Re&&i.jsx(i1,{workflowName:Re.name,parameters:(()=>{var ie;const Z=vt.getState();return((ie=[...Z.defaults,...Z.userItems,...Z.projectItems].find(me=>me.id===Re.id))==null?void 0:ie.parameters)??[]})(),onConfirm:Z=>{De(void 0,void 0,Re.id,Re.subGroup,Z),$e(null)},onCancel:()=>$e(null)}),Ge&&i.jsx(i1,{workflowName:"Command",confirmLabel:"Launch command",parameters:Ge.paramKeys.map((Z,oe)=>({id:Z,label:Z,position:oe})),onConfirm:Z=>{let oe=Ge.prompt;for(const[Ke,ct]of Object.entries(Z))oe=oe.replaceAll(`{{${Ke}}}`,ct);const{agentMode:ie,textareaContent:me,attachments:Ue}=Ge;ie&&(L==null?void 0:L.mode)!==ie&&Le.getState().switchMode(ie);const Ie=me&&me.trim()?`${me.trim()}
|
|
323
|
+
|
|
324
|
+
${oe}`:oe;ce(Ie,Ue!=null&&Ue.length?Ue:void 0,{messageKind:"command",isSystemGenerated:!0}),He(),je(null)},onCancel:()=>je(null)})]}),b&&i.jsx(e7,{isOpen:b,onClose:()=>{j(!1),Kl(!0)},displayItems:K,onNavigate:ke})]})}function e9(){var b;const[,e]=fo("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=E.useState(null),[a,l]=E.useState([]),[u,c]=E.useState(0),[d,h]=E.useState(!0),[p,m]=E.useState(null),x=async()=>{if(t){h(!0),m(null);try{const j=await ye(`/api/sessions/${t}?full=true`);if(!j.ok){m(`Failed to load session (${j.status})`),h(!1);return}const N=await j.json();r(N.session??null),l(N.messages??[]),c(N.hiddenCount??0)}catch(j){m(j instanceof Error?j.message:"Unknown error")}finally{h(!1)}}};E.useEffect(()=>{Ft.getState().getSettings([...og])},[]),E.useEffect(()=>{x()},[t]);const{showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S}=ea(),v=E.useMemo(()=>Nj(a),[a]);return d?i.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:i.jsx(gi,{})}):p?i.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:i.jsxs("div",{className:"text-center space-y-4",children:[i.jsx("div",{className:"text-red-400 text-sm",children:p}),i.jsx("button",{onClick:x,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):i.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((b=n==null?void 0:n.metadata)==null?void 0:b.title)??"Session"," — Read-only view"]}),i.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages",u>0?` (${u} older hidden)`:""]})]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("button",{onClick:x,disabled:d,className:"px-3 py-1 text-xs bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors disabled:opacity-50",children:d?"Refreshing...":"Refresh"})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto print:overflow-visible scrollbar-stable",children:[i.jsx("div",{className:"pt-4",children:i.jsx(xj,{displayItems:v,showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S})}),i.jsx("div",{className:"h-8"})]})]})}function o1({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,l]=E.useState(""),u=E.useRef(null);E.useEffect(()=>{e&&(l(""),setTimeout(()=>{var d;return(d=u.current)==null?void 0:d.focus()},100))},[e]);const c=d=>{d.preventDefault(),a.trim()&&n(a)};return i.jsx(jt,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:t?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),i.jsx(di,{ref:u,type:"password",value:a,onChange:d=>l(d.target.value),placeholder:"Enter password",autoFocus:!0}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(st,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),i.jsx(st,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function t9({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return i.jsx("div",{className:"flex justify-center py-6",children:i.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,l)=>{const u=l+1,c=u<e,d=u===e;return i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${c?"bg-accent-primary text-text-primary hover:opacity-80":d?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:c?"✓":u}),i.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${d?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[l]}),l<t-1&&i.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${c?"bg-accent-primary":"bg-border"}`})]},l)})})})}function n9({onNext:e}){const[t,n]=E.useState([]),[r,a]=E.useState([]),[l,u]=E.useState(!1),[c,d]=E.useState(null),[h,p]=E.useState(null),[m,x]=E.useState(null);E.useEffect(()=>{y()},[]);async function y(){try{const N=await ye("/api/providers");if(N.ok){const D=(await N.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,sendReasoningInMessages:L.sendReasoningInMessages,models:L.models}));n(D),a(D)}}catch{}}async function w(N){const T=N.id.startsWith("temp-"),D=r.some(M=>M.id===N.id),L=r.length===0&&c===null,I=jj(N);try{let M;if(T){const U=await ye("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)});if(!U.ok)throw new Error("Failed to create provider");const R=await U.json();M={...N,id:R.provider.id,model:null}}else{if(!(await ye(`/api/providers/${N.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)})).ok)throw new Error("Failed to update provider");M={...N,model:null}}const G=U=>U.some(R=>R.id===M.id)?U.map(R=>R.id===M.id?M:R):[...U,M];a(G),n(G),L&&!D&&e({providers:[M]})}catch{if(T){const M={...N,model:null};a(G=>[...G,M])}}}function C(){d(null),u(!0)}function _(N){d(N),u(!0)}function S(){u(!1),d(null)}function v(N){p(N),t.some(D=>D.id===N)?ye(`/api/providers/${N}`,{method:"DELETE"}).then(()=>{a(r.filter(D=>D.id!==N)),n(t.filter(D=>D.id!==N)),p(null)}).catch(()=>p(null)):(a(r.filter(D=>D.id!==N)),p(null))}function b(){const N=r.filter(T=>!T.id.startsWith("temp-"));e({providers:N})}const j=r.length>0;return i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),i.jsxs("div",{className:"space-y-4",children:[r.length>0?i.jsx("div",{className:"space-y-2",children:r.map(N=>i.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:v1(N.backend)}),i.jsx("span",{className:"text-text-primary font-medium",children:N.name}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${N.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:N.isLocal?"local":"api"})]}),i.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:N.url}),N.model&&i.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",N.model]})]}),i.jsx("div",{className:"flex items-center gap-1",children:m===N.id?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>v(N.id),disabled:h===N.id,className:"px-2 py-1 text-xs text-red-500 hover:text-red-400 bg-red-500/10 rounded transition-colors disabled:opacity-50",children:h===N.id?"Deleting...":"Confirm"}),i.jsx("button",{onClick:()=>x(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>_(N),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),i.jsx("button",{onClick:()=>x(N.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:i.jsx(ta,{})})]})})]},N.id))}):i.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:i.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),i.jsxs("button",{onClick:C,"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[i.jsx(Jr,{className:"w-4 h-4"}),"Add Provider"]}),i.jsx("button",{onClick:b,disabled:!j,"data-testid":"onboarding-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]}),i.jsx(Ej,{isOpen:l,onClose:S,onSave:w,initialStep:1,editProvider:c??void 0})]})}function r9({onNext:e}){const[t,n]=E.useState(""),[r,a]=E.useState(!1);return E.useEffect(()=>{ye("/api/config").then(l=>l.json()).then(l=>{l.workdir?n(l.workdir):fetch(Es("/api/directories?path=")+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&n(u.current)}).catch(()=>{})}).catch(()=>{fetch(Es("/api/directories?path=")+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})})},[]),i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",value:t,onChange:l=>n(l.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),i.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&i.jsx(Dd,{initialPath:t||void 0,onSelect:l=>{n(l),a(!1)},onClose:()=>a(!1)}),i.jsx("button",{onClick:()=>e({workdir:t}),disabled:!t,"data-testid":"onboarding-workdir-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function s9(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function i9(e){return E.useMemo(()=>{const t=[];for(const n of e)for(const r of n.models)r.supportsVision&&t.push({providerId:n.id,providerName:n.name,modelId:r.id,modelName:r.name??s9(r.id)});return t},[e])}function a9({value:e,options:t,onChange:n,className:r}){return i.jsxs("select",{value:e,onChange:a=>n(a.target.value),className:r??"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[i.jsx("option",{value:"",children:"Manual configuration..."}),t.map(a=>i.jsxs("option",{value:`${a.providerId}/${a.modelId}`,children:[a.providerName," • ",a.modelName]},`${a.providerId}/${a.modelId}`))]})}function o9({backend:e,url:t,model:n,onBackendChange:r,onUrlChange:a,onModelChange:l}){return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),i.jsxs("select",{value:e,onChange:u=>r(u.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[i.jsx("option",{value:"ollama",children:"Ollama"}),i.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),i.jsx("input",{type:"text",value:t,onChange:u=>a(u.target.value),placeholder:e==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),i.jsx("input",{type:"text",value:n,onChange:u=>l(u.target.value),placeholder:e==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]})}function l9(e,t,n,r){return a=>{e(a),t(""),a==="ollama"?(n("http://localhost:11434"),r("qwen3.5:0.8b")):(n("http://localhost:8000/v1"),r("qwen3.5-27b"))}}function c9(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function u9({enabled:e,hasOptions:t,selectedRef:n,visionModelOptions:r,onProviderModelSelect:a,backend:l,url:u,model:c,onBackendChange:d,onUrlChange:h,onModelChange:p,noOptionsMessage:m,children:x}){return e?i.jsxs("div",{className:"space-y-4 pl-8",children:[t?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model from your providers"}),i.jsx(a9,{value:n,options:r,onChange:a})]}):i.jsx("p",{className:"text-sm text-text-muted italic",children:m}),i.jsx(o9,{backend:l,url:u,model:c,onBackendChange:d,onUrlChange:h,onModelChange:p}),x]}):null}function d9({onNext:e}){const[t,n]=E.useState(!1),[r,a]=E.useState("http://localhost:11434"),[l,u]=E.useState("qwen3.5:0.8b"),[c,d]=E.useState("ollama"),[h,p]=E.useState([]),[m,x]=E.useState(""),{copied:y,copy:w}=Nk();E.useEffect(()=>{ye("/api/config").then(N=>N.json()).then(N=>{N.visionFallback&&(n(N.visionFallback.enabled),N.visionFallback.providerModelRef?x(N.visionFallback.providerModelRef):(a(N.visionFallback.url??"http://localhost:11434"),u(N.visionFallback.model??"qwen3.5:0.8b"),N.visionFallback.backend&&d(N.visionFallback.backend))),N.providers&&p(N.providers)}).catch(()=>{})},[]);const C=i9(h),_=c9(x,a,u),S=l9(d,x,a,u);function v(N){if(N){e({});return}e(t&&m?{visionFallback:{enabled:t,providerModelRef:m,timeout:120}}:{visionFallback:{enabled:t,url:r,model:l,timeout:120,backend:c,providerModelRef:""}})}const b=C.length>0;return i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),i.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),i.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),i.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[i.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),i.jsx("button",{onClick:()=>w("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:y?i.jsx($r,{className:"w-4 h-4 text-accent-primary"}):i.jsx(uT,{className:"w-4 h-4"})})]}),i.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",i.jsx("strong",{children:"OpenAI"})," backend type."]})]}),i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t,onChange:N=>n(N.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),i.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),i.jsx(u9,{enabled:t,hasOptions:b,selectedRef:m,visionModelOptions:C,onProviderModelSelect:_,backend:c,url:r,model:l,onBackendChange:S,onUrlChange:a,onModelChange:u,noOptionsMessage:"No vision-capable models found in your providers. You can manually enter a model below."}),i.jsxs("div",{className:"flex items-center justify-between pt-4",children:[i.jsx("button",{onClick:()=>v(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),i.jsx("button",{onClick:()=>v(!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 h9({onComplete:e}){const[t,n]=E.useState(1),[r,a]=E.useState(!1),[l,u]=E.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 h(m){a(!0);try{if(!(await ye("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:l.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),a(!1)}}const p=m=>{n(m)};return i.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[i.jsx(ac,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),i.jsx(t9,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),i.jsx("div",{className:"max-w-xl mx-auto",children:r?i.jsxs("div",{className:"text-center",children:[i.jsx(Jr,{className:"w-6 h-6"}),i.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):i.jsxs(i.Fragment,{children:[t===1&&i.jsx(n9,{onNext:c}),t===2&&i.jsx(r9,{onNext:d}),t===3&&i.jsx(d9,{onNext:h})]})})]})}function f9({projectId:e}){var p;const[,t]=Tn(),n=Le(m=>m.sessionsWithPendingConfirmations),r=Le(m=>{var x;return(x=m.currentSession)==null?void 0:x.id}),a=Le(m=>m.crossSessionConfirmations),l=Le(m=>m.sessions),u=n.find(m=>m!==r);if(!u)return null;const c=l.find(m=>m.id===u),d=(c==null?void 0:c.title)??u.slice(0,6),h=((p=a[u])==null?void 0:p.length)??0;return i.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 cursor-pointer hover:bg-amber-500/20 transition-colors",onClick:()=>t(e?`/p/${e}/s/${u}`:`/s/${u}`),role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&t(e?`/p/${e}/s/${u}`:`/s/${u}`)},children:[i.jsx(cg,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),i.jsxs("span",{className:"text-sm text-amber-300 flex-1 truncate",children:[h," confirmation",h>1?"s":"",' pending in session "',d,'"']}),i.jsx("span",{className:"text-xs text-amber-400 font-medium flex-shrink-0",children:"View session →"})]})}const xp="openfox_updated_to",yp="update_pending";function m9(){const[e,t]=E.useState(!1),n=localStorage.getItem(xp),r=localStorage.getItem(yp);E.useEffect(()=>{if(!n||!r)return;const l=setTimeout(()=>{localStorage.removeItem(xp),localStorage.removeItem(yp),t(!0)},8e3);return()=>clearTimeout(l)},[n,r]);const a=()=>{localStorage.removeItem(xp),localStorage.removeItem(yp),t(!0)};return e||r!=="true"||!n?null:i.jsxs("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 bg-bg-secondary border border-border rounded-lg shadow-xl animate-slide-down",role:"status","aria-live":"polite",children:[i.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:i.jsx($r,{className:"w-3 h-3 text-accent-primary"})}),i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),i.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),i.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:i.jsx(dg,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Bt.getState().loadUserPresets(),Bt.getState().applySavedTheme());function lx(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function Tj(){return i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx(gi,{})})}function p9({sidebarOpen:e,onSidebarToggle:t}){const[,n]=fo("/p/:projectId"),r=n==null?void 0:n.projectId,a=Le(d=>d.connectionStatus),l=Wt(d=>d.currentProject),u=lx();return sT({canLoad:a==="connected"||u,projectId:r,currentProjectId:l==null?void 0:l.id}),!l||l.id!==r?i.jsx(Tj,{}):i.jsxs(i.Fragment,{children:[i.jsx(Fk,{projectId:r,isOpen:e,onClose:t}),i.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:i.jsx(kB,{})})]})}function g9({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=fo("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,c]=Tn(),d=Le(C=>C.connectionStatus),h=Le(C=>C.currentSession),p=Le(C=>C.error),m=Le(C=>C.clearError),x=Wt(C=>C.currentProject),y=lx();return iT({canLoad:d==="connected"||y,projectId:l,sessionId:u,currentProjectId:x==null?void 0:x.id,currentSessionId:h==null?void 0:h.id}),E.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),c(`/p/${l}`))},[p,l,m,c]),!x||x.id!==l?i.jsx(Tj,{}):i.jsxs(i.Fragment,{children:[i.jsx(Fk,{projectId:l,isOpen:e,onClose:t}),i.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[i.jsx(f9,{projectId:l}),i.jsx(Z7,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function x9(){const e=Qt(r=>r.fetchConfig),[,t]=Tn();async function n(){await e(),t("/")}return i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsx(h9,{onComplete:n})})}function y9(){const{connectionStatus:e}=JN(),t=Qt(O=>O.fetchConfig),n=Qt(O=>O.refreshProviderModels),r=Qt(O=>O.providers),a=Qt(O=>O.activeProviderId),[,l]=Tn(),u=lx(),[c,d]=E.useState(!1);E.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{d(!0),Ft.getState().getSettings([...og,Te.DISPLAY_THEME,Te.DISPLAY_USER_PRESETS,Te.DISPLAY_CUSTOM_CSS,Te.KEYBINDINGS]),Il.getState().fetchServers()})},[e,u,t]),E.useEffect(()=>{c&&a&&n(a).then(()=>{const O=Qt.getState().defaultModelSelection;(O?O.split("/")[0]:null)!==a&&t()})},[c,a,n,t]);const h=Ft(O=>O.settings);E.useEffect(()=>{c&&r.length===0&&l("/onboarding")},[c,r.length]),E.useEffect(()=>{const{applyPreset:O,applyTokens:B,setFollowSystemTheme:q,initSystemThemeListener:z}=Bt.getState(),re=h[Te.DISPLAY_THEME],ne=h[Te.DISPLAY_USER_PRESETS],J=h[Te.DISPLAY_FOLLOW_SYSTEM_THEME];if(ne&&localStorage.setItem("openfox:userPresets",ne),re){localStorage.setItem("openfox:theme",re);try{const P=JSON.parse(re);P.preset&&P.tokens?(O(P.preset),Bt.setState({basePreset:P.preset}),B(P.tokens)):P.preset?O(P.preset):P.tokens&&B(P.tokens)}catch{O("dark")}}else O("system");J!==void 0&&Bt.getState().followSystemTheme!==(J==="true")&&q(J==="true");const K=z();return()=>K()},[h[Te.DISPLAY_THEME],h[Te.DISPLAY_USER_PRESETS]]),E.useEffect(()=>{const O=h[Te.DISPLAY_CUSTOM_CSS]??"";let B=document.getElementById("custom-css");B||(B=document.createElement("style"),B.id="custom-css",document.head.appendChild(B)),B.textContent=O},[h[Te.DISPLAY_CUSTOM_CSS]]);const[p,m]=E.useState(!1);E.useEffect(()=>{const O=Ft.getState().settings[Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(O===void 0||O==="false")return;let B=!1;if(localStorage.getItem("update_pending")==="true"&&(B=!0,localStorage.removeItem("update_pending")),c){const z=Qt.getState().version,re=localStorage.getItem("openfox_last_version");z&&re&&z!==re&&(B=!0),localStorage.setItem("openfox_last_version",z??"")}B&&m(!0)},[h[Te.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],c]);const x=()=>{const O=localStorage.getItem("openfox:leftSidebar");return O!==null?O==="true":!0},y=()=>{const O=localStorage.getItem("openfox:rightSidebar");return O!==null?O==="true":!0},[w,C]=E.useState(x),[_,S]=E.useState(y),[v,b]=E.useState(!1),[j,N]=E.useState(!1),[T,D]=E.useState(!1),L=EN();E.useEffect(()=>{const O=()=>{D(window.innerWidth<768)};return O(),window.addEventListener("resize",O),()=>window.removeEventListener("resize",O)},[]);const[I]=Tn(),M=/^\/p\/[^/]+$/.test(I),G=T?v:M?!0:w,U=T?j:_,R=()=>{T?b(!v):C(!w)},H=()=>{T?N(!j):S(!_)};E.useEffect(()=>{T||localStorage.setItem("openfox:leftSidebar",String(w))},[w,T]),E.useEffect(()=>{T||localStorage.setItem("openfox:rightSidebar",String(_))},[_,T]),E.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const W=Le(O=>O.showPasswordModal),V=Le(O=>O.passwordModalRetry),ee=Le(O=>O.submitPassword),X=Le(O=>O.cancelPassword),[$]=fo("/p/:projectId/s/:sessionId/readonly");return!$&&e!=="connected"&&!W&&!u?i.jsxs(i.Fragment,{children:[i.jsx(o1,{isOpen:!0,isRetry:V,onSubmit:ee,onCancel:X}),i.jsx("div",{className:"h-screen flex items-center justify-center",children:i.jsx(OT,{text:"Connecting to server..."})})]}):$?i.jsx(e9,{}):i.jsxs(i.Fragment,{children:[i.jsx(o1,{isOpen:W,isRetry:V,onSubmit:ee,onCancel:X}),i.jsxs("div",{className:"flex flex-col",style:{height:T?`calc(${L.offsetTop}px + ${L.height}px)`:"100vh"},children:[i.jsx(_B,{}),i.jsx(fB,{onMenuClick:R,onCriteriaToggle:H}),i.jsx("div",{className:"flex-1 flex overflow-hidden",children:i.jsxs(SN,{children:[i.jsx(dl,{path:"/onboarding",children:i.jsx(x9,{})}),i.jsx(dl,{path:"/p/:projectId/s/:sessionId",children:i.jsx(g9,{sidebarOpen:G,onSidebarToggle:R,rightSidebarOpen:U,onRightSidebarToggle:H})}),i.jsx(dl,{path:"/p/:projectId/new",children:i.jsx(CB,{})}),i.jsx(dl,{path:"/p/:projectId",children:i.jsx(p9,{sidebarOpen:G,onSidebarToggle:R})}),i.jsx(dl,{path:"/",children:i.jsx(wB,{})})]})})]}),i.jsx(m9,{}),i.jsx(Tk,{isOpen:p,onClose:()=>m(!1)})]})}tN.createRoot(document.getElementById("root")).render(i.jsx(oi.StrictMode,{children:i.jsx(g1,{base:y1,children:i.jsx(y9,{})})}));
|