openfox 2.0.113 → 2.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/CHANGELOG.md +22 -0
  3. package/dist/agent-defaults/builder.agent.md +1 -0
  4. package/dist/agent-defaults/planner.agent.md +1 -0
  5. package/dist/{backend-P3GHHLHJ.js → backend-LVYHLGQJ.js} +2 -2
  6. package/dist/{chat-handler-PEK5JDHO.js → chat-handler-KWXRSWXZ.js} +31 -25
  7. package/dist/{chunk-HKD4IMOE.js → chunk-2XD65L7M.js} +2 -2
  8. package/dist/{chunk-AZFZE36I.js → chunk-3O77NT4T.js} +17 -7
  9. package/dist/{chunk-HGOTZWON.js → chunk-7GWARYQC.js} +60 -1064
  10. package/dist/{chunk-YHEQTVFV.js → chunk-AZHWLLPP.js} +1 -1
  11. package/dist/{chunk-6UPBZ2ZR.js → chunk-BZVW77PI.js} +4 -4
  12. package/dist/{chunk-YGPPFVLJ.js → chunk-FW4NDUBL.js} +15 -15
  13. package/dist/{chunk-O2YSYW2F.js → chunk-GUHHUDNL.js} +6 -6
  14. package/dist/{chunk-WWTYWLDM.js → chunk-HP5CIB66.js} +2 -2
  15. package/dist/{chunk-ONONXV3N.js → chunk-HV6IALXF.js} +4 -4
  16. package/dist/{chunk-4NMGX5F2.js → chunk-I7FY2LTR.js} +2 -2
  17. package/dist/{chunk-Y64PEWKP.js → chunk-JP7NM545.js} +2 -2
  18. package/dist/{chunk-CP44U7BT.js → chunk-JXLRL5JR.js} +5 -5
  19. package/dist/{chunk-5VYSKVZT.js → chunk-K733B5T2.js} +254 -20
  20. package/dist/{chunk-SNLLOXCM.js → chunk-L63Q4JQJ.js} +3 -3
  21. package/dist/{chunk-43M7QZMX.js → chunk-LXYPMFTH.js} +3 -3
  22. package/dist/{chunk-TCGWZBTS.js → chunk-MUSPWEBB.js} +3 -3
  23. package/dist/chunk-NCZRWCJN.js +7 -0
  24. package/dist/{chunk-JR54MDZI.js → chunk-NLO64UE3.js} +2 -2
  25. package/dist/{chunk-3R43CMLS.js → chunk-NWJLWLKF.js} +8 -8
  26. package/dist/chunk-OSXPQSLW.js +128 -0
  27. package/dist/chunk-OTYAEEX3.js +1081 -0
  28. package/dist/{chunk-V4664YKR.js → chunk-OXSTNSCF.js} +2 -2
  29. package/dist/{chunk-R2MTWC7C.js → chunk-P5UANBBX.js} +6 -4
  30. package/dist/{chunk-PWXBIUEY.js → chunk-PBW3YC3G.js} +85 -1
  31. package/dist/{chunk-TEQEDOWI.js → chunk-QD7MRMCH.js} +245 -289
  32. package/dist/{chunk-BNFGDTEU.js → chunk-SA34STZ6.js} +2 -2
  33. package/dist/{chunk-VGRVPYZ5.js → chunk-SBSUDHL4.js} +2 -2
  34. package/dist/{chunk-XQR76MQ5.js → chunk-SFZGMB2G.js} +2 -2
  35. package/dist/{chunk-EC5T5A6O.js → chunk-TKKP56QK.js} +3 -3
  36. package/dist/{chunk-BYSUSSSC.js → chunk-UPBWEHIL.js} +30 -148
  37. package/dist/{chunk-YB6WYVNY.js → chunk-UTIQ7OO5.js} +2 -2
  38. package/dist/{chunk-EMI3YYLP.js → chunk-VPVLO436.js} +4 -4
  39. package/dist/chunk-W77NBJAZ.js +957 -0
  40. package/dist/{chunk-BKCW3JLL.js → chunk-X25Q6RAV.js} +1 -1
  41. package/dist/{chunk-FF2EKUQO.js → chunk-YGJIK3CG.js} +4 -4
  42. package/dist/cli/dev.js +1 -1
  43. package/dist/cli/index.js +1 -1
  44. package/dist/{client-3LJGD6KY.js → client-EM7ISGUP.js} +6 -6
  45. package/dist/{compactor-ZBNKANHV.js → compactor-V3LR7APW.js} +13 -12
  46. package/dist/{dynamic-context-F2XTQJR5.js → dynamic-context-MVGOF5V2.js} +10 -9
  47. package/dist/{events-224IO5NJ.js → events-PI7IMPHT.js} +8 -7
  48. package/dist/{folding-YTTTVS56.js → folding-FO57K4JM.js} +6 -5
  49. package/dist/http-client-33EZ3BLR.js +11 -0
  50. package/dist/{inspect-proxy-B7LGGTM7.js → inspect-proxy-NHKQQ2CD.js} +4 -4
  51. package/dist/launch-L5ROVNI3.js +52 -0
  52. package/dist/{manager-4QGXI6WZ.js → manager-66YAEO7K.js} +5 -5
  53. package/dist/{model-overrides-OY2YKUNV.js → model-overrides-L53PZNZA.js} +4 -4
  54. package/dist/orchestrator-XK5K3RPL.js +63 -0
  55. package/dist/package.json +3 -3
  56. package/dist/{path-security-PFMZY7IA.js → path-security-RSEI3YKB.js} +12 -11
  57. package/dist/{platform-QNGCKX4L.js → platform-WA4GK5BO.js} +4 -4
  58. package/dist/{processor-NYPJ5PFA.js → processor-WDZSFBVO.js} +30 -24
  59. package/dist/{project-creator-AWP2JUFS.js → project-creator-676WQXVI.js} +3 -3
  60. package/dist/{projects-C4353IQK.js → projects-SSBWIYL4.js} +3 -3
  61. package/dist/{protocol-CBT1d98i.d.ts → protocol-BzHs024-.d.ts} +21 -3
  62. package/dist/{protocol-LZZ7C4VQ.js → protocol-RKSWKNXI.js} +3 -3
  63. package/dist/provider/index.d.ts +4 -4
  64. package/dist/{provider-PIRPN2CC.js → provider-PLIWRBCF.js} +7 -7
  65. package/dist/{provider-manager-GNEPR6UN.js → provider-manager-2QSJTPWS.js} +7 -7
  66. package/dist/{registry-VCKDSVKA.js → registry-ZP4TN2IN.js} +5 -4
  67. package/dist/{serve-6DRHQLCG.js → serve-MZ3BCCWC.js} +35 -32
  68. package/dist/server/index.d.ts +4 -4
  69. package/dist/server/index.js +34 -31
  70. package/dist/server-EPXODFMB.js +55 -0
  71. package/dist/service-54PGIPDQ.js +25 -0
  72. package/dist/{session-overrides-RNKV35MU.js → session-overrides-LXN6W7SA.js} +7 -6
  73. package/dist/{sessions-D5CEPQGU.js → sessions-CHPVUG6H.js} +6 -5
  74. package/dist/{settings-BNRNX6IW.js → settings-NEBM3GQX.js} +3 -3
  75. package/dist/shared/index.d.ts +3 -3
  76. package/dist/shared/index.js +1 -1
  77. package/dist/skill-defaults/workflows/SKILL.md +24 -6
  78. package/dist/tasks-TJXG2V3U.js +217 -0
  79. package/dist/{tools-2B363F7L.js → tools-CIM26IFB.js} +30 -22
  80. package/dist/{types-BAxh20ZL.d.ts → types-CMtHpDWT.d.ts} +74 -1
  81. package/dist/{types-cVfqOj6M.d.ts → types-CbggXFvR.d.ts} +1 -1
  82. package/dist/{update-IQMRYN7J.js → update-UZBBO42X.js} +2 -2
  83. package/dist/web/assets/{index-CjWC6EQ4.css → index-BmILAZrT.css} +1 -1
  84. package/dist/web/assets/index-rZHXkfMq.js +324 -0
  85. package/dist/web/index.html +2 -2
  86. package/dist/web/sw.js +1 -1
  87. package/dist/workflow-defaults/default.workflow.json +5 -3
  88. package/dist/{workspace-YUNHV4WS.js → workspace-2XODU4YJ.js} +4 -4
  89. package/package.json +3 -3
  90. package/dist/chunk-B2PHPBFU.js +0 -7
  91. package/dist/http-client-YC3UA5OZ.js +0 -11
  92. package/dist/orchestrator-JKBY7B3P.js +0 -57
  93. package/dist/server-HUHFJW7U.js +0 -48
  94. package/dist/web/assets/index-DBUtUSHK.js +0 -323
@@ -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 aD=Object.defineProperty;var oD=Object.getPrototypeOf;var lD=Reflect.get;var FS=e=>{throw TypeError(e)};var cD=(e,t,n)=>t in e?aD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ae=(e,t,n)=>cD(e,typeof t!="symbol"?t+"":t,n),sg=(e,t,n)=>t.has(e)||FS("Cannot "+n);var sr=(e,t,n)=>(sg(e,t,"read from private field"),n?n.call(e):t.get(e)),_a=(e,t,n)=>t.has(e)?FS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ss=(e,t,n,r)=>(sg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ig=(e,t,n)=>(sg(e,t,"access private method"),n);var US=(e,t,n)=>lD(oD(e),n,t);function uD(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 c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).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 af(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ag={exports:{}},gc={};/**
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 VS;function dD(){if(VS)return gc;VS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,l){var c=null;if(l!==void 0&&(c=""+l),a.key!==void 0&&(c=""+a.key),"key"in a){l={};for(var u in a)u!=="key"&&(l[u]=a[u])}else l=a;return a=l.ref,{$$typeof:e,type:r,key:c,ref:a!==void 0?a:null,props:l}}return gc.Fragment=t,gc.jsx=n,gc.jsxs=n,gc}var GS;function hD(){return GS||(GS=1,ag.exports=dD()),ag.exports}var s=hD(),og={exports:{}},xt={};/**
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 WS;function fD(){if(WS)return xt;WS=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"),c=Symbol.for("react.context"),u=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"),g=Symbol.iterator;function x(R){return R===null||typeof R!="object"?null:(R=g&&R[g]||R["@@iterator"],typeof R=="function"?R:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,_={};function S(R,W,B){this.props=R,this.context=W,this.refs=_,this.updater=B||w}S.prototype.isReactComponent={},S.prototype.setState=function(R,W){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,W,"setState")},S.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function v(){}v.prototype=S.prototype;function b(R,W,B){this.props=R,this.context=W,this.refs=_,this.updater=B||w}var k=b.prototype=new v;k.constructor=b,C(k,S.prototype),k.isPureReactComponent=!0;var N=Array.isArray;function E(){}var D={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function O(R,W,B){var Z=B.ref;return{$$typeof:e,type:R,key:W,ref:Z!==void 0?Z:null,props:B}}function P(R,W){return O(R.type,W,R.props)}function G(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function z(R){var W={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(B){return W[B]})}var V=/\/+/g;function $(R,W){return typeof R=="object"&&R!==null&&R.key!=null?z(""+R.key):W.toString(36)}function H(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(E,E):(R.status="pending",R.then(function(W){R.status==="pending"&&(R.status="fulfilled",R.value=W)},function(W){R.status==="pending"&&(R.status="rejected",R.reason=W)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function q(R,W,B,Z,Q){var J=typeof R;(J==="undefined"||J==="boolean")&&(R=null);var U=!1;if(R===null)U=!0;else switch(J){case"bigint":case"string":case"number":U=!0;break;case"object":switch(R.$$typeof){case e:case t:U=!0;break;case p:return U=R._init,q(U(R._payload),W,B,Z,Q)}}if(U)return Q=Q(R),U=Z===""?"."+$(R,0):Z,N(Q)?(B="",U!=null&&(B=U.replace(V,"$&/")+"/"),q(Q,W,B,"",function(se){return se})):Q!=null&&(G(Q)&&(Q=P(Q,B+(Q.key==null||R&&R.key===Q.key?"":(""+Q.key).replace(V,"$&/")+"/")+U)),W.push(Q)),1;U=0;var M=Z===""?".":Z+":";if(N(R))for(var te=0;te<R.length;te++)Z=R[te],J=M+$(Z,te),U+=q(Z,W,B,J,Q);else if(te=x(R),typeof te=="function")for(R=te.call(R),te=0;!(Z=R.next()).done;)Z=Z.value,J=M+$(Z,te++),U+=q(Z,W,B,J,Q);else if(J==="object"){if(typeof R.then=="function")return q(H(R),W,B,Z,Q);throw W=String(R),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return U}function X(R,W,B){if(R==null)return R;var Z=[],Q=0;return q(R,Z,"","",function(J){return W.call(B,J,Q++)}),Z}function Y(R){if(R._status===-1){var W=R._result;W=W(),W.then(function(B){(R._status===0||R._status===-1)&&(R._status=1,R._result=B)},function(B){(R._status===0||R._status===-1)&&(R._status=2,R._result=B)}),R._status===-1&&(R._status=0,R._result=W)}if(R._status===1)return R._result.default;throw R._result}var F=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},I={map:X,forEach:function(R,W,B){X(R,function(){W.apply(this,arguments)},B)},count:function(R){var W=0;return X(R,function(){W++}),W},toArray:function(R){return X(R,function(W){return W})||[]},only:function(R){if(!G(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return xt.Activity=m,xt.Children=I,xt.Component=S,xt.Fragment=n,xt.Profiler=a,xt.PureComponent=b,xt.StrictMode=r,xt.Suspense=d,xt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,xt.__COMPILER_RUNTIME={__proto__:null,c:function(R){return D.H.useMemoCache(R)}},xt.cache=function(R){return function(){return R.apply(null,arguments)}},xt.cacheSignal=function(){return null},xt.cloneElement=function(R,W,B){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var Z=C({},R.props),Q=R.key;if(W!=null)for(J in W.key!==void 0&&(Q=""+W.key),W)!A.call(W,J)||J==="key"||J==="__self"||J==="__source"||J==="ref"&&W.ref===void 0||(Z[J]=W[J]);var J=arguments.length-2;if(J===1)Z.children=B;else if(1<J){for(var U=Array(J),M=0;M<J;M++)U[M]=arguments[M+2];Z.children=U}return O(R.type,Q,Z)},xt.createContext=function(R){return R={$$typeof:c,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:l,_context:R},R},xt.createElement=function(R,W,B){var Z,Q={},J=null;if(W!=null)for(Z in W.key!==void 0&&(J=""+W.key),W)A.call(W,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(Q[Z]=W[Z]);var U=arguments.length-2;if(U===1)Q.children=B;else if(1<U){for(var M=Array(U),te=0;te<U;te++)M[te]=arguments[te+2];Q.children=M}if(R&&R.defaultProps)for(Z in U=R.defaultProps,U)Q[Z]===void 0&&(Q[Z]=U[Z]);return O(R,J,Q)},xt.createRef=function(){return{current:null}},xt.forwardRef=function(R){return{$$typeof:u,render:R}},xt.isValidElement=G,xt.lazy=function(R){return{$$typeof:p,_payload:{_status:-1,_result:R},_init:Y}},xt.memo=function(R,W){return{$$typeof:h,type:R,compare:W===void 0?null:W}},xt.startTransition=function(R){var W=D.T,B={};D.T=B;try{var Z=R(),Q=D.S;Q!==null&&Q(B,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(E,F)}catch(J){F(J)}finally{W!==null&&B.types!==null&&(W.types=B.types),D.T=W}},xt.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},xt.use=function(R){return D.H.use(R)},xt.useActionState=function(R,W,B){return D.H.useActionState(R,W,B)},xt.useCallback=function(R,W){return D.H.useCallback(R,W)},xt.useContext=function(R){return D.H.useContext(R)},xt.useDebugValue=function(){},xt.useDeferredValue=function(R,W){return D.H.useDeferredValue(R,W)},xt.useEffect=function(R,W){return D.H.useEffect(R,W)},xt.useEffectEvent=function(R){return D.H.useEffectEvent(R)},xt.useId=function(){return D.H.useId()},xt.useImperativeHandle=function(R,W,B){return D.H.useImperativeHandle(R,W,B)},xt.useInsertionEffect=function(R,W){return D.H.useInsertionEffect(R,W)},xt.useLayoutEffect=function(R,W){return D.H.useLayoutEffect(R,W)},xt.useMemo=function(R,W){return D.H.useMemo(R,W)},xt.useOptimistic=function(R,W){return D.H.useOptimistic(R,W)},xt.useReducer=function(R,W,B){return D.H.useReducer(R,W,B)},xt.useRef=function(R){return D.H.useRef(R)},xt.useState=function(R){return D.H.useState(R)},xt.useSyncExternalStore=function(R,W,B){return D.H.useSyncExternalStore(R,W,B)},xt.useTransition=function(){return D.H.useTransition()},xt.version="19.2.8",xt}var qS;function of(){return qS||(qS=1,og.exports=fD()),og.exports}var j=of();const cs=af(j),mD=uD({__proto__:null,default:cs},[j]);var lg={exports:{}},xc={},cg={exports:{}},ug={};/**
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 KS;function pD(){return KS||(KS=1,(function(e){function t(q,X){var Y=q.length;q.push(X);e:for(;0<Y;){var F=Y-1>>>1,I=q[F];if(0<a(I,X))q[F]=X,q[Y]=I,Y=F;else break e}}function n(q){return q.length===0?null:q[0]}function r(q){if(q.length===0)return null;var X=q[0],Y=q.pop();if(Y!==X){q[0]=Y;e:for(var F=0,I=q.length,R=I>>>1;F<R;){var W=2*(F+1)-1,B=q[W],Z=W+1,Q=q[Z];if(0>a(B,Y))Z<I&&0>a(Q,B)?(q[F]=Q,q[Z]=Y,F=Z):(q[F]=B,q[W]=Y,F=W);else if(Z<I&&0>a(Q,Y))q[F]=Q,q[Z]=Y,F=Z;else break e}}return X}function a(q,X){var Y=q.sortIndex-X.sortIndex;return Y!==0?Y:q.id-X.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 c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var d=[],h=[],p=1,m=null,g=3,x=!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 k(q){for(var X=n(h);X!==null;){if(X.callback===null)r(h);else if(X.startTime<=q)r(h),X.sortIndex=X.expirationTime,t(d,X);else break;X=n(h)}}function N(q){if(C=!1,k(q),!w)if(n(d)!==null)w=!0,E||(E=!0,z());else{var X=n(h);X!==null&&H(N,X.startTime-q)}}var E=!1,D=-1,A=5,O=-1;function P(){return _?!0:!(e.unstable_now()-O<A)}function G(){if(_=!1,E){var q=e.unstable_now();O=q;var X=!0;try{e:{w=!1,C&&(C=!1,v(D),D=-1),x=!0;var Y=g;try{t:{for(k(q),m=n(d);m!==null&&!(m.expirationTime>q&&P());){var F=m.callback;if(typeof F=="function"){m.callback=null,g=m.priorityLevel;var I=F(m.expirationTime<=q);if(q=e.unstable_now(),typeof I=="function"){m.callback=I,k(q),X=!0;break t}m===n(d)&&r(d),k(q)}else r(d);m=n(d)}if(m!==null)X=!0;else{var R=n(h);R!==null&&H(N,R.startTime-q),X=!1}}break e}finally{m=null,g=Y,x=!1}X=void 0}}finally{X?z():E=!1}}}var z;if(typeof b=="function")z=function(){b(G)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,$=V.port2;V.port1.onmessage=G,z=function(){$.postMessage(null)}}else z=function(){S(G,0)};function H(q,X){D=S(function(){q(e.unstable_now())},X)}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(q){q.callback=null},e.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(q){switch(g){case 1:case 2:case 3:var X=3;break;default:X=g}var Y=g;g=X;try{return q()}finally{g=Y}},e.unstable_requestPaint=function(){_=!0},e.unstable_runWithPriority=function(q,X){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var Y=g;g=q;try{return X()}finally{g=Y}},e.unstable_scheduleCallback=function(q,X,Y){var F=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?F+Y:F):Y=F,q){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=Y+I,q={id:p++,callback:X,priorityLevel:q,startTime:Y,expirationTime:I,sortIndex:-1},Y>F?(q.sortIndex=Y,t(h,q),n(d)===null&&q===n(h)&&(C?(v(D),D=-1):C=!0,H(N,Y-F))):(q.sortIndex=I,t(d,q),w||x||(w=!0,E||(E=!0,z()))),q},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(q){var X=g;return function(){var Y=g;g=X;try{return q.apply(this,arguments)}finally{g=Y}}}})(ug)),ug}var YS;function gD(){return YS||(YS=1,cg.exports=pD()),cg.exports}var dg={exports:{}},Yn={};/**
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 XS;function xD(){if(XS)return Yn;XS=1;var e=of();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 c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(d,h){if(d==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Yn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Yn.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)},Yn.flushSync=function(d){var h=c.T,p=r.p;try{if(c.T=null,r.p=2,d)return d()}finally{c.T=h,r.p=p,r.d.f()}},Yn.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))},Yn.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},Yn.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var p=h.as,m=u(p,h.crossOrigin),g=typeof h.integrity=="string"?h.integrity:void 0,x=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:g,fetchPriority:x}):p==="script"&&r.d.X(d,{crossOrigin:m,integrity:g,fetchPriority:x,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Yn.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=u(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)},Yn.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,m=u(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})}},Yn.preloadModule=function(d,h){if(typeof d=="string")if(h){var p=u(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)},Yn.requestFormReset=function(d){r.d.r(d)},Yn.unstable_batchedUpdates=function(d,h){return d(h)},Yn.useFormState=function(d,h,p){return c.H.useFormState(d,h,p)},Yn.useFormStatus=function(){return c.H.useHostTransitionStatus()},Yn.version="19.2.8",Yn}var JS;function jk(){if(JS)return dg.exports;JS=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(),dg.exports=xD(),dg.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 QS;function yD(){if(QS)return xc;QS=1;var e=gD(),t=of(),n=jk();function r(i){var o="https://react.dev/errors/"+i;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 #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function l(i){var o=i,f=i;if(i.alternate)for(;o.return;)o=o.return;else{i=o;do o=i,(o.flags&4098)!==0&&(f=o.return),i=o.return;while(i)}return o.tag===3?f:null}function c(i){if(i.tag===13){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function u(i){if(i.tag===31){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function d(i){if(l(i)!==i)throw Error(r(188))}function h(i){var o=i.alternate;if(!o){if(o=l(i),o===null)throw Error(r(188));return o!==i?null:i}for(var f=i,y=o;;){var T=f.return;if(T===null)break;var L=T.alternate;if(L===null){if(y=T.return,y!==null){f=y;continue}break}if(T.child===L.child){for(L=T.child;L;){if(L===f)return d(T),i;if(L===y)return d(T),o;L=L.sibling}throw Error(r(188))}if(f.return!==y.return)f=T,y=L;else{for(var K=!1,ee=T.child;ee;){if(ee===f){K=!0,f=T,y=L;break}if(ee===y){K=!0,y=T,f=L;break}ee=ee.sibling}if(!K){for(ee=L.child;ee;){if(ee===f){K=!0,f=L,y=T;break}if(ee===y){K=!0,y=L,f=T;break}ee=ee.sibling}if(!K)throw Error(r(189))}}if(f.alternate!==y)throw Error(r(190))}if(f.tag!==3)throw Error(r(188));return f.stateNode.current===f?i:o}function p(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i;for(i=i.child;i!==null;){if(o=p(i),o!==null)return o;i=i.sibling}return null}var m=Object.assign,g=Symbol.for("react.element"),x=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"),k=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function z(i){return i===null||typeof i!="object"?null:(i=G&&i[G]||i["@@iterator"],typeof i=="function"?i:null)}var V=Symbol.for("react.client.reference");function $(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===V?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case S:return"Profiler";case _:return"StrictMode";case N:return"Suspense";case E:return"SuspenseList";case O:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case b:return i.displayName||"Context";case v:return(i._context.displayName||"Context")+".Consumer";case k:var o=i.render;return i=i.displayName,i||(i=o.displayName||o.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case D:return o=i.displayName||null,o!==null?o:$(i.type)||"Memo";case A:o=i._payload,i=i._init;try{return $(i(o))}catch{}}return null}var H=Array.isArray,q=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y={pending:!1,data:null,method:null,action:null},F=[],I=-1;function R(i){return{current:i}}function W(i){0>I||(i.current=F[I],F[I]=null,I--)}function B(i,o){I++,F[I]=i.current,i.current=o}var Z=R(null),Q=R(null),J=R(null),U=R(null);function M(i,o){switch(B(J,o),B(Q,i),B(Z,null),o.nodeType){case 9:case 11:i=(i=o.documentElement)&&(i=i.namespaceURI)?dS(i):0;break;default:if(i=o.tagName,o=o.namespaceURI)o=dS(o),i=hS(o,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}W(Z),B(Z,i)}function te(){W(Z),W(Q),W(J)}function se(i){i.memoizedState!==null&&B(U,i);var o=Z.current,f=hS(o,i.type);o!==f&&(B(Q,i),B(Z,f))}function re(i){Q.current===i&&(W(Z),W(Q)),U.current===i&&(W(U),hc._currentValue=Y)}var le,ye;function _e(i){if(le===void 0)try{throw Error()}catch(f){var o=f.stack.trim().match(/\n( *(at )?)/);le=o&&o[1]||"",ye=-1<f.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+le+i+ye}var Oe=!1;function Be(i,o){if(!i||Oe)return"";Oe=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var y={DetermineComponentFrameRoot:function(){try{if(o){var ze=function(){throw Error()};if(Object.defineProperty(ze.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ze,[])}catch(je){var Ce=je}Reflect.construct(i,[],ze)}else{try{ze.call()}catch(je){Ce=je}i.call(ze.prototype)}}else{try{throw Error()}catch(je){Ce=je}(ze=i())&&typeof ze.catch=="function"&&ze.catch(function(){})}}catch(je){if(je&&Ce&&typeof je.stack=="string")return[je.stack,Ce.stack]}return[null,null]}};y.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var T=Object.getOwnPropertyDescriptor(y.DetermineComponentFrameRoot,"name");T&&T.configurable&&Object.defineProperty(y.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=y.DetermineComponentFrameRoot(),K=L[0],ee=L[1];if(K&&ee){var ce=K.split(`
45
+ `),ve=ee.split(`
46
+ `);for(T=y=0;y<ce.length&&!ce[y].includes("DetermineComponentFrameRoot");)y++;for(;T<ve.length&&!ve[T].includes("DetermineComponentFrameRoot");)T++;if(y===ce.length||T===ve.length)for(y=ce.length-1,T=ve.length-1;1<=y&&0<=T&&ce[y]!==ve[T];)T--;for(;1<=y&&0<=T;y--,T--)if(ce[y]!==ve[T]){if(y!==1||T!==1)do if(y--,T--,0>T||ce[y]!==ve[T]){var De=`
47
+ `+ce[y].replace(" at new "," at ");return i.displayName&&De.includes("<anonymous>")&&(De=De.replace("<anonymous>",i.displayName)),De}while(1<=y&&0<=T);break}}}finally{Oe=!1,Error.prepareStackTrace=f}return(f=i?i.displayName||i.name:"")?_e(f):""}function ke(i,o){switch(i.tag){case 26:case 27:case 5:return _e(i.type);case 16:return _e("Lazy");case 13:return i.child!==o&&o!==null?_e("Suspense Fallback"):_e("Suspense");case 19:return _e("SuspenseList");case 0:case 15:return Be(i.type,!1);case 11:return Be(i.type.render,!1);case 1:return Be(i.type,!0);case 31:return _e("Activity");default:return""}}function Ge(i){try{var o="",f=null;do o+=ke(i,f),f=i,i=i.return;while(i);return o}catch(y){return`
48
+ Error generating stack: `+y.message+`
49
+ `+y.stack}}var Je=Object.prototype.hasOwnProperty,ae=e.unstable_scheduleCallback,ue=e.unstable_cancelCallback,Me=e.unstable_shouldYield,fe=e.unstable_requestPaint,Fe=e.unstable_now,He=e.unstable_getCurrentPriorityLevel,ie=e.unstable_ImmediatePriority,Se=e.unstable_UserBlockingPriority,Le=e.unstable_NormalPriority,he=e.unstable_LowPriority,me=e.unstable_IdlePriority,We=e.log,Ue=e.unstable_setDisableYieldValue,Qe=null,it=null;function ge(i){if(typeof We=="function"&&Ue(i),it&&typeof it.setStrictMode=="function")try{it.setStrictMode(Qe,i)}catch{}}var Ve=Math.clz32?Math.clz32:Ht,at=Math.log,ht=Math.LN2;function Ht(i){return i>>>=0,i===0?32:31-(at(i)/ht|0)|0}var Vt=256,At=262144,Bn=4194304;function Sn(i){var o=i&42;if(o!==0)return o;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function hn(i,o,f){var y=i.pendingLanes;if(y===0)return 0;var T=0,L=i.suspendedLanes,K=i.pingedLanes;i=i.warmLanes;var ee=y&134217727;return ee!==0?(y=ee&~L,y!==0?T=Sn(y):(K&=ee,K!==0?T=Sn(K):f||(f=ee&~i,f!==0&&(T=Sn(f))))):(ee=y&~L,ee!==0?T=Sn(ee):K!==0?T=Sn(K):f||(f=y&~i,f!==0&&(T=Sn(f)))),T===0?0:o!==0&&o!==T&&(o&L)===0&&(L=T&-T,f=o&-o,L>=f||L===32&&(f&4194048)!==0)?o:T}function Dn(i,o){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&o)===0}function wn(i,o){switch(i){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function un(){var i=Bn;return Bn<<=1,(Bn&62914560)===0&&(Bn=4194304),i}function nr(i){for(var o=[],f=0;31>f;f++)o.push(i);return o}function we(i,o){i.pendingLanes|=o,o!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function et(i,o,f,y,T,L){var K=i.pendingLanes;i.pendingLanes=f,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=f,i.entangledLanes&=f,i.errorRecoveryDisabledLanes&=f,i.shellSuspendCounter=0;var ee=i.entanglements,ce=i.expirationTimes,ve=i.hiddenUpdates;for(f=K&~f;0<f;){var De=31-Ve(f),ze=1<<De;ee[De]=0,ce[De]=-1;var Ce=ve[De];if(Ce!==null)for(ve[De]=null,De=0;De<Ce.length;De++){var je=Ce[De];je!==null&&(je.lane&=-536870913)}f&=~ze}y!==0&&Ye(i,y,0),L!==0&&T===0&&i.tag!==0&&(i.suspendedLanes|=L&~(K&~o))}function Ye(i,o,f){i.pendingLanes|=o,i.suspendedLanes&=~o;var y=31-Ve(o);i.entangledLanes|=o,i.entanglements[y]=i.entanglements[y]|1073741824|f&261930}function oe(i,o){var f=i.entangledLanes|=o;for(i=i.entanglements;f;){var y=31-Ve(f),T=1<<y;T&o|i[y]&o&&(i[y]|=o),f&=~T}}function Pe(i,o){var f=o&-o;return f=(f&42)!==0?1:Ze(f),(f&(i.suspendedLanes|o))!==0?0:f}function Ze(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Dt(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function rn(){var i=X.p;return i!==0?i:(i=window.event,i===void 0?32:IS(i.type))}function Ne(i,o){var f=X.p;try{return X.p=i,o()}finally{X.p=f}}var Te=Math.random().toString(36).slice(2),$e="__reactFiber$"+Te,Xe="__reactProps$"+Te,tt="__reactContainer$"+Te,mt="__reactEvents$"+Te,_t="__reactListeners$"+Te,Rn="__reactHandles$"+Te,gn="__reactResources$"+Te,Cn="__reactMarker$"+Te;function to(i){delete i[$e],delete i[Xe],delete i[mt],delete i[_t],delete i[Rn]}function no(i){var o=i[$e];if(o)return o;for(var f=i.parentNode;f;){if(o=f[tt]||f[$e]){if(f=o.alternate,o.child!==null||f!==null&&f.child!==null)for(i=bS(i);i!==null;){if(f=i[$e])return f;i=bS(i)}return o}i=f,f=i.parentNode}return null}function ro(i){if(i=i[$e]||i[tt]){var o=i.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return i}return null}function Nl(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i.stateNode;throw Error(r(33))}function so(i){var o=i[gn];return o||(o=i[gn]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function $n(i){i[Cn]=!0}var Zb=new Set,ev={};function sa(i,o){io(i,o),io(i+"Capture",o)}function io(i,o){for(ev[i]=o,i=0;i<o.length;i++)Zb.add(o[i])}var JT=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]*$"),tv={},nv={};function QT(i){return Je.call(nv,i)?!0:Je.call(tv,i)?!1:JT.test(i)?nv[i]=!0:(tv[i]=!0,!1)}function Cu(i,o,f){if(QT(o))if(f===null)i.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":i.removeAttribute(o);return;case"boolean":var y=o.toLowerCase().slice(0,5);if(y!=="data-"&&y!=="aria-"){i.removeAttribute(o);return}}i.setAttribute(o,""+f)}}function ku(i,o,f){if(f===null)i.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(o);return}i.setAttribute(o,""+f)}}function Is(i,o,f,y){if(y===null)i.removeAttribute(f);else{switch(typeof y){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(f);return}i.setAttributeNS(o,f,""+y)}}function Ir(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function rv(i){var o=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function ZT(i,o,f){var y=Object.getOwnPropertyDescriptor(i.constructor.prototype,o);if(!i.hasOwnProperty(o)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var T=y.get,L=y.set;return Object.defineProperty(i,o,{configurable:!0,get:function(){return T.call(this)},set:function(K){f=""+K,L.call(this,K)}}),Object.defineProperty(i,o,{enumerable:y.enumerable}),{getValue:function(){return f},setValue:function(K){f=""+K},stopTracking:function(){i._valueTracker=null,delete i[o]}}}}function Jf(i){if(!i._valueTracker){var o=rv(i)?"checked":"value";i._valueTracker=ZT(i,o,""+i[o])}}function sv(i){if(!i)return!1;var o=i._valueTracker;if(!o)return!0;var f=o.getValue(),y="";return i&&(y=rv(i)?i.checked?"true":"false":i.value),i=y,i!==f?(o.setValue(i),!0):!1}function ju(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var eA=/[\n"\\]/g;function Mr(i){return i.replace(eA,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Qf(i,o,f,y,T,L,K,ee){i.name="",K!=null&&typeof K!="function"&&typeof K!="symbol"&&typeof K!="boolean"?i.type=K:i.removeAttribute("type"),o!=null?K==="number"?(o===0&&i.value===""||i.value!=o)&&(i.value=""+Ir(o)):i.value!==""+Ir(o)&&(i.value=""+Ir(o)):K!=="submit"&&K!=="reset"||i.removeAttribute("value"),o!=null?Zf(i,K,Ir(o)):f!=null?Zf(i,K,Ir(f)):y!=null&&i.removeAttribute("value"),T==null&&L!=null&&(i.defaultChecked=!!L),T!=null&&(i.checked=T&&typeof T!="function"&&typeof T!="symbol"),ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?i.name=""+Ir(ee):i.removeAttribute("name")}function iv(i,o,f,y,T,L,K,ee){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(i.type=L),o!=null||f!=null){if(!(L!=="submit"&&L!=="reset"||o!=null)){Jf(i);return}f=f!=null?""+Ir(f):"",o=o!=null?""+Ir(o):f,ee||o===i.value||(i.value=o),i.defaultValue=o}y=y??T,y=typeof y!="function"&&typeof y!="symbol"&&!!y,i.checked=ee?i.checked:!!y,i.defaultChecked=!!y,K!=null&&typeof K!="function"&&typeof K!="symbol"&&typeof K!="boolean"&&(i.name=K),Jf(i)}function Zf(i,o,f){o==="number"&&ju(i.ownerDocument)===i||i.defaultValue===""+f||(i.defaultValue=""+f)}function ao(i,o,f,y){if(i=i.options,o){o={};for(var T=0;T<f.length;T++)o["$"+f[T]]=!0;for(f=0;f<i.length;f++)T=o.hasOwnProperty("$"+i[f].value),i[f].selected!==T&&(i[f].selected=T),T&&y&&(i[f].defaultSelected=!0)}else{for(f=""+Ir(f),o=null,T=0;T<i.length;T++){if(i[T].value===f){i[T].selected=!0,y&&(i[T].defaultSelected=!0);return}o!==null||i[T].disabled||(o=i[T])}o!==null&&(o.selected=!0)}}function av(i,o,f){if(o!=null&&(o=""+Ir(o),o!==i.value&&(i.value=o),f==null)){i.defaultValue!==o&&(i.defaultValue=o);return}i.defaultValue=f!=null?""+Ir(f):""}function ov(i,o,f,y){if(o==null){if(y!=null){if(f!=null)throw Error(r(92));if(H(y)){if(1<y.length)throw Error(r(93));y=y[0]}f=y}f==null&&(f=""),o=f}f=Ir(o),i.defaultValue=f,y=i.textContent,y===f&&y!==""&&y!==null&&(i.value=y),Jf(i)}function oo(i,o){if(o){var f=i.firstChild;if(f&&f===i.lastChild&&f.nodeType===3){f.nodeValue=o;return}}i.textContent=o}var tA=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 lv(i,o,f){var y=o.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?y?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="":y?i.setProperty(o,f):typeof f!="number"||f===0||tA.has(o)?o==="float"?i.cssFloat=f:i[o]=(""+f).trim():i[o]=f+"px"}function cv(i,o,f){if(o!=null&&typeof o!="object")throw Error(r(62));if(i=i.style,f!=null){for(var y in f)!f.hasOwnProperty(y)||o!=null&&o.hasOwnProperty(y)||(y.indexOf("--")===0?i.setProperty(y,""):y==="float"?i.cssFloat="":i[y]="");for(var T in o)y=o[T],o.hasOwnProperty(T)&&f[T]!==y&&lv(i,T,y)}else for(var L in o)o.hasOwnProperty(L)&&lv(i,L,o[L])}function em(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var nA=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"]]),rA=/^[\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 Eu(i){return rA.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Ms(){}var tm=null;function nm(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var lo=null,co=null;function uv(i){var o=ro(i);if(o&&(i=o.stateNode)){var f=i[Xe]||null;e:switch(i=o.stateNode,o.type){case"input":if(Qf(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),o=f.name,f.type==="radio"&&o!=null){for(f=i;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+Mr(""+o)+'"][type="radio"]'),o=0;o<f.length;o++){var y=f[o];if(y!==i&&y.form===i.form){var T=y[Xe]||null;if(!T)throw Error(r(90));Qf(y,T.value,T.defaultValue,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name)}}for(o=0;o<f.length;o++)y=f[o],y.form===i.form&&sv(y)}break e;case"textarea":av(i,f.value,f.defaultValue);break e;case"select":o=f.value,o!=null&&ao(i,!!f.multiple,o,!1)}}}var rm=!1;function dv(i,o,f){if(rm)return i(o,f);rm=!0;try{var y=i(o);return y}finally{if(rm=!1,(lo!==null||co!==null)&&(md(),lo&&(o=lo,i=co,co=lo=null,uv(o),i)))for(o=0;o<i.length;o++)uv(i[o])}}function Tl(i,o){var f=i.stateNode;if(f===null)return null;var y=f[Xe]||null;if(y===null)return null;f=y[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":(y=!y.disabled)||(i=i.type,y=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!y;break e;default:i=!1}if(i)return null;if(f&&typeof f!="function")throw Error(r(231,o,typeof f));return f}var Ps=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),sm=!1;if(Ps)try{var Al={};Object.defineProperty(Al,"passive",{get:function(){sm=!0}}),window.addEventListener("test",Al,Al),window.removeEventListener("test",Al,Al)}catch{sm=!1}var gi=null,im=null,Nu=null;function hv(){if(Nu)return Nu;var i,o=im,f=o.length,y,T="value"in gi?gi.value:gi.textContent,L=T.length;for(i=0;i<f&&o[i]===T[i];i++);var K=f-i;for(y=1;y<=K&&o[f-y]===T[L-y];y++);return Nu=T.slice(i,1<y?1-y:void 0)}function Tu(i){var o=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&o===13&&(i=13)):i=o,i===10&&(i=13),32<=i||i===13?i:0}function Au(){return!0}function fv(){return!1}function lr(i){function o(f,y,T,L,K){this._reactName=f,this._targetInst=T,this.type=y,this.nativeEvent=L,this.target=K,this.currentTarget=null;for(var ee in i)i.hasOwnProperty(ee)&&(f=i[ee],this[ee]=f?f(L):L[ee]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Au:fv,this.isPropagationStopped=fv,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=Au)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=Au)},persist:function(){},isPersistent:Au}),o}var ia={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Lu=lr(ia),Ll=m({},ia,{view:0,detail:0}),sA=lr(Ll),am,om,Dl,Du=m({},Ll,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cm,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Dl&&(Dl&&i.type==="mousemove"?(am=i.screenX-Dl.screenX,om=i.screenY-Dl.screenY):om=am=0,Dl=i),am)},movementY:function(i){return"movementY"in i?i.movementY:om}}),mv=lr(Du),iA=m({},Du,{dataTransfer:0}),aA=lr(iA),oA=m({},Ll,{relatedTarget:0}),lm=lr(oA),lA=m({},ia,{animationName:0,elapsedTime:0,pseudoElement:0}),cA=lr(lA),uA=m({},ia,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),dA=lr(uA),hA=m({},ia,{data:0}),pv=lr(hA),fA={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mA={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"},pA={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gA(i){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(i):(i=pA[i])?!!o[i]:!1}function cm(){return gA}var xA=m({},Ll,{key:function(i){if(i.key){var o=fA[i.key]||i.key;if(o!=="Unidentified")return o}return i.type==="keypress"?(i=Tu(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?mA[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cm,charCode:function(i){return i.type==="keypress"?Tu(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Tu(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),yA=lr(xA),bA=m({},Du,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),gv=lr(bA),vA=m({},Ll,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cm}),_A=lr(vA),SA=m({},ia,{propertyName:0,elapsedTime:0,pseudoElement:0}),wA=lr(SA),CA=m({},Du,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),kA=lr(CA),jA=m({},ia,{newState:0,oldState:0}),EA=lr(jA),NA=[9,13,27,32],um=Ps&&"CompositionEvent"in window,Rl=null;Ps&&"documentMode"in document&&(Rl=document.documentMode);var TA=Ps&&"TextEvent"in window&&!Rl,xv=Ps&&(!um||Rl&&8<Rl&&11>=Rl),yv=" ",bv=!1;function vv(i,o){switch(i){case"keyup":return NA.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _v(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var uo=!1;function AA(i,o){switch(i){case"compositionend":return _v(o);case"keypress":return o.which!==32?null:(bv=!0,yv);case"textInput":return i=o.data,i===yv&&bv?null:i;default:return null}}function LA(i,o){if(uo)return i==="compositionend"||!um&&vv(i,o)?(i=hv(),Nu=im=gi=null,uo=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return xv&&o.locale!=="ko"?null:o.data;default:return null}}var DA={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 Sv(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o==="input"?!!DA[i.type]:o==="textarea"}function wv(i,o,f,y){lo?co?co.push(y):co=[y]:lo=y,o=_d(o,"onChange"),0<o.length&&(f=new Lu("onChange","change",null,f,y),i.push({event:f,listeners:o}))}var Ol=null,Il=null;function RA(i){iS(i,0)}function Ru(i){var o=Nl(i);if(sv(o))return i}function Cv(i,o){if(i==="change")return o}var kv=!1;if(Ps){var dm;if(Ps){var hm="oninput"in document;if(!hm){var jv=document.createElement("div");jv.setAttribute("oninput","return;"),hm=typeof jv.oninput=="function"}dm=hm}else dm=!1;kv=dm&&(!document.documentMode||9<document.documentMode)}function Ev(){Ol&&(Ol.detachEvent("onpropertychange",Nv),Il=Ol=null)}function Nv(i){if(i.propertyName==="value"&&Ru(Il)){var o=[];wv(o,Il,i,nm(i)),dv(RA,o)}}function OA(i,o,f){i==="focusin"?(Ev(),Ol=o,Il=f,Ol.attachEvent("onpropertychange",Nv)):i==="focusout"&&Ev()}function IA(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ru(Il)}function MA(i,o){if(i==="click")return Ru(o)}function PA(i,o){if(i==="input"||i==="change")return Ru(o)}function BA(i,o){return i===o&&(i!==0||1/i===1/o)||i!==i&&o!==o}var _r=typeof Object.is=="function"?Object.is:BA;function Ml(i,o){if(_r(i,o))return!0;if(typeof i!="object"||i===null||typeof o!="object"||o===null)return!1;var f=Object.keys(i),y=Object.keys(o);if(f.length!==y.length)return!1;for(y=0;y<f.length;y++){var T=f[y];if(!Je.call(o,T)||!_r(i[T],o[T]))return!1}return!0}function Tv(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Av(i,o){var f=Tv(i);i=0;for(var y;f;){if(f.nodeType===3){if(y=i+f.textContent.length,i<=o&&y>=o)return{node:f,offset:o-i};i=y}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=Tv(f)}}function Lv(i,o){return i&&o?i===o?!0:i&&i.nodeType===3?!1:o&&o.nodeType===3?Lv(i,o.parentNode):"contains"in i?i.contains(o):i.compareDocumentPosition?!!(i.compareDocumentPosition(o)&16):!1:!1}function Dv(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var o=ju(i.document);o instanceof i.HTMLIFrameElement;){try{var f=typeof o.contentWindow.location.href=="string"}catch{f=!1}if(f)i=o.contentWindow;else break;o=ju(i.document)}return o}function fm(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o&&(o==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||o==="textarea"||i.contentEditable==="true")}var $A=Ps&&"documentMode"in document&&11>=document.documentMode,ho=null,mm=null,Pl=null,pm=!1;function Rv(i,o,f){var y=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;pm||ho==null||ho!==ju(y)||(y=ho,"selectionStart"in y&&fm(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Pl&&Ml(Pl,y)||(Pl=y,y=_d(mm,"onSelect"),0<y.length&&(o=new Lu("onSelect","select",null,o,f),i.push({event:o,listeners:y}),o.target=ho)))}function aa(i,o){var f={};return f[i.toLowerCase()]=o.toLowerCase(),f["Webkit"+i]="webkit"+o,f["Moz"+i]="moz"+o,f}var fo={animationend:aa("Animation","AnimationEnd"),animationiteration:aa("Animation","AnimationIteration"),animationstart:aa("Animation","AnimationStart"),transitionrun:aa("Transition","TransitionRun"),transitionstart:aa("Transition","TransitionStart"),transitioncancel:aa("Transition","TransitionCancel"),transitionend:aa("Transition","TransitionEnd")},gm={},Ov={};Ps&&(Ov=document.createElement("div").style,"AnimationEvent"in window||(delete fo.animationend.animation,delete fo.animationiteration.animation,delete fo.animationstart.animation),"TransitionEvent"in window||delete fo.transitionend.transition);function oa(i){if(gm[i])return gm[i];if(!fo[i])return i;var o=fo[i],f;for(f in o)if(o.hasOwnProperty(f)&&f in Ov)return gm[i]=o[f];return i}var Iv=oa("animationend"),Mv=oa("animationiteration"),Pv=oa("animationstart"),zA=oa("transitionrun"),HA=oa("transitionstart"),FA=oa("transitioncancel"),Bv=oa("transitionend"),$v=new Map,xm="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(" ");xm.push("scrollEnd");function ts(i,o){$v.set(i,o),sa(o,[i])}var Ou=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Pr=[],mo=0,ym=0;function Iu(){for(var i=mo,o=ym=mo=0;o<i;){var f=Pr[o];Pr[o++]=null;var y=Pr[o];Pr[o++]=null;var T=Pr[o];Pr[o++]=null;var L=Pr[o];if(Pr[o++]=null,y!==null&&T!==null){var K=y.pending;K===null?T.next=T:(T.next=K.next,K.next=T),y.pending=T}L!==0&&zv(f,T,L)}}function Mu(i,o,f,y){Pr[mo++]=i,Pr[mo++]=o,Pr[mo++]=f,Pr[mo++]=y,ym|=y,i.lanes|=y,i=i.alternate,i!==null&&(i.lanes|=y)}function bm(i,o,f,y){return Mu(i,o,f,y),Pu(i)}function la(i,o){return Mu(i,null,null,o),Pu(i)}function zv(i,o,f){i.lanes|=f;var y=i.alternate;y!==null&&(y.lanes|=f);for(var T=!1,L=i.return;L!==null;)L.childLanes|=f,y=L.alternate,y!==null&&(y.childLanes|=f),L.tag===22&&(i=L.stateNode,i===null||i._visibility&1||(T=!0)),i=L,L=L.return;return i.tag===3?(L=i.stateNode,T&&o!==null&&(T=31-Ve(f),i=L.hiddenUpdates,y=i[T],y===null?i[T]=[o]:y.push(o),o.lane=f|536870912),L):null}function Pu(i){if(50<ic)throw ic=0,Np=null,Error(r(185));for(var o=i.return;o!==null;)i=o,o=i.return;return i.tag===3?i.stateNode:null}var po={};function UA(i,o,f,y){this.tag=i,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=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Sr(i,o,f,y){return new UA(i,o,f,y)}function vm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Bs(i,o){var f=i.alternate;return f===null?(f=Sr(i.tag,o,i.key,i.mode),f.elementType=i.elementType,f.type=i.type,f.stateNode=i.stateNode,f.alternate=i,i.alternate=f):(f.pendingProps=o,f.type=i.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=i.flags&65011712,f.childLanes=i.childLanes,f.lanes=i.lanes,f.child=i.child,f.memoizedProps=i.memoizedProps,f.memoizedState=i.memoizedState,f.updateQueue=i.updateQueue,o=i.dependencies,f.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},f.sibling=i.sibling,f.index=i.index,f.ref=i.ref,f.refCleanup=i.refCleanup,f}function Hv(i,o){i.flags&=65011714;var f=i.alternate;return f===null?(i.childLanes=0,i.lanes=o,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=f.childLanes,i.lanes=f.lanes,i.child=f.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=f.memoizedProps,i.memoizedState=f.memoizedState,i.updateQueue=f.updateQueue,i.type=f.type,o=f.dependencies,i.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),i}function Bu(i,o,f,y,T,L){var K=0;if(y=i,typeof i=="function")vm(i)&&(K=1);else if(typeof i=="string")K=KL(i,f,Z.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case O:return i=Sr(31,f,o,T),i.elementType=O,i.lanes=L,i;case C:return ca(f.children,T,L,o);case _:K=8,T|=24;break;case S:return i=Sr(12,f,o,T|2),i.elementType=S,i.lanes=L,i;case N:return i=Sr(13,f,o,T),i.elementType=N,i.lanes=L,i;case E:return i=Sr(19,f,o,T),i.elementType=E,i.lanes=L,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case b:K=10;break e;case v:K=9;break e;case k:K=11;break e;case D:K=14;break e;case A:K=16,y=null;break e}K=29,f=Error(r(130,i===null?"null":typeof i,"")),y=null}return o=Sr(K,f,o,T),o.elementType=i,o.type=y,o.lanes=L,o}function ca(i,o,f,y){return i=Sr(7,i,y,o),i.lanes=f,i}function _m(i,o,f){return i=Sr(6,i,null,o),i.lanes=f,i}function Fv(i){var o=Sr(18,null,null,0);return o.stateNode=i,o}function Sm(i,o,f){return o=Sr(4,i.children!==null?i.children:[],i.key,o),o.lanes=f,o.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},o}var Uv=new WeakMap;function Br(i,o){if(typeof i=="object"&&i!==null){var f=Uv.get(i);return f!==void 0?f:(o={value:i,source:o,stack:Ge(o)},Uv.set(i,o),o)}return{value:i,source:o,stack:Ge(o)}}var go=[],xo=0,$u=null,Bl=0,$r=[],zr=0,xi=null,gs=1,xs="";function $s(i,o){go[xo++]=Bl,go[xo++]=$u,$u=i,Bl=o}function Vv(i,o,f){$r[zr++]=gs,$r[zr++]=xs,$r[zr++]=xi,xi=i;var y=gs;i=xs;var T=32-Ve(y)-1;y&=~(1<<T),f+=1;var L=32-Ve(o)+T;if(30<L){var K=T-T%5;L=(y&(1<<K)-1).toString(32),y>>=K,T-=K,gs=1<<32-Ve(o)+T|f<<T|y,xs=L+i}else gs=1<<L|f<<T|y,xs=i}function wm(i){i.return!==null&&($s(i,1),Vv(i,1,0))}function Cm(i){for(;i===$u;)$u=go[--xo],go[xo]=null,Bl=go[--xo],go[xo]=null;for(;i===xi;)xi=$r[--zr],$r[zr]=null,xs=$r[--zr],$r[zr]=null,gs=$r[--zr],$r[zr]=null}function Gv(i,o){$r[zr++]=gs,$r[zr++]=xs,$r[zr++]=xi,gs=o.id,xs=o.overflow,xi=i}var Vn=null,sn=null,Nt=!1,yi=null,Hr=!1,km=Error(r(519));function bi(i){var o=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw $l(Br(o,i)),km}function Wv(i){var o=i.stateNode,f=i.type,y=i.memoizedProps;switch(o[$e]=i,o[Xe]=y,f){case"dialog":Ct("cancel",o),Ct("close",o);break;case"iframe":case"object":case"embed":Ct("load",o);break;case"video":case"audio":for(f=0;f<oc.length;f++)Ct(oc[f],o);break;case"source":Ct("error",o);break;case"img":case"image":case"link":Ct("error",o),Ct("load",o);break;case"details":Ct("toggle",o);break;case"input":Ct("invalid",o),iv(o,y.value,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name,!0);break;case"select":Ct("invalid",o);break;case"textarea":Ct("invalid",o),ov(o,y.value,y.defaultValue,y.children)}f=y.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||o.textContent===""+f||y.suppressHydrationWarning===!0||cS(o.textContent,f)?(y.popover!=null&&(Ct("beforetoggle",o),Ct("toggle",o)),y.onScroll!=null&&Ct("scroll",o),y.onScrollEnd!=null&&Ct("scrollend",o),y.onClick!=null&&(o.onclick=Ms),o=!0):o=!1,o||bi(i,!0)}function qv(i){for(Vn=i.return;Vn;)switch(Vn.tag){case 5:case 31:case 13:Hr=!1;return;case 27:case 3:Hr=!0;return;default:Vn=Vn.return}}function yo(i){if(i!==Vn)return!1;if(!Nt)return qv(i),Nt=!0,!1;var o=i.tag,f;if((f=o!==3&&o!==27)&&((f=o===5)&&(f=i.type,f=!(f!=="form"&&f!=="button")||Up(i.type,i.memoizedProps)),f=!f),f&&sn&&bi(i),qv(i),o===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));sn=yS(i)}else if(o===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));sn=yS(i)}else o===27?(o=sn,Ri(i.type)?(i=Kp,Kp=null,sn=i):sn=o):sn=Vn?Ur(i.stateNode.nextSibling):null;return!0}function ua(){sn=Vn=null,Nt=!1}function jm(){var i=yi;return i!==null&&(hr===null?hr=i:hr.push.apply(hr,i),yi=null),i}function $l(i){yi===null?yi=[i]:yi.push(i)}var Em=R(null),da=null,zs=null;function vi(i,o,f){B(Em,o._currentValue),o._currentValue=f}function Hs(i){i._currentValue=Em.current,W(Em)}function Nm(i,o,f){for(;i!==null;){var y=i.alternate;if((i.childLanes&o)!==o?(i.childLanes|=o,y!==null&&(y.childLanes|=o)):y!==null&&(y.childLanes&o)!==o&&(y.childLanes|=o),i===f)break;i=i.return}}function Tm(i,o,f,y){var T=i.child;for(T!==null&&(T.return=i);T!==null;){var L=T.dependencies;if(L!==null){var K=T.child;L=L.firstContext;e:for(;L!==null;){var ee=L;L=T;for(var ce=0;ce<o.length;ce++)if(ee.context===o[ce]){L.lanes|=f,ee=L.alternate,ee!==null&&(ee.lanes|=f),Nm(L.return,f,i),y||(K=null);break e}L=ee.next}}else if(T.tag===18){if(K=T.return,K===null)throw Error(r(341));K.lanes|=f,L=K.alternate,L!==null&&(L.lanes|=f),Nm(K,f,i),K=null}else K=T.child;if(K!==null)K.return=T;else for(K=T;K!==null;){if(K===i){K=null;break}if(T=K.sibling,T!==null){T.return=K.return,K=T;break}K=K.return}T=K}}function bo(i,o,f,y){i=null;for(var T=o,L=!1;T!==null;){if(!L){if((T.flags&524288)!==0)L=!0;else if((T.flags&262144)!==0)break}if(T.tag===10){var K=T.alternate;if(K===null)throw Error(r(387));if(K=K.memoizedProps,K!==null){var ee=T.type;_r(T.pendingProps.value,K.value)||(i!==null?i.push(ee):i=[ee])}}else if(T===U.current){if(K=T.alternate,K===null)throw Error(r(387));K.memoizedState.memoizedState!==T.memoizedState.memoizedState&&(i!==null?i.push(hc):i=[hc])}T=T.return}i!==null&&Tm(o,i,f,y),o.flags|=262144}function zu(i){for(i=i.firstContext;i!==null;){if(!_r(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function ha(i){da=i,zs=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Gn(i){return Kv(da,i)}function Hu(i,o){return da===null&&ha(i),Kv(i,o)}function Kv(i,o){var f=o._currentValue;if(o={context:o,memoizedValue:f,next:null},zs===null){if(i===null)throw Error(r(308));zs=o,i.dependencies={lanes:0,firstContext:o},i.flags|=524288}else zs=zs.next=o;return f}var VA=typeof AbortController<"u"?AbortController:function(){var i=[],o=this.signal={aborted:!1,addEventListener:function(f,y){i.push(y)}};this.abort=function(){o.aborted=!0,i.forEach(function(f){return f()})}},GA=e.unstable_scheduleCallback,WA=e.unstable_NormalPriority,kn={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Am(){return{controller:new VA,data:new Map,refCount:0}}function zl(i){i.refCount--,i.refCount===0&&GA(WA,function(){i.controller.abort()})}var Hl=null,Lm=0,vo=0,_o=null;function qA(i,o){if(Hl===null){var f=Hl=[];Lm=0,vo=Op(),_o={status:"pending",value:void 0,then:function(y){f.push(y)}}}return Lm++,o.then(Yv,Yv),o}function Yv(){if(--Lm===0&&Hl!==null){_o!==null&&(_o.status="fulfilled");var i=Hl;Hl=null,vo=0,_o=null;for(var o=0;o<i.length;o++)(0,i[o])()}}function KA(i,o){var f=[],y={status:"pending",value:null,reason:null,then:function(T){f.push(T)}};return i.then(function(){y.status="fulfilled",y.value=o;for(var T=0;T<f.length;T++)(0,f[T])(o)},function(T){for(y.status="rejected",y.reason=T,T=0;T<f.length;T++)(0,f[T])(void 0)}),y}var Xv=q.S;q.S=function(i,o){R0=Fe(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&qA(i,o),Xv!==null&&Xv(i,o)};var fa=R(null);function Dm(){var i=fa.current;return i!==null?i:Jt.pooledCache}function Fu(i,o){o===null?B(fa,fa.current):B(fa,o.pool)}function Jv(){var i=Dm();return i===null?null:{parent:kn._currentValue,pool:i}}var So=Error(r(460)),Rm=Error(r(474)),Uu=Error(r(542)),Vu={then:function(){}};function Qv(i){return i=i.status,i==="fulfilled"||i==="rejected"}function Zv(i,o,f){switch(f=i[f],f===void 0?i.push(o):f!==o&&(o.then(Ms,Ms),o=f),o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,t_(i),i;default:if(typeof o.status=="string")o.then(Ms,Ms);else{if(i=Jt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=o,i.status="pending",i.then(function(y){if(o.status==="pending"){var T=o;T.status="fulfilled",T.value=y}},function(y){if(o.status==="pending"){var T=o;T.status="rejected",T.reason=y}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,t_(i),i}throw pa=o,So}}function ma(i){try{var o=i._init;return o(i._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(pa=f,So):f}}var pa=null;function e_(){if(pa===null)throw Error(r(459));var i=pa;return pa=null,i}function t_(i){if(i===So||i===Uu)throw Error(r(483))}var wo=null,Fl=0;function Gu(i){var o=Fl;return Fl+=1,wo===null&&(wo=[]),Zv(wo,i,o)}function Ul(i,o){o=o.props.ref,i.ref=o!==void 0?o:null}function Wu(i,o){throw o.$$typeof===g?Error(r(525)):(i=Object.prototype.toString.call(o),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":i)))}function n_(i){function o(pe,de){if(i){var be=pe.deletions;be===null?(pe.deletions=[de],pe.flags|=16):be.push(de)}}function f(pe,de){if(!i)return null;for(;de!==null;)o(pe,de),de=de.sibling;return null}function y(pe){for(var de=new Map;pe!==null;)pe.key!==null?de.set(pe.key,pe):de.set(pe.index,pe),pe=pe.sibling;return de}function T(pe,de){return pe=Bs(pe,de),pe.index=0,pe.sibling=null,pe}function L(pe,de,be){return pe.index=be,i?(be=pe.alternate,be!==null?(be=be.index,be<de?(pe.flags|=67108866,de):be):(pe.flags|=67108866,de)):(pe.flags|=1048576,de)}function K(pe){return i&&pe.alternate===null&&(pe.flags|=67108866),pe}function ee(pe,de,be,Ie){return de===null||de.tag!==6?(de=_m(be,pe.mode,Ie),de.return=pe,de):(de=T(de,be),de.return=pe,de)}function ce(pe,de,be,Ie){var ot=be.type;return ot===C?De(pe,de,be.props.children,Ie,be.key):de!==null&&(de.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===A&&ma(ot)===de.type)?(de=T(de,be.props),Ul(de,be),de.return=pe,de):(de=Bu(be.type,be.key,be.props,null,pe.mode,Ie),Ul(de,be),de.return=pe,de)}function ve(pe,de,be,Ie){return de===null||de.tag!==4||de.stateNode.containerInfo!==be.containerInfo||de.stateNode.implementation!==be.implementation?(de=Sm(be,pe.mode,Ie),de.return=pe,de):(de=T(de,be.children||[]),de.return=pe,de)}function De(pe,de,be,Ie,ot){return de===null||de.tag!==7?(de=ca(be,pe.mode,Ie,ot),de.return=pe,de):(de=T(de,be),de.return=pe,de)}function ze(pe,de,be){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return de=_m(""+de,pe.mode,be),de.return=pe,de;if(typeof de=="object"&&de!==null){switch(de.$$typeof){case x:return be=Bu(de.type,de.key,de.props,null,pe.mode,be),Ul(be,de),be.return=pe,be;case w:return de=Sm(de,pe.mode,be),de.return=pe,de;case A:return de=ma(de),ze(pe,de,be)}if(H(de)||z(de))return de=ca(de,pe.mode,be,null),de.return=pe,de;if(typeof de.then=="function")return ze(pe,Gu(de),be);if(de.$$typeof===b)return ze(pe,Hu(pe,de),be);Wu(pe,de)}return null}function Ce(pe,de,be,Ie){var ot=de!==null?de.key:null;if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return ot!==null?null:ee(pe,de,""+be,Ie);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case x:return be.key===ot?ce(pe,de,be,Ie):null;case w:return be.key===ot?ve(pe,de,be,Ie):null;case A:return be=ma(be),Ce(pe,de,be,Ie)}if(H(be)||z(be))return ot!==null?null:De(pe,de,be,Ie,null);if(typeof be.then=="function")return Ce(pe,de,Gu(be),Ie);if(be.$$typeof===b)return Ce(pe,de,Hu(pe,be),Ie);Wu(pe,be)}return null}function je(pe,de,be,Ie,ot){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number"||typeof Ie=="bigint")return pe=pe.get(be)||null,ee(de,pe,""+Ie,ot);if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case x:return pe=pe.get(Ie.key===null?be:Ie.key)||null,ce(de,pe,Ie,ot);case w:return pe=pe.get(Ie.key===null?be:Ie.key)||null,ve(de,pe,Ie,ot);case A:return Ie=ma(Ie),je(pe,de,be,Ie,ot)}if(H(Ie)||z(Ie))return pe=pe.get(be)||null,De(de,pe,Ie,ot,null);if(typeof Ie.then=="function")return je(pe,de,be,Gu(Ie),ot);if(Ie.$$typeof===b)return je(pe,de,be,Hu(de,Ie),ot);Wu(de,Ie)}return null}function nt(pe,de,be,Ie){for(var ot=null,Rt=null,st=de,vt=de=0,Et=null;st!==null&&vt<be.length;vt++){st.index>vt?(Et=st,st=null):Et=st.sibling;var Ot=Ce(pe,st,be[vt],Ie);if(Ot===null){st===null&&(st=Et);break}i&&st&&Ot.alternate===null&&o(pe,st),de=L(Ot,de,vt),Rt===null?ot=Ot:Rt.sibling=Ot,Rt=Ot,st=Et}if(vt===be.length)return f(pe,st),Nt&&$s(pe,vt),ot;if(st===null){for(;vt<be.length;vt++)st=ze(pe,be[vt],Ie),st!==null&&(de=L(st,de,vt),Rt===null?ot=st:Rt.sibling=st,Rt=st);return Nt&&$s(pe,vt),ot}for(st=y(st);vt<be.length;vt++)Et=je(st,pe,vt,be[vt],Ie),Et!==null&&(i&&Et.alternate!==null&&st.delete(Et.key===null?vt:Et.key),de=L(Et,de,vt),Rt===null?ot=Et:Rt.sibling=Et,Rt=Et);return i&&st.forEach(function(Bi){return o(pe,Bi)}),Nt&&$s(pe,vt),ot}function ct(pe,de,be,Ie){if(be==null)throw Error(r(151));for(var ot=null,Rt=null,st=de,vt=de=0,Et=null,Ot=be.next();st!==null&&!Ot.done;vt++,Ot=be.next()){st.index>vt?(Et=st,st=null):Et=st.sibling;var Bi=Ce(pe,st,Ot.value,Ie);if(Bi===null){st===null&&(st=Et);break}i&&st&&Bi.alternate===null&&o(pe,st),de=L(Bi,de,vt),Rt===null?ot=Bi:Rt.sibling=Bi,Rt=Bi,st=Et}if(Ot.done)return f(pe,st),Nt&&$s(pe,vt),ot;if(st===null){for(;!Ot.done;vt++,Ot=be.next())Ot=ze(pe,Ot.value,Ie),Ot!==null&&(de=L(Ot,de,vt),Rt===null?ot=Ot:Rt.sibling=Ot,Rt=Ot);return Nt&&$s(pe,vt),ot}for(st=y(st);!Ot.done;vt++,Ot=be.next())Ot=je(st,pe,vt,Ot.value,Ie),Ot!==null&&(i&&Ot.alternate!==null&&st.delete(Ot.key===null?vt:Ot.key),de=L(Ot,de,vt),Rt===null?ot=Ot:Rt.sibling=Ot,Rt=Ot);return i&&st.forEach(function(iD){return o(pe,iD)}),Nt&&$s(pe,vt),ot}function qt(pe,de,be,Ie){if(typeof be=="object"&&be!==null&&be.type===C&&be.key===null&&(be=be.props.children),typeof be=="object"&&be!==null){switch(be.$$typeof){case x:e:{for(var ot=be.key;de!==null;){if(de.key===ot){if(ot=be.type,ot===C){if(de.tag===7){f(pe,de.sibling),Ie=T(de,be.props.children),Ie.return=pe,pe=Ie;break e}}else if(de.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===A&&ma(ot)===de.type){f(pe,de.sibling),Ie=T(de,be.props),Ul(Ie,be),Ie.return=pe,pe=Ie;break e}f(pe,de);break}else o(pe,de);de=de.sibling}be.type===C?(Ie=ca(be.props.children,pe.mode,Ie,be.key),Ie.return=pe,pe=Ie):(Ie=Bu(be.type,be.key,be.props,null,pe.mode,Ie),Ul(Ie,be),Ie.return=pe,pe=Ie)}return K(pe);case w:e:{for(ot=be.key;de!==null;){if(de.key===ot)if(de.tag===4&&de.stateNode.containerInfo===be.containerInfo&&de.stateNode.implementation===be.implementation){f(pe,de.sibling),Ie=T(de,be.children||[]),Ie.return=pe,pe=Ie;break e}else{f(pe,de);break}else o(pe,de);de=de.sibling}Ie=Sm(be,pe.mode,Ie),Ie.return=pe,pe=Ie}return K(pe);case A:return be=ma(be),qt(pe,de,be,Ie)}if(H(be))return nt(pe,de,be,Ie);if(z(be)){if(ot=z(be),typeof ot!="function")throw Error(r(150));return be=ot.call(be),ct(pe,de,be,Ie)}if(typeof be.then=="function")return qt(pe,de,Gu(be),Ie);if(be.$$typeof===b)return qt(pe,de,Hu(pe,be),Ie);Wu(pe,be)}return typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint"?(be=""+be,de!==null&&de.tag===6?(f(pe,de.sibling),Ie=T(de,be),Ie.return=pe,pe=Ie):(f(pe,de),Ie=_m(be,pe.mode,Ie),Ie.return=pe,pe=Ie),K(pe)):f(pe,de)}return function(pe,de,be,Ie){try{Fl=0;var ot=qt(pe,de,be,Ie);return wo=null,ot}catch(st){if(st===So||st===Uu)throw st;var Rt=Sr(29,st,null,pe.mode);return Rt.lanes=Ie,Rt.return=pe,Rt}finally{}}}var ga=n_(!0),r_=n_(!1),_i=!1;function Om(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Im(i,o){i=i.updateQueue,o.updateQueue===i&&(o.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Si(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function wi(i,o,f){var y=i.updateQueue;if(y===null)return null;if(y=y.shared,(Pt&2)!==0){var T=y.pending;return T===null?o.next=o:(o.next=T.next,T.next=o),y.pending=o,o=Pu(i),zv(i,null,f),o}return Mu(i,y,o,f),Pu(i)}function Vl(i,o,f){if(o=o.updateQueue,o!==null&&(o=o.shared,(f&4194048)!==0)){var y=o.lanes;y&=i.pendingLanes,f|=y,o.lanes=f,oe(i,f)}}function Mm(i,o){var f=i.updateQueue,y=i.alternate;if(y!==null&&(y=y.updateQueue,f===y)){var T=null,L=null;if(f=f.firstBaseUpdate,f!==null){do{var K={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};L===null?T=L=K:L=L.next=K,f=f.next}while(f!==null);L===null?T=L=o:L=L.next=o}else T=L=o;f={baseState:y.baseState,firstBaseUpdate:T,lastBaseUpdate:L,shared:y.shared,callbacks:y.callbacks},i.updateQueue=f;return}i=f.lastBaseUpdate,i===null?f.firstBaseUpdate=o:i.next=o,f.lastBaseUpdate=o}var Pm=!1;function Gl(){if(Pm){var i=_o;if(i!==null)throw i}}function Wl(i,o,f,y){Pm=!1;var T=i.updateQueue;_i=!1;var L=T.firstBaseUpdate,K=T.lastBaseUpdate,ee=T.shared.pending;if(ee!==null){T.shared.pending=null;var ce=ee,ve=ce.next;ce.next=null,K===null?L=ve:K.next=ve,K=ce;var De=i.alternate;De!==null&&(De=De.updateQueue,ee=De.lastBaseUpdate,ee!==K&&(ee===null?De.firstBaseUpdate=ve:ee.next=ve,De.lastBaseUpdate=ce))}if(L!==null){var ze=T.baseState;K=0,De=ve=ce=null,ee=L;do{var Ce=ee.lane&-536870913,je=Ce!==ee.lane;if(je?(jt&Ce)===Ce:(y&Ce)===Ce){Ce!==0&&Ce===vo&&(Pm=!0),De!==null&&(De=De.next={lane:0,tag:ee.tag,payload:ee.payload,callback:null,next:null});e:{var nt=i,ct=ee;Ce=o;var qt=f;switch(ct.tag){case 1:if(nt=ct.payload,typeof nt=="function"){ze=nt.call(qt,ze,Ce);break e}ze=nt;break e;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=ct.payload,Ce=typeof nt=="function"?nt.call(qt,ze,Ce):nt,Ce==null)break e;ze=m({},ze,Ce);break e;case 2:_i=!0}}Ce=ee.callback,Ce!==null&&(i.flags|=64,je&&(i.flags|=8192),je=T.callbacks,je===null?T.callbacks=[Ce]:je.push(Ce))}else je={lane:Ce,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},De===null?(ve=De=je,ce=ze):De=De.next=je,K|=Ce;if(ee=ee.next,ee===null){if(ee=T.shared.pending,ee===null)break;je=ee,ee=je.next,je.next=null,T.lastBaseUpdate=je,T.shared.pending=null}}while(!0);De===null&&(ce=ze),T.baseState=ce,T.firstBaseUpdate=ve,T.lastBaseUpdate=De,L===null&&(T.shared.lanes=0),Ni|=K,i.lanes=K,i.memoizedState=ze}}function s_(i,o){if(typeof i!="function")throw Error(r(191,i));i.call(o)}function i_(i,o){var f=i.callbacks;if(f!==null)for(i.callbacks=null,i=0;i<f.length;i++)s_(f[i],o)}var Co=R(null),qu=R(0);function a_(i,o){i=Xs,B(qu,i),B(Co,o),Xs=i|o.baseLanes}function Bm(){B(qu,Xs),B(Co,Co.current)}function $m(){Xs=qu.current,W(Co),W(qu)}var wr=R(null),Fr=null;function Ci(i){var o=i.alternate;B(xn,xn.current&1),B(wr,i),Fr===null&&(o===null||Co.current!==null||o.memoizedState!==null)&&(Fr=i)}function zm(i){B(xn,xn.current),B(wr,i),Fr===null&&(Fr=i)}function o_(i){i.tag===22?(B(xn,xn.current),B(wr,i),Fr===null&&(Fr=i)):ki()}function ki(){B(xn,xn.current),B(wr,wr.current)}function Cr(i){W(wr),Fr===i&&(Fr=null),W(xn)}var xn=R(0);function Ku(i){for(var o=i;o!==null;){if(o.tag===13){var f=o.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||Wp(f)||qp(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===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Fs=0,bt=null,Gt=null,jn=null,Yu=!1,ko=!1,xa=!1,Xu=0,ql=0,jo=null,YA=0;function fn(){throw Error(r(321))}function Hm(i,o){if(o===null)return!1;for(var f=0;f<o.length&&f<i.length;f++)if(!_r(i[f],o[f]))return!1;return!0}function Fm(i,o,f,y,T,L){return Fs=L,bt=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,q.H=i===null||i.memoizedState===null?V_:rp,xa=!1,L=f(y,T),xa=!1,ko&&(L=c_(o,f,y,T)),l_(i),L}function l_(i){q.H=Xl;var o=Gt!==null&&Gt.next!==null;if(Fs=0,jn=Gt=bt=null,Yu=!1,ql=0,jo=null,o)throw Error(r(300));i===null||En||(i=i.dependencies,i!==null&&zu(i)&&(En=!0))}function c_(i,o,f,y){bt=i;var T=0;do{if(ko&&(jo=null),ql=0,ko=!1,25<=T)throw Error(r(301));if(T+=1,jn=Gt=null,i.updateQueue!=null){var L=i.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}q.H=G_,L=o(f,y)}while(ko);return L}function XA(){var i=q.H,o=i.useState()[0];return o=typeof o.then=="function"?Kl(o):o,i=i.useState()[0],(Gt!==null?Gt.memoizedState:null)!==i&&(bt.flags|=1024),o}function Um(){var i=Xu!==0;return Xu=0,i}function Vm(i,o,f){o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~f}function Gm(i){if(Yu){for(i=i.memoizedState;i!==null;){var o=i.queue;o!==null&&(o.pending=null),i=i.next}Yu=!1}Fs=0,jn=Gt=bt=null,ko=!1,ql=Xu=0,jo=null}function rr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jn===null?bt.memoizedState=jn=i:jn=jn.next=i,jn}function yn(){if(Gt===null){var i=bt.alternate;i=i!==null?i.memoizedState:null}else i=Gt.next;var o=jn===null?bt.memoizedState:jn.next;if(o!==null)jn=o,Gt=i;else{if(i===null)throw bt.alternate===null?Error(r(467)):Error(r(310));Gt=i,i={memoizedState:Gt.memoizedState,baseState:Gt.baseState,baseQueue:Gt.baseQueue,queue:Gt.queue,next:null},jn===null?bt.memoizedState=jn=i:jn=jn.next=i}return jn}function Ju(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Kl(i){var o=ql;return ql+=1,jo===null&&(jo=[]),i=Zv(jo,i,o),o=bt,(jn===null?o.memoizedState:jn.next)===null&&(o=o.alternate,q.H=o===null||o.memoizedState===null?V_:rp),i}function Qu(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Kl(i);if(i.$$typeof===b)return Gn(i)}throw Error(r(438,String(i)))}function Wm(i){var o=null,f=bt.updateQueue;if(f!==null&&(o=f.memoCache),o==null){var y=bt.alternate;y!==null&&(y=y.updateQueue,y!==null&&(y=y.memoCache,y!=null&&(o={data:y.data.map(function(T){return T.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),f===null&&(f=Ju(),bt.updateQueue=f),f.memoCache=o,f=o.data[o.index],f===void 0)for(f=o.data[o.index]=Array(i),y=0;y<i;y++)f[y]=P;return o.index++,f}function Us(i,o){return typeof o=="function"?o(i):o}function Zu(i){var o=yn();return qm(o,Gt,i)}function qm(i,o,f){var y=i.queue;if(y===null)throw Error(r(311));y.lastRenderedReducer=f;var T=i.baseQueue,L=y.pending;if(L!==null){if(T!==null){var K=T.next;T.next=L.next,L.next=K}o.baseQueue=T=L,y.pending=null}if(L=i.baseState,T===null)i.memoizedState=L;else{o=T.next;var ee=K=null,ce=null,ve=o,De=!1;do{var ze=ve.lane&-536870913;if(ze!==ve.lane?(jt&ze)===ze:(Fs&ze)===ze){var Ce=ve.revertLane;if(Ce===0)ce!==null&&(ce=ce.next={lane:0,revertLane:0,gesture:null,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null}),ze===vo&&(De=!0);else if((Fs&Ce)===Ce){ve=ve.next,Ce===vo&&(De=!0);continue}else ze={lane:0,revertLane:ve.revertLane,gesture:null,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null},ce===null?(ee=ce=ze,K=L):ce=ce.next=ze,bt.lanes|=Ce,Ni|=Ce;ze=ve.action,xa&&f(L,ze),L=ve.hasEagerState?ve.eagerState:f(L,ze)}else Ce={lane:ze,revertLane:ve.revertLane,gesture:ve.gesture,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null},ce===null?(ee=ce=Ce,K=L):ce=ce.next=Ce,bt.lanes|=ze,Ni|=ze;ve=ve.next}while(ve!==null&&ve!==o);if(ce===null?K=L:ce.next=ee,!_r(L,i.memoizedState)&&(En=!0,De&&(f=_o,f!==null)))throw f;i.memoizedState=L,i.baseState=K,i.baseQueue=ce,y.lastRenderedState=L}return T===null&&(y.lanes=0),[i.memoizedState,y.dispatch]}function Km(i){var o=yn(),f=o.queue;if(f===null)throw Error(r(311));f.lastRenderedReducer=i;var y=f.dispatch,T=f.pending,L=o.memoizedState;if(T!==null){f.pending=null;var K=T=T.next;do L=i(L,K.action),K=K.next;while(K!==T);_r(L,o.memoizedState)||(En=!0),o.memoizedState=L,o.baseQueue===null&&(o.baseState=L),f.lastRenderedState=L}return[L,y]}function u_(i,o,f){var y=bt,T=yn(),L=Nt;if(L){if(f===void 0)throw Error(r(407));f=f()}else f=o();var K=!_r((Gt||T).memoizedState,f);if(K&&(T.memoizedState=f,En=!0),T=T.queue,Jm(f_.bind(null,y,T,i),[i]),T.getSnapshot!==o||K||jn!==null&&jn.memoizedState.tag&1){if(y.flags|=2048,Eo(9,{destroy:void 0},h_.bind(null,y,T,f,o),null),Jt===null)throw Error(r(349));L||(Fs&127)!==0||d_(y,o,f)}return f}function d_(i,o,f){i.flags|=16384,i={getSnapshot:o,value:f},o=bt.updateQueue,o===null?(o=Ju(),bt.updateQueue=o,o.stores=[i]):(f=o.stores,f===null?o.stores=[i]:f.push(i))}function h_(i,o,f,y){o.value=f,o.getSnapshot=y,m_(o)&&p_(i)}function f_(i,o,f){return f(function(){m_(o)&&p_(i)})}function m_(i){var o=i.getSnapshot;i=i.value;try{var f=o();return!_r(i,f)}catch{return!0}}function p_(i){var o=la(i,2);o!==null&&fr(o,i,2)}function Ym(i){var o=rr();if(typeof i=="function"){var f=i;if(i=f(),xa){ge(!0);try{f()}finally{ge(!1)}}}return o.memoizedState=o.baseState=i,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Us,lastRenderedState:i},o}function g_(i,o,f,y){return i.baseState=f,qm(i,Gt,typeof y=="function"?y:Us)}function JA(i,o,f,y,T){if(nd(i))throw Error(r(485));if(i=o.action,i!==null){var L={payload:T,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(K){L.listeners.push(K)}};q.T!==null?f(!0):L.isTransition=!1,y(L),f=o.pending,f===null?(L.next=o.pending=L,x_(o,L)):(L.next=f.next,o.pending=f.next=L)}}function x_(i,o){var f=o.action,y=o.payload,T=i.state;if(o.isTransition){var L=q.T,K={};q.T=K;try{var ee=f(T,y),ce=q.S;ce!==null&&ce(K,ee),y_(i,o,ee)}catch(ve){Xm(i,o,ve)}finally{L!==null&&K.types!==null&&(L.types=K.types),q.T=L}}else try{L=f(T,y),y_(i,o,L)}catch(ve){Xm(i,o,ve)}}function y_(i,o,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(y){b_(i,o,y)},function(y){return Xm(i,o,y)}):b_(i,o,f)}function b_(i,o,f){o.status="fulfilled",o.value=f,v_(o),i.state=f,o=i.pending,o!==null&&(f=o.next,f===o?i.pending=null:(f=f.next,o.next=f,x_(i,f)))}function Xm(i,o,f){var y=i.pending;if(i.pending=null,y!==null){y=y.next;do o.status="rejected",o.reason=f,v_(o),o=o.next;while(o!==y)}i.action=null}function v_(i){i=i.listeners;for(var o=0;o<i.length;o++)(0,i[o])()}function __(i,o){return o}function S_(i,o){if(Nt){var f=Jt.formState;if(f!==null){e:{var y=bt;if(Nt){if(sn){t:{for(var T=sn,L=Hr;T.nodeType!==8;){if(!L){T=null;break t}if(T=Ur(T.nextSibling),T===null){T=null;break t}}L=T.data,T=L==="F!"||L==="F"?T:null}if(T){sn=Ur(T.nextSibling),y=T.data==="F!";break e}}bi(y)}y=!1}y&&(o=f[0])}}return f=rr(),f.memoizedState=f.baseState=o,y={pending:null,lanes:0,dispatch:null,lastRenderedReducer:__,lastRenderedState:o},f.queue=y,f=H_.bind(null,bt,y),y.dispatch=f,y=Ym(!1),L=np.bind(null,bt,!1,y.queue),y=rr(),T={state:o,dispatch:null,action:i,pending:null},y.queue=T,f=JA.bind(null,bt,T,L,f),T.dispatch=f,y.memoizedState=i,[o,f,!1]}function w_(i){var o=yn();return C_(o,Gt,i)}function C_(i,o,f){if(o=qm(i,o,__)[0],i=Zu(Us)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var y=Kl(o)}catch(K){throw K===So?Uu:K}else y=o;o=yn();var T=o.queue,L=T.dispatch;return f!==o.memoizedState&&(bt.flags|=2048,Eo(9,{destroy:void 0},QA.bind(null,T,f),null)),[y,L,i]}function QA(i,o){i.action=o}function k_(i){var o=yn(),f=Gt;if(f!==null)return C_(o,f,i);yn(),o=o.memoizedState,f=yn();var y=f.queue.dispatch;return f.memoizedState=i,[o,y,!1]}function Eo(i,o,f,y){return i={tag:i,create:f,deps:y,inst:o,next:null},o=bt.updateQueue,o===null&&(o=Ju(),bt.updateQueue=o),f=o.lastEffect,f===null?o.lastEffect=i.next=i:(y=f.next,f.next=i,i.next=y,o.lastEffect=i),i}function j_(){return yn().memoizedState}function ed(i,o,f,y){var T=rr();bt.flags|=i,T.memoizedState=Eo(1|o,{destroy:void 0},f,y===void 0?null:y)}function td(i,o,f,y){var T=yn();y=y===void 0?null:y;var L=T.memoizedState.inst;Gt!==null&&y!==null&&Hm(y,Gt.memoizedState.deps)?T.memoizedState=Eo(o,L,f,y):(bt.flags|=i,T.memoizedState=Eo(1|o,L,f,y))}function E_(i,o){ed(8390656,8,i,o)}function Jm(i,o){td(2048,8,i,o)}function ZA(i){bt.flags|=4;var o=bt.updateQueue;if(o===null)o=Ju(),bt.updateQueue=o,o.events=[i];else{var f=o.events;f===null?o.events=[i]:f.push(i)}}function N_(i){var o=yn().memoizedState;return ZA({ref:o,nextImpl:i}),function(){if((Pt&2)!==0)throw Error(r(440));return o.impl.apply(void 0,arguments)}}function T_(i,o){return td(4,2,i,o)}function A_(i,o){return td(4,4,i,o)}function L_(i,o){if(typeof o=="function"){i=i();var f=o(i);return function(){typeof f=="function"?f():o(null)}}if(o!=null)return i=i(),o.current=i,function(){o.current=null}}function D_(i,o,f){f=f!=null?f.concat([i]):null,td(4,4,L_.bind(null,o,i),f)}function Qm(){}function R_(i,o){var f=yn();o=o===void 0?null:o;var y=f.memoizedState;return o!==null&&Hm(o,y[1])?y[0]:(f.memoizedState=[i,o],i)}function O_(i,o){var f=yn();o=o===void 0?null:o;var y=f.memoizedState;if(o!==null&&Hm(o,y[1]))return y[0];if(y=i(),xa){ge(!0);try{i()}finally{ge(!1)}}return f.memoizedState=[y,o],y}function Zm(i,o,f){return f===void 0||(Fs&1073741824)!==0&&(jt&261930)===0?i.memoizedState=o:(i.memoizedState=f,i=I0(),bt.lanes|=i,Ni|=i,f)}function I_(i,o,f,y){return _r(f,o)?f:Co.current!==null?(i=Zm(i,f,y),_r(i,o)||(En=!0),i):(Fs&42)===0||(Fs&1073741824)!==0&&(jt&261930)===0?(En=!0,i.memoizedState=f):(i=I0(),bt.lanes|=i,Ni|=i,o)}function M_(i,o,f,y,T){var L=X.p;X.p=L!==0&&8>L?L:8;var K=q.T,ee={};q.T=ee,np(i,!1,o,f);try{var ce=T(),ve=q.S;if(ve!==null&&ve(ee,ce),ce!==null&&typeof ce=="object"&&typeof ce.then=="function"){var De=KA(ce,y);Yl(i,o,De,Er(i))}else Yl(i,o,y,Er(i))}catch(ze){Yl(i,o,{then:function(){},status:"rejected",reason:ze},Er())}finally{X.p=L,K!==null&&ee.types!==null&&(K.types=ee.types),q.T=K}}function eL(){}function ep(i,o,f,y){if(i.tag!==5)throw Error(r(476));var T=P_(i).queue;M_(i,T,o,Y,f===null?eL:function(){return B_(i),f(y)})}function P_(i){var o=i.memoizedState;if(o!==null)return o;o={memoizedState:Y,baseState:Y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Us,lastRenderedState:Y},next:null};var f={};return o.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Us,lastRenderedState:f},next:null},i.memoizedState=o,i=i.alternate,i!==null&&(i.memoizedState=o),o}function B_(i){var o=P_(i);o.next===null&&(o=i.alternate.memoizedState),Yl(i,o.next.queue,{},Er())}function tp(){return Gn(hc)}function $_(){return yn().memoizedState}function z_(){return yn().memoizedState}function tL(i){for(var o=i.return;o!==null;){switch(o.tag){case 24:case 3:var f=Er();i=Si(f);var y=wi(o,i,f);y!==null&&(fr(y,o,f),Vl(y,o,f)),o={cache:Am()},i.payload=o;return}o=o.return}}function nL(i,o,f){var y=Er();f={lane:y,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},nd(i)?F_(o,f):(f=bm(i,o,f,y),f!==null&&(fr(f,i,y),U_(f,o,y)))}function H_(i,o,f){var y=Er();Yl(i,o,f,y)}function Yl(i,o,f,y){var T={lane:y,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(nd(i))F_(o,T);else{var L=i.alternate;if(i.lanes===0&&(L===null||L.lanes===0)&&(L=o.lastRenderedReducer,L!==null))try{var K=o.lastRenderedState,ee=L(K,f);if(T.hasEagerState=!0,T.eagerState=ee,_r(ee,K))return Mu(i,o,T,0),Jt===null&&Iu(),!1}catch{}finally{}if(f=bm(i,o,T,y),f!==null)return fr(f,i,y),U_(f,o,y),!0}return!1}function np(i,o,f,y){if(y={lane:2,revertLane:Op(),gesture:null,action:y,hasEagerState:!1,eagerState:null,next:null},nd(i)){if(o)throw Error(r(479))}else o=bm(i,f,y,2),o!==null&&fr(o,i,2)}function nd(i){var o=i.alternate;return i===bt||o!==null&&o===bt}function F_(i,o){ko=Yu=!0;var f=i.pending;f===null?o.next=o:(o.next=f.next,f.next=o),i.pending=o}function U_(i,o,f){if((f&4194048)!==0){var y=o.lanes;y&=i.pendingLanes,f|=y,o.lanes=f,oe(i,f)}}var Xl={readContext:Gn,use:Qu,useCallback:fn,useContext:fn,useEffect:fn,useImperativeHandle:fn,useLayoutEffect:fn,useInsertionEffect:fn,useMemo:fn,useReducer:fn,useRef:fn,useState:fn,useDebugValue:fn,useDeferredValue:fn,useTransition:fn,useSyncExternalStore:fn,useId:fn,useHostTransitionStatus:fn,useFormState:fn,useActionState:fn,useOptimistic:fn,useMemoCache:fn,useCacheRefresh:fn};Xl.useEffectEvent=fn;var V_={readContext:Gn,use:Qu,useCallback:function(i,o){return rr().memoizedState=[i,o===void 0?null:o],i},useContext:Gn,useEffect:E_,useImperativeHandle:function(i,o,f){f=f!=null?f.concat([i]):null,ed(4194308,4,L_.bind(null,o,i),f)},useLayoutEffect:function(i,o){return ed(4194308,4,i,o)},useInsertionEffect:function(i,o){ed(4,2,i,o)},useMemo:function(i,o){var f=rr();o=o===void 0?null:o;var y=i();if(xa){ge(!0);try{i()}finally{ge(!1)}}return f.memoizedState=[y,o],y},useReducer:function(i,o,f){var y=rr();if(f!==void 0){var T=f(o);if(xa){ge(!0);try{f(o)}finally{ge(!1)}}}else T=o;return y.memoizedState=y.baseState=T,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:T},y.queue=i,i=i.dispatch=nL.bind(null,bt,i),[y.memoizedState,i]},useRef:function(i){var o=rr();return i={current:i},o.memoizedState=i},useState:function(i){i=Ym(i);var o=i.queue,f=H_.bind(null,bt,o);return o.dispatch=f,[i.memoizedState,f]},useDebugValue:Qm,useDeferredValue:function(i,o){var f=rr();return Zm(f,i,o)},useTransition:function(){var i=Ym(!1);return i=M_.bind(null,bt,i.queue,!0,!1),rr().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,o,f){var y=bt,T=rr();if(Nt){if(f===void 0)throw Error(r(407));f=f()}else{if(f=o(),Jt===null)throw Error(r(349));(jt&127)!==0||d_(y,o,f)}T.memoizedState=f;var L={value:f,getSnapshot:o};return T.queue=L,E_(f_.bind(null,y,L,i),[i]),y.flags|=2048,Eo(9,{destroy:void 0},h_.bind(null,y,L,f,o),null),f},useId:function(){var i=rr(),o=Jt.identifierPrefix;if(Nt){var f=xs,y=gs;f=(y&~(1<<32-Ve(y)-1)).toString(32)+f,o="_"+o+"R_"+f,f=Xu++,0<f&&(o+="H"+f.toString(32)),o+="_"}else f=YA++,o="_"+o+"r_"+f.toString(32)+"_";return i.memoizedState=o},useHostTransitionStatus:tp,useFormState:S_,useActionState:S_,useOptimistic:function(i){var o=rr();o.memoizedState=o.baseState=i;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=f,o=np.bind(null,bt,!0,f),f.dispatch=o,[i,o]},useMemoCache:Wm,useCacheRefresh:function(){return rr().memoizedState=tL.bind(null,bt)},useEffectEvent:function(i){var o=rr(),f={impl:i};return o.memoizedState=f,function(){if((Pt&2)!==0)throw Error(r(440));return f.impl.apply(void 0,arguments)}}},rp={readContext:Gn,use:Qu,useCallback:R_,useContext:Gn,useEffect:Jm,useImperativeHandle:D_,useInsertionEffect:T_,useLayoutEffect:A_,useMemo:O_,useReducer:Zu,useRef:j_,useState:function(){return Zu(Us)},useDebugValue:Qm,useDeferredValue:function(i,o){var f=yn();return I_(f,Gt.memoizedState,i,o)},useTransition:function(){var i=Zu(Us)[0],o=yn().memoizedState;return[typeof i=="boolean"?i:Kl(i),o]},useSyncExternalStore:u_,useId:$_,useHostTransitionStatus:tp,useFormState:w_,useActionState:w_,useOptimistic:function(i,o){var f=yn();return g_(f,Gt,i,o)},useMemoCache:Wm,useCacheRefresh:z_};rp.useEffectEvent=N_;var G_={readContext:Gn,use:Qu,useCallback:R_,useContext:Gn,useEffect:Jm,useImperativeHandle:D_,useInsertionEffect:T_,useLayoutEffect:A_,useMemo:O_,useReducer:Km,useRef:j_,useState:function(){return Km(Us)},useDebugValue:Qm,useDeferredValue:function(i,o){var f=yn();return Gt===null?Zm(f,i,o):I_(f,Gt.memoizedState,i,o)},useTransition:function(){var i=Km(Us)[0],o=yn().memoizedState;return[typeof i=="boolean"?i:Kl(i),o]},useSyncExternalStore:u_,useId:$_,useHostTransitionStatus:tp,useFormState:k_,useActionState:k_,useOptimistic:function(i,o){var f=yn();return Gt!==null?g_(f,Gt,i,o):(f.baseState=i,[i,f.queue.dispatch])},useMemoCache:Wm,useCacheRefresh:z_};G_.useEffectEvent=N_;function sp(i,o,f,y){o=i.memoizedState,f=f(y,o),f=f==null?o:m({},o,f),i.memoizedState=f,i.lanes===0&&(i.updateQueue.baseState=f)}var ip={enqueueSetState:function(i,o,f){i=i._reactInternals;var y=Er(),T=Si(y);T.payload=o,f!=null&&(T.callback=f),o=wi(i,T,y),o!==null&&(fr(o,i,y),Vl(o,i,y))},enqueueReplaceState:function(i,o,f){i=i._reactInternals;var y=Er(),T=Si(y);T.tag=1,T.payload=o,f!=null&&(T.callback=f),o=wi(i,T,y),o!==null&&(fr(o,i,y),Vl(o,i,y))},enqueueForceUpdate:function(i,o){i=i._reactInternals;var f=Er(),y=Si(f);y.tag=2,o!=null&&(y.callback=o),o=wi(i,y,f),o!==null&&(fr(o,i,f),Vl(o,i,f))}};function W_(i,o,f,y,T,L,K){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(y,L,K):o.prototype&&o.prototype.isPureReactComponent?!Ml(f,y)||!Ml(T,L):!0}function q_(i,o,f,y){i=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(f,y),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(f,y),o.state!==i&&ip.enqueueReplaceState(o,o.state,null)}function ya(i,o){var f=o;if("ref"in o){f={};for(var y in o)y!=="ref"&&(f[y]=o[y])}if(i=i.defaultProps){f===o&&(f=m({},f));for(var T in i)f[T]===void 0&&(f[T]=i[T])}return f}function K_(i){Ou(i)}function Y_(i){console.error(i)}function X_(i){Ou(i)}function rd(i,o){try{var f=i.onUncaughtError;f(o.value,{componentStack:o.stack})}catch(y){setTimeout(function(){throw y})}}function J_(i,o,f){try{var y=i.onCaughtError;y(f.value,{componentStack:f.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function ap(i,o,f){return f=Si(f),f.tag=3,f.payload={element:null},f.callback=function(){rd(i,o)},f}function Q_(i){return i=Si(i),i.tag=3,i}function Z_(i,o,f,y){var T=f.type.getDerivedStateFromError;if(typeof T=="function"){var L=y.value;i.payload=function(){return T(L)},i.callback=function(){J_(o,f,y)}}var K=f.stateNode;K!==null&&typeof K.componentDidCatch=="function"&&(i.callback=function(){J_(o,f,y),typeof T!="function"&&(Ti===null?Ti=new Set([this]):Ti.add(this));var ee=y.stack;this.componentDidCatch(y.value,{componentStack:ee!==null?ee:""})})}function rL(i,o,f,y,T){if(f.flags|=32768,y!==null&&typeof y=="object"&&typeof y.then=="function"){if(o=f.alternate,o!==null&&bo(o,f,T,!0),f=wr.current,f!==null){switch(f.tag){case 31:case 13:return Fr===null?pd():f.alternate===null&&mn===0&&(mn=3),f.flags&=-257,f.flags|=65536,f.lanes=T,y===Vu?f.flags|=16384:(o=f.updateQueue,o===null?f.updateQueue=new Set([y]):o.add(y),Lp(i,y,T)),!1;case 22:return f.flags|=65536,y===Vu?f.flags|=16384:(o=f.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([y])},f.updateQueue=o):(f=o.retryQueue,f===null?o.retryQueue=new Set([y]):f.add(y)),Lp(i,y,T)),!1}throw Error(r(435,f.tag))}return Lp(i,y,T),pd(),!1}if(Nt)return o=wr.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=T,y!==km&&(i=Error(r(422),{cause:y}),$l(Br(i,f)))):(y!==km&&(o=Error(r(423),{cause:y}),$l(Br(o,f))),i=i.current.alternate,i.flags|=65536,T&=-T,i.lanes|=T,y=Br(y,f),T=ap(i.stateNode,y,T),Mm(i,T),mn!==4&&(mn=2)),!1;var L=Error(r(520),{cause:y});if(L=Br(L,f),sc===null?sc=[L]:sc.push(L),mn!==4&&(mn=2),o===null)return!0;y=Br(y,f),f=o;do{switch(f.tag){case 3:return f.flags|=65536,i=T&-T,f.lanes|=i,i=ap(f.stateNode,y,i),Mm(f,i),!1;case 1:if(o=f.type,L=f.stateNode,(f.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(Ti===null||!Ti.has(L))))return f.flags|=65536,T&=-T,f.lanes|=T,T=Q_(T),Z_(T,i,f,y),Mm(f,T),!1}f=f.return}while(f!==null);return!1}var op=Error(r(461)),En=!1;function Wn(i,o,f,y){o.child=i===null?r_(o,null,f,y):ga(o,i.child,f,y)}function e0(i,o,f,y,T){f=f.render;var L=o.ref;if("ref"in y){var K={};for(var ee in y)ee!=="ref"&&(K[ee]=y[ee])}else K=y;return ha(o),y=Fm(i,o,f,K,L,T),ee=Um(),i!==null&&!En?(Vm(i,o,T),Vs(i,o,T)):(Nt&&ee&&wm(o),o.flags|=1,Wn(i,o,y,T),o.child)}function t0(i,o,f,y,T){if(i===null){var L=f.type;return typeof L=="function"&&!vm(L)&&L.defaultProps===void 0&&f.compare===null?(o.tag=15,o.type=L,n0(i,o,L,y,T)):(i=Bu(f.type,null,y,o,o.mode,T),i.ref=o.ref,i.return=o,o.child=i)}if(L=i.child,!pp(i,T)){var K=L.memoizedProps;if(f=f.compare,f=f!==null?f:Ml,f(K,y)&&i.ref===o.ref)return Vs(i,o,T)}return o.flags|=1,i=Bs(L,y),i.ref=o.ref,i.return=o,o.child=i}function n0(i,o,f,y,T){if(i!==null){var L=i.memoizedProps;if(Ml(L,y)&&i.ref===o.ref)if(En=!1,o.pendingProps=y=L,pp(i,T))(i.flags&131072)!==0&&(En=!0);else return o.lanes=i.lanes,Vs(i,o,T)}return lp(i,o,f,y,T)}function r0(i,o,f,y){var T=y.children,L=i!==null?i.memoizedState:null;if(i===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),y.mode==="hidden"){if((o.flags&128)!==0){if(L=L!==null?L.baseLanes|f:f,i!==null){for(y=o.child=i.child,T=0;y!==null;)T=T|y.lanes|y.childLanes,y=y.sibling;y=T&~L}else y=0,o.child=null;return s0(i,o,L,f,y)}if((f&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},i!==null&&Fu(o,L!==null?L.cachePool:null),L!==null?a_(o,L):Bm(),o_(o);else return y=o.lanes=536870912,s0(i,o,L!==null?L.baseLanes|f:f,f,y)}else L!==null?(Fu(o,L.cachePool),a_(o,L),ki(),o.memoizedState=null):(i!==null&&Fu(o,null),Bm(),ki());return Wn(i,o,T,f),o.child}function Jl(i,o){return i!==null&&i.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function s0(i,o,f,y,T){var L=Dm();return L=L===null?null:{parent:kn._currentValue,pool:L},o.memoizedState={baseLanes:f,cachePool:L},i!==null&&Fu(o,null),Bm(),o_(o),i!==null&&bo(i,o,y,!0),o.childLanes=T,null}function sd(i,o){return o=ad({mode:o.mode,children:o.children},i.mode),o.ref=i.ref,i.child=o,o.return=i,o}function i0(i,o,f){return ga(o,i.child,null,f),i=sd(o,o.pendingProps),i.flags|=2,Cr(o),o.memoizedState=null,i}function sL(i,o,f){var y=o.pendingProps,T=(o.flags&128)!==0;if(o.flags&=-129,i===null){if(Nt){if(y.mode==="hidden")return i=sd(o,y),o.lanes=536870912,Jl(null,i);if(zm(o),(i=sn)?(i=xS(i,Hr),i=i!==null&&i.data==="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:xi!==null?{id:gs,overflow:xs}:null,retryLane:536870912,hydrationErrors:null},f=Fv(i),f.return=o,o.child=f,Vn=o,sn=null)):i=null,i===null)throw bi(o);return o.lanes=536870912,null}return sd(o,y)}var L=i.memoizedState;if(L!==null){var K=L.dehydrated;if(zm(o),T)if(o.flags&256)o.flags&=-257,o=i0(i,o,f);else if(o.memoizedState!==null)o.child=i.child,o.flags|=128,o=null;else throw Error(r(558));else if(En||bo(i,o,f,!1),T=(f&i.childLanes)!==0,En||T){if(y=Jt,y!==null&&(K=Pe(y,f),K!==0&&K!==L.retryLane))throw L.retryLane=K,la(i,K),fr(y,i,K),op;pd(),o=i0(i,o,f)}else i=L.treeContext,sn=Ur(K.nextSibling),Vn=o,Nt=!0,yi=null,Hr=!1,i!==null&&Gv(o,i),o=sd(o,y),o.flags|=4096;return o}return i=Bs(i.child,{mode:y.mode,children:y.children}),i.ref=o.ref,o.child=i,i.return=o,i}function id(i,o){var f=o.ref;if(f===null)i!==null&&i.ref!==null&&(o.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(r(284));(i===null||i.ref!==f)&&(o.flags|=4194816)}}function lp(i,o,f,y,T){return ha(o),f=Fm(i,o,f,y,void 0,T),y=Um(),i!==null&&!En?(Vm(i,o,T),Vs(i,o,T)):(Nt&&y&&wm(o),o.flags|=1,Wn(i,o,f,T),o.child)}function a0(i,o,f,y,T,L){return ha(o),o.updateQueue=null,f=c_(o,y,f,T),l_(i),y=Um(),i!==null&&!En?(Vm(i,o,L),Vs(i,o,L)):(Nt&&y&&wm(o),o.flags|=1,Wn(i,o,f,L),o.child)}function o0(i,o,f,y,T){if(ha(o),o.stateNode===null){var L=po,K=f.contextType;typeof K=="object"&&K!==null&&(L=Gn(K)),L=new f(y,L),o.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=ip,o.stateNode=L,L._reactInternals=o,L=o.stateNode,L.props=y,L.state=o.memoizedState,L.refs={},Om(o),K=f.contextType,L.context=typeof K=="object"&&K!==null?Gn(K):po,L.state=o.memoizedState,K=f.getDerivedStateFromProps,typeof K=="function"&&(sp(o,f,K,y),L.state=o.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(K=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),K!==L.state&&ip.enqueueReplaceState(L,L.state,null),Wl(o,y,L,T),Gl(),L.state=o.memoizedState),typeof L.componentDidMount=="function"&&(o.flags|=4194308),y=!0}else if(i===null){L=o.stateNode;var ee=o.memoizedProps,ce=ya(f,ee);L.props=ce;var ve=L.context,De=f.contextType;K=po,typeof De=="object"&&De!==null&&(K=Gn(De));var ze=f.getDerivedStateFromProps;De=typeof ze=="function"||typeof L.getSnapshotBeforeUpdate=="function",ee=o.pendingProps!==ee,De||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(ee||ve!==K)&&q_(o,L,y,K),_i=!1;var Ce=o.memoizedState;L.state=Ce,Wl(o,y,L,T),Gl(),ve=o.memoizedState,ee||Ce!==ve||_i?(typeof ze=="function"&&(sp(o,f,ze,y),ve=o.memoizedState),(ce=_i||W_(o,f,ce,y,Ce,ve,K))?(De||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(o.flags|=4194308)):(typeof L.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=y,o.memoizedState=ve),L.props=y,L.state=ve,L.context=K,y=ce):(typeof L.componentDidMount=="function"&&(o.flags|=4194308),y=!1)}else{L=o.stateNode,Im(i,o),K=o.memoizedProps,De=ya(f,K),L.props=De,ze=o.pendingProps,Ce=L.context,ve=f.contextType,ce=po,typeof ve=="object"&&ve!==null&&(ce=Gn(ve)),ee=f.getDerivedStateFromProps,(ve=typeof ee=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(K!==ze||Ce!==ce)&&q_(o,L,y,ce),_i=!1,Ce=o.memoizedState,L.state=Ce,Wl(o,y,L,T),Gl();var je=o.memoizedState;K!==ze||Ce!==je||_i||i!==null&&i.dependencies!==null&&zu(i.dependencies)?(typeof ee=="function"&&(sp(o,f,ee,y),je=o.memoizedState),(De=_i||W_(o,f,De,y,Ce,je,ce)||i!==null&&i.dependencies!==null&&zu(i.dependencies))?(ve||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(y,je,ce),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(y,je,ce)),typeof L.componentDidUpdate=="function"&&(o.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof L.componentDidUpdate!="function"||K===i.memoizedProps&&Ce===i.memoizedState||(o.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||K===i.memoizedProps&&Ce===i.memoizedState||(o.flags|=1024),o.memoizedProps=y,o.memoizedState=je),L.props=y,L.state=je,L.context=ce,y=De):(typeof L.componentDidUpdate!="function"||K===i.memoizedProps&&Ce===i.memoizedState||(o.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||K===i.memoizedProps&&Ce===i.memoizedState||(o.flags|=1024),y=!1)}return L=y,id(i,o),y=(o.flags&128)!==0,L||y?(L=o.stateNode,f=y&&typeof f.getDerivedStateFromError!="function"?null:L.render(),o.flags|=1,i!==null&&y?(o.child=ga(o,i.child,null,T),o.child=ga(o,null,f,T)):Wn(i,o,f,T),o.memoizedState=L.state,i=o.child):i=Vs(i,o,T),i}function l0(i,o,f,y){return ua(),o.flags|=256,Wn(i,o,f,y),o.child}var cp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function up(i){return{baseLanes:i,cachePool:Jv()}}function dp(i,o,f){return i=i!==null?i.childLanes&~f:0,o&&(i|=jr),i}function c0(i,o,f){var y=o.pendingProps,T=!1,L=(o.flags&128)!==0,K;if((K=L)||(K=i!==null&&i.memoizedState===null?!1:(xn.current&2)!==0),K&&(T=!0,o.flags&=-129),K=(o.flags&32)!==0,o.flags&=-33,i===null){if(Nt){if(T?Ci(o):ki(),(i=sn)?(i=xS(i,Hr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:xi!==null?{id:gs,overflow:xs}:null,retryLane:536870912,hydrationErrors:null},f=Fv(i),f.return=o,o.child=f,Vn=o,sn=null)):i=null,i===null)throw bi(o);return qp(i)?o.lanes=32:o.lanes=536870912,null}var ee=y.children;return y=y.fallback,T?(ki(),T=o.mode,ee=ad({mode:"hidden",children:ee},T),y=ca(y,T,f,null),ee.return=o,y.return=o,ee.sibling=y,o.child=ee,y=o.child,y.memoizedState=up(f),y.childLanes=dp(i,K,f),o.memoizedState=cp,Jl(null,y)):(Ci(o),hp(o,ee))}var ce=i.memoizedState;if(ce!==null&&(ee=ce.dehydrated,ee!==null)){if(L)o.flags&256?(Ci(o),o.flags&=-257,o=fp(i,o,f)):o.memoizedState!==null?(ki(),o.child=i.child,o.flags|=128,o=null):(ki(),ee=y.fallback,T=o.mode,y=ad({mode:"visible",children:y.children},T),ee=ca(ee,T,f,null),ee.flags|=2,y.return=o,ee.return=o,y.sibling=ee,o.child=y,ga(o,i.child,null,f),y=o.child,y.memoizedState=up(f),y.childLanes=dp(i,K,f),o.memoizedState=cp,o=Jl(null,y));else if(Ci(o),qp(ee)){if(K=ee.nextSibling&&ee.nextSibling.dataset,K)var ve=K.dgst;K=ve,y=Error(r(419)),y.stack="",y.digest=K,$l({value:y,source:null,stack:null}),o=fp(i,o,f)}else if(En||bo(i,o,f,!1),K=(f&i.childLanes)!==0,En||K){if(K=Jt,K!==null&&(y=Pe(K,f),y!==0&&y!==ce.retryLane))throw ce.retryLane=y,la(i,y),fr(K,i,y),op;Wp(ee)||pd(),o=fp(i,o,f)}else Wp(ee)?(o.flags|=192,o.child=i.child,o=null):(i=ce.treeContext,sn=Ur(ee.nextSibling),Vn=o,Nt=!0,yi=null,Hr=!1,i!==null&&Gv(o,i),o=hp(o,y.children),o.flags|=4096);return o}return T?(ki(),ee=y.fallback,T=o.mode,ce=i.child,ve=ce.sibling,y=Bs(ce,{mode:"hidden",children:y.children}),y.subtreeFlags=ce.subtreeFlags&65011712,ve!==null?ee=Bs(ve,ee):(ee=ca(ee,T,f,null),ee.flags|=2),ee.return=o,y.return=o,y.sibling=ee,o.child=y,Jl(null,y),y=o.child,ee=i.child.memoizedState,ee===null?ee=up(f):(T=ee.cachePool,T!==null?(ce=kn._currentValue,T=T.parent!==ce?{parent:ce,pool:ce}:T):T=Jv(),ee={baseLanes:ee.baseLanes|f,cachePool:T}),y.memoizedState=ee,y.childLanes=dp(i,K,f),o.memoizedState=cp,Jl(i.child,y)):(Ci(o),f=i.child,i=f.sibling,f=Bs(f,{mode:"visible",children:y.children}),f.return=o,f.sibling=null,i!==null&&(K=o.deletions,K===null?(o.deletions=[i],o.flags|=16):K.push(i)),o.child=f,o.memoizedState=null,f)}function hp(i,o){return o=ad({mode:"visible",children:o},i.mode),o.return=i,i.child=o}function ad(i,o){return i=Sr(22,i,null,o),i.lanes=0,i}function fp(i,o,f){return ga(o,i.child,null,f),i=hp(o,o.pendingProps.children),i.flags|=2,o.memoizedState=null,i}function u0(i,o,f){i.lanes|=o;var y=i.alternate;y!==null&&(y.lanes|=o),Nm(i.return,o,f)}function mp(i,o,f,y,T,L){var K=i.memoizedState;K===null?i.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:y,tail:f,tailMode:T,treeForkCount:L}:(K.isBackwards=o,K.rendering=null,K.renderingStartTime=0,K.last=y,K.tail=f,K.tailMode=T,K.treeForkCount=L)}function d0(i,o,f){var y=o.pendingProps,T=y.revealOrder,L=y.tail;y=y.children;var K=xn.current,ee=(K&2)!==0;if(ee?(K=K&1|2,o.flags|=128):K&=1,B(xn,K),Wn(i,o,y,f),y=Nt?Bl:0,!ee&&i!==null&&(i.flags&128)!==0)e:for(i=o.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&u0(i,f,o);else if(i.tag===19)u0(i,f,o);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break e;for(;i.sibling===null;){if(i.return===null||i.return===o)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(T){case"forwards":for(f=o.child,T=null;f!==null;)i=f.alternate,i!==null&&Ku(i)===null&&(T=f),f=f.sibling;f=T,f===null?(T=o.child,o.child=null):(T=f.sibling,f.sibling=null),mp(o,!1,T,f,L,y);break;case"backwards":case"unstable_legacy-backwards":for(f=null,T=o.child,o.child=null;T!==null;){if(i=T.alternate,i!==null&&Ku(i)===null){o.child=T;break}i=T.sibling,T.sibling=f,f=T,T=i}mp(o,!0,f,null,L,y);break;case"together":mp(o,!1,null,null,void 0,y);break;default:o.memoizedState=null}return o.child}function Vs(i,o,f){if(i!==null&&(o.dependencies=i.dependencies),Ni|=o.lanes,(f&o.childLanes)===0)if(i!==null){if(bo(i,o,f,!1),(f&o.childLanes)===0)return null}else return null;if(i!==null&&o.child!==i.child)throw Error(r(153));if(o.child!==null){for(i=o.child,f=Bs(i,i.pendingProps),o.child=f,f.return=o;i.sibling!==null;)i=i.sibling,f=f.sibling=Bs(i,i.pendingProps),f.return=o;f.sibling=null}return o.child}function pp(i,o){return(i.lanes&o)!==0?!0:(i=i.dependencies,!!(i!==null&&zu(i)))}function iL(i,o,f){switch(o.tag){case 3:M(o,o.stateNode.containerInfo),vi(o,kn,i.memoizedState.cache),ua();break;case 27:case 5:se(o);break;case 4:M(o,o.stateNode.containerInfo);break;case 10:vi(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,zm(o),null;break;case 13:var y=o.memoizedState;if(y!==null)return y.dehydrated!==null?(Ci(o),o.flags|=128,null):(f&o.child.childLanes)!==0?c0(i,o,f):(Ci(o),i=Vs(i,o,f),i!==null?i.sibling:null);Ci(o);break;case 19:var T=(i.flags&128)!==0;if(y=(f&o.childLanes)!==0,y||(bo(i,o,f,!1),y=(f&o.childLanes)!==0),T){if(y)return d0(i,o,f);o.flags|=128}if(T=o.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),B(xn,xn.current),y)break;return null;case 22:return o.lanes=0,r0(i,o,f,o.pendingProps);case 24:vi(o,kn,i.memoizedState.cache)}return Vs(i,o,f)}function h0(i,o,f){if(i!==null)if(i.memoizedProps!==o.pendingProps)En=!0;else{if(!pp(i,f)&&(o.flags&128)===0)return En=!1,iL(i,o,f);En=(i.flags&131072)!==0}else En=!1,Nt&&(o.flags&1048576)!==0&&Vv(o,Bl,o.index);switch(o.lanes=0,o.tag){case 16:e:{var y=o.pendingProps;if(i=ma(o.elementType),o.type=i,typeof i=="function")vm(i)?(y=ya(i,y),o.tag=1,o=o0(null,o,i,y,f)):(o.tag=0,o=lp(null,o,i,y,f));else{if(i!=null){var T=i.$$typeof;if(T===k){o.tag=11,o=e0(null,o,i,y,f);break e}else if(T===D){o.tag=14,o=t0(null,o,i,y,f);break e}}throw o=$(i)||i,Error(r(306,o,""))}}return o;case 0:return lp(i,o,o.type,o.pendingProps,f);case 1:return y=o.type,T=ya(y,o.pendingProps),o0(i,o,y,T,f);case 3:e:{if(M(o,o.stateNode.containerInfo),i===null)throw Error(r(387));y=o.pendingProps;var L=o.memoizedState;T=L.element,Im(i,o),Wl(o,y,null,f);var K=o.memoizedState;if(y=K.cache,vi(o,kn,y),y!==L.cache&&Tm(o,[kn],f,!0),Gl(),y=K.element,L.isDehydrated)if(L={element:y,isDehydrated:!1,cache:K.cache},o.updateQueue.baseState=L,o.memoizedState=L,o.flags&256){o=l0(i,o,y,f);break e}else if(y!==T){T=Br(Error(r(424)),o),$l(T),o=l0(i,o,y,f);break e}else{switch(i=o.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(sn=Ur(i.firstChild),Vn=o,Nt=!0,yi=null,Hr=!0,f=r_(o,null,y,f),o.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling}else{if(ua(),y===T){o=Vs(i,o,f);break e}Wn(i,o,y,f)}o=o.child}return o;case 26:return id(i,o),i===null?(f=wS(o.type,null,o.pendingProps,null))?o.memoizedState=f:Nt||(f=o.type,i=o.pendingProps,y=Sd(J.current).createElement(f),y[$e]=o,y[Xe]=i,qn(y,f,i),$n(y),o.stateNode=y):o.memoizedState=wS(o.type,i.memoizedProps,o.pendingProps,i.memoizedState),null;case 27:return se(o),i===null&&Nt&&(y=o.stateNode=vS(o.type,o.pendingProps,J.current),Vn=o,Hr=!0,T=sn,Ri(o.type)?(Kp=T,sn=Ur(y.firstChild)):sn=T),Wn(i,o,o.pendingProps.children,f),id(i,o),i===null&&(o.flags|=4194304),o.child;case 5:return i===null&&Nt&&((T=y=sn)&&(y=IL(y,o.type,o.pendingProps,Hr),y!==null?(o.stateNode=y,Vn=o,sn=Ur(y.firstChild),Hr=!1,T=!0):T=!1),T||bi(o)),se(o),T=o.type,L=o.pendingProps,K=i!==null?i.memoizedProps:null,y=L.children,Up(T,L)?y=null:K!==null&&Up(T,K)&&(o.flags|=32),o.memoizedState!==null&&(T=Fm(i,o,XA,null,null,f),hc._currentValue=T),id(i,o),Wn(i,o,y,f),o.child;case 6:return i===null&&Nt&&((i=f=sn)&&(f=ML(f,o.pendingProps,Hr),f!==null?(o.stateNode=f,Vn=o,sn=null,i=!0):i=!1),i||bi(o)),null;case 13:return c0(i,o,f);case 4:return M(o,o.stateNode.containerInfo),y=o.pendingProps,i===null?o.child=ga(o,null,y,f):Wn(i,o,y,f),o.child;case 11:return e0(i,o,o.type,o.pendingProps,f);case 7:return Wn(i,o,o.pendingProps,f),o.child;case 8:return Wn(i,o,o.pendingProps.children,f),o.child;case 12:return Wn(i,o,o.pendingProps.children,f),o.child;case 10:return y=o.pendingProps,vi(o,o.type,y.value),Wn(i,o,y.children,f),o.child;case 9:return T=o.type._context,y=o.pendingProps.children,ha(o),T=Gn(T),y=y(T),o.flags|=1,Wn(i,o,y,f),o.child;case 14:return t0(i,o,o.type,o.pendingProps,f);case 15:return n0(i,o,o.type,o.pendingProps,f);case 19:return d0(i,o,f);case 31:return sL(i,o,f);case 22:return r0(i,o,f,o.pendingProps);case 24:return ha(o),y=Gn(kn),i===null?(T=Dm(),T===null&&(T=Jt,L=Am(),T.pooledCache=L,L.refCount++,L!==null&&(T.pooledCacheLanes|=f),T=L),o.memoizedState={parent:y,cache:T},Om(o),vi(o,kn,T)):((i.lanes&f)!==0&&(Im(i,o),Wl(o,null,null,f),Gl()),T=i.memoizedState,L=o.memoizedState,T.parent!==y?(T={parent:y,cache:y},o.memoizedState=T,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=T),vi(o,kn,y)):(y=L.cache,vi(o,kn,y),y!==T.cache&&Tm(o,[kn],f,!0))),Wn(i,o,o.pendingProps.children,f),o.child;case 29:throw o.pendingProps}throw Error(r(156,o.tag))}function Gs(i){i.flags|=4}function gp(i,o,f,y,T){if((o=(i.mode&32)!==0)&&(o=!1),o){if(i.flags|=16777216,(T&335544128)===T)if(i.stateNode.complete)i.flags|=8192;else if($0())i.flags|=8192;else throw pa=Vu,Rm}else i.flags&=-16777217}function f0(i,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!NS(o))if($0())i.flags|=8192;else throw pa=Vu,Rm}function od(i,o){o!==null&&(i.flags|=4),i.flags&16384&&(o=i.tag!==22?un():536870912,i.lanes|=o,Lo|=o)}function Ql(i,o){if(!Nt)switch(i.tailMode){case"hidden":o=i.tail;for(var f=null;o!==null;)o.alternate!==null&&(f=o),o=o.sibling;f===null?i.tail=null:f.sibling=null;break;case"collapsed":f=i.tail;for(var y=null;f!==null;)f.alternate!==null&&(y=f),f=f.sibling;y===null?o||i.tail===null?i.tail=null:i.tail.sibling=null:y.sibling=null}}function an(i){var o=i.alternate!==null&&i.alternate.child===i.child,f=0,y=0;if(o)for(var T=i.child;T!==null;)f|=T.lanes|T.childLanes,y|=T.subtreeFlags&65011712,y|=T.flags&65011712,T.return=i,T=T.sibling;else for(T=i.child;T!==null;)f|=T.lanes|T.childLanes,y|=T.subtreeFlags,y|=T.flags,T.return=i,T=T.sibling;return i.subtreeFlags|=y,i.childLanes=f,o}function aL(i,o,f){var y=o.pendingProps;switch(Cm(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return an(o),null;case 1:return an(o),null;case 3:return f=o.stateNode,y=null,i!==null&&(y=i.memoizedState.cache),o.memoizedState.cache!==y&&(o.flags|=2048),Hs(kn),te(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(i===null||i.child===null)&&(yo(o)?Gs(o):i===null||i.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,jm())),an(o),null;case 26:var T=o.type,L=o.memoizedState;return i===null?(Gs(o),L!==null?(an(o),f0(o,L)):(an(o),gp(o,T,null,y,f))):L?L!==i.memoizedState?(Gs(o),an(o),f0(o,L)):(an(o),o.flags&=-16777217):(i=i.memoizedProps,i!==y&&Gs(o),an(o),gp(o,T,i,y,f)),null;case 27:if(re(o),f=J.current,T=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==y&&Gs(o);else{if(!y){if(o.stateNode===null)throw Error(r(166));return an(o),null}i=Z.current,yo(o)?Wv(o):(i=vS(T,y,f),o.stateNode=i,Gs(o))}return an(o),null;case 5:if(re(o),T=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==y&&Gs(o);else{if(!y){if(o.stateNode===null)throw Error(r(166));return an(o),null}if(L=Z.current,yo(o))Wv(o);else{var K=Sd(J.current);switch(L){case 1:L=K.createElementNS("http://www.w3.org/2000/svg",T);break;case 2:L=K.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;default:switch(T){case"svg":L=K.createElementNS("http://www.w3.org/2000/svg",T);break;case"math":L=K.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;case"script":L=K.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof y.is=="string"?K.createElement("select",{is:y.is}):K.createElement("select"),y.multiple?L.multiple=!0:y.size&&(L.size=y.size);break;default:L=typeof y.is=="string"?K.createElement(T,{is:y.is}):K.createElement(T)}}L[$e]=o,L[Xe]=y;e:for(K=o.child;K!==null;){if(K.tag===5||K.tag===6)L.appendChild(K.stateNode);else if(K.tag!==4&&K.tag!==27&&K.child!==null){K.child.return=K,K=K.child;continue}if(K===o)break e;for(;K.sibling===null;){if(K.return===null||K.return===o)break e;K=K.return}K.sibling.return=K.return,K=K.sibling}o.stateNode=L;e:switch(qn(L,T,y),T){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}y&&Gs(o)}}return an(o),gp(o,o.type,i===null?null:i.memoizedProps,o.pendingProps,f),null;case 6:if(i&&o.stateNode!=null)i.memoizedProps!==y&&Gs(o);else{if(typeof y!="string"&&o.stateNode===null)throw Error(r(166));if(i=J.current,yo(o)){if(i=o.stateNode,f=o.memoizedProps,y=null,T=Vn,T!==null)switch(T.tag){case 27:case 5:y=T.memoizedProps}i[$e]=o,i=!!(i.nodeValue===f||y!==null&&y.suppressHydrationWarning===!0||cS(i.nodeValue,f)),i||bi(o,!0)}else i=Sd(i).createTextNode(y),i[$e]=o,o.stateNode=i}return an(o),null;case 31:if(f=o.memoizedState,i===null||i.memoizedState!==null){if(y=yo(o),f!==null){if(i===null){if(!y)throw Error(r(318));if(i=o.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[$e]=o}else ua(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;an(o),i=!1}else f=jm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=f),i=!0;if(!i)return o.flags&256?(Cr(o),o):(Cr(o),null);if((o.flags&128)!==0)throw Error(r(558))}return an(o),null;case 13:if(y=o.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(T=yo(o),y!==null&&y.dehydrated!==null){if(i===null){if(!T)throw Error(r(318));if(T=o.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(r(317));T[$e]=o}else ua(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;an(o),T=!1}else T=jm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=T),T=!0;if(!T)return o.flags&256?(Cr(o),o):(Cr(o),null)}return Cr(o),(o.flags&128)!==0?(o.lanes=f,o):(f=y!==null,i=i!==null&&i.memoizedState!==null,f&&(y=o.child,T=null,y.alternate!==null&&y.alternate.memoizedState!==null&&y.alternate.memoizedState.cachePool!==null&&(T=y.alternate.memoizedState.cachePool.pool),L=null,y.memoizedState!==null&&y.memoizedState.cachePool!==null&&(L=y.memoizedState.cachePool.pool),L!==T&&(y.flags|=2048)),f!==i&&f&&(o.child.flags|=8192),od(o,o.updateQueue),an(o),null);case 4:return te(),i===null&&Bp(o.stateNode.containerInfo),an(o),null;case 10:return Hs(o.type),an(o),null;case 19:if(W(xn),y=o.memoizedState,y===null)return an(o),null;if(T=(o.flags&128)!==0,L=y.rendering,L===null)if(T)Ql(y,!1);else{if(mn!==0||i!==null&&(i.flags&128)!==0)for(i=o.child;i!==null;){if(L=Ku(i),L!==null){for(o.flags|=128,Ql(y,!1),i=L.updateQueue,o.updateQueue=i,od(o,i),o.subtreeFlags=0,i=f,f=o.child;f!==null;)Hv(f,i),f=f.sibling;return B(xn,xn.current&1|2),Nt&&$s(o,y.treeForkCount),o.child}i=i.sibling}y.tail!==null&&Fe()>hd&&(o.flags|=128,T=!0,Ql(y,!1),o.lanes=4194304)}else{if(!T)if(i=Ku(L),i!==null){if(o.flags|=128,T=!0,i=i.updateQueue,o.updateQueue=i,od(o,i),Ql(y,!0),y.tail===null&&y.tailMode==="hidden"&&!L.alternate&&!Nt)return an(o),null}else 2*Fe()-y.renderingStartTime>hd&&f!==536870912&&(o.flags|=128,T=!0,Ql(y,!1),o.lanes=4194304);y.isBackwards?(L.sibling=o.child,o.child=L):(i=y.last,i!==null?i.sibling=L:o.child=L,y.last=L)}return y.tail!==null?(i=y.tail,y.rendering=i,y.tail=i.sibling,y.renderingStartTime=Fe(),i.sibling=null,f=xn.current,B(xn,T?f&1|2:f&1),Nt&&$s(o,y.treeForkCount),i):(an(o),null);case 22:case 23:return Cr(o),$m(),y=o.memoizedState!==null,i!==null?i.memoizedState!==null!==y&&(o.flags|=8192):y&&(o.flags|=8192),y?(f&536870912)!==0&&(o.flags&128)===0&&(an(o),o.subtreeFlags&6&&(o.flags|=8192)):an(o),f=o.updateQueue,f!==null&&od(o,f.retryQueue),f=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),y=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(y=o.memoizedState.cachePool.pool),y!==f&&(o.flags|=2048),i!==null&&W(fa),null;case 24:return f=null,i!==null&&(f=i.memoizedState.cache),o.memoizedState.cache!==f&&(o.flags|=2048),Hs(kn),an(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function oL(i,o){switch(Cm(o),o.tag){case 1:return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 3:return Hs(kn),te(),i=o.flags,(i&65536)!==0&&(i&128)===0?(o.flags=i&-65537|128,o):null;case 26:case 27:case 5:return re(o),null;case 31:if(o.memoizedState!==null){if(Cr(o),o.alternate===null)throw Error(r(340));ua()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 13:if(Cr(o),i=o.memoizedState,i!==null&&i.dehydrated!==null){if(o.alternate===null)throw Error(r(340));ua()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 19:return W(xn),null;case 4:return te(),null;case 10:return Hs(o.type),null;case 22:case 23:return Cr(o),$m(),i!==null&&W(fa),i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 24:return Hs(kn),null;case 25:return null;default:return null}}function m0(i,o){switch(Cm(o),o.tag){case 3:Hs(kn),te();break;case 26:case 27:case 5:re(o);break;case 4:te();break;case 31:o.memoizedState!==null&&Cr(o);break;case 13:Cr(o);break;case 19:W(xn);break;case 10:Hs(o.type);break;case 22:case 23:Cr(o),$m(),i!==null&&W(fa);break;case 24:Hs(kn)}}function Zl(i,o){try{var f=o.updateQueue,y=f!==null?f.lastEffect:null;if(y!==null){var T=y.next;f=T;do{if((f.tag&i)===i){y=void 0;var L=f.create,K=f.inst;y=L(),K.destroy=y}f=f.next}while(f!==T)}}catch(ee){Ut(o,o.return,ee)}}function ji(i,o,f){try{var y=o.updateQueue,T=y!==null?y.lastEffect:null;if(T!==null){var L=T.next;y=L;do{if((y.tag&i)===i){var K=y.inst,ee=K.destroy;if(ee!==void 0){K.destroy=void 0,T=o;var ce=f,ve=ee;try{ve()}catch(De){Ut(T,ce,De)}}}y=y.next}while(y!==L)}}catch(De){Ut(o,o.return,De)}}function p0(i){var o=i.updateQueue;if(o!==null){var f=i.stateNode;try{i_(o,f)}catch(y){Ut(i,i.return,y)}}}function g0(i,o,f){f.props=ya(i.type,i.memoizedProps),f.state=i.memoizedState;try{f.componentWillUnmount()}catch(y){Ut(i,o,y)}}function ec(i,o){try{var f=i.ref;if(f!==null){switch(i.tag){case 26:case 27:case 5:var y=i.stateNode;break;case 30:y=i.stateNode;break;default:y=i.stateNode}typeof f=="function"?i.refCleanup=f(y):f.current=y}}catch(T){Ut(i,o,T)}}function ys(i,o){var f=i.ref,y=i.refCleanup;if(f!==null)if(typeof y=="function")try{y()}catch(T){Ut(i,o,T)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(T){Ut(i,o,T)}else f.current=null}function x0(i){var o=i.type,f=i.memoizedProps,y=i.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":f.autoFocus&&y.focus();break e;case"img":f.src?y.src=f.src:f.srcSet&&(y.srcset=f.srcSet)}}catch(T){Ut(i,i.return,T)}}function xp(i,o,f){try{var y=i.stateNode;TL(y,i.type,f,o),y[Xe]=o}catch(T){Ut(i,i.return,T)}}function y0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ri(i.type)||i.tag===4}function yp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||y0(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Ri(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function bp(i,o,f){var y=i.tag;if(y===5||y===6)i=i.stateNode,o?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(i,o):(o=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,o.appendChild(i),f=f._reactRootContainer,f!=null||o.onclick!==null||(o.onclick=Ms));else if(y!==4&&(y===27&&Ri(i.type)&&(f=i.stateNode,o=null),i=i.child,i!==null))for(bp(i,o,f),i=i.sibling;i!==null;)bp(i,o,f),i=i.sibling}function ld(i,o,f){var y=i.tag;if(y===5||y===6)i=i.stateNode,o?f.insertBefore(i,o):f.appendChild(i);else if(y!==4&&(y===27&&Ri(i.type)&&(f=i.stateNode),i=i.child,i!==null))for(ld(i,o,f),i=i.sibling;i!==null;)ld(i,o,f),i=i.sibling}function b0(i){var o=i.stateNode,f=i.memoizedProps;try{for(var y=i.type,T=o.attributes;T.length;)o.removeAttributeNode(T[0]);qn(o,y,f),o[$e]=i,o[Xe]=f}catch(L){Ut(i,i.return,L)}}var Ws=!1,Nn=!1,vp=!1,v0=typeof WeakSet=="function"?WeakSet:Set,zn=null;function lL(i,o){if(i=i.containerInfo,Hp=Td,i=Dv(i),fm(i)){if("selectionStart"in i)var f={start:i.selectionStart,end:i.selectionEnd};else e:{f=(f=i.ownerDocument)&&f.defaultView||window;var y=f.getSelection&&f.getSelection();if(y&&y.rangeCount!==0){f=y.anchorNode;var T=y.anchorOffset,L=y.focusNode;y=y.focusOffset;try{f.nodeType,L.nodeType}catch{f=null;break e}var K=0,ee=-1,ce=-1,ve=0,De=0,ze=i,Ce=null;t:for(;;){for(var je;ze!==f||T!==0&&ze.nodeType!==3||(ee=K+T),ze!==L||y!==0&&ze.nodeType!==3||(ce=K+y),ze.nodeType===3&&(K+=ze.nodeValue.length),(je=ze.firstChild)!==null;)Ce=ze,ze=je;for(;;){if(ze===i)break t;if(Ce===f&&++ve===T&&(ee=K),Ce===L&&++De===y&&(ce=K),(je=ze.nextSibling)!==null)break;ze=Ce,Ce=ze.parentNode}ze=je}f=ee===-1||ce===-1?null:{start:ee,end:ce}}else f=null}f=f||{start:0,end:0}}else f=null;for(Fp={focusedElem:i,selectionRange:f},Td=!1,zn=o;zn!==null;)if(o=zn,i=o.child,(o.subtreeFlags&1028)!==0&&i!==null)i.return=o,zn=i;else for(;zn!==null;){switch(o=zn,L=o.alternate,i=o.flags,o.tag){case 0:if((i&4)!==0&&(i=o.updateQueue,i=i!==null?i.events:null,i!==null))for(f=0;f<i.length;f++)T=i[f],T.ref.impl=T.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&L!==null){i=void 0,f=o,T=L.memoizedProps,L=L.memoizedState,y=f.stateNode;try{var nt=ya(f.type,T);i=y.getSnapshotBeforeUpdate(nt,L),y.__reactInternalSnapshotBeforeUpdate=i}catch(ct){Ut(f,f.return,ct)}}break;case 3:if((i&1024)!==0){if(i=o.stateNode.containerInfo,f=i.nodeType,f===9)Gp(i);else if(f===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Gp(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=o.sibling,i!==null){i.return=o.return,zn=i;break}zn=o.return}}function _0(i,o,f){var y=f.flags;switch(f.tag){case 0:case 11:case 15:Ks(i,f),y&4&&Zl(5,f);break;case 1:if(Ks(i,f),y&4)if(i=f.stateNode,o===null)try{i.componentDidMount()}catch(K){Ut(f,f.return,K)}else{var T=ya(f.type,o.memoizedProps);o=o.memoizedState;try{i.componentDidUpdate(T,o,i.__reactInternalSnapshotBeforeUpdate)}catch(K){Ut(f,f.return,K)}}y&64&&p0(f),y&512&&ec(f,f.return);break;case 3:if(Ks(i,f),y&64&&(i=f.updateQueue,i!==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{i_(i,o)}catch(K){Ut(f,f.return,K)}}break;case 27:o===null&&y&4&&b0(f);case 26:case 5:Ks(i,f),o===null&&y&4&&x0(f),y&512&&ec(f,f.return);break;case 12:Ks(i,f);break;case 31:Ks(i,f),y&4&&C0(i,f);break;case 13:Ks(i,f),y&4&&k0(i,f),y&64&&(i=f.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(f=xL.bind(null,f),PL(i,f))));break;case 22:if(y=f.memoizedState!==null||Ws,!y){o=o!==null&&o.memoizedState!==null||Nn,T=Ws;var L=Nn;Ws=y,(Nn=o)&&!L?Ys(i,f,(f.subtreeFlags&8772)!==0):Ks(i,f),Ws=T,Nn=L}break;case 30:break;default:Ks(i,f)}}function S0(i){var o=i.alternate;o!==null&&(i.alternate=null,S0(o)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(o=i.stateNode,o!==null&&to(o)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var cn=null,cr=!1;function qs(i,o,f){for(f=f.child;f!==null;)w0(i,o,f),f=f.sibling}function w0(i,o,f){if(it&&typeof it.onCommitFiberUnmount=="function")try{it.onCommitFiberUnmount(Qe,f)}catch{}switch(f.tag){case 26:Nn||ys(f,o),qs(i,o,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:Nn||ys(f,o);var y=cn,T=cr;Ri(f.type)&&(cn=f.stateNode,cr=!1),qs(i,o,f),cc(f.stateNode),cn=y,cr=T;break;case 5:Nn||ys(f,o);case 6:if(y=cn,T=cr,cn=null,qs(i,o,f),cn=y,cr=T,cn!==null)if(cr)try{(cn.nodeType===9?cn.body:cn.nodeName==="HTML"?cn.ownerDocument.body:cn).removeChild(f.stateNode)}catch(L){Ut(f,o,L)}else try{cn.removeChild(f.stateNode)}catch(L){Ut(f,o,L)}break;case 18:cn!==null&&(cr?(i=cn,pS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,f.stateNode),$o(i)):pS(cn,f.stateNode));break;case 4:y=cn,T=cr,cn=f.stateNode.containerInfo,cr=!0,qs(i,o,f),cn=y,cr=T;break;case 0:case 11:case 14:case 15:ji(2,f,o),Nn||ji(4,f,o),qs(i,o,f);break;case 1:Nn||(ys(f,o),y=f.stateNode,typeof y.componentWillUnmount=="function"&&g0(f,o,y)),qs(i,o,f);break;case 21:qs(i,o,f);break;case 22:Nn=(y=Nn)||f.memoizedState!==null,qs(i,o,f),Nn=y;break;default:qs(i,o,f)}}function C0(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{$o(i)}catch(f){Ut(o,o.return,f)}}}function k0(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{$o(i)}catch(f){Ut(o,o.return,f)}}function cL(i){switch(i.tag){case 31:case 13:case 19:var o=i.stateNode;return o===null&&(o=i.stateNode=new v0),o;case 22:return i=i.stateNode,o=i._retryCache,o===null&&(o=i._retryCache=new v0),o;default:throw Error(r(435,i.tag))}}function cd(i,o){var f=cL(i);o.forEach(function(y){if(!f.has(y)){f.add(y);var T=yL.bind(null,i,y);y.then(T,T)}})}function ur(i,o){var f=o.deletions;if(f!==null)for(var y=0;y<f.length;y++){var T=f[y],L=i,K=o,ee=K;e:for(;ee!==null;){switch(ee.tag){case 27:if(Ri(ee.type)){cn=ee.stateNode,cr=!1;break e}break;case 5:cn=ee.stateNode,cr=!1;break e;case 3:case 4:cn=ee.stateNode.containerInfo,cr=!0;break e}ee=ee.return}if(cn===null)throw Error(r(160));w0(L,K,T),cn=null,cr=!1,L=T.alternate,L!==null&&(L.return=null),T.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)j0(o,i),o=o.sibling}var ns=null;function j0(i,o){var f=i.alternate,y=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:ur(o,i),dr(i),y&4&&(ji(3,i,i.return),Zl(3,i),ji(5,i,i.return));break;case 1:ur(o,i),dr(i),y&512&&(Nn||f===null||ys(f,f.return)),y&64&&Ws&&(i=i.updateQueue,i!==null&&(y=i.callbacks,y!==null&&(f=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=f===null?y:f.concat(y))));break;case 26:var T=ns;if(ur(o,i),dr(i),y&512&&(Nn||f===null||ys(f,f.return)),y&4){var L=f!==null?f.memoizedState:null;if(y=i.memoizedState,f===null)if(y===null)if(i.stateNode===null){e:{y=i.type,f=i.memoizedProps,T=T.ownerDocument||T;t:switch(y){case"title":L=T.getElementsByTagName("title")[0],(!L||L[Cn]||L[$e]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=T.createElement(y),T.head.insertBefore(L,T.querySelector("head > title"))),qn(L,y,f),L[$e]=i,$n(L),y=L;break e;case"link":var K=jS("link","href",T).get(y+(f.href||""));if(K){for(var ee=0;ee<K.length;ee++)if(L=K[ee],L.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&L.getAttribute("rel")===(f.rel==null?null:f.rel)&&L.getAttribute("title")===(f.title==null?null:f.title)&&L.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){K.splice(ee,1);break t}}L=T.createElement(y),qn(L,y,f),T.head.appendChild(L);break;case"meta":if(K=jS("meta","content",T).get(y+(f.content||""))){for(ee=0;ee<K.length;ee++)if(L=K[ee],L.getAttribute("content")===(f.content==null?null:""+f.content)&&L.getAttribute("name")===(f.name==null?null:f.name)&&L.getAttribute("property")===(f.property==null?null:f.property)&&L.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&L.getAttribute("charset")===(f.charSet==null?null:f.charSet)){K.splice(ee,1);break t}}L=T.createElement(y),qn(L,y,f),T.head.appendChild(L);break;default:throw Error(r(468,y))}L[$e]=i,$n(L),y=L}i.stateNode=y}else ES(T,i.type,i.stateNode);else i.stateNode=kS(T,y,i.memoizedProps);else L!==y?(L===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):L.count--,y===null?ES(T,i.type,i.stateNode):kS(T,y,i.memoizedProps)):y===null&&i.stateNode!==null&&xp(i,i.memoizedProps,f.memoizedProps)}break;case 27:ur(o,i),dr(i),y&512&&(Nn||f===null||ys(f,f.return)),f!==null&&y&4&&xp(i,i.memoizedProps,f.memoizedProps);break;case 5:if(ur(o,i),dr(i),y&512&&(Nn||f===null||ys(f,f.return)),i.flags&32){T=i.stateNode;try{oo(T,"")}catch(nt){Ut(i,i.return,nt)}}y&4&&i.stateNode!=null&&(T=i.memoizedProps,xp(i,T,f!==null?f.memoizedProps:T)),y&1024&&(vp=!0);break;case 6:if(ur(o,i),dr(i),y&4){if(i.stateNode===null)throw Error(r(162));y=i.memoizedProps,f=i.stateNode;try{f.nodeValue=y}catch(nt){Ut(i,i.return,nt)}}break;case 3:if(kd=null,T=ns,ns=wd(o.containerInfo),ur(o,i),ns=T,dr(i),y&4&&f!==null&&f.memoizedState.isDehydrated)try{$o(o.containerInfo)}catch(nt){Ut(i,i.return,nt)}vp&&(vp=!1,E0(i));break;case 4:y=ns,ns=wd(i.stateNode.containerInfo),ur(o,i),dr(i),ns=y;break;case 12:ur(o,i),dr(i);break;case 31:ur(o,i),dr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,cd(i,y)));break;case 13:ur(o,i),dr(i),i.child.flags&8192&&i.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(dd=Fe()),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,cd(i,y)));break;case 22:T=i.memoizedState!==null;var ce=f!==null&&f.memoizedState!==null,ve=Ws,De=Nn;if(Ws=ve||T,Nn=De||ce,ur(o,i),Nn=De,Ws=ve,dr(i),y&8192)e:for(o=i.stateNode,o._visibility=T?o._visibility&-2:o._visibility|1,T&&(f===null||ce||Ws||Nn||ba(i)),f=null,o=i;;){if(o.tag===5||o.tag===26){if(f===null){ce=f=o;try{if(L=ce.stateNode,T)K=L.style,typeof K.setProperty=="function"?K.setProperty("display","none","important"):K.display="none";else{ee=ce.stateNode;var ze=ce.memoizedProps.style,Ce=ze!=null&&ze.hasOwnProperty("display")?ze.display:null;ee.style.display=Ce==null||typeof Ce=="boolean"?"":(""+Ce).trim()}}catch(nt){Ut(ce,ce.return,nt)}}}else if(o.tag===6){if(f===null){ce=o;try{ce.stateNode.nodeValue=T?"":ce.memoizedProps}catch(nt){Ut(ce,ce.return,nt)}}}else if(o.tag===18){if(f===null){ce=o;try{var je=ce.stateNode;T?gS(je,!0):gS(ce.stateNode,!1)}catch(nt){Ut(ce,ce.return,nt)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===i)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break e;for(;o.sibling===null;){if(o.return===null||o.return===i)break e;f===o&&(f=null),o=o.return}f===o&&(f=null),o.sibling.return=o.return,o=o.sibling}y&4&&(y=i.updateQueue,y!==null&&(f=y.retryQueue,f!==null&&(y.retryQueue=null,cd(i,f))));break;case 19:ur(o,i),dr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,cd(i,y)));break;case 30:break;case 21:break;default:ur(o,i),dr(i)}}function dr(i){var o=i.flags;if(o&2){try{for(var f,y=i.return;y!==null;){if(y0(y)){f=y;break}y=y.return}if(f==null)throw Error(r(160));switch(f.tag){case 27:var T=f.stateNode,L=yp(i);ld(i,L,T);break;case 5:var K=f.stateNode;f.flags&32&&(oo(K,""),f.flags&=-33);var ee=yp(i);ld(i,ee,K);break;case 3:case 4:var ce=f.stateNode.containerInfo,ve=yp(i);bp(i,ve,ce);break;default:throw Error(r(161))}}catch(De){Ut(i,i.return,De)}i.flags&=-3}o&4096&&(i.flags&=-4097)}function E0(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var o=i;E0(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),i=i.sibling}}function Ks(i,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)_0(i,o.alternate,o),o=o.sibling}function ba(i){for(i=i.child;i!==null;){var o=i;switch(o.tag){case 0:case 11:case 14:case 15:ji(4,o,o.return),ba(o);break;case 1:ys(o,o.return);var f=o.stateNode;typeof f.componentWillUnmount=="function"&&g0(o,o.return,f),ba(o);break;case 27:cc(o.stateNode);case 26:case 5:ys(o,o.return),ba(o);break;case 22:o.memoizedState===null&&ba(o);break;case 30:ba(o);break;default:ba(o)}i=i.sibling}}function Ys(i,o,f){for(f=f&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var y=o.alternate,T=i,L=o,K=L.flags;switch(L.tag){case 0:case 11:case 15:Ys(T,L,f),Zl(4,L);break;case 1:if(Ys(T,L,f),y=L,T=y.stateNode,typeof T.componentDidMount=="function")try{T.componentDidMount()}catch(ve){Ut(y,y.return,ve)}if(y=L,T=y.updateQueue,T!==null){var ee=y.stateNode;try{var ce=T.shared.hiddenCallbacks;if(ce!==null)for(T.shared.hiddenCallbacks=null,T=0;T<ce.length;T++)s_(ce[T],ee)}catch(ve){Ut(y,y.return,ve)}}f&&K&64&&p0(L),ec(L,L.return);break;case 27:b0(L);case 26:case 5:Ys(T,L,f),f&&y===null&&K&4&&x0(L),ec(L,L.return);break;case 12:Ys(T,L,f);break;case 31:Ys(T,L,f),f&&K&4&&C0(T,L);break;case 13:Ys(T,L,f),f&&K&4&&k0(T,L);break;case 22:L.memoizedState===null&&Ys(T,L,f),ec(L,L.return);break;case 30:break;default:Ys(T,L,f)}o=o.sibling}}function _p(i,o){var f=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),i=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(i=o.memoizedState.cachePool.pool),i!==f&&(i!=null&&i.refCount++,f!=null&&zl(f))}function Sp(i,o){i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&zl(i))}function rs(i,o,f,y){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)N0(i,o,f,y),o=o.sibling}function N0(i,o,f,y){var T=o.flags;switch(o.tag){case 0:case 11:case 15:rs(i,o,f,y),T&2048&&Zl(9,o);break;case 1:rs(i,o,f,y);break;case 3:rs(i,o,f,y),T&2048&&(i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&zl(i)));break;case 12:if(T&2048){rs(i,o,f,y),i=o.stateNode;try{var L=o.memoizedProps,K=L.id,ee=L.onPostCommit;typeof ee=="function"&&ee(K,o.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(ce){Ut(o,o.return,ce)}}else rs(i,o,f,y);break;case 31:rs(i,o,f,y);break;case 13:rs(i,o,f,y);break;case 23:break;case 22:L=o.stateNode,K=o.alternate,o.memoizedState!==null?L._visibility&2?rs(i,o,f,y):tc(i,o):L._visibility&2?rs(i,o,f,y):(L._visibility|=2,No(i,o,f,y,(o.subtreeFlags&10256)!==0||!1)),T&2048&&_p(K,o);break;case 24:rs(i,o,f,y),T&2048&&Sp(o.alternate,o);break;default:rs(i,o,f,y)}}function No(i,o,f,y,T){for(T=T&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var L=i,K=o,ee=f,ce=y,ve=K.flags;switch(K.tag){case 0:case 11:case 15:No(L,K,ee,ce,T),Zl(8,K);break;case 23:break;case 22:var De=K.stateNode;K.memoizedState!==null?De._visibility&2?No(L,K,ee,ce,T):tc(L,K):(De._visibility|=2,No(L,K,ee,ce,T)),T&&ve&2048&&_p(K.alternate,K);break;case 24:No(L,K,ee,ce,T),T&&ve&2048&&Sp(K.alternate,K);break;default:No(L,K,ee,ce,T)}o=o.sibling}}function tc(i,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var f=i,y=o,T=y.flags;switch(y.tag){case 22:tc(f,y),T&2048&&_p(y.alternate,y);break;case 24:tc(f,y),T&2048&&Sp(y.alternate,y);break;default:tc(f,y)}o=o.sibling}}var nc=8192;function To(i,o,f){if(i.subtreeFlags&nc)for(i=i.child;i!==null;)T0(i,o,f),i=i.sibling}function T0(i,o,f){switch(i.tag){case 26:To(i,o,f),i.flags&nc&&i.memoizedState!==null&&YL(f,ns,i.memoizedState,i.memoizedProps);break;case 5:To(i,o,f);break;case 3:case 4:var y=ns;ns=wd(i.stateNode.containerInfo),To(i,o,f),ns=y;break;case 22:i.memoizedState===null&&(y=i.alternate,y!==null&&y.memoizedState!==null?(y=nc,nc=16777216,To(i,o,f),nc=y):To(i,o,f));break;default:To(i,o,f)}}function A0(i){var o=i.alternate;if(o!==null&&(i=o.child,i!==null)){o.child=null;do o=i.sibling,i.sibling=null,i=o;while(i!==null)}}function rc(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var y=o[f];zn=y,D0(y,i)}A0(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)L0(i),i=i.sibling}function L0(i){switch(i.tag){case 0:case 11:case 15:rc(i),i.flags&2048&&ji(9,i,i.return);break;case 3:rc(i);break;case 12:rc(i);break;case 22:var o=i.stateNode;i.memoizedState!==null&&o._visibility&2&&(i.return===null||i.return.tag!==13)?(o._visibility&=-3,ud(i)):rc(i);break;default:rc(i)}}function ud(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var y=o[f];zn=y,D0(y,i)}A0(i)}for(i=i.child;i!==null;){switch(o=i,o.tag){case 0:case 11:case 15:ji(8,o,o.return),ud(o);break;case 22:f=o.stateNode,f._visibility&2&&(f._visibility&=-3,ud(o));break;default:ud(o)}i=i.sibling}}function D0(i,o){for(;zn!==null;){var f=zn;switch(f.tag){case 0:case 11:case 15:ji(8,f,o);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var y=f.memoizedState.cachePool.pool;y!=null&&y.refCount++}break;case 24:zl(f.memoizedState.cache)}if(y=f.child,y!==null)y.return=f,zn=y;else e:for(f=i;zn!==null;){y=zn;var T=y.sibling,L=y.return;if(S0(y),y===f){zn=null;break e}if(T!==null){T.return=L,zn=T;break e}zn=L}}}var uL={getCacheForType:function(i){var o=Gn(kn),f=o.data.get(i);return f===void 0&&(f=i(),o.data.set(i,f)),f},cacheSignal:function(){return Gn(kn).controller.signal}},dL=typeof WeakMap=="function"?WeakMap:Map,Pt=0,Jt=null,wt=null,jt=0,Ft=0,kr=null,Ei=!1,Ao=!1,wp=!1,Xs=0,mn=0,Ni=0,va=0,Cp=0,jr=0,Lo=0,sc=null,hr=null,kp=!1,dd=0,R0=0,hd=1/0,fd=null,Ti=null,On=0,Ai=null,Do=null,Js=0,jp=0,Ep=null,O0=null,ic=0,Np=null;function Er(){return(Pt&2)!==0&&jt!==0?jt&-jt:q.T!==null?Op():rn()}function I0(){if(jr===0)if((jt&536870912)===0||Nt){var i=At;At<<=1,(At&3932160)===0&&(At=262144),jr=i}else jr=536870912;return i=wr.current,i!==null&&(i.flags|=32),jr}function fr(i,o,f){(i===Jt&&(Ft===2||Ft===9)||i.cancelPendingCommit!==null)&&(Ro(i,0),Li(i,jt,jr,!1)),we(i,f),((Pt&2)===0||i!==Jt)&&(i===Jt&&((Pt&2)===0&&(va|=f),mn===4&&Li(i,jt,jr,!1)),bs(i))}function M0(i,o,f){if((Pt&6)!==0)throw Error(r(327));var y=!f&&(o&127)===0&&(o&i.expiredLanes)===0||Dn(i,o),T=y?mL(i,o):Ap(i,o,!0),L=y;do{if(T===0){Ao&&!y&&Li(i,o,0,!1);break}else{if(f=i.current.alternate,L&&!hL(f)){T=Ap(i,o,!1),L=!1;continue}if(T===2){if(L=o,i.errorRecoveryDisabledLanes&L)var K=0;else K=i.pendingLanes&-536870913,K=K!==0?K:K&536870912?536870912:0;if(K!==0){o=K;e:{var ee=i;T=sc;var ce=ee.current.memoizedState.isDehydrated;if(ce&&(Ro(ee,K).flags|=256),K=Ap(ee,K,!1),K!==2){if(wp&&!ce){ee.errorRecoveryDisabledLanes|=L,va|=L,T=4;break e}L=hr,hr=T,L!==null&&(hr===null?hr=L:hr.push.apply(hr,L))}T=K}if(L=!1,T!==2)continue}}if(T===1){Ro(i,0),Li(i,o,0,!0);break}e:{switch(y=i,L=T,L){case 0:case 1:throw Error(r(345));case 4:if((o&4194048)!==o)break;case 6:Li(y,o,jr,!Ei);break e;case 2:hr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((o&62914560)===o&&(T=dd+300-Fe(),10<T)){if(Li(y,o,jr,!Ei),hn(y,0,!0)!==0)break e;Js=o,y.timeoutHandle=fS(P0.bind(null,y,f,hr,fd,kp,o,jr,va,Lo,Ei,L,"Throttled",-0,0),T);break e}P0(y,f,hr,fd,kp,o,jr,va,Lo,Ei,L,null,-0,0)}}break}while(!0);bs(i)}function P0(i,o,f,y,T,L,K,ee,ce,ve,De,ze,Ce,je){if(i.timeoutHandle=-1,ze=o.subtreeFlags,ze&8192||(ze&16785408)===16785408){ze={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ms},T0(o,L,ze);var nt=(L&62914560)===L?dd-Fe():(L&4194048)===L?R0-Fe():0;if(nt=XL(ze,nt),nt!==null){Js=L,i.cancelPendingCommit=nt(G0.bind(null,i,o,L,f,y,T,K,ee,ce,De,ze,null,Ce,je)),Li(i,L,K,!ve);return}}G0(i,o,L,f,y,T,K,ee,ce)}function hL(i){for(var o=i;;){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 y=0;y<f.length;y++){var T=f[y],L=T.getSnapshot;T=T.value;try{if(!_r(L(),T))return!1}catch{return!1}}if(f=o.child,o.subtreeFlags&16384&&f!==null)f.return=o,o=f;else{if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function Li(i,o,f,y){o&=~Cp,o&=~va,i.suspendedLanes|=o,i.pingedLanes&=~o,y&&(i.warmLanes|=o),y=i.expirationTimes;for(var T=o;0<T;){var L=31-Ve(T),K=1<<L;y[L]=-1,T&=~K}f!==0&&Ye(i,f,o)}function md(){return(Pt&6)===0?(ac(0),!1):!0}function Tp(){if(wt!==null){if(Ft===0)var i=wt.return;else i=wt,zs=da=null,Gm(i),wo=null,Fl=0,i=wt;for(;i!==null;)m0(i.alternate,i),i=i.return;wt=null}}function Ro(i,o){var f=i.timeoutHandle;f!==-1&&(i.timeoutHandle=-1,DL(f)),f=i.cancelPendingCommit,f!==null&&(i.cancelPendingCommit=null,f()),Js=0,Tp(),Jt=i,wt=f=Bs(i.current,null),jt=o,Ft=0,kr=null,Ei=!1,Ao=Dn(i,o),wp=!1,Lo=jr=Cp=va=Ni=mn=0,hr=sc=null,kp=!1,(o&8)!==0&&(o|=o&32);var y=i.entangledLanes;if(y!==0)for(i=i.entanglements,y&=o;0<y;){var T=31-Ve(y),L=1<<T;o|=i[T],y&=~L}return Xs=o,Iu(),f}function B0(i,o){bt=null,q.H=Xl,o===So||o===Uu?(o=e_(),Ft=3):o===Rm?(o=e_(),Ft=4):Ft=o===op?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,kr=o,wt===null&&(mn=1,rd(i,Br(o,i.current)))}function $0(){var i=wr.current;return i===null?!0:(jt&4194048)===jt?Fr===null:(jt&62914560)===jt||(jt&536870912)!==0?i===Fr:!1}function z0(){var i=q.H;return q.H=Xl,i===null?Xl:i}function H0(){var i=q.A;return q.A=uL,i}function pd(){mn=4,Ei||(jt&4194048)!==jt&&wr.current!==null||(Ao=!0),(Ni&134217727)===0&&(va&134217727)===0||Jt===null||Li(Jt,jt,jr,!1)}function Ap(i,o,f){var y=Pt;Pt|=2;var T=z0(),L=H0();(Jt!==i||jt!==o)&&(fd=null,Ro(i,o)),o=!1;var K=mn;e:do try{if(Ft!==0&&wt!==null){var ee=wt,ce=kr;switch(Ft){case 8:Tp(),K=6;break e;case 3:case 2:case 9:case 6:wr.current===null&&(o=!0);var ve=Ft;if(Ft=0,kr=null,Oo(i,ee,ce,ve),f&&Ao){K=0;break e}break;default:ve=Ft,Ft=0,kr=null,Oo(i,ee,ce,ve)}}fL(),K=mn;break}catch(De){B0(i,De)}while(!0);return o&&i.shellSuspendCounter++,zs=da=null,Pt=y,q.H=T,q.A=L,wt===null&&(Jt=null,jt=0,Iu()),K}function fL(){for(;wt!==null;)F0(wt)}function mL(i,o){var f=Pt;Pt|=2;var y=z0(),T=H0();Jt!==i||jt!==o?(fd=null,hd=Fe()+500,Ro(i,o)):Ao=Dn(i,o);e:do try{if(Ft!==0&&wt!==null){o=wt;var L=kr;t:switch(Ft){case 1:Ft=0,kr=null,Oo(i,o,L,1);break;case 2:case 9:if(Qv(L)){Ft=0,kr=null,U0(o);break}o=function(){Ft!==2&&Ft!==9||Jt!==i||(Ft=7),bs(i)},L.then(o,o);break e;case 3:Ft=7;break e;case 4:Ft=5;break e;case 7:Qv(L)?(Ft=0,kr=null,U0(o)):(Ft=0,kr=null,Oo(i,o,L,7));break;case 5:var K=null;switch(wt.tag){case 26:K=wt.memoizedState;case 5:case 27:var ee=wt;if(K?NS(K):ee.stateNode.complete){Ft=0,kr=null;var ce=ee.sibling;if(ce!==null)wt=ce;else{var ve=ee.return;ve!==null?(wt=ve,gd(ve)):wt=null}break t}}Ft=0,kr=null,Oo(i,o,L,5);break;case 6:Ft=0,kr=null,Oo(i,o,L,6);break;case 8:Tp(),mn=6;break e;default:throw Error(r(462))}}pL();break}catch(De){B0(i,De)}while(!0);return zs=da=null,q.H=y,q.A=T,Pt=f,wt!==null?0:(Jt=null,jt=0,Iu(),mn)}function pL(){for(;wt!==null&&!Me();)F0(wt)}function F0(i){var o=h0(i.alternate,i,Xs);i.memoizedProps=i.pendingProps,o===null?gd(i):wt=o}function U0(i){var o=i,f=o.alternate;switch(o.tag){case 15:case 0:o=a0(f,o,o.pendingProps,o.type,void 0,jt);break;case 11:o=a0(f,o,o.pendingProps,o.type.render,o.ref,jt);break;case 5:Gm(o);default:m0(f,o),o=wt=Hv(o,Xs),o=h0(f,o,Xs)}i.memoizedProps=i.pendingProps,o===null?gd(i):wt=o}function Oo(i,o,f,y){zs=da=null,Gm(o),wo=null,Fl=0;var T=o.return;try{if(rL(i,T,o,f,jt)){mn=1,rd(i,Br(f,i.current)),wt=null;return}}catch(L){if(T!==null)throw wt=T,L;mn=1,rd(i,Br(f,i.current)),wt=null;return}o.flags&32768?(Nt||y===1?i=!0:Ao||(jt&536870912)!==0?i=!1:(Ei=i=!0,(y===2||y===9||y===3||y===6)&&(y=wr.current,y!==null&&y.tag===13&&(y.flags|=16384))),V0(o,i)):gd(o)}function gd(i){var o=i;do{if((o.flags&32768)!==0){V0(o,Ei);return}i=o.return;var f=aL(o.alternate,o,Xs);if(f!==null){wt=f;return}if(o=o.sibling,o!==null){wt=o;return}wt=o=i}while(o!==null);mn===0&&(mn=5)}function V0(i,o){do{var f=oL(i.alternate,i);if(f!==null){f.flags&=32767,wt=f;return}if(f=i.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!o&&(i=i.sibling,i!==null)){wt=i;return}wt=i=f}while(i!==null);mn=6,wt=null}function G0(i,o,f,y,T,L,K,ee,ce){i.cancelPendingCommit=null;do xd();while(On!==0);if((Pt&6)!==0)throw Error(r(327));if(o!==null){if(o===i.current)throw Error(r(177));if(L=o.lanes|o.childLanes,L|=ym,et(i,f,L,K,ee,ce),i===Jt&&(wt=Jt=null,jt=0),Do=o,Ai=i,Js=f,jp=L,Ep=T,O0=y,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,bL(Le,function(){return X0(),null})):(i.callbackNode=null,i.callbackPriority=0),y=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||y){y=q.T,q.T=null,T=X.p,X.p=2,K=Pt,Pt|=4;try{lL(i,o,f)}finally{Pt=K,X.p=T,q.T=y}}On=1,W0(),q0(),K0()}}function W0(){if(On===1){On=0;var i=Ai,o=Do,f=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||f){f=q.T,q.T=null;var y=X.p;X.p=2;var T=Pt;Pt|=4;try{j0(o,i);var L=Fp,K=Dv(i.containerInfo),ee=L.focusedElem,ce=L.selectionRange;if(K!==ee&&ee&&ee.ownerDocument&&Lv(ee.ownerDocument.documentElement,ee)){if(ce!==null&&fm(ee)){var ve=ce.start,De=ce.end;if(De===void 0&&(De=ve),"selectionStart"in ee)ee.selectionStart=ve,ee.selectionEnd=Math.min(De,ee.value.length);else{var ze=ee.ownerDocument||document,Ce=ze&&ze.defaultView||window;if(Ce.getSelection){var je=Ce.getSelection(),nt=ee.textContent.length,ct=Math.min(ce.start,nt),qt=ce.end===void 0?ct:Math.min(ce.end,nt);!je.extend&&ct>qt&&(K=qt,qt=ct,ct=K);var pe=Av(ee,ct),de=Av(ee,qt);if(pe&&de&&(je.rangeCount!==1||je.anchorNode!==pe.node||je.anchorOffset!==pe.offset||je.focusNode!==de.node||je.focusOffset!==de.offset)){var be=ze.createRange();be.setStart(pe.node,pe.offset),je.removeAllRanges(),ct>qt?(je.addRange(be),je.extend(de.node,de.offset)):(be.setEnd(de.node,de.offset),je.addRange(be))}}}}for(ze=[],je=ee;je=je.parentNode;)je.nodeType===1&&ze.push({element:je,left:je.scrollLeft,top:je.scrollTop});for(typeof ee.focus=="function"&&ee.focus(),ee=0;ee<ze.length;ee++){var Ie=ze[ee];Ie.element.scrollLeft=Ie.left,Ie.element.scrollTop=Ie.top}}Td=!!Hp,Fp=Hp=null}finally{Pt=T,X.p=y,q.T=f}}i.current=o,On=2}}function q0(){if(On===2){On=0;var i=Ai,o=Do,f=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||f){f=q.T,q.T=null;var y=X.p;X.p=2;var T=Pt;Pt|=4;try{_0(i,o.alternate,o)}finally{Pt=T,X.p=y,q.T=f}}On=3}}function K0(){if(On===4||On===3){On=0,fe();var i=Ai,o=Do,f=Js,y=O0;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?On=5:(On=0,Do=Ai=null,Y0(i,i.pendingLanes));var T=i.pendingLanes;if(T===0&&(Ti=null),Dt(f),o=o.stateNode,it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(Qe,o,void 0,(o.current.flags&128)===128)}catch{}if(y!==null){o=q.T,T=X.p,X.p=2,q.T=null;try{for(var L=i.onRecoverableError,K=0;K<y.length;K++){var ee=y[K];L(ee.value,{componentStack:ee.stack})}}finally{q.T=o,X.p=T}}(Js&3)!==0&&xd(),bs(i),T=i.pendingLanes,(f&261930)!==0&&(T&42)!==0?i===Np?ic++:(ic=0,Np=i):ic=0,ac(0)}}function Y0(i,o){(i.pooledCacheLanes&=o)===0&&(o=i.pooledCache,o!=null&&(i.pooledCache=null,zl(o)))}function xd(){return W0(),q0(),K0(),X0()}function X0(){if(On!==5)return!1;var i=Ai,o=jp;jp=0;var f=Dt(Js),y=q.T,T=X.p;try{X.p=32>f?32:f,q.T=null,f=Ep,Ep=null;var L=Ai,K=Js;if(On=0,Do=Ai=null,Js=0,(Pt&6)!==0)throw Error(r(331));var ee=Pt;if(Pt|=4,L0(L.current),N0(L,L.current,K,f),Pt=ee,ac(0,!1),it&&typeof it.onPostCommitFiberRoot=="function")try{it.onPostCommitFiberRoot(Qe,L)}catch{}return!0}finally{X.p=T,q.T=y,Y0(i,o)}}function J0(i,o,f){o=Br(f,o),o=ap(i.stateNode,o,2),i=wi(i,o,2),i!==null&&(we(i,2),bs(i))}function Ut(i,o,f){if(i.tag===3)J0(i,i,f);else for(;o!==null;){if(o.tag===3){J0(o,i,f);break}else if(o.tag===1){var y=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Ti===null||!Ti.has(y))){i=Br(f,i),f=Q_(2),y=wi(o,f,2),y!==null&&(Z_(f,y,o,i),we(y,2),bs(y));break}}o=o.return}}function Lp(i,o,f){var y=i.pingCache;if(y===null){y=i.pingCache=new dL;var T=new Set;y.set(o,T)}else T=y.get(o),T===void 0&&(T=new Set,y.set(o,T));T.has(f)||(wp=!0,T.add(f),i=gL.bind(null,i,o,f),o.then(i,i))}function gL(i,o,f){var y=i.pingCache;y!==null&&y.delete(o),i.pingedLanes|=i.suspendedLanes&f,i.warmLanes&=~f,Jt===i&&(jt&f)===f&&(mn===4||mn===3&&(jt&62914560)===jt&&300>Fe()-dd?(Pt&2)===0&&Ro(i,0):Cp|=f,Lo===jt&&(Lo=0)),bs(i)}function Q0(i,o){o===0&&(o=un()),i=la(i,o),i!==null&&(we(i,o),bs(i))}function xL(i){var o=i.memoizedState,f=0;o!==null&&(f=o.retryLane),Q0(i,f)}function yL(i,o){var f=0;switch(i.tag){case 31:case 13:var y=i.stateNode,T=i.memoizedState;T!==null&&(f=T.retryLane);break;case 19:y=i.stateNode;break;case 22:y=i.stateNode._retryCache;break;default:throw Error(r(314))}y!==null&&y.delete(o),Q0(i,f)}function bL(i,o){return ae(i,o)}var yd=null,Io=null,Dp=!1,bd=!1,Rp=!1,Di=0;function bs(i){i!==Io&&i.next===null&&(Io===null?yd=Io=i:Io=Io.next=i),bd=!0,Dp||(Dp=!0,_L())}function ac(i,o){if(!Rp&&bd){Rp=!0;do for(var f=!1,y=yd;y!==null;){if(i!==0){var T=y.pendingLanes;if(T===0)var L=0;else{var K=y.suspendedLanes,ee=y.pingedLanes;L=(1<<31-Ve(42|i)+1)-1,L&=T&~(K&~ee),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(f=!0,nS(y,L))}else L=jt,L=hn(y,y===Jt?L:0,y.cancelPendingCommit!==null||y.timeoutHandle!==-1),(L&3)===0||Dn(y,L)||(f=!0,nS(y,L));y=y.next}while(f);Rp=!1}}function vL(){Z0()}function Z0(){bd=Dp=!1;var i=0;Di!==0&&LL()&&(i=Di);for(var o=Fe(),f=null,y=yd;y!==null;){var T=y.next,L=eS(y,o);L===0?(y.next=null,f===null?yd=T:f.next=T,T===null&&(Io=f)):(f=y,(i!==0||(L&3)!==0)&&(bd=!0)),y=T}On!==0&&On!==5||ac(i),Di!==0&&(Di=0)}function eS(i,o){for(var f=i.suspendedLanes,y=i.pingedLanes,T=i.expirationTimes,L=i.pendingLanes&-62914561;0<L;){var K=31-Ve(L),ee=1<<K,ce=T[K];ce===-1?((ee&f)===0||(ee&y)!==0)&&(T[K]=wn(ee,o)):ce<=o&&(i.expiredLanes|=ee),L&=~ee}if(o=Jt,f=jt,f=hn(i,i===o?f:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y=i.callbackNode,f===0||i===o&&(Ft===2||Ft===9)||i.cancelPendingCommit!==null)return y!==null&&y!==null&&ue(y),i.callbackNode=null,i.callbackPriority=0;if((f&3)===0||Dn(i,f)){if(o=f&-f,o===i.callbackPriority)return o;switch(y!==null&&ue(y),Dt(f)){case 2:case 8:f=Se;break;case 32:f=Le;break;case 268435456:f=me;break;default:f=Le}return y=tS.bind(null,i),f=ae(f,y),i.callbackPriority=o,i.callbackNode=f,o}return y!==null&&y!==null&&ue(y),i.callbackPriority=2,i.callbackNode=null,2}function tS(i,o){if(On!==0&&On!==5)return i.callbackNode=null,i.callbackPriority=0,null;var f=i.callbackNode;if(xd()&&i.callbackNode!==f)return null;var y=jt;return y=hn(i,i===Jt?y:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y===0?null:(M0(i,y,o),eS(i,Fe()),i.callbackNode!=null&&i.callbackNode===f?tS.bind(null,i):null)}function nS(i,o){if(xd())return null;M0(i,o,!0)}function _L(){RL(function(){(Pt&6)!==0?ae(ie,vL):Z0()})}function Op(){if(Di===0){var i=vo;i===0&&(i=Vt,Vt<<=1,(Vt&261888)===0&&(Vt=256)),Di=i}return Di}function rS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Eu(""+i)}function sS(i,o){var f=o.ownerDocument.createElement("input");return f.name=o.name,f.value=o.value,i.id&&f.setAttribute("form",i.id),o.parentNode.insertBefore(f,o),i=new FormData(i),f.parentNode.removeChild(f),i}function SL(i,o,f,y,T){if(o==="submit"&&f&&f.stateNode===T){var L=rS((T[Xe]||null).action),K=y.submitter;K&&(o=(o=K[Xe]||null)?rS(o.formAction):K.getAttribute("formAction"),o!==null&&(L=o,K=null));var ee=new Lu("action","action",null,y,T);i.push({event:ee,listeners:[{instance:null,listener:function(){if(y.defaultPrevented){if(Di!==0){var ce=K?sS(T,K):new FormData(T);ep(f,{pending:!0,data:ce,method:T.method,action:L},null,ce)}}else typeof L=="function"&&(ee.preventDefault(),ce=K?sS(T,K):new FormData(T),ep(f,{pending:!0,data:ce,method:T.method,action:L},L,ce))},currentTarget:T}]})}}for(var Ip=0;Ip<xm.length;Ip++){var Mp=xm[Ip],wL=Mp.toLowerCase(),CL=Mp[0].toUpperCase()+Mp.slice(1);ts(wL,"on"+CL)}ts(Iv,"onAnimationEnd"),ts(Mv,"onAnimationIteration"),ts(Pv,"onAnimationStart"),ts("dblclick","onDoubleClick"),ts("focusin","onFocus"),ts("focusout","onBlur"),ts(zA,"onTransitionRun"),ts(HA,"onTransitionStart"),ts(FA,"onTransitionCancel"),ts(Bv,"onTransitionEnd"),io("onMouseEnter",["mouseout","mouseover"]),io("onMouseLeave",["mouseout","mouseover"]),io("onPointerEnter",["pointerout","pointerover"]),io("onPointerLeave",["pointerout","pointerover"]),sa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),sa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),sa("onBeforeInput",["compositionend","keypress","textInput","paste"]),sa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),sa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),sa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var oc="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(" "),kL=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(oc));function iS(i,o){o=(o&4)!==0;for(var f=0;f<i.length;f++){var y=i[f],T=y.event;y=y.listeners;e:{var L=void 0;if(o)for(var K=y.length-1;0<=K;K--){var ee=y[K],ce=ee.instance,ve=ee.currentTarget;if(ee=ee.listener,ce!==L&&T.isPropagationStopped())break e;L=ee,T.currentTarget=ve;try{L(T)}catch(De){Ou(De)}T.currentTarget=null,L=ce}else for(K=0;K<y.length;K++){if(ee=y[K],ce=ee.instance,ve=ee.currentTarget,ee=ee.listener,ce!==L&&T.isPropagationStopped())break e;L=ee,T.currentTarget=ve;try{L(T)}catch(De){Ou(De)}T.currentTarget=null,L=ce}}}}function Ct(i,o){var f=o[mt];f===void 0&&(f=o[mt]=new Set);var y=i+"__bubble";f.has(y)||(aS(o,i,2,!1),f.add(y))}function Pp(i,o,f){var y=0;o&&(y|=4),aS(f,i,y,o)}var vd="_reactListening"+Math.random().toString(36).slice(2);function Bp(i){if(!i[vd]){i[vd]=!0,Zb.forEach(function(f){f!=="selectionchange"&&(kL.has(f)||Pp(f,!1,i),Pp(f,!0,i))});var o=i.nodeType===9?i:i.ownerDocument;o===null||o[vd]||(o[vd]=!0,Pp("selectionchange",!1,o))}}function aS(i,o,f,y){switch(IS(o)){case 2:var T=ZL;break;case 8:T=eD;break;default:T=Zp}f=T.bind(null,o,f,i),T=void 0,!sm||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(T=!0),y?T!==void 0?i.addEventListener(o,f,{capture:!0,passive:T}):i.addEventListener(o,f,!0):T!==void 0?i.addEventListener(o,f,{passive:T}):i.addEventListener(o,f,!1)}function $p(i,o,f,y,T){var L=y;if((o&1)===0&&(o&2)===0&&y!==null)e:for(;;){if(y===null)return;var K=y.tag;if(K===3||K===4){var ee=y.stateNode.containerInfo;if(ee===T)break;if(K===4)for(K=y.return;K!==null;){var ce=K.tag;if((ce===3||ce===4)&&K.stateNode.containerInfo===T)return;K=K.return}for(;ee!==null;){if(K=no(ee),K===null)return;if(ce=K.tag,ce===5||ce===6||ce===26||ce===27){y=L=K;continue e}ee=ee.parentNode}}y=y.return}dv(function(){var ve=L,De=nm(f),ze=[];e:{var Ce=$v.get(i);if(Ce!==void 0){var je=Lu,nt=i;switch(i){case"keypress":if(Tu(f)===0)break e;case"keydown":case"keyup":je=yA;break;case"focusin":nt="focus",je=lm;break;case"focusout":nt="blur",je=lm;break;case"beforeblur":case"afterblur":je=lm;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":je=mv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=aA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=_A;break;case Iv:case Mv:case Pv:je=cA;break;case Bv:je=wA;break;case"scroll":case"scrollend":je=sA;break;case"wheel":je=kA;break;case"copy":case"cut":case"paste":je=dA;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=gv;break;case"toggle":case"beforetoggle":je=EA}var ct=(o&4)!==0,qt=!ct&&(i==="scroll"||i==="scrollend"),pe=ct?Ce!==null?Ce+"Capture":null:Ce;ct=[];for(var de=ve,be;de!==null;){var Ie=de;if(be=Ie.stateNode,Ie=Ie.tag,Ie!==5&&Ie!==26&&Ie!==27||be===null||pe===null||(Ie=Tl(de,pe),Ie!=null&&ct.push(lc(de,Ie,be))),qt)break;de=de.return}0<ct.length&&(Ce=new je(Ce,nt,null,f,De),ze.push({event:Ce,listeners:ct}))}}if((o&7)===0){e:{if(Ce=i==="mouseover"||i==="pointerover",je=i==="mouseout"||i==="pointerout",Ce&&f!==tm&&(nt=f.relatedTarget||f.fromElement)&&(no(nt)||nt[tt]))break e;if((je||Ce)&&(Ce=De.window===De?De:(Ce=De.ownerDocument)?Ce.defaultView||Ce.parentWindow:window,je?(nt=f.relatedTarget||f.toElement,je=ve,nt=nt?no(nt):null,nt!==null&&(qt=l(nt),ct=nt.tag,nt!==qt||ct!==5&&ct!==27&&ct!==6)&&(nt=null)):(je=null,nt=ve),je!==nt)){if(ct=mv,Ie="onMouseLeave",pe="onMouseEnter",de="mouse",(i==="pointerout"||i==="pointerover")&&(ct=gv,Ie="onPointerLeave",pe="onPointerEnter",de="pointer"),qt=je==null?Ce:Nl(je),be=nt==null?Ce:Nl(nt),Ce=new ct(Ie,de+"leave",je,f,De),Ce.target=qt,Ce.relatedTarget=be,Ie=null,no(De)===ve&&(ct=new ct(pe,de+"enter",nt,f,De),ct.target=be,ct.relatedTarget=qt,Ie=ct),qt=Ie,je&&nt)t:{for(ct=jL,pe=je,de=nt,be=0,Ie=pe;Ie;Ie=ct(Ie))be++;Ie=0;for(var ot=de;ot;ot=ct(ot))Ie++;for(;0<be-Ie;)pe=ct(pe),be--;for(;0<Ie-be;)de=ct(de),Ie--;for(;be--;){if(pe===de||de!==null&&pe===de.alternate){ct=pe;break t}pe=ct(pe),de=ct(de)}ct=null}else ct=null;je!==null&&oS(ze,Ce,je,ct,!1),nt!==null&&qt!==null&&oS(ze,qt,nt,ct,!0)}}e:{if(Ce=ve?Nl(ve):window,je=Ce.nodeName&&Ce.nodeName.toLowerCase(),je==="select"||je==="input"&&Ce.type==="file")var Rt=Cv;else if(Sv(Ce))if(kv)Rt=PA;else{Rt=IA;var st=OA}else je=Ce.nodeName,!je||je.toLowerCase()!=="input"||Ce.type!=="checkbox"&&Ce.type!=="radio"?ve&&em(ve.elementType)&&(Rt=Cv):Rt=MA;if(Rt&&(Rt=Rt(i,ve))){wv(ze,Rt,f,De);break e}st&&st(i,Ce,ve),i==="focusout"&&ve&&Ce.type==="number"&&ve.memoizedProps.value!=null&&Zf(Ce,"number",Ce.value)}switch(st=ve?Nl(ve):window,i){case"focusin":(Sv(st)||st.contentEditable==="true")&&(ho=st,mm=ve,Pl=null);break;case"focusout":Pl=mm=ho=null;break;case"mousedown":pm=!0;break;case"contextmenu":case"mouseup":case"dragend":pm=!1,Rv(ze,f,De);break;case"selectionchange":if($A)break;case"keydown":case"keyup":Rv(ze,f,De)}var vt;if(um)e:{switch(i){case"compositionstart":var Et="onCompositionStart";break e;case"compositionend":Et="onCompositionEnd";break e;case"compositionupdate":Et="onCompositionUpdate";break e}Et=void 0}else uo?vv(i,f)&&(Et="onCompositionEnd"):i==="keydown"&&f.keyCode===229&&(Et="onCompositionStart");Et&&(xv&&f.locale!=="ko"&&(uo||Et!=="onCompositionStart"?Et==="onCompositionEnd"&&uo&&(vt=hv()):(gi=De,im="value"in gi?gi.value:gi.textContent,uo=!0)),st=_d(ve,Et),0<st.length&&(Et=new pv(Et,i,null,f,De),ze.push({event:Et,listeners:st}),vt?Et.data=vt:(vt=_v(f),vt!==null&&(Et.data=vt)))),(vt=TA?AA(i,f):LA(i,f))&&(Et=_d(ve,"onBeforeInput"),0<Et.length&&(st=new pv("onBeforeInput","beforeinput",null,f,De),ze.push({event:st,listeners:Et}),st.data=vt)),SL(ze,i,ve,f,De)}iS(ze,o)})}function lc(i,o,f){return{instance:i,listener:o,currentTarget:f}}function _d(i,o){for(var f=o+"Capture",y=[];i!==null;){var T=i,L=T.stateNode;if(T=T.tag,T!==5&&T!==26&&T!==27||L===null||(T=Tl(i,f),T!=null&&y.unshift(lc(i,T,L)),T=Tl(i,o),T!=null&&y.push(lc(i,T,L))),i.tag===3)return y;i=i.return}return[]}function jL(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function oS(i,o,f,y,T){for(var L=o._reactName,K=[];f!==null&&f!==y;){var ee=f,ce=ee.alternate,ve=ee.stateNode;if(ee=ee.tag,ce!==null&&ce===y)break;ee!==5&&ee!==26&&ee!==27||ve===null||(ce=ve,T?(ve=Tl(f,L),ve!=null&&K.unshift(lc(f,ve,ce))):T||(ve=Tl(f,L),ve!=null&&K.push(lc(f,ve,ce)))),f=f.return}K.length!==0&&i.push({event:o,listeners:K})}var EL=/\r\n?/g,NL=/\u0000|\uFFFD/g;function lS(i){return(typeof i=="string"?i:""+i).replace(EL,`
50
+ `).replace(NL,"")}function cS(i,o){return o=lS(o),lS(i)===o}function Wt(i,o,f,y,T,L){switch(f){case"children":typeof y=="string"?o==="body"||o==="textarea"&&y===""||oo(i,y):(typeof y=="number"||typeof y=="bigint")&&o!=="body"&&oo(i,""+y);break;case"className":ku(i,"class",y);break;case"tabIndex":ku(i,"tabindex",y);break;case"dir":case"role":case"viewBox":case"width":case"height":ku(i,f,y);break;case"style":cv(i,y,L);break;case"data":if(o!=="object"){ku(i,"data",y);break}case"src":case"href":if(y===""&&(o!=="a"||f!=="href")){i.removeAttribute(f);break}if(y==null||typeof y=="function"||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(f);break}y=Eu(""+y),i.setAttribute(f,y);break;case"action":case"formAction":if(typeof y=="function"){i.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 L=="function"&&(f==="formAction"?(o!=="input"&&Wt(i,o,"name",T.name,T,null),Wt(i,o,"formEncType",T.formEncType,T,null),Wt(i,o,"formMethod",T.formMethod,T,null),Wt(i,o,"formTarget",T.formTarget,T,null)):(Wt(i,o,"encType",T.encType,T,null),Wt(i,o,"method",T.method,T,null),Wt(i,o,"target",T.target,T,null)));if(y==null||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(f);break}y=Eu(""+y),i.setAttribute(f,y);break;case"onClick":y!=null&&(i.onclick=Ms);break;case"onScroll":y!=null&&Ct("scroll",i);break;case"onScrollEnd":y!=null&&Ct("scrollend",i);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(f=y.__html,f!=null){if(T.children!=null)throw Error(r(60));i.innerHTML=f}}break;case"multiple":i.multiple=y&&typeof y!="function"&&typeof y!="symbol";break;case"muted":i.muted=y&&typeof y!="function"&&typeof y!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(y==null||typeof y=="function"||typeof y=="boolean"||typeof y=="symbol"){i.removeAttribute("xlink:href");break}f=Eu(""+y),i.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":y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(f,""+y):i.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":y&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(f,""):i.removeAttribute(f);break;case"capture":case"download":y===!0?i.setAttribute(f,""):y!==!1&&y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(f,y):i.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":y!=null&&typeof y!="function"&&typeof y!="symbol"&&!isNaN(y)&&1<=y?i.setAttribute(f,y):i.removeAttribute(f);break;case"rowSpan":case"start":y==null||typeof y=="function"||typeof y=="symbol"||isNaN(y)?i.removeAttribute(f):i.setAttribute(f,y);break;case"popover":Ct("beforetoggle",i),Ct("toggle",i),Cu(i,"popover",y);break;case"xlinkActuate":Is(i,"http://www.w3.org/1999/xlink","xlink:actuate",y);break;case"xlinkArcrole":Is(i,"http://www.w3.org/1999/xlink","xlink:arcrole",y);break;case"xlinkRole":Is(i,"http://www.w3.org/1999/xlink","xlink:role",y);break;case"xlinkShow":Is(i,"http://www.w3.org/1999/xlink","xlink:show",y);break;case"xlinkTitle":Is(i,"http://www.w3.org/1999/xlink","xlink:title",y);break;case"xlinkType":Is(i,"http://www.w3.org/1999/xlink","xlink:type",y);break;case"xmlBase":Is(i,"http://www.w3.org/XML/1998/namespace","xml:base",y);break;case"xmlLang":Is(i,"http://www.w3.org/XML/1998/namespace","xml:lang",y);break;case"xmlSpace":Is(i,"http://www.w3.org/XML/1998/namespace","xml:space",y);break;case"is":Cu(i,"is",y);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=nA.get(f)||f,Cu(i,f,y))}}function zp(i,o,f,y,T,L){switch(f){case"style":cv(i,y,L);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(f=y.__html,f!=null){if(T.children!=null)throw Error(r(60));i.innerHTML=f}}break;case"children":typeof y=="string"?oo(i,y):(typeof y=="number"||typeof y=="bigint")&&oo(i,""+y);break;case"onScroll":y!=null&&Ct("scroll",i);break;case"onScrollEnd":y!=null&&Ct("scrollend",i);break;case"onClick":y!=null&&(i.onclick=Ms);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ev.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(T=f.endsWith("Capture"),o=f.slice(2,T?f.length-7:void 0),L=i[Xe]||null,L=L!=null?L[f]:null,typeof L=="function"&&i.removeEventListener(o,L,T),typeof y=="function")){typeof L!="function"&&L!==null&&(f in i?i[f]=null:i.hasAttribute(f)&&i.removeAttribute(f)),i.addEventListener(o,y,T);break e}f in i?i[f]=y:y===!0?i.setAttribute(f,""):Cu(i,f,y)}}}function qn(i,o,f){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ct("error",i),Ct("load",i);var y=!1,T=!1,L;for(L in f)if(f.hasOwnProperty(L)){var K=f[L];if(K!=null)switch(L){case"src":y=!0;break;case"srcSet":T=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Wt(i,o,L,K,f,null)}}T&&Wt(i,o,"srcSet",f.srcSet,f,null),y&&Wt(i,o,"src",f.src,f,null);return;case"input":Ct("invalid",i);var ee=L=K=T=null,ce=null,ve=null;for(y in f)if(f.hasOwnProperty(y)){var De=f[y];if(De!=null)switch(y){case"name":T=De;break;case"type":K=De;break;case"checked":ce=De;break;case"defaultChecked":ve=De;break;case"value":L=De;break;case"defaultValue":ee=De;break;case"children":case"dangerouslySetInnerHTML":if(De!=null)throw Error(r(137,o));break;default:Wt(i,o,y,De,f,null)}}iv(i,L,ee,ce,ve,K,T,!1);return;case"select":Ct("invalid",i),y=K=L=null;for(T in f)if(f.hasOwnProperty(T)&&(ee=f[T],ee!=null))switch(T){case"value":L=ee;break;case"defaultValue":K=ee;break;case"multiple":y=ee;default:Wt(i,o,T,ee,f,null)}o=L,f=K,i.multiple=!!y,o!=null?ao(i,!!y,o,!1):f!=null&&ao(i,!!y,f,!0);return;case"textarea":Ct("invalid",i),L=T=y=null;for(K in f)if(f.hasOwnProperty(K)&&(ee=f[K],ee!=null))switch(K){case"value":y=ee;break;case"defaultValue":T=ee;break;case"children":L=ee;break;case"dangerouslySetInnerHTML":if(ee!=null)throw Error(r(91));break;default:Wt(i,o,K,ee,f,null)}ov(i,y,T,L);return;case"option":for(ce in f)if(f.hasOwnProperty(ce)&&(y=f[ce],y!=null))switch(ce){case"selected":i.selected=y&&typeof y!="function"&&typeof y!="symbol";break;default:Wt(i,o,ce,y,f,null)}return;case"dialog":Ct("beforetoggle",i),Ct("toggle",i),Ct("cancel",i),Ct("close",i);break;case"iframe":case"object":Ct("load",i);break;case"video":case"audio":for(y=0;y<oc.length;y++)Ct(oc[y],i);break;case"image":Ct("error",i),Ct("load",i);break;case"details":Ct("toggle",i);break;case"embed":case"source":case"link":Ct("error",i),Ct("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ve in f)if(f.hasOwnProperty(ve)&&(y=f[ve],y!=null))switch(ve){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Wt(i,o,ve,y,f,null)}return;default:if(em(o)){for(De in f)f.hasOwnProperty(De)&&(y=f[De],y!==void 0&&zp(i,o,De,y,f,void 0));return}}for(ee in f)f.hasOwnProperty(ee)&&(y=f[ee],y!=null&&Wt(i,o,ee,y,f,null))}function TL(i,o,f,y){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var T=null,L=null,K=null,ee=null,ce=null,ve=null,De=null;for(je in f){var ze=f[je];if(f.hasOwnProperty(je)&&ze!=null)switch(je){case"checked":break;case"value":break;case"defaultValue":ce=ze;default:y.hasOwnProperty(je)||Wt(i,o,je,null,y,ze)}}for(var Ce in y){var je=y[Ce];if(ze=f[Ce],y.hasOwnProperty(Ce)&&(je!=null||ze!=null))switch(Ce){case"type":L=je;break;case"name":T=je;break;case"checked":ve=je;break;case"defaultChecked":De=je;break;case"value":K=je;break;case"defaultValue":ee=je;break;case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(r(137,o));break;default:je!==ze&&Wt(i,o,Ce,je,y,ze)}}Qf(i,K,ee,ce,ve,De,L,T);return;case"select":je=K=ee=Ce=null;for(L in f)if(ce=f[L],f.hasOwnProperty(L)&&ce!=null)switch(L){case"value":break;case"multiple":je=ce;default:y.hasOwnProperty(L)||Wt(i,o,L,null,y,ce)}for(T in y)if(L=y[T],ce=f[T],y.hasOwnProperty(T)&&(L!=null||ce!=null))switch(T){case"value":Ce=L;break;case"defaultValue":ee=L;break;case"multiple":K=L;default:L!==ce&&Wt(i,o,T,L,y,ce)}o=ee,f=K,y=je,Ce!=null?ao(i,!!f,Ce,!1):!!y!=!!f&&(o!=null?ao(i,!!f,o,!0):ao(i,!!f,f?[]:"",!1));return;case"textarea":je=Ce=null;for(ee in f)if(T=f[ee],f.hasOwnProperty(ee)&&T!=null&&!y.hasOwnProperty(ee))switch(ee){case"value":break;case"children":break;default:Wt(i,o,ee,null,y,T)}for(K in y)if(T=y[K],L=f[K],y.hasOwnProperty(K)&&(T!=null||L!=null))switch(K){case"value":Ce=T;break;case"defaultValue":je=T;break;case"children":break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:T!==L&&Wt(i,o,K,T,y,L)}av(i,Ce,je);return;case"option":for(var nt in f)if(Ce=f[nt],f.hasOwnProperty(nt)&&Ce!=null&&!y.hasOwnProperty(nt))switch(nt){case"selected":i.selected=!1;break;default:Wt(i,o,nt,null,y,Ce)}for(ce in y)if(Ce=y[ce],je=f[ce],y.hasOwnProperty(ce)&&Ce!==je&&(Ce!=null||je!=null))switch(ce){case"selected":i.selected=Ce&&typeof Ce!="function"&&typeof Ce!="symbol";break;default:Wt(i,o,ce,Ce,y,je)}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 ct in f)Ce=f[ct],f.hasOwnProperty(ct)&&Ce!=null&&!y.hasOwnProperty(ct)&&Wt(i,o,ct,null,y,Ce);for(ve in y)if(Ce=y[ve],je=f[ve],y.hasOwnProperty(ve)&&Ce!==je&&(Ce!=null||je!=null))switch(ve){case"children":case"dangerouslySetInnerHTML":if(Ce!=null)throw Error(r(137,o));break;default:Wt(i,o,ve,Ce,y,je)}return;default:if(em(o)){for(var qt in f)Ce=f[qt],f.hasOwnProperty(qt)&&Ce!==void 0&&!y.hasOwnProperty(qt)&&zp(i,o,qt,void 0,y,Ce);for(De in y)Ce=y[De],je=f[De],!y.hasOwnProperty(De)||Ce===je||Ce===void 0&&je===void 0||zp(i,o,De,Ce,y,je);return}}for(var pe in f)Ce=f[pe],f.hasOwnProperty(pe)&&Ce!=null&&!y.hasOwnProperty(pe)&&Wt(i,o,pe,null,y,Ce);for(ze in y)Ce=y[ze],je=f[ze],!y.hasOwnProperty(ze)||Ce===je||Ce==null&&je==null||Wt(i,o,ze,Ce,y,je)}function uS(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function AL(){if(typeof performance.getEntriesByType=="function"){for(var i=0,o=0,f=performance.getEntriesByType("resource"),y=0;y<f.length;y++){var T=f[y],L=T.transferSize,K=T.initiatorType,ee=T.duration;if(L&&ee&&uS(K)){for(K=0,ee=T.responseEnd,y+=1;y<f.length;y++){var ce=f[y],ve=ce.startTime;if(ve>ee)break;var De=ce.transferSize,ze=ce.initiatorType;De&&uS(ze)&&(ce=ce.responseEnd,K+=De*(ce<ee?1:(ee-ve)/(ce-ve)))}if(--y,o+=8*(L+K)/(T.duration/1e3),i++,10<i)break}}if(0<i)return o/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Hp=null,Fp=null;function Sd(i){return i.nodeType===9?i:i.ownerDocument}function dS(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function hS(i,o){if(i===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&o==="foreignObject"?0:i}function Up(i,o){return i==="textarea"||i==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Vp=null;function LL(){var i=window.event;return i&&i.type==="popstate"?i===Vp?!1:(Vp=i,!0):(Vp=null,!1)}var fS=typeof setTimeout=="function"?setTimeout:void 0,DL=typeof clearTimeout=="function"?clearTimeout:void 0,mS=typeof Promise=="function"?Promise:void 0,RL=typeof queueMicrotask=="function"?queueMicrotask:typeof mS<"u"?function(i){return mS.resolve(null).then(i).catch(OL)}:fS;function OL(i){setTimeout(function(){throw i})}function Ri(i){return i==="head"}function pS(i,o){var f=o,y=0;do{var T=f.nextSibling;if(i.removeChild(f),T&&T.nodeType===8)if(f=T.data,f==="/$"||f==="/&"){if(y===0){i.removeChild(T),$o(o);return}y--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")y++;else if(f==="html")cc(i.ownerDocument.documentElement);else if(f==="head"){f=i.ownerDocument.head,cc(f);for(var L=f.firstChild;L;){var K=L.nextSibling,ee=L.nodeName;L[Cn]||ee==="SCRIPT"||ee==="STYLE"||ee==="LINK"&&L.rel.toLowerCase()==="stylesheet"||f.removeChild(L),L=K}}else f==="body"&&cc(i.ownerDocument.body);f=T}while(f);$o(o)}function gS(i,o){var f=i;i=0;do{var y=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||""),y&&y.nodeType===8)if(f=y.data,f==="/$"){if(i===0)break;i--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||i++;f=y}while(f)}function Gp(i){var o=i.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":Gp(f),to(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}i.removeChild(f)}}function IL(i,o,f,y){for(;i.nodeType===1;){var T=f;if(i.nodeName.toLowerCase()!==o.toLowerCase()){if(!y&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(y){if(!i[Cn])switch(o){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(L=i.getAttribute("rel"),L==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(L!==T.rel||i.getAttribute("href")!==(T.href==null||T.href===""?null:T.href)||i.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin)||i.getAttribute("title")!==(T.title==null?null:T.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(L=i.getAttribute("src"),(L!==(T.src==null?null:T.src)||i.getAttribute("type")!==(T.type==null?null:T.type)||i.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin))&&L&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(o==="input"&&i.type==="hidden"){var L=T.name==null?null:""+T.name;if(T.type==="hidden"&&i.getAttribute("name")===L)return i}else return i;if(i=Ur(i.nextSibling),i===null)break}return null}function ML(i,o,f){if(o==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!f||(i=Ur(i.nextSibling),i===null))return null;return i}function xS(i,o){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!o||(i=Ur(i.nextSibling),i===null))return null;return i}function Wp(i){return i.data==="$?"||i.data==="$~"}function qp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function PL(i,o){var f=i.ownerDocument;if(i.data==="$~")i._reactRetry=o;else if(i.data!=="$?"||f.readyState!=="loading")o();else{var y=function(){o(),f.removeEventListener("DOMContentLoaded",y)};f.addEventListener("DOMContentLoaded",y),i._reactRetry=y}}function Ur(i){for(;i!=null;i=i.nextSibling){var o=i.nodeType;if(o===1||o===3)break;if(o===8){if(o=i.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return i}var Kp=null;function yS(i){i=i.nextSibling;for(var o=0;i;){if(i.nodeType===8){var f=i.data;if(f==="/$"||f==="/&"){if(o===0)return Ur(i.nextSibling);o--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||o++}i=i.nextSibling}return null}function bS(i){i=i.previousSibling;for(var o=0;i;){if(i.nodeType===8){var f=i.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(o===0)return i;o--}else f!=="/$"&&f!=="/&"||o++}i=i.previousSibling}return null}function vS(i,o,f){switch(o=Sd(f),i){case"html":if(i=o.documentElement,!i)throw Error(r(452));return i;case"head":if(i=o.head,!i)throw Error(r(453));return i;case"body":if(i=o.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function cc(i){for(var o=i.attributes;o.length;)i.removeAttributeNode(o[0]);to(i)}var Vr=new Map,_S=new Set;function wd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Qs=X.d;X.d={f:BL,r:$L,D:zL,C:HL,L:FL,m:UL,X:GL,S:VL,M:WL};function BL(){var i=Qs.f(),o=md();return i||o}function $L(i){var o=ro(i);o!==null&&o.tag===5&&o.type==="form"?B_(o):Qs.r(i)}var Mo=typeof document>"u"?null:document;function SS(i,o,f){var y=Mo;if(y&&typeof o=="string"&&o){var T=Mr(o);T='link[rel="'+i+'"][href="'+T+'"]',typeof f=="string"&&(T+='[crossorigin="'+f+'"]'),_S.has(T)||(_S.add(T),i={rel:i,crossOrigin:f,href:o},y.querySelector(T)===null&&(o=y.createElement("link"),qn(o,"link",i),$n(o),y.head.appendChild(o)))}}function zL(i){Qs.D(i),SS("dns-prefetch",i,null)}function HL(i,o){Qs.C(i,o),SS("preconnect",i,o)}function FL(i,o,f){Qs.L(i,o,f);var y=Mo;if(y&&i&&o){var T='link[rel="preload"][as="'+Mr(o)+'"]';o==="image"&&f&&f.imageSrcSet?(T+='[imagesrcset="'+Mr(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(T+='[imagesizes="'+Mr(f.imageSizes)+'"]')):T+='[href="'+Mr(i)+'"]';var L=T;switch(o){case"style":L=Po(i);break;case"script":L=Bo(i)}Vr.has(L)||(i=m({rel:"preload",href:o==="image"&&f&&f.imageSrcSet?void 0:i,as:o},f),Vr.set(L,i),y.querySelector(T)!==null||o==="style"&&y.querySelector(uc(L))||o==="script"&&y.querySelector(dc(L))||(o=y.createElement("link"),qn(o,"link",i),$n(o),y.head.appendChild(o)))}}function UL(i,o){Qs.m(i,o);var f=Mo;if(f&&i){var y=o&&typeof o.as=="string"?o.as:"script",T='link[rel="modulepreload"][as="'+Mr(y)+'"][href="'+Mr(i)+'"]',L=T;switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Bo(i)}if(!Vr.has(L)&&(i=m({rel:"modulepreload",href:i},o),Vr.set(L,i),f.querySelector(T)===null)){switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(dc(L)))return}y=f.createElement("link"),qn(y,"link",i),$n(y),f.head.appendChild(y)}}}function VL(i,o,f){Qs.S(i,o,f);var y=Mo;if(y&&i){var T=so(y).hoistableStyles,L=Po(i);o=o||"default";var K=T.get(L);if(!K){var ee={loading:0,preload:null};if(K=y.querySelector(uc(L)))ee.loading=5;else{i=m({rel:"stylesheet",href:i,"data-precedence":o},f),(f=Vr.get(L))&&Yp(i,f);var ce=K=y.createElement("link");$n(ce),qn(ce,"link",i),ce._p=new Promise(function(ve,De){ce.onload=ve,ce.onerror=De}),ce.addEventListener("load",function(){ee.loading|=1}),ce.addEventListener("error",function(){ee.loading|=2}),ee.loading|=4,Cd(K,o,y)}K={type:"stylesheet",instance:K,count:1,state:ee},T.set(L,K)}}}function GL(i,o){Qs.X(i,o);var f=Mo;if(f&&i){var y=so(f).hoistableScripts,T=Bo(i),L=y.get(T);L||(L=f.querySelector(dc(T)),L||(i=m({src:i,async:!0},o),(o=Vr.get(T))&&Xp(i,o),L=f.createElement("script"),$n(L),qn(L,"link",i),f.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},y.set(T,L))}}function WL(i,o){Qs.M(i,o);var f=Mo;if(f&&i){var y=so(f).hoistableScripts,T=Bo(i),L=y.get(T);L||(L=f.querySelector(dc(T)),L||(i=m({src:i,async:!0,type:"module"},o),(o=Vr.get(T))&&Xp(i,o),L=f.createElement("script"),$n(L),qn(L,"link",i),f.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},y.set(T,L))}}function wS(i,o,f,y){var T=(T=J.current)?wd(T):null;if(!T)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(o=Po(f.href),f=so(T).hoistableStyles,y=f.get(o),y||(y={type:"style",instance:null,count:0,state:null},f.set(o,y)),y):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){i=Po(f.href);var L=so(T).hoistableStyles,K=L.get(i);if(K||(T=T.ownerDocument||T,K={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(i,K),(L=T.querySelector(uc(i)))&&!L._p&&(K.instance=L,K.state.loading=5),Vr.has(i)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},Vr.set(i,f),L||qL(T,i,f,K.state))),o&&y===null)throw Error(r(528,""));return K}if(o&&y!==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=Bo(f),f=so(T).hoistableScripts,y=f.get(o),y||(y={type:"script",instance:null,count:0,state:null},f.set(o,y)),y):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function Po(i){return'href="'+Mr(i)+'"'}function uc(i){return'link[rel="stylesheet"]['+i+"]"}function CS(i){return m({},i,{"data-precedence":i.precedence,precedence:null})}function qL(i,o,f,y){i.querySelector('link[rel="preload"][as="style"]['+o+"]")?y.loading=1:(o=i.createElement("link"),y.preload=o,o.addEventListener("load",function(){return y.loading|=1}),o.addEventListener("error",function(){return y.loading|=2}),qn(o,"link",f),$n(o),i.head.appendChild(o))}function Bo(i){return'[src="'+Mr(i)+'"]'}function dc(i){return"script[async]"+i}function kS(i,o,f){if(o.count++,o.instance===null)switch(o.type){case"style":var y=i.querySelector('style[data-href~="'+Mr(f.href)+'"]');if(y)return o.instance=y,$n(y),y;var T=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return y=(i.ownerDocument||i).createElement("style"),$n(y),qn(y,"style",T),Cd(y,f.precedence,i),o.instance=y;case"stylesheet":T=Po(f.href);var L=i.querySelector(uc(T));if(L)return o.state.loading|=4,o.instance=L,$n(L),L;y=CS(f),(T=Vr.get(T))&&Yp(y,T),L=(i.ownerDocument||i).createElement("link"),$n(L);var K=L;return K._p=new Promise(function(ee,ce){K.onload=ee,K.onerror=ce}),qn(L,"link",y),o.state.loading|=4,Cd(L,f.precedence,i),o.instance=L;case"script":return L=Bo(f.src),(T=i.querySelector(dc(L)))?(o.instance=T,$n(T),T):(y=f,(T=Vr.get(L))&&(y=m({},f),Xp(y,T)),i=i.ownerDocument||i,T=i.createElement("script"),$n(T),qn(T,"link",y),i.head.appendChild(T),o.instance=T);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(y=o.instance,o.state.loading|=4,Cd(y,f.precedence,i));return o.instance}function Cd(i,o,f){for(var y=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),T=y.length?y[y.length-1]:null,L=T,K=0;K<y.length;K++){var ee=y[K];if(ee.dataset.precedence===o)L=ee;else if(L!==T)break}L?L.parentNode.insertBefore(i,L.nextSibling):(o=f.nodeType===9?f.head:f,o.insertBefore(i,o.firstChild))}function Yp(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.title==null&&(i.title=o.title)}function Xp(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.integrity==null&&(i.integrity=o.integrity)}var kd=null;function jS(i,o,f){if(kd===null){var y=new Map,T=kd=new Map;T.set(f,y)}else T=kd,y=T.get(f),y||(y=new Map,T.set(f,y));if(y.has(i))return y;for(y.set(i,null),f=f.getElementsByTagName(i),T=0;T<f.length;T++){var L=f[T];if(!(L[Cn]||L[$e]||i==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var K=L.getAttribute(o)||"";K=i+K;var ee=y.get(K);ee?ee.push(L):y.set(K,[L])}}return y}function ES(i,o,f){i=i.ownerDocument||i,i.head.insertBefore(f,o==="title"?i.querySelector("head > title"):null)}function KL(i,o,f){if(f===1||o.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return i=o.disabled,typeof o.precedence=="string"&&i==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function NS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function YL(i,o,f,y){if(f.type==="stylesheet"&&(typeof y.media!="string"||matchMedia(y.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var T=Po(y.href),L=o.querySelector(uc(T));if(L){o=L._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(i.count++,i=jd.bind(i),o.then(i,i)),f.state.loading|=4,f.instance=L,$n(L);return}L=o.ownerDocument||o,y=CS(y),(T=Vr.get(T))&&Yp(y,T),L=L.createElement("link"),$n(L);var K=L;K._p=new Promise(function(ee,ce){K.onload=ee,K.onerror=ce}),qn(L,"link",y),f.instance=L}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(f,o),(o=f.state.preload)&&(f.state.loading&3)===0&&(i.count++,f=jd.bind(i),o.addEventListener("load",f),o.addEventListener("error",f))}}var Jp=0;function XL(i,o){return i.stylesheets&&i.count===0&&Nd(i,i.stylesheets),0<i.count||0<i.imgCount?function(f){var y=setTimeout(function(){if(i.stylesheets&&Nd(i,i.stylesheets),i.unsuspend){var L=i.unsuspend;i.unsuspend=null,L()}},6e4+o);0<i.imgBytes&&Jp===0&&(Jp=62500*AL());var T=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Nd(i,i.stylesheets),i.unsuspend)){var L=i.unsuspend;i.unsuspend=null,L()}},(i.imgBytes>Jp?50:800)+o);return i.unsuspend=f,function(){i.unsuspend=null,clearTimeout(y),clearTimeout(T)}}:null}function jd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ed=null;function Nd(i,o){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ed=new Map,o.forEach(JL,i),Ed=null,jd.call(i))}function JL(i,o){if(!(o.state.loading&4)){var f=Ed.get(i);if(f)var y=f.get(null);else{f=new Map,Ed.set(i,f);for(var T=i.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<T.length;L++){var K=T[L];(K.nodeName==="LINK"||K.getAttribute("media")!=="not all")&&(f.set(K.dataset.precedence,K),y=K)}y&&f.set(null,y)}T=o.instance,K=T.getAttribute("data-precedence"),L=f.get(K)||y,L===y&&f.set(null,T),f.set(K,T),this.count++,y=jd.bind(this),T.addEventListener("load",y),T.addEventListener("error",y),L?L.parentNode.insertBefore(T,L.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(T,i.firstChild)),o.state.loading|=4}}var hc={$$typeof:b,Provider:null,Consumer:null,_currentValue:Y,_currentValue2:Y,_threadCount:0};function QL(i,o,f,y,T,L,K,ee,ce){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=nr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=nr(0),this.hiddenUpdates=nr(null),this.identifierPrefix=y,this.onUncaughtError=T,this.onCaughtError=L,this.onRecoverableError=K,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ce,this.incompleteTransitions=new Map}function TS(i,o,f,y,T,L,K,ee,ce,ve,De,ze){return i=new QL(i,o,f,K,ce,ve,De,ze,ee),o=1,L===!0&&(o|=24),L=Sr(3,null,null,o),i.current=L,L.stateNode=i,o=Am(),o.refCount++,i.pooledCache=o,o.refCount++,L.memoizedState={element:y,isDehydrated:f,cache:o},Om(L),i}function AS(i){return i?(i=po,i):po}function LS(i,o,f,y,T,L){T=AS(T),y.context===null?y.context=T:y.pendingContext=T,y=Si(o),y.payload={element:f},L=L===void 0?null:L,L!==null&&(y.callback=L),f=wi(i,y,o),f!==null&&(fr(f,i,o),Vl(f,i,o))}function DS(i,o){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var f=i.retryLane;i.retryLane=f!==0&&f<o?f:o}}function Qp(i,o){DS(i,o),(i=i.alternate)&&DS(i,o)}function RS(i){if(i.tag===13||i.tag===31){var o=la(i,67108864);o!==null&&fr(o,i,67108864),Qp(i,67108864)}}function OS(i){if(i.tag===13||i.tag===31){var o=Er();o=Ze(o);var f=la(i,o);f!==null&&fr(f,i,o),Qp(i,o)}}var Td=!0;function ZL(i,o,f,y){var T=q.T;q.T=null;var L=X.p;try{X.p=2,Zp(i,o,f,y)}finally{X.p=L,q.T=T}}function eD(i,o,f,y){var T=q.T;q.T=null;var L=X.p;try{X.p=8,Zp(i,o,f,y)}finally{X.p=L,q.T=T}}function Zp(i,o,f,y){if(Td){var T=eg(y);if(T===null)$p(i,o,y,Ad,f),MS(i,y);else if(nD(T,i,o,f,y))y.stopPropagation();else if(MS(i,y),o&4&&-1<tD.indexOf(i)){for(;T!==null;){var L=ro(T);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var K=Sn(L.pendingLanes);if(K!==0){var ee=L;for(ee.pendingLanes|=2,ee.entangledLanes|=2;K;){var ce=1<<31-Ve(K);ee.entanglements[1]|=ce,K&=~ce}bs(L),(Pt&6)===0&&(hd=Fe()+500,ac(0))}}break;case 31:case 13:ee=la(L,2),ee!==null&&fr(ee,L,2),md(),Qp(L,2)}if(L=eg(y),L===null&&$p(i,o,y,Ad,f),L===T)break;T=L}T!==null&&y.stopPropagation()}else $p(i,o,y,null,f)}}function eg(i){return i=nm(i),tg(i)}var Ad=null;function tg(i){if(Ad=null,i=no(i),i!==null){var o=l(i);if(o===null)i=null;else{var f=o.tag;if(f===13){if(i=c(o),i!==null)return i;i=null}else if(f===31){if(i=u(o),i!==null)return i;i=null}else if(f===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;i=null}else o!==i&&(i=null)}}return Ad=i,null}function IS(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(He()){case ie:return 2;case Se:return 8;case Le:case he:return 32;case me:return 268435456;default:return 32}default:return 32}}var ng=!1,Oi=null,Ii=null,Mi=null,fc=new Map,mc=new Map,Pi=[],tD="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 MS(i,o){switch(i){case"focusin":case"focusout":Oi=null;break;case"dragenter":case"dragleave":Ii=null;break;case"mouseover":case"mouseout":Mi=null;break;case"pointerover":case"pointerout":fc.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":mc.delete(o.pointerId)}}function pc(i,o,f,y,T,L){return i===null||i.nativeEvent!==L?(i={blockedOn:o,domEventName:f,eventSystemFlags:y,nativeEvent:L,targetContainers:[T]},o!==null&&(o=ro(o),o!==null&&RS(o)),i):(i.eventSystemFlags|=y,o=i.targetContainers,T!==null&&o.indexOf(T)===-1&&o.push(T),i)}function nD(i,o,f,y,T){switch(o){case"focusin":return Oi=pc(Oi,i,o,f,y,T),!0;case"dragenter":return Ii=pc(Ii,i,o,f,y,T),!0;case"mouseover":return Mi=pc(Mi,i,o,f,y,T),!0;case"pointerover":var L=T.pointerId;return fc.set(L,pc(fc.get(L)||null,i,o,f,y,T)),!0;case"gotpointercapture":return L=T.pointerId,mc.set(L,pc(mc.get(L)||null,i,o,f,y,T)),!0}return!1}function PS(i){var o=no(i.target);if(o!==null){var f=l(o);if(f!==null){if(o=f.tag,o===13){if(o=c(f),o!==null){i.blockedOn=o,Ne(i.priority,function(){OS(f)});return}}else if(o===31){if(o=u(f),o!==null){i.blockedOn=o,Ne(i.priority,function(){OS(f)});return}}else if(o===3&&f.stateNode.current.memoizedState.isDehydrated){i.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Ld(i){if(i.blockedOn!==null)return!1;for(var o=i.targetContainers;0<o.length;){var f=eg(i.nativeEvent);if(f===null){f=i.nativeEvent;var y=new f.constructor(f.type,f);tm=y,f.target.dispatchEvent(y),tm=null}else return o=ro(f),o!==null&&RS(o),i.blockedOn=f,!1;o.shift()}return!0}function BS(i,o,f){Ld(i)&&f.delete(o)}function rD(){ng=!1,Oi!==null&&Ld(Oi)&&(Oi=null),Ii!==null&&Ld(Ii)&&(Ii=null),Mi!==null&&Ld(Mi)&&(Mi=null),fc.forEach(BS),mc.forEach(BS)}function Dd(i,o){i.blockedOn===o&&(i.blockedOn=null,ng||(ng=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,rD)))}var Rd=null;function $S(i){Rd!==i&&(Rd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Rd===i&&(Rd=null);for(var o=0;o<i.length;o+=3){var f=i[o],y=i[o+1],T=i[o+2];if(typeof y!="function"){if(tg(y||f)===null)continue;break}var L=ro(f);L!==null&&(i.splice(o,3),o-=3,ep(L,{pending:!0,data:T,method:f.method,action:y},y,T))}}))}function $o(i){function o(ce){return Dd(ce,i)}Oi!==null&&Dd(Oi,i),Ii!==null&&Dd(Ii,i),Mi!==null&&Dd(Mi,i),fc.forEach(o),mc.forEach(o);for(var f=0;f<Pi.length;f++){var y=Pi[f];y.blockedOn===i&&(y.blockedOn=null)}for(;0<Pi.length&&(f=Pi[0],f.blockedOn===null);)PS(f),f.blockedOn===null&&Pi.shift();if(f=(i.ownerDocument||i).$$reactFormReplay,f!=null)for(y=0;y<f.length;y+=3){var T=f[y],L=f[y+1],K=T[Xe]||null;if(typeof L=="function")K||$S(f);else if(K){var ee=null;if(L&&L.hasAttribute("formAction")){if(T=L,K=L[Xe]||null)ee=K.formAction;else if(tg(T)!==null)continue}else ee=K.action;typeof ee=="function"?f[y+1]=ee:(f.splice(y,3),y-=3),$S(f)}}}function zS(){function i(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(K){return T=K})},focusReset:"manual",scroll:"manual"})}function o(){T!==null&&(T(),T=null),y||setTimeout(f,20)}function f(){if(!y&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var y=!1,T=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(f,100),function(){y=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),T!==null&&(T(),T=null)}}}function rg(i){this._internalRoot=i}Od.prototype.render=rg.prototype.render=function(i){var o=this._internalRoot;if(o===null)throw Error(r(409));var f=o.current,y=Er();LS(f,y,i,o,null,null)},Od.prototype.unmount=rg.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var o=i.containerInfo;LS(i.current,2,null,i,null,null),md(),o[tt]=null}};function Od(i){this._internalRoot=i}Od.prototype.unstable_scheduleHydration=function(i){if(i){var o=rn();i={blockedOn:null,target:i,priority:o};for(var f=0;f<Pi.length&&o!==0&&o<Pi[f].priority;f++);Pi.splice(f,0,i),f===0&&PS(i)}};var HS=t.version;if(HS!=="19.2.8")throw Error(r(527,HS,"19.2.8"));X.findDOMNode=function(i){var o=i._reactInternals;if(o===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=h(o),i=i!==null?p(i):null,i=i===null?null:i.stateNode,i};var sD={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Id=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Id.isDisabled&&Id.supportsFiber)try{Qe=Id.inject(sD),it=Id}catch{}}return xc.createRoot=function(i,o){if(!a(i))throw Error(r(299));var f=!1,y="",T=K_,L=Y_,K=X_;return o!=null&&(o.unstable_strictMode===!0&&(f=!0),o.identifierPrefix!==void 0&&(y=o.identifierPrefix),o.onUncaughtError!==void 0&&(T=o.onUncaughtError),o.onCaughtError!==void 0&&(L=o.onCaughtError),o.onRecoverableError!==void 0&&(K=o.onRecoverableError)),o=TS(i,1,!1,null,null,f,y,null,T,L,K,zS),i[tt]=o.current,Bp(i),new rg(o)},xc.hydrateRoot=function(i,o,f){if(!a(i))throw Error(r(299));var y=!1,T="",L=K_,K=Y_,ee=X_,ce=null;return f!=null&&(f.unstable_strictMode===!0&&(y=!0),f.identifierPrefix!==void 0&&(T=f.identifierPrefix),f.onUncaughtError!==void 0&&(L=f.onUncaughtError),f.onCaughtError!==void 0&&(K=f.onCaughtError),f.onRecoverableError!==void 0&&(ee=f.onRecoverableError),f.formState!==void 0&&(ce=f.formState)),o=TS(i,1,!0,o,f??null,y,T,ce,L,K,ee,zS),o.context=AS(null),f=o.current,y=Er(),y=Ze(y),T=Si(y),T.callback=null,wi(f,T,y),f=y,o.current.lanes=f,we(o,f),bs(o),i[tt]=o.current,Bp(i),new Od(o)},xc.version="19.2.8",xc}var ZS;function bD(){if(ZS)return lg.exports;ZS=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(),lg.exports=yD(),lg.exports}var vD=bD();const _D=af(vD);function SD(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,l,c=[],u="",d=e.split("/");for(d[0]||d.shift();a=d.shift();)n=a[0],n==="*"?(c.push(n),u+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=a.indexOf("?",1),l=a.indexOf(".",1),c.push(a.substring(1,~r?r:~l?l:a.length)),u+=~r&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(u+=(~r?"?":"")+"\\"+a.substring(l))):u+="/"+a;return{keys:c,pattern:new RegExp("^"+u+(t?"(?=$|/)":"/?$"),"i")}}var hg={exports:{}},fg={};/**
51
+ * @license React
52
+ * use-sync-external-store-shim.production.js
53
+ *
54
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
55
+ *
56
+ * This source code is licensed under the MIT license found in the
57
+ * LICENSE file in the root directory of this source tree.
58
+ */var ew;function wD(){if(ew)return fg;ew=1;var e=of();function t(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function u(m,g){var x=g(),w=r({inst:{value:x,getSnapshot:g}}),C=w[0].inst,_=w[1];return l(function(){C.value=x,C.getSnapshot=g,d(C)&&_({inst:C})},[m,x,g]),a(function(){return d(C)&&_({inst:C}),m(function(){d(C)&&_({inst:C})})},[m]),c(x),x}function d(m){var g=m.getSnapshot;m=m.value;try{var x=g();return!n(m,x)}catch{return!0}}function h(m,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return fg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,fg}var tw;function CD(){return tw||(tw=1,hg.exports=wD()),hg.exports}var kD=CD();const jD=mD.useInsertionEffect,ED=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ND=ED?j.useLayoutEffect:j.useEffect,TD=jD||ND,Ek=e=>{const t=j.useRef([e,(...n)=>t[0](...n)]).current;return TD(()=>{t[0]=e}),t[1]},AD="popstate",_y="pushState",Sy="replaceState",LD="hashchange",nw=[AD,_y,Sy,LD],DD=e=>{for(const t of nw)addEventListener(t,e);return()=>{for(const t of nw)removeEventListener(t,e)}},Nk=(e,t)=>kD.useSyncExternalStore(DD,e,t),rw=()=>location.search,RD=({ssrSearch:e}={})=>Nk(rw,e!=null?()=>e:rw),sw=()=>location.pathname,OD=({ssrPath:e}={})=>Nk(sw,e!=null?()=>e:sw),ID=(e,{replace:t=!1,state:n=null}={})=>history[t?Sy:_y](n,"",e),MD=(e={})=>[OD(e),ID],iw=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[iw]>"u"){for(const e of[_y,Sy]){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,iw,{value:!0})}const PD=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",Tk=(e="")=>e==="/"?"":e,BD=(e,t)=>e[0]==="~"?e.slice(1):Tk(t)+e,$D=(e="",t)=>PD(aw(Tk(e)),aw(t)),aw=e=>{try{return decodeURI(e)}catch{return e}},Ak={hook:MD,searchHook:RD,parser:SD,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},Lk=j.createContext(Ak),gl=()=>j.useContext(Lk),Dk={},Rk=j.createContext(Dk),zD=()=>j.useContext(Rk),lf=e=>{const[t,n]=e.hook(e);return[$D(e.base,t),Ek((r,a)=>e.aroundNav(n,BD(r,e.base),a))]},Ln=()=>lf(gl()),wy=(e,t,n,r)=>{const{pattern:a,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),c=a.exec(n)||[],[u,...d]=c;return u!==void 0?[!0,(()=>{const h=l!==!1?Object.fromEntries(l.map((m,g)=>[m,d[g]])):c.groups;let p={...d};return h&&Object.assign(p,h),p})(),...r?[u]:[]]:[!1,null]},xl=e=>wy(gl().parser,e,Ln()[0]),Ok=({children:e,...t})=>{var p,m,g;const n=gl(),r=t.hook?Ak:n;let a=r;const[l,c=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];l&&(t.ssrSearch=c,t.ssrPath=l),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((g=t.hook)==null?void 0:g.searchHook);let u=j.useRef({}),d=u.current,h=d;for(let x in r){const w=x==="base"?r[x]+(t[x]??""):t[x]??r[x];d===h&&w!==h[x]&&(u.current=h={...h}),h[x]=w,(w!==r[x]||w!==a[x])&&(a=h)}return j.createElement(Lk.Provider,{value:a,children:e})},ow=({children:e,component:t},n)=>t?j.createElement(t,{params:n}):typeof e=="function"?e(n):e,HD=e=>{let t=j.useRef(Dk);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},yc=({path:e,nest:t,match:n,...r})=>{const a=gl(),[l]=lf(a),[c,u,d]=n??wy(a.parser,e,l,t),h=HD({...zD(),...u});if(!c)return null;const p=d?j.createElement(Ok,{base:d},ow(r,h)):ow(r,h);return j.createElement(Rk.Provider,{value:h,children:p})},yr=j.forwardRef((e,t)=>{const n=gl(),[r,a]=lf(n),{to:l="",href:c=l,onClick:u,asChild:d,children:h,className:p,replace:m,state:g,transition:x,...w}=e,C=Ek(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(u==null||u(S),S.defaultPrevented||(S.preventDefault(),a(c,e)))}),_=n.hrefs(c[0]==="~"?c.slice(1):n.base+c,n);return d&&j.isValidElement(h)?j.cloneElement(h,{onClick:C,href:_}):j.createElement("a",{...w,onClick:C,href:_,className:p!=null&&p.call?p(r===c):p,children:h,ref:t})}),Ik=e=>Array.isArray(e)?e.flatMap(t=>Ik(t&&t.type===j.Fragment?t.props.children:t)):[e],FD=({children:e,location:t})=>{const n=gl(),[r]=lf(n);for(const a of Ik(e)){let l=0;if(j.isValidElement(a)&&(l=wy(n.parser,a.props.path,t||r,a.props.nest))[0])return j.cloneElement(a,{match:l})}return null};/*!
59
+ * OverlayScrollbars
60
+ * Version: 2.16.0
61
+ *
62
+ * Copyright (c) Rene Haas | KingSora.
63
+ * https://github.com/KingSora
64
+ *
65
+ * Released under the MIT license.
66
+ */const Ar=(e,t)=>{const{o:n,i:r,u:a}=e;let l=n,c;const u=(p,m)=>{const g=l,x=p,w=m||(r?!r(g,x):g!==x);return(w||a)&&(l=x,c=g),[l,w,c]};return[t?p=>u(t(l,c),p):u,p=>[l,!!p,c]]},UD=typeof window<"u"&&typeof HTMLElement<"u"&&!!window.document,xr=UD?window:{},Mk=Math.max,VD=Math.min,_x=Math.round,Gi=Math.abs,lw=Math.sign,Pk=xr.cancelAnimationFrame,Cy=xr.requestAnimationFrame,ky=xr.setTimeout,Bk=xr.clearTimeout,cf=e=>typeof xr[e]<"u"?xr[e]:void 0,GD=cf("MutationObserver"),cw=cf("IntersectionObserver"),Jo=cf("ResizeObserver"),Ic=cf("ScrollTimeline"),jy=e=>e===void 0,uf=e=>e===null,Ki=e=>typeof e=="number",yl=e=>typeof e=="string",df=e=>typeof e=="boolean",ps=e=>typeof e=="function",Zr=e=>Array.isArray(e),Ch=e=>typeof e=="object"&&!Zr(e)&&!uf(e),Ey=e=>{const t=!!e&&e.length,n=Ki(t)&&t>-1&&t%1==0;return Zr(e)||!ps(e)&&n?t>0&&Ch(e)?t-1 in e:!0:!1},Kc=e=>!!e&&e.constructor===Object,kh=e=>e instanceof HTMLElement,hf=e=>e instanceof Element;function Xt(e,t){if(Ey(e))for(let n=0;n<e.length&&t(e[n],n,e)!==!1;n++);else e&&Xt(Object.keys(e),(n=>t(e[n],n,e)));return e}const $k=(e,t)=>e.indexOf(t)>=0,ll=(e,t)=>e.concat(t),dn=(e,t,n)=>(!yl(t)&&Ey(t)?Array.prototype.push.apply(e,t):e.push(t),e),Zi=e=>Array.from(e||[]),Ny=e=>Zr(e)?e:!yl(e)&&Ey(e)?Zi(e):[e],jh=e=>!!e&&!e.length,Eh=e=>Zi(new Set(e)),Dr=(e,t,n)=>{Xt(e,a=>a?a.apply(void 0,t||[]):!0),n||(e.length=0)},zk="paddingTop",Hk="paddingRight",Fk="paddingLeft",Uk="paddingBottom",Vk="marginLeft",Gk="marginRight",Wk="marginBottom",Ty="overflowX",Ay="overflowY",ff="width",mf="height",ai="visible",as="hidden",Ha="scroll",WD=e=>{const t=String(e||"");return t?t[0].toUpperCase()+t.slice(1):""},pf=(e,t,n,r)=>{if(e&&t){let a=!0;return Xt(n,(l=>{const c=e[l],u=t[l];c!==u&&(a=!1)})),a}return!1},qk=(e,t)=>pf(e,t,["w","h"]),fh=(e,t)=>pf(e,t,["x","y"]),qD=(e,t)=>pf(e,t,["t","r","b","l"]),ft=(e,...t)=>e.bind(0,...t),Qo=e=>{let t;const n=e?ky:Cy,r=e?Bk:Pk;return[a=>{r(t),t=n((()=>a()),ps(e)?e():e)},()=>r(t)]},uw=e=>{const t=ps(e)?e():e;if(Ki(t)){const n=t?ky:Cy,r=t?Bk:Pk;return a=>{const l=n((()=>a()),t);return()=>{r(l)}}}return t&&t._},Kk=(e,t)=>{const{p:n,v:r,S:a,m:l}=t||{};let c,u,d,h;const p=function(C){u&&u(),c&&c(),h=u=c=d=void 0,e.apply(this,C)},m=w=>l&&d?l(d,w):w,g=()=>{u&&d&&p(m(d)||d)},x=function(){const C=Zi(arguments),_=uw(n);if(_){const S=typeof a=="function"?a():a,v=uw(r),k=m(C)||C,N=p.bind(0,k);u&&u(),S&&!h?(N(),h=!0,u=_((()=>h=void 0))):(u=_(N),v&&!c&&(c=v(g))),d=k}else p(C)};return x.O=g,x},Yk=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),pr=e=>e?Object.keys(e):[],Mt=(e,t,n,r,a,l,c)=>{const u=[t,n,r,a,l,c];return(typeof e!="object"||uf(e))&&!ps(e)&&(e={}),Xt(u,(d=>{Xt(d,((h,p)=>{const m=d[p];if(e===m)return!0;const g=Zr(m);if(m&&Kc(m)){const x=e[p];let w=x;g&&!Zr(x)?w=[]:!g&&!Kc(x)&&(w={}),e[p]=Mt(w,m)}else e[p]=g?m.slice():m}))})),e},Xk=(e,t)=>Xt(Mt({},e),((n,r,a)=>{n===void 0?delete a[r]:n&&Kc(n)&&(a[r]=Xk(n))})),Ly=e=>!pr(e).length,Yc=()=>{},Jk=(e,t,n)=>Mk(e,VD(t,n)),Fa=e=>Eh((Zr(e)?e:(e||"").split(" ")).filter((t=>t))),Dy=(e,t)=>e&&e.getAttribute(t),dw=(e,t)=>e&&e.hasAttribute(t),ri=(e,t,n)=>{Xt(Fa(t),(r=>{e&&e.setAttribute(r,String(n||""))}))},Ss=(e,t)=>{Xt(Fa(t),(n=>e&&e.removeAttribute(n)))},gf=(e,t)=>{const n=Fa(Dy(e,t)),r=ft(ri,e,t),a=(l,c)=>{const u=new Set(n);return Xt(Fa(l),(d=>{u[c](d)})),Zi(u).join(" ")};return{C:l=>r(a(l,"delete")),$:l=>r(a(l,"add")),H:l=>{const c=Fa(l);return c.reduce(((u,d)=>u&&n.includes(d)),c.length>0)}}},Qk=(e,t,n)=>(gf(e,t).C(n),ft(Ry,e,t,n)),Ry=(e,t,n)=>(gf(e,t).$(n),ft(Qk,e,t,n)),Nh=(e,t,n,r)=>(r?Ry:Qk)(e,t,n),Oy=(e,t,n)=>gf(e,t).H(n),Zk=e=>gf(e,"class"),ej=(e,t)=>{Zk(e).C(t)},Iy=(e,t)=>(Zk(e).$(t),ft(ej,e,t)),tj=(e,t)=>{const n=t?hf(t)&&t:document;return n?Zi(n.querySelectorAll(e)):[]},KD=(e,t)=>{const n=t?hf(t)&&t:document;return n&&n.querySelector(e)},Sx=(e,t)=>hf(e)&&e.matches(t),nj=e=>Sx(e,"body"),wx=e=>e?Zi(e.childNodes):[],Xc=e=>e&&e.parentElement,Zo=(e,t)=>hf(e)&&e.closest(t),Cx=e=>document.activeElement,YD=(e,t,n)=>{const r=Zo(e,t),a=e&&KD(n,r),l=Zo(a,t)===r;return r&&a?r===e||a===e||l&&Zo(Zo(e,n),t)!==r:!1},cl=e=>{Xt(Ny(e),(t=>{const n=Xc(t);t&&n&&n.removeChild(t)}))},gr=(e,t)=>ft(cl,e&&t&&Xt(Ny(t),(n=>{n&&e.appendChild(n)})));let rj;const XD=()=>rj,JD=e=>{rj=e},nl=e=>{const t=document.createElement("div");return ri(t,"class",e),t},sj=e=>{const t=nl(),n=XD(),r=e.trim();return t.innerHTML=n?n.createHTML(r):r,Xt(wx(t),(a=>cl(a)))},hw=(e,t)=>e.getPropertyValue(t)||e[t]||"",ij=e=>{const t=e||0;return isFinite(t)?t:0},Md=e=>ij(parseFloat(e||"")),kx=e=>Math.round(e*1e4)/1e4,aj=e=>`${kx(ij(e))}px`;function Jc(e,t){e&&t&&Xt(t,((n,r)=>{try{const a=e.style,l=uf(n)||df(n)?"":Ki(n)?aj(n):n;r.indexOf("--")===0?a.setProperty(r,l):a[r]=l}catch{}}))}function As(e,t,n){const r=yl(t);let a=r?"":{};if(e){const l=xr.getComputedStyle(e,n)||e.style;a=r?hw(l,t):Zi(t).reduce(((c,u)=>(c[u]=hw(l,u),c)),a)}return a}const fw=(e,t,n)=>{const r=t?`${t}-`:"",a=n?`-${n}`:"",l=`${r}top${a}`,c=`${r}right${a}`,u=`${r}bottom${a}`,d=`${r}left${a}`,h=As(e,[l,c,u,d]);return{t:Md(h[l]),r:Md(h[c]),b:Md(h[u]),l:Md(h[d])}},mg=(e,t)=>`translate${Ch(e)?`(${e.x},${e.y})`:`${t?"X":"Y"}(${e})`}`,QD=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length),ZD={w:0,h:0},xf=(e,t)=>t?{w:t[`${e}Width`],h:t[`${e}Height`]}:ZD,eR=e=>xf("inner",e||xr),rl=ft(xf,"offset"),oj=ft(xf,"client"),Th=ft(xf,"scroll"),My=e=>{const t=parseFloat(As(e,ff))||0,n=parseFloat(As(e,mf))||0;return{w:t-_x(t),h:n-_x(n)}},pg=e=>e.getBoundingClientRect(),tR=e=>!!e&&QD(e),jx=e=>!!(e&&(e[mf]||e[ff])),lj=(e,t)=>{const n=jx(e);return!jx(t)&&n},mw=(e,t,n,r)=>{Xt(Fa(t),(a=>{e&&e.removeEventListener(a,n,r)}))},on=(e,t,n,r)=>{var a;const l=(a=r&&r.D)!=null?a:!0,c=r&&r.I||!1,u=r&&r.A||!1,d={passive:l,capture:c};return ft(Dr,Fa(t).map((h=>{const p=u?m=>{mw(e,h,p,c),n&&n(m)}:n;return e&&e.addEventListener(h,p,d),ft(mw,e,h,p,c)})))},cj=e=>e.stopPropagation(),Ex=e=>e.preventDefault(),uj=e=>cj(e)||Ex(e),Es=(e,t)=>{const{x:n,y:r}=Ki(t)?{x:t,y:t}:t||{};Ki(n)&&(e.scrollLeft=n),Ki(r)&&(e.scrollTop=r)},Lr=e=>({x:e.scrollLeft,y:e.scrollTop}),dj=()=>({T:{x:0,y:0},k:{x:0,y:0}}),nR=(e,t)=>{const{T:n,k:r}=e,{w:a,h:l}=t,c=(m,g,x)=>{let w=lw(m)*x,C=lw(g)*x;if(w===C){const _=Gi(m),S=Gi(g);C=_>S?0:C,w=_<S?0:w}return w=w===C?0:w,[w+0,C+0]},[u,d]=c(n.x,r.x,a),[h,p]=c(n.y,r.y,l);return{T:{x:u,y:h},k:{x:d,y:p}}},gg=({T:e,k:t})=>{const n=(r,a)=>r===0&&r<=a;return{x:n(e.x,t.x),y:n(e.y,t.y)}},pw=({T:e,k:t},n)=>{const r=(a,l,c)=>Jk(0,1,(a-c)/(a-l)||0);return{x:r(e.x,t.x,n.x),y:r(e.y,t.y,n.y)}},Nx=e=>{e&&e.focus&&e.focus({preventScroll:!0,focusVisible:!1})},gw=(e,t)=>{Xt(Ny(t),e)},Tx=e=>{const t=new Map,n=(l,c)=>{if(l){const u=t.get(l);gw((d=>{u&&u[d?"delete":"clear"](d)}),c)}else t.forEach((u=>{u.clear()})),t.clear()},r=(l,c)=>{if(yl(l)){const h=t.get(l)||new Set;return t.set(l,h),gw((p=>{ps(p)&&h.add(p)}),c),ft(n,l,c)}df(c)&&c&&n();const u=pr(l),d=[];return Xt(u,(h=>{const p=l[h];p&&dn(d,r(h,p))})),ft(Dr,d)},a=(l,c)=>{Xt(Zi(t.get(l)),(u=>{c&&!jh(c)?u.apply(0,c):u()}))};return r(e||{}),[r,n,a]},hj={},fj={},rR=e=>{Xt(e,(t=>Xt(t,((n,r)=>{hj[r]=t[r]}))))},mj=(e,t,n)=>pr(e).map((r=>{const{static:a,instance:l}=e[r],[c,u,d]=n||[],h=n?l:a;if(h){const p=n?h(c,u,t):h(t);return(d||fj)[r]=p}})),sR=(e,t)=>e[t],bl=e=>sR(fj,e),iR="__osOptionsValidationPlugin",vl="data-overlayscrollbars",mh="os-environment",Pd=`${mh}-scrollbar-hidden`,xg=`${vl}-initialize`,ph="noClipping",xw=`${vl}-body`,Yi=vl,aR="host",si=`${vl}-viewport`,oR=Ty,lR=Ay,cR="arrange",pj="measuring",uR="scrolling",gj="scrollbarHidden",dR="noContent",Ax=`${vl}-padding`,yw=`${vl}-content`,Py="os-size-observer",hR=`${Py}-appear`,fR=`${Py}-listener`,mR="os-trinsic-observer",pR="os-theme-none",Or="os-scrollbar",gR=`${Or}-rtl`,xR=`${Or}-horizontal`,yR=`${Or}-vertical`,xj=`${Or}-track`,By=`${Or}-handle`,bR=`${Or}-visible`,vR=`${Or}-cornerless`,bw=`${Or}-interaction`,vw=`${Or}-unusable`,Lx=`${Or}-auto-hide`,_R=`${Lx}-hidden`,_w=`${Or}-wheel`,SR=`${xj}-interactive`,wR=`${By}-interactive`,CR="__osSizeObserverPlugin",kR=(e,t)=>{const{M:n}=t,[r,a]=e("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,a]},el=e=>e.indexOf(ai)===0,jR=e=>e.replace(`${ai}-`,""),Dx=(e,t)=>{if(e==="auto")return t?Ha:as;const n=e||as;return[as,Ha,ai].includes(n)?n:as},ER=(e,t)=>{const{overflowX:n,overflowY:r}=As(e,[Ty,Ay]);return{x:Dx(n,t.x),y:Dx(r,t.y)}},$y="__osScrollbarsHidingPlugin",NR="__osClickScrollPlugin",Sw=e=>JSON.stringify(e,((t,n)=>{if(ps(n))throw 0;return n})),ww=(e,t)=>e?`${t}`.split(".").reduce(((n,r)=>n&&Yk(n,r)?n[r]:void 0),e):void 0,TR=[0,33],yj=[33,99],bj=[222,666,!0],AR={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:{mutation:TR,resize:null,event:yj,env:bj},attributes:null,ignoreMutation:null,flowDirectionStyles:null},overflow:{x:"scroll",y:"scroll"},scrollbars:{theme:"os-theme-dark",visibility:"auto",autoHide:"never",autoHideDelay:1300,autoHideSuspend:!1,dragScroll:!0,clickScroll:!1,pointers:["mouse","touch","pen"]}},vj=(e,t)=>{const n={},r=ll(pr(t),pr(e));return Xt(r,(a=>{const l=e[a],c=t[a];if(Ch(l)&&Ch(c))Mt(n[a]={},vj(l,c)),Ly(n[a])&&delete n[a];else if(Yk(t,a)&&c!==l){let u=!0;if(Zr(l)||Zr(c))try{Sw(l)===Sw(c)&&(u=!1)}catch{}u&&(n[a]=c)}})),n},yg=(e,t,n)=>r=>[ww(e,r),n||ww(t,r)!==void 0];let _j;const LR=()=>_j,DR=e=>{_j=e};let bg;const RR=()=>{const e=(k,N,E)=>{gr(document.body,k),gr(document.body,k);const D=oj(k),A=rl(k),O=My(N);return E&&cl(k),{x:A.h-D.h+O.h,y:A.w-D.w+O.w}},t=k=>{let N=!1;const E=Iy(k,Pd);try{N=As(k,"scrollbar-width")==="none"||As(k,"display","::-webkit-scrollbar")==="none"}catch{}return E(),N},n=`.${mh}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${mh} div{width:200%;height:200%;margin:10px 0}.${Pd}{scrollbar-width:none!important}.${Pd}::-webkit-scrollbar,.${Pd}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`,a=sj(`<div class="${mh}"><div></div><style>${n}</style></div>`)[0],l=a.firstChild,c=a.lastChild,u=LR();u&&(c.nonce=u);const[d,,h]=Tx(),[p,m]=Ar({o:e(a,l),i:fh},ft(e,a,l,!0)),[g]=m(),x=t(a),w={x:g.x===0,y:g.y===0},C={elements:{host:null,padding:!x,viewport:k=>x&&nj(k)&&k,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},_=Mt({},AR),S=ft(Mt,{},_),v=ft(Mt,{},C),b={U:g,M:w,P:x,J:!!Ic,G:ft(d,"r"),K:v,Z:k=>Mt(C,k)&&v(),tt:S,nt:k=>Mt(_,k)&&S(),ot:Mt({},C),st:Mt({},_)};if(Ss(a,"style"),cl(a),on(xr,"resize",(()=>{h("r",[])})),ps(xr.matchMedia)&&!x&&(!w.x||!w.y)){const k=N=>{const E=xr.matchMedia(`(resolution: ${xr.devicePixelRatio}dppx)`);on(E,"change",(()=>{N(),k(N)}),{A:!0})};k((()=>{const[N,E]=p();Mt(b.U,N),h("r",[E])}))}return b},Ls=()=>(bg||(bg=RR()),bg),OR=(e,t,n)=>{let r=!1;const a=n?new WeakMap:!1,l=()=>{r=!0},c=u=>{if(a&&n){const d=n.map((h=>{const[p,m]=h||[];return[m&&p?(u||tj)(p,e):[],m]}));Xt(d,(h=>Xt(h[0],(p=>{const m=h[1],g=a.get(p)||[];if(e.contains(p)&&m){const w=on(p,m,(C=>{r?(w(),a.delete(p)):t(C)}));a.set(p,dn(g,w))}else Dr(g),a.delete(p)}))))}};return c(),[l,c]},Cw=(e,t,n,r)=>{let a=!1;const{et:l,ct:c,rt:u,it:d,lt:h,ut:p}=r||{},[m,g]=OR(e,(()=>a&&n(!0)),u),x=l||[],w=c||[],C=ll(x,w),_=(v,b)=>{if(!jh(b)){const k=h||Yc,N=p||Yc,E=[],D=[];let A=!1,O=!1;if(Xt(b,(P=>{const{attributeName:G,target:z,type:V,oldValue:$,addedNodes:H,removedNodes:q}=P,X=V==="attributes",Y=V==="childList",F=e===z,I=X&&G,R=I&&Dy(z,G||""),W=yl(R)?R:null,B=I&&$!==W,Z=$k(w,G)&&B;if(t&&(Y||!F)){const Q=X&&B,J=Q&&d&&Sx(z,d),M=(J?!k(z,G,$,W):!X||Q)&&!N(P,!!J,e,r);Xt(H,(te=>dn(E,te))),Xt(q,(te=>dn(E,te))),O=O||M}!t&&F&&B&&!k(z,G,$,W)&&(dn(D,G),A=A||Z)})),g((P=>Eh(E).reduce(((G,z)=>(dn(G,tj(P,z)),Sx(z,P)?dn(G,z):G)),[]))),t)return!v&&O&&n(!1),[!1];if(!jh(D)||A){const P=[Eh(D),A];return v||n.apply(0,P),P}}},S=new GD(ft(_,!1));return[()=>(S.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:C,subtree:t,childList:t,characterData:t}),a=!0,()=>{a&&(m(),S.disconnect(),a=!1)}),()=>{if(a)return _(!0,S.takeRecords())}]};let Sa=null;const Sj=(e,t,n)=>{const{ft:r}=n||{},a=bl(CR),[l]=Ar({o:!1,u:!0});return()=>{const c=[],d=sj(`<div class="${Py}"><div class="${fR}"></div></div>`)[0],h=d.firstChild,p=m=>{const g=Zr(m)&&!jh(m);let x=!1,w=!1;if(g){const C=m[0],[_,,S]=l(C.contentRect),v=jx(_);w=lj(_,S),x=!w&&!v}else w=m===!0;x||t({_t:!0,ft:w})};if(Jo){if(!df(Sa)){const w=new Jo(Yc);w.observe(e,{get box(){Sa=!0}}),Sa=Sa||!1,w.disconnect()}const m=Kk(p,{p:0,v:0}),g=w=>m(w),x=new Jo(g);if(x.observe(Sa?e:h),dn(c,[()=>{x.disconnect()},!Sa&&gr(e,d)]),Sa){const w=new Jo(g);w.observe(e,{box:"border-box"}),dn(c,(()=>w.disconnect()))}}else if(a){const[m,g]=a(h,p,r);dn(c,ll([Iy(d,hR),on(d,"animationstart",m),gr(e,d)],g))}else return Yc;return ft(Dr,c)}},IR=(e,t)=>{let n;const r=d=>d.h===0||d.isIntersecting||d.intersectionRatio>0,a=nl(mR),[l]=Ar({o:!1}),c=(d,h)=>{if(d){const p=l(r(d)),[,m]=p;return m&&!h&&t(p)&&[p]}},u=(d,h)=>c(h.pop(),d);return[()=>{const d=[];if(cw)n=new cw(ft(u,!1),{root:e}),n.observe(a),dn(d,(()=>{n.disconnect()}));else{const h=()=>{const p=rl(a);c(p)};dn(d,Sj(a,h)()),h()}return ft(Dr,dn(d,gr(e,a)))},()=>n&&u(!0,n.takeRecords())]},MR=(e,t,n,r)=>{let a,l,c,u,d,h,p,m;const g=`[${Yi}]`,x=`[${si}]`,w=["id","class","style","open","wrap","cols","rows"],{dt:C,vt:_,L:S,gt:v,ht:b,V:k,bt:N,yt:E,wt:D,St:A}=e,O=U=>As(U,"direction")==="rtl",P=()=>{let U,M,te;const se=Kk(r,{p:()=>U,v:()=>M,S:()=>te,m(le,ye){const[_e]=le,[Oe]=ye;return[ll(pr(_e),pr(Oe)).reduce(((Be,ke)=>(Be[ke]=_e[ke]||Oe[ke],Be)),{})]}}),re=(le,ye)=>{if(Zr(ye)){const[_e,Oe,Be]=ye;U=_e,M=Oe,te=Be}else Ki(ye)?(U=ye,M=!1,te=!1):(U=!1,M=!1,te=!1);se(le)};return re.O=se.O,re},G={Ot:!1,B:O(C)},z=Ls(),V=bl($y),[$]=Ar({i:qk,o:{w:0,h:0}},(()=>{const U=V&&V.R(e,t,G,z,n).Y,te=!(N&&k)&&Oy(_,Yi,ph),se=!k&&E(cR),re=se&&Lr(v),le=re&&A(),ye=D(pj,te),_e=se&&U&&U(),Oe=Th(S),Be=My(S);return _e&&_e(),Es(v,re),le&&le(),te&&ye(),{w:Oe.w+Be.w,h:Oe.h+Be.h}})),H=P(),q=U=>{const M=O(C);Mt(U,{Ct:m!==M}),Mt(G,{B:M}),m=M},X=(U,M)=>{const[te,se]=U,re={$t:se};return Mt(G,{Ot:te}),M||r(re),re},Y=({_t:U,ft:M})=>{const te=M?r:H,se={_t:U||M,ft:M};q(se),te(se,l)},F=(U,M)=>{const[,te]=$(),se={xt:te};return q(se),te&&!M&&H(se,U?c:a),se},I=(U,M,te)=>{const se={Ht:M};return q(se),M&&!te&&H(se,a),se},[R,W]=b?IR(_,X):[],B=!k&&Sj(_,Y,{ft:!0}),[Z,Q]=Cw(_,!1,I,{ct:w,et:w}),J=k&&Jo&&new Jo((U=>{const M=U[U.length-1].contentRect;Y({_t:!0,ft:lj(M,p)}),p=M}));return[()=>{J&&J.observe(_);const U=B&&B(),M=R&&R(),te=Z(),se=z.G((re=>{const[,le]=$();H({Et:re,xt:le,_t:N},u)}));return()=>{J&&J.disconnect(),U&&U(),M&&M(),h&&h(),te(),se()}},({Dt:U,zt:M,It:te})=>{const se={},[re]=U("update.ignoreMutation"),[le,ye]=U("update.attributes"),[_e,Oe]=U("update.elementEvents"),[Be,ke]=U("update.debounce"),Ge=Oe||ye,Je=M||te,ae=ue=>ps(re)&&!!re(ue);if(Ge){d&&d(),h&&h();const[ue,Me]=Cw(b||S,!0,F,{et:ll(w,le||[]),rt:_e,it:g,ut:(fe,Fe)=>{const{target:He,attributeName:ie}=fe;return(!Fe&&ie&&!k?YD(He,g,x):!1)||!!Zo(He,`.${Or}`)||ae(fe)}});h=ue(),d=Me}if(ke&&(H.O(),Zr(Be)||Ki(Be)?(a=Be,l=!1,c=yj,u=bj):Kc(Be)?(a=Be.mutation,l=Be.resize,c=Be.event,u=Be.env):(a=!1,l=!1,c=!1,u=!1)),Je){const ue=Q(),Me=W&&W(),fe=d&&d();ue&&Mt(se,I(ue[0],ue[1],Je)),Me&&Mt(se,X(Me[0],Je)),fe&&Mt(se,F(fe[0],Je))}return q(se),se},G]},wj=(e,t)=>ps(t)?t.apply(0,e):t,PR=(e,t,n,r)=>{const a=jy(r)?n:r;return wj(e,a)||t.apply(0,e)},Cj=(e,t,n,r)=>{const a=jy(r)?n:r,l=wj(e,a);return!!l&&(kh(l)?l:t.apply(0,e))},BR=(e,t)=>{const{nativeScrollbarsOverlaid:n,body:r}=t||{},{M:a,P:l,K:c}=Ls(),{nativeScrollbarsOverlaid:u,body:d}=c().cancel,h=n??u,p=jy(r)?d:r,m=(a.x||a.y)&&h,g=e&&(uf(p)?!l:p);return!!m||!!g},$R=(e,t,n,r)=>{const a="--os-viewport-percent",l="--os-scroll-percent",c="--os-scroll-direction",{K:u}=Ls(),{scrollbars:d}=u(),{slot:h}=d,{dt:p,vt:m,L:g,At:x,gt:w,bt:C,V:_}=t,{scrollbars:S}=x?{}:e,{slot:v}=S||{},b=[],k=[],N=[],E=Cj([p,m,g],(()=>_&&C?p:m),h,v),D=R=>{if(Ic){let W=null,B=[];const Z=new Ic({source:w,axis:R}),Q=()=>{W&&W.cancel(),W=null};return{Mt:U=>{const{Tt:M}=n,te=gg(M)[R],se=R==="x",re=[mg(0,se),mg(`calc(-100% + 100cq${se?"w":"h"})`,se)],le=te?re:re.reverse();return B[0]===le[0]&&B[1]===le[1]||(B=le,Q(),W=U.kt.animate({clear:["left"],transform:le},{timeline:Z})),Q}}}},A={x:D("x"),y:D("y")},O=()=>{const{Rt:R,Vt:W}=n,B=(Z,Q)=>Jk(0,1,Z/(Z+Q)||0);return{x:B(W.x,R.x),y:B(W.y,R.y)}},P=(R,W,B)=>{const Z=B?Iy:ej;Xt(R,(Q=>{Z(Q.Lt,W)}))},G=(R,W)=>{Xt(R,(B=>{const[Z,Q]=W(B);Jc(Z,Q)}))},z=(R,W,B)=>{const Z=df(B),Q=Z?B:!0,J=Z?!B:!0;Q&&P(k,R,W),J&&P(N,R,W)},V=()=>{const R=O(),W=B=>Z=>[Z.Lt,{[a]:kx(B)+""}];G(k,W(R.x)),G(N,W(R.y))},$=()=>{if(!Ic){const{Tt:R}=n,W=pw(R,Lr(w)),B=Z=>Q=>[Q.Lt,{[l]:kx(Z)+""}];G(k,B(W.x)),G(N,B(W.y))}},H=()=>{const{Tt:R}=n,W=gg(R),B=Z=>Q=>[Q.Lt,{[c]:Z?"0":"1"}];G(k,B(W.x)),G(N,B(W.y)),Ic&&(k.forEach(A.x.Mt),N.forEach(A.y.Mt))},q=()=>{if(_&&!C){const{Rt:R,Tt:W}=n,B=gg(W),Z=pw(W,Lr(w)),Q=J=>{const{Lt:U}=J,M=Xc(U)===g&&U,te=(se,re,le)=>{const ye=re*se;return aj(le?ye:-ye)};return[M,M&&{transform:mg({x:te(Z.x,R.x,B.x),y:te(Z.y,R.y,B.y)})}]};G(k,Q),G(N,Q)}},X=R=>{const W=R?"x":"y",Z=nl(`${Or} ${R?xR:yR}`),Q=nl(xj),J=nl(By),U={Lt:Z,Pt:Q,kt:J},M=A[W];return dn(R?k:N,U),dn(b,[gr(Z,Q),gr(Q,J),ft(cl,Z),M&&M.Mt(U),r(U,z,R)]),U},Y=ft(X,!0),F=ft(X,!1),I=()=>(gr(E,k[0].Lt),gr(E,N[0].Lt),ft(Dr,b));return Y(),F(),[{Ut:V,Nt:$,qt:H,Bt:q,Ft:z,jt:{Xt:k,Yt:Y,Wt:ft(G,k)},Jt:{Xt:N,Yt:F,Wt:ft(G,N)}},I]},zR=(e,t,n,r,a)=>(l,c,u)=>{const{vt:d,L:h,V:p,gt:m,Gt:g,St:x}=t,{Lt:w,Pt:C,kt:_}=l,[S,v]=Qo(333),[b,k]=Qo(444),N=A=>{ps(m.scrollBy)&&m.scrollBy({behavior:"smooth",left:A.x,top:A.y})},E=()=>{const A="pointerup pointercancel lostpointercapture",O=`client${u?"X":"Y"}`,P=u?ff:mf,G=u?"left":"top",z=u?"w":"h",V=u?"x":"y",$=[];return on(C,"pointerdown",r((H=>{const q=Zo(H.target,`.${By}`)===_,X=q?_:C,Y=e.scrollbars,F=Y[q?"dragScroll":"clickScroll"],{button:I,isPrimary:R,pointerType:W}=H,{pointers:B}=Y;if(I===0&&R&&F&&(B||[]).includes(W)){Dr($),k();const Q=!q&&(H.shiftKey||F==="instant"),J=ft(pg,_),U=ft(pg,C),M=(He,ie)=>(He||J())[G]-(ie||U())[G],te=_x(pg(m)[P])/rl(m)[z]||1,se=Lr(m)[V],re=He=>{Es(m,{[V]:se+He})},le=He=>{const{Rt:ie}=n,Se=rl(C)[z]-rl(_)[z],Le=1/te*He/Se;re(Le*ie[V])},ye=H[O],_e=J(),Oe=U(),Be=_e[P],ke=M(_e,Oe)+Be/2,Je=ye-Oe[G]-ke,ae=q?0:Je,ue=He=>{Dr(Fe),X.releasePointerCapture(He.pointerId)},Me=q||Q,fe=x(),Fe=[on(g,A,ue),on(g,"selectstart",(He=>Ex(He)),{D:!1}),on(C,A,ue),Me&&on(C,"pointermove",(He=>le(ae+He[O]-ye))),Me&&(()=>{const He=Lr(m);fe();const ie=Lr(m),Se={x:ie.x-He.x,y:ie.y-He.y};(Gi(Se.x)>3||Gi(Se.y)>3)&&(x(),Es(m,He),N(Se),b(fe))})];if(X.setPointerCapture(H.pointerId),Q)le(Je);else if(!q){const He=bl(NR);if(He){const{Vt:ie}=n,Se=He(re,le,ft(M),Je,ie[V],F,!!u,(Le=>{Le?fe():dn(Fe,fe)}));dn(Fe,Se),dn($,ft(Se,!0))}}}})))};let D=!0;return ft(Dr,[on(_,"pointermove pointerleave",r(a)),on(w,"pointerenter",r((()=>{c(bw,!0)}))),on(w,"pointerleave pointercancel",r((()=>{c(bw,!1)}))),on(w,"wheel",r((A=>{const{deltaX:O,deltaY:P,deltaMode:G}=A;D&&G===0&&Xc(w)===d&&N({x:O,y:P}),D=!1,c(_w,!0),S((()=>{D=!0,c(_w)})),Ex(A)})),{D:!1,I:!0}),!p&&on(w,"mousedown",r((()=>{const A=Cx();(dw(A,si)||dw(A,Yi)||A===document.body)&&ky(ft(Nx,h),25)}))),on(w,"pointerdown",(()=>{const A=on(g,"click",(P=>{O(),uj(P)}),{A:!0,I:!0,D:!1}),O=on(g,"pointerup pointercancel",(()=>{O(),setTimeout(A,150)}),{I:!0,D:!0})}),{I:!0,D:!0}),E(),v,k])},HR=(e,t,n,r,a,l,c)=>{let u,d,h,p,m,g=Yc,x=0;const w=["mouse","pen"],C=J=>U=>{n.Kt||J(U)},_=J=>w.includes(J.pointerType),[S,v]=Qo(),[b,k]=Qo(100),[N,E]=Qo(50),[D,A]=Qo((()=>x)),[O,P]=$R(e,l,a,zR(t,l,a,C,(J=>_(J)&&I()))),{vt:G,Qt:z,bt:V}=l,{Ft:$,Ut:H,Nt:q,qt:X,Bt:Y}=O,F=(J,U)=>{A();const M=te=>{n.Kt||$(_R,te)};if(J)M();else{const te=h?!u:!0;x>0&&!U?D(ft(M,te)):M(te)}},I=()=>{(h?!u:!p)&&(F(!0),b((()=>{F(!1)})))},R=J=>{_(J)&&(u=!0,!n.Kt&&h&&F(!0))},W=J=>{_(J)&&(u=!1,!n.Kt&&h&&F(!1))},B=J=>{$(Lx,J,!0),$(Lx,J,!1)},Z=[A,k,E,v,()=>g(),on(G,"pointerover",R,{A:!0}),on(G,"pointerenter",R),on(G,"pointerleave",W),on(G,"pointermove",C((J=>{_(J)&&d&&I()}))),on(z,"scroll",C((J=>{S((()=>{q(),I()})),c(J),Y()})))],Q=bl($y);return[()=>ft(Dr,dn(Z,P())),({Dt:J,It:U,Zt:M,tn:te})=>{const{nn:se,sn:re,en:le,cn:ye}=te||{},{Ct:_e,ft:Oe}=M||{},{B:Be}=r,{M:ke,P:Ge}=Ls(),{rn:Je,j:ae}=a,[ue,Me]=J("showNativeOverlaidScrollbars"),[fe,Fe]=J("scrollbars.theme"),[He,ie]=J("scrollbars.visibility"),[Se,Le]=J("scrollbars.autoHide"),[he,me]=J("scrollbars.autoHideSuspend"),[We]=J("scrollbars.autoHideDelay"),[Ue,Qe]=J("scrollbars.dragScroll"),[it,ge]=J("scrollbars.clickScroll"),[Ve,at]=J("overflow"),ht=Oe&&!U,Ht=se||re||ye||_e||U,Vt=le||ie||at,At=ue&&ke.x&&ke.y,Bn=!Ge&&!Q,Sn=At||Bn,hn=(Dn,wn,un)=>{const nr=Dn.includes(Ha)&&(He===ai||He==="auto"&&wn===Ha);return $(bR,nr,un),nr};if(x=We,(Me||Bn)&&$(pR,Sn),Fe&&($(m),$(fe,!0),m=fe),(me||ht)&&(B(!he),ht&&he&&(ae.x||ae.y?(g(),N((()=>{g=on(z,Ha,C(ft(B,!0)),{A:!0})}))):B(!0))),Le&&(d=Se==="move",h=Se==="leave",p=Se==="never",F(p,!0)),Qe&&$(wR,Ue),ge&&$(SR,!!it),Vt){const Dn=hn(Ve.x,Je.x,!0),wn=hn(Ve.y,Je.y,!1);$(vR,!(Dn&&wn))}Ht&&(q(),H(),Y(),ye&&X(),$(vw,!ae.x,!0),$(vw,!ae.y,!1),$(gR,Be&&!V))},{},O]},FR=e=>{const t=Ls(),{K:n,P:r}=t,{elements:a}=n(),{padding:l,viewport:c,content:u}=a,d=kh(e),h=d?{}:e,{elements:p}=h,{padding:m,viewport:g,content:x}=p||{},w=d?e:h.target,C=nj(w),_=w.ownerDocument,S=_.documentElement,v=()=>_.defaultView||xr,b=ft(PR,[w]),k=ft(Cj,[w]),N=ft(nl,""),E=ft(b,N,c),D=ft(k,N,u),A=_e=>{const Oe=rl(_e),Be=Th(_e),ke=As(_e,Ty),Ge=As(_e,Ay);return Be.w-Oe.w>0&&!el(ke)||Be.h-Oe.h>0&&!el(Ge)},O=E(g),P=O===w,G=P&&C,z=!P&&D(x),V=!P&&O===z,$=G?S:O,H=G?$:w,q=!P&&k(N,l,m),X=!V&&z,Y=[X,$,q,H].map((_e=>kh(_e)&&!Xc(_e)&&_e)),F=_e=>_e&&$k(Y,_e),I=!F($)&&A($)?$:w,R=G?S:$,B={dt:w,vt:H,L:$,ln:q,ht:X,gt:R,Qt:G?_:$,an:C?S:I,Gt:_,bt:C,At:d,V:P,un:v,yt:_e=>Oy($,si,_e),wt:(_e,Oe)=>Nh($,si,_e,Oe),St:()=>Nh(R,si,uR,!0)},{dt:Z,vt:Q,ln:J,L:U,ht:M}=B,te=[()=>{Ss(Q,[Yi,xg]),Ss(Z,xg),C&&Ss(S,[xg,Yi])}];let se=wx([M,U,J,Q,Z].find((_e=>_e&&!F(_e))));const re=G?Z:M||U,le=ft(Dr,te);return[B,()=>{const _e=v(),Oe=Cx(),Be=ue=>{gr(Xc(ue),wx(ue)),cl(ue)},ke=ue=>on(ue,"focusin focusout focus blur",uj,{I:!0,D:!1}),Ge="tabindex",Je=Dy(U,Ge),ae=ke(Oe);return ri(Q,Yi,P?"":aR),ri(J,Ax,""),ri(U,si,""),ri(M,yw,""),P||(ri(U,Ge,Je||"-1"),C&&ri(S,xw,"")),gr(re,se),gr(Q,J),gr(J||Q,!P&&U),gr(U,M),dn(te,[ae,()=>{const ue=Cx(),Me=F(U),fe=Me&&ue===U?Z:ue,Fe=ke(fe);Ss(J,Ax),Ss(M,yw),Ss(U,si),C&&Ss(S,xw),Je?ri(U,Ge,Je):Ss(U,Ge),F(M)&&Be(M),Me&&Be(U),F(J)&&Be(J),Nx(fe),Fe()}]),r&&!P&&(Ry(U,si,gj),dn(te,ft(Ss,U,si))),Nx(!P&&C&&Oe===Z&&_e.top===_e?U:Oe),ae(),se=0,le},le]},UR=({ht:e})=>({Zt:t,fn:n,It:r})=>{const{$t:a}=t||{},{Ot:l}=n;e&&(a||r)&&Jc(e,{[mf]:l&&"100%"})},VR=({vt:e,ln:t,L:n,V:r},a)=>{const[l,c]=Ar({i:qD,o:fw()},ft(fw,e,"padding",""));return({Dt:u,Zt:d,fn:h,It:p})=>{let[m,g]=c(p);const{P:x}=Ls(),{_t:w,xt:C,Ct:_}=d||{},{B:S}=h,[v,b]=u("paddingAbsolute");(w||g||(p||C))&&([m,g]=l(p));const N=!r&&(b||_||g);if(N){const E=!v||!t&&!x,D=m.r+m.l,A=m.t+m.b,O={[Gk]:E&&!S?-D:0,[Wk]:E?-A:0,[Vk]:E&&S?-D:0,top:E?-m.t:0,right:E?S?-m.r:"auto":0,left:E?S?"auto":-m.l:0,[ff]:E&&`calc(100% + ${D}px)`},P={[zk]:E?m.t:0,[Hk]:E?m.r:0,[Uk]:E?m.b:0,[Fk]:E?m.l:0};Jc(t||n,O),Jc(n,P),Mt(a,{ln:m,_n:!E,F:t?P:Mt({},O,P)})}return{dn:N}}},GR=(e,t)=>{const n=Ls(),{vt:r,ln:a,L:l,V:c,Qt:u,gt:d,bt:h,wt:p,un:m}=e,{P:g}=n,x=h&&c,w=ft(Mk,0),C={display:()=>!1,direction:Z=>Z!=="ltr",flexDirection:Z=>Z.endsWith("-reverse"),writingMode:Z=>Z!=="horizontal-tb"},_=pr(C),S={i:qk,o:{w:0,h:0}},v={i:fh,o:{}},b=Z=>{p(pj,!x&&Z)},k=()=>As(l,_),N=(Z,Q)=>{const J=!pr(Z).length,U=Q?!0:_.some((Ge=>{const Je=Z[Ge];return yl(Je)&&C[Ge](Je)}));if(J||!U||!tR(l))return{T:{x:0,y:0},k:{x:1,y:1}};b(!0);const M=Lr(d),te=on(u,Ha,(Ge=>{const Je=Lr(d);Ge.isTrusted&&Je.x===M.x&&Je.y===M.y&&cj(Ge)}),{I:!0,A:!0}),se=p(dR,!0);Es(d,{x:0,y:0}),se();const re=Lr(d),le=Th(d);Es(d,{x:le.w,y:le.h});const ye=Lr(d),_e={x:ye.x-re.x,y:ye.y-re.y};Es(d,{x:-le.w,y:-le.h});const Oe=Lr(d),Be={x:Oe.x-re.x,y:Oe.y-re.y},ke={x:Gi(_e.x)>=Gi(Be.x)?ye.x:Oe.x,y:Gi(_e.y)>=Gi(Be.y)?ye.y:Oe.y};return Es(d,M),Cy((()=>te())),{T:re,k:ke}},E=(Z,Q)=>{const J=xr.devicePixelRatio%1!==0?1:0,U={w:w(Z.w-Q.w),h:w(Z.h-Q.h)};return{w:U.w>J?U.w:0,h:U.h>J?U.h:0}},D=(Z,Q)=>{const J=(U,M,te,se)=>{const re=U===ai?as:jR(U),le=el(U),ye=el(te);return!M&&!se?as:le&&ye?ai:le?M&&se?re:M?ai:as:M?re:ye&&se?ai:as};return{x:J(Q.x,Z.x,Q.y,Z.y),y:J(Q.y,Z.y,Q.x,Z.x)}},A=Z=>{const Q=U=>[ai,as,Ha].map((M=>B(Dx(M),U))),J=Q(!0).concat(Q()).join(" ");p(J),p(pr(Z).map((U=>B(Z[U],U==="x"))).join(" "),!0)},[O,P]=Ar(S,ft(My,l)),[G,z]=Ar(S,ft(Th,l)),[V,$]=Ar(S),[H]=Ar(v),[q,X]=Ar(S),[Y]=Ar(v),[F]=Ar({i:(Z,Q)=>pf(Z,Q,Eh(ll(pr(Z),pr(Q)))),o:{}}),[I,R]=Ar({i:(Z,Q)=>fh(Z.T,Q.T)&&fh(Z.k,Q.k),o:dj()}),W=bl($y),B=(Z,Q)=>`${Q?oR:lR}${WD(Z)}`;return({Dt:Z,Zt:Q,fn:J,It:U},{dn:M})=>{const{_t:te,Ht:se,xt:re,Ct:le,ft:ye,Et:_e}=Q||{},Oe=W&&W.R(e,t,J,n,Z),{X:Be,Y:ke,W:Ge}=Oe||{},[Je,ae]=kR(Z,n),[ue,Me]=Z("overflow"),fe=el(ue.x),Fe=el(ue.y),He=te||M||re||le||_e||ae;let ie=P(U),Se=z(U),Le=$(U),he=X(U);if(ae&&g&&p(gj,!Je),He){Oy(r,Yi,ph)&&b(!0);const et=ke&&ke(),[Ye]=ie=O(U),[oe]=Se=G(U),Pe=oj(l),Ze=x&&eR(m()),Dt={w:w(oe.w+Ye.w),h:w(oe.h+Ye.h)},rn={w:w((Ze?Ze.w:Pe.w+w(Pe.w-oe.w))+Ye.w),h:w((Ze?Ze.h:Pe.h+w(Pe.h-oe.h))+Ye.h)};et&&et(),he=q(rn),Le=V(E(Dt,rn),U)}const[me,We]=he,[Ue,Qe]=Le,[it,ge]=Se,[Ve,at]=ie,[ht]=H({x:Ue.w>0,y:Ue.h>0}),Ht=fe&&Fe&&(ht.x||ht.y)||fe&&ht.x&&!ht.y||Fe&&ht.y&&!ht.x,Vt=M||le||_e||at||ge||We||Qe||Me||ae||He||se&&x,[At]=Z("update.flowDirectionStyles"),[Bn,Sn]=F(At?At(l)||{}:k(),U),hn=le||ye||Sn||U,[Dn,wn]=hn?I(N(Bn,!!At),U):R();let un=D(ht,ue);b(!1),Vt&&(A(un),un=ER(l,ht),Ge&&Be&&(Be(un,it,Ve),Jc(l,Ge(un))));const[nr,we]=Y(un);return Nh(r,Yi,ph,Ht),Nh(a,Ax,ph,Ht),Mt(t,{rn:nr,Vt:{x:me.w,y:me.h},Rt:{x:Ue.w,y:Ue.h},j:ht,Tt:nR(Dn,Ue)}),{en:we,nn:We,sn:Qe,cn:wn||Qe}}},WR=e=>{const[t,n,r]=FR(e),a={ln:{t:0,r:0,b:0,l:0},_n:!1,F:{[Gk]:0,[Wk]:0,[Vk]:0,[zk]:0,[Hk]:0,[Uk]:0,[Fk]:0},Vt:{x:0,y:0},Rt:{x:0,y:0},rn:{x:as,y:as},j:{x:!1,y:!1},Tt:dj()},{dt:l,gt:c,V:u,St:d}=t,{P:h,M:p}=Ls(),m=!h&&(p.x||p.y),g=[UR(t),VR(t,a),GR(t,a)];return[n,x=>{const w={},_=m&&Lr(c),S=_&&d();return Xt(g,(v=>{Mt(w,v(x,w)||{})})),Es(c,_),S&&S(),u||Es(l,0),w},a,t,r]},qR=(e,t,n,r)=>{let a=!1;const l={Kt:!1,pn:!1},c=yg(t,{}),[u,d,h,p,m]=WR(e),[g,x,w]=MR(p,h,c,(k=>{b({},k)})),[C,_,,S]=HR(e,t,l,w,h,p,r),v=k=>pr(k).some((N=>!!k[N])),b=(k,N)=>{const{Kt:E,pn:D}=l;if(D||E&&a)return!1;const{vn:A,It:O,zt:P}=k,G=A||{},z=!!O||!a,V={Dt:yg(t,G,z),vn:G,It:z},$=N||x(Mt({},V,{zt:P})),H=d(Mt({},V,{fn:w,Zt:$}));_(Mt({},V,{Zt:$,tn:H}));const q=v($),X=v(H),Y=q||X||!Ly(G)||z;return a=!0,Y&&n(k,{Zt:$,tn:H}),Y};return[()=>{const{an:k,gt:N,St:E}=p,D=Lr(k),A=[g(),u(),C(),()=>{l.pn=!0}],O=E();return Es(N,D),O(),ft(Dr,A)},b,k=>{const N=l.Kt;l.Kt=k,!k&&N!==k&&b({It:!0,zt:!0})},()=>{_({Dt:yg(t,{},!1),vn:{},It:!1})},()=>({gn:l,hn:w,bn:h}),{yn:p,wn:S},m]},zy=new WeakMap,KR=(e,t)=>{zy.set(e,t)},YR=e=>{zy.delete(e)},kj=e=>zy.get(e),us=(e,t,n)=>{const{tt:r}=Ls(),a=kh(e),l=a?e:e.target,c=kj(l);if(t&&!c){const u=[],d={},h=z=>{const V=Xk(z),$=bl(iR);return $?$(V,!0):V},p=Mt({},r(),h(t)),[m,g,x]=Tx(),[w,C,_]=Tx(n),S=(z,V)=>{_(z,V),x(z,V)},[v,b,k,N,E,D,A]=qR(e,p,(({vn:z,It:V},{Zt:$,tn:H})=>{const{_t:q,Ct:X,$t:Y,xt:F,Ht:I,ft:R}=$,{nn:W,sn:B,en:Z,cn:Q}=H;S("updated",[G,{updateHints:{sizeChanged:!!q,directionChanged:!!X,heightIntrinsicChanged:!!Y,overflowEdgeChanged:!!W,overflowAmountChanged:!!B,overflowStyleChanged:!!Z,scrollCoordinatesChanged:!!Q,contentMutation:!!F,hostMutation:!!I,appear:!!R},changedOptions:z||{},force:!!V}])}),(z=>S("scroll",[G,z]))),O=z=>{const{gn:V}=E(),{pn:$}=V;$||(YR(l),Dr(u),S("destroyed",[G,z]),g(),C())},G={options(z,V){if(z){const $=V?r():{},H=vj(p,Mt($,h(z)));Ly(H)||(Mt(p,H),b({vn:H}))}return Mt({},p)},on:w,off:(z,V)=>{z&&V&&C(z,V)},state(){const{gn:z,hn:V,bn:$}=E(),{pn:H,Kt:q}=z,{B:X}=V,{Vt:Y,Rt:F,rn:I,j:R,ln:W,_n:B,Tt:Z}=$;return Mt({},{overflowEdge:Y,overflowAmount:F,overflowStyle:I,hasOverflow:R,scrollCoordinates:{start:Z.T,end:Z.k},padding:W,paddingAbsolute:B,directionRTL:X,sleeping:q,destroyed:H})},elements(){const{dt:z,vt:V,ln:$,L:H,ht:q,gt:X,Qt:Y}=D.yn,{jt:F,Jt:I}=D.wn,R=B=>{const{kt:Z,Pt:Q,Lt:J}=B;return{scrollbar:J,track:Q,handle:Z}},W=B=>{const{Xt:Z,Yt:Q}=B,J=R(Z[0]);return Mt({},J,{clone:()=>{const U=R(Q());return N(),U}})};return Mt({},{target:z,host:V,padding:$||H,viewport:H,content:q||H,scrollOffsetElement:X,scrollEventElement:Y,scrollbarHorizontal:W(F),scrollbarVertical:W(I)})},update:z=>b({It:z,zt:!0}),destroy:ft(O,!1),sleep:k,plugin:z=>d[pr(z)[0]]};return dn(u,[A]),KR(l,G),mj(hj,us,[G,m,d]),BR(D.yn.bt,!a&&e.cancel)?(O(!0),G):(dn(u,v()),S("initialized",[G]),G.update(),G)}return c};us.plugin=e=>{const t=Zr(e),n=t?e:[e],r=n.map((a=>mj(a,us)[0]));return rR(n),t?r:r[0]};us.valid=e=>{const t=e&&e.elements,n=ps(t)&&t();return Kc(n)&&!!kj(n.target)};us.env=()=>{const{U:e,M:t,P:n,J:r,ot:a,st:l,K:c,Z:u,tt:d,nt:h}=Ls();return Mt({},{scrollbarsSize:e,scrollbarsOverlaid:t,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:a,staticDefaultOptions:l,getDefaultInitialization:c,setDefaultInitialization:u,getDefaultOptions:d,setDefaultOptions:h})};us.nonce=DR;us.trustedTypePolicy=JD;const XR=()=>{if(typeof window>"u"){const h=()=>{};return[h,h]}let e,t;const n=window,r=typeof n.requestIdleCallback=="function",a=n.requestAnimationFrame,l=n.cancelAnimationFrame,c=r?n.requestIdleCallback:a,u=r?n.cancelIdleCallback:l,d=()=>{u(e),l(t)};return[(h,p)=>{d(),e=c(r?()=>{d(),t=a(h)}:h,typeof p=="object"?p:{timeout:2233})},d]},JR=e=>{const{options:t,events:n,defer:r}=e||{},[a,l]=j.useMemo(XR,[]),c=j.useRef(null),u=j.useRef(r),d=j.useRef(t),h=j.useRef(n);return j.useEffect(()=>{u.current=r},[r]),j.useEffect(()=>{const{current:p}=c;d.current=t,us.valid(p)&&p.options(t||{},!0)},[t]),j.useEffect(()=>{const{current:p}=c;h.current=n,us.valid(p)&&p.on(n||{},!0)},[n]),j.useEffect(()=>()=>{var p;l(),(p=c.current)==null||p.destroy()},[]),j.useMemo(()=>[p=>{const m=c.current;if(us.valid(m))return;const g=u.current,x=d.current||{},w=h.current||{},C=()=>c.current=us(p,x,w);g?a(C,g):C()},()=>c.current],[])},QR=(e,t)=>{const{element:n="div",options:r,events:a,defer:l,children:c,...u}=e,d=n,h=j.useRef(null),p=j.useRef(null),[m,g]=JR({options:r,events:a,defer:l});return j.useEffect(()=>{const{current:x}=h,{current:w}=p;if(!x)return;const C=x;return m(n==="body"?{target:C,cancel:{body:null}}:{target:C,elements:{viewport:w,content:w}}),()=>{var _;return(_=g())==null?void 0:_.destroy()}},[m,n]),j.useImperativeHandle(t,()=>({osInstance:g,getElement:()=>h.current}),[]),cs.createElement(d,{"data-overlayscrollbars-initialize":"",ref:h,...u},n==="body"?c:cs.createElement("div",{"data-overlayscrollbars-contents":"",ref:p},c))},ZR=j.forwardRef(QR),dt=j.forwardRef(({options:e,horizontal:t,both:n,onScrollbarGesture:r,...a},l)=>{const c=t||n,u=j.useRef(r);u.current=r;const d=j.useRef(null),h=j.useMemo(()=>({initialized:m=>{var v;(v=d.current)==null||v.call(d);const g=m.elements().scrollbarVertical,x=()=>{const b=g.handle.getBoundingClientRect(),k=g.track.getBoundingClientRect();return b.height===0||k.height===0?null:Math.max(0,k.bottom-b.bottom)};let w=null;const C=()=>{var b;(b=u.current)==null||b.call(u,"up",x()),w==null||w()},_=b=>{var k;if(b.buttons===0){C();return}(k=u.current)==null||k.call(u,"move",x())},S=()=>{var b;(b=u.current)==null||b.call(u,"down",x()),w==null||w(),window.addEventListener("pointermove",_),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),w=()=>{window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C),w=null}};g.track.addEventListener("pointerdown",S),d.current=()=>{g.track.removeEventListener("pointerdown",S),w==null||w()}}}),[]);return j.useEffect(()=>()=>{var p;return(p=d.current)==null?void 0:p.call(d)},[]),s.jsx(ZR,{ref:l,events:h,options:{overflow:{x:c?"scroll":"hidden",y:n?"scroll":t?"hidden":"scroll"},scrollbars:{autoHide:c?"leave":"move",autoHideDelay:c?1500:600,clickScroll:"instant"},update:{elementEvents:[[":scope","mouseenter"]]},...e},...a})});dt.displayName="ScrollArea";const kw=e=>{let t;const n=new Set,r=(h,p)=>{const m=typeof h=="function"?h(t):h;if(!Object.is(m,t)){const g=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(x=>x(t,g))}},a=()=>t,u={setState:r,getState:a,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h))},d=t=e(r,a,u);return u},e5=(e=>e?kw(e):kw),t5=e=>e;function n5(e,t=t5){const n=cs.useSyncExternalStore(e.subscribe,cs.useCallback(()=>t(e.getState()),[e,t]),cs.useCallback(()=>t(e.getInitialState()),[e,t]));return cs.useDebugValue(n),n}const jw=e=>{const t=e5(e),n=r=>n5(t,r);return Object.assign(n,t),n},Kn=(e=>e?jw(e):jw);function r5(){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 jj=r5();function ms(e){return e.startsWith("/")?`${jj}${e}`||"/":e}async function xe(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(ms(e),{...t,headers:r})}async function Ew(e,t,n,r){try{return(await xe(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{content:n}:{},...r!==void 0?{attachments:r}:{}})})).ok}catch{return!1}}async function Ej(e,t,n){try{const r=await xe(`/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 Ee={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SYSTEM_THEME_PREFS:"display.systemThemePrefs",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",DISPLAY_SHOW_CHANGELOG_ON_UPDATE:"display.showChangelogOnUpdate",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",DISPLAY_CUSTOM_CSS:"display.customCss",DISPLAY_TERMINAL_FONT:"display.terminalFont",DISPLAY_USE_NATIVE_SCROLLBARS:"display.useNativeScrollbars",DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS:"display.useNativeScrollbarsCodeBlocks",DISPLAY_COLLAPSE_LARGE_TOOL_CALLS:"display.collapseLargeToolCalls",DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING:"display.deferCodeHighlightWhileStreaming",DISPLAY_FEED_VIRTUALIZATION:"display.feedVirtualization",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey",TOOLS_USE_RTK:"tools.useRtk",TOOLS_SHELL:"tools.shell",CONFIRM_ON_WORKSPACE_ACTIONS:"tools.confirmOnWorkspaceActions",FEATURES_PER_SESSION_MCP:"features.perSessionMcp",PROXY_URL:"network.proxyUrl",DEFAULT_AGENT:"agent.defaultAgent"};function Bd(e,t){return n=>({loading:{...n.loading,[e]:t}})}function Nw(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const Hy=[Ee.DISPLAY_SHOW_THINKING,Ee.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Ee.DISPLAY_SHOW_STATS,Ee.DISPLAY_SHOW_AGENT_DEFINITIONS,Ee.DISPLAY_SHOW_WORKFLOW_BARS,Ee.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Ee.DISPLAY_FOLLOW_SYSTEM_THEME,Ee.DISPLAY_SHOW_OPEN_IN_EDITOR,Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,Ee.DISPLAY_MAX_VISIBLE_ITEMS,Ee.DISPLAY_TERMINAL_FONT,Ee.DISPLAY_USE_NATIVE_SCROLLBARS,Ee.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,Ee.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,Ee.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,Ee.DISPLAY_FEED_VIRTUALIZATION];function Ds(){return{showThinking:Lt(e=>e.settings[Ee.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Lt(e=>e.settings[Ee.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Lt(e=>e.settings[Ee.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Lt(e=>e.settings[Ee.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Lt(e=>e.settings[Ee.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Lt(e=>e.settings[Ee.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Lt(e=>e.settings[Ee.DISPLAY_MAX_VISIBLE_ITEMS]??"300")),useNativeScrollbars:Lt(e=>e.settings[Ee.DISPLAY_USE_NATIVE_SCROLLBARS]??"false")==="true",useNativeScrollbarsCodeBlocks:Lt(e=>e.settings[Ee.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS]??"false")==="true",collapseLargeToolCalls:Lt(e=>e.settings[Ee.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS]??"false")==="true",deferCodeHighlightWhileStreaming:Lt(e=>e.settings[Ee.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING]??"false")==="true",feedVirtualization:Lt(e=>e.settings[Ee.DISPLAY_FEED_VIRTUALIZATION]??"false")==="true"}}const Lt=Kn(e=>({settings:{},loading:{},getSetting:async t=>{e(Bd(t,!0));try{const r=await(await xe(`/api/settings/${t}`)).json();return e(Nw(t,r.value??"")),r.value}catch{return e(Bd(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await xe(`/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(Bd(t,!0));try{const a=await(await xe(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(Nw(t,a.value??""))}catch{e(Bd(t,!1))}}})),bc=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:Hy,SETTINGS_KEYS:Ee,useDisplaySettings:Ds,useSettingsStore:Lt},Symbol.toStringTag,{value:"Module"}));function s5(){const[e,t]=j.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=j.useRef(window.innerHeight);return j.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const l=r.offsetTop,c=r.height,u=n.current-c>100;t({offsetTop:l,height:c,keyboardVisible:u})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}const Tw=1e4,ul=new Map;function i5(){const e=Date.now();for(const[t,n]of ul)n.expiresAt<e&&ul.delete(t)}function a5(e){if(ul.has(e))return;const t=localStorage.getItem("openfox_token"),n=fetch(ms(`/api/sessions/${e}`),{headers:t?{"x-session-token":t}:void 0}).then(async r=>r.ok?{ok:!0,data:await r.json()}:{ok:!1}).catch(()=>({ok:!1}));ul.set(e,{promise:n,expiresAt:Date.now()+Tw}),setTimeout(i5,Tw)}function o5(e){const t=ul.get(e);if(t&&(ul.delete(e),!(t.expiresAt<Date.now())))return t.promise}function l5(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function gh(){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 c5{constructor(t){Ae(this,"ws",null);Ae(this,"handlers",new Set);Ae(this,"statusHandler",null);Ae(this,"baseUrl");Ae(this,"isReconnecting",!1);Ae(this,"connectingPromise",null);Ae(this,"lastCloseCode",0);Ae(this,"reconnectAttempts",0);Ae(this,"manualReconnectScheduled",!1);Ae(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 c=this.getUrl();this.ws=new WebSocket(c);const u=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(u),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(u),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(u),console.error("WebSocket error:",d),this.connectingPromise=null,l(d)},this.ws.onmessage=d=>{try{const h=JSON.parse(d.data);l5(h)&&this.handlers.forEach(p=>p(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(c){this.connectingPromise=null,l(c)}}),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=gh(),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 u5=window.location.protocol==="https:"?"wss:":"ws:";let Rx=window.location.port;Rx||(Rx=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const d5=`${u5}//${window.location.hostname}:${Rx}${ms("/ws")}`,Bt=new c5(d5),h5=3e4;function Nj(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}let vc=null;const en=Kn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,platform:null,workdir:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>vc||(e({loading:!0,error:null}),vc=(async()=>{try{const n=await xe("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json(),a=r.platform&&typeof r.platform=="object"?{isWSL:!!r.platform.isWSL,wslDistro:String(r.platform.wslDistro??"")}:null;e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,platform:a,workdir:r.workdir??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}finally{vc=null}})(),vc),refreshModel:async()=>{try{const n=await xe("/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 xe(`/api/providers/${n}/activate`,{method:"POST"});if(!l.ok){const u=await l.json();throw new Error(u.error??"Failed to activate provider")}const c=await l.json();return e({activeProviderId:c.activeProviderId,model:c.model,backend:c.backend,providers:a.map(u=>({...u,isActive:u.id===c.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 xe("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!l.ok)return!1;const c=await l.json();return e({activeProviderId:n,model:r,defaultModelSelection:c.defaultModelSelection,providers:a.map(u=>({...u,isActive:u.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await xe(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const c=await r.json();throw new Error(c.error??"Failed to refresh models")}const a=await r.json(),{providers:l}=t();return e({providers:l.map(c=>c.id===n?{...c,models:a.models,status:a.status}:c),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()},h5);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(u=>u.id===a);if(!l)return 2e5;const c=l.models.find(u=>u.id===n);return(c==null?void 0:c.contextWindow)??2e5}})),Yt=Kn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await xe("/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 xe("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!a.ok){const c=await a.json().catch(()=>({}));return{error:{code:c.code||"UNKNOWN",path:c.path,message:c.error}}}const l=await a.json();return await t().listProjects(),l.project}catch{return null}},loadProject:async n=>{try{const r=await xe(`/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 xe(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!l.ok)return null;const c=await l.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:c.project}),await t().listProjects(),c.project}catch{return null}},deleteProject:async n=>{var r;try{return(await xe(`/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 xe(`/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 c=await l.json();e({currentProject:c.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),Qi=async(e,t,n)=>{try{const r=await xe(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"}}},yf=async(e,t,n)=>{try{const r=await xe(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 Tj(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let $d=[];const Hc=Kn()((e,t)=>{function n(){if($d.length===0)return;const a=$d;$d=[],e(l=>{const c={...l.logs};for(const u of a){const d=c[u.processId]??[];c[u.processId]=[...d,{offset:d.length,content:u.content,timestamp:Date.now(),stream:u.stream}]}return{logs:c}})}const r=Tj(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(l=>({processes:[...l.processes,a]})),updateProcess:(a,l)=>e(c=>({processes:c.processes.map(u=>u.id===a?{...u,...l}:u)})),removeProcess:a=>e(l=>({processes:l.processes.filter(c=>c.id!==a),logs:Object.fromEntries(Object.entries(l.logs).filter(([c])=>c!==a))})),stopProcess:async(a,l)=>{try{(await xe(`/api/sessions/${l}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,l,c)=>{$d.push({processId:a,stream:l,content:c}),r()},setLogs:(a,l)=>e(c=>({logs:{...c.logs,[a]:l}})),clearLogs:a=>e(l=>({logs:{...l.logs,[a]:[]}})),handleMessage:(a,l)=>{switch(a){case"backgroundProcess.started":{const{processId:c,name:u,command:d,cwd:h,pid:p,status:m}=l;e(g=>({processes:[...g.processes,{id:c,sessionId:"",name:u,command:d,cwd:h,pid:p,status:m,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const c=l.processId,u=l.stream,d=l.content;t().appendLog(c,u,d);break}case"backgroundProcess.exited":{const c=l.processId,u=l.exitCode;e(d=>({processes:d.processes.map(h=>h.id===c?{...h,status:"exited",exitCode:u}:h)}));break}case"backgroundProcess.removed":{const c=l.processId;t().removeProcess(c);break}}}}}),Mc={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Ua=null,li=null,sl=null,Fy=0;const Aw=16;function f5(e){Ua=e}function Pc(){return Mc}function m5(){li!==null&&(sl==="raf"?cancelAnimationFrame(li):clearTimeout(li),li=null,sl=null)}function vg(){li=null,sl=null,Fy=Date.now(),Ua==null||Ua()}function _g(){if(li!==null)return;const e=Date.now()-Fy;e>=Aw?typeof document<"u"&&document.hidden?(li=setTimeout(vg,0),sl="timeout"):(li=requestAnimationFrame(vg),sl="raf"):(li=setTimeout(vg,Aw-e),sl="timeout")}function Ia(){m5(),Ua==null||Ua(),Mc.messageId=null,Mc.deltaContent="",Mc.thinkingContent="",Mc.toolOutput=[],Fy=0}let zd=[];const Jn=Kn()((e,t)=>{function n(){if(zd.length===0)return;const a=zd;zd=[],e(l=>({logs:[...l.logs,...a]}))}const r=Tj(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 c=await(await xe(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:c,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const c=await(await xe(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:c.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const u=(await(await xe(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content,...d.type?{type:d.type}:{}}));e({logs:u})}catch{}},clearLogs:async()=>{const a=t().workdir;if(a)try{await xe(`/api/dev-server/clear-logs?workdir=${encodeURIComponent(a)}`,{method:"POST"}),e({logs:[]})}catch{}},insertMarker:async()=>{const a=t().workdir;if(a)try{await xe(`/api/dev-server/insert-marker?workdir=${encodeURIComponent(a)}`,{method:"POST"}),t().fetchLogs()}catch{}},start:async()=>{const a=t().workdir;if(a)try{const c=await(await xe(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const c=await(await xe(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const c=await(await xe(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},saveConfig:async a=>{const l=t().workdir;if(l)try{const u=await(await xe(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:u.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const l=t().workdir;if(l)switch(a.type){case"devServer.output":{const c=a.payload;if(c.workdir!==l)return;zd.push({stream:c.stream,content:c.content}),r();break}case"devServer.state":{const c=a.payload;if(c.workdir!==l)return;e(u=>({status:u.status?{...u.status,state:c.state,errorMessage:c.errorMessage,...c.url!==void 0?{url:c.url}:{},...c.inspectProxyPort!==void 0?{inspectProxyPort:c.inspectProxyPort}:{}}:{state:c.state,url:c.url??null,hotReload:!1,config:null,errorMessage:c.errorMessage,inspectProxyPort:c.inspectProxyPort??null}}));break}}}}}),Lw={open:0,todo:0,inProgress:0,running:0,queued:0,done:0};function p5(e,t,n){e(r=>({...n.tasks?{tasks:n.tasks}:{},...n.settings?{settings:n.settings}:{},...n.counts?{counts:n.counts}:{},...n.gates?{gates:n.gates}:{},activeProjectId:t,lastError:null}))}const It=Kn((e,t)=>({tasks:[],settings:{slotLimit:1,queuePaused:!1},counts:Lw,gates:[],summaries:{},loading:!1,activeProjectId:null,lastError:null,lastAutoLaunch:null,loadBoard:async n=>{e({loading:!0});try{const r=await xe(`/api/projects/${n}/tasks`);if(!r.ok){e({loading:!1});return}const a=await r.json();p5(e,n,a),e({loading:!1})}catch{e({loading:!1})}},loadCounts:async n=>{try{const r=await xe(`/api/projects/${n}/tasks/count`);if(!r.ok)return;const a=await r.json();e(l=>({counts:a.counts??l.counts,activeProjectId:n}))}catch{}},loadGates:async n=>{try{const r=await xe(`/api/projects/${n}/tasks/gates`);if(!r.ok)return;const a=await r.json();e({gates:a.gates??[]})}catch{}},loadSummaries:async n=>{await Promise.all(n.map(async r=>{try{const a=await xe(`/api/projects/${r}/tasks/count`);if(!a.ok)return;const l=await a.json(),c=l==null?void 0:l.counts;if(!c)return;const u=t().summaries[r];if(u&&Object.keys(c).every(d=>u[d]===c[d]))return;e(d=>({summaries:{...d.summaries,[r]:c}}))}catch{}}))},createTask:async(n,r)=>{try{const a=await xe(`/api/projects/${n}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),l=await a.json();return a.ok?(await t().loadBoard(n),l.task):(e({lastError:l.error??"Failed to create task"}),null)}catch{return e({lastError:"Failed to create task"}),null}},updateTask:async(n,r,a)=>{try{const l=await xe(`/api/projects/${n}/tasks/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await l.json();return l.ok?(await t().loadBoard(n),c.task):(e({lastError:c.error??"Failed to update task"}),null)}catch{return e({lastError:"Failed to update task"}),null}},deleteTask:async(n,r)=>{try{return(await xe(`/api/projects/${n}/tasks/${r}`,{method:"DELETE"})).ok?(await t().loadBoard(n),!0):!1}catch{return!1}},duplicateTask:async(n,r)=>{try{const a=await xe(`/api/projects/${n}/tasks/${r}/duplicate`,{method:"POST"}),l=await a.json();return a.ok?(await t().loadBoard(n),l.task):null}catch{return null}},moveTask:async(n,r,a,l)=>{try{const c=await xe(`/api/projects/${n}/tasks/${r}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({to:a,...l?{reason:l}:{}})}),u=await c.json();return c.ok?(e({lastError:null}),u.autoLaunched&&e({lastAutoLaunch:u.autoLaunched}),await t().loadBoard(n),u):(e({lastError:u.error??"Failed to move task"}),null)}catch{return e({lastError:"Failed to move task"}),null}},setGateValue:async(n,r,a,l)=>{try{const c=await xe(`/api/projects/${n}/tasks/${r}/gate-values/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})}),u=await c.json();return c.ok?(await t().loadBoard(n),u.task):(e({lastError:u.error??"Failed to set gate value"}),null)}catch{return e({lastError:"Failed to set gate value"}),null}},setGateConfig:async(n,r)=>{try{return(await xe(`/api/projects/${n}/tasks/gates`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({gates:r})})).ok?(e({gates:r}),!0):!1}catch{return!1}},setSettings:async(n,r)=>{e(a=>a.activeProjectId===n?{settings:{...a.settings,...r}}:{});try{return!!(await xe(`/api/projects/${n}/tasks/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).ok}catch{return!1}},reorderTask:async(n,r,a,l)=>{try{return!!(await xe(`/api/projects/${n}/tasks/${r}/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:a,index:l})})).ok}catch{return!1}},clearBoard:()=>{e({tasks:[],gates:[],settings:{slotLimit:1,queuePaused:!1},counts:Lw,activeProjectId:null})},clearAutoLaunch:()=>e({lastAutoLaunch:null}),handleTasksUpdate:n=>{n.counts&&e(r=>({summaries:{...r.summaries,[n.projectId]:n.counts}})),n.projectId===t().activeProjectId&&e(r=>({tasks:n.tasks??r.tasks,settings:n.settings??r.settings,counts:n.counts??r.counts,...n.gates?{gates:n.gates}:{},...n.autoLaunched?{lastAutoLaunch:n.autoLaunched}:{}}))}})),g5=[{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"}],x5=[{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"}],Aj={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"},Wi={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Lj={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Ox={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Wi},waiting_for_user:{...Wi},phase_done:{...Wi},phase_blocked:{...Wi},new_message:{...Lj}},agentOverrides:{}};function Dj(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 Ra=Kn((e,t)=>({settings:Ox,loaded:!1,load:()=>{Lt.getState().getSetting(Ee.NOTIFICATION_SETTINGS);const r=Lt.subscribe(l=>{const c=l.settings[Ee.NOTIFICATION_SETTINGS];if(c!==void 0)try{const u=JSON.parse(c);e({settings:Dw(u),loaded:!0})}catch{e({loaded:!0})}}),a=Lt.getState().settings[Ee.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:Dw(l),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Sg(n)},updateEvent:(n,r)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:l}),Sg(l)},updateAgentOverride:(n,r,a)=>{var d;const l=t().settings,c={...l.agentOverrides};if(a===null){if(c[n]){const h={...c[n]};delete h[r],Object.keys(h).length===0?delete c[n]:c[n]=h}}else c[n]={...c[n],[r]:{...((d=c[n])==null?void 0:d[r])??{},...a}};const u={...l,agentOverrides:c};e({settings:u}),Sg(u)}}));function Sg(e){Lt.getState().setSetting(Ee.NOTIFICATION_SETTINGS,JSON.stringify(e))}function Dw(e){var t,n,r,a,l;return{soundEnabled:e.soundEnabled??Ox.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Ox.browserNotificationEnabled,events:{complete:{...Wi,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Wi,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Wi,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...Wi,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...Lj,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const Rw=new Map;function y5(e){let t=Rw.get(e);return t||(t=new Audio(ms(e)),t.volume=.5,Rw.set(e,t)),t}let Rj=typeof Notification<"u"?Notification.permission:"denied";function b5(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(Rj=e,e))}const v5={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},_5={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 S5(e){typeof Notification>"u"||Rj==="granted"&&(document.hasFocus()||new Notification(v5[e],{body:_5[e],icon:ms("/fox.svg"),tag:`openfox-${e}`}))}function du(e,t){const{settings:n}=Ra.getState(),r=Dj(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??Aj[e],l=y5(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&S5(e)}const w5=e=>du("complete",e),C5=e=>du("phase_done",e),k5=e=>du("phase_blocked",e),wg=e=>du("waiting_for_user",e),j5=e=>du("new_message",e),Ow=new Map;function qo(e,t){var l;const n=t===((l=e.currentSession)==null?void 0:l.id)?e.currentSession:null,r=e.sessions.find(c=>c.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function E5(e,t){if(e.type==="chat.done"){const n=e.payload,r=qo(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&w5(a),n.reason==="waiting_for_user"&&wg(a);return}if(e.type==="chat.path_confirmation"){const n=qo(t,e.sessionId);wg(n);return}if(e.type==="session.confirmation_pending"){const n=qo(t,e.sessionId);wg(n);return}if(e.type==="task.completed"){const n=qo(t,e.sessionId);C5(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=Ow.get(e.sessionId)??null;if(Ow.set(e.sessionId,n.phase),r===n.phase)return;const a=qo(t,e.sessionId);n.phase==="blocked"&&k5(a)}}const Qc=Kn(e=>({servers:[],setServers:t=>e({servers:t}),fetchServers:async()=>{try{const t=await xe("/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{}}})),Cg=new Set;function bn(e,t){return t!==null&&e.sessionId===t}function N5(e,t,n){return e.id!==void 0||bn(e,t)||n===!0&&e.sessionId!==void 0}function T5(e,t){return e.includes(t)?e:[...e,t]}function Iw(e,t){return e.filter(n=>n!==t)}function A5(e,t){const n=e.find(l=>l.id===t.id),r=t.messageCount??0,a=n?{...n,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(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,isFavorite:!1,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 kg(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 L5(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,l=t.find(c=>c.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 Mw(e,t,n,r){var u;const a=e.sessionId,l=(u=n().currentSession)==null?void 0:u.id,c=a&&a!==l;if(t(d=>({sessions:d.sessions.map(h=>h.id===a?r(h):h)})),!c){const d=n().currentSession;if(d){const h=r(d);t(()=>({currentSession:h}))}}}function Pw(e,t,n){var u,d,h,p,m,g,x,w,C,_,S,v,b,k,N,E,D,A,O,P,G,z,V;const r=n();E5(e,r);const a=((u=r.currentSession)==null?void 0:u.id)??null,l=()=>{const $=e.sessionId;!$||$===a||t(H=>({unreadSessionIds:T5(H.unreadSessionIds,$)}))},c=($,H,q)=>({messages:$.messages.map(X=>X.id===H?q(X):X)});switch(e.type){case"session.state":{const $=e.payload;if(!N5(e,a,r.pendingSessionCreate))break;Ia();const H=n().pendingSessionCreate===!0,q=$.pendingConfirmations??[],X=$.session.id,Y={...n().crossSessionConfirmations};delete Y[X],t({currentSession:$.session,sessions:A5(n().sessions,$.session),unreadSessionIds:Iw(n().unreadSessionIds,X),messages:$.messages,hiddenCount:$.hiddenCount??0,currentTodos:[],pendingPathConfirmations:q,crossSessionConfirmations:Y,sessionsWithPendingConfirmations:Object.keys(Y),pendingQuestions:$.pendingQuestions??[],activeWorkflowExecution:$.activeWorkflowExecution??null,...H?{pendingSessionCreate:$.session.id}:{}});break}case"session.list":{const $=e.payload;t(H=>({sessions:L5($.sessions,H.sessions,H.currentSession)}));break}case"session.created":{const $=e.payload;t(H=>({sessions:H.sessions.some(q=>q.id===$.session.id)?H.sessions.map(q=>q.id===$.session.id?{...q,...$.session}:q):[$.session,...H.sessions],searchSessions:null}));break}case"session.deleted":{const $=e.payload;t(H=>({unreadSessionIds:Iw(H.unreadSessionIds,$.sessionId),searchSessions:null})),n().listSessions();break}case"session.deletedAll":{t({searchSessions:null}),n().listSessions();break}case"session.running":{const $=e.payload;Mw(e,t,n,H=>({...H,isRunning:$.isRunning})),$.isRunning||t({abortInProgress:!1,queuedMessages:[]}),$.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!bn(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const $=e.payload;t(H=>{if(H.messages.some(X=>X.id===$.message.id))return H;const q=$.message.role==="user";return{messages:[...H.messages,$.message],sessions:H.sessions.map(X=>X.id===e.sessionId&&q?{...X,messageCount:X.messageCount+1}:X)}});break}case"chat.message_updated":{if(!bn(e,((h=n().currentSession)==null?void 0:h.id)??null)){l();break}const $=e.payload,H=n().messages.find(X=>X.id===$.messageId);$.updates.isStreaming===!1&&(H==null?void 0:H.isStreaming)===!0&&Ia(),t(X=>({messages:X.messages.map(Y=>Y.id===$.messageId?{...Y,...$.updates}:Y)}));break}case"chat.delta":{if(!bn(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const $=e.payload;if(!Cg.has($.messageId)){Cg.add($.messageId);const q=$.subAgentType?"sub-agent":qo(n(),e.sessionId);j5(q)}const H=Pc();H.messageId=$.messageId,H.deltaContent+=$.content,_g();break}case"chat.thinking":{if(!bn(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const $=e.payload,H=Pc();H.messageId=$.messageId,H.thinkingContent+=$.content,_g();break}case"chat.tool_preparing":{if(!bn(e,((g=n().currentSession)==null?void 0:g.id)??null)){l();break}const $=e.payload;t(H=>{var R;const q=H.messages.find(W=>W.id===$.messageId);if(!q)return{};if((R=q.toolCalls)==null?void 0:R.find((W,B)=>B===$.index))return{};const Y=q.preparingToolCalls??[],F=Y.findIndex(W=>W.index===$.index);let I;return F>=0?I=Y.map((W,B)=>B===F?{...W,arguments:$.arguments}:W):I=[...Y,{index:$.index,name:$.name,...$.arguments?{arguments:$.arguments}:{}}],{messages:H.messages.map(W=>W.id===$.messageId?{...W,preparingToolCalls:I}:W)}});break}case"chat.tool_call":{if(!bn(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const $=e.payload,H=q=>{var R;const X=(q.toolCalls??[]).length,Y=(R=q.preparingToolCalls)==null?void 0:R.filter(W=>W.index!==X),F=Pc(),I=F.toolOutput.filter(W=>W.callId===$.callId);return I.length>0&&(F.toolOutput=F.toolOutput.filter(W=>W.callId!==$.callId)),{...q,toolCalls:[...q.toolCalls??[],{id:$.callId,name:$.tool,arguments:$.args,startedAt:Date.now(),...I.length>0?{streamingOutput:I.map(W=>({stream:W.stream,content:W.content,timestamp:Date.now()}))}:{}}],...Y&&Y.length>0?{preparingToolCalls:Y}:{preparingToolCalls:void 0}}};t(q=>c(q,$.messageId,H));break}case"chat.tool_output":{if(!bn(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const $=e.payload,H=Pc();H.messageId=$.messageId,H.toolOutput.push({messageId:$.messageId,callId:$.callId,stream:$.stream,content:$.output}),_g();break}case"chat.tool_result":{if(!bn(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const $=e.payload,H=q=>{var Y;const X=(Y=q.toolCalls)==null?void 0:Y.map(F=>F.id===$.callId?{...F,result:$.result}:F);return{...q,toolCalls:X}};t(q=>c(q,$.messageId,H));break}case"chat.vision_fallback":{if(!bn(e,((_=n().currentSession)==null?void 0:_.id)??null)){l();break}const $=e.payload;t(H=>{const q=`${$.messageId}-${$.attachmentId}`,X={...H.visionFallbackByMessage};return X[q]={type:$.type,attachmentId:$.attachmentId,filename:$.filename,description:$.description},{visionFallbackByMessage:X}});break}case"chat.todo":{if(!bn(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const $=e.payload;t({currentTodos:$.todos});break}case"chat.progress":{if(!bn(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const $=e.payload;console.warn("Progress:",$.message,$.phase);break}case"chat.format_retry":{if(!bn(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const $=e.payload;console.warn("Format retry:",$.attempt,"/",$.maxAttempts);break}case"chat.done":{if(!bn(e,((k=n().currentSession)==null?void 0:k.id)??null)){l();break}Ia(),Cg.delete(e.payload.messageId);const $=e.payload,H=$.stats;t(q=>({messages:q.messages.map(X=>X.id===$.messageId?{...X,isStreaming:!1,stats:H??X.stats,completeReason:$.reason,preparingToolCalls:void 0}:X),visionFallbackByMessage:{}}));break}case"chat.error":{if(!bn(e,((N=n().currentSession)==null?void 0:N.id)??null)){l();break}Ia();const $=e.payload;console.error("Chat error:",$.error,"recoverable:",$.recoverable),t(H=>({error:{code:"CHAT_ERROR",message:$.error},...$.recoverable?{}:{messages:H.messages}}));break}case"chat.path_confirmation":{const $=e.sessionId,H=$===(((E=n().currentSession)==null?void 0:E.id)??null),q=e.payload,X={callId:q.callId,tool:q.tool,paths:q.paths,workdir:q.workdir,reason:q.reason};if(!H){l(),$&&t(Y=>({crossSessionConfirmations:{...Y.crossSessionConfirmations,[$]:kg(Y.crossSessionConfirmations[$]??[],X)},sessionsWithPendingConfirmations:Y.sessionsWithPendingConfirmations.includes($)?Y.sessionsWithPendingConfirmations:[...Y.sessionsWithPendingConfirmations,$]}));break}t(Y=>({pendingPathConfirmations:kg(Y.pendingPathConfirmations,X)}));break}case"session.confirmation_pending":{const $=e.sessionId,H=e.payload,q={callId:H.callId,tool:H.tool,paths:H.paths,workdir:H.workdir,reason:H.reason};$&&t(X=>({crossSessionConfirmations:{...X.crossSessionConfirmations,[$]:kg(X.crossSessionConfirmations[$]??[],q)},sessionsWithPendingConfirmations:X.sessionsWithPendingConfirmations.includes($)?X.sessionsWithPendingConfirmations:[...X.sessionsWithPendingConfirmations,$]}));break}case"session.confirmation_resolved":{const $=e.sessionId,H=e.payload;$&&t(q=>{const Y=(q.crossSessionConfirmations[$]??[]).filter(I=>I.callId!==H.callId),F={...q.crossSessionConfirmations};return Y.length===0?delete F[$]:F[$]=Y,{crossSessionConfirmations:F,sessionsWithPendingConfirmations:Object.keys(F)}});break}case"chat.ask_user":{if(!bn(e,((D=n().currentSession)==null?void 0:D.id)??null)){l();return}const $=e.payload,H={callId:$.callId,question:$.question,type:$.type??"text",options:$.options??void 0};t(q=>({pendingQuestions:[...q.pendingQuestions.filter(X=>X.callId!==$.callId),H]}));break}case"mode.changed":{if(!bn(e,((A=n().currentSession)==null?void 0:A.id)??null)){l();break}const $=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,mode:$.mode}:null}));break}case"phase.changed":{const $=e.payload;Mw(e,t,n,H=>({...H,phase:$.phase}));break}case"workflow.execution_changed":{if(!bn(e,((O=n().currentSession)==null?void 0:O.id)??null)){l();break}const $=e.payload,H={...$.currentStepId?{currentStepId:$.currentStepId}:{},...$.currentStepName?{currentStepName:$.currentStepName}:{},...$.pendingChoices?{pendingChoices:$.pendingChoices}:{}};t(q=>{const X=q.activeWorkflowExecution;return X?{activeWorkflowExecution:{...X,status:$.status,...H}}:{activeWorkflowExecution:{id:$.executionId,sessionId:e.sessionId??"",workflowId:$.workflowId,workflowName:$.workflowName,...$.workflowColor?{workflowColor:$.workflowColor}:{},status:$.status,...H,stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}});break}case"criteria.updated":{if(!bn(e,((P=n().currentSession)==null?void 0:P.id)??null)){l();break}const $=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,criteria:$.criteria}:null}));break}case"metadata.updated":{if(!bn(e,((G=n().currentSession)==null?void 0:G.id)??null)){l();break}const $=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,metadataEntries:{...H.currentSession.metadataEntries,[$.key]:$.entries}}:null}));break}case"context.state":{const $=e.payload,H=bn(e,((z=n().currentSession)==null?void 0:z.id)??null);$.subAgentId?H&&n().updateSubAgentContextState($.subAgentId,$.context):H?t({contextState:$.context}):l();break}case"session.name_generated":{const $=e.payload,H=e.sessionId,q=(V=n().currentSession)==null?void 0:V.id;t(X=>{const Y=X.sessions.map(I=>I.id===H?{...I,title:$.name}:I),F=q===H?X.currentSession?{...X.currentSession,metadata:{...X.currentSession.metadata,title:$.name}}:null:X.currentSession;return{sessions:Y,currentSession:F}});break}case"queue.state":{const $=e.payload;t({queuedMessages:$.messages??[]});break}case"mcp.servers.changed":{const $=e.payload;if($!=null&&$.servers){const H=[...$.servers].sort((q,X)=>q.name.localeCompare(X.name));Qc.getState().setServers(H)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const $=e.payload;t({gitStatus:{branch:$.branch,diff:$.diff}});break}case"devServer.output":case"devServer.state":{Jn.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Hc.getState().handleMessage(e.type,e.payload);break}case"tasks.update":{It.getState().handleTasksUpdate(e.payload);break}case"error":{const $=e.payload;console.error("Server error:",$),t({error:{code:$.code,message:$.message}});break}}}let _c=!1,vs=null;const jg=new Set,wa=new Set,Hd=new Map;let Sc=null;function Bw(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 $w(e,t,n,r,a){try{const c=await(await xe(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();c.queueState&&a({queuedMessages:c.queueState})}catch(l){console.error("Error queueing message:",l)}}function zw(e,t){return e.map(n=>{var a,l;const r=t.sessions.find(c=>c.id===n.id);return{...n,title:n.title??(r==null?void 0:r.title),mode:((a=t.currentSession)==null?void 0:a.id)===n.id?t.currentSession.mode:(r==null?void 0:r.mode)??n.mode,phase:((l=t.currentSession)==null?void 0:l.id)===n.id?t.currentSession.phase:(r==null?void 0:r.phase)??n.phase,isRunning:n.isRunning&&(r==null?void 0:r.isRunning)!==!1,messageCount:n.messageCount,...n.recentUserPrompts!==void 0&&{recentUserPrompts:n.recentUserPrompts}}})}const Re=Kn((e,t)=>{f5(()=>{const r=Pc();if(!r.messageId)return;const a=r.deltaContent.length>0,l=r.thinkingContent.length>0,c=r.toolOutput.length>0;if(!a&&!l&&!c)return;const u=r.deltaContent,d=r.thinkingContent,h=r.toolOutput;r.deltaContent="",r.thinkingContent="",r.toolOutput=[],e(p=>{const m=p.messages.find(g=>g.id===r.messageId);if(m){const g={...m};if(a&&(g.content=g.content+u),l&&(g.thinkingContent=(g.thinkingContent??"")+d),c){const x=new Set;g.toolCalls=Bw(g.toolCalls,h,x);const w=h.filter(C=>!x.has(C.callId));w.length>0&&r.toolOutput.push(...w)}return{messages:p.messages.map(x=>x.id===r.messageId?g:x)}}if(c){const g=new Set,x=p.messages.map(C=>C.id!==r.messageId?C:{...C,toolCalls:Bw(C.toolCalls,h,g)}),w=h.filter(C=>!g.has(C.callId));return w.length>0&&r.toolOutput.push(...w),{messages:x}}return p})});function n(r,a,l,c,u){return{workflowId:r.workflowId,resumeFrom:r.currentStepId,stepOutput:r.stepOutput,...r.params&&Object.keys(r.params).length>0?{params:r.params}:{},...r.subGroup?{subGroup:r.subGroup}:{},...u?{userChoice:u}:{},...a!=null&&a.trim()?{content:a}:{},...l&&l.length>0?{attachments:l}:{},...c?{messageKind:c}:{}}}return{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],searchSessions:null,currentSession:null,unreadSessionIds:[],messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],crossSessionConfirmations:{},sessionsWithPendingConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,activeWorkflowExecution:null,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 xe("/api/auth")).json()).requiresAuth}catch{}if(a&&!Bt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Bt.onStatusChange(l=>{var c,u;if(e({connectionStatus:l}),l==="connected"){const d=(c=t().currentSession)==null?void 0:c.projectId;d&&t().listSessions(d),Yt.getState().listProjects();const h=(u=t().currentSession)==null?void 0:u.id;h&&t().loadSession(h)}else(l==="disconnected"||l==="reconnecting")&&wa.clear()});try{await Bt.connect(),_c||(_c=!0,vs=Bt.subscribe(l=>{Pw(l,e,t)}))}catch(l){console.error("Failed to connect:",l);const c=Bt.getLastCloseCode();if(!Bt.hasToken()&&(c===1006||c===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}vs&&(vs(),vs=null),_c=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Bt.disconnect(),vs&&(vs(),vs=null),_c=!1,wa.clear(),e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Bt.disconnect(),vs&&(vs(),vs=null),_c=!1,wa.clear(),e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async r=>{try{const a=await fetch(ms("/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();Bt.setToken(l),e({showPasswordModal:!1}),t().connect();const{listProjects:c}=Yt.getState(),{fetchConfig:u}=en.getState();c(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Bt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(r,a)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const c=await xe("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r,title:a})});if(!c.ok)return e({pendingSessionCreate:!1}),null;const u=await c.json();e({searchSessions:null});try{Bt.send("session.load",{sessionId:u.session.id})}catch{}return u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async(r,a=!1)=>{if(!(!a&&jg.has(r))&&!(!a&&wa.has(r))){jg.add(r);try{const l=t().currentSession;if(!l||l.id!==r){wa.clear();const g=l==null?void 0:l.id,x=t().pendingPathConfirmations,C={...t().crossSessionConfirmations};g&&x.length>0&&(C[g]=[...C[g]??[],...x]),Ia(),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(_=>_!==r),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,gitStatus:null,pendingSessionCreate:!1,crossSessionConfirmations:C,sessionsWithPendingConfirmations:Object.keys(C)})}else e({unreadSessionIds:t().unreadSessionIds.filter(g=>g!==r)});const c=o5(r),u=c?c.then(async g=>{if(g.ok)return g.data;const x=await xe(`/api/sessions/${r}`);return x.ok?await x.json():null}):xe(`/api/sessions/${r}`).then(async g=>g.ok?await g.json():null),d=xe(`/api/sessions/${r}/background-processes`),h=await u;if(!h)return;const p=h.messages??[],m={...t().crossSessionConfirmations};delete m[r],e({currentSession:h.session,messages:p,hiddenCount:h.hiddenCount??0,contextState:h.contextState,queuedMessages:h.queueState??[],pendingPathConfirmations:h.pendingConfirmations??[],pendingQuestions:h.pendingQuestions??[],activeWorkflowExecution:h.activeWorkflowExecution??null,crossSessionConfirmations:m,sessionsWithPendingConfirmations:Object.keys(m)}),Bt.send("session.load",{sessionId:r});try{const g=await d;if(g.ok){const x=await g.json();Hc.getState().setProcesses(x.processes??[])}}catch{}wa.add(r)}catch{}finally{jg.delete(r)}}},listSessions:async(r,a=20)=>{const l=r??"global";if(Hd.has(l))return Hd.get(l);const c=(async()=>{var u;try{const d=new URLSearchParams;d.set("limit",String(a)),r&&d.set("projectId",r);const p=await(await xe(`/api/sessions?${d.toString()}`)).json(),m=p.sessions??[];e(x=>({sessions:zw(m,x),sessionsHasMore:r?p.hasMore??!1:!0}));const g=p.pendingConfirmationsBySession;if(g){const x=(u=t().currentSession)==null?void 0:u.id,w={};for(const[C,_]of Object.entries(g))C!==x&&(w[C]=_);e({crossSessionConfirmations:w,sessionsWithPendingConfirmations:Object.keys(w)})}}catch{}finally{Hd.delete(l)}})();return Hd.set(l,c),c},listHomeSessions:async()=>{try{const r=await xe("/api/sessions/home");if(!r.ok)return;const a=await r.json();e(l=>({sessions:zw(a.sessions,l),sessionsHasMore:!1}))}catch{}},ensureFullSessionList:async()=>{if(!t().searchSessions)return Sc||(Sc=(async()=>{try{const l=(await(await xe("/api/sessions")).json()).sessions??[];e({searchSessions:l})}catch{}finally{Sc=null}})(),Sc)},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 u=await(await xe(`/api/sessions?${l.toString()}`)).json(),d=u.sessions??[];e(h=>({sessions:[...h.sessions,...d.map(p=>{const m=h.sessions.find(g=>g.id===p.id);return(m==null?void 0:m.isRunning)===!1?{...p,isRunning:!1}:p})],sessionsHasMore:u.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async r=>{var a;try{return(await xe(`/api/sessions/${r}`,{method:"DELETE"})).ok?(e({searchSessions:null}),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 c=await xe(`/api/sessions/${r}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a})});if(!c.ok)return!1;if(e({searchSessions:null}),await t().listSessions(),((l=t().currentSession)==null?void 0:l.id)===r){const d=await c.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},toggleFavorite:async(r,a)=>{e(l=>({sessions:l.sessions.map(c=>c.id===r?{...c,isFavorite:a}:c)}));try{const l=await xe(`/api/sessions/${r}/favorite`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isFavorite:a})});return l.ok?(await t().listSessions(),!0):(console.warn("Failed to toggle favorite",{sessionId:r,isFavorite:a,status:l.status}),e(c=>({sessions:c.sessions.map(u=>u.id===r?{...u,isFavorite:!a}:u)})),!1)}catch(l){return console.error("Error toggling favorite:",l),e(c=>({sessions:c.sessions.map(u=>u.id===r?{...u,isFavorite:!a}:u)})),!1}},deleteAllSessions:async r=>{try{return(await xe(`/api/projects/${r}/sessions`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Ia(),wa.clear(),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 c=(d=t().currentSession)==null?void 0:d.id;if(!c)return;const u=t().activeWorkflowExecution;if(u&&u.status==="running"){Bt.send("runner.launch",n(u,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 x=await(await xe(`/api/sessions/${c}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)})).json();x.queueState&&e({queuedMessages:x.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){Ia(),e({abortInProgress:!0});try{const c=await(await xe(`/api/sessions/${r}/stop`,{method:"POST"})).json();if(c.queuedMessages&&c.queuedMessages.length>0){const u=c.queuedMessages.map(d=>d.content).join(`
67
+ `);e({restoredInput:u})}}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 xe(`/api/sessions/${r}/continue`,{method:"POST"})}catch(l){console.error("Error continuing generation:",l)}},launchWorkflow:(r,a,l,c,u,d)=>{const h={};r!=null&&r.trim()&&(h.content=r),a&&a.length>0&&(h.attachments=a),l&&(h.workflowId=l),c&&(h.subGroup=c),u&&(h.params=u),h.scope=d??"auto",Bt.send("runner.launch",h)},continueWorkflow:r=>{const l=t().activeWorkflowExecution;!l||l.status!=="waiting"||Bt.send("runner.launch",n(l,void 0,void 0,void 0,r))},exitWorkflow:()=>{Bt.send("workflow.exit",{})},switchMode:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const c=await xe(`/api/sessions/${a}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})});if(!c.ok){console.error("Failed to switch mode:",await c.json());return}const u=await c.json();u.session&&e({currentSession:u.session}),u.messages&&e({messages:u.messages,hiddenCount:u.hiddenCount??0})}catch(c){console.error("Error switching mode:",c)}},switchDangerLevel:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const c=await xe(`/api/sessions/${a}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:r})});if(!c.ok){console.error("Failed to switch danger level:",await c.json());return}const u=await c.json();u.session&&e({currentSession:u.session})}catch(c){console.error("Error switching danger level:",c)}},editCriteria:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const c=await xe(`/api/sessions/${a}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:r})});c.ok||console.error("Failed to update criteria:",await c.json())}catch(c){console.error("Error updating criteria:",c)}},compactContext:()=>{Bt.send("context.compact",{})},setSessionProvider:async(r,a)=>{var l;try{const c=(l=t().currentSession)==null?void 0:l.id;if(!c)return null;const u=await xe(`/api/sessions/${c}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r,...a?{model:a}:{}})});if(!u.ok)return null;const d=await u.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 u;const c=(u=t().currentSession)==null?void 0:u.id;if(c)try{const d=await xe(`/api/sessions/${c}/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 u;const c=(u=t().currentSession)==null?void 0:u.id;if(c){try{await xe(`/api/sessions/${c}/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 u;const c=(u=t().currentSession)==null?void 0:u.id;c&&await $w(c,r,a,l,e)},queueCompletion:async(r,a,l)=>{var u;const c=(u=t().currentSession)==null?void 0:u.id;c&&await $w(c,r,a,l,e)},cancelQueued:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await(await xe(`/api/sessions/${a}/queue/${r}`,{method:"DELETE"})).json();u.queueState&&e({queuedMessages:u.queueState})}catch(c){console.error("Error canceling queued message:",c)}},clearError:()=>{e({error:null})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:()=>{e({pendingUpdate:!0})},triggerPendingUpdate:()=>{t().pendingUpdate&&(e({pendingUpdate:!1}),Bt.send("context.applyDynamic",{}))},handleServerMessage:r=>{Pw(r,e,t)}}});function bf(){return Re(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function D5(){return Re(e=>e.abortInProgress)}function R5(){const e=Re(a=>a.connect),t=Re(a=>a.connectionStatus),n=Ra(a=>a.load),r=xl("/p/:projectId/s/:sessionId/readonly")[0];return j.useEffect(()=>{r||e()},[e,r]),j.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const O5="modulepreload",I5=function(e){return"/"+e},Hw={},ne=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let c=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 u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=c(n.map(h=>{if(h=I5(h),h in Hw)return;Hw[h]=!0;const p=h.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":O5,p||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),p)return new Promise((x,w)=>{g.addEventListener("load",x),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return a.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})},M5=[{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"}],P5=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"}]'),Oj={tokens:M5,presets:P5},Ij=Oj.tokens,ir=Oj.presets;function Fw(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function B5(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Kt=Kn((e,t)=>{const n=B5();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:Fw(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:l}=t(),c=r();if(c)try{const u=JSON.parse(c);u.preset&&u.tokens?(a(u.preset),e({basePreset:u.preset}),l(u.tokens)):u.preset?a(u.preset):u.tokens&&l(u.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(ir.find(l=>l.id===r))if(r==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:c,systemLightPreset:u,userPresets:d}=t(),h=l.matches?c:u,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=ir.find(c=>c.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 u,d;const{basePreset:r,customTokens:a,isCustom:l}=t();if(l&&r)return{...((u=ir.find(p=>p.id===r))==null?void 0:u.tokens)??{},...a};if(l)return{...Ij.reduce((h,p)=>({...h,[p.key]:p.defaultValue}),{}),...a};const c=ir.find(h=>h.id===t().currentPreset);return(c==null?void 0:c.tokens)??((d=ir[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([l,c])=>{a.style.setProperty(`--${l}`,c)})},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 ne(async()=>{const{useSettingsStore:l}=await Promise.resolve().then(()=>bc);return{useSettingsStore:l}},void 0);await a.getState().setSetting(Ee.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),ne(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>bc);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=c=>{const{followSystemTheme:u,systemDarkPreset:d,systemLightPreset:h}=t();if(!u)return;const p=c?d:h;t().applyPreset(p),t().saveTheme(JSON.stringify({preset:p}))},l=c=>a(c.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:c}=t(),u=a||c,d=ir.find(m=>m.id===u),h={id:"custom-"+Date.now(),name:r,basePreset:u,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,c)=>c!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:Fw()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),ne(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>bc);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(Ee.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),ne(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>bc);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})),ne(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>bc);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 $5({canLoad:e,projectId:t,currentProjectId:n}){const r=Yt(c=>c.loadProject),a=Re(c=>c.listSessions),l=Re(c=>c.clearSession);j.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),l())},[e,t,n,r,a,l])}function z5({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const l=Re(h=>h.loadSession),c=Yt(h=>h.loadProject),u=Re(h=>h.listSessions),d=Re(h=>h.pendingSessionCreate);j.useEffect(()=>{e&&t&&r!==t&&c(t)},[e,t,r,c]),j.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&u(t)},[e,n,a,l,u,d,t])}function H5({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function vf({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function Mj({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function F5({className:e="w-3 h-3 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function Va({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function Rs({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Pj({className:e="w-3 h-3 text-text-muted",rotate:t,direction:n="down"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:n==="up"?"M5 15l7-7 7 7":"M19 9l-7 7-7-7"})})}function pn(e){return s.jsx(Pj,{direction:"down",...e})}function Bj(e){return s.jsx(Pj,{direction:"up",...e})}function U5({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function dl({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function Uy({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function Vy({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"}),s.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Gy({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function Qr({className:e="w-5 h-5 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function V5({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})})}function G5({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function W5({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function _f({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function q5({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function Uw({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function $j({className:e="w-[18px] h-[18px]"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Wy({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),s.jsx("path",{d:"M9.5 2h4.5v4.5"}),s.jsx("path",{d:"M14 2L7.5 8.5"})]})}function Sf({className:e="w-3 h-3",color:t}){return s.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M8 5v14l11-7z"})})}function es({className:e="w-3 h-3 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function K5({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function wf({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function zj({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function Y5({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return s.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[s.jsx("title",{children:"Running"}),s.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),s.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Zc({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function Cf({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function qy({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function X5({className:e="w-3.5 h-3.5 shrink-0",color:t}){return s.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Ky({className:e="w-5 h-5"}){return s.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"4.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"3",y:"10.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"3",y:"16.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 6.75h11"}),s.jsx("path",{d:"M10 12.75h8"}),s.jsx("path",{d:"M10 18.75h9"})]})}function Hj({className:e="w-4 h-4",color:t}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:t??"currentColor",children:[s.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),s.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})}function J5({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function fi({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function hi({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function Q5({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Ix({className:e="w-2.5 h-2.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function ea({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function Yy({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function Z5({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function e3({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function Vw({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function Mx(){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 Gw(e,t){const n=Bt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Mx(),type:e,payload:t}))}const os=Kn((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 xe(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const l=Bt.ws;if(l&&l.readyState===WebSocket.OPEN)for(const c of a)l.send(JSON.stringify({id:Mx(),type:"terminal.subscribe",payload:{sessionId:c.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await xe("/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(u=>({sessions:[...u.sessions,l]}));const c=Bt.ws;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({id:Mx(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{Gw("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{Gw("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await xe(`/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(c=>c.id!==r);return l.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:l}});break}}}}));Bt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&os.getState().handleMessage(e)});const ui=Kn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(ms(`/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"})}}}})),js={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 Px(e){if(!e)return structuredClone(js);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(js[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(js)}}function Ww(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Ah(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 t3(e){return e.type==="double-press"}function Fj(e){return e.type==="chord"}function n3(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 Uj(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return n3(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===l}function hu(){const e=Lt(t=>t.settings[Ee.KEYBINDINGS]);return Px(e)}function r3(e,t,n){const r=j.useRef(0),a=j.useRef(t);a.current=t,j.useEffect(()=>{if(!e)return;const l=e.threshold??300,c=u=>{if(u.key!==e.key)return;const d=e.key==="Control",h=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!d&&u.ctrlKey||!h&&u.shiftKey||!p&&u.altKey||!m&&u.metaKey)return;const g=Date.now();g-r.current<l?(u.preventDefault(),u.stopPropagation(),a.current(),r.current=0):r.current=g};return window.addEventListener("keydown",c,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",c,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function s3(e,t){const n=j.useRef(t);n.current=t,j.useEffect(()=>{if(!e)return;const r=a=>{Uj(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function eu(e,t,n){r3(e&&t3(e)?e:void 0,t,n),s3(e&&Fj(e)?e:void 0,t)}function i3(e,t,n){const r=j.useRef(n);r.current=n,j.useEffect(()=>{const a=l=>{for(let c=0;c<e.length;c++){const u=e[c];if(!u)continue;const d=t[c];if(d&&Fj(u)&&Uj(l,u)){l.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var mi=jk();const kf=j.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>s.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));kf.displayName="IconButton";const a3="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",di=j.forwardRef((e,t)=>s.jsx(kf,{ref:t,icon:a3,title:"Edit",...e}));di.displayName="EditButton";const o3="M6 18L18 6M6 6l12 12",Xy=j.forwardRef((e,t)=>s.jsx(kf,{ref:t,icon:o3,...e}));Xy.displayName="CloseButton";const l3={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 St({label:e,title:t,headerRight:n,size:r="md",minHeight:a,children:l,footer:c,className:u,onClose:d,isOpen:h,closeOnBackdropClick:p=!0,closeOnEscape:m=!0,showCloseButton:g=!0,scrollable:x=!0}){const[w,C]=j.useState(!1),_=h!==void 0,S=_?h:w,v=j.useCallback(()=>{_||C(!0)},[_]),b=j.useCallback(()=>{_||C(!1),d==null||d()},[_,d]);j.useEffect(()=>{if(!S||!m)return;const N=E=>{if(E.key==="Escape"){const D=document.activeElement;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"))return;E.stopPropagation(),b()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[S,b,m]);const k=e&&(typeof e=="string"?s.jsx("button",{type:"button",onClick:v,className:u,children:e}):s.jsx("span",{onClick:v,className:u,style:{cursor:"pointer"},children:e}));return s.jsxs(s.Fragment,{children:[k,S&&(typeof document<"u"?mi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p?b:void 0}),s.jsxs("div",{role:"dialog",className:`relative w-full ${l3[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||g)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 border-b border-border",children:[t&&s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),s.jsxs("div",{className:"flex items-center gap-2 ml-auto w-full sm:w-auto min-w-0",children:[n,g&&s.jsx(Xy,{onClick:b,"aria-label":"Close"})]})]}),x?s.jsx(dt,{className:"p-4 flex-1 min-h-0",style:a?{minHeight:a}:void 0,children:l}):s.jsx("div",{className:"p-4 flex-1 min-h-0 overflow-hidden flex flex-col",style:a?{minHeight:a}:void 0,children:l}),c&&s.jsx("div",{className:"px-4 py-3 border-t border-border",children:c})]})]}),document.body):null)]})}function c3({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a,disabled:n,onChange:l=>{const c=l.target.value;r(c===t?null:c)},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:x5.map(({url:l,label:c})=>s.jsx("option",{value:l,title:c,children:c.split(" ")[0]},l))}),s.jsx(pn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const qw=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function u3(){const e=Ra(d=>d.settings),t=Ra(d=>d.update),n=Ra(d=>d.updateEvent),r=Ra(d=>d.updateAgentOverride),a=Ra(d=>d.load);j.useEffect(()=>{a()},[a]);const l=async()=>{await b5()==="granted"&&t({...e,browserNotificationEnabled:!0})},c=(d,h,p,m)=>{d==="general"?n(h,{[p]:m}):r(d,h,{[p]:m})},u=(d,h,p)=>{d==="general"?n(h,{customSoundUrl:p}):r(d,h,{customSoundUrl:p})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),s.jsx(Kw,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),s.jsx(Kw,{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&&s.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),s.jsx("div",{className:"border border-border rounded overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),qw.map(d=>s.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),s.jsx("tbody",{children:g5.map(d=>s.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[s.jsx("td",{className:"px-3 py-2",children:s.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),qw.map(h=>{const p=Dj(e,d.key,h.key==="general"?void 0:h.key),m=Aj[d.key];return s.jsx("td",{className:"px-2 py-2 align-top",children:s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:g=>c(h.key,d.key,"soundEnabled",g.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:g=>c(h.key,d.key,"browserNotification",g.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&s.jsx(c3,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:g=>u(h.key,d.key,g)})]})},h.key)})]},d.key))})]})})]})]})}function Kw({label:e,description:t,checked:n,onChange:r}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),r(!n)},children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})})]})}const rt=j.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},l)=>{const c="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",u={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},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 s.jsx("button",{ref:l,className:`${c} ${u[e]} ${d[t]} ${n}`,...a,children:r})});rt.displayName="Button";async function Yw(e,t,n){try{const r=await xe(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}function Ca(e,t){return t?`${e}?workdir=${encodeURIComponent(t)}`:e}const Hn=Kn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,workdir:null,setWorkdir:n=>{e({workdir:n})},fetchSkills:async n=>{const r=n??t().workdir;e({loading:!0});try{const l=await(await xe(Ca("/api/skills",r))).json();e({defaults:l.defaults??[],userItems:l.userItems??[],projectItems:l.projectItems??[],items:l.items??[],selectedDirectory:l.selectedDirectory??null,diagnostics:l.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await xe(Ca(`/api/skills/${n}/toggle`,t().workdir),{method:"POST"})).json();e(l=>({defaults:l.defaults.map(c=>c.id===n?{...c,enabled:a.enabled}:c),userItems:l.userItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c),projectItems:l.projectItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c),items:l.items.map(c=>c.id===n?{...c,enabled:a.enabled}:c)}))}catch{}},fetchSkill:async n=>{try{const r=await xe(Ca(`/api/skills/${n}`,t().workdir));return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await xe(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await Qi("POST",Ca("/api/skills",t().workdir),{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await Qi("PUT",Ca(`/api/skills/${n}`,t().workdir),r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await xe(Ca(`/api/skills/${n}`,t().workdir),{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(c=>c.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>yf(Ca(`/api/skills/${n}/duplicate`,t().workdir),()=>t().fetchSkills(),r),selectDirectory:async n=>Yw("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await xe("/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 Yw("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function fu(){const[e,t]=j.useState({id:null,type:null}),n=j.useCallback(l=>t({id:l,type:"delete"}),[]),r=j.useCallback(()=>t({id:null,type:null}),[]),a=j.useCallback((l,c)=>e.id===l&&e.type===c,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function Lh({onConfirm:e,onCancel:t}){return s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),s.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function Dh({onClick:e}){return s.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:s.jsx(fi,{})})}function tu({onClick:e}){return s.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:s.jsx(dl,{})})}function Xr({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:l,mono:c}){return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,l&&s.jsx("span",{className:"text-text-muted ml-1",children:l})]}),s.jsx("input",{value:t,onChange:u=>n(u.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${c?"font-mono":""} ${a?"opacity-60":""}`})]})}function Vj({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(rt,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(rt,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function il({message:e}){return s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function jf({value:e,onChange:t}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),s.jsxs("select",{value:e,onChange:n=>t(n.target.value),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[s.jsx("option",{value:"user",children:"Global config"}),s.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})}function Gj({description:e,onNew:t,loading:n,hasItems:r,children:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(rt,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?s.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?a:s.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function Wj({label:e="Custom",children:t}){return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t})]})}function qj({description:e,onNew:t,newLabel:n="+ New"}){return s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(rt,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function Jy({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?s.jsx("div",{className:"text-text-muted text-sm",children:n}):t?s.jsx("div",{className:"space-y-4",children:a}):r?s.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function Kj({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:l="my-item",nameHint:c,readOnlyId:u=!1,readOnlyHint:d="(read-only)",onNameChange:h,onIdChange:p}){return s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Xr,{label:n,value:e,onChange:h,placeholder:a,hint:c}),s.jsx(Xr,{label:r,value:t,onChange:p,readOnly:u,placeholder:l,hint:u?d:void 0,mono:!0})]})}function Yj(e={}){const{initialData:t={}}=e,[n,r]=j.useState("list"),[a,l]=j.useState(null),[c,u]=j.useState(""),[d,h]=j.useState(!1),[p,m]=j.useState(t),g=j.useCallback(()=>{m(t),u(""),l(null)},[t]),x=j.useCallback(S=>{r(S),S==="list"&&g()},[g]),w=j.useCallback(S=>{m(v=>typeof S=="function"?S(v):S)},[]),C=j.useCallback((S,v={})=>{l(S),r("edit"),m({...v}),u("")},[]),_=j.useCallback(()=>{l(null),r("edit"),m(t),u("")},[t]);return{view:n,editingId:a,formError:c,saving:d,formData:p,setView:x,setEditingId:l,setFormError:u,setFormData:w,setSaving:h,resetForm:g,startEditing:C,startNew:_}}function hl({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:l="Confirm",confirmVariant:c="primary",disabled:u=!1}){return s.jsx(St,{isOpen:e,onClose:t,title:r,size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"text-text-secondary",children:a}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(rt,{variant:"secondary",onClick:t,disabled:u,children:"Cancel"}),s.jsx(rt,{variant:c,onClick:n,disabled:u,autoFocus:!0,children:l})]})]})})}const d3={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function ta({size:e="md",className:t=""}){return s.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${d3[e]} ${t}`})}function h3({text:e,...t}){return s.jsxs("div",{className:"text-center",children:[s.jsx(ta,{...t,className:"mx-auto mb-4"}),e&&s.jsx("div",{className:"text-text-secondary",children:e})]})}function mu(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function f3(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 Xj(e,t=28){if(e.length<=t)return e;const n=e.includes("\\")?"\\":"/",r=e.split(/[\\/]/).filter(Boolean);if(r.length<=2)return e;const a=r[0],l=r[r.length-1],c=r.slice(1,-1).join(n),u=t-a.length-l.length-3;if(u<0)return e;const d=c.slice(0,Math.floor(u/2)),h=c.slice(-Math.ceil(u/2));return`${e.startsWith(n)?n:""}${a}${n}${d}...${h}${n}${l}`}function zt(){return typeof window>"u"||typeof window.matchMedia!="function"?!0:!window.matchMedia("(hover: none) and (pointer: coarse)").matches}const Ns=j.forwardRef(({className:e="",...t},n)=>s.jsx("input",{ref:n,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...t}));Ns.displayName="Input";function Ef({onSelect:e,onClose:t,initialPath:n}){const[r,a]=j.useState(null),[l,c]=j.useState(!0),[u,d]=j.useState(""),[h,p]=j.useState(-1),m=j.useRef(null),g=j.useRef(null),x=j.useCallback(async b=>{c(!0),d(""),p(-1);try{const k=b?`/api/directories?path=${encodeURIComponent(b)}`:"/api/directories",E=await(await xe(k)).json();a(E)}catch(k){console.error("Failed to load directories:",k)}finally{c(!1)}},[]);j.useEffect(()=>{x(n)},[n,x]);const w=f3((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(b=>u===""||b.name.toLowerCase().includes(u.toLowerCase())))??[],_=[...!u&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(b=>({type:"dir",path:b.path,name:b.name}))];j.useEffect(()=>{p(u?0:-1)},[u,C.length]),j.useEffect(()=>{if(h>=0&&g.current){const b=g.current.querySelector(`[data-index="${h}"]`);b==null||b.scrollIntoView({block:"nearest"})}},[h]);const S=b=>{var k;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?x(_[h].path):e(_[h].path)}else b.key==="Escape"&&(d(""),zt()&&((k=m.current)==null||k.focus()))},v=s.jsx("div",{className:"flex flex-col gap-2",children:s.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return s.jsx(St,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:v,scrollable:!1,children:s.jsxs("div",{ref:g,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[s.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&s.jsx("div",{className:"px-3 pt-3 pb-1",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((b,k)=>s.jsxs("span",{className:"flex items-center shrink-0",children:[s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx("button",{onClick:()=>x(b.path),className:`px-1 ${k===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:b.name})]},b.path)),w.length===0&&s.jsx("button",{onClick:()=>x("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&s.jsx("button",{onClick:()=>e(r.current),className:"ml-auto shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90",children:"Select"})]})}),s.jsx("div",{className:"px-4 py-2",children:s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none flex items-center justify-center",children:s.jsx(hi,{})}),s.jsx(Ns,{autoFocus:zt(),ref:m,value:u,onChange:b=>d(b.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),s.jsx(dt,{className:"flex-1",children:l?s.jsx("div",{className:"p-8 text-center",children:s.jsx(ta,{size:"sm"})}):_.length===0?s.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:u?"No matching directories":"No subdirectories"}):s.jsx("div",{className:"divide-y divide-border",children:_.map((b,k)=>s.jsxs("div",{"data-index":k,className:`group flex items-center ${k===h?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[s.jsxs("button",{onClick:()=>{x(b.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[b.type==="parent"?s.jsx(H5,{className:"w-5 h-5 text-text-muted shrink-0"}):s.jsx(Qr,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"truncate",children:b.name}),b.type==="dir"&&s.jsx(pn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${k===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),b.type==="dir"&&s.jsx("button",{"data-select":"true",tabIndex:k===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 ${k===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${b.name}`,children:"Select"})]},b.path))})})]})})}function Jj(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 m3(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 Jj(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function p3(e){return new Promise((t,n)=>e.file(t,n))}async function Qj(e,t=""){const n=e.createReader(),r=[];for(;;){const l=await new Promise((c,u)=>n.readEntries(c,u));if(!l.length)break;r.push(...l)}return(await Promise.all(r.map(async l=>{const c=t?`${t}/${l.name}`:l.name;return l.isDirectory?Qj(l,c):[{path:c,file:await p3(l)}]}))).flat()}async function g3(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 Jj(n.name,await Qj(n))}function x3({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[l,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(""),[m,g]=j.useState(null),[x,w]=j.useState(!1),C=j.useRef(null);j.useEffect(()=>{var k;(k=C.current)==null||k.setAttribute("webkitdirectory","")},[]);const _=k=>{g(k)},S=async()=>{if(!m||x)return;w(!0);const k=await t(m);if(k&&!k.success){p(k.error??"Cannot use selected folder."),w(!1);return}g(null),c(!1),w(!1)},v=async k=>{d(!0),p("");const N=await a(k);d(!1),N.success||p(N.error??"Failed to install skill package.")},b=async k=>{if(k.preventDefault(),!(!(e!=null&&e.available)||u))try{await v(await g3(k.dataTransfer))}catch(N){p(N instanceof Error?N.message:"Invalid skill folder.")}};return s.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),s.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(rt,{variant:"secondary",onClick:()=>c(!0),children:"Change folder"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(rt,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&s.jsx(rt,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),s.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||u,onClick:()=>{var k;return(k=C.current)==null?void 0:k.click()},onDragOver:k=>k.preventDefault(),onDrop:b,className:"mt-3 w-full rounded border border-dashed border-border px-4 py-5 text-center text-xs text-text-secondary disabled:cursor-not-allowed disabled:opacity-50",children:e!=null&&e.available?u?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),s.jsx("input",{ref:C,hidden:!0,type:"file",multiple:!0,onChange:k=>{var N;if((N=k.target.files)!=null&&N.length)try{v(m3(k.target.files))}catch(E){p(E instanceof Error?E.message:"Invalid skill folder.")}finally{k.target.value=""}}}),h&&s.jsx("p",{className:"mt-2 text-xs text-error",children:h}),l&&s.jsx(Ef,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:_,onClose:()=>c(!1)}),s.jsx(hl,{isOpen:m!==null,onClose:()=>g(null),onConfirm:S,title:"Trust this folder?",message:"Skills may contain instructions and scripts. Select this folder for discovery without executing package content?",confirmLabel:"Trust folder",disabled:x})]})}function ds({enabled:e,onClick:t,label:n,disabled:r}){return s.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:r?void 0:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"} ${r?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function Zj({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:l,onCancelDelete:c,actions:u,children:d}){return s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:d}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&r&&s.jsx(di,{onClick:r}),e&&!r&&n&&s.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:s.jsx(Gy,{})}),s.jsx(tu,{onClick:a}),!e&&r&&s.jsx(di,{onClick:r}),!e&&l&&(t?s.jsx(Lh,{onConfirm:()=>{l==null||l()},onCancel:()=>c==null?void 0:c()}):s.jsx(Dh,{onClick:()=>l==null?void 0:l()})),u]})]})}function y3({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:p}){return s.jsxs(Zj,{isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:p,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&s.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function Xw({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:l,onDelete:c,onToggle:u,readOnly:d=!1}){return s.jsx(y3,{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:c,actions:s.jsx(ds,{enabled:e.enabled,onClick:u,label:`Activation for ${e.name}`})})}function b3({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return s.jsxs(St,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(rt,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),s.jsx(rt,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[s.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),s.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&s.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&s.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function v3({isOpen:e}){const t=Hn(re=>re.defaults),n=Hn(re=>re.userItems),r=Hn(re=>re.projectItems),a=Hn(re=>re.items),l=Hn(re=>re.selectedDirectory),c=Hn(re=>re.diagnostics),u=Hn(re=>re.loading),d=Hn(re=>re.fetchSkills),h=Hn(re=>re.setWorkdir),p=Hn(re=>re.fetchSkill),m=Hn(re=>re.fetchDefaultContent),g=Hn(re=>re.createSkill),x=Hn(re=>re.updateSkill),w=Hn(re=>re.deleteSkill),C=Hn(re=>re.selectDirectory),_=Hn(re=>re.removeDirectory),S=Hn(re=>re.installSkill),v=Hn(re=>re.toggleSkill),b=Re(re=>re.currentSession),[k,N]=j.useState(null),[E,D]=j.useState(!1),[A,O]=j.useState(""),{view:P,editingId:G,formError:z,saving:V,formData:$,setView:H,setEditingId:q,setFormError:X,setFormData:Y,setSaving:F}=Yj(),{clearConfirm:I}=fu();j.useEffect(()=>{if(e){const re=(b==null?void 0:b.workspace)??(b==null?void 0:b.workdir)??null;h(re),d(re),H("list"),q(null),I()}},[e,d,h,I,b==null?void 0:b.workdir,b==null?void 0:b.workspace]);const R=(re,le,ye,_e)=>{Y({name:_e??re.metadata.name,id:ye??re.metadata.id,description:re.metadata.description??"",version:re.metadata.version??"1.0.0",prompt:re.prompt,isReadOnly:le,destination:"user"})},W=async re=>{if(t.some(ye=>ye.id===re)){const ye=await m(re);if(!ye)return;R(ye,!0),q(re),X(""),H("edit")}else{const ye=await p(re);if(!ye)return;R(ye,!0),q(re),X(""),H("edit")}},B=async re=>{const ye=t.some(Oe=>Oe.id===re)?await m(re):await p(re);if(!ye)return;const _e=`${re}-copy-${Date.now()}`;R(ye,!1,_e,`${ye.metadata.name} (copy)`),q(null),X(""),H("edit")},Z=()=>{Y({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),H("edit")},Q=async re=>{const le=await p(re);le&&(R(le,!1),q(re),X(""),H("edit"))},J=async()=>{if(!k)return;D(!0),O("");const re=await w(k.id);if(D(!1),!re.success){O(re.error??"Failed to delete skill.");return}await d(),N(null),I()},U=async()=>{const re=G??$.id;if(!re||!$.name||!$.prompt){X("Name, ID, and prompt are required.");return}F(!0),X("");const le={metadata:{id:re,name:$.name,description:$.description,version:$.version},prompt:$.prompt},ye=G?await x(G,le):await g(le,$.destination);if(F(!1),!ye.success){X(ye.error??"Failed to save skill.");return}H("list")},M=re=>{Y(le=>({...le,name:re})),G||Y(le=>({...le,id:re.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},te=$.isReadOnly;if(P==="edit")return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:te?$.name:G?"Edit Skill":"New Skill"}),s.jsx("button",{onClick:()=>H("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),z&&s.jsx(il,{message:z}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(Kj,{name:$.name,id:$.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:M,onIdChange:()=>{}}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Xr,{label:"Description",value:$.description,onChange:re=>Y(le=>({...le,description:re})),placeholder:"What this skill does...",readOnly:te}),s.jsx(Xr,{label:"Version",value:$.version,onChange:re=>Y(le=>({...le,version:re})),placeholder:"1.0.0",readOnly:te})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:$.prompt,onChange:re=>Y(le=>({...le,prompt:re.target.value})),readOnly:te,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"})]}),!G&&s.jsx(jf,{value:$.destination,onChange:re=>Y(le=>({...le,destination:re}))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[s.jsx(rt,{variant:"secondary",onClick:()=>H("list"),children:"Cancel"}),te?s.jsx(rt,{variant:"primary",onClick:()=>{Y(re=>({...re,name:re.name+" (copy)",id:`${G}-copy-${Date.now()}`,isReadOnly:!1})),q(null)},children:"Duplicate & Customize"}):s.jsx(rt,{variant:"primary",onClick:U,disabled:V||!$.name||!$.id||!$.prompt,children:V?"Saving...":"Save"})]})]});function se({items:re}){return re.map(le=>s.jsx(Xw,{skill:le,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>W(le.id),onEdit:()=>Q(le.id),onDuplicate:()=>B(le.id),onDelete:()=>{O(""),N(le)},onToggle:()=>v(le.id),readOnly:le.readOnly},le.id))}return s.jsxs("div",{children:[s.jsx(b3,{skill:k,deleting:E,error:A,onClose:()=>{E||N(null)},onConfirm:J}),s.jsx(x3,{selectedDirectory:l,onSelect:C,onRemove:_,onRefresh:d,onInstall:S}),c.length>0&&s.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:c.map((re,le)=>s.jsx("p",{children:re},`${re}-${le}`))}),s.jsx(qj,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:Z}),s.jsxs(Jy,{loading:u,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:t.map(re=>s.jsx(Xw,{skill:re,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>W(re.id),onDuplicate:()=>B(re.id),onToggle:()=>v(re.id)},re.id))})]}),n.length>0&&s.jsx(Wj,{children:s.jsx(se,{items:n})}),a.some(re=>["global-shared","selected","project-shared"].includes(re.source))&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),s.jsx("div",{className:"space-y-2",children:s.jsx(se,{items:a.filter(re=>["global-shared","selected","project-shared"].includes(re.source))})})]}),r.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:s.jsx(se,{items:r})})]})]})]})}function na(){const e=Lt(a=>a.settings),t=Lt(a=>a.loading),n=Lt(a=>a.getSetting),r=Lt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function _3({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=na(),l=t[Ee.GLOBAL_INSTRUCTIONS]??"",c=n[Ee.GLOBAL_INSTRUCTIONS]??!1,[u,d]=j.useState(l),[h,p]=j.useState(!1),[m,g]=j.useState(!1);j.useEffect(()=>{e&&r(Ee.GLOBAL_INSTRUCTIONS)},[e,r]),j.useEffect(()=>{d(l),p(!1)},[l]);const x=async()=>{g(!0),await a(Ee.GLOBAL_INSTRUCTIONS,u),g(!1),p(!1)},w=()=>{d(l),p(!1)},C=c||m;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),s.jsx("textarea",{value:u,onChange:_=>{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})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(rt,{variant:"secondary",onClick:w,disabled:!h,children:"Discard"}),s.jsx(rt,{variant:"primary",onClick:x,disabled:!h||C,children:m?"Saving...":"Save"})]})]})}function S3(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 xh(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 w3({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:l,onClose:c,onSave:u}){const[d,h]=j.useState(l),[p,m]=j.useState(r),[g,x]=j.useState(a);j.useEffect(()=>{h(l),m(r)},[l,r]);const w=(b,k)=>{const N=k.startsWith("#")?S3(k):k;h(E=>({...E,[b]:N}))},C=()=>{u(p.trim()||"Untitled",{...d},g)},_=Ij.reduce((b,k)=>{const N=k.category;return b[N]||(b[N]=[]),b[N].push(k),b},{}),S={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},v=ir.find(b=>b.id===n);return s.jsx(St,{isOpen:e,onClose:c,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{type:"button",onClick:c,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:C,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.jsx("input",{type:"text",value: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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Mode"}),s.jsxs("div",{className:"flex rounded overflow-hidden border border-border",children:[s.jsx("button",{type:"button",onClick:()=>x("dark"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="dark"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Dark"}),s.jsx("button",{type:"button",onClick:()=>x("light"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="light"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Light"})]})]})]}),!t&&s.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",s.jsx("span",{className:"text-text-primary",children:v==null?void 0:v.name})]}),Object.entries(_).map(([b,k])=>s.jsxs("div",{className:"space-y-3",children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:S[b]??b}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:k.map(N=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("label",{htmlFor:N.key,className:"text-xs text-text-muted",children:N.label}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"color",id:N.key,value:xh(d[N.key]??N.defaultValue),onChange:E=>w(N.key,E.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),s.jsx("input",{type:"text",value:d[N.key]??N.defaultValue,onChange:E=>w(N.key,E.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 Jw({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:l,onDelete:c}){return s.jsxs("div",{className:"relative group",children:[s.jsxs("button",{type:"button",onClick:r,className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${t?"border-accent-primary bg-bg-tertiary text-text-primary":n?"border-dashed border-accent-primary/50 bg-bg-tertiary/50 text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[s.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:e.id==="system"?"transparent":xh(e.tokens["color-bg-primary"]??"#000"),borderColor:xh(e.tokens["color-border"]??"#000")},children:e.id==="system"?s.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:xh(e.tokens["color-text-primary"]??"#fff")}})}),s.jsx("span",{className:"text-xs",children:e.name})]}),a&&s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),a()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:s.jsx("span",{className:"text-xs",children:"✎"})}),l&&s.jsx("button",{type:"button",onClick:u=>{u.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:s.jsx("span",{className:"text-xs",children:"✎"})}),c&&s.jsx("button",{type:"button",onClick:u=>c(u),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:s.jsx(ea,{className:"w-3 h-3"})})]})}function C3(){const[e,t]=j.useState(null),n=Kt(z=>z.currentPreset),r=Kt(z=>z.isCustom),a=Kt(z=>z.basePreset),l=Kt(z=>z.isSystem),c=Kt(z=>z.systemDarkPreset),u=Kt(z=>z.systemLightPreset),d=Kt(z=>z.applyPreset),h=Kt(z=>z.applyUserPreset),p=Kt(z=>z.deleteUserPreset),m=Kt(z=>z.saveTheme),g=Kt(z=>z.setSystemDarkPreset),x=Kt(z=>z.setSystemLightPreset),w=Kt(z=>z.activeUserPresetId),C=Kt(z=>z.userPresets),_=ir.filter(z=>z.mode==="dark"),S=ir.filter(z=>z.mode==="light"),v=z=>{var V;if(l){const $=C[z];if(!$)return;const H=$.mode??((V=ir.find(q=>q.id===$.basePreset))==null?void 0:V.mode);H==="dark"?g($.id):H==="light"&&x($.id)}else h(z)},b=z=>{const V=ir.find($=>$.id===z);V&&t({type:"new",presetIndex:C.length,basePresetId:z,presetName:V.name+" Copy",mode:V.mode??"dark",tokens:{...V.tokens}})},k=z=>{const V=C[z];if(!V)return;const $=ir.find(q=>q.id===V.basePreset),H=$?{...$.tokens,...V.tokens}:V.tokens;t({type:"edit",presetIndex:z,basePresetId:V.basePreset,presetName:V.name,mode:V.mode??"dark",tokens:H})},N=(z,V,$)=>{if(!e)return;const H=[...C];if(e.type==="new"){const q={id:"custom-"+Date.now(),name:z,basePreset:e.basePresetId,mode:$,tokens:V};H.push(q);const X=H.length-1;Kt.setState({userPresets:H}),Kt.getState().saveUserPresets(),Kt.getState().applyUserPreset(X)}else{const q=H[e.presetIndex];q&&(H[e.presetIndex]={...q,name:z,mode:$,tokens:V}),Kt.setState({userPresets:H}),Kt.getState().saveUserPresets(),Kt.getState().applyUserPreset(e.presetIndex)}t(null)},E=()=>{t(null)},D=(z,V)=>{z.stopPropagation(),p(V)},A=l?"system":r?a:n,O=()=>{l?(d(n),m(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),m(JSON.stringify({preset:"system"})).catch(()=>{}))},P=z=>{if(l){const V=ir.find($=>$.id===z);(V==null?void 0:V.mode)==="dark"?g(z):(V==null?void 0:V.mode)==="light"&&x(z)}else d(z),m(JSON.stringify({preset:z})).catch(()=>{})},G=z=>{const V=ir.find($=>$.id===z.basePreset);return V?{...V.tokens,...z.tokens}:z.tokens};return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),s.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[s.jsx("span",{className:"text-sm text-text-primary font-medium",children:"Follow system theme"}),s.jsx("button",{type:"button",onClick:O,className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${l?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:z,mode:V})=>{const $=V==="dark"?_:S,H=C.filter(q=>{var Y;return(q.mode??((Y=ir.find(F=>F.id===q.basePreset))==null?void 0:Y.mode))===V});return s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:z}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[$.map(q=>s.jsx(Jw,{preset:q,isActive:q.id===A&&!r,isUnderlying:l&&(q.id===c||q.id===u),onClick:()=>P(q.id),onNewFrom:()=>b(q.id)},q.id)),H.map(q=>{const X=C.indexOf(q),Y=G(q);return s.jsx(Jw,{preset:{id:q.id,name:q.name,tokens:Y},isActive:w===q.id,isUnderlying:l&&(q.id===c||q.id===u),onClick:()=>v(X),onEdit:()=>k(X),onDelete:F=>D(F,X)},q.id)})]})]},z)}),e&&s.jsx(w3,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,mode:e.mode,initialTokens:e.tokens,onClose:E,onSave:N})]})}const k3=["monospace","serif","sans-serif"],eE=["JetBrains Mono","Cascadia Mono","Menlo","Consolas","DejaVu Sans Mono","Liberation Mono"],yh=`${eE.map(e=>`"${e}"`).join(", ")}, monospace`,j3=["Andale Mono","Anonymous Pro","Cascadia Code","Cascadia Mono","Consolas","Courier New","DejaVu Sans Mono","Fira Code","Fira Mono","Geist Mono","Hack","IBM Plex Mono","Inconsolata","Iosevka","JetBrains Mono","Liberation Mono","Menlo","Monaco","Noto Sans Mono","Roboto Mono","SF Mono","Source Code Pro","Space Mono","Ubuntu Mono","Victor Mono","CaskaydiaCove Nerd Font","CaskaydiaCove Nerd Font Mono","DejaVuSansMono Nerd Font","FiraCode Nerd Font","FiraCode Nerd Font Mono","Hack Nerd Font","Hack Nerd Font Mono","Iosevka Nerd Font","JetBrainsMono Nerd Font","JetBrainsMono Nerd Font Mono","MesloLGS NF","MesloLGS Nerd Font","SauceCodePro Nerd Font","SauceCodePro Nerd Font Mono","UbuntuMono Nerd Font"],E3="mmmmmmmmmmlliWWWW@0Oo",N3="72px";let wc;function T3(){if(wc!==void 0)return wc;try{wc=document.createElement("canvas").getContext("2d")}catch{wc=null}return wc}function Qy(e){const t=T3();if(!t)throw new Error("Canvas 2D context unavailable");return t.font=`${N3} ${e}`,t.measureText(E3).width}function tE(e,t=Qy){const n=e.trim();if(!n)return!1;try{return k3.some(r=>{const a=t(r);return t(`"${n}", ${r}`)!==a})}catch{return!1}}function A3(e=j3,t=Qy){const n=new Set;for(const r of e)tE(r,t)&&n.add(r);return[...n].sort((r,a)=>r.localeCompare(a))}function L3(e=eE,t=Qy){return e.find(n=>tE(n,t))??""}function D3(e){const t=e.trim();return t?`"${t}", monospace`:""}function R3(e){var n;return(((n=e.split(",")[0])==null?void 0:n.trim())??"").replace(/^['"]|['"]$/g,"")}function O3(){return s.jsx(C3,{})}function I3(){const{settings:e,loading:t,getSetting:n,setSetting:r}=na(),a=t[Ee.DISPLAY_SHOW_THINKING]??!1,l=e[Ee.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[c,u]=j.useState(l);j.useEffect(()=>{n(Ee.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),j.useEffect(()=>{u(l)},[l]);const d=()=>{const v=parseInt(c,10),b=isNaN(v)||v<0?0:Math.min(v,9999);u(String(b)),r(Ee.DISPLAY_MAX_VISIBLE_ITEMS,String(b))},h=[{key:Ee.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Ee.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Ee.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Ee.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Ee.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],p=[{key:Ee.DISPLAY_USE_NATIVE_SCROLLBARS,label:"Use native scrollbars in tool calls",description:"Swap custom styled scrollbars for native ones in tool call views (file previews, arguments, results). Faster, but native scrollbars look different on some platforms.",defaultValue:"false"},{key:Ee.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,label:"Use native scrollbars in code blocks",description:"Swap custom styled scrollbars for native ones in markdown code blocks and tables.",defaultValue:"false"},{key:Ee.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,label:"Collapse large tool calls automatically",description:"Start finished tool calls with large outputs collapsed; click to expand. Speeds up loading long sessions.",defaultValue:"false"},{key:Ee.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,label:"Defer code highlighting while streaming",description:"While a code block is streaming, wait until it closes to highlight it. Smoother streaming, but code stays plain until the end.",defaultValue:"false"},{key:Ee.DISPLAY_FEED_VIRTUALIZATION,label:"Virtualize long feeds",description:"Mount only the most recent items and reveal older ones as you scroll up. Faster on very long sessions, but older history loading is experimental.",defaultValue:"false"},{key:Ee.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews",defaultValue:"true"}],m=[...h,...p],g=Object.fromEntries(h.map(v=>[v.key,e[v.key]??"true"])),x=Object.fromEntries(p.map(v=>[v.key,e[v.key]??v.defaultValue])),w={...g,...x},[C,_]=j.useState(()=>Object.fromEntries(m.map(v=>[v.key,w[v.key]==="true"])));j.useEffect(()=>{m.forEach(v=>n(v.key))},[n]),j.useEffect(()=>{_(Object.fromEntries(m.map(v=>[v.key,w[v.key]==="true"])))},[JSON.stringify(w)]);const S=async v=>{const b=String(!C[v]);_(k=>({...k,[v]:!k[v]})),await r(v,b)};return a?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(O3,{}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Custom CSS"}),s.jsx("p",{className:"text-xs text-text-muted mb-3",children:"Add global CSS overrides for any element."}),s.jsx(B3,{})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),s.jsx(Qw,{toggles:h,local:C,onToggle:S})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Performance"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(Qw,{toggles:p,local:C,onToggle:S}),s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Keep only the last N items in the feed. Set to 0 to show all."})]}),s.jsx("input",{type:"number",min:0,max:9999,value:c,onChange:v=>{const b=v.target.value.replace(/[^0-9]/g,"");u(b)},onBlur:d,onKeyDown:v=>{v.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})]})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Terminal"}),s.jsx(P3,{})]})]})}const M3="~/project  git status ✓ ✗ → 0123 iIlL1 |─┤";function Qw({toggles:e,local:t,onToggle:n}){return s.jsx("div",{className:"space-y-4",children:e.map(({key:r,label:a,description:l})=>s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:a}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:l})]}),s.jsx("button",{type:"button",onClick:()=>n(r),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${t[r]?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t[r]?"translate-x-6":"translate-x-1"}`})})]},r))})}function P3(){const{settings:e,getSetting:t,setSetting:n}=na(),r=e[Ee.DISPLAY_TERMINAL_FONT]??yh,[a,l]=j.useState(r),c=j.useMemo(()=>A3(),[]),u=j.useMemo(()=>L3(),[]);j.useEffect(()=>{t(Ee.DISPLAY_TERMINAL_FONT)},[t]),j.useEffect(()=>{l(r)},[r]);const h=r===yh?u:R3(r),p=h!==""&&!c.includes(h),m=x=>{const w=x.target.value;w&&n(Ee.DISPLAY_TERMINAL_FONT,D3(w))},g=()=>{n(Ee.DISPLAY_TERMINAL_FONT,a.trim()||yh)};return s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Only monospace fonts detected on this machine are listed. If your shell theme uses icons or powerline glyphs, pick a Nerd Font."}),s.jsxs("select",{value:p?"":h,onChange:m,className:"w-full px-2 py-1.5 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",children:[p&&s.jsx("option",{value:"",children:`Custom: ${h}`}),c.length===0&&s.jsx("option",{value:"",children:"No monospace font detected"}),c.map(x=>s.jsx("option",{value:x,style:{fontFamily:`"${x}", monospace`},children:x},x))]}),s.jsx(dt,{horizontal:!0,className:"px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded whitespace-nowrap",style:{fontFamily:r},children:M3}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-text-muted mb-1",children:'Not listed? Enter a CSS font-family manually (e.g. "My Font", monospace)'}),s.jsx("input",{type:"text",value:a,onChange:x=>l(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&g()},className:"w-full px-2 py-1 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})]})]})}function B3(){const{settings:e,getSetting:t,setSetting:n}=na(),r=e[Ee.DISPLAY_CUSTOM_CSS]??"",[a,l]=j.useState(r);j.useEffect(()=>{t(Ee.DISPLAY_CUSTOM_CSS)},[t]),j.useEffect(()=>{l(r)},[r]);const c=()=>{n(Ee.DISPLAY_CUSTOM_CSS,a)};return s.jsx("div",{className:"space-y-2",children:s.jsx("textarea",{value:a,onChange:u=>l(u.target.value),onBlur:c,placeholder:"/* Paste your custom CSS here */",className:"w-full h-32 px-3 py-2 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded resize-y focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})})}function Bx(){const[e,t]=j.useState("Test"),[n,r]=j.useState(""),[a,l]=j.useState(!1),c=j.useCallback(async u=>{t("Testing..."),r(""),l(!1);try{const d=await u();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,c]}function $3(e){try{return new RegExp(e),!0}catch{return!1}}function z3({value:e,onChange:t}){const[n,r]=j.useState({}),a=(d,h)=>{const p=e.patterns.map((m,g)=>g===d?{...m,...h}:m);t({...e,patterns:p})},l=d=>{const h=e.patterns.filter((p,m)=>m!==d);t({...e,patterns:h})},c=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},u=(d,h)=>{r(p=>({...p,[d]:h.length>0&&!$3(h)})),a(d,{pattern:h})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),s.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange: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?s.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[s.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),s.jsx("th",{className:"pb-2 pr-2",children:"Field"}),s.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),s.jsx("th",{className:"pb-2 pr-2",children:"Action"}),s.jsx("th",{className:"pb-2 w-8"})]})}),s.jsx("tbody",{children:e.patterns.map((d,h)=>s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("td",{className:"py-2 pr-2",children:s.jsx("input",{type:"checkbox",checked:d.active,onChange:()=>a(h,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${h+1}`})}),s.jsx("td",{className:"py-2 pr-2",children:s.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:[s.jsx("option",{value:"content",children:"content"}),s.jsx("option",{value:"thinking",children:"thinking"}),s.jsx("option",{value:"both",children:"both"})]})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"text",value:d.pattern,onChange:p=>u(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&&s.jsx("span",{className:`text-sm ${n[h]?"text-red-500":"text-green-500"}`,children:n[h]?"✗":"✓"})]})}),s.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),s.jsx("td",{className:"py-2",children:s.jsx("button",{onClick:()=>l(h),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},h))})]}),s.jsx(rt,{variant:"secondary",onClick:c,children:"Add Pattern"})]})}const Zw=1e3,H3=3e4;function e1({message:e,command:t,hint:n}){return s.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[s.jsx("span",{children:"⚠️"}),s.jsx("p",{className:"text-text-secondary",children:e})]}),s.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:t}),s.jsx("p",{className:"text-xs text-text-muted",children:n})]})}function nE({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=j.useState("ready"),[l,c]=j.useState(""),[u,d]=j.useState(n),[h,p]=j.useState(null),[m,g]=j.useState(null),[x,w]=j.useState(!1),[C,_]=j.useState(!1),[S,v]=j.useState(!1),b=j.useRef(!1),k=j.useRef(null),N=j.useRef(null),E=j.useRef(!0),D=j.useRef(n);D.current=n,j.useEffect(()=>{if(!e)return;let Y=!1;return(async()=>{try{const I=await(await fetch(ms("/api/auto-update/check"))).json();if(Y)return;_(!!I.isService),!D.current&&I.current&&I.latest&&d({current:I.current,latest:I.latest})}catch{Y||_(!1)}})(),()=>{Y=!0}},[e]),j.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const Y=setInterval(()=>{c(F=>F.length>=3?"":F+".")},400);return()=>clearInterval(Y)},[e,r]);const A=j.useCallback(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null),N.current=null},[]),O=j.useCallback(Y=>{g(Y),a("restartFailed")},[]),P=j.useCallback(Y=>{b.current=Y,v(Y)},[]),G=j.useCallback(Y=>{localStorage.setItem("openfox_updated_to",Y),localStorage.setItem("update_pending","true")},[]),z=j.useCallback(async Y=>{a("restarting"),g(null),A();try{await xe("/api/auto-update/restart",{method:"POST"})}catch{}if(!E.current)return;N.current=Date.now();const F=async()=>{if(!E.current){A();return}const I=N.current;if(I!==null&&Date.now()-I>=H3){A(),O("OpenFox could not be reached after restart within 30 seconds. Please restart OpenFox manually.");return}try{const R=await fetch(ms("/api/auto-update/check?force=true"));if(!R.ok)throw new Error(`HTTP ${R.status}`);if((await R.json()).current===Y){A(),G(Y),window.location.reload();return}}catch{}if(!E.current){A();return}k.current=setTimeout(()=>{F()},Zw)};k.current=setTimeout(()=>{F()},Zw)},[A,O,G]),V=j.useCallback(async()=>{a("updating"),g(null);try{const F=await(await xe("/api/auto-update",{method:"POST"})).json();if(F.success){const I=F.version??"unknown";p(I),w(!!F.isService),b.current&&F.isService?z(I):a("complete")}else g(F.error??"Update failed"),a("failed")}catch(Y){g(Y instanceof Error?Y.message:"Update request failed"),a("failed")}},[z]),$=j.useCallback(()=>{const Y=h??(u==null?void 0:u.latest)??null;if(!Y){O("Installed version unknown; cannot verify restart.");return}z(Y)},[h,u,O,z]);j.useEffect(()=>(E.current=!0,()=>{E.current=!1,A()}),[A]),j.useEffect(()=>{e&&(c(""),A(),a("ready"),p(null),g(null),w(!1),_(!1),P(!1))},[e,A,P]);const H=r!=="updating"&&r!=="restarting",q=Y=>Y,X=r==="failed"?"Update Failed":r==="restarting"?"Restarting…":r==="complete"?"Update Complete":r==="restartFailed"?"Restart Not Confirmed":"New OpenFox version available";return s.jsxs(St,{isOpen:e,onClose:H?t:void 0,title:X,size:"md",closeOnBackdropClick:H,showCloseButton:H,children:[s.jsxs("div",{className:"flex flex-col gap-4",children:[u&&s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-text-muted",children:"Current version"}),s.jsx("span",{className:"text-text-primary font-mono",children:q(u.current)})]}),u&&s.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[s.jsx("span",{className:"text-text-muted",children:"Latest version"}),s.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:u.latest})]}),(r==="updating"||r==="restarting")&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),s.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",l]})]}),r==="complete"&&s.jsx("div",{className:"flex flex-col gap-3 mt-2",children:s.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h??(u==null?void 0:u.latest),".",x?' Click "Restart OpenFox now" to apply the update.':" Please restart OpenFox to use the new version."]})}),r==="failed"&&s.jsx(e1,{message:m,command:"openfox update",hint:"Run this command in your terminal to complete the update."}),r==="restartFailed"&&s.jsx(e1,{message:m,command:"openfox service restart",hint:"Run this command in your terminal to restart OpenFox."})]}),r==="ready"&&s.jsx("button",{onClick:V,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="ready"||r==="updating")&&C&&s.jsxs("label",{className:"flex items-center justify-center gap-2 text-xs text-text-muted cursor-pointer select-none mt-2",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:Y=>P(Y.target.checked)}),"Auto-restart once update is done"]}),r==="complete"&&x&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("button",{onClick:$,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Restart OpenFox now"}),s.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium",children:"Later"})]}),r==="complete"&&!x&&s.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"}),(r==="failed"||r==="restartFailed")&&s.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"})]})}function _n({children:e,className:t="",horizontal:n=!1,style:r,scope:a="toolCalls"}){const{useNativeScrollbars:l,useNativeScrollbarsCodeBlocks:c}=Ds();if(a==="codeBlocks"?c:l){const d=n?"overflow-x-auto":"overflow-y-auto";return s.jsx("div",{className:`${d} ${t}`.trim(),style:r,children:e})}return s.jsx(dt,{horizontal:n,className:t,style:r,children:e})}function F3(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const U3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,V3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,G3={};function t1(e,t){return(G3.jsx?V3:U3).test(e)}const W3=/[ \t\n\f\r]/g;function q3(e){return typeof e=="object"?e.type==="text"?n1(e.value):!1:n1(e)}function n1(e){return e.replace(W3,"")===""}let pu=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};pu.prototype.normal={};pu.prototype.property={};pu.prototype.space=void 0;function rE(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new pu(n,r,t)}function $x(e){return e.toLowerCase()}let br=class{constructor(t,n){this.attribute=n,this.property=t}};br.prototype.attribute="";br.prototype.booleanish=!1;br.prototype.boolean=!1;br.prototype.commaOrSpaceSeparated=!1;br.prototype.commaSeparated=!1;br.prototype.defined=!1;br.prototype.mustUseProperty=!1;br.prototype.number=!1;br.prototype.overloadedBoolean=!1;br.prototype.property="";br.prototype.spaceSeparated=!1;br.prototype.space=void 0;let K3=0;const pt=Za(),Tn=Za(),zx=Za(),qe=Za(),Qt=Za(),Ga=Za(),Nr=Za();function Za(){return 2**++K3}const Hx=Object.freeze(Object.defineProperty({__proto__:null,boolean:pt,booleanish:Tn,commaOrSpaceSeparated:Nr,commaSeparated:Ga,number:qe,overloadedBoolean:zx,spaceSeparated:Qt},Symbol.toStringTag,{value:"Module"})),Eg=Object.keys(Hx);let Zy=class extends br{constructor(t,n,r,a){let l=-1;if(super(t,n),r1(this,"space",a),typeof r=="number")for(;++l<Eg.length;){const c=Eg[l];r1(this,Eg[l],(r&Hx[c])===Hx[c])}}};Zy.prototype.defined=!0;function r1(e,t,n){n&&(e[t]=n)}function _l(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new Zy(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[$x(r)]=r,n[$x(l.attribute)]=r}return new pu(t,n,e.space)}const sE=_l({properties:{ariaActiveDescendant:null,ariaAtomic:Tn,ariaAutoComplete:null,ariaBusy:Tn,ariaChecked:Tn,ariaColCount:qe,ariaColIndex:qe,ariaColSpan:qe,ariaControls:Qt,ariaCurrent:null,ariaDescribedBy:Qt,ariaDetails:null,ariaDisabled:Tn,ariaDropEffect:Qt,ariaErrorMessage:null,ariaExpanded:Tn,ariaFlowTo:Qt,ariaGrabbed:Tn,ariaHasPopup:null,ariaHidden:Tn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qt,ariaLevel:qe,ariaLive:null,ariaModal:Tn,ariaMultiLine:Tn,ariaMultiSelectable:Tn,ariaOrientation:null,ariaOwns:Qt,ariaPlaceholder:null,ariaPosInSet:qe,ariaPressed:Tn,ariaReadOnly:Tn,ariaRelevant:null,ariaRequired:Tn,ariaRoleDescription:Qt,ariaRowCount:qe,ariaRowIndex:qe,ariaRowSpan:qe,ariaSelected:Tn,ariaSetSize:qe,ariaSort:null,ariaValueMax:qe,ariaValueMin:qe,ariaValueNow:qe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function iE(e,t){return t in e?e[t]:t}function aE(e,t){return iE(e,t.toLowerCase())}const Y3=_l({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ga,acceptCharset:Qt,accessKey:Qt,action:null,allow:null,allowFullScreen:pt,allowPaymentRequest:pt,allowUserMedia:pt,alpha:pt,alt:null,as:null,async:pt,autoCapitalize:null,autoComplete:Qt,autoFocus:pt,autoPlay:pt,blocking:Qt,capture:null,charSet:null,checked:pt,cite:null,className:Qt,closedBy:null,colorSpace:null,cols:qe,colSpan:qe,command:null,commandFor:null,content:null,contentEditable:Tn,controls:pt,controlsList:Qt,coords:qe|Ga,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pt,defer:pt,dir:null,dirName:null,disabled:pt,download:zx,draggable:Tn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pt,formTarget:null,headers:Qt,height:qe,hidden:zx,high:qe,href:null,hrefLang:null,htmlFor:Qt,httpEquiv:Qt,id:null,imageSizes:null,imageSrcSet:null,inert:pt,inputMode:null,integrity:null,is:null,isMap:pt,itemId:null,itemProp:Qt,itemRef:Qt,itemScope:pt,itemType:Qt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pt,low:qe,manifest:null,max:null,maxLength:qe,media:null,method:null,min:null,minLength:qe,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:qe,pattern:null,ping:Qt,placeholder:null,playsInline:pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pt,referrerPolicy:null,rel:Qt,required:pt,reversed:pt,rows:qe,rowSpan:qe,sandbox:Qt,scope:null,scoped:pt,seamless:pt,selected:pt,shadowRootClonable:pt,shadowRootCustomElementRegistry:pt,shadowRootDelegatesFocus:pt,shadowRootMode:null,shadowRootSerializable:pt,shape:null,size:qe,sizes:null,slot:null,span:qe,spellCheck:Tn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:qe,step:null,style:null,tabIndex:qe,target:null,title:null,translate:null,type:null,typeMustMatch:pt,useMap:null,value:Tn,width:qe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qt,axis:null,background:null,bgColor:null,border:qe,borderColor:null,bottomMargin:qe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:pt,declare:pt,event:null,face:null,frame:null,frameBorder:null,hSpace:qe,leftMargin:qe,link:null,longDesc:null,lowSrc:null,marginHeight:qe,marginWidth:qe,noResize:pt,noHref:pt,noShade:pt,noWrap:pt,object:null,profile:null,prompt:null,rev:null,rightMargin:qe,rules:null,scheme:null,scrolling:Tn,standby:null,summary:null,text:null,topMargin:qe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:qe,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:pt,disablePictureInPicture:pt,disableRemotePlayback:pt,exportParts:Ga,part:Qt,prefix:null,property:null,results:qe,security:null,unselectable:null},space:"html",transform:aE}),X3=_l({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Nr,accentHeight:qe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:qe,amplitude:qe,arabicForm:null,ascent:qe,attributeName:null,attributeType:null,azimuth:qe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:qe,by:null,calcMode:null,capHeight:qe,className:Qt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:qe,diffuseConstant:qe,direction:null,display:null,dur:null,divisor:qe,dominantBaseline:null,download:pt,dx:null,dy:null,edgeMode:null,editable:null,elevation:qe,enableBackground:null,end:null,event:null,exponent:qe,externalResourcesRequired:null,fill:null,fillOpacity:qe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ga,g2:Ga,glyphName:Ga,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:qe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:qe,horizOriginX:qe,horizOriginY:qe,id:null,ideographic:qe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:qe,k:qe,k1:qe,k2:qe,k3:qe,k4:qe,kernelMatrix:Nr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:qe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:qe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:qe,overlineThickness:qe,paintOrder:null,panose1:null,path:null,pathLength:qe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:qe,pointsAtY:qe,pointsAtZ:qe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nr,rev:Nr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nr,requiredFeatures:Nr,requiredFonts:Nr,requiredFormats:Nr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:qe,specularExponent:qe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:qe,strikethroughThickness:qe,string:null,stroke:null,strokeDashArray:Nr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:qe,strokeOpacity:qe,strokeWidth:null,style:null,surfaceScale:qe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Nr,tabIndex:qe,tableValues:null,target:null,targetX:qe,targetY:qe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Nr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:qe,underlineThickness:qe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:qe,values:null,vAlphabetic:qe,vMathematical:qe,vectorEffect:null,vHanging:qe,vIdeographic:qe,version:null,vertAdvY:qe,vertOriginX:qe,vertOriginY:qe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:qe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:iE}),oE=_l({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()}}),lE=_l({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:aE}),cE=_l({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),J3={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"},Q3=/[A-Z]/g,s1=/-[a-z]/g,Z3=/^data[-\w.:]+$/i;function eO(e,t){const n=$x(t);let r=t,a=br;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Z3.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(s1,nO);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!s1.test(l)){let c=l.replace(Q3,tO);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Zy}return new a(r,t)}function tO(e){return"-"+e.toLowerCase()}function nO(e){return e.charAt(1).toUpperCase()}const rO=rE([sE,Y3,oE,lE,cE],"html"),eb=rE([sE,X3,oE,lE,cE],"svg");function sO(e){return e.join(" ").trim()}var zo={},Ng,i1;function iO(){if(i1)return Ng;i1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
68
+ `,h="/",p="*",m="",g="comment",x="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 k($){var H=$.match(t);H&&(v+=H.length);var q=$.lastIndexOf(d);b=~q?$.length-q:b+$.length}function N(){var $={line:v,column:b};return function(H){return H.position=new E($),O(),H}}function E($){this.start=$,this.end={line:v,column:b},this.source=S.source}E.prototype.content=_;function D($){var H=new Error(S.source+":"+v+":"+b+": "+$);if(H.reason=$,H.filename=S.source,H.line=v,H.column=b,H.source=_,!S.silent)throw H}function A($){var H=$.exec(_);if(H){var q=H[0];return k(q),_=_.slice(q.length),H}}function O(){A(n)}function P($){var H;for($=$||[];H=G();)H!==!1&&$.push(H);return $}function G(){var $=N();if(!(h!=_.charAt(0)||p!=_.charAt(1))){for(var H=2;m!=_.charAt(H)&&(p!=_.charAt(H)||h!=_.charAt(H+1));)++H;if(H+=2,m===_.charAt(H-1))return D("End of comment missing");var q=_.slice(2,H-2);return b+=2,k(q),_=_.slice(H),b+=2,$({type:g,comment:q})}}function z(){var $=N(),H=A(r);if(H){if(G(),!A(a))return D("property missing ':'");var q=A(l),X=$({type:x,property:C(H[0].replace(e,m)),value:q?C(q[0].replace(e,m)):m});return A(c),X}}function V(){var $=[];P($);for(var H;H=z();)H!==!1&&($.push(H),P($));return $}return O(),V()}function C(_){return _?_.replace(u,m):m}return Ng=w,Ng}var a1;function aO(){if(a1)return zo;a1=1;var e=zo&&zo.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(zo,"__esModule",{value:!0}),zo.default=n;const t=e(iO());function n(r,a){let l=null;if(!r||typeof r!="string")return l;const c=(0,t.default)(r),u=typeof a=="function";return c.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:p}=d;u?a(h,p,d):p&&(l=l||{},l[h]=p)}),l}return zo}var Cc={},o1;function oO(){if(o1)return Cc;o1=1,Object.defineProperty(Cc,"__esModule",{value:!0}),Cc.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)},c=function(h,p){return p.toUpperCase()},u=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,u):h=h.replace(r,u),h.replace(t,c))};return Cc.camelCase=d,Cc}var kc,l1;function lO(){if(l1)return kc;l1=1;var e=kc&&kc.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(aO()),n=oO();function r(a,l){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(u,d){u&&d&&(c[(0,n.camelCase)(u,l)]=d)}),c}return r.default=r,kc=r,kc}var cO=lO();const uO=af(cO),uE=dE("end"),tb=dE("start");function dE(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 dO(e){const t=tb(e),n=uE(e);if(t&&n)return{start:t,end:n}}function Fc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?c1(e.position):"start"in e||"end"in e?c1(e):"line"in e||"column"in e?Fx(e):""}function Fx(e){return u1(e&&e.line)+":"+u1(e&&e.column)}function c1(e){return Fx(e&&e.start)+"-"+Fx(e&&e.end)}function u1(e){return e&&typeof e=="number"?e:1}class tr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",l={},c=!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&&(c=!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 u=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=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=u?u.line:void 0,this.name=Fc(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=c&&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}}tr.prototype.file="";tr.prototype.name="";tr.prototype.reason="";tr.prototype.message="";tr.prototype.stack="";tr.prototype.column=void 0;tr.prototype.line=void 0;tr.prototype.ancestors=void 0;tr.prototype.cause=void 0;tr.prototype.fatal=void 0;tr.prototype.place=void 0;tr.prototype.ruleId=void 0;tr.prototype.source=void 0;const nb={}.hasOwnProperty,hO=new Map,fO=/[A-Z]/g,mO=new Set(["table","tbody","thead","tfoot","tr"]),pO=new Set(["td","th"]),hE="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function gO(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=CO(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=wO(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"?eb:rO,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=fE(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function fE(e,t,n){if(t.type==="element")return xO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return yO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return vO(e,t,n);if(t.type==="mdxjsEsm")return bO(e,t);if(t.type==="root")return _O(e,t,n);if(t.type==="text")return SO(e,t)}function xO(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=eb,e.schema=a),e.ancestors.push(t);const l=pE(e,t.tagName,!1),c=kO(e,t);let u=sb(e,t);return mO.has(t.tagName)&&(u=u.filter(function(d){return typeof d=="string"?!q3(d):!0})),mE(e,c,l,t),rb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,l,c,n)}function yO(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)}nu(e,t.position)}function bO(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);nu(e,t.position)}function vO(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=eb,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:pE(e,t.name,!0),c=jO(e,t),u=sb(e,t);return mE(e,c,l,t),rb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,l,c,n)}function _O(e,t,n){const r={};return rb(r,sb(e,t)),e.create(t,e.Fragment,r,n)}function SO(e,t){return t.value}function mE(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function rb(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function wO(e,t,n){return r;function r(a,l,c,u){const h=Array.isArray(c.children)?n:t;return u?h(l,c,u):h(l,c)}}function CO(e,t){return n;function n(r,a,l,c){const u=Array.isArray(l.children),d=tb(r);return t(a,l,c,u,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function kO(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&nb.call(t.properties,a)){const l=EO(e,a,t.properties[a]);if(l){const[c,u]=l;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&pO.has(t.tagName)?r=u:n[c]=u}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function jO(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 c=l.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else nu(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 u=r.value.data.estree.body[0];u.type,l=e.evaluater.evaluateExpression(u.expression)}else nu(e,t.position);else l=r.value===null?!0:r.value;n[a]=l}return n}function sb(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:hO;for(;++r<t.children.length;){const l=t.children[r];let c;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;c=d+"-"+h,a.set(d,h+1)}}const u=fE(e,l,c);u!==void 0&&n.push(u)}return n}function EO(e,t,n){const r=eO(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?F3(n):sO(n)),r.property==="style"){let a=typeof n=="object"?n:NO(e,String(n));return e.stylePropertyNameCase==="css"&&(a=TO(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?J3[r.property]||r.property:r.attribute,n]}}function NO(e,t){try{return uO(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new tr("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=hE+"#cannot-parse-style-attribute",a}}function pE(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,c;for(;++l<a.length;){const u=t1(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(l&&u.type==="Literal"),optional:!1}:u}r=c}else r=t1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return nb.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);nu(e)}function nu(e,t){const n=new tr("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=hE+"#cannot-handle-mdx-estrees-without-createevaluater",n}function TO(e){const t={};let n;for(n in e)nb.call(e,n)&&(t[AO(n)]=e[n]);return t}function AO(e){let t=e.replace(fO,LO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function LO(e){return"-"+e.toLowerCase()}const Tg={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"]},DO={};function ib(e,t){const n=DO,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return gE(e,r,a)}function gE(e,t,n){if(RO(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 d1(e.children,t,n)}return Array.isArray(e)?d1(e,t,n):""}function d1(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=gE(e[a],t,n);return r.join("")}function RO(e){return!!(e&&typeof e=="object")}const h1=document.createElement("i");function ab(e){const t="&"+e+";";h1.innerHTML=t;const n=h1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Rr(e,t,n,r){const a=e.length;let l=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)c=Array.from(r),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);l<r.length;)c=r.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function Wr(e,t){return e.length>0?(Rr(e,e.length,0,t),e):t}const f1={}.hasOwnProperty;function xE(e){const t={};let n=-1;for(;++n<e.length;)OO(t,e[n]);return t}function OO(e,t){let n;for(n in t){const a=(f1.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let c;if(l)for(c in l){f1.call(a,c)||(a[c]=[]);const u=l[c];IO(a[c],Array.isArray(u)?u:u?[u]:[])}}}function IO(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Rr(e,0,0,r)}function yE(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 hs(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const or=ra(/[A-Za-z]/),er=ra(/[\dA-Za-z]/),MO=ra(/[#-'*+\--9=?A-Z^-~]/);function Rh(e){return e!==null&&(e<32||e===127)}const Ux=ra(/\d/),PO=ra(/[\dA-Fa-f]/),BO=ra(/[!-/:-@[-`{-~]/);function lt(e){return e!==null&&e<-2}function tn(e){return e!==null&&(e<0||e===32)}function kt(e){return e===-2||e===-1||e===32}const Nf=ra(new RegExp("\\p{P}|\\p{S}","u")),Ya=ra(/\s/);function ra(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Sl(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let c="";if(l===37&&er(e.charCodeAt(n+1))&&er(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const u=e.charCodeAt(n+1);l<56320&&u>56319&&u<57344?(c=String.fromCharCode(l,u),a=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(r,n),encodeURIComponent(c)),r=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Tt(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(d){return kt(d)?(e.enter(n),u(d)):t(d)}function u(d){return kt(d)&&l++<a?(e.consume(d),u):(e.exit(n),t(d))}}const $O={tokenize:zO};function zO(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Tt(e,t,"linePrefix")}function a(u){return e.enter("paragraph"),l(u)}function l(u){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,c(u)}function c(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return lt(u)?(e.consume(u),e.exit("chunkText"),l):(e.consume(u),c)}}const HO={tokenize:FO},m1={tokenize:UO};function FO(e){const t=this,n=[];let r=0,a,l,c;return u;function u(b){if(r<n.length){const k=n[r];return t.containerState=k[1],e.attempt(k[0].continuation,d,h)(b)}return h(b)}function d(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&v();const k=t.events.length;let N=k,E;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){E=t.events[N][1].end;break}S(r);let D=k;for(;D<t.events.length;)t.events[D][1].end={...E},D++;return Rr(t.events,N+1,0,t.events.slice(k)),t.events.length=D,h(b)}return u(b)}function h(b){if(r===n.length){if(!a)return g(b);if(a.currentConstruct&&a.currentConstruct.concrete)return w(b);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(m1,p,m)(b)}function p(b){return a&&v(),S(r),g(b)}function m(b){return t.parser.lazy[t.now().line]=r!==n.length,c=t.now().offset,w(b)}function g(b){return t.containerState={},e.attempt(m1,x,w)(b)}function x(b){return r++,n.push([t.currentConstruct,t.containerState]),g(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 lt(b)?(e.consume(b),_(e.exit("chunkFlow")),r=0,t.interrupt=void 0,u):(e.consume(b),C)}function _(b,k){const N=t.sliceStream(b);if(k&&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 E=a.events.length;for(;E--;)if(a.events[E][1].start.offset<c&&(!a.events[E][1].end||a.events[E][1].end.offset>c))return;const D=t.events.length;let A=D,O,P;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(O){P=t.events[A][1].end;break}O=!0}for(S(r),E=D;E<t.events.length;)t.events[E][1].end={...P},E++;Rr(t.events,A+1,0,t.events.slice(D)),t.events.length=E}}function S(b){let k=n.length;for(;k-- >b;){const N=n[k];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 UO(e,t,n){return Tt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function fl(e){if(e===null||tn(e)||Ya(e))return 1;if(Nf(e))return 2}function Tf(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 Vx={name:"attention",resolveAll:VO,tokenize:GO};function VO(e,t){let n=-1,r,a,l,c,u,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},g={...e[n][1].start};p1(m,-d),p1(g,d),c={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...e[r][1].end}},u={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},l={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...c.start},end:{...u.end}},e[r][1].end={...c.start},e[n][1].start={...u.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",c,t],["exit",c,t],["enter",l,t]]),h=Wr(h,Tf(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=Wr(h,[["exit",l,t],["enter",u,t],["exit",u,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,Rr(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 GO(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=fl(r);let l;return c;function c(d){return l=d,e.enter("attentionSequence"),u(d)}function u(d){if(d===l)return e.consume(d),u;const h=e.exit("attentionSequence"),p=fl(d),m=!p||p===2&&a||n.includes(d),g=!a||a===2&&p||n.includes(r);return h._open=!!(l===42?m:m&&(a||!g)),h._close=!!(l===42?g:g&&(p||!m)),t(d)}}function p1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const WO={name:"autolink",tokenize:qO};function qO(e,t,n){let r=0;return a;function a(x){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(x){return or(x)?(e.consume(x),c):x===64?n(x):h(x)}function c(x){return x===43||x===45||x===46||er(x)?(r=1,u(x)):h(x)}function u(x){return x===58?(e.consume(x),r=0,d):(x===43||x===45||x===46||er(x))&&r++<32?(e.consume(x),u):(r=0,h(x))}function d(x){return x===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):x===null||x===32||x===60||Rh(x)?n(x):(e.consume(x),d)}function h(x){return x===64?(e.consume(x),p):MO(x)?(e.consume(x),h):n(x)}function p(x){return er(x)?m(x):n(x)}function m(x){return x===46?(e.consume(x),r=0,p):x===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):g(x)}function g(x){if((x===45||er(x))&&r++<63){const w=x===45?g:m;return e.consume(x),w}return n(x)}}const gu={partial:!0,tokenize:KO};function KO(e,t,n){return r;function r(l){return kt(l)?Tt(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||lt(l)?t(l):n(l)}}const bE={continuation:{tokenize:XO},exit:JO,name:"blockQuote",tokenize:YO};function YO(e,t,n){const r=this;return a;function a(c){if(c===62){const u=r.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return n(c)}function l(c){return kt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function XO(e,t,n){const r=this;return a;function a(c){return kt(c)?Tt(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(bE,t,n)(c)}}function JO(e){e.exit("blockQuote")}const vE={name:"characterEscape",tokenize:QO};function QO(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 BO(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const _E={name:"characterReference",tokenize:ZO};function ZO(e,t,n){const r=this;let a=0,l,c;return u;function u(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,c=er,p(m))}function h(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=PO,p):(e.enter("characterReferenceValue"),l=7,c=Ux,p(m))}function p(m){if(m===59&&a){const g=e.exit("characterReferenceValue");return c===er&&!ab(r.sliceSerialize(g))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(m)&&a++<l?(e.consume(m),p):n(m)}}const g1={partial:!0,tokenize:tI},x1={concrete:!0,name:"codeFenced",tokenize:eI};function eI(e,t,n){const r=this,a={partial:!0,tokenize:N};let l=0,c=0,u;return d;function d(E){return h(E)}function h(E){const D=r.events[r.events.length-1];return l=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,u=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(E)}function p(E){return E===u?(c++,e.consume(E),p):c<3?n(E):(e.exit("codeFencedFenceSequence"),kt(E)?Tt(e,m,"whitespace")(E):m(E))}function m(E){return E===null||lt(E)?(e.exit("codeFencedFence"),r.interrupt?t(E):e.check(g1,C,k)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(E))}function g(E){return E===null||lt(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(E)):kt(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Tt(e,x,"whitespace")(E)):E===96&&E===u?n(E):(e.consume(E),g)}function x(E){return E===null||lt(E)?m(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(E))}function w(E){return E===null||lt(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(E)):E===96&&E===u?n(E):(e.consume(E),w)}function C(E){return e.attempt(a,k,_)(E)}function _(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),S}function S(E){return l>0&&kt(E)?Tt(e,v,"linePrefix",l+1)(E):v(E)}function v(E){return E===null||lt(E)?e.check(g1,C,k)(E):(e.enter("codeFlowValue"),b(E))}function b(E){return E===null||lt(E)?(e.exit("codeFlowValue"),v(E)):(e.consume(E),b)}function k(E){return e.exit("codeFenced"),t(E)}function N(E,D,A){let O=0;return P;function P(H){return E.enter("lineEnding"),E.consume(H),E.exit("lineEnding"),G}function G(H){return E.enter("codeFencedFence"),kt(H)?Tt(E,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):z(H)}function z(H){return H===u?(E.enter("codeFencedFenceSequence"),V(H)):A(H)}function V(H){return H===u?(O++,E.consume(H),V):O>=c?(E.exit("codeFencedFenceSequence"),kt(H)?Tt(E,$,"whitespace")(H):$(H)):A(H)}function $(H){return H===null||lt(H)?(E.exit("codeFencedFence"),D(H)):A(H)}}}function tI(e,t,n){const r=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}const Ag={name:"codeIndented",tokenize:rI},nI={partial:!0,tokenize:sI};function rI(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),Tt(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?c(h):n(h)}function c(h){return h===null?d(h):lt(h)?e.attempt(nI,c,d)(h):(e.enter("codeFlowValue"),u(h))}function u(h){return h===null||lt(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),u)}function d(h){return e.exit("codeIndented"),t(h)}}function sI(e,t,n){const r=this;return a;function a(c){return r.parser.lazy[r.now().line]?n(c):lt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Tt(e,l,"linePrefix",5)(c)}function l(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):lt(c)?a(c):n(c)}}const iI={name:"codeText",previous:oI,resolve:aI,tokenize:lI};function aI(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 oI(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function lI(e,t,n){let r=0,a,l;return c;function c(m){return e.enter("codeText"),e.enter("codeTextSequence"),u(m)}function u(m){return m===96?(e.consume(m),r++,u):(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)):lt(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||lt(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 cI{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&&jc(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),jc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),jc(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);jc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);jc(this.left,n.reverse())}}}function jc(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 SE(e){const t={};let n=-1,r,a,l,c,u,d,h;const p=new cI(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,uI(p,n)),n=t[n],h=!0);else if(r[1]._container){for(l=n,a=void 0;l--;)if(c=p.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(p.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(r[1].end={...p.get(a)[1].start},u=p.slice(a,n),u.unshift(r),p.splice(a,n-a+1,u))}}return Rr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function uI(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const l=[];let c=n._tokenizer;c||(c=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,d=[],h={};let p,m,g=-1,x=n,w=0,C=0;const _=[C];for(;x;){for(;e.get(++a)[1]!==x;);l.push(a),x._tokenizer||(p=r.sliceStream(x),x.next||p.push(null),m&&c.defineSkip(x.start),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(p),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),m=x,x=x.next}for(x=n;++g<u.length;)u[g][0]==="exit"&&u[g-1][0]==="enter"&&u[g][1].type===u[g-1][1].type&&u[g][1].start.line!==u[g][1].end.line&&(C=g+1,_.push(C),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(c.events=[],x?(x._tokenizer=void 0,x.previous=void 0):_.pop(),g=_.length;g--;){const S=u.slice(_[g],_[g+1]),v=l.pop();d.push([v,v+S.length-1]),e.splice(v,2,S)}for(d.reverse(),g=-1;++g<d.length;)h[w+d[g][0]]=w+d[g][1],w+=d[g][1]-d[g][0]-1;return h}const dI={resolve:fI,tokenize:mI},hI={partial:!0,tokenize:pI};function fI(e){return SE(e),e}function mI(e,t){let n;return r;function r(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(u)}function a(u){return u===null?l(u):lt(u)?e.check(hI,c,l)(u):(e.consume(u),a)}function l(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function c(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function pI(e,t,n){const r=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Tt(e,l,"linePrefix")}function l(c){if(c===null||lt(c))return n(c);const u=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):e.interrupt(r.parser.constructs.flow,n,t)(c)}}function wE(e,t,n,r,a,l,c,u,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),g):S===null||S===32||S===41||Rh(S)?n(S):(e.enter(r),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),C(S))}function g(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(a),e.exit(r),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),x(S))}function x(S){return S===62?(e.exit("chunkString"),e.exit(u),g(S)):S===null||S===60||lt(S)?n(S):(e.consume(S),S===92?w:x)}function w(S){return S===60||S===62||S===92?(e.consume(S),x):x(S)}function C(S){return!p&&(S===null||S===41||tn(S))?(e.exit("chunkString"),e.exit(u),e.exit(c),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||Rh(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 CE(e,t,n,r,a,l){const c=this;let u=0,d;return h;function h(x){return e.enter(r),e.enter(a),e.consume(x),e.exit(a),e.enter(l),p}function p(x){return u>999||x===null||x===91||x===93&&!d||x===94&&!u&&"_hiddenFootnoteSupport"in c.parser.constructs?n(x):x===93?(e.exit(l),e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):lt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===null||x===91||x===93||lt(x)||u++>999?(e.exit("chunkString"),p(x)):(e.consume(x),d||(d=!kt(x)),x===92?g:m)}function g(x){return x===91||x===92||x===93?(e.consume(x),u++,m):m(x)}}function kE(e,t,n,r,a,l){let c;return u;function u(g){return g===34||g===39||g===40?(e.enter(r),e.enter(a),e.consume(g),e.exit(a),c=g===40?41:g,d):n(g)}function d(g){return g===c?(e.enter(a),e.consume(g),e.exit(a),e.exit(r),t):(e.enter(l),h(g))}function h(g){return g===c?(e.exit(l),d(c)):g===null?n(g):lt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Tt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===c||g===null||lt(g)?(e.exit("chunkString"),h(g)):(e.consume(g),g===92?m:p)}function m(g){return g===c||g===92?(e.consume(g),p):p(g)}}function Uc(e,t){let n;return r;function r(a){return lt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):kt(a)?Tt(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const gI={name:"definition",tokenize:yI},xI={partial:!0,tokenize:bI};function yI(e,t,n){const r=this;let a;return l;function l(x){return e.enter("definition"),c(x)}function c(x){return CE.call(r,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function u(x){return a=hs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),d):n(x)}function d(x){return tn(x)?Uc(e,h)(x):h(x)}function h(x){return wE(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function p(x){return e.attempt(xI,m,m)(x)}function m(x){return kt(x)?Tt(e,g,"whitespace")(x):g(x)}function g(x){return x===null||lt(x)?(e.exit("definition"),r.parser.defined.push(a),t(x)):n(x)}}function bI(e,t,n){return r;function r(u){return tn(u)?Uc(e,a)(u):n(u)}function a(u){return kE(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function l(u){return kt(u)?Tt(e,c,"whitespace")(u):c(u)}function c(u){return u===null||lt(u)?t(u):n(u)}}const vI={name:"hardBreakEscape",tokenize:_I};function _I(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return lt(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const SI={name:"headingAtx",resolve:wI,tokenize:CI};function wI(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"},Rr(e,r,n-r+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function CI(e,t,n){let r=0;return a;function a(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),c(p)}function c(p){return p===35&&r++<6?(e.consume(p),c):p===null||tn(p)?(e.exit("atxHeadingSequence"),u(p)):n(p)}function u(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||lt(p)?(e.exit("atxHeading"),t(p)):kt(p)?Tt(e,u,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),u(p))}function h(p){return p===null||p===35||tn(p)?(e.exit("atxHeadingText"),u(p)):(e.consume(p),h)}}const kI=["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"],y1=["pre","script","style","textarea"],jI={concrete:!0,name:"htmlFlow",resolveTo:TI,tokenize:AI},EI={partial:!0,tokenize:DI},NI={partial:!0,tokenize:LI};function TI(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 AI(e,t,n){const r=this;let a,l,c,u,d;return h;function h(B){return p(B)}function p(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),g):B===47?(e.consume(B),l=!0,C):B===63?(e.consume(B),a=3,r.interrupt?t:I):or(B)?(e.consume(B),c=String.fromCharCode(B),_):n(B)}function g(B){return B===45?(e.consume(B),a=2,x):B===91?(e.consume(B),a=5,u=0,w):or(B)?(e.consume(B),a=4,r.interrupt?t:I):n(B)}function x(B){return B===45?(e.consume(B),r.interrupt?t:I):n(B)}function w(B){const Z="CDATA[";return B===Z.charCodeAt(u++)?(e.consume(B),u===Z.length?r.interrupt?t:z:w):n(B)}function C(B){return or(B)?(e.consume(B),c=String.fromCharCode(B),_):n(B)}function _(B){if(B===null||B===47||B===62||tn(B)){const Z=B===47,Q=c.toLowerCase();return!Z&&!l&&y1.includes(Q)?(a=1,r.interrupt?t(B):z(B)):kI.includes(c.toLowerCase())?(a=6,Z?(e.consume(B),S):r.interrupt?t(B):z(B)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):l?v(B):b(B))}return B===45||er(B)?(e.consume(B),c+=String.fromCharCode(B),_):n(B)}function S(B){return B===62?(e.consume(B),r.interrupt?t:z):n(B)}function v(B){return kt(B)?(e.consume(B),v):P(B)}function b(B){return B===47?(e.consume(B),P):B===58||B===95||or(B)?(e.consume(B),k):kt(B)?(e.consume(B),b):P(B)}function k(B){return B===45||B===46||B===58||B===95||er(B)?(e.consume(B),k):N(B)}function N(B){return B===61?(e.consume(B),E):kt(B)?(e.consume(B),N):b(B)}function E(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),d=B,D):kt(B)?(e.consume(B),E):A(B)}function D(B){return B===d?(e.consume(B),d=null,O):B===null||lt(B)?n(B):(e.consume(B),D)}function A(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||tn(B)?N(B):(e.consume(B),A)}function O(B){return B===47||B===62||kt(B)?b(B):n(B)}function P(B){return B===62?(e.consume(B),G):n(B)}function G(B){return B===null||lt(B)?z(B):kt(B)?(e.consume(B),G):n(B)}function z(B){return B===45&&a===2?(e.consume(B),q):B===60&&a===1?(e.consume(B),X):B===62&&a===4?(e.consume(B),R):B===63&&a===3?(e.consume(B),I):B===93&&a===5?(e.consume(B),F):lt(B)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(EI,W,V)(B)):B===null||lt(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),z)}function V(B){return e.check(NI,$,W)(B)}function $(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),H}function H(B){return B===null||lt(B)?V(B):(e.enter("htmlFlowData"),z(B))}function q(B){return B===45?(e.consume(B),I):z(B)}function X(B){return B===47?(e.consume(B),c="",Y):z(B)}function Y(B){if(B===62){const Z=c.toLowerCase();return y1.includes(Z)?(e.consume(B),R):z(B)}return or(B)&&c.length<8?(e.consume(B),c+=String.fromCharCode(B),Y):z(B)}function F(B){return B===93?(e.consume(B),I):z(B)}function I(B){return B===62?(e.consume(B),R):B===45&&a===2?(e.consume(B),I):z(B)}function R(B){return B===null||lt(B)?(e.exit("htmlFlowData"),W(B)):(e.consume(B),R)}function W(B){return e.exit("htmlFlow"),t(B)}}function LI(e,t,n){const r=this;return a;function a(c){return lt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):n(c)}function l(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}function DI(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(gu,t,n)}}const RI={name:"htmlText",tokenize:OI};function OI(e,t,n){const r=this;let a,l,c;return u;function u(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),d}function d(I){return I===33?(e.consume(I),h):I===47?(e.consume(I),N):I===63?(e.consume(I),b):or(I)?(e.consume(I),A):n(I)}function h(I){return I===45?(e.consume(I),p):I===91?(e.consume(I),l=0,w):or(I)?(e.consume(I),v):n(I)}function p(I){return I===45?(e.consume(I),x):n(I)}function m(I){return I===null?n(I):I===45?(e.consume(I),g):lt(I)?(c=m,X(I)):(e.consume(I),m)}function g(I){return I===45?(e.consume(I),x):m(I)}function x(I){return I===62?q(I):I===45?g(I):m(I)}function w(I){const R="CDATA[";return I===R.charCodeAt(l++)?(e.consume(I),l===R.length?C:w):n(I)}function C(I){return I===null?n(I):I===93?(e.consume(I),_):lt(I)?(c=C,X(I)):(e.consume(I),C)}function _(I){return I===93?(e.consume(I),S):C(I)}function S(I){return I===62?q(I):I===93?(e.consume(I),S):C(I)}function v(I){return I===null||I===62?q(I):lt(I)?(c=v,X(I)):(e.consume(I),v)}function b(I){return I===null?n(I):I===63?(e.consume(I),k):lt(I)?(c=b,X(I)):(e.consume(I),b)}function k(I){return I===62?q(I):b(I)}function N(I){return or(I)?(e.consume(I),E):n(I)}function E(I){return I===45||er(I)?(e.consume(I),E):D(I)}function D(I){return lt(I)?(c=D,X(I)):kt(I)?(e.consume(I),D):q(I)}function A(I){return I===45||er(I)?(e.consume(I),A):I===47||I===62||tn(I)?O(I):n(I)}function O(I){return I===47?(e.consume(I),q):I===58||I===95||or(I)?(e.consume(I),P):lt(I)?(c=O,X(I)):kt(I)?(e.consume(I),O):q(I)}function P(I){return I===45||I===46||I===58||I===95||er(I)?(e.consume(I),P):G(I)}function G(I){return I===61?(e.consume(I),z):lt(I)?(c=G,X(I)):kt(I)?(e.consume(I),G):O(I)}function z(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),a=I,V):lt(I)?(c=z,X(I)):kt(I)?(e.consume(I),z):(e.consume(I),$)}function V(I){return I===a?(e.consume(I),a=void 0,H):I===null?n(I):lt(I)?(c=V,X(I)):(e.consume(I),V)}function $(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||tn(I)?O(I):(e.consume(I),$)}function H(I){return I===47||I===62||tn(I)?O(I):n(I)}function q(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function X(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),Y}function Y(I){return kt(I)?Tt(e,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):F(I)}function F(I){return e.enter("htmlTextData"),c(I)}}const ob={name:"labelEnd",resolveAll:BI,resolveTo:$I,tokenize:zI},II={tokenize:HI},MI={tokenize:FI},PI={tokenize:UI};function BI(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&&Rr(e,0,e.length,n),e}function $I(e,t){let n=e.length,r=0,a,l,c,u;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(c){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"&&(c=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[c][1].end}},p={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",d,t],["enter",h,t]],u=Wr(u,e.slice(l+1,l+r+3)),u=Wr(u,[["enter",p,t]]),u=Wr(u,Tf(t.parser.constructs.insideSpan.null,e.slice(l+r+4,c-3),t)),u=Wr(u,[["exit",p,t],e[c-2],e[c-1],["exit",h,t]]),u=Wr(u,e.slice(c+1)),u=Wr(u,[["exit",d,t]]),Rr(e,l,e.length,u),e}function zI(e,t,n){const r=this;let a=r.events.length,l,c;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 u;function u(g){return l?l._inactive?m(g):(c=r.parser.defined.includes(hs(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),d):n(g)}function d(g){return g===40?e.attempt(II,p,c?p:m)(g):g===91?e.attempt(MI,p,c?h:m)(g):c?p(g):m(g)}function h(g){return e.attempt(PI,p,m)(g)}function p(g){return t(g)}function m(g){return l._balanced=!0,n(g)}}function HI(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 tn(m)?Uc(e,l)(m):l(m)}function l(m){return m===41?p(m):wE(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function c(m){return tn(m)?Uc(e,d)(m):p(m)}function u(m){return n(m)}function d(m){return m===34||m===39||m===40?kE(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function h(m){return tn(m)?Uc(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 FI(e,t,n){const r=this;return a;function a(u){return CE.call(r,e,l,c,"reference","referenceMarker","referenceString")(u)}function l(u){return r.parser.defined.includes(hs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function UI(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 VI={name:"labelStartImage",resolveAll:ob.resolveAll,tokenize:GI};function GI(e,t,n){const r=this;return a;function a(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),l}function l(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const WI={name:"labelStartLink",resolveAll:ob.resolveAll,tokenize:qI};function qI(e,t,n){const r=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const Lg={name:"lineEnding",tokenize:KI};function KI(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Tt(e,t,"linePrefix")}}const bh={name:"thematicBreak",tokenize:YI};function YI(e,t,n){let r=0,a;return l;function l(h){return e.enter("thematicBreak"),c(h)}function c(h){return a=h,u(h)}function u(h){return h===a?(e.enter("thematicBreakSequence"),d(h)):r>=3&&(h===null||lt(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===a?(e.consume(h),r++,d):(e.exit("thematicBreakSequence"),kt(h)?Tt(e,u,"whitespace")(h):u(h))}}const mr={continuation:{tokenize:ZI},exit:tM,name:"list",tokenize:QI},XI={partial:!0,tokenize:nM},JI={partial:!0,tokenize:eM};function QI(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,c=0;return u;function u(x){const w=r.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||x===r.containerState.marker:Ux(x)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),x===42||x===45?e.check(bh,n,h)(x):h(x);if(!r.interrupt||x===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(x)}return n(x)}function d(x){return Ux(x)&&++c<10?(e.consume(x),d):(!r.interrupt||c<2)&&(r.containerState.marker?x===r.containerState.marker:x===41||x===46)?(e.exit("listItemValue"),h(x)):n(x)}function h(x){return e.enter("listItemMarker"),e.consume(x),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||x,e.check(gu,r.interrupt?n:p,e.attempt(XI,g,m))}function p(x){return r.containerState.initialBlankLine=!0,l++,g(x)}function m(x){return kt(x)?(e.enter("listItemPrefixWhitespace"),e.consume(x),e.exit("listItemPrefixWhitespace"),g):n(x)}function g(x){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(x)}}function ZI(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(gu,a,l);function a(u){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Tt(e,t,"listItemIndent",r.containerState.size+1)(u)}function l(u){return r.containerState.furtherBlankLines||!kt(u)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,c(u)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(JI,t,c)(u))}function c(u){return r.containerState._closeFlow=!0,r.interrupt=void 0,Tt(e,e.attempt(mr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function eM(e,t,n){const r=this;return Tt(e,a,"listItemIndent",r.containerState.size+1);function a(l){const c=r.events[r.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===r.containerState.size?t(l):n(l)}}function tM(e){e.exit(this.containerState.type)}function nM(e,t,n){const r=this;return Tt(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const c=r.events[r.events.length-1];return!kt(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const b1={name:"setextUnderline",resolveTo:rM,tokenize:sM};function rM(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 c={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",c,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=c,e.push(["exit",c,t]),e}function sM(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,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),u(h)}function u(h){return h===a?(e.consume(h),u):(e.exit("setextHeadingLineSequence"),kt(h)?Tt(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||lt(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const iM={tokenize:aM};function aM(e){const t=this,n=e.attempt(gu,r,e.attempt(this.parser.constructs.flowInitial,a,Tt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(dI,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 oM={resolveAll:EE()},lM=jE("string"),cM=jE("text");function jE(e){return{resolveAll:EE(e==="text"?uM:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],l=n.attempt(a,c,u);return c;function c(p){return h(p)?l(p):u(p)}function u(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 g=-1;if(m)for(;++g<m.length;){const x=m[g];if(!x.previous||x.previous.call(r,r.previous))return!0}return!1}}}function EE(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 uM(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,c=-1,u=0,d;for(;l--;){const h=a[l];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)u++,c--;if(c)break;c=-1}else if(h===-2)d=!0,u++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const h={type:n===e.length||d||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:r.start._bufferIndex+c,_index:r.start._index+l,line:r.end.line,column:r.end.column-u,offset:r.end.offset-u},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const dM={42:mr,43:mr,45:mr,48:mr,49:mr,50:mr,51:mr,52:mr,53:mr,54:mr,55:mr,56:mr,57:mr,62:bE},hM={91:gI},fM={[-2]:Ag,[-1]:Ag,32:Ag},mM={35:SI,42:bh,45:[b1,bh],60:jI,61:b1,95:bh,96:x1,126:x1},pM={38:_E,92:vE},gM={[-5]:Lg,[-4]:Lg,[-3]:Lg,33:VI,38:_E,42:Vx,60:[WO,RI],91:WI,92:[vI,vE],93:ob,95:Vx,96:iI},xM={null:[Vx,oM]},yM={null:[42,95]},bM={null:[]},vM=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:yM,contentInitial:hM,disable:bM,document:dM,flow:mM,flowInitial:fM,insideSpan:xM,string:pM,text:gM},Symbol.toStringTag,{value:"Module"}));function _M(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 c=[],u=[];const d={attempt:D(N),check:D(E),consume:v,enter:b,exit:k,interrupt:D(E,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:x,write:m};let p=t.tokenize.call(h,d);return t.resolveAll&&l.push(t),h;function m(G){return c=Wr(c,G),_(),c[c.length-1]!==null?[]:(A(t,0),h.events=Tf(l,h.events,h),h.events)}function g(G,z){return wM(x(G),z)}function x(G){return SM(c,G)}function w(){const{_bufferIndex:G,_index:z,line:V,column:$,offset:H}=r;return{_bufferIndex:G,_index:z,line:V,column:$,offset:H}}function C(G){a[G.line]=G.column,P()}function _(){let G;for(;r._index<c.length;){const z=c[r._index];if(typeof z=="string")for(G=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===G&&r._bufferIndex<z.length;)S(z.charCodeAt(r._bufferIndex));else S(z)}}function S(G){p=p(G)}function v(G){lt(G)?(r.line++,r.column=1,r.offset+=G===-3?2:1,P()):G!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===c[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=G}function b(G,z){const V=z||{};return V.type=G,V.start=w(),h.events.push(["enter",V,h]),u.push(V),V}function k(G){const z=u.pop();return z.end=w(),h.events.push(["exit",z,h]),z}function N(G,z){A(G,z.from)}function E(G,z){z.restore()}function D(G,z){return V;function V($,H,q){let X,Y,F,I;return Array.isArray($)?W($):"tokenize"in $?W([$]):R($);function R(J){return U;function U(M){const te=M!==null&&J[M],se=M!==null&&J.null,re=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(se)?se:se?[se]:[]];return W(re)(M)}}function W(J){return X=J,Y=0,J.length===0?q:B(J[Y])}function B(J){return U;function U(M){return I=O(),F=J,J.partial||(h.currentConstruct=J),J.name&&h.parser.constructs.disable.null.includes(J.name)?Q():J.tokenize.call(z?Object.assign(Object.create(h),z):h,d,Z,Q)(M)}}function Z(J){return G(F,I),H}function Q(J){return I.restore(),++Y<X.length?B(X[Y]):q}}}function A(G,z){G.resolveAll&&!l.includes(G)&&l.push(G),G.resolve&&Rr(h.events,z,h.events.length-z,G.resolve(h.events.slice(z),h)),G.resolveTo&&(h.events=G.resolveTo(h.events,h))}function O(){const G=w(),z=h.previous,V=h.currentConstruct,$=h.events.length,H=Array.from(u);return{from:$,restore:q};function q(){r=G,h.previous=z,h.currentConstruct=V,h.events.length=$,u=H,P()}}function P(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function SM(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let c;if(n===a)c=[e[n].slice(r,l)];else{if(c=e.slice(n,a),r>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(r):c.shift()}l>0&&c.push(e[a].slice(0,l))}return c}function wM(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const l=e[n];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
69
+ `;break}case-3:{c=`\r
70
+ `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(l)}a=l===-2,r.push(c)}return r.join("")}function CM(e){const r={constructs:xE([vM,...(e||{}).extensions||[]]),content:a($O),defined:[],document:a(HO),flow:a(iM),lazy:{},string:a(lM),text:a(cM)};return r;function a(l){return c;function c(u){return _M(r,l,u)}}}function kM(e){for(;!SE(e););return e}const v1=/[\0\t\n\r]/g;function jM(){let e=1,t="",n=!0,r;return a;function a(l,c,u){const d=[];let h,p,m,g,x;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),m=0,t="",n&&(l.charCodeAt(0)===65279&&m++,n=void 0);m<l.length;){if(v1.lastIndex=m,h=v1.exec(l),g=h&&h.index!==void 0?h.index:l.length,x=l.charCodeAt(g),!h){t=l.slice(m);break}if(x===10&&m===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),m<g&&(d.push(l.slice(m,g)),e+=g-m),x){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=g+1}return u&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const EM=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function NM(e){return e.replace(EM,TM)}function TM(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return yE(n.slice(l?2:1),l?16:10)}return ab(n)||e}const NE={}.hasOwnProperty;function AM(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),LM(n)(kM(CM(n).document().write(jM()(e,t,!0))))}function LM(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Je),autolinkProtocol:O,autolinkEmail:O,atxHeading:l(Oe),blockQuote:l(se),characterEscape:O,characterReference:O,codeFenced:l(re),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(re,c),codeText:l(le,c),codeTextData:O,data:O,codeFlowValue:O,definition:l(ye),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(_e),hardBreakEscape:l(Be),hardBreakTrailing:l(Be),htmlFlow:l(ke,c),htmlFlowData:O,htmlText:l(ke,c),htmlTextData:O,image:l(Ge),label:c,link:l(Je),listItem:l(ue),listItemValue:g,listOrdered:l(ae,m),listUnordered:l(ae),paragraph:l(Me),reference:B,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(Oe),strong:l(fe),thematicBreak:l(He)},exit:{atxHeading:d(),atxHeadingSequence:N,autolink:d(),autolinkEmail:te,autolinkProtocol:M,blockQuote:d(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:Q,characterReferenceMarkerNumeric:Q,characterReferenceValue:J,characterReference:U,codeFenced:d(_),codeFencedFence:C,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:P,codeIndented:d(S),codeText:d(H),codeTextData:P,data:P,definition:d(),definitionDestinationString:k,definitionLabelString:v,definitionTitleString:b,emphasis:d(),hardBreakEscape:d(z),hardBreakTrailing:d(z),htmlFlow:d(V),htmlFlowData:P,htmlText:d($),htmlTextData:P,image:d(X),label:F,labelText:Y,lineEnding:G,link:d(q),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:Z,resourceDestinationString:I,resourceTitleString:R,resource:W,setextHeading:d(A),setextHeadingLineSequence:D,setextHeadingText:E,strong:d(),thematicBreak:d()}};TE(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ie){let Se={type:"root",children:[]};const Le={stack:[Se],tokenStack:[],config:t,enter:u,exit:h,buffer:c,resume:p,data:n},he=[];let me=-1;for(;++me<ie.length;)if(ie[me][1].type==="listOrdered"||ie[me][1].type==="listUnordered")if(ie[me][0]==="enter")he.push(me);else{const We=he.pop();me=a(ie,We,me)}for(me=-1;++me<ie.length;){const We=t[ie[me][0]];NE.call(We,ie[me][1].type)&&We[ie[me][1].type].call(Object.assign({sliceSerialize:ie[me][2].sliceSerialize},Le),ie[me][1])}if(Le.tokenStack.length>0){const We=Le.tokenStack[Le.tokenStack.length-1];(We[1]||_1).call(Le,void 0,We[0])}for(Se.position={start:$i(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:$i(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},me=-1;++me<t.transforms.length;)Se=t.transforms[me](Se)||Se;return Se}function a(ie,Se,Le){let he=Se-1,me=-1,We=!1,Ue,Qe,it,ge;for(;++he<=Le;){const Ve=ie[he];switch(Ve[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ve[0]==="enter"?me++:me--,ge=void 0;break}case"lineEndingBlank":{Ve[0]==="enter"&&(Ue&&!ge&&!me&&!it&&(it=he),ge=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ge=void 0}if(!me&&Ve[0]==="enter"&&Ve[1].type==="listItemPrefix"||me===-1&&Ve[0]==="exit"&&(Ve[1].type==="listUnordered"||Ve[1].type==="listOrdered")){if(Ue){let at=he;for(Qe=void 0;at--;){const ht=ie[at];if(ht[1].type==="lineEnding"||ht[1].type==="lineEndingBlank"){if(ht[0]==="exit")continue;Qe&&(ie[Qe][1].type="lineEndingBlank",We=!0),ht[1].type="lineEnding",Qe=at}else if(!(ht[1].type==="linePrefix"||ht[1].type==="blockQuotePrefix"||ht[1].type==="blockQuotePrefixWhitespace"||ht[1].type==="blockQuoteMarker"||ht[1].type==="listItemIndent"))break}it&&(!Qe||it<Qe)&&(Ue._spread=!0),Ue.end=Object.assign({},Qe?ie[Qe][1].start:Ve[1].end),ie.splice(Qe||he,0,["exit",Ue,Ve[2]]),he++,Le++}if(Ve[1].type==="listItemPrefix"){const at={type:"listItem",_spread:!1,start:Object.assign({},Ve[1].start),end:void 0};Ue=at,ie.splice(he,0,["enter",at,Ve[2]]),he++,Le++,it=void 0,ge=!0}}}return ie[Se][1]._spread=We,Le}function l(ie,Se){return Le;function Le(he){u.call(this,ie(he),he),Se&&Se.call(this,he)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(ie,Se,Le){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([Se,Le||void 0]),ie.position={start:$i(Se.start),end:void 0}}function d(ie){return Se;function Se(Le){ie&&ie.call(this,Le),h.call(this,Le)}}function h(ie,Se){const Le=this.stack.pop(),he=this.tokenStack.pop();if(he)he[0].type!==ie.type&&(Se?Se.call(this,ie,he[0]):(he[1]||_1).call(this,ie,he[0]));else throw new Error("Cannot close `"+ie.type+"` ("+Fc({start:ie.start,end:ie.end})+"): it’s not open");Le.position.end=$i(ie.end)}function p(){return ib(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function g(ie){if(this.data.expectingFirstListItemValue){const Se=this.stack[this.stack.length-2];Se.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function x(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.lang=ie}function w(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.meta=ie}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.value=ie.replace(/(\r?\n|\r)$/g,"")}function v(ie){const Se=this.resume(),Le=this.stack[this.stack.length-1];Le.label=Se,Le.identifier=hs(this.sliceSerialize(ie)).toLowerCase()}function b(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.title=ie}function k(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.url=ie}function N(ie){const Se=this.stack[this.stack.length-1];if(!Se.depth){const Le=this.sliceSerialize(ie).length;Se.depth=Le}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function D(ie){const Se=this.stack[this.stack.length-1];Se.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function O(ie){const Le=this.stack[this.stack.length-1].children;let he=Le[Le.length-1];(!he||he.type!=="text")&&(he=Fe(),he.position={start:$i(ie.start),end:void 0},Le.push(he)),this.stack.push(he)}function P(ie){const Se=this.stack.pop();Se.value+=this.sliceSerialize(ie),Se.position.end=$i(ie.end)}function G(ie){const Se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Le=Se.children[Se.children.length-1];Le.position.end=$i(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Se.type)&&(O.call(this,ie),P.call(this,ie))}function z(){this.data.atHardBreak=!0}function V(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.value=ie}function $(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.value=ie}function H(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.value=ie}function q(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const Se=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=Se,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function X(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const Se=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=Se,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function Y(ie){const Se=this.sliceSerialize(ie),Le=this.stack[this.stack.length-2];Le.label=NM(Se),Le.identifier=hs(Se).toLowerCase()}function F(){const ie=this.stack[this.stack.length-1],Se=this.resume(),Le=this.stack[this.stack.length-1];if(this.data.inReference=!0,Le.type==="link"){const he=ie.children;Le.children=he}else Le.alt=Se}function I(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.url=ie}function R(){const ie=this.resume(),Se=this.stack[this.stack.length-1];Se.title=ie}function W(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function Z(ie){const Se=this.resume(),Le=this.stack[this.stack.length-1];Le.label=Se,Le.identifier=hs(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function Q(ie){this.data.characterReferenceType=ie.type}function J(ie){const Se=this.sliceSerialize(ie),Le=this.data.characterReferenceType;let he;Le?(he=yE(Se,Le==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):he=ab(Se);const me=this.stack[this.stack.length-1];me.value+=he}function U(ie){const Se=this.stack.pop();Se.position.end=$i(ie.end)}function M(ie){P.call(this,ie);const Se=this.stack[this.stack.length-1];Se.url=this.sliceSerialize(ie)}function te(ie){P.call(this,ie);const Se=this.stack[this.stack.length-1];Se.url="mailto:"+this.sliceSerialize(ie)}function se(){return{type:"blockquote",children:[]}}function re(){return{type:"code",lang:null,meta:null,value:""}}function le(){return{type:"inlineCode",value:""}}function ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function _e(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function Be(){return{type:"break"}}function ke(){return{type:"html",value:""}}function Ge(){return{type:"image",title:null,url:"",alt:null}}function Je(){return{type:"link",title:null,url:"",children:[]}}function ae(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function ue(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function Me(){return{type:"paragraph",children:[]}}function fe(){return{type:"strong",children:[]}}function Fe(){return{type:"text",value:""}}function He(){return{type:"thematicBreak"}}}function $i(e){return{line:e.line,column:e.column,offset:e.offset}}function TE(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?TE(e,r):DM(e,r)}}function DM(e,t){let n;for(n in t)if(NE.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 _1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Fc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Fc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Fc({start:t.start,end:t.end})+") is still open")}function RM(e){const t=this;t.parser=n;function n(r){return AM(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function OM(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 IM(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
71
+ `}]}function MM(e,t){const n=t.value?t.value+`
72
+ `:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let 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 PM(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function BM(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $M(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=Sl(r.toLowerCase()),l=e.footnoteOrder.indexOf(r);let c,u=e.footnoteCounts.get(r);u===void 0?(u=0,e.footnoteOrder.push(r),c=e.footnoteOrder.length):c=l+1,u+=1,e.footnoteCounts.set(r,u);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function zM(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 HM(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function AE(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 c=a[a.length-1];return c&&c.type==="text"?c.value+=r:a.push({type:"text",value:r}),a}function FM(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AE(e,t);const a={src:Sl(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 UM(e,t){const n={src:Sl(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 VM(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 GM(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AE(e,t);const a={href:Sl(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 WM(e,t){const n={href:Sl(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 qM(e,t,n){const r=e.all(t),a=n?KM(n):LE(t),l={},c=[];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 u=-1;for(;++u<r.length;){const p=r[u];(a||u!==0||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
73
+ `}),p.type==="element"&&p.tagName==="p"&&!a?c.push(...p.children):c.push(p)}const d=r[r.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&c.push({type:"text",value:`
74
+ `});const h={type:"element",tagName:"li",properties:l,children:c};return e.patch(t,h),e.applyData(t,h)}function KM(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=LE(n[r])}return t}function LE(e){const t=e.spread;return t??e.children.length>1}function YM(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 c=r[a];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.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 XM(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JM(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function QM(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZM(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],c),a.push(c)}if(n.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},u=tb(t.children[1]),d=uE(t.children[t.children.length-1]);u&&d&&(c.position={start:u,end:d}),a.push(c)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,l),e.applyData(t,l)}function e4(e,t,n){const r=n?n.children:void 0,l=(r?r.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,u=c?c.length:t.children.length;let d=-1;const h=[];for(;++d<u;){const m=t.children[d],g={},x=c?c[d]:void 0;x&&(g.align=x);let w={type:"element",tagName:l,properties:g,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 t4(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const S1=9,w1=32;function n4(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const l=[];for(;r;)l.push(C1(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return l.push(C1(t.slice(a),a>0,!1)),l.join("")}function C1(e,t,n){let r=0,a=e.length;if(t){let l=e.codePointAt(r);for(;l===S1||l===w1;)r++,l=e.codePointAt(r)}if(n){let l=e.codePointAt(a-1);for(;l===S1||l===w1;)a--,l=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function r4(e,t){const n={type:"text",value:n4(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function s4(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const i4={blockquote:OM,break:IM,code:MM,delete:PM,emphasis:BM,footnoteReference:$M,heading:zM,html:HM,imageReference:FM,image:UM,inlineCode:VM,linkReference:GM,link:WM,listItem:qM,list:YM,paragraph:XM,root:JM,strong:QM,table:ZM,tableCell:t4,tableRow:e4,text:r4,thematicBreak:s4,toml:Fd,yaml:Fd,definition:Fd,footnoteDefinition:Fd};function Fd(){}const DE=-1,Af=0,Vc=1,Oh=2,lb=3,cb=4,ub=5,db=6,RE=7,OE=8,IE=typeof self=="object"?self:globalThis,k1=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new IE[e](t)},a4=(e,t)=>{const n=(a,l)=>(e.set(l,a),a),r=a=>{if(e.has(a))return e.get(a);const[l,c]=t[a];switch(l){case Af:case DE:return n(c,a);case Vc:{const u=n([],a);for(const d of c)u.push(r(d));return u}case Oh:{const u=n({},a);for(const[d,h]of c)u[r(d)]=r(h);return u}case lb:return n(new Date(c),a);case cb:{const{source:u,flags:d}=c;return n(new RegExp(u,d),a)}case ub:{const u=n(new Map,a);for(const[d,h]of c)u.set(r(d),r(h));return u}case db:{const u=n(new Set,a);for(const d of c)u.add(r(d));return u}case RE:{const{name:u,message:d}=c;return n(typeof IE[u]=="function"?k1(u,d):new Error(d),a)}case OE:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:u}=new Uint8Array(c);return n(new DataView(u),c)}}return n(k1(l,c),a)};return r},j1=e=>a4(new Map,e)(0),Da="",{toString:o4}={},{keys:l4}=Object,Ec=e=>{const t=typeof e;if(t!=="object"||!e)return[Af,t];const n=o4.call(e).slice(8,-1);switch(n){case"Array":return[Vc,Da];case"Object":return[Oh,Da];case"Date":return[lb,Da];case"RegExp":return[cb,Da];case"Map":return[ub,Da];case"Set":return[db,Da];case"DataView":return[Vc,n]}return n.includes("Array")?[Vc,n]:e instanceof Error?[RE,e.name||"Error"]:[Oh,n]},Ud=([e,t])=>e===Af&&(t==="function"||t==="symbol"),c4=(e,t,n,r)=>{const a=(c,u)=>{const d=r.push(c)-1;return n.set(u,d),d},l=c=>{if(n.has(c))return n.get(c);let[u,d]=Ec(c);switch(u){case Af:{let p=c;switch(d){case"bigint":u=OE,p=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return a([DE],c)}return a([u,p],c)}case Vc:{if(d){let g=c;return d==="DataView"?g=new Uint8Array(c.buffer):d==="ArrayBuffer"&&(g=new Uint8Array(c)),a([d,[...g]],c)}const p=[],m=a([u,p],c);for(const g of c)p.push(l(g));return m}case Oh:{if(d)switch(d){case"BigInt":return a([d,c.toString()],c);case"Boolean":case"Number":case"String":return a([d,c.valueOf()],c)}if(t&&"toJSON"in c)return l(c.toJSON());const p=[],m=a([u,p],c);for(const g of l4(c))(e||!Ud(Ec(c[g])))&&p.push([l(g),l(c[g])]);return m}case lb:return a([u,isNaN(c.getTime())?Da:c.toISOString()],c);case cb:{const{source:p,flags:m}=c;return a([u,{source:p,flags:m}],c)}case ub:{const p=[],m=a([u,p],c);for(const[g,x]of c)(e||!(Ud(Ec(g))||Ud(Ec(x))))&&p.push([l(g),l(x)]);return m}case db:{const p=[],m=a([u,p],c);for(const g of c)(e||!Ud(Ec(g)))&&p.push(l(g));return m}}const{message:h}=c;return a([u,{name:d,message:h}],c)};return l},E1=(e,{json:t,lossy:n}={})=>{const r=[];return c4(!(t||n),!!t,new Map,r)(e),r},Ih=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?j1(E1(e,t)):structuredClone(e):(e,t)=>j1(E1(e,t));function u4(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 d4(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function h4(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||u4,r=e.options.footnoteBackLabel||d4,a=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},u=[];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(),g=Sl(m.toLowerCase());let x=0;const w=[],C=e.footnoteCounts.get(m);for(;C!==void 0&&++x<=C;){w.length>0&&w.push({type:"text",value:" "});let v=typeof n=="string"?n:n(d,x);typeof v=="string"&&(v={type:"text",value:v}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,x),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-"+g},children:e.wrap(p,!0)};e.patch(h,S),u.push(S)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...Ih(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
75
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
76
+ `}]}}const Lf=(function(e){if(e==null)return g4;if(typeof e=="function")return Df(e);if(typeof e=="object")return Array.isArray(e)?f4(e):m4(e);if(typeof e=="string")return p4(e);throw new Error("Expected function, string, or object as test")});function f4(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Lf(e[n]);return Df(r);function r(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function m4(e){const t=e;return Df(n);function n(r){const a=r;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function p4(e){return Df(t);function t(n){return n&&n.type===e}}function Df(e){return t;function t(n,r,a){return!!(x4(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function g4(){return!0}function x4(e){return e!==null&&typeof e=="object"&&"type"in e}const ME=[],y4=!0,Gx=!1,b4="skip";function PE(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const l=Lf(a),c=r?-1:1;u(e,void 0,[])();function u(d,h,p){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const x=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(x?"<"+x+">":""))+")"})}return g;function g(){let x=ME,w,C,_;if((!t||l(d,h,p[p.length-1]||void 0))&&(x=v4(n(d,p)),x[0]===Gx))return x;if("children"in d&&d.children){const S=d;if(S.children&&x[0]!==b4)for(C=(r?S.children.length:-1)+c,_=p.concat(S);C>-1&&C<S.children.length;){const v=S.children[C];if(w=u(v,C,_)(),w[0]===Gx)return w;C=typeof w[1]=="number"?w[1]:C+c}}return x}}}function v4(e){return Array.isArray(e)?e:typeof e=="number"?[y4,e]:e==null?ME:[e]}function hb(e,t,n,r){let a,l,c;typeof t=="function"&&typeof n!="function"?(l=void 0,c=t,a=n):(l=t,c=n,a=r),PE(e,l,u,a);function u(d,h){const p=h[h.length-1],m=p?p.children.indexOf(d):void 0;return c(d,m,p)}}const Wx={}.hasOwnProperty,_4={};function S4(e,t){const n=t||_4,r=new Map,a=new Map,l=new Map,c={...i4,...n.handlers},u={all:h,applyData:C4,definitionById:r,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:c,one:d,options:n,patch:w4,wrap:j4};return hb(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?r:a,g=String(p.identifier).toUpperCase();m.has(g)||m.set(g,p)}}),u;function d(p,m){const g=p.type,x=u.handlers[g];if(Wx.call(u.handlers,g)&&x)return x(u,p,m);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in p){const{children:C,..._}=p,S=Ih(_);return S.children=u.all(p),S}return Ih(p)}return(u.options.unknownHandler||k4)(u,p,m)}function h(p){const m=[];if("children"in p){const g=p.children;let x=-1;for(;++x<g.length;){const w=u.one(g[x],p);if(w){if(x&&g[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=N1(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=N1(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function w4(e,t){e.position&&(t.position=dO(e))}function C4(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 c="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:c}}n.type==="element"&&l&&Object.assign(n.properties,Ih(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function k4(e,t){const n=t.data||{},r="value"in t&&!(Wx.call(n,"hProperties")||Wx.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 j4(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
77
+ `});++r<e.length;)r&&n.push({type:"text",value:`
78
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
79
+ `}),n}function N1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function T1(e,t){const n=S4(e,t),r=n.one(e,void 0),a=h4(n),l=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
80
+ `},a),l}function E4(e,t){return e&&"run"in e?async function(n,r){const a=T1(n,{file:r,...t});await e.run(a,r)}:function(n,r){return T1(n,{file:r,...e||t})}}function A1(e){if(e)throw e}var Dg,L1;function N4(){if(L1)return Dg;L1=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 g;for(g in h);return typeof g>"u"||e.call(h,g)},c=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},u=function(h,p){if(p==="__proto__")if(e.call(h,p)){if(r)return r(h,p).value}else return;return h[p]};return Dg=function d(){var h,p,m,g,x,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=u(C,p),g=u(h,p),C!==g&&(v&&g&&(l(g)||(x=a(g)))?(x?(x=!1,w=m&&a(m)?m:[]):w=m&&l(m)?m:{},c(C,{name:p,newValue:d(v,w,g)})):typeof g<"u"&&c(C,{name:p,newValue:g}));return C},Dg}var T4=N4();const Rg=af(T4);function qx(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 A4(){const e=[],t={run:n,use:r};return t;function n(...a){let l=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);u(null,...a);function u(d,...h){const p=e[++l];let m=-1;if(d){c(d);return}for(;++m<a.length;)(h[m]===null||h[m]===void 0)&&(h[m]=a[m]);a=h,p?L4(p,u)(...h):c(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 L4(e,t){let n;return r;function r(...c){const u=e.length>c.length;let d;u&&c.push(a);try{d=e.apply(this,c)}catch(h){const p=h;if(u&&n)throw p;return a(p)}u||(d&&d.then&&typeof d.then=="function"?d.then(l,a):d instanceof Error?a(d):l(d))}function a(c,...u){n||(n=!0,t(c,...u))}function l(c){a(null,c)}}const ks={basename:D4,dirname:R4,extname:O4,join:I4,sep:"/"};function D4(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');xu(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 c=-1,u=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else c<0&&(l=!0,c=a+1),u>-1&&(e.codePointAt(a)===t.codePointAt(u--)?u<0&&(r=a):(u=-1,r=c));return n===r?r=c:r<0&&(r=e.length),e.slice(n,r)}function R4(e){if(xu(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 O4(e){xu(e);let t=e.length,n=-1,r=0,a=-1,l=0,c;for(;t--;){const u=e.codePointAt(t);if(u===47){if(c){r=t+1;break}continue}n<0&&(c=!0,n=t+1),u===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 I4(...e){let t=-1,n;for(;++t<e.length;)xu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":M4(n)}function M4(e){xu(e);const t=e.codePointAt(0)===47;let n=P4(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function P4(e,t){let n="",r=0,a=-1,l=0,c=-1,u,d;for(;++c<=e.length;){if(c<e.length)u=e.codePointAt(c);else{if(u===47)break;u=47}if(u===47){if(!(a===c-1||l===1))if(a!==c-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=c,l=0;continue}}else if(n.length>0){n="",r=0,a=c,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),r=c-a-1;a=c,l=0}else u===46&&l>-1?l++:l=-1}return n}function xu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const B4={cwd:$4};function $4(){return"/"}function Kx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function z4(e){if(typeof e=="string")e=new URL(e);else if(!Kx(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 H4(e)}function H4(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 Og=["history","path","basename","stem","extname","dirname"];class BE{constructor(t){let n;t?Kx(t)?n={path:t}:typeof t=="string"||F4(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":B4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Og.length;){const l=Og[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)Og.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?ks.basename(this.path):void 0}set basename(t){Mg(t,"basename"),Ig(t,"basename"),this.path=ks.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ks.dirname(this.path):void 0}set dirname(t){D1(this.basename,"dirname"),this.path=ks.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ks.extname(this.path):void 0}set extname(t){if(Ig(t,"extname"),D1(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=ks.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Kx(t)&&(t=z4(t)),Mg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ks.basename(this.path,this.extname):void 0}set stem(t){Mg(t,"stem"),Ig(t,"stem"),this.path=ks.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 tr(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 Ig(e,t){if(e&&e.includes(ks.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ks.sep+"`")}function Mg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function D1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function F4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const U4=(function(e){const r=this.constructor.prototype,a=r[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),V4={}.hasOwnProperty;class fb extends U4{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=A4()}copy(){const t=new fb;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Rg(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?($g("data",this.frozen),this.namespace[t]=n,this):V4.call(this.namespace,t)&&this.namespace[t]||void 0:t?($g("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=Vd(t),r=this.parser||this.Parser;return Pg("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Pg("process",this.parser||this.Parser),Bg("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,c){const u=Vd(t),d=r.parse(u);r.run(d,u,function(p,m,g){if(p||!m||!g)return h(p);const x=m,w=r.stringify(x,g);q4(w)?g.value=w:g.result=w,h(p,g)});function h(p,m){p||!m?c(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,r;return this.freeze(),Pg("processSync",this.parser||this.Parser),Bg("processSync",this.compiler||this.Compiler),this.process(t,a),O1("processSync","process",n),r;function a(l,c){n=!0,A1(l),r=c}}run(t,n,r){R1(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(c,u){const d=Vd(n);a.run(t,d,h);function h(p,m,g){const x=m||t;p?u(p):c?c(x):r(void 0,x,g)}}}runSync(t,n){let r=!1,a;return this.run(t,n,l),O1("runSync","run",r),a;function l(c,u){A1(c),a=u,r=!0}}stringify(t,n){this.freeze();const r=Vd(n),a=this.compiler||this.Compiler;return Bg("stringify",a),R1(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if($g("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?u(t):c(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 c(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function c(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");u(h.plugins),h.settings&&(a.settings=Rg(!0,a.settings,h.settings))}function u(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,g=-1;for(;++m<r.length;)if(r[m][0]===h){g=m;break}if(g===-1)r.push([h,...p]);else if(p.length>0){let[x,...w]=p;const C=r[g][1];qx(C)&&qx(x)&&(x=Rg(!0,C,x)),r[g]=[h,x,...w]}}}}const G4=new fb().freeze();function Pg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Bg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function $g(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 R1(e){if(!qx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function O1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Vd(e){return W4(e)?e:new BE(e)}function W4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function q4(e){return typeof e=="string"||K4(e)}function K4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Y4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",I1=[],M1={allowDangerousHtml:!0},X4=/^(https?|ircs?|mailto|xmpp)$/i,J4=[{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 Q4(e){const t=Z4(e),n=eP(e);return tP(t.runSync(t.parse(n),n),e)}function Z4(e){const t=e.rehypePlugins||I1,n=e.remarkPlugins||I1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...M1}:M1;return G4().use(RM).use(n).use(E4,r).use(t)}function eP(e){const t=e.children||"",n=new BE;return typeof t=="string"&&(n.value=t),n}function tP(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,l=t.disallowedElements,c=t.skipHtml,u=t.unwrapDisallowed,d=t.urlTransform||nP;for(const p of J4)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+Y4+p.id,void 0);return hb(e,h),gO(e,{Fragment:s.Fragment,components:a,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function h(p,m,g){if(p.type==="raw"&&g&&typeof m=="number")return c?g.children.splice(m,1):g.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let x;for(x in Tg)if(Object.hasOwn(Tg,x)&&Object.hasOwn(p.properties,x)){const w=p.properties[x],C=Tg[x];(C===null||C.includes(p.tagName))&&(p.properties[x]=d(String(w||""),x,p))}}if(p.type==="element"){let x=n?!n.includes(p.tagName):l?l.includes(p.tagName):!1;if(!x&&r&&typeof m=="number"&&(x=!r(p,m,g)),x&&g&&typeof m=="number")return u&&p.children?g.children.splice(m,1,...p.children):g.children.splice(m,1),m}}}function nP(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||X4.test(e.slice(0,t))?e:""}function P1(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 rP(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function sP(e,t,n){const a=Lf((n||{}).ignore||[]),l=iP(t);let c=-1;for(;++c<l.length;)PE(e,"text",u);function u(h,p){let m=-1,g;for(;++m<p.length;){const x=p[m],w=g?g.children:void 0;if(a(x,w?w.indexOf(x):void 0,g))return;g=x}if(g)return d(h,p)}function d(h,p){const m=p[p.length-1],g=l[c][0],x=l[c][1];let w=0;const _=m.children.indexOf(h);let S=!1,v=[];g.lastIndex=0;let b=g.exec(h.value);for(;b;){const k=b.index,N={index:b.index,input:b.input,stack:[...p,h]};let E=x(...b,N);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?g.lastIndex=k+1:(w!==k&&v.push({type:"text",value:h.value.slice(w,k)}),Array.isArray(E)?v.push(...E):E&&v.push(E),w=k+b[0].length,S=!0),!g.global)break;b=g.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 iP(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([aP(a[0]),oP(a[1])])}return t}function aP(e){return typeof e=="string"?new RegExp(rP(e),"g"):e}function oP(e){return typeof e=="function"?e:function(){return e}}const zg="phrasing",Hg=["autolink","link","image","label"];function lP(){return{transforms:[pP],enter:{literalAutolink:uP,literalAutolinkEmail:Fg,literalAutolinkHttp:Fg,literalAutolinkWww:Fg},exit:{literalAutolink:mP,literalAutolinkEmail:fP,literalAutolinkHttp:dP,literalAutolinkWww:hP}}}function cP(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:zg,notInConstruct:Hg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:zg,notInConstruct:Hg},{character:":",before:"[ps]",after:"\\/",inConstruct:zg,notInConstruct:Hg}]}}function uP(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Fg(e){this.config.enter.autolinkProtocol.call(this,e)}function dP(e){this.config.exit.autolinkProtocol.call(this,e)}function hP(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 fP(e){this.config.exit.autolinkEmail.call(this,e)}function mP(e){this.exit(e)}function pP(e){sP(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,gP],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),xP]],{ignore:["link","linkReference"]})}function gP(e,t,n,r,a){let l="";if(!$E(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!yP(n)))return!1;const c=bP(n+r);if(!c[0])return!1;const u={type:"link",title:null,url:l+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[u,{type:"text",value:c[1]}]:u}function xP(e,t,n,r){return!$E(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function yP(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 bP(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=P1(e,"(");let l=P1(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 $E(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ya(n)||Nf(n))&&(!t||n!==47)}zE.peek=NP;function vP(){this.buffer()}function _P(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function SP(){this.buffer()}function wP(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function CP(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=hs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function kP(e){this.exit(e)}function jP(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=hs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function EP(e){this.exit(e)}function NP(){return"["}function zE(e,t,n,r){const a=n.createTracker(r);let l=a.move("[^");const c=n.enter("footnoteReference"),u=n.enter("reference");return l+=a.move(n.safe(n.associationId(e),{after:"]",before:l})),u(),c(),l+=a.move("]"),l}function TP(){return{enter:{gfmFootnoteCallString:vP,gfmFootnoteCall:_P,gfmFootnoteDefinitionLabelString:SP,gfmFootnoteDefinition:wP},exit:{gfmFootnoteCallString:CP,gfmFootnoteCall:kP,gfmFootnoteDefinitionLabelString:jP,gfmFootnoteDefinition:EP}}}function AP(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:zE},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,l,c){const u=l.createTracker(c);let d=u.move("[^");const h=l.enter("footnoteDefinition"),p=l.enter("label");return d+=u.move(l.safe(l.associationId(r),{before:d,after:"]"})),p(),d+=u.move("]:"),r.children&&r.children.length>0&&(u.shift(4),d+=u.move((t?`
81
+ `:" ")+l.indentLines(l.containerFlow(r,u.current()),t?HE:LP))),h(),d}}function LP(e,t,n){return t===0?e:HE(e,t,n)}function HE(e,t,n){return(n?"":" ")+e}const DP=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];FE.peek=PP;function RP(){return{canContainEols:["delete"],enter:{strikethrough:IP},exit:{strikethrough:MP}}}function OP(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:DP}],handlers:{delete:FE}}}function IP(e){this.enter({type:"delete",children:[]},e)}function MP(e){this.exit(e)}function FE(e,t,n,r){const a=n.createTracker(r),l=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),l(),c}function PP(){return"~"}function BP(e){return e.length}function $P(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||BP,l=[],c=[],u=[],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=zP(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)}c[p]=C,u[p]=_}let m=-1;if(typeof r=="object"&&"length"in r)for(;++m<h;)l[m]=B1(r[m]);else{const C=B1(r);for(;++m<h;)l[m]=C}m=-1;const g=[],x=[];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),x[m]=v),g[m]=b}c.splice(1,0,g),u.splice(1,0,x),p=-1;const w=[];for(;++p<c.length;){const C=c[p],_=u[p];m=-1;const S=[];for(;++m<h;){const v=C[m]||"";let b="",k="";if(n.alignDelimiters!==!1){const N=d[m]-(_[m]||0),E=l[m];E===114?b=" ".repeat(N):E===99?N%2?(b=" ".repeat(N/2+.5),k=" ".repeat(N/2-.5)):(b=" ".repeat(N/2),k=b):k=" ".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(k),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(`
82
+ `)}function zP(e){return e==null?"":String(e)}function B1(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 HP(e,t,n,r){const a=n.enter("blockquote"),l=n.createTracker(r);l.move("> "),l.shift(2);const c=n.indentLines(n.containerFlow(e,l.current()),FP);return a(),c}function FP(e,t,n){return">"+(n?"":" ")+e}function UP(e,t){return $1(e,t.inConstruct,!0)&&!$1(e,t.notInConstruct,!1)}function $1(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 z1(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
83
+ `&&UP(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
84
+ `}function VP(e,t){const n=String(e);let r=n.indexOf(t),a=r,l=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++l>c&&(c=l):l=1,a=r+t.length,r=n.indexOf(t,a);return c}function GP(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 WP(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 qP(e,t,n,r){const a=WP(n),l=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(GP(e,n)){const m=n.enter("codeIndented"),g=n.indentLines(l,KP);return m(),g}const u=n.createTracker(r),d=a.repeat(Math.max(VP(l,a)+1,3)),h=n.enter("codeFenced");let p=u.move(d);if(e.lang){const m=n.enter(`codeFencedLang${c}`);p+=u.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...u.current()})),m()}if(e.lang&&e.meta){const m=n.enter(`codeFencedMeta${c}`);p+=u.move(" "),p+=u.move(n.safe(e.meta,{before:p,after:`
85
+ `,encode:["`"],...u.current()})),m()}return p+=u.move(`
86
+ `),l&&(p+=u.move(l+`
87
+ `)),p+=u.move(d),h(),p}function KP(e,t,n){return(n?"":" ")+e}function mb(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 YP(e,t,n,r){const a=mb(n),l=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let u=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("]: "),u(),!e.url||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(u=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":`
88
+ `,...d.current()}))),u(),e.title&&(u=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),u()),c(),h}function XP(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 ru(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Mh(e,t,n){const r=fl(e),a=fl(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}}UE.peek=JP;function UE(e,t,n,r){const a=XP(n),l=n.enter("emphasis"),c=n.createTracker(r),u=c.move(a);let d=c.move(n.containerPhrasing(e,{after:a,before:u,...c.current()}));const h=d.charCodeAt(0),p=Mh(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=ru(h)+d.slice(1));const m=d.charCodeAt(d.length-1),g=Mh(r.after.charCodeAt(0),m,a);g.inside&&(d=d.slice(0,-1)+ru(m));const x=c.move(a);return l(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},u+d+x}function JP(e,t,n){return n.options.emphasis||"*"}function QP(e,t){let n=!1;return hb(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Gx}),!!((!e.depth||e.depth<3)&&ib(e)&&(t.options.setext||n))}function ZP(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(r);if(QP(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),g=n.containerPhrasing(e,{...l.current(),before:`
89
+ `,after:`
90
+ `});return m(),p(),g+`
91
+ `+(a===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
92
+ `))+1))}const c="#".repeat(a),u=n.enter("headingAtx"),d=n.enter("phrasing");l.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
93
+ `,...l.current()});return/^[\t ]/.test(h)&&(h=ru(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),d(),u(),h}VE.peek=e6;function VE(e){return e.value||""}function e6(){return"<"}GE.peek=t6;function GE(e,t,n,r){const a=mb(n),l=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let u=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("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(u=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),u(),e.title&&(u=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),u()),h+=d.move(")"),c(),h}function t6(){return"!"}WE.peek=n6;function WE(e,t,n,r){const a=e.referenceType,l=n.enter("imageReference");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("![");const h=n.safe(e.alt,{before:d,after:"]",...u.current()});d+=u.move(h+"]["),c();const p=n.stack;n.stack=[],c=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=p,l(),a==="full"||!h||h!==m?d+=u.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function n6(){return"!"}qE.peek=r6;function qE(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 c=n.unsafe[l],u=n.compilePattern(c);let d;if(c.atBreak)for(;d=u.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 r6(){return"`"}function KE(e,t){const n=ib(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))}YE.peek=s6;function YE(e,t,n,r){const a=mb(n),l=a==='"'?"Quote":"Apostrophe",c=n.createTracker(r);let u,d;if(KE(e,n)){const p=n.stack;n.stack=[],u=n.enter("autolink");let m=c.move("<");return m+=c.move(n.containerPhrasing(e,{before:m,after:">",...c.current()})),m+=c.move(">"),u(),n.stack=p,m}u=n.enter("link"),d=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(d=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),d(),e.title&&(d=n.enter(`title${l}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),d()),h+=c.move(")"),u(),h}function s6(e,t,n){return KE(e,n)?"<":"["}XE.peek=i6;function XE(e,t,n,r){const a=e.referenceType,l=n.enter("linkReference");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("[");const h=n.containerPhrasing(e,{before:d,after:"]",...u.current()});d+=u.move(h+"]["),c();const p=n.stack;n.stack=[],c=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=p,l(),a==="full"||!h||h!==m?d+=u.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function i6(){return"["}function pb(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 a6(e){const t=pb(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 o6(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 JE(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 l6(e,t,n,r){const a=n.enter("list"),l=n.bulletCurrent;let c=e.ordered?o6(n):pb(n);const u=e.ordered?c==="."?")":".":a6(n);let d=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&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),JE(n)===c&&p){let m=-1;for(;++m<e.children.length;){const g=e.children[m];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(c=u),n.bulletCurrent=c;const h=n.containerFlow(e,r);return n.bulletLastUsed=c,n.bulletCurrent=l,a(),h}function c6(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 u6(e,t,n,r){const a=c6(n);let l=n.bulletCurrent||pb(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 c=l.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const u=n.createTracker(r);u.move(l+" ".repeat(c-l.length)),u.shift(c);const d=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,u.current()),p);return d(),h;function p(m,g,x){return g?(x?"":" ".repeat(c))+m:(x?l:l+" ".repeat(c-l.length))+m}}function d6(e,t,n,r){const a=n.enter("paragraph"),l=n.enter("phrasing"),c=n.containerPhrasing(e,r);return l(),a(),c}const h6=Lf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function f6(e,t,n,r){return(e.children.some(function(c){return h6(c)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function m6(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}QE.peek=p6;function QE(e,t,n,r){const a=m6(n),l=n.enter("strong"),c=n.createTracker(r),u=c.move(a+a);let d=c.move(n.containerPhrasing(e,{after:a,before:u,...c.current()}));const h=d.charCodeAt(0),p=Mh(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=ru(h)+d.slice(1));const m=d.charCodeAt(d.length-1),g=Mh(r.after.charCodeAt(0),m,a);g.inside&&(d=d.slice(0,-1)+ru(m));const x=c.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},u+d+x}function p6(e,t,n){return n.options.strong||"*"}function g6(e,t,n,r){return n.safe(e.value,r)}function x6(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 y6(e,t,n){const r=(JE(n)+(n.options.ruleSpaces?" ":"")).repeat(x6(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ZE={blockquote:HP,break:z1,code:qP,definition:YP,emphasis:UE,hardBreak:z1,heading:ZP,html:VE,image:GE,imageReference:WE,inlineCode:qE,link:YE,linkReference:XE,list:l6,listItem:u6,paragraph:d6,root:f6,strong:QE,text:g6,thematicBreak:y6};function b6(){return{enter:{table:v6,tableData:H1,tableHeader:H1,tableRow:S6},exit:{codeText:w6,table:_6,tableData:Ug,tableHeader:Ug,tableRow:Ug}}}function v6(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 _6(e){this.exit(e),this.data.inTable=void 0}function S6(e){this.enter({type:"tableRow",children:[]},e)}function Ug(e){this.exit(e)}function H1(e){this.enter({type:"tableCell",children:[]},e)}function w6(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,C6));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function C6(e,t){return t==="|"?t:e}function k6(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
94
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:c,tableCell:d,tableRow:u}};function c(x,w,C,_){return h(p(x,C,_),x.align)}function u(x,w,C,_){const S=m(x,C,_),v=h([S]);return v.slice(0,v.indexOf(`
95
+ `))}function d(x,w,C,_){const S=C.enter("tableCell"),v=C.enter("phrasing"),b=C.containerPhrasing(x,{..._,before:l,after:l});return v(),S(),b}function h(x,w){return $P(x,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function p(x,w,C){const _=x.children;let S=-1;const v=[],b=w.enter("table");for(;++S<_.length;)v[S]=m(_[S],w,C);return b(),v}function m(x,w,C){const _=x.children;let S=-1;const v=[],b=w.enter("tableRow");for(;++S<_.length;)v[S]=d(_[S],x,w,C);return b(),v}function g(x,w,C){let _=ZE.inlineCode(x,w,C);return C.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function j6(){return{exit:{taskListCheckValueChecked:F1,taskListCheckValueUnchecked:F1,paragraph:N6}}}function E6(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:T6}}}function F1(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function N6(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,c;for(;++l<a.length;){const u=a[l];if(u.type==="paragraph"){c=u;break}}c===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 T6(e,t,n,r){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);l&&u.move(c);let d=ZE.listItem(e,t,n,{...r,...u.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(p){return p+c}}function A6(){return[lP(),TP(),RP(),b6(),j6()]}function L6(e){return{extensions:[cP(),AP(e),OP(),k6(e),E6()]}}const D6={tokenize:B6,partial:!0},e2={tokenize:$6,partial:!0},t2={tokenize:z6,partial:!0},n2={tokenize:H6,partial:!0},R6={tokenize:F6,partial:!0},r2={name:"wwwAutolink",tokenize:M6,previous:i2},s2={name:"protocolAutolink",tokenize:P6,previous:a2},pi={name:"emailAutolink",tokenize:I6,previous:o2},Os={};function O6(){return{text:Os}}let ka=48;for(;ka<123;)Os[ka]=pi,ka++,ka===58?ka=65:ka===91&&(ka=97);Os[43]=pi;Os[45]=pi;Os[46]=pi;Os[95]=pi;Os[72]=[pi,s2];Os[104]=[pi,s2];Os[87]=[pi,r2];Os[119]=[pi,r2];function I6(e,t,n){const r=this;let a,l;return c;function c(m){return!Yx(m)||!o2.call(r,r.previous)||gb(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(m))}function u(m){return Yx(m)?(e.consume(m),u):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(R6,p,h)(m):m===45||m===95||er(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&&or(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function M6(e,t,n){const r=this;return a;function a(c){return c!==87&&c!==119||!i2.call(r,r.previous)||gb(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(D6,e.attempt(e2,e.attempt(t2,l),n),n)(c))}function l(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function P6(e,t,n){const r=this;let a="",l=!1;return c;function c(m){return(m===72||m===104)&&a2.call(r,r.previous)&&!gb(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),u):n(m)}function u(m){if(or(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),u;if(m===58){const g=a.toLowerCase();if(g==="http"||g==="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||Rh(m)||tn(m)||Ya(m)||Nf(m)?n(m):e.attempt(e2,e.attempt(t2,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function B6(e,t,n){let r=0;return a;function a(c){return(c===87||c===119)&&r<3?(r++,e.consume(c),a):c===46&&r===3?(e.consume(c),l):n(c)}function l(c){return c===null?n(c):t(c)}}function $6(e,t,n){let r,a,l;return c;function c(h){return h===46||h===95?e.check(n2,d,u)(h):h===null||tn(h)||Ya(h)||h!==45&&Nf(h)?d(h):(l=!0,e.consume(h),c)}function u(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),c}function d(h){return a||r||!l?n(h):t(h)}}function z6(e,t){let n=0,r=0;return a;function a(c){return c===40?(n++,e.consume(c),a):c===41&&r<n?l(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(n2,t,l)(c):c===null||tn(c)||Ya(c)?t(c):(e.consume(c),a)}function l(c){return c===41&&r++,e.consume(c),a}}function H6(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),l):u===93?(e.consume(u),a):u===60||u===null||tn(u)||Ya(u)?t(u):n(u)}function a(u){return u===null||u===40||u===91||tn(u)||Ya(u)?t(u):r(u)}function l(u){return or(u)?c(u):n(u)}function c(u){return u===59?(e.consume(u),r):or(u)?(e.consume(u),c):n(u)}}function F6(e,t,n){return r;function r(l){return e.consume(l),a}function a(l){return er(l)?n(l):t(l)}}function i2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||tn(e)}function a2(e){return!or(e)}function o2(e){return!(e===47||Yx(e))}function Yx(e){return e===43||e===45||e===46||e===95||er(e)}function gb(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 U6={tokenize:J6,partial:!0};function V6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:K6,continuation:{tokenize:Y6},exit:X6}},text:{91:{name:"gfmFootnoteCall",tokenize:q6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:G6,resolveTo:W6}}}}function G6(e,t,n){const r=this;let a=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let c;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){c=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return u;function u(d){if(!c||!c._balanced)return n(d);const h=hs(r.sliceSerialize({start:c.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 W6(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)},c={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},u=[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",c,t],["exit",c,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...u),e}function q6(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l=0,c;return u;function u(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&&!c||m===null||m===91||tn(m))return n(m);if(m===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(hs(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return tn(m)||(c=!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 K6(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l,c=0,u;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(c>999||w===93&&!u||w===null||w===91||tn(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=hs(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return tn(w)||(u=!0),c++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),c++,p):p(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),Tt(e,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return t(w)}}function Y6(e,t,n){return e.check(gu,t,e.attempt(U6,t,n))}function X6(e){e.exit("gfmFootnoteDefinition")}function J6(e,t,n){const r=this;return Tt(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const c=r.events[r.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(l):n(l)}}function Q6(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(c,u){let d=-1;for(;++d<c.length;)if(c[d][0]==="enter"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._close){let h=d;for(;h--;)if(c[h][0]==="exit"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._open&&c[d][1].end.offset-c[d][1].start.offset===c[h][1].end.offset-c[h][1].start.offset){c[d][1].type="strikethroughSequence",c[h][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[d][1].end)},m={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[d][1].start)},g=[["enter",p,u],["enter",c[h][1],u],["exit",c[h][1],u],["enter",m,u]],x=u.parser.constructs.insideSpan.null;x&&Rr(g,g.length,0,Tf(x,c.slice(h+1,d),u)),Rr(g,g.length,0,[["exit",m,u],["enter",c[d][1],u],["exit",c[d][1],u],["exit",p,u]]),Rr(c,h-1,d-h+3,g),d=h+g.length-2;break}}for(d=-1;++d<c.length;)c[d][1].type==="strikethroughSequenceTemporary"&&(c[d][1].type="data");return c}function l(c,u,d){const h=this.previous,p=this.events;let m=0;return g;function g(w){return h===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(c.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const C=fl(h);if(w===126)return m>1?d(w):(c.consume(w),m++,x);if(m<2&&!n)return d(w);const _=c.exit("strikethroughSequenceTemporary"),S=fl(w);return _._open=!S||S===2&&!!C,_._close=!C||C===2&&!!S,u(w)}}}class Z6{constructor(){this.map=[]}add(t,n,r){eB(this,t,n,r)}consume(t){if(this.map.sort(function(l,c){return l[0]-c[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 eB(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 tB(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 nB(){return{flow:{null:{name:"table",tokenize:rB,resolveAll:sB}}}}function rB(e,t,n){const r=this;let a=0,l=0,c;return u;function u(P){let G=r.events.length-1;for(;G>-1;){const $=r.events[G][1].type;if($==="lineEnding"||$==="linePrefix")G--;else break}const z=G>-1?r.events[G][1].type:null,V=z==="tableHead"||z==="tableRow"?E:d;return V===E&&r.parser.lazy[r.now().line]?n(P):V(P)}function d(P){return e.enter("tableHead"),e.enter("tableRow"),h(P)}function h(P){return P===124||(c=!0,l+=1),p(P)}function p(P){return P===null?n(P):lt(P)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),x):n(P):kt(P)?Tt(e,p,"whitespace")(P):(l+=1,c&&(c=!1,a+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),c=!0,p):(e.enter("data"),m(P)))}function m(P){return P===null||P===124||tn(P)?(e.exit("data"),p(P)):(e.consume(P),P===92?g:m)}function g(P){return P===92||P===124?(e.consume(P),m):m(P)}function x(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),c=!1,kt(P)?Tt(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):w(P))}function w(P){return P===45||P===58?_(P):P===124?(c=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),C):N(P)}function C(P){return kt(P)?Tt(e,_,"whitespace")(P):_(P)}function _(P){return P===58?(l+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),S):P===45?(l+=1,S(P)):P===null||lt(P)?k(P):N(P)}function S(P){return P===45?(e.enter("tableDelimiterFiller"),v(P)):N(P)}function v(P){return P===45?(e.consume(P),v):P===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(P))}function b(P){return kt(P)?Tt(e,k,"whitespace")(P):k(P)}function k(P){return P===124?w(P):P===null||lt(P)?!c||a!==l?N(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):N(P)}function N(P){return n(P)}function E(P){return e.enter("tableRow"),D(P)}function D(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),D):P===null||lt(P)?(e.exit("tableRow"),t(P)):kt(P)?Tt(e,D,"whitespace")(P):(e.enter("data"),A(P))}function A(P){return P===null||P===124||tn(P)?(e.exit("data"),D(P)):(e.consume(P),P===92?O:A)}function O(P){return P===92||P===124?(e.consume(P),A):A(P)}}function sB(e,t){let n=-1,r=!0,a=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,h,p,m;const g=new Z6;for(;++n<e.length;){const x=e[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(u=!1,d!==0&&(U1(g,t,d,h,p),p=void 0,d=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",h,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,m=void 0,l=[0,0,0,0],c=[0,n+1,0,0],u&&(u=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.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,c[2]===0&&(l[1]!==0&&(c[0]=c[1],m=Gd(g,t,l,a,void 0,m),l=[0,0,0,0]),c[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(c[0]=c[1],m=Gd(g,t,l,a,void 0,m)),l=c,c=[l[1],n,0,0])):w.type==="tableHead"?(u=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,l[1]!==0?(c[0]=c[1],m=Gd(g,t,l,a,n,m)):c[1]!==0&&(m=Gd(g,t,c,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=n)}for(d!==0&&U1(g,t,d,h,p),g.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=tB(t.events,n))}return e}function Gd(e,t,n,r,a,l){const c=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(l.end=Object.assign({},Ko(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=Ko(t.events,n[1]);if(l={type:c,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const h=Ko(t.events,n[2]),p=Ko(t.events,n[3]),m={type:u,start:Object.assign({},h),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const g=t.events[n[2]],x=t.events[n[3]];if(g[1].end=Object.assign({},x[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},Ko(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function U1(e,t,n,r,a){const l=[],c=Ko(t.events,n);a&&(a.end=Object.assign({},c),l.push(["exit",a,t])),r.end=Object.assign({},c),l.push(["exit",r,t]),e.add(n+1,0,l)}function Ko(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const iB={name:"tasklistCheck",tokenize:oB};function aB(){return{text:{91:iB}}}function oB(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 tn(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),c):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),c):n(d)}function c(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),u):n(d)}function u(d){return lt(d)?t(d):kt(d)?e.check({tokenize:lB},t,n)(d):n(d)}}function lB(e,t,n){return Tt(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function cB(e){return xE([O6(),V6(),Q6(e),nB(),aB()])}const uB={};function dB(e){const t=this,n=e||uB,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),c=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(cB(n)),l.push(A6()),c.push(L6(n))}var Xx=Object.defineProperty,hB=Object.getOwnPropertyDescriptor,fB=Object.getOwnPropertyNames,mB=Object.prototype.hasOwnProperty,xb=(e,t)=>{let n={};for(var r in e)Xx(n,r,{get:e[r],enumerable:!0});return Xx(n,Symbol.toStringTag,{value:"Module"}),n},pB=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=fB(t),l=0,c=a.length,u;l<c;l++)u=a[l],!mB.call(e,u)&&u!==n&&Xx(e,u,{get:(d=>t[d]).bind(null,u),enumerable:!(r=hB(t,u))||r.enumerable});return e},l2=(e,t,n)=>(pB(e,t,"default"),n);const Rf=[{id:"abap",name:"ABAP",import:(()=>ne(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>ne(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>ne(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>ne(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>ne(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>ne(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>ne(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>ne(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>ne(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>ne(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>ne(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>ne(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>ne(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>ne(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>ne(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>ne(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>ne(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>ne(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>ne(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>ne(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>ne(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>ne(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>ne(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>ne(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>ne(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>ne(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>ne(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>ne(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>ne(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>ne(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>ne(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>ne(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>ne(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>ne(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>ne(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>ne(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>ne(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>ne(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>ne(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>ne(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>ne(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>ne(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>ne(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>ne(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>ne(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>ne(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>ne(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>ne(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>ne(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>ne(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>ne(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>ne(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>ne(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>ne(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>ne(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>ne(()=>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:(()=>ne(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>ne(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>ne(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>ne(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>ne(()=>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:(()=>ne(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>ne(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>ne(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>ne(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>ne(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>ne(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>ne(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>ne(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>ne(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>ne(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>ne(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>ne(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>ne(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>ne(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>ne(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>ne(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>ne(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>ne(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>ne(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>ne(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>ne(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>ne(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>ne(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>ne(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>ne(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>ne(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>ne(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>ne(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>ne(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>ne(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>ne(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>ne(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>ne(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>ne(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>ne(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>ne(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>ne(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>ne(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>ne(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>ne(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>ne(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>ne(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>ne(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>ne(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>ne(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>ne(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>ne(()=>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:(()=>ne(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>ne(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>ne(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>ne(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>ne(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>ne(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>ne(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>ne(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>ne(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>ne(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>ne(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>ne(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>ne(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>ne(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>ne(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>ne(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>ne(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>ne(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>ne(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>ne(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>ne(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>ne(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>ne(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>ne(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>ne(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>ne(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>ne(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>ne(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>ne(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>ne(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>ne(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>ne(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>ne(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>ne(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>ne(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>ne(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>ne(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>ne(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>ne(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>ne(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>ne(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>ne(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>ne(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>ne(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>ne(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>ne(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>ne(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>ne(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>ne(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>ne(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>ne(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>ne(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>ne(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>ne(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>ne(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>ne(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>ne(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>ne(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>ne(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>ne(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>ne(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>ne(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>ne(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>ne(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>ne(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>ne(()=>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:(()=>ne(()=>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:(()=>ne(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>ne(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>ne(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>ne(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>ne(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>ne(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>ne(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>ne(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>ne(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>ne(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>ne(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>ne(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>ne(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>ne(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>ne(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>ne(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>ne(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>ne(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>ne(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>ne(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>ne(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>ne(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>ne(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>ne(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>ne(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>ne(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>ne(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>ne(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>ne(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>ne(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>ne(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>ne(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>ne(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>ne(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>ne(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>ne(()=>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:(()=>ne(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>ne(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>ne(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>ne(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>ne(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>ne(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>ne(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>ne(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>ne(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>ne(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>ne(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>ne(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>ne(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>ne(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>ne(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>ne(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>ne(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>ne(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>ne(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>ne(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>ne(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>ne(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>ne(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>ne(()=>import("./zig-VOosw3JB.js"),[]))}],yb=Object.fromEntries(Rf.map(e=>[e.id,e.import])),bb=Object.fromEntries(Rf.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),Of={...yb,...bb},vb=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>ne(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>ne(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>ne(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>ne(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>ne(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>ne(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>ne(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>ne(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>ne(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>ne(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>ne(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>ne(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>ne(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>ne(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>ne(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>ne(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>ne(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>ne(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>ne(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>ne(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>ne(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>ne(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>ne(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>ne(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>ne(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>ne(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>ne(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>ne(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>ne(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>ne(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>ne(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>ne(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>ne(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>ne(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>ne(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>ne(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>ne(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>ne(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>ne(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>ne(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>ne(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>ne(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>ne(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>ne(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>ne(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>ne(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>ne(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>ne(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>ne(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>ne(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>ne(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>ne(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>ne(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>ne(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>ne(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>ne(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>ne(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>ne(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>ne(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>ne(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>ne(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>ne(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>ne(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>ne(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>ne(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],_b=Object.fromEntries(vb.map(e=>[e.id,e.import]));var Sb=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function gB(){return 2147483648}function xB(){return typeof performance<"u"?performance.now():Date.now()}const yB=(e,t)=>e+(t-e%t)%t;async function bB(e){let t,n;const r={};function a(x){n=x,r.HEAPU8=new Uint8Array(x),r.HEAPU32=new Uint32Array(x)}function l(x,w,C){r.HEAPU8.copyWithin(x,w,w+C)}function c(x){try{return t.grow(x-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function u(x){const w=r.HEAPU8.length;x=x>>>0;const C=gB();if(x>C)return!1;for(let _=1;_<=4;_*=2){let S=w*(1+.2/_);S=Math.min(S,x+100663296);const v=Math.min(C,yB(Math.max(x,S),65536));if(c(v))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(x,w,C=1024){const _=w+C;let S=w;for(;x[S]&&!(S>=_);)++S;if(S-w>16&&x.buffer&&d)return d.decode(x.subarray(w,S));let v="";for(;w<S;){let b=x[w++];if(!(b&128)){v+=String.fromCharCode(b);continue}const k=x[w++]&63;if((b&224)===192){v+=String.fromCharCode((b&31)<<6|k);continue}const N=x[w++]&63;if((b&240)===224?b=(b&15)<<12|k<<6|N:b=(b&7)<<18|k<<12|N<<6|x[w++]&63,b<65536)v+=String.fromCharCode(b);else{const E=b-65536;v+=String.fromCharCode(55296|E>>10,56320|E&1023)}}return v}function p(x,w){return x?h(r.HEAPU8,x,w):""}const m={emscripten_get_now:xB,emscripten_memcpy_big:l,emscripten_resize_heap:u,fd_write:()=>0};async function g(){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 g(),r}var vB=Object.defineProperty,_B=(e,t,n)=>t in e?vB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,In=(e,t,n)=>_B(e,typeof t!="symbol"?t+"":t,n);let Fn=null;function SB(e){throw new Sb(e.UTF8ToString(e.getLastOnigError()))}class If{constructor(t){In(this,"utf16Length"),In(this,"utf8Length"),In(this,"utf16Value"),In(this,"utf8Value"),In(this,"utf16OffsetToUtf8"),In(this,"utf8OffsetToUtf16");const n=t.length,r=If._utf8ByteLength(t),a=r!==n,l=a?new Uint32Array(n+1):null;a&&(l[n]=r);const c=a?new Uint32Array(r+1):null;a&&(c[r]=n);const u=new Uint8Array(r);let d=0;for(let h=0;h<n;h++){const p=t.charCodeAt(h);let m=p,g=!1;if(p>=55296&&p<=56319&&h+1<n){const x=t.charCodeAt(h+1);x>=56320&&x<=57343&&(m=(p-55296<<10)+65536|x-56320,g=!0)}a&&(l[h]=d,g&&(l[h+1]=d),m<=127?c[d+0]=h:m<=2047?(c[d+0]=h,c[d+1]=h):m<=65535?(c[d+0]=h,c[d+1]=h,c[d+2]=h):(c[d+0]=h,c[d+1]=h,c[d+2]=h,c[d+3]=h)),m<=127?u[d++]=m:m<=2047?(u[d++]=192|(m&1984)>>>6,u[d++]=128|(m&63)>>>0):m<=65535?(u[d++]=224|(m&61440)>>>12,u[d++]=128|(m&4032)>>>6,u[d++]=128|(m&63)>>>0):(u[d++]=240|(m&1835008)>>>18,u[d++]=128|(m&258048)>>>12,u[d++]=128|(m&4032)>>>6,u[d++]=128|(m&63)>>>0),g&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=u,this.utf16OffsetToUtf8=l,this.utf8OffsetToUtf16=c}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const l=t.charCodeAt(r);let c=l,u=!1;if(l>=55296&&l<=56319&&r+1<a){const d=t.charCodeAt(r+1);d>=56320&&d<=57343&&(c=(l-55296<<10)+65536|d-56320,u=!0)}c<=127?n+=1:c<=2047?n+=2:c<=65535?n+=3:n+=4,u&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const Mf=class ws{constructor(t){if(In(this,"id",++ws.LAST_ID),In(this,"_onigBinding"),In(this,"content"),In(this,"utf16Length"),In(this,"utf8Length"),In(this,"utf16OffsetToUtf8"),In(this,"utf8OffsetToUtf16"),In(this,"ptr"),!Fn)throw new Sb("Must invoke loadWasm first.");this._onigBinding=Fn,this.content=t;const n=new If(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!ws._sharedPtrInUse?(ws._sharedPtr||(ws._sharedPtr=Fn.omalloc(1e4)),ws._sharedPtrInUse=!0,Fn.HEAPU8.set(n.utf8Value,ws._sharedPtr),this.ptr=ws._sharedPtr):this.ptr=n.createString(Fn)}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===ws._sharedPtr?ws._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};In(Mf,"LAST_ID",0);In(Mf,"_sharedPtr",0);In(Mf,"_sharedPtrInUse",!1);let c2=Mf;class wB{constructor(t){if(In(this,"_onigBinding"),In(this,"_ptr"),!Fn)throw new Sb("Must invoke loadWasm first.");const n=[],r=[];for(let u=0,d=t.length;u<d;u++){const h=new If(t[u]);n[u]=h.createString(Fn),r[u]=h.utf8Length}const a=Fn.omalloc(4*t.length);Fn.HEAPU32.set(n,a/4);const l=Fn.omalloc(4*t.length);Fn.HEAPU32.set(r,l/4);const c=Fn.createOnigScanner(a,l,t.length);for(let u=0,d=t.length;u<d;u++)Fn.ofree(n[u]);Fn.ofree(l),Fn.ofree(a),c===0&&SB(Fn),this._onigBinding=Fn,this._ptr=c}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let a=0;if(typeof r=="number"&&(a=r),typeof t=="string"){t=new c2(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,c=l.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(c===0)return null;const u=l.HEAPU32;let d=c/4;const h=u[d++],p=u[d++],m=[];for(let g=0;g<p;g++){const x=t.convertUtf8OffsetToUtf16(u[d++]),w=t.convertUtf8OffsetToUtf16(u[d++]);m[g]={start:x,end:w,length:w-x}}return{index:h,captureIndices:m}}}function CB(e){return typeof e.instantiator=="function"}function kB(e){return typeof e.default=="function"}function jB(e){return typeof e.data<"u"}function EB(e){return typeof Response<"u"&&e instanceof Response}function NB(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 Wd;function wb(e){if(Wd)return Wd;async function t(){Fn=await bB(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),CB(r)?r=await r.instantiator(n):kB(r)?r=await r.default(n):(jB(r)&&(r=r.data),EB(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await TB(r)(n):r=await AB(r)(n):NB(r)?r=await Vg(r)(n):r instanceof WebAssembly.Module?r=await Vg(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Vg(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Wd=t(),Wd}function Vg(e){return t=>WebAssembly.instantiate(e,t)}function TB(e){return t=>WebAssembly.instantiateStreaming(e,t)}function AB(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let u2;function LB(e){u2=e}function DB(){return u2}async function d2(e){return e&&await wb(e),{createScanner(t){return new wB(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new c2(t)}}}const RB=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:d2,getDefaultWasmLoader:DB,loadWasm:wb,setDefaultWasmLoader:LB},Symbol.toStringTag,{value:"Module"}));var h2=xb({});l2(h2,RB);var nn=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function OB(e){return Cb(e)}function Cb(e){return Array.isArray(e)?IB(e):e instanceof RegExp?e:typeof e=="object"?MB(e):e}function IB(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Cb(e[n]);return t}function MB(e){let t={};for(let n in e)t[n]=Cb(e[n]);return t}function f2(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function m2(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?m2(e.substring(0,e.length-1)):e.substr(~t+1)}var Gg=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,qd=class{static hasCaptures(e){return e===null?!1:(Gg.lastIndex=0,Gg.test(e))}static replaceCaptures(e,t,n){return e.replace(Gg,(r,a,l,c)=>{let u=n[parseInt(a||l,10)];if(u){let d=t.substring(u.start,u.end);for(;d[0]===".";)d=d.substring(1);switch(c){case"downcase":return d.toLowerCase();case"upcase":return d.toUpperCase();default:return d}}else return r})}};function p2(e,t){return e<t?-1:e>t?1:0}function g2(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=p2(e[a],t[a]);if(l!==0)return l}return 0}return n-r}function V1(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 x2(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var y2=class{constructor(e){Ae(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}},Ph=class{constructor(e,t,n){Ae(this,"_cachedMatchRoot",new y2(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme($B(e),t)}static createFromParsedTheme(e,t){return HB(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=>PB(e.parent,a.parentScopes));return r?new b2(r.fontStyle,r.foreground,r.background):null}},Wg=class vh{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new vh(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new vh(n,t[r]);return n}push(t){return new vh(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function PB(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&&!BB(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function BB(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var b2=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function $B(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 c=t[a];if(!c.settings)continue;let u;if(typeof c.scope=="string"){let m=c.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),u=m.split(",")}else Array.isArray(c.scope)?u=c.scope:u=[""];let d=-1;if(typeof c.settings.fontStyle=="string"){d=0;let m=c.settings.fontStyle.split(" ");for(let g=0,x=m.length;g<x;g++)switch(m[g]){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 c.settings.foreground=="string"&&V1(c.settings.foreground)&&(h=c.settings.foreground);let p=null;typeof c.settings.background=="string"&&V1(c.settings.background)&&(p=c.settings.background);for(let m=0,g=u.length;m<g;m++){let w=u[m].trim().split(" "),C=w[w.length-1],_=null;w.length>1&&(_=w.slice(0,w.length-1),_.reverse()),n[r++]=new zB(C,_,a,d,h,p)}}return n}var zB=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}},Zn=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(Zn||{});function HB(e,t){e.sort((d,h)=>{let p=p2(d.scope,h.scope);return p!==0||(p=g2(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 FB(t),c=new b2(n,l.getId(r),l.getId(a)),u=new VB(new Jx(0,null,-1,0,0),[]);for(let d=0,h=e.length;d<h;d++){let p=e[d];u.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new Ph(l,c,u)}var FB=class{constructor(e){Ae(this,"_isFrozen");Ae(this,"_lastColorId");Ae(this,"_id2color");Ae(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)}},UB=Object.freeze([]),Jx=class v2{constructor(t,n,r,a,l){Ae(this,"scopeDepth");Ae(this,"parentScopes");Ae(this,"fontStyle");Ae(this,"foreground");Ae(this,"background");this.scopeDepth=t,this.parentScopes=n||UB,this.fontStyle=r,this.foreground=a,this.background=l}clone(){return new v2(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)}},VB=class Qx{constructor(t,n=[],r={}){Ae(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(Qx._cmpBySpecificity),n}insert(t,n,r,a,l,c){if(n===""){this._doInsertHere(t,r,a,l,c);return}let u=n.indexOf("."),d,h;u===-1?(d=n,h=""):(d=n.substring(0,u),h=n.substring(u+1));let p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new Qx(this._mainRule.clone(),Jx.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.insert(t+1,h,r,a,l,c)}_doInsertHere(t,n,r,a,l){if(n===null){this._mainRule.acceptOverwrite(t,r,a,l);return}for(let c=0,u=this._rulesWithParentScopes.length;c<u;c++){let d=this._rulesWithParentScopes[c];if(g2(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 Jx(t,n,r,a,l))}},Wa=class Gr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Gr.getLanguageId(t),r=Gr.getTokenType(t),a=Gr.getFontStyle(t),l=Gr.getForeground(t),c=Gr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:a,foreground:l,background:c})}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,c,u){let d=Gr.getLanguageId(t),h=Gr.getTokenType(t),p=Gr.containsBalancedBrackets(t)?1:0,m=Gr.getFontStyle(t),g=Gr.getForeground(t),x=Gr.getBackground(t);return n!==0&&(d=n),r!==8&&(h=r),a!==null&&(p=a?1:0),l!==-1&&(m=l),c!==0&&(g=c),u!==0&&(x=u),(d<<0|h<<8|p<<10|m<<11|g<<15|x<<24)>>>0}};function Bh(e,t){const n=[],r=GB(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=c();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=u();return a===")"&&(a=r.next()),d}if(G1(a)){const d=[];do d.push(a),a=r.next();while(G1(a));return h=>t(d,h)}return null}function c(){const d=[];let h=l();for(;h;)d.push(h),h=l();return p=>d.every(m=>m(p))}function u(){const d=[];let h=c();for(;h&&(d.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=c()}return p=>d.some(m=>m(p))}}function G1(e){return!!e&&!!e.match(/[\w\.:]+/)}function GB(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 _2(e){typeof e.dispose=="function"&&e.dispose()}var su=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},WB=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},qB=class{constructor(){Ae(this,"_references",[]);Ae(this,"_seenReferenceKeys",new Set);Ae(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))}},KB=class{constructor(e,t){Ae(this,"seenFullScopeRequests",new Set);Ae(this,"seenPartialScopeRequests",new Set);Ae(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new su(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new qB;for(const n of e)YB(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof su){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 YB(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 su?_h({baseGrammar:l,selfGrammar:a},r):Zx(e.ruleName,{baseGrammar:l,selfGrammar:a,repository:a.repository},r);const c=n.injections(e.scopeName);if(c)for(const u of c)r.add(new su(u))}function Zx(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];$h([r],t,n)}}function _h(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&$h(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&$h(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function $h(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?f2({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&$h(r.patterns,{...t,repository:a},n);const l=r.include;if(!l)continue;const c=S2(l);switch(c.kind){case 0:_h({...t,selfGrammar:t.baseGrammar},n);break;case 1:_h(t,n);break;case 2:Zx(c.ruleName,{...t,repository:a},n);break;case 3:case 4:const u=c.scopeName===t.selfGrammar.scopeName?t.selfGrammar:c.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(u){const d={baseGrammar:t.baseGrammar,selfGrammar:u,repository:a};c.kind===4?Zx(c.ruleName,d,n):_h(d,n)}else c.kind===4?n.add(new WB(c.scopeName,c.ruleName)):n.add(new su(c.scopeName));break}}}var XB=class{constructor(){Ae(this,"kind",0)}},JB=class{constructor(){Ae(this,"kind",1)}},QB=class{constructor(e){Ae(this,"kind",2);this.ruleName=e}},ZB=class{constructor(e){Ae(this,"kind",3);this.scopeName=e}},e8=class{constructor(e,t){Ae(this,"kind",4);this.scopeName=e,this.ruleName=t}};function S2(e){if(e==="$base")return new XB;if(e==="$self")return new JB;const t=e.indexOf("#");if(t===-1)return new ZB(e);if(t===0)return new QB(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new e8(n,r)}}var t8=/\\(\d+)/,W1=/\\(\d+)/g,n8=-1,w2=-2;var yu=class{constructor(e,t,n,r){Ae(this,"$location");Ae(this,"id");Ae(this,"_nameIsCapturing");Ae(this,"_name");Ae(this,"_contentNameIsCapturing");Ae(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=qd.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=qd.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${m2(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:qd.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:qd.replaceCaptures(this._contentName,e,t)}},r8=class extends yu{constructor(t,n,r,a,l){super(t,n,r,a);Ae(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!")}},s8=class extends yu{constructor(t,n,r,a,l){super(t,n,r,null);Ae(this,"_match");Ae(this,"captures");Ae(this,"_cachedCompiledPatterns");this._match=new iu(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 au,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},q1=class extends yu{constructor(t,n,r,a,l){super(t,n,r,a);Ae(this,"hasMissingPatterns");Ae(this,"patterns");Ae(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 au,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ey=class extends yu{constructor(t,n,r,a,l,c,u,d,h,p){super(t,n,r,a);Ae(this,"_begin");Ae(this,"beginCaptures");Ae(this,"_end");Ae(this,"endHasBackReferences");Ae(this,"endCaptures");Ae(this,"applyEndPatternLast");Ae(this,"hasMissingPatterns");Ae(this,"patterns");Ae(this,"_cachedCompiledPatterns");this._begin=new iu(l,this.id),this.beginCaptures=c,this._end=new iu(u||"￿",-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 au;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}},zh=class extends yu{constructor(t,n,r,a,l,c,u,d,h){super(t,n,r,a);Ae(this,"_begin");Ae(this,"beginCaptures");Ae(this,"whileCaptures");Ae(this,"_while");Ae(this,"whileHasBackReferences");Ae(this,"hasMissingPatterns");Ae(this,"patterns");Ae(this,"_cachedCompiledPatterns");Ae(this,"_cachedCompiledWhilePatterns");this._begin=new iu(l,this.id),this.beginCaptures=c,this.whileCaptures=d,this._while=new iu(u,w2),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 au;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 au,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},C2=class Xn{static createCaptureRule(t,n,r,a,l){return t.registerRule(c=>new r8(n,c,r,a,l))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new s8(t.$vscodeTextmateLocation,t.id,t.name,t.match,Xn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=f2({},r,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new q1(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Xn._compilePatterns(l,n,r))}return t.while?new zh(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Xn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Xn._compileCaptures(t.whileCaptures||t.captures,n,r),Xn._compilePatterns(t.patterns,n,r)):new ey(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Xn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Xn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Xn._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let a=[];if(t){let l=0;for(const c in t){if(c==="$vscodeTextmateLocation")continue;const u=parseInt(c,10);u>l&&(l=u)}for(let c=0;c<=l;c++)a[c]=null;for(const c in t){if(c==="$vscodeTextmateLocation")continue;const u=parseInt(c,10);let d=0;t[c].patterns&&(d=Xn.getCompiledRuleId(t[c],n,r)),a[u]=Xn.createCaptureRule(n,t[c].$vscodeTextmateLocation,t[c].name,t[c].contentName,d)}}return a}static _compilePatterns(t,n,r){let a=[];if(t)for(let l=0,c=t.length;l<c;l++){const u=t[l];let d=-1;if(u.include){const h=S2(u.include);switch(h.kind){case 0:case 1:d=Xn.getCompiledRuleId(r[u.include],n,r);break;case 2:let p=r[h.ruleName];p&&(d=Xn.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=h.scopeName,g=h.kind===4?h.ruleName:null,x=n.getExternalGrammar(m,r);if(x)if(g){let w=x.repository[g];w&&(d=Xn.getCompiledRuleId(w,n,x.repository))}else d=Xn.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else d=Xn.getCompiledRuleId(u,n,r);if(d!==-1){const h=n.getRule(d);let p=!1;if((h instanceof q1||h instanceof ey||h instanceof zh)&&h.hasMissingPatterns&&h.patterns.length===0&&(p=!0),p)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},iu=class k2{constructor(t,n){Ae(this,"source");Ae(this,"ruleId");Ae(this,"hasAnchor");Ae(this,"hasBackReferences");Ae(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,l=[],c=!1;for(let u=0;u<r;u++)if(t.charAt(u)==="\\"&&u+1<r){const h=t.charAt(u+1);h==="z"?(l.push(t.substring(a,u)),l.push("$(?!\\n)(?<!\\n)"),a=u+2):(h==="A"||h==="G")&&(c=!0),u++}this.hasAnchor=c,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=t8.test(this.source):this.hasBackReferences=!1}clone(){return new k2(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 W1.lastIndex=0,this.source.replace(W1,(a,l)=>x2(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,c,u,d;for(l=0,c=this.source.length;l<c;l++)u=this.source.charAt(l),t[l]=u,n[l]=u,r[l]=u,a[l]=u,u==="\\"&&l+1<c&&(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}},au=class{constructor(){Ae(this,"_items");Ae(this,"_hasAnchors");Ae(this,"_cached");Ae(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 K1(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 K1(e,r,this._items.map(a=>a.ruleId))}},K1=class{constructor(e,t,n){Ae(this,"scanner");this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
96
+ `)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},qg=class{constructor(e,t){this.languageId=e,this.tokenType=t}},oi,i8=(oi=class{constructor(t,n){Ae(this,"_defaultAttributes");Ae(this,"_embeddedLanguagesMatcher");Ae(this,"_getBasicScopeAttributes",new y2(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new qg(n,r)}));this._defaultAttributes=new qg(t,8),this._embeddedLanguagesMatcher=new a8(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?oi._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(oi.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!")}},Ae(oi,"_NULL_SCOPE_METADATA",new qg(0,0)),Ae(oi,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),oi),a8=class{constructor(e){Ae(this,"values");Ae(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>x2(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])}},Y1=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function j2(e,t,n,r,a,l,c,u){const d=t.content.length;let h=!1,p=-1;if(c){const x=o8(e,t,n,r,a,l);a=x.stack,r=x.linePos,n=x.isFirstLine,p=x.anchorPosition}const m=Date.now();for(;!h;){if(u!==0&&Date.now()-m>u)return new Y1(a,!0);g()}return new Y1(a,!1);function g(){const x=l8(e,t,n,r,a,p);if(!x){l.produce(a,d),h=!0;return}const w=x.captureIndices,C=x.matchedRuleId,_=w&&w.length>0?w[0].end>r:!1;if(C===n8){const S=a.getRule(e);l.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),Bc(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),k=a.contentNameScopesList.pushAttributed(b,e);if(a=a.push(C,r,p,w[0].end===d,null,k,k),S instanceof ey){const N=S;Bc(e,t,n,a,l,N.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const E=N.getContentName(t.content,w),D=k.pushAttributed(E,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 zh){const N=S;Bc(e,t,n,a,l,N.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const E=N.getContentName(t.content,w),D=k.pushAttributed(E,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(Bc(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 o8(e,t,n,r,a,l){let c=a.beginRuleCapturedEOL?0:-1;const u=[];for(let d=a;d;d=d.pop()){const h=d.getRule(e);h instanceof zh&&u.push({rule:h,stack:d})}for(let d=u.pop();d;d=u.pop()){const{ruleScanner:h,findOptions:p}=d8(d.rule,e,d.stack.endRule,n,r===c),m=h.findNextMatchSync(t,r,p);if(m){if(m.ruleId!==w2){a=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(d.stack,m.captureIndices[0].start),Bc(e,t,n,d.stack,l,d.rule.whileCaptures,m.captureIndices),l.produce(d.stack,m.captureIndices[0].end),c=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:c,isFirstLine:n}}function l8(e,t,n,r,a,l){const c=c8(e,t,n,r,a,l),u=e.getInjections();if(u.length===0)return c;const d=u8(u,e,t,n,r,a,l);if(!d)return c;if(!c)return d;const h=c.captureIndices[0].start,p=d.captureIndices[0].start;return p<h||d.priorityMatch&&p===h?d:c}function c8(e,t,n,r,a,l){const c=a.getRule(e),{ruleScanner:u,findOptions:d}=E2(c,e,a.endRule,n,r===l),h=u.findNextMatchSync(t,r,d);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function u8(e,t,n,r,a,l,c){let u=Number.MAX_VALUE,d=null,h,p=0;const m=l.contentNameScopesList.getScopeNames();for(let g=0,x=e.length;g<x;g++){const w=e[g];if(!w.matcher(m))continue;const C=t.getRule(w.ruleId),{ruleScanner:_,findOptions:S}=E2(C,t,null,r,a===c),v=_.findNextMatchSync(n,a,S);if(!v)continue;const b=v.captureIndices[0].start;if(!(b>=u)&&(u=b,d=v.captureIndices,h=v.ruleId,p=w.priority,u===a))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:h}:null}function E2(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function d8(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function Bc(e,t,n,r,a,l,c){if(l.length===0)return;const u=t.content,d=Math.min(l.length,c.length),h=[],p=c[0].end;for(let m=0;m<d;m++){const g=l[m];if(g===null)continue;const x=c[m];if(x.length===0)continue;if(x.start>p)break;for(;h.length>0&&h[h.length-1].endPos<=x.start;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?a.produceFromScopes(h[h.length-1].scopes,x.start):a.produce(r,x.start),g.retokenizeCapturedWithRuleId){const C=g.getName(u,c),_=r.contentNameScopesList.pushAttributed(C,e),S=g.getContentName(u,c),v=_.pushAttributed(S,e),b=r.push(g.retokenizeCapturedWithRuleId,x.start,-1,!1,null,_,v),k=e.createOnigString(u.substring(0,x.end));j2(e,k,n&&x.start===0,x.start,b,a,!1,0),_2(k);continue}const w=g.getName(u,c);if(w!==null){const _=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);h.push(new h8(_,x.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var h8=class{constructor(e,t){Ae(this,"scopes");Ae(this,"endPos");this.scopes=e,this.endPos=t}};function f8(e,t,n,r,a,l,c,u){return new p8(e,t,n,r,a,l,c,u)}function X1(e,t,n,r,a){const l=Bh(t,Hh),c=C2.getCompiledRuleId(n,r,a.repository);for(const u of l)e.push({debugSelector:t,matcher:u.matcher,ruleId:c,grammar:a,priority:u.priority})}function Hh(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(m8(t[a],r))return n=a+1,!0;return!1})}function m8(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 p8=class{constructor(e,t,n,r,a,l,c,u){Ae(this,"_rootId");Ae(this,"_lastRuleId");Ae(this,"_ruleId2desc");Ae(this,"_includedGrammars");Ae(this,"_grammarRepository");Ae(this,"_grammar");Ae(this,"_injections");Ae(this,"_basicScopeAttributesProvider");Ae(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=u,this._basicScopeAttributesProvider=new i8(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=c,this._grammar=J1(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const h=Bh(d,Hh);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 c in a)X1(t,c,a[c],this,r);const l=this._grammarRepository.injections(n);l&&l.forEach(c=>{const u=this.getExternalGrammar(c);if(u){const d=u.injectionSelector;d&&X1(t,d,u,this,u)}})}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]=J1(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=C2.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===ty.NULL){a=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Wa.set(0,h.languageId,h.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),g=this.getRule(this._rootId).getName(null,null);let x;g?x=Gc.createRootAndLookUpScopeName(g,m,this):x=Gc.createRoot("unknown",m),t=new ty(null,this._rootId,-1,-1,!1,null,x,x)}else a=!1,t.reset();e=e+`
97
+ `;const l=this.createOnigString(e),c=l.content.length,u=new x8(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=j2(this,l,a,0,t,u,!0,r);return _2(l),{lineLength:c,lineTokens:u,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function J1(e,t){return e=OB(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 Gc=class Cs{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=Wg.push(a,l.scopeNames),r=new Cs(r,a,l.encodedTokenAttributes);return r}static createRoot(t,n){return new Cs(null,new Wg(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),l=new Wg(null,t),c=r.themeProvider.themeMatch(l),u=Cs.mergeAttributes(n,a,c);return new Cs(null,l,u)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Cs.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,c=0;return r!==null&&(a=r.fontStyle,l=r.foregroundId,c=r.backgroundId),Wa.set(t,n.languageId,n.tokenType,null,a,l,c)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Cs._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const l of r)a=Cs._pushAttributed(a,l,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),l=t.scopePath.push(n),c=r.themeProvider.themeMatch(l),u=Cs.mergeAttributes(t.tokenAttributes,a,c);return new Cs(t,l,u)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((a=r.parent)==null?void 0:a.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},Kr,ty=(Kr=class{constructor(t,n,r,a,l,c,u,d){Ae(this,"_stackElementBrand");Ae(this,"_enterPos");Ae(this,"_anchorPos");Ae(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=l,this.endRule=c,this.nameScopesList=u,this.contentNameScopesList=d,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=a}equals(t){return t===null?!1:Kr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Gc.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(){Kr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,l,c,u){return new Kr(this,t,n,r,a,l,c,u)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var r,a;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(a=this.contentNameScopesList)==null?void 0:a.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new Kr(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=Gc.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new Kr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Gc.fromExtension(r,n.contentNameScopesList))}},Ae(Kr,"NULL",new Kr(null,0,0,0,!1,null,null,null)),Kr),g8=class{constructor(e,t){Ae(this,"balancedBracketScopes");Ae(this,"unbalancedBracketScopes");Ae(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Bh(n,Hh).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Bh(n,Hh).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}},x8=class{constructor(e,t,n,r){Ae(this,"_emitBinaryTokens");Ae(this,"_lineText");Ae(this,"_tokens");Ae(this,"_binaryTokens");Ae(this,"_lastTokenEndIndex");Ae(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 c=(e==null?void 0:e.getScopeNames())??[];for(const u of this._tokenTypeOverrides)u.matcher(c)&&(a=Wa.set(a,0,u.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(c))}if(l&&(a=Wa.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}},y8=class{constructor(e,t){Ae(this,"_grammars",new Map);Ae(this,"_rawGrammars",new Map);Ae(this,"_injectionGrammars",new Map);Ae(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,f8(e,l,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},b8=class{constructor(t){Ae(this,"_options");Ae(this,"_syncRegistry");Ae(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new y8(Ph.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Ph.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 g8(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,l){const c=new KB(this._syncRegistry,t);for(;c.Q.length>0;)c.Q.map(u=>this._loadSingleGrammar(u.scopeName)),c.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)}},ny=ty.NULL;function Fh(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 Xi(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function v8(e){return Array.isArray(e)?e:[e]}async function N2(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Pf(e){return!e||["plaintext","txt","text","plain"].includes(e)}function T2(e){return e==="ansi"||Pf(e)}function Bf(e){return e==="none"}function A2(e){return Bf(e)}const _8=/(\r?\n)/g;function $f(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(_8);let r=0;const a=[];for(let c=0;c<n.length;c+=2){const u=t?n[c]+(n[c+1]||""):n[c];a.push([u,r]),r+=n[c].length,r+=((l=n[c+1])==null?void 0:l.length)||0}return a}const Q1={light:"#333333",dark:"#bbbbbb"},Z1={light:"#fffffe",dark:"#1e1e1e"},eC="__shiki_resolved";function kb(e){var u,d,h,p,m;if(e!=null&&e[eC])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||(t.type="dark"),t.colorReplacements={...t.colorReplacements},t.settings||(t.settings=[]);let{bg:n,fg:r}=t;if(!n||!r){const g=t.settings?t.settings.find(x=>!x.name&&!x.scope):void 0;(u=g==null?void 0:g.settings)!=null&&u.foreground&&(r=g.settings.foreground),(d=g==null?void 0:g.settings)!=null&&d.background&&(n=g.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"?Q1.light:Q1.dark),n||(n=t.type==="light"?Z1.light:Z1.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 c(g){var w;if(l.has(g))return l.get(g);a+=1;const x=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${x}`]?c(g):(l.set(g,x),x)}t.settings=t.settings.map(g=>{var _,S;const x=((_=g.settings)==null?void 0:_.foreground)&&!g.settings.foreground.startsWith("#"),w=((S=g.settings)==null?void 0:S.background)&&!g.settings.background.startsWith("#");if(!x&&!w)return g;const C={...g,settings:{...g.settings}};if(x){const v=c(g.settings.foreground);t.colorReplacements[v]=g.settings.foreground,C.settings.foreground=v}if(w){const v=c(g.settings.background);t.colorReplacements[v]=g.settings.background,C.settings.background=v}return C});for(const g of Object.keys(t.colors||{}))if((g==="editor.foreground"||g==="editor.background"||g.startsWith("terminal.ansi"))&&!((m=t.colors[g])!=null&&m.startsWith("#"))){const x=c(t.colors[g]);t.colorReplacements[x]=t.colors[g],t.colors[g]=x}return Object.defineProperty(t,eC,{enumerable:!1,writable:!1,value:!0}),t}async function L2(e){return[...new Set((await Promise.all(e.filter(t=>!T2(t)).map(async t=>await N2(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function D2(e){return(await Promise.all(e.map(async t=>A2(t)?null:kb(await N2(t))))).filter(t=>!!t)}function R2(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 nn(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var S8=class extends b8{constructor(t,n,r,a={}){super(t);Ae(this,"_resolver");Ae(this,"_themes");Ae(this,"_langs");Ae(this,"_alias");Ae(this,"_resolvedThemes",new Map);Ae(this,"_resolvedGrammars",new Map);Ae(this,"_langMap",new Map);Ae(this,"_langGraph",new Map);Ae(this,"_textmateThemeCache",new WeakMap);Ae(this,"_loadedThemesCache",null);Ae(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=kb(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=Ph.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=R2(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var l,c,u,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,(c=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||c.delete(h.scopeName),(d=(u=this._syncRegistry)==null?void 0:u._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,c])=>{var u;return c?(u=c.embeddedLanguages||c.embeddedLangs)==null?void 0:u.some(d=>r.map(([h])=>h).includes(d)):!1}).filter(l=>!r.includes(l));throw new nn(`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))}},w8=class{constructor(e,t){Ae(this,"_langs",new Map);Ae(this,"_scopeToLang",new Map);Ae(this,"_injections",new Map);Ae(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 Nc=0;function C8(e){Nc+=1,e.warnings!==!1&&Nc>=10&&Nc%10===0&&console.warn(`[Shiki] ${Nc} 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 nn("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(kb),a=new S8(new w8(e.engine,n),r,n,e.langAlias);let l;function c(v){return R2(v,e.langAlias)}function u(v){_();const b=a.getGrammar(typeof v=="string"?v:v.name);if(!b)throw new nn(`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 nn(`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 g(...v){_(),a.loadLanguages(v.flat(1))}async function x(...v){return g(await L2(v))}function w(...v){_();for(const b of v.flat(1))a.loadTheme(b)}async function C(...v){return _(),w(await D2(v))}function _(){if(t)throw new nn("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),Nc-=1)}return{setTheme:h,getTheme:d,getLanguage:u,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:c,loadLanguage:x,loadLanguageSync:g,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function k8(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([D2(e.themes||[]),L2(e.langs||[]),e.engine]);return C8({...e,themes:t,langs:n,engine:r})}const O2=new WeakMap;function zf(e,t){O2.set(e,t)}function ou(e){return O2.get(e)}var Hf=class I2{constructor(...t){Ae(this,"_stacks",{});Ae(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 I2(Object.fromEntries(v8(n).map(r=>[r,ny])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return j8(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function j8(e){const t=[],n=new Set;function r(a){var c;if(n.has(a))return;n.add(a);const l=(c=a==null?void 0:a.nameScopesList)==null?void 0:c.scopeName;l&&t.push(l),a.parent&&r(a.parent)}return r(e),t}function E8(e,t){if(!(e instanceof Hf))throw new nn("Invalid grammar state");return e.getInternalStack(t)}const N8=/,/,T8=/ /;function M2(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Pf(e.resolveLangAlias(n.lang||"text"))||Bf(r))return $f(t).map(u=>[{content:u[0],offset:u[1]}]);const{theme:a,colorMap:l}=e.setTheme(r),c=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==c.name)throw new nn(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${c.name}"`);if(!n.grammarState.themes.includes(a.name))throw new nn(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return L8(t,c,a,l,n)}function A8(...e){if(e.length===2)return ou(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=r;if(Pf(a)||Bf(l))throw new nn("Plain language does not have grammar state");if(a==="ansi")throw new nn("ANSI language does not have grammar state");const{theme:c,colorMap:u}=t.setTheme(l),d=t.getLanguage(a);return new Hf(jb(n,d,c,u,r).stateStack,d.name,c.name)}function L8(e,t,n,r,a){const l=jb(e,t,n,r,a),c=new Hf(l.stateStack,t.name,n.name);return zf(l.tokens,c),l.tokens}function jb(e,t,n,r,a){const l=Fh(n,a),{tokenizeMaxLineLength:c=0,tokenizeTimeLimit:u=500,includeExplanation:d=!1}=a,h=$f(e);let p=a.grammarState?E8(a.grammarState,n.name)??ny:a.grammarContextCode!=null?jb(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:ny,m=[];const g=[];for(let x=0,w=h.length;x<w;x++){const[C,_]=h[x];if(C===""){m=[],g.push([]);continue}if(c>0&&C.length>=c){m=[],g.push([{content:C,offset:_,color:"",fontStyle:0}]);continue}let S,v,b;d&&d!=="tokenType"&&(S=t.tokenizeLine(C,p,u),v=S.tokens,b=0);const k=t.tokenizeLine2(C,p,u),N=k.tokens.length/2;for(let E=0;E<N;E++){const D=k.tokens[2*E],A=E+1<N?k.tokens[2*E+2]:C.length;if(D===A)continue;const O=k.tokens[2*E+1],P=Xi(r[Wa.getForeground(O)],l),G=Wa.getFontStyle(O),z={content:C.substring(D,A),offset:_+D,color:P,fontStyle:G};if(d==="tokenType")z.type=Wa.getTokenType(O);else if(d){const V=[];if(d!=="scopeName")for(const H of n.settings){let q;switch(typeof H.scope){case"string":q=H.scope.split(N8).map(X=>X.trim());break;case"object":q=H.scope;break;default:continue}V.push({settings:H,selectors:q.map(X=>X.split(T8))})}z.explanation=[];let $=0;for(;D+$<A;){const H=v[b],q=C.substring(H.startIndex,H.endIndex);$+=q.length,z.explanation.push({content:q,scopes:d==="scopeName"?D8(H.scopes):R8(V,H.scopes)}),b+=1}}m.push(z)}g.push(m),m=[],p=k.ruleStack}return{tokens:g,stateStack:p}}function D8(e){return e.map(t=>({scopeName:t}))}function R8(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const l=t[r];n[r]={scopeName:l,themeMatches:I8(e,l,t.slice(0,r))}}return n}function tC(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function O8(e,t,n){if(!tC(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)tC(e[r],n[a])&&(r-=1),a-=1;return r===-1}function I8(e,t,n){const r=[];for(const{selectors:a,settings:l}of e)for(const c of a)if(O8(c,t,n)){r.push(l);break}return r}function P2(e,t,n,r=M2){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:ou(p),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),c=M8(...l.map(h=>h.tokens)),u=c[0].map((h,p)=>h.map((m,g)=>{const x={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=m.explanation),c.forEach((w,C)=>{const{content:_,explanation:S,offset:v,...b}=w[p][g];x.variants[a[C].color]=b}),x})),d=l[0].state?new Hf(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&&zf(u,d),u}function M8(...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 c=a.map(()=>0),u=a.map(d=>d[0]);for(;u.every(d=>d);){const d=Math.min(...u.map(h=>h.content.length));for(let h=0;h<n;h++){const p=u[h];p.content.length===d?(l[h].push(p),c[h]+=1,u[h]=a[h][c[h]]):(l[h].push({...p,content:p.content.slice(0,d)}),u[h]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const P8=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class bu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}bu.prototype.normal={};bu.prototype.property={};bu.prototype.space=void 0;function B2(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new bu(n,r,t)}function ry(e){return e.toLowerCase()}class vr{constructor(t,n){this.attribute=n,this.property=t}}vr.prototype.attribute="";vr.prototype.booleanish=!1;vr.prototype.boolean=!1;vr.prototype.commaOrSpaceSeparated=!1;vr.prototype.commaSeparated=!1;vr.prototype.defined=!1;vr.prototype.mustUseProperty=!1;vr.prototype.number=!1;vr.prototype.overloadedBoolean=!1;vr.prototype.property="";vr.prototype.spaceSeparated=!1;vr.prototype.space=void 0;let B8=0;const gt=eo(),An=eo(),sy=eo(),Ke=eo(),Zt=eo(),qa=eo(),Tr=eo();function eo(){return 2**++B8}const iy=Object.freeze(Object.defineProperty({__proto__:null,boolean:gt,booleanish:An,commaOrSpaceSeparated:Tr,commaSeparated:qa,number:Ke,overloadedBoolean:sy,spaceSeparated:Zt},Symbol.toStringTag,{value:"Module"})),Kg=Object.keys(iy);class Eb extends vr{constructor(t,n,r,a){let l=-1;if(super(t,n),nC(this,"space",a),typeof r=="number")for(;++l<Kg.length;){const c=Kg[l];nC(this,Kg[l],(r&iy[c])===iy[c])}}}Eb.prototype.defined=!0;function nC(e,t,n){n&&(e[t]=n)}function wl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new Eb(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[ry(r)]=r,n[ry(l.attribute)]=r}return new bu(t,n,e.space)}const $2=wl({properties:{ariaActiveDescendant:null,ariaAtomic:An,ariaAutoComplete:null,ariaBusy:An,ariaChecked:An,ariaColCount:Ke,ariaColIndex:Ke,ariaColSpan:Ke,ariaControls:Zt,ariaCurrent:null,ariaDescribedBy:Zt,ariaDetails:null,ariaDisabled:An,ariaDropEffect:Zt,ariaErrorMessage:null,ariaExpanded:An,ariaFlowTo:Zt,ariaGrabbed:An,ariaHasPopup:null,ariaHidden:An,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Zt,ariaLevel:Ke,ariaLive:null,ariaModal:An,ariaMultiLine:An,ariaMultiSelectable:An,ariaOrientation:null,ariaOwns:Zt,ariaPlaceholder:null,ariaPosInSet:Ke,ariaPressed:An,ariaReadOnly:An,ariaRelevant:null,ariaRequired:An,ariaRoleDescription:Zt,ariaRowCount:Ke,ariaRowIndex:Ke,ariaRowSpan:Ke,ariaSelected:An,ariaSetSize:Ke,ariaSort:null,ariaValueMax:Ke,ariaValueMin:Ke,ariaValueNow:Ke,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function z2(e,t){return t in e?e[t]:t}function H2(e,t){return z2(e,t.toLowerCase())}const $8=wl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qa,acceptCharset:Zt,accessKey:Zt,action:null,allow:null,allowFullScreen:gt,allowPaymentRequest:gt,allowUserMedia:gt,alpha:gt,alt:null,as:null,async:gt,autoCapitalize:null,autoComplete:Zt,autoFocus:gt,autoPlay:gt,blocking:Zt,capture:null,charSet:null,checked:gt,cite:null,className:Zt,closedBy:null,colorSpace:null,cols:Ke,colSpan:Ke,command:null,commandFor:null,content:null,contentEditable:An,controls:gt,controlsList:Zt,coords:Ke|qa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gt,defer:gt,dir:null,dirName:null,disabled:gt,download:sy,draggable:An,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gt,formTarget:null,headers:Zt,height:Ke,hidden:sy,high:Ke,href:null,hrefLang:null,htmlFor:Zt,httpEquiv:Zt,id:null,imageSizes:null,imageSrcSet:null,inert:gt,inputMode:null,integrity:null,is:null,isMap:gt,itemId:null,itemProp:Zt,itemRef:Zt,itemScope:gt,itemType:Zt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gt,low:Ke,manifest:null,max:null,maxLength:Ke,media:null,method:null,min:null,minLength:Ke,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:Ke,pattern:null,ping:Zt,placeholder:null,playsInline:gt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gt,referrerPolicy:null,rel:Zt,required:gt,reversed:gt,rows:Ke,rowSpan:Ke,sandbox:Zt,scope:null,scoped:gt,seamless:gt,selected:gt,shadowRootClonable:gt,shadowRootCustomElementRegistry:gt,shadowRootDelegatesFocus:gt,shadowRootMode:null,shadowRootSerializable:gt,shape:null,size:Ke,sizes:null,slot:null,span:Ke,spellCheck:An,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ke,step:null,style:null,tabIndex:Ke,target:null,title:null,translate:null,type:null,typeMustMatch:gt,useMap:null,value:An,width:Ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Zt,axis:null,background:null,bgColor:null,border:Ke,borderColor:null,bottomMargin:Ke,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:Ke,leftMargin:Ke,link:null,longDesc:null,lowSrc:null,marginHeight:Ke,marginWidth:Ke,noResize:gt,noHref:gt,noShade:gt,noWrap:gt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ke,rules:null,scheme:null,scrolling:An,standby:null,summary:null,text:null,topMargin:Ke,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ke,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:gt,disablePictureInPicture:gt,disableRemotePlayback:gt,exportParts:qa,part:Zt,prefix:null,property:null,results:Ke,security:null,unselectable:null},space:"html",transform:H2}),z8=wl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Tr,accentHeight:Ke,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ke,amplitude:Ke,arabicForm:null,ascent:Ke,attributeName:null,attributeType:null,azimuth:Ke,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ke,by:null,calcMode:null,capHeight:Ke,className:Zt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ke,diffuseConstant:Ke,direction:null,display:null,dur:null,divisor:Ke,dominantBaseline:null,download:gt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ke,enableBackground:null,end:null,event:null,exponent:Ke,externalResourcesRequired:null,fill:null,fillOpacity:Ke,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:qa,g2:qa,glyphName:qa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ke,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ke,horizOriginX:Ke,horizOriginY:Ke,id:null,ideographic:Ke,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ke,k:Ke,k1:Ke,k2:Ke,k3:Ke,k4:Ke,kernelMatrix:Tr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ke,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ke,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:Ke,overlineThickness:Ke,paintOrder:null,panose1:null,path:null,pathLength:Ke,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Zt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ke,pointsAtY:Ke,pointsAtZ:Ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Tr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Tr,rev:Tr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Tr,requiredFeatures:Tr,requiredFonts:Tr,requiredFormats:Tr,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:Ke,specularExponent:Ke,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ke,strikethroughThickness:Ke,string:null,stroke:null,strokeDashArray:Tr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ke,strokeOpacity:Ke,strokeWidth:null,style:null,surfaceScale:Ke,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Tr,tabIndex:Ke,tableValues:null,target:null,targetX:Ke,targetY:Ke,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Tr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ke,underlineThickness:Ke,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ke,values:null,vAlphabetic:Ke,vMathematical:Ke,vectorEffect:null,vHanging:Ke,vIdeographic:Ke,version:null,vertAdvY:Ke,vertOriginX:Ke,vertOriginY:Ke,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ke,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:z2}),F2=wl({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()}}),U2=wl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:H2}),V2=wl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),H8=/[A-Z]/g,rC=/-[a-z]/g,F8=/^data[-\w.:]+$/i;function U8(e,t){const n=ry(t);let r=t,a=vr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&F8.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(rC,G8);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!rC.test(l)){let c=l.replace(H8,V8);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Eb}return new a(r,t)}function V8(e){return"-"+e.toLowerCase()}function G8(e){return e.charAt(1).toUpperCase()}const W8=B2([$2,$8,F2,U2,V2],"html"),G2=B2([$2,z8,F2,U2,V2],"svg"),sC={}.hasOwnProperty;function q8(e,t){const n=t||{};function r(a,...l){let c=r.invalid;const u=r.handlers;if(a&&sC.call(a,e)){const d=String(a[e]);c=sC.call(u,d)?u[d]:r.unknown}if(c)return c.call(this,a,...l)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const K8=/["&'<>`]/g,Y8=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,X8=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,J8=/[|\\{}()[\]^$+*?.]/g,iC=new WeakMap;function Q8(e,t){if(e=e.replace(t.subset?Z8(t.subset):K8,r),t.subset||t.escapeOnly)return e;return e.replace(Y8,n).replace(X8,r);function n(a,l,c){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,c.charCodeAt(l+2),t)}function r(a,l,c){return t.format(a.charCodeAt(0),c.charCodeAt(l+1),t)}}function Z8(e){let t=iC.get(e);return t||(t=e$(e),iC.set(e,t)),t}function e$(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(J8,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const t$=/[\dA-Fa-f]/;function n$(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!t$.test(String.fromCharCode(t))?r:r+";"}const r$=/\d/;function s$(e,t,n){const r="&#"+String(e);return n&&t&&!r$.test(String.fromCharCode(t))?r:r+";"}const i$=["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"],Yg={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:"€"},a$=["cent","copy","divide","gt","lt","not","para","times"],W2={}.hasOwnProperty,ay={};let Kd;for(Kd in Yg)W2.call(Yg,Kd)&&(ay[Yg[Kd]]=Kd);const o$=/[^\dA-Za-z]/;function l$(e,t,n,r){const a=String.fromCharCode(e);if(W2.call(ay,a)){const l=ay[a],c="&"+l;return n&&i$.includes(l)&&!a$.includes(l)&&(!r||t&&t!==61&&o$.test(String.fromCharCode(t)))?c:c+";"}return""}function c$(e,t,n){let r=n$(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=l$(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=s$(e,t,n.omitOptionalSemicolons);l.length<r.length&&(r=l)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function al(e,t){return Q8(e,Object.assign({format:c$},t))}const u$=/^>|^->|<!--|-->|--!>|<!-$/g,d$=[">"],h$=["<",">"];function f$(e,t,n,r){return r.settings.bogusComments?"<?"+al(e.value,Object.assign({},r.settings.characterReferences,{subset:d$}))+">":"<!--"+e.value.replace(u$,a)+"-->";function a(l){return al(l,Object.assign({},r.settings.characterReferences,{subset:h$}))}}function m$(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function aC(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 p$(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function g$(e){return e.join(" ").trim()}const x$=/[ \t\n\f\r]/g;function Nb(e){return typeof e=="object"?e.type==="text"?oC(e.value):!1:oC(e)}function oC(e){return e.replace(x$,"")===""}const Pn=K2(1),q2=K2(-1),y$=[];function K2(e){return t;function t(n,r,a){const l=n?n.children:y$;let c=(r||0)+e,u=l[c];if(!a)for(;u&&Nb(u);)c+=e,u=l[c];return u}}const b$={}.hasOwnProperty;function Y2(e){return t;function t(n,r,a){return b$.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const Tb=Y2({body:_$,caption:Xg,colgroup:Xg,dd:k$,dt:C$,head:Xg,html:v$,li:w$,optgroup:j$,option:E$,p:S$,rp:lC,rt:lC,tbody:T$,td:cC,tfoot:A$,th:cC,thead:N$,tr:L$});function Xg(e,t,n){const r=Pn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Nb(r.value.charAt(0)))}function v$(e,t,n){const r=Pn(n,t);return!r||r.type!=="comment"}function _$(e,t,n){const r=Pn(n,t);return!r||r.type!=="comment"}function S$(e,t,n){const r=Pn(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function w$(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function C$(e,t,n){const r=Pn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function k$(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function lC(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function j$(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function E$(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function N$(e,t,n){const r=Pn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function T$(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function A$(e,t,n){return!Pn(n,t)}function L$(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function cC(e,t,n){const r=Pn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const D$=Y2({body:I$,colgroup:M$,head:O$,html:R$,tbody:P$});function R$(e){const t=Pn(e,-1);return!t||t.type!=="comment"}function O$(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 I$(e){const t=Pn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Nb(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function M$(e,t,n){const r=q2(n,t),a=Pn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Tb(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function P$(e,t,n){const r=q2(n,t),a=Pn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Tb(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const Yd={name:[[`
98
+ \f\r &/=>`.split(""),`
99
+ \f\r "&'/=>\``.split("")],[`\0
100
+ \f\r "&'/<=>`.split(""),`\0
101
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
102
+ \f\r &>`.split(""),`\0
103
+ \f\r "&'<=>\``.split("")],[`\0
104
+ \f\r "&'<=>\``.split(""),`\0
105
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function B$(e,t,n,r){const a=r.schema,l=a.space==="svg"?!1:r.settings.omitOptionalTags;let c=a.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const u=[];let d;a.space==="html"&&e.tagName==="svg"&&(r.schema=G2);const h=$$(r,e.properties),p=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,p&&(c=!1),(h||!l||!D$(e,t,n))&&(u.push("<",e.tagName,h?" "+h:""),c&&(a.space==="svg"||r.settings.closeSelfClosing)&&(d=h.charAt(h.length-1),(!r.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&u.push(" "),u.push("/")),u.push(">")),u.push(p),!c&&(!l||!Tb(e,t,n))&&u.push("</"+e.tagName+">"),u.join("")}function $$(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=z$(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 z$(e,t,n){const r=U8(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,l=e.settings.allowDangerousCharacters?0:1;let c=e.quote,u;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const d=al(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Yd.name[a][l]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?p$:g$)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(u=al(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Yd.unquoted[a][l]}))),u!==n&&(e.settings.quoteSmart&&aC(n,c)>aC(n,e.alternative)&&(c=e.alternative),u=c+al(n,Object.assign({},e.settings.characterReferences,{subset:(c==="'"?Yd.single:Yd.double)[a][l],attribute:!0}))+c),d+(u&&"="+u))}const H$=["<","&"];function X2(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:al(e.value,Object.assign({},r.settings.characterReferences,{subset:H$}))}function F$(e,t,n,r){return r.settings.allowDangerousHtml?e.value:X2(e,t,n,r)}function U$(e,t,n,r){return r.all(e)}const V$=q8("type",{invalid:G$,unknown:W$,handlers:{comment:f$,doctype:m$,element:B$,raw:F$,root:U$,text:X2}});function G$(e){throw new Error("Expected node, not `"+e+"`")}function W$(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const q$={},K$={},Y$=[];function X$(e,t){const n=t||q$,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:J$,all:Q$,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||P8,characterReferences:n.characterReferences||K$,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?G2:W8,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function J$(e,t,n){return V$(e,t,n,this)}function Q$(e){const t=[],n=e&&e.children||Y$;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const uC=/\s+/g;function J2(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(uC)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(uC);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const Z$=/:?lang=["']([^"']+)["']/g,ez=/(?:```|~~~)([\w-]+)/g,tz=/\\begin\{([\w-]+)\}/g,nz=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function rz(e){const t=$f(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,c=0;for(const u of t){if(l<u.length)break;l-=u.length,c++}return{line:c,character:l}}function r(a,l){let c=0;for(let u=0;u<a;u++)c+=t[u].length;return c+=l,c}return{lines:t,indexToPos:n,posToIndex:r}}function sz(e,t,n){const r=new Set;for(const l of e.matchAll(Z$)){const c=l[1].toLowerCase().trim();c&&r.add(c)}for(const l of e.matchAll(ez)){const c=l[1].toLowerCase().trim();c&&r.add(c)}for(const l of e.matchAll(tz)){const c=l[1].toLowerCase().trim();c&&r.add(c)}for(const l of e.matchAll(nz)){const c=l[1].toLowerCase().trim(),u=c.includes("/")?c.split("/").pop():c;u&&r.add(u)}if(!n)return[...r];const a=n.getBundledLanguages();return[...r].filter(l=>l&&a[l])}const iz=["color","background-color"];function az(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 oz(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(c=>a.offset<c&&c<a.offset+a.content.length).map(c=>c-a.offset).sort((c,u)=>c-u);return l.length?az(a,l):a})):e}function lz(e,t,n,r,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},c=t.map(p=>Uh(e.variants[p])),u=new Set(c.flatMap(p=>Object.keys(p))),d={},h=(p,m)=>{const g=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":g)};return c.forEach((p,m)=>{for(const g of u){const x=p[g]||"inherit";if(m===0&&r&&iz.includes(g))if(r==="light-dark()"&&c.length>1){const w=t.findIndex(_=>_==="light"),C=t.findIndex(_=>_==="dark");if(w===-1||C===-1)throw new nn('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[g]=`light-dark(${c[w][g]||"inherit"}, ${c[C][g]||"inherit"})`,a==="css-vars"&&(d[h(m,g)]=x)}else d[g]=x;else a==="css-vars"&&(d[h(m,g)]=x)}}),l.htmlStyle=d,l}function Uh(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&Zn.Italic&&(t["font-style"]="italic"),e.fontStyle&Zn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&Zn.Underline&&n.push("underline"),e.fontStyle&Zn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function oy(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function cz(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let l=function(u){if(typeof u=="number"){if(u<0||u>n.source.length)throw new nn(`Invalid decoration offset: ${u}. Code length: ${n.source.length}`);return{...a.indexToPos(u),offset:u}}else{const d=a.lines[u.line];if(d===void 0)throw new nn(`Invalid decoration position ${JSON.stringify(u)}. Lines length: ${a.lines.length}`);let h=u.character;if(h<0&&(h=d.length+h),h<0||h>d.length)throw new nn(`Invalid decoration position ${JSON.stringify(u)}. Line ${u.line} length: ${d.length}`);return{...u,character:h,offset:a.posToIndex(u.line,h)}}};var r=l;const a=rz(n.source),c=(n.options.decorations||[]).map(u=>({...u,start:l(u.start),end:l(u.end)}));uz(c),e.set(n.meta,{decorations:c,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 oz(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 nn(`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,g,x,w){const C=a[m];let _="",S=-1,v=-1;if(g===0&&(S=0),x===0&&(v=0),x===Number.POSITIVE_INFINITY&&(v=C.children.length),S===-1||v===-1)for(let k=0;k<C.children.length;k++)_+=Q2(C.children[k]),S===-1&&_.length===g&&(S=k+1),v===-1&&_.length===x&&(v=k+1);if(S===-1)throw new nn(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(v===-1)throw new nn(`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)u(C,w,"line");else if(!w.alwaysWrap&&b.length===1&&b[0].type==="element")u(b[0],w,"token");else{const k={type:"element",tagName:"span",properties:{},children:b};u(k,w,"wrapper"),C.children.splice(S,b.length,k)}}function c(m,g){a[m]=u(a[m],g,"line")}function u(m,g,x){var _;const w=g.properties||{},C=g.transform||(S=>S);return m.tagName=g.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(_=g.properties)!=null&&_.class&&J2(m,g.properties.class),m=C(m,x)||m,m}const d=[],h=r.decorations.sort((m,g)=>g.start.offset-m.start.offset||m.end.offset-g.end.offset);for(const m of h){const{start:g,end:x}=m;if(g.line===x.line)l(g.line,g.character,x.character,m);else if(g.line<x.line){l(g.line,g.character,Number.POSITIVE_INFINITY,m);for(let w=g.line+1;w<x.line;w++)d.unshift(()=>c(w,m));l(x.line,0,x.character,m)}}d.forEach(m=>m())}}}function uz(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new nn(`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,c=n.start.offset<a.end.offset&&a.end.offset<=n.end.offset,u=a.start.offset<=n.start.offset&&n.start.offset<a.end.offset,d=a.start.offset<n.end.offset&&n.end.offset<=a.end.offset;if(l||c||u||d){if(l&&c||u&&d||u&&n.start.offset===n.end.offset||c&&a.start.offset===a.end.offset)continue;throw new nn(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function Q2(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Q2).join(""):""}const dz=[cz()];function Vh(e){const t=hz(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...dz]}function hz(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 Ma=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Jg={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function fz(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 dC(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 mz(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)Jg[r]&&t.push({type:"setDecoration",value:Jg[r]});else if(r<=29){const a=Jg[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:Ma[r-30]}});else if(r===38){const a=dC(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:Ma[r-40]}});else if(r===48){const a=dC(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:Ma[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Ma[r-100+8]}})}return t}function pz(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let l=0;do{const c=fz(r,l),u=c.sequence?r.substring(l,c.startPosition):r.substring(l);if(u.length>0&&a.push({value:u,foreground:e,background:t,decorations:new Set(n)}),c.sequence){const d=mz(c.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=c.position}while(l<r.length);return a}}}var gz={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 xz(e=gz){function t(u){return e[u]}function n(u){return`#${u.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<Ma.length;h++)r.push(t(Ma[h]));let u=[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([u[h],u[p],u[m]]));let d=8;for(let h=0;h<24;h++,d+=10)r.push(n([d,d,d]));return r}function l(u){return a()[u]}function c(u){switch(u.type){case"named":return t(u.name);case"rgb":return n(u.rgb);case"table":return l(u.index)}}return{value:c}}const yz=/#([0-9a-f]{3,8})/i,bz=/var\((--[\w-]+-ansi-[\w-]+)\)/,vz={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function _z(e,t,n){const r=Fh(e,n),a=$f(t),l=xz(Object.fromEntries(Ma.map(u=>{var h;const d=`terminal.ansi${u[0].toUpperCase()}${u.substring(1)}`;return[u,((h=e.colors)==null?void 0:h[d])||vz[u]]}))),c=pz();return a.map(u=>c.parse(u[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=Xi(h,r),p=Xi(p,r),d.decorations.has("dim")&&(h=Sz(h));let m=Zn.None;return d.decorations.has("bold")&&(m|=Zn.Bold),d.decorations.has("italic")&&(m|=Zn.Italic),d.decorations.has("underline")&&(m|=Zn.Underline),d.decorations.has("strikethrough")&&(m|=Zn.Strikethrough),{content:d.value,offset:u[1],color:h,bgColor:p,fontStyle:m}}))}function Sz(e){const t=e.match(yz);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],c=r[2],u=r[3];return`#${a}${a}${l}${l}${c}${c}${Math.round(Number.parseInt(`${u}${u}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],l=r[1],c=r[2];return`#${a}${a}${l}${l}${c}${c}80`}}}const n=e.match(bz);return n?`var(${n[1]}-dim)`:e}function ly(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!Pf(r)&&!Bf(a)&&r==="ansi"){const{theme:l}=e.setTheme(a);return _z(l,t,n)}return M2(e,t,n)}function Gh(e,t,n){let r,a,l,c,u,d;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,g=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(g.length===0)throw new nn("`themes` option must not be empty");const x=P2(e,t,n,ly);if(d=ou(x),h&&h!=="light-dark()"&&!g.some(S=>S.color===h))throw new nn(`\`themes\` option must contain the defaultColor key \`${h}\``);const w=g.map(S=>e.getTheme(S.theme)),C=g.map(S=>S.color);l=x.map(S=>S.map(v=>lz(v,C,p,h,m))),d&&zf(l,d);const _=g.map(S=>Fh(S.theme,n));a=hC(g,w,_,p,h,"fg",m),r=hC(g,w,_,p,h,"bg",m),c=`shiki-themes ${w.map(S=>S.name).join(" ")}`,u=h?void 0:[a,r].join(";")}else if("theme"in n){const h=Fh(n.theme,n);l=ly(e,t,n);const p=e.getTheme(n.theme);r=Xi(p.bg,h),a=Xi(p.fg,h),c=p.name,d=ou(l)}else throw new nn("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:r,themeName:c,rootStyle:u,grammarState:d}}function hC(e,t,n,r,a,l,c){return e.map((u,d)=>{const h=Xi(t[d][l],n[d])||"inherit",p=`${r+u.color}${l==="bg"?"-bg":""}:${h}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(x=>x.color==="light"),g=e.findIndex(x=>x.color==="dark");if(m===-1||g===-1)throw new nn('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Xi(t[m][l],n[m])||"inherit"}, ${Xi(t[g][l],n[g])||"inherit"});${p}`}return h}return c==="css-vars"?p:null}).filter(u=>!!u).join(";")}const Z2=/^\s+$/,wz=/^(\s*)(.*?)(\s*)$/;function Wh(e,t,n,r={meta:{},options:n,codeToHast:(a,l)=>Wh(e,a,l),codeToTokens:(a,l)=>Gh(e,a,l)}){var w,C;let a=t;for(const _ of Vh(n))a=((w=_.preprocess)==null?void 0:w.call(r,a,n))||a;let{tokens:l,fg:c,bg:u,themeName:d,rootStyle:h,grammarState:p}=Gh(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:g=!1}=n;m===!0?l=kz(l):m==="never"&&(l=jz(l)),g&&(l=Ez(l));const x={...r,get source(){return a}};for(const _ of Vh(n))l=((C=_.tokens)==null?void 0:C.call(x,l))||l;return Cz(l,{...n,fg:c,bg:u,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},x,p)}function Cz(e,t,n,r=ou(e)){var C,_,S,v;const a=Vh(t),l=[],c={type:"root",children:[]},{structure:u="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,k]of Object.entries(t.meta||{}))b.startsWith("_")||(h[b]=k);let p={type:"element",tagName:"pre",properties:h,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const g=[],x={...n,structure:u,addClassToHast:J2,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return c},get pre(){return p},get code(){return m},get lines(){return g}};if(e.forEach((b,k)=>{var D,A;k&&(u==="inline"?c.children.push({type:"element",tagName:"br",properties:{},children:[]}):u==="classic"&&l.push({type:"text",value:`
106
+ `}));let N={type:"element",tagName:"span",properties:{class:"line"},children:[]},E=0;for(const O of b){let P={type:"element",tagName:"span",properties:{...O.htmlAttrs},children:[{type:"text",value:O.content}]};const G=oy(O.htmlStyle||Uh(O));G&&(P.properties.style=G);for(const z of a)P=((D=z==null?void 0:z.span)==null?void 0:D.call(x,P,k+1,E,N,O))||P;u==="inline"?c.children.push(P):u==="classic"&&N.children.push(P),E+=O.content.length}if(u==="classic"){for(const O of a)N=((A=O==null?void 0:O.line)==null?void 0:A.call(x,N,k+1))||N;g.push(N),l.push(N)}else u==="inline"&&g.push(N)}),u==="classic"){for(const b of a)m=((C=b==null?void 0:b.code)==null?void 0:C.call(x,m))||m;p.children.push(m);for(const b of a)p=((_=b==null?void 0:b.pre)==null?void 0:_.call(x,p))||p;c.children.push(p)}else if(u==="inline"){const b=[];let k={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const E of c.children)E.type==="element"&&E.tagName==="br"?(b.push(k),k={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(E.type==="element"||E.type==="text")&&k.children.push(E);b.push(k);let N={type:"element",tagName:"code",properties:{},children:b};for(const E of a)N=((S=E==null?void 0:E.code)==null?void 0:S.call(x,N))||N;c.children=[];for(let E=0;E<N.children.length;E++){E>0&&c.children.push({type:"element",tagName:"br",properties:{},children:[]});const D=N.children[E];D.type==="element"&&c.children.push(...D.children)}}let w=c;for(const b of a)w=((v=b==null?void 0:b.root)==null?void 0:v.call(x,w))||w;return r&&zf(w,r),w}function kz(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((l,c)=>{const u=!(l.fontStyle&&(l.fontStyle&Zn.Underline||l.fontStyle&Zn.Strikethrough));u&&Z2.test(l.content)&&t[c+1]?(a===void 0&&(a=l.offset),r+=l.content):r?(u?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 jz(e){return e.map(t=>t.flatMap(n=>{if(Z2.test(n.content))return n;const r=n.content.match(wz);if(!r)return n;const[,a,l,c]=r;if(!a&&!c)return n;const u=[{...n,offset:n.offset+a.length,content:l}];return a&&u.unshift({content:a,offset:n.offset}),c&&u.push({content:c,offset:n.offset+a.length+l.length}),u}))}function Ez(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=oy(a.htmlStyle||Uh(a)),c=oy(r.htmlStyle||Uh(r)),u=a.fontStyle&&(a.fontStyle&Zn.Underline||a.fontStyle&Zn.Strikethrough),d=r.fontStyle&&(r.fontStyle&Zn.Underline||r.fontStyle&Zn.Strikethrough);!u&&!d&&l===c?a.content+=r.content:n.push({...r})}return n})}const Nz=X$;function Tz(e,t,n){var l;const r={meta:{},options:n,codeToHast:(c,u)=>Wh(e,c,u),codeToTokens:(c,u)=>Gh(e,c,u)};let a=Nz(Wh(e,t,n,r));for(const c of Vh(n))a=((l=c.postprocess)==null?void 0:l.call(r,a,n))||a;return a}async function Az(e){const t=await k8(e);return{getLastGrammarState:(...n)=>A8(t,...n),codeToTokensBase:(n,r)=>ly(t,n,r),codeToTokensWithThemes:(n,r)=>P2(t,n,r),codeToTokens:(n,r)=>Gh(t,n,r),codeToHast:(n,r)=>Wh(t,n,r),codeToHtml:(n,r)=>Tz(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Lz(e){const t=e.langs,n=e.themes,r=e.engine;async function a(l){function c(m){var g;if(typeof m=="string"){if(m=((g=l.langAlias)==null?void 0:g[m])||m,T2(m))return[];const x=t[m];if(!x)throw new nn(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return x}return m}function u(m){if(A2(m))return"none";if(typeof m=="string"){const g=n[m];if(!g)throw new nn(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return g}return m}const d=(l.themes??[]).map(m=>u(m)),h=(l.langs??[]).map(m=>c(m)),p=await Az({engine:l.engine??r(),...l,themes:d,langs:h});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(c))},loadTheme(...m){return p.loadTheme(...m.map(u))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function Dz(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 Rz(e,t){const n=Dz(e);async function r(a,l){var d;const c=await n({langs:[l.lang],themes:"theme"in l?[l.theme]:Object.values(l.themes)}),u=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,a,l.lang,c));return u&&await c.loadLanguage(...u),c}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 Oz=xb({bundledLanguages:()=>Of,bundledLanguagesAlias:()=>bb,bundledLanguagesBase:()=>yb,bundledLanguagesInfo:()=>Rf,bundledThemes:()=>_b,bundledThemesInfo:()=>vb,codeToHast:()=>tN,codeToHtml:()=>eN,codeToTokens:()=>nN,codeToTokensBase:()=>rN,codeToTokensWithThemes:()=>sN,createHighlighter:()=>Ff,getLastGrammarState:()=>aN,getSingletonHighlighter:()=>iN});const Ff=Lz({langs:Of,themes:_b,engine:()=>(0,h2.createOnigurumaEngine)(ne(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:eN,codeToHast:tN,codeToTokens:nN,codeToTokensBase:rN,codeToTokensWithThemes:sN,getSingletonHighlighter:iN,getLastGrammarState:aN}=Rz(Ff,{guessEmbeddedLanguages:sz}),fC=4294967295;var Iz=class{constructor(e,t={}){Ae(this,"patterns");Ae(this,"options");Ae(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 c=r==null?void 0:r.get(l);if(c){if(c instanceof RegExp)return c;if(n)return null;throw c}try{const u=a(l);return r==null||r.set(l,u),u}catch(u){if(r==null||r.set(l,u),n)return null;throw u}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function l(c,u,d=0){return{index:c,captureIndices:u.indices.map(h=>h==null?{start:fC,end:fC,length:0}:{start:h[0]+d,end:h[1]+d,length:h[1]-h[0]})}}for(let c=0;c<this.regexps.length;c++){const u=this.regexps[c];if(u)try{u.lastIndex=t;const d=u.exec(r);if(!d)continue;if(d.index===t)return l(c,d,0);a.push([c,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(a.length){const c=Math.min(...a.map(u=>u[1].index));for(const[u,d,h]of a)if(d.index===c)return l(u,d,h)}return null}};function Cl(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Mz(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const Ab=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Un=String.raw;function kl(e,t){if(e==null)throw new Error(t??"Value expected");return e}const oN=Un`\[\^?`,lN=`c.? | C(?:-.?)?|${Un`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Un`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Un`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Un`o\{[^\}]*\}?`}|${Un`\d{1,3}`}`,Lb=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Xd=new RegExp(Un`
107
+ \\ (?:
108
+ ${lN}
109
+ | [gk]<[^>]*>?
110
+ | [gk]'[^']*'?
111
+ | .
112
+ )
113
+ | \( (?:
114
+ \? (?:
115
+ [:=!>({]
116
+ | <[=!]
117
+ | <[^>]*>
118
+ | '[^']*'
119
+ | ~\|?
120
+ | #(?:[^)\\]|\\.?)*
121
+ | [^:)]*[:)]
122
+ )?
123
+ | \*[^\)]*\)?
124
+ )?
125
+ | (?:${Lb.source})+
126
+ | ${oN}
127
+ | .
128
+ `.replace(/\s+/g,""),"gsu"),Qg=new RegExp(Un`
129
+ \\ (?:
130
+ ${lN}
131
+ | .
132
+ )
133
+ | \[:(?:\^?\p{Alpha}+|\^):\]
134
+ | ${oN}
135
+ | &&
136
+ | .
137
+ `.replace(/\s+/g,""),"gsu");function Pz(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=nH(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 c=[],u;for(Xd.lastIndex=0;u=Xd.exec(e);){const m=Bz(l,e,u[0],Xd.lastIndex);m.tokens?c.push(...m.tokens):m.token&&c.push(m.token),m.lastIndex!==void 0&&(Xd.lastIndex=m.lastIndex)}const d=[];let h=0;c.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++h:m.raw==="("&&d.push(m)}),h||d.forEach((m,g)=>{m.kind="capturing",m.number=g+1});const p=h||d.length;return{tokens:c.map(m=>m.type==="EscapedNumber"?sH(m,p):m).flat(),flags:r}}function Bz(e,t,n,r){const[a,l]=n;if(n==="["||n==="[^"){const c=$z(t,n,r);return{tokens:c.tokens,lastIndex:c.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:mC(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Yz(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:uN(n)}}if(l==="K")return{token:dN("keep",n)};if(l==="N"||l==="R")return{token:Pa("newline",n,{negate:l==="N"})};if(l==="O")return{token:Pa("any",n)};if(l==="X")return{token:Pa("text_segment",n)};const c=cN(n,{inCharClass:!1});return Array.isArray(c)?{tokens:c}:{token:c}}if(a==="("){if(l==="*")return{token:Zz(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:Qz(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Yo("group",n)};if(n==="(?>")return{token:Yo("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Yo(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Yo("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Yo("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:Wz(n)}}if(e.getCurrentModX()){if(n==="#"){const c=t.indexOf(`
138
+ `,r);return{lastIndex:c===-1?t.length:c}}if(/^\s$/.test(n)){const c=/\s+/y;return c.lastIndex=r,{lastIndex:c.exec(t)?c.lastIndex:r}}}if(n===".")return{token:Pa("dot",n)};if(n==="^"||n==="$"){const c=e.singleline?{"^":Un`\A`,$:Un`\Z`}[n]:n;return{token:mC(c,n)}}return n==="|"?{token:Hz(n)}:Lb.test(n)?{tokens:iH(n)}:{token:ci(Cl(n),n)}}function $z(e,t,n){const r=[pC(t[1]==="^",t)];let a=1,l;for(Qg.lastIndex=n;l=Qg.exec(e);){const c=l[0];if(c[0]==="["&&c[1]!==":")a++,r.push(pC(c[1]==="^",c));else if(c==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(ci(93,c));else if(a--,r.push(Fz(c)),!a)break}else{const u=zz(c);Array.isArray(u)?r.push(...u):r.push(u)}}return{tokens:r,lastIndex:Qg.lastIndex||e.length}}function zz(e){if(e[0]==="\\")return cN(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Ab.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Pa("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Uz(e):e==="&&"?Vz(e):ci(Cl(e),e)}function cN(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return Jz(e);if("dDhHsSwW".includes(n))return eH(e);if(e.startsWith(Un`\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 tH(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(c=>parseInt(c,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),l=new TextEncoder;return[...a].map(c=>{const u=[...l.encode(c)].map(d=>`\\x${d.toString(16)}`).join("");return ci(Cl(c),u)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return ci(rH(e),e);if(gC.has(n))return ci(gC.get(n),e);if(/\d/.test(n))return Gz(t,e);if(e==="\\")throw new Error(Un`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return ci(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Hz(e){return{type:"Alternator",raw:e}}function mC(e,t){return{type:"Assertion",kind:e,raw:t}}function uN(e){return{type:"Backreference",raw:e}}function ci(e,t){return{type:"Character",value:e,raw:t}}function Fz(e){return{type:"CharacterClassClose",raw:e}}function Uz(e){return{type:"CharacterClassHyphen",raw:e}}function Vz(e){return{type:"CharacterClassIntersector",raw:e}}function pC(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Pa(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function dN(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:kl(n.flags),raw:t}}function Gz(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Wz(e){return{type:"GroupClose",raw:e}}function Yo(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function qz(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Kz(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Yz(e){return{type:"Subroutine",raw:e}}const Xz=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),gC=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Jz(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 ci(Cl(t.toUpperCase())-64,e)}function Qz(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=yC(n),c=yC(r),u={};if(l&&(u.enable=l),c&&(u.disable=c),e.endsWith(")"))return t.replaceCurrentModX(a),dN("flags",e,{flags:u});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Yo("group",e,{...(l||c)&&{flags:u}});throw new Error(`Unexpected flag modifier "${e}"`)}function Zz(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):[],[c,u,d]=l,h=Xz.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 c=="string")throw new Error(`Named callout argument must be a number "${c}"`);break;case"max":if(!l.length||l.length>2)throw new Error(`Named callout must have one or two arguments "${l}"`);if(typeof c=="string"&&!/^[A-Za-z_]\w*$/.test(c))throw new Error(`Named callout argument one must be a tag or number "${c}"`);if(l.length===2&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${u}"`);break;case"count":case"total_count":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(l.length===1&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${c}"`);break;case"cmp":if(l.length!==3)throw new Error(`Named callout must have three arguments "${l}"`);if(typeof c=="string"&&!/^[A-Za-z_]\w*$/.test(c))throw new Error(`Named callout argument one must be a tag or number "${c}"`);if(typeof u=="number"||!/^(?:[<>!=]=|[<>])$/.test(u))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${u}"`);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 qz(h,r??null,(a==null?void 0:a.split(","))??null,e)}function xC(e){let t=null,n,r;if(e[0]==="{"){const{minStr:a,maxStr:l}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,c=1e5;if(+a>c||l&&+l>c)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 Kz(t,n,r,e)}function eH(e){const t=e[1].toLowerCase();return Pa({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function tH(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Pa("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function yC(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 nH(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 rH(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function sH(e,t){const{raw:n,inCharClass:r}=e,a=n.slice(1);if(!r&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[uN(n)];const l=[],c=a.match(/^[0-7]+|\d/g);for(let u=0;u<c.length;u++){const d=c[u];let h;if(u===0&&d!=="8"&&d!=="9"){if(h=parseInt(d,8),h>127)throw new Error(Un`Octal encoded byte above 177 unsupported "${n}"`)}else h=Cl(d);l.push(ci(h,(u===0?"\\":"")+d))}return l}function iH(e){const t=[],n=new RegExp(Lb,"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:c,max:u}=l.groups;if(+c>+u&&a.endsWith("?")){n.lastIndex--,t.push(xC(a.slice(0,-1)));continue}}}t.push(xC(a))}return t}function hN(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 aH(e){return oH.has(e.type)}const oH=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function fN(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Pz(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(g,x)=>{const w=r.tokens[l.nextIndex];switch(l.parent=g,l.nextIndex++,w.type){case"Alternator":return Xa();case"Assertion":return lH(w);case"Backreference":return cH(w,l);case"Character":return Uf(w.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return uH(w,l,x);case"CharacterClassOpen":return dH(w,l,x);case"CharacterSet":return hH(w,l);case"Directive":return yH(w.kind,{flags:w.flags});case"GroupOpen":return fH(w,l,x);case"NamedCallout":return vH(w.kind,w.tag,w.arguments);case"Quantifier":return mH(w,l);case"Subroutine":return pH(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},c=SH(bH(r.flags));let u=c.body[0];for(;l.nextIndex<r.tokens.length;){const g=a(u,{});g.type==="Alternative"?(c.body.push(g),u=g):u.body.push(g)}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:g}of m)if(typeof g=="number"){if(g>d.length)throw new Error("Subroutine uses a group number that's not defined");g&&(d[g-1].isSubroutined=!0)}else if(p.has(g)){if(p.get(g).length>1)throw new Error(Un`Subroutine uses a duplicate group name "\g<${g}>"`);p.get(g)[0].isSubroutined=!0}else throw new Error(Un`Subroutine uses a group name that's not defined "\g<${g}>"`);return c}function lH({kind:e}){return cy(kl({"^":"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===Un`\B`||e===Un`\Y`})}function cH({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),a=(l,c=!1)=>{const u=t.capturingGroups.length;let d=!1;if(l>u)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,uy(c?u+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 uy(r)}return a(+r)}function uH(e,t,n){const{tokens:r,walk:a}=t,l=t.parent,c=l.body.at(-1),u=r[t.nextIndex];if(!n.isCheckingRangeEnd&&c&&c.type!=="CharacterClass"&&c.type!=="CharacterClassRange"&&u&&u.type!=="CharacterClassOpen"&&u.type!=="CharacterClassClose"&&u.type!=="CharacterClassIntersector"){const d=a(l,{...n,isCheckingRangeEnd:!0});if(c.type==="Character"&&d.type==="Character")return l.body.pop(),xH(c,d);throw new Error("Invalid character class range")}return Uf(Cl("-"))}function dH({negate:e},t,n){const{tokens:r,walk:a}=t,l=[Sh()],c=r[t.nextIndex];let u=_C(c);for(;u.type!=="CharacterClassClose";){if(u.type==="CharacterClassIntersector")l.push(Sh()),t.nextIndex++;else{const h=l.at(-1);h.body.push(a(h,n))}u=_C(r[t.nextIndex],c)}const d=Sh({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 hH({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:c}=r;if(e==="property"){const u=Vf(n);if(Ab.has(u)&&!(c!=null&&c.has(u)))e="posix",n=u;else return Xo(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:c})}return e==="posix"?_H(n,{negate:t}):dy(e,{negate:t})}function fH(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:c,walk:u}=t,d=wH(e),h=d.type==="AbsenceFunction",p=vC(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&Mz(l,d.name,[]).push(d)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let g=SC(r[t.nextIndex]);for(;g.type!=="GroupClose";){if(g.type==="Alternator")d.body.push(Xa()),t.nextIndex++;else{const x=d.body.at(-1),w=u(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||m});if(x.body.push(w),(p||n.isInLookbehind)&&!c){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(m||n.isInNegLookbehind){if(bC(w)||w.type==="CapturingGroup")throw new Error(C)}else if(bC(w)||vC(w)&&w.negate)throw new Error(C)}}g=SC(r[t.nextIndex])}return t.nextIndex++,d}function mH({kind:e,min:t,max:n},r){const a=r.parent,l=a.body.at(-1);if(!l||!aH(l))throw new Error("Quantifier requires a repeatable token");const c=pN(e,t,n,l);return a.body.pop(),c}function pH({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 u=+l.groups.num,d=n.length;if(t.hasNumberedRef=!0,a={"":u,"+":d+u,"-":d+1-u}[l.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const c=gN(a);return r.push(c),c}function gH(e,t){return{type:"AbsenceFunction",kind:e,body:vu(t==null?void 0:t.body)}}function Xa(e){return{type:"Alternative",body:xN(e==null?void 0:e.body)}}function cy(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function uy(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function mN(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!CH(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:vu(t==null?void 0:t.body)}}function Uf(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 Sh(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:xN(e==null?void 0:e.body)}}function xH(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function dy(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 yH(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:kl(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function bH(e){return{type:"Flags",...e}}function ls(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:vu(e==null?void 0:e.body)}}function Oa(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:vu(e==null?void 0:e.body)}}function vH(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function _H(e,t){const n=!!(t!=null&&t.negate);if(!Ab.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function pN(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 SH(e,t){return{type:"Regex",body:vu(t==null?void 0:t.body),flags:e}}function gN(e){return{type:"Subroutine",ref:e}}function Xo(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(Vf(e));if(!r){if(n.normalizeUnknownPropertyNames)r=kH(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Un`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function wH({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return gH("repeater");case"atomic":return ls({atomic:!0});case"capturing":return mN(a,{name:n});case"group":return ls({flags:e});case"lookahead":case"lookbehind":return Oa({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function vu(e){if(e===void 0)e=[Xa()];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 xN(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 bC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function vC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function CH(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function kH(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 Vf(e){return e.replace(/[- _]+/g,"").toLowerCase()}function _C(e,t){const n=t;return kl(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function SC(e){return kl(e,"Unclosed group")}function Wc(e,t,n=null){function r(l,c){for(let u=0;u<l.length;u++){const d=a(l[u],c,u,l);u=Math.max(-1,u+d)}}function a(l,c=null,u=null,d=null){var S,v;let h=0,p=!1;const m={node:l,parent:c,key:u,container:d,root:e,remove(){Jd(d).splice(Math.max(0,Ho(u)+h),1),h--,p=!0},removeAllNextSiblings(){return Jd(d).splice(Ho(u)+1)},removeAllPrevSiblings(){const b=Ho(u)+h;return h-=b,Jd(d).splice(0,Math.max(0,b))},replaceWith(b,k={}){const N=!!k.traverse;d?d[Math.max(0,Ho(u)+h)]=b:kl(c,"Can't replace root node")[u]=b,N&&a(b,c,u,d),p=!0},replaceWithMultiple(b,k={}){const N=!!k.traverse;if(Jd(d).splice(Math.max(0,Ho(u)+h),1,...b),h+=b.length-1,N){let E=0;for(let D=0;D<b.length;D++)E+=a(b[D],c,Ho(u)+D+E,d)}p=!0},skip(){p=!0}},{type:g}=l,x=t["*"],w=t[g],C=typeof x=="function"?x:x==null?void 0:x.enter,_=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(m,n),_==null||_(m,n),!p)switch(g){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 "${g}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,m,n),(v=x==null?void 0:x.exit)==null||v.call(x,m,n),h}return a(e),e}function Jd(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Ho(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const jH=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function EH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function NH(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const Jr=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Db(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let c=0,u="";for(const d of e.matchAll(a)){const{0:h,groups:{$skip:p}}=d;if(!p&&(!r||r===Jr.DEFAULT==!c)){n instanceof Function?u+=n(d,{context:c?Jr.CHAR_CLASS:Jr.DEFAULT,negated:l[l.length-1]}):u+=n;continue}h[0]==="["?(c++,l.push(h[1]==="^")):h==="]"&&c&&(c--,l.pop()),u+=h}return u}function yN(e,t,n,r){Db(e,t,n,r)}function TH(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,c;for(;c=a.exec(e);){const{0:u,groups:{$skip:d}}=c;if(!d&&(!r||r===Jr.DEFAULT==!l))return c;u==="["?l++:u==="]"&&l&&l--,a.lastIndex==c.index&&a.lastIndex++}return null}function Qd(e,t,n){return!!TH(e,t,0,n)}function AH(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,a=0,l=1,c;for(;c=n.exec(e);){const[u]=c;if(u==="[")a++;else if(a)u==="]"&&a--;else if(u==="(")l++;else if(u===")"&&(l--,!l)){r=c.index;break}}return e.slice(t,r)}const wC=new RegExp(String.raw`(?<noncapturingStart>${jH})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function LH(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="(?:(?=(",c=[0],u=[];let d=0,h=0,p=NaN,m;do{m=!1;let g=0,x=0,w=!1,C;for(wC.lastIndex=Number.isNaN(p)?0:p+l.length;C=wC.exec(e);){const{0:_,index:S,groups:{capturingStart:v,noncapturingStart:b}}=C;if(_==="[")g++;else if(g)_==="]"&&g--;else if(_===a&&!w)p=S,w=!0;else if(w&&b)x++;else if(v)w?x++:(d++,c.push(d+h));else if(_===")"&&w){if(!x){h++;const k=d+h;if(e=`${e.slice(0,p)}${l}${e.slice(p+a.length,S)}))<$$${k}>)${e.slice(S+1)}`,m=!0,u.push(k),EH(n,k),r.size){const N=new Map;r.forEach((E,D)=>{N.set(D>=k?D+1:D,E.map(A=>A>=k?A+1:A))}),r=N}break}x--}}}while(m);return n.push(...u),e=Db(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:g,groups:{backrefNum:x,wrappedBackrefNum:w}})=>{if(x){const C=+x;if(C>c.length-1)throw new Error(`Backref "${g}" greater than number of captures`);return`\\${c[C]}`}return`\\${w}`},Jr.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const bN=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Zg=new RegExp(String.raw`
139
+ \\(?: \d+
140
+ | c[A-Za-z]
141
+ | [gk]<[^>]+>
142
+ | [pPu]\{[^\}]+\}
143
+ | u[A-Fa-f\d]{4}
144
+ | x[A-Fa-f\d]{2}
145
+ )
146
+ | \((?: \? (?: [:=!>]
147
+ | <(?:[=!]|[^>]+>)
148
+ | [A-Za-z\-]+:
149
+ | \(DEFINE\)
150
+ ))?
151
+ | (?<qBase>${bN})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
152
+ | \\?.
153
+ `.replace(/\s+/g,""),"gsu");function DH(e){if(!new RegExp(`${bN}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",l=0,c;for(Zg.lastIndex=0;c=Zg.exec(e);){const{0:u,index:d,groups:{qBase:h,qMod:p,invalidQ:m}}=c;if(u==="[")l||(r=d),l++;else if(u==="]")l?l--:r=null;else if(!l)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${u}"`);let g=-1;if(/^\{\d+\}$/.test(h))e=NH(e,d+h.length,p,"");else{if(a===")"||a==="]"){const x=a===")"?n:r;if(x===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,x)}(?>${e.slice(x,d)}${h})${e.slice(d+u.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${h})${e.slice(d+u.length)}`;g+=4}Zg.lastIndex+=g}else u[0]==="("?t.push(d):u===")"&&(n=t.length?t.pop():null);a=u}return{pattern:e}}const Yr=String.raw,RH=Yr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,hy=Yr`\(\?R=(?<rDepth>[^\)]+)\)|${RH}`,Gf=Yr`\(\?<(?![=!])(?<captureName>[^>]+)>`,vN=Yr`${Gf}|(?<unnamed>\()(?!\?)`,ja=new RegExp(Yr`${Gf}|${hy}|\(\?|\\?.`,"gsu"),ex="Cannot use multiple overlapping recursions";function OH(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(hy,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&Qd(e,Yr`\(\?\(DEFINE\)`,Jr.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],c=Qd(e,Yr`\\[1-9]`,Jr.DEFAULT),u=new Map,d=[];let h=!1,p=0,m=0,g;for(ja.lastIndex=0;g=ja.exec(e);){const{0:x,groups:{captureName:w,rDepth:C,gRNameOrNum:_,gRDepth:S}}=g;if(x==="[")p++;else if(p)x==="]"&&p--;else if(C){if(CC(C),h)throw new Error(ex);if(c)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const v=e.slice(0,g.index),b=e.slice(ja.lastIndex);if(Qd(b,hy,Jr.DEFAULT))throw new Error(ex);const k=+C-1;e=kC(v,b,k,!1,n,l,m),a=EC(a,v,k,l.length,0,m);break}else if(_){CC(S);let v=!1;for(const z of d)if(z.name===_||z.num===+_){if(v=!0,z.hasRecursedWithin)throw new Error(ex);break}if(!v)throw new Error(Yr`Recursive \g cannot be used outside the referenced group "${r==="external"?_:Yr`\g<${_}&R=${S}>`}"`);const b=u.get(_),k=AH(e,b);if(c&&Qd(k,Yr`${Gf}|\((?!\?)`,Jr.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const N=e.slice(b,g.index),E=k.slice(N.length+x.length),D=l.length,A=+S-1,O=kC(N,E,A,!0,n,l,m);a=EC(a,N,A,l.length-D,D,m);const P=e.slice(0,b),G=e.slice(b+k.length);e=`${P}${O}${G}`,ja.lastIndex+=O.length-x.length-N.length-E.length,d.forEach(z=>z.hasRecursedWithin=!0),h=!0}else if(w)m++,u.set(String(m),ja.lastIndex),u.set(w,ja.lastIndex),d.push({num:m,name:w});else if(x[0]==="("){const v=x==="(";v&&(m++,u.set(String(m),ja.lastIndex)),d.push(v?{num:m}:{})}else x===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function CC(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 kC(e,t,n,r,a,l,c){const u=new Set;r&&yN(e+t,Gf,({groups:{captureName:h}})=>{u.add(h)},Jr.DEFAULT);const d=[n,r?u:null,a,l,c];return`${e}${jC(`(?:${e}`,"forward",...d)}(?:)${jC(`${t})`,"backward",...d)}${t}`}function jC(e,t,n,r,a,l,c){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+=Db(e,Yr`${vN}|\\k<(?<backref>[^>]+)>`,({0:g,groups:{captureName:x,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return g;const _=`_$${m}`;if(w||x){const S=c+l.length+1;return l.push(S),IH(a,S),w?g:`(?<${x}${_}>`}return Yr`\k<${C}${_}>`},Jr.DEFAULT)}return h}function IH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function EC(e,t,n,r,a,l){if(e.size&&r){let c=0;yN(t,vN,()=>c++,Jr.DEFAULT);const u=l-c+a,d=new Map;return e.forEach((h,p)=>{const m=(r-c*n)/n,g=c*n,x=p>u+c?p+r:p,w=[];for(const C of h)if(C<=u)w.push(C);else if(C>u+c+m)w.push(C+r);else if(C<=u+c)for(let _=0;_<=n;_++)w.push(C+c*_);else for(let _=0;_<=n;_++)w.push(C+g+m*_);d.set(x,w)}),d}return e}var Mn=String.fromCodePoint,yt=String.raw,fs={},Wf=globalThis.RegExp;fs.flagGroups=(()=>{try{new Wf("(?i:)")}catch{return!1}return!0})();fs.unicodeSets=(()=>{try{new Wf("[[]]","v")}catch{return!1}return!0})();fs.bugFlagVLiteralHyphenIsRange=fs.unicodeSets?(()=>{try{new Wf(yt`[\d\-a]`,"v")}catch{return!0}return!1})():!1;fs.bugNestedClassIgnoresNegation=fs.unicodeSets&&new Wf("[[^a]]","v").test("a");function qh(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 lu(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function fy(e,t){return NC[e]>=NC[t]}function MH(e,t){if(e==null)throw new Error(t??"Value expected");return e}var NC={ES2025:2025,ES2024:2024,ES2018:2018},PH={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function _N(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!PH[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=fs.flagGroups?"ES2025":fs.unicodeSets?"ES2024":"ES2018"),t}var BH="[ -\r ]",$H=new Set([Mn(304),Mn(305)]),Zs=yt`[\p{L}\p{M}\p{N}\p{Pc}]`;function SN(e){if($H.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=FH.get(n),l=zH.get(n),c=HH.get(n);return[...r].length===1&&t.add(r),c&&t.add(c),a&&t.add(a),t.add(n),l&&t.add(l),[...t]}var Rb=new Map(`C Other
154
+ Cc Control cntrl
155
+ Cf Format
156
+ Cn Unassigned
157
+ Co Private_Use
158
+ Cs Surrogate
159
+ L Letter
160
+ LC Cased_Letter
161
+ Ll Lowercase_Letter
162
+ Lm Modifier_Letter
163
+ Lo Other_Letter
164
+ Lt Titlecase_Letter
165
+ Lu Uppercase_Letter
166
+ M Mark Combining_Mark
167
+ Mc Spacing_Mark
168
+ Me Enclosing_Mark
169
+ Mn Nonspacing_Mark
170
+ N Number
171
+ Nd Decimal_Number digit
172
+ Nl Letter_Number
173
+ No Other_Number
174
+ P Punctuation punct
175
+ Pc Connector_Punctuation
176
+ Pd Dash_Punctuation
177
+ Pe Close_Punctuation
178
+ Pf Final_Punctuation
179
+ Pi Initial_Punctuation
180
+ Po Other_Punctuation
181
+ Ps Open_Punctuation
182
+ S Symbol
183
+ Sc Currency_Symbol
184
+ Sk Modifier_Symbol
185
+ Sm Math_Symbol
186
+ So Other_Symbol
187
+ Z Separator
188
+ Zl Line_Separator
189
+ Zp Paragraph_Separator
190
+ Zs Space_Separator
191
+ ASCII
192
+ ASCII_Hex_Digit AHex
193
+ Alphabetic Alpha
194
+ Any
195
+ Assigned
196
+ Bidi_Control Bidi_C
197
+ Bidi_Mirrored Bidi_M
198
+ Case_Ignorable CI
199
+ Cased
200
+ Changes_When_Casefolded CWCF
201
+ Changes_When_Casemapped CWCM
202
+ Changes_When_Lowercased CWL
203
+ Changes_When_NFKC_Casefolded CWKCF
204
+ Changes_When_Titlecased CWT
205
+ Changes_When_Uppercased CWU
206
+ Dash
207
+ Default_Ignorable_Code_Point DI
208
+ Deprecated Dep
209
+ Diacritic Dia
210
+ Emoji
211
+ Emoji_Component EComp
212
+ Emoji_Modifier EMod
213
+ Emoji_Modifier_Base EBase
214
+ Emoji_Presentation EPres
215
+ Extended_Pictographic ExtPict
216
+ Extender Ext
217
+ Grapheme_Base Gr_Base
218
+ Grapheme_Extend Gr_Ext
219
+ Hex_Digit Hex
220
+ IDS_Binary_Operator IDSB
221
+ IDS_Trinary_Operator IDST
222
+ ID_Continue IDC
223
+ ID_Start IDS
224
+ Ideographic Ideo
225
+ Join_Control Join_C
226
+ Logical_Order_Exception LOE
227
+ Lowercase Lower
228
+ Math
229
+ Noncharacter_Code_Point NChar
230
+ Pattern_Syntax Pat_Syn
231
+ Pattern_White_Space Pat_WS
232
+ Quotation_Mark QMark
233
+ Radical
234
+ Regional_Indicator RI
235
+ Sentence_Terminal STerm
236
+ Soft_Dotted SD
237
+ Terminal_Punctuation Term
238
+ Unified_Ideograph UIdeo
239
+ Uppercase Upper
240
+ Variation_Selector VS
241
+ White_Space space
242
+ XID_Continue XIDC
243
+ XID_Start XIDS`.split(/\s/).map(e=>[Vf(e),e])),zH=new Map([["s",Mn(383)],[Mn(383),"s"]]),HH=new Map([[Mn(223),Mn(7838)],[Mn(107),Mn(8490)],[Mn(229),Mn(8491)],[Mn(969),Mn(8486)]]),FH=new Map([Hi(453),Hi(456),Hi(459),Hi(498),...tx(8072,8079),...tx(8088,8095),...tx(8104,8111),Hi(8124),Hi(8140),Hi(8188)]),UH=new Map([["alnum",yt`[\p{Alpha}\p{Nd}]`],["alpha",yt`\p{Alpha}`],["ascii",yt`\p{ASCII}`],["blank",yt`[\p{Zs}\t]`],["cntrl",yt`\p{Cc}`],["digit",yt`\p{Nd}`],["graph",yt`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",yt`\p{Lower}`],["print",yt`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",yt`[\p{P}\p{S}]`],["space",yt`\p{space}`],["upper",yt`\p{Upper}`],["word",yt`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",yt`\p{AHex}`]]);function VH(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Hi(e){const t=Mn(e);return[t.toLowerCase(),t]}function tx(e,t){return VH(e,t).map(n=>Hi(n))}var wN=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function GH(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};CN(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:fy(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};Wc(e,WH,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};Wc(e,qH,l);const c={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return Wc(e,KH,c),e._originMap=l.groupOriginByCopy,e._strategy=r.strategy,e}var WH={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const l=ls();l.body[0].body.push(Oa({negate:!0,body:r}),Xo("Any"));const c=ls();c.body[0].body.push(pN("greedy",0,1/0,l)),n(vn(c,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 c=t.body[l];lu(r,c,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=jN(t.get(e));if(r){const a=ls({flags:r});a.body[0].body=e.body,e.body=[vn(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:l,replaceWith:c},u){const{kind:d,negate:h}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:g,wordIsAscii:x}=u;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(d==="line_end")c(vn(Oa({body:[Xa({body:[cy("string_end")]}),Xa({body:[Uf(10)]})]}),t));else if(d==="line_start")c(vn(ei(yt`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(g.has(e))a.flags.sticky=!0,l();else{const w=r[n-1];if(w&&eF(w))c(vn(Oa({negate:!0}),t));else{if(m)throw new Error(yt`Uses "\G" in a way that requires a subclass`);c(Fi(cy("string_start"),t)),u.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")c(vn(ei(yt`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!x&&!p){const w=`(?:(?<=${Zs})(?!${Zs})|(?<!${Zs})(?=${Zs}))`,C=`(?:(?<=${Zs})(?=${Zs})|(?<!${Zs})(?!${Zs}))`;c(vn(ei(h?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!rx(n)&&(n=nx(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!rx(r)&&(r=nx(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=Sh({body:[e]});n(vn(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:c,wordIsAscii:u}){const{kind:d,negate:h,value:p}=e;if(l&&(d==="digit"||p==="digit")){n(Fi(dy("digit",{negate:h}),t));return}if(c&&(d==="space"||p==="space")){n(vn(sx(ei(BH),h),t));return}if(u&&(d==="word"||p==="word")){n(Fi(dy("word",{negate:h}),t));return}if(d==="any")n(Fi(Xo("Any"),t));else if(d==="digit")n(Fi(Xo("Nd",{negate:h}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(yt`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",g=yt`\p{RI}{2}|${m}(?:\u200D${m})*`;n(vn(ei(yt`(?>\r\n|${a?yt`\p{RGI_Emoji}`:g}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Fi(Xo("AHex",{negate:h}),t));else if(d==="newline")n(vn(ei(h?`[^
244
+ ]`:`(?>\r
245
+ ?|[
246
+ \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-${Mn(m.codePointAt(0)-1)}${Mn(m.codePointAt(2)+1)}-􏿿`),n(vn(ei(`[${m}]`),t))}else n(vn(sx(ei(UH.get(p)),h),t));else if(d==="property")Rb.has(Vf(p))||(e.key="sc");else if(d==="space")n(Fi(Xo("space",{negate:h}),t));else if(d==="word")n(vn(sx(ei(Zs),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:c}){const{kind:u,flags:d}=e;if(u==="flags")if(!d.enable&&!d.disable)r();else{const h=ls({flags:d});h.body[0].body=c(),a(vn(h,t),{traverse:!0})}else if(u==="keep"){const h=n.body[0],m=n.body.length===1&&hN(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(yt`Uses "\K" in a way that's unsupported`);const g=Oa({behind:!0});g.body[0].body=l(),a(vn(g,t))}else throw new Error(`Unexpected directive kind "${u}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(vn(Oa({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=ls();t.body[0].body.push(e.body),e.body=vn(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 c=NN(l.body);c?(r=!0,Array.isArray(c)?n.push(...c):n.push(c)):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(yt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!rx(n)&&(n=nx(n,t),e.ref=n)}},qH={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:c,openRefs:u,reffedNodesByReferencer:d}){const h=a.get(e);if(h&&u.has(e.number)){const m=Fi(TC(e.number),t);d.set(m,u.get(e.number)),n(m);return}u.set(e.number,e),c.set(e.number,[]),e.name&&lu(c,e.name,[]);const p=c.get(e.name??e.number);for(let m=0;m<p.length;m++){const g=p[m];if(h===g.node||h&&h===g.origin||e===g.origin){p.splice(m,1);break}}if(c.get(e.number).push({node:e,origin:h}),e.name&&c.get(e.name).push({node:e,origin:h}),e.name){const m=lu(l,e.name,new Map);let g=!1;if(h)g=!0;else for(const x of m.values())if(!x.hasDuplicateNameToRemove){g=!0;break}l.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:g})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=qh(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 c=r.subroutineRefMap.get(l),u=l===0,d=u?TC(0):kN(c,r.groupOriginByCopy,null);let h=d;if(!u){const p=jN(JH(c,g=>g.type==="Group"&&!!g.flags)),m=p?qh(r.globalFlags,p):r.globalFlags;YH(m,r.currentFlags)||(h=ls({flags:QH(m)}),h.body[0].body.push(d))}n(vn(h,t),{traverse:!u})}},KH={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(c=>XH(c,e));if(!l.length)n(vn(Oa({negate:!0}),t));else if(l.length>1){const c=ls({atomic:!0,body:l.reverse().map(u=>Xa({body:[uy(u.number)]}))});n(vn(c,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=mN();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function CN(e){Wc(e,{"*"({node:t,parent:n}){t.parent=n}})}function YH(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function XH(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=EN(n.parent);for(const a of r){if(a===n)break;if(a===e||TN(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function kN(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[l,c]of Object.entries(e))l==="parent"?a.parent=Array.isArray(n)?r:n:c&&typeof c=="object"?a[l]=kN(c,t,a,n):(l==="type"&&c==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=c);return a}function TC(e){const t=gN(e);return t.isRecursive=!0,t}function JH(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function nx(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 jN(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var l,c;(l=r.enable)!=null&&l[a]&&(delete n.disable[a],n.enable[a]=!0),(c=r.disable)!=null&&c[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 QH({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 EN(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function NN(e){const t=e.find(n=>n.kind==="search_start"||tF(n,{negate:!1})||!ZH(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=NN(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function TN(e,t){const n=EN(e)??[];for(const r of n)if(r===t||TN(r,t))return!0;return!1}function ZH({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function eF(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function tF(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&hN(e.body[0],{type:"Assertion",kind:"search_start"})}function rx(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function ei(e,t){const r=fN(e,{...t,unicodePropertyMap:Rb}).body;return r.length>1||r[0].body.length>1?ls({body:r}):r[0].body[0]}function sx(e,t){return e.negate=t,e}function Fi(e,t){return e.parent=t,e}function vn(e,t){return CN(e),e.parent=t,e}function nF(e,t){const n=_N(t),r=fy(n.target,"ES2024"),a=fy(n.target,"ES2025"),l=n.rules.recursionLimit;if(!Number.isInteger(l)||l<2||l>20)throw new Error("Invalid recursionLimit; use 2-20");let c=null,u=null;if(!a){const x=[e.flags.ignoreCase];Wc(e,rF,{getCurrentModI:()=>x.at(-1),popModI(){x.pop()},pushModI(w){x.push(w)},setHasCasedChar(){x.at(-1)?c=!0:u=!0}})}const d={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||c)&&!u)};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&&c&&u),useFlagMods:a,useFlagV:r,verbose:n.verbose};function m(x){return p.lastNode=h,h=x,MH(sF[x.type],`Unexpected node type "${x.type}"`)(x,p,m)}const g={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};return r||(delete g.options.force.v,g.options.disable.v=!0,g.options.unicodeSetsPlugin=null),g._captureTransfers=new Map,g._hiddenCaptures=[],p.captureMap.forEach((x,w)=>{x.hidden&&g._hiddenCaptures.push(w),x.transferTo&&lu(g._captureTransfers,x.transferTo,[]).push(w)}),g}var rF={"*":{enter({node:e},t){if(LC(e)){const n=t.getCurrentModI();t.pushModI(e.flags?qh({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){LC(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Ob(Mn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),AN(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&wN.has(e.value)&&t.setHasCasedChar()}},sF={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?yt`\B`:yt`\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,c={ignoreCase:t.currentFlags.ignoreCase},u=t.originMap.get(e);return u&&(c.hidden=!0,l>u.number&&(c.transferTo=u.number)),t.captureMap.set(l,c),`(${a?`?<${a}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=Mn(e),r=Fo(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Ob(n)){const a=SN(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:c}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");fs.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&c.some(DC)&&(c=[Uf(45),...c.filter(h=>!DC(h))]);const u=()=>`[${a?"^":""}${c.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||fs.bugNestedClassIgnoresNegation)&&!a){const p=c.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=ls(),g=m.body[0];return m.parent=l,g.parent=m,c=c.filter(x=>!p.includes(x)),e.body=c,c.length?(e.parent=g,g.body.push(e)):m.body.pop(),p.forEach(x=>{const w=Xa({body:[x]});x.parent=w,w.parent=m,m.body.push(w)}),n(m)}}t.inCharClass=!0;const h=u();return t.inCharClass=!1,h}const d=c[0];if(r==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(fs.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&l.kind==="intersection"&&c.length===1&&d.type!=="CharacterClassRange"))return c.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 u()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=Fo(n,a),c=Fo(r,a),u=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=AN(e);cF(d).forEach(p=>{u.add(Array.isArray(p)?`${Fo(p[0],a)}-${Fo(p[1],a)}`:Fo(p,a))})}return`${l}-${c}${[...u].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":yt`[^\n]`;if(e==="digit")return t?yt`\D`:yt`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&wN.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?yt`\P`:yt`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?yt`\W`:yt`\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 c=a.currentFlags;n&&(a.currentFlags=qh(c,n));const u=t.map(l).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?u:`(?${uF(e,n,a.useFlagMods)}${u})`;return a.currentFlags=c,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)+dF(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})`:yt`\g<${t}&R=${r}>`}},iF=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),aF=new Set(["-","\\","]","^","["]),oF=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),AC=new Map([[9,yt`\t`],[10,yt`\n`],[11,yt`\v`],[12,yt`\f`],[13,yt`\r`],[8232,yt`\u2028`],[8233,yt`\u2029`],[65279,yt`\uFEFF`]]),lF=new RegExp("^\\p{Cased}$","u");function Ob(e){return lF.test(e)}function AN(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 c=r;c<=a;c++){const u=Mn(c);if(!Ob(u))continue;const d=SN(u).filter(h=>{const p=h.codePointAt(0);return p<r||p>a});if(d.length&&(l.push(...d),n))break}return l}function Fo(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(AC.has(e))return AC.get(e);if(e<32||e>126&&e<160||e>262143||t&&hF(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?oF:aF:iF,l=Mn(e);return(a.has(l)?"\\":"")+l}function cF(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 uF(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 dF({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 LC({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function hF(e){return e>47&&e<58}function DC({type:e,value:t}){return e==="Character"&&t===45}var Ui,ii,$a,Vi,za,uu,my,Ji,fF=(Ji=class extends RegExp{constructor(n,r,a){var t=(...NW)=>(super(...NW),_a(this,uu),_a(this,Ui,new Map),_a(this,ii,null),_a(this,$a),_a(this,Vi,null),_a(this,za,null),Ae(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 c=n;t(c,r),ss(this,$a,c.source),c instanceof Ji&&(ss(this,Ui,sr(c,Ui)),ss(this,Vi,sr(c,Vi)),ss(this,za,sr(c,za)),this.rawOptions=c.rawOptions)}else{const c={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,r),ss(this,$a,n),ss(this,Ui,pF(c.hiddenCaptures,c.transfers)),ss(this,za,c.strategy),this.rawOptions=a??{}}l||ss(this,ii,this)}get source(){return sr(this,$a)||"(?:)"}exec(n){if(!sr(this,ii)){const{lazyCompile:l,...c}=this.rawOptions;ss(this,ii,new Ji(sr(this,$a),this.flags,c))}const r=this.global||this.sticky,a=this.lastIndex;if(sr(this,za)==="clip_search"&&r&&a){this.lastIndex=0;const l=ig(this,uu,my).call(this,n.slice(a));return l&&(mF(l,a,n,this.hasIndices),this.lastIndex+=a),l}return ig(this,uu,my).call(this,n)}},Ui=new WeakMap,ii=new WeakMap,$a=new WeakMap,Vi=new WeakMap,za=new WeakMap,uu=new WeakSet,my=function(n){sr(this,ii).lastIndex=this.lastIndex;const r=US(Ji.prototype,this,"exec").call(sr(this,ii),n);if(this.lastIndex=sr(this,ii).lastIndex,!r||!sr(this,Ui).size)return r;const a=[...r];r.length=1;let l;this.hasIndices&&(l=[...r.indices],r.indices.length=1);const c=[0];for(let u=1;u<a.length;u++){const{hidden:d,transferTo:h}=sr(this,Ui).get(u)??{};if(d?c.push(null):(c.push(r.length),r.push(a[u]),this.hasIndices&&r.indices.push(l[u])),h&&a[u]!==void 0){const p=c[h];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=a[u],this.hasIndices&&(r.indices[p]=l[u]),r.groups){sr(this,Vi)||ss(this,Vi,gF(this.source));const m=sr(this,Vi).get(h);m&&(r.groups[m]=a[u],this.hasIndices&&(r.indices.groups[m]=l[u]))}}}return r},Ji);function mF(e,t,n,r){if(e.index+=t,e.input=n,r){const a=e.indices;for(let c=0;c<a.length;c++){const u=a[c];u&&(a[c]=[u[0]+t,u[1]+t])}const l=a.groups;l&&Object.keys(l).forEach(c=>{const u=l[c];u&&(l[c]=[u[0]+t,u[1]+t])})}}function pF(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)lu(n,l,{}).transferTo=r;return n}function gF(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,l;for(;l=t.exec(e);){const{0:c,groups:{capture:u,name:d}}=l;c==="["?r++:r?c==="]"&&r--:u&&(a++,d&&n.set(a,d))}return n}function xF(e,t){const n=yF(e,t);return n.options?new fF(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function yF(e,t){const n=_N(t),r=fN(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Rb}),a=GH(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=nF(a,n),c=OH(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),u=DH(c.pattern),d=LH(u.pattern,{captureTransfers:c.captureTransfers,hiddenCaptures:c.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),g=a._strategy,x=h.pattern.length>=n.lazyCompileLength;(p.length||m.length||g||x)&&(h.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...g&&{strategy:g},...x&&{lazyCompile:x}})}return h}function LN(e,t){return xF(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function bF(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>LN(n,{target:t.target})),{createScanner(n){return new Iz(n,t)},createString(n){return{content:n}}}}l2(xb({bundledLanguages:()=>Of,bundledLanguagesAlias:()=>bb,bundledLanguagesBase:()=>yb,bundledLanguagesInfo:()=>Rf,bundledThemes:()=>_b,bundledThemesInfo:()=>vb,codeToHast:()=>tN,codeToHtml:()=>eN,codeToTokens:()=>nN,codeToTokensBase:()=>rN,codeToTokensWithThemes:()=>sN,createHighlighter:()=>Ff,createJavaScriptRegexEngine:()=>bF,createOnigurumaEngine:()=>d2,defaultJavaScriptRegexConstructor:()=>LN,getLastGrammarState:()=>aN,getSingletonHighlighter:()=>iN,loadWasm:()=>wb}),Oz);let ix=null;const qc=new Set,Zd=new Map,RC=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],vF=["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"],ax={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 _F(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function DN(){return ix||(ix=Ff({themes:vF,langs:RC}).then(e=>(RC.forEach(t=>qc.add(t)),e))),ix}async function SF(e){if(qc.has(e))return;if(Zd.has(e))return Zd.get(e);const t=(async()=>{const n=await DN(),r=Of[e];if(r){await n.loadLanguage(r),qc.add(e);return}try{const a=await ne(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),qc.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();Zd.set(e,t),await t,Zd.delete(e)}const Tc=new Map,wF=50;function CF(e,t,n){return`${e}|${t}|${n}`}async function RN(e,t,n="github-dark-default"){t!=="text"&&!qc.has(t)&&await SF(t);const r=CF(e,t,n),a=Tc.get(r);if(a)return a;const c=(await DN()).codeToHtml(e,{lang:t,theme:n,transformers:[_F()]});if(Tc.size>=wF){const u=Tc.keys().next().value;u&&Tc.delete(u)}return Tc.set(r,c),c}const kF={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 qf(e){var a;if(!e)return"text";const t=mu(e),n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return r?kF[r]??"text":"text"}function ON(){const e=Kt(r=>r.currentPreset),t=Kt(r=>r.isCustom),n=Kt(r=>r.basePreset);return jF(e,t,n)}function jF(e,t,n){return t?n&&n!=="system"&&ax[n]?ax[n]??"github-dark-default":"github-dark-default":ax[e]??"github-dark-default"}function IN(e=2e3){const[t,n]=j.useState(!1),r=j.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 EF=5e3,$c=new Map,NF=100,TF=20*1024*1024;let AF=TF,ox=0;function LF(e,t){for($c.set(e,t),ox+=e.length;$c.size>NF||ox>AF;){const n=$c.keys().next().value;if(n===void 0)break;$c.delete(n),ox-=n.length}return t}const DF=j.memo(function({language:t,codeString:n,showSyntaxHighlighting:r,deferHighlight:a}){const{copied:l,copy:c}=IN(),[u,d]=j.useState(null),h=ON(),p=j.useRef(n),m=t==="text"||n.length>EF;return j.useEffect(()=>{!r||a||m||(p.current=n,RN(n,t,h).then(g=>{p.current===n&&d(g)}))},[n,t,h,r,a,m]),s.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[s.jsxs("div",{className:"absolute bottom-0 right-0 flex items-center gap-2 px-2 py-1 text-xs text-text-muted/70 bg-bg-tertiary/60 rounded-tl rounded-tr z-10",children:[s.jsx("span",{children:t}),s.jsx("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),c(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:l?s.jsx(Rs,{}):s.jsx(dl,{})})]}),r&&u?s.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):s.jsx(_n,{horizontal:!0,scope:"codeBlocks",children:s.jsx("pre",{className:"my-0 px-4 py-3 font-mono text-sm whitespace-pre-wrap break-word",children:s.jsx("code",{className:`language-${t}`,children:n})})})]})});function RF(e,t,n){const r=e?"text-text-muted":"text-text-heading",a=e?"text-text-secondary":"text-text-bold";return{code({className:l,children:c,...u}){const d=/language-(\w+)/.exec(l||"");if(!d&&!String(c).includes(`
247
+ `)){const g=e?"text-text-muted":"text-text-code";return s.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${g} font-mono text-xs`,...u,children:c})}const p=(d==null?void 0:d[1])||"text",m=String(c).replace(/\n$/,"");return s.jsx(DF,{language:p,codeString:m,showSyntaxHighlighting:t,deferHighlight:n})},p({children:l}){const c=e?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${c} mb-1.5 last:mb-0 leading-tight break-words`,children:l})},ul({children:l}){return s.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:l})},ol({children:l}){return s.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:l})},li({children:l}){const c=e?"text-text-muted":"text-text-primary";return s.jsx("li",{className:`${c} text-sm list-item`,children:l})},h1({children:l}){return s.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:l})},h2({children:l}){return s.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:l})},h3({children:l}){return s.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:l})},h4({children:l}){return s.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:l})},strong({children:l}){return s.jsx("strong",{className:`font-bold ${a}`,children:l})},em({children:l}){return s.jsx("em",{className:e?"italic text-text-secondary":"italic",children:l})},a({href:l,children:c}){return s.jsx("a",{href:l,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:c})},blockquote({children:l}){const c=e?"text-text-muted":"text-text-secondary";return s.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${c} italic text-sm`,children:l})},table({children:l}){return s.jsx(_n,{horizontal:!0,className:"my-1.5",scope:"codeBlocks",children:s.jsx("table",{className:"min-w-full border border-border",children:l})})},th({children:l}){return s.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:l})},td({children:l}){return s.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:l})},hr(){return s.jsx("hr",{className:"border-border my-2"})},input({checked:l,...c}){return s.jsx("input",{type:"checkbox",checked:l,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...c})}}}const ar=j.memo(function({content:t,className:n="",muted:r=!1,isStreaming:a=!1}){const{showSyntaxHighlighting:l,deferCodeHighlightWhileStreaming:c}=Ds(),u=j.useMemo(()=>a&&c&&PN(t)%2===1,[a,c,t]),d=j.useMemo(()=>RF(r,l,u),[r,l,u]),h=j.useMemo(()=>{const p=OF(t);if(!MF(p)){if(!p.trim())return null;const m=r?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${m} mb-1.5 last:mb-0 leading-tight break-words whitespace-pre-line`,children:IF(p)})}return a?MN(p,d):PF(p,d,r,l)},[t,a,d,r,l]);return s.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:h})});function OF(e){let t=BF(e);return t=$F(t),t.trimEnd()}function IF(e){const t=e.split(/(https?:\/\/[^\s<>"']+)/g);return t.length===1?e:t.map((n,r)=>/^https?:\/\//.test(n)?s.jsx("a",{href:n,className:"text-text-link hover:underline",target:"_blank",rel:"noopener noreferrer",children:n},r):n)}function MF(e){return e.includes("`")||e.includes("~")||e.includes("<")||/^#{1,6}\s/m.test(e)||/^\s*[-*+]\s/m.test(e)||/^\s*\d+[.)]\s/m.test(e)||/^\s*>\s?/m.test(e)||/^\s*\|.*\|/m.test(e)||/^\s*([-*_])\1{2,}\s*$/m.test(e)||/\[[^\]]*\]\([^)]*\)/.test(e)||/!\[[^\]]*\]/.test(e)||/[*_]/.test(e)||e.includes("&")}function MN(e,t){return s.jsx(Q4,{remarkPlugins:[dB],components:t,children:e})}function PF(e,t,n,r){const a=`${n?"m":"n"}|${r?"h":"p"}|${e}`,l=$c.get(a);if(l!==void 0)return l;const c=MN(e,t);return LF(a,c)}function BF(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 PN(e){var t;return((t=e.match(/```/g))==null?void 0:t.length)??0}function $F(e){if(PN(e)%2===1){const n=e.lastIndexOf("```");return e.slice(n+3).includes(`
248
+ `),e+"\n```"}return e}function BN({isOpen:e,onClose:t}){const[n,r]=j.useState(null),[a,l]=j.useState(!1),{settings:c,getSetting:u,setSetting:d}=na(),h=c[Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";j.useEffect(()=>{e&&u(Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,u]),j.useEffect(()=>{e&&(l(!0),xe("/api/changelog").then(m=>m.json()).then(m=>{r(m.content)}).catch(()=>{r(`# Changelog
249
+
250
+ Failed to load changelog.`)}).finally(()=>l(!1)))},[e]);const p=j.useCallback(()=>{const m=h?"false":"true";d(Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,m)},[h,d]);return s.jsx(St,{isOpen:e,onClose:t,title:"What's New in OpenFox",size:"xl",closeOnBackdropClick:!0,showCloseButton:!0,footer:s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx(ds,{enabled:h,onClick:p}),s.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:s.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:a?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):s.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:s.jsx(ar,{content:n??""})})})})}const zF="#6b7280";function Ja(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??zF}const ut=Kn(e=>{const t=async()=>{e({loading:!0});try{const r=await(await xe("/api/agents")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],modelOverrides:r.modelOverrides??{},loading:!1})}catch{e({loading:!1})}};return{defaults:[],userItems:[],projectItems:[],modelOverrides:{},loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await xe(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await xe(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const a=await Qi("POST","/api/agents",{...n,destination:r});return a.success&&await t(),a},updateAgent:async(n,r)=>{const a=await Qi("PUT",`/api/agents/${n}`,r);return a.success&&await t(),a},deleteAgent:async n=>{try{const r=await xe(`/api/agents/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(c=>c.id!==n),projectItems:l.projectItems.filter(c=>c.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r)=>yf(`/api/agents/${n}/duplicate`,t,r)}});function HF({onClose:e}){const[,t]=Ln(),{settings:n,getSetting:r,setSetting:a}=na(),l=n[Ee.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",c=n[Ee.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",u=n[Ee.CACHE_WARMING]==="true",[d,h]=j.useState({openInEditor:l,dynamicPrompt:c,cacheWarming:u}),[p,m]=j.useState({patterns:[],maxRetriesPerTurn:10}),[g,x]=j.useState(""),[w,C]=j.useState(""),[_,S]=j.useState(!1),[v,b,k,N]=Bx(),[E,D]=j.useState(!1),[A,O]=j.useState(!1),P=en(M=>M.version),G=ui(M=>M.status),z=ui(M=>M.latest),V=ui(M=>M.check),$=P&&z?{current:P,latest:z}:null,[H,q]=j.useState(!1),X=ut(M=>M.defaults),Y=ut(M=>M.userItems),F=ut(M=>M.fetchAgents),I=[...X,...Y].filter(M=>!M.subagent);j.useEffect(()=>{h({openInEditor:l,dynamicPrompt:c,cacheWarming:u})},[l,c,u]),j.useEffect(()=>{r(Ee.DISPLAY_SHOW_OPEN_IN_EDITOR),r(Ee.LLM_DYNAMIC_SYSTEM_PROMPT),r(Ee.CACHE_WARMING),r(Ee.RETRY_PATTERNS),r(Ee.PROXY_URL)},[r]),j.useEffect(()=>{const M=n[Ee.RETRY_PATTERNS];if(M)try{m(JSON.parse(M))}catch{}},[n]),j.useEffect(()=>{const M=n[Ee.PROXY_URL];M!==void 0&&x(M)},[n]),j.useEffect(()=>{F().catch(()=>{})},[F]),j.useEffect(()=>{r(Ee.DEFAULT_AGENT)},[r]),j.useEffect(()=>{const M=n[Ee.DEFAULT_AGENT];M!==void 0&&(C(M),S(!0))},[n]);const R=j.useCallback(M=>{m(M),a(Ee.RETRY_PATTERNS,JSON.stringify(M))},[a]),W=M=>{x(M),a(Ee.PROXY_URL,M)};function B(){N(async()=>(await xe("/api/proxy/test",{method:"POST"})).json())}const Z=()=>{const M=!d.openInEditor;h(te=>({...te,openInEditor:M})),a(Ee.DISPLAY_SHOW_OPEN_IN_EDITOR,String(M))},Q=()=>{const M=!d.dynamicPrompt;h(te=>({...te,dynamicPrompt:M})),a(Ee.LLM_DYNAMIC_SYSTEM_PROMPT,String(M))},J=()=>{const M=!d.cacheWarming;h(te=>({...te,cacheWarming:M})),a(Ee.CACHE_WARMING,String(M))};function U(){e(),t("/onboarding")}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[G==="available"&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:P?s.jsxs(s.Fragment,{children:["Current version: ",s.jsxs("span",{className:"font-mono",children:["v",P]})]}):"Check for a new OpenFox version."}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(rt,{variant:"secondary",onClick:()=>{q(!0),V()},disabled:G==="checking",children:G==="checking"?"Checking…":"Check for Updates"}),H&&G==="upToDate"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),G==="error"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),G==="available"&&s.jsxs("button",{onClick:()=>D(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",z," →"]})]})]}),s.jsx(nE,{isOpen:E,onClose:()=>D(!1),versionInfo:$}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("button",{onClick:()=>O(!0),className:"text-sm text-accent-primary hover:underline",children:"View Changelog →"}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("span",{className:"text-xs text-text-muted",children:"Show on update"}),s.jsx(ds,{enabled:(n[Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const te=(n[Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,te)}})]})]}),s.jsx(BN,{isOpen:A,onClose:()=>O(!1)}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Default Agent"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Choose which agent is used by default for new sessions. The stock Planner is read-only; custom agents can have broader capabilities."}),s.jsxs("select",{value:_?w:"",onChange:M=>{const te=M.target.value;C(te),a(Ee.DEFAULT_AGENT,te)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",children:[!_&&s.jsx("option",{value:"",children:"Loading…"}),_&&s.jsx("option",{value:"",children:"System default (planner)"}),I.map(M=>s.jsx("option",{value:M.id,children:M.name},M.id))]}),I.length===0&&_&&s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),s.jsx(rt,{variant:"secondary",onClick:U,children:"Launch Onboarding"})]}),s.jsx("hr",{className:"border-border"}),s.jsx("div",{children:s.jsx(lx,{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:Z})}),s.jsx("hr",{className:"border-border"}),s.jsx(lx,{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}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Network"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"HTTP Proxy"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(Ns,{type:"text",value:g,onChange:M=>W(M.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),s.jsx(rt,{variant:"secondary",onClick:B,style:k?{color:"rgb(63, 185, 80)"}:void 0,children:v})]}),b&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:b}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Proxy server all OpenFox network requests (AI, model fetching, web search, terminal). Leave empty for direct connection."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Define regex patterns that, when matched against LLM responses mid-stream, trigger an automatic retry with a "continue" prompt. The content that triggered the match is preserved in the chat feed.'}),s.jsx(z3,{value:p,onChange:R})]}),s.jsx("hr",{className:"border-border"}),s.jsx(lx,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:Q,boldTitle:!0})]})}function lx({title:e,description:t,enabled:n,onToggle:r,boldTitle:a}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),s.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0",children:s.jsx(ds,{enabled:n,onClick:r})})]})}function FF(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function UF({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:l,onClear:c,onReset:u,onCancelRecording:d}){const h=j.useRef(null),p=j.useRef(0),m=j.useRef("");return j.useEffect(()=>{if(!r)return;const g=new Set(["Control","Shift","Alt","Meta"]);let x=[];const w=_=>{if(_.preventDefault(),_.stopPropagation(),_.key==="Escape"){d();return}if(g.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&&!x.includes("ctrl")&&x.push("ctrl"),_.metaKey&&!x.includes("meta")&&x.push("meta"),_.altKey&&!x.includes("alt")&&x.push("alt"),_.shiftKey&&!x.includes("shift")&&x.push("shift");return}if(x.length>0||_.ctrlKey||_.metaKey||_.altKey||_.shiftKey){const b=[...x];_.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:Ww(_),modifiers:b});return}const S=Date.now(),v=Ww(_);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"&&(x=x.filter(S=>S!=="ctrl")),_.key==="Shift"&&(x=x.filter(S=>S!=="shift")),_.key==="Alt"&&(x=x.filter(S=>S!=="alt")),_.key==="Meta"&&(x=x.filter(S=>S!=="meta"))};return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",C,!0)}},[r,l,d]),s.jsxs("div",{ref:h,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${r?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-sm text-text-primary",children:e}),s.jsx("div",{className:"flex items-center gap-2",children:r?s.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:t?Ah(t):"None"}),t&&s.jsx("button",{type:"button",onClick:c,title:"Remove shortcut","aria-label":`Remove shortcut for ${e}`,className:"p-1 text-text-muted rounded hover:text-accent-error hover:bg-bg-tertiary transition-colors",children:s.jsx(Yy,{className:"w-3.5 h-3.5"})}),!FF(t,n)&&s.jsx("button",{type:"button",onClick:u,title:"Reset to default","aria-label":`Reset ${e} to default`,className:"p-1 text-text-muted rounded hover:text-accent-primary hover:bg-bg-tertiary transition-colors",children:s.jsx(wf,{className:"w-3.5 h-3.5"})})]})})]})}function VF(){const{settings:e,loading:t,setSetting:n}=na(),r=e[Ee.KEYBINDINGS],a=t[Ee.KEYBINDINGS]??!1,l=Px(r),[c,u]=j.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle,defaultBinding:js.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction,defaultBinding:js.quickAction},{id:"modelSelector",label:"Select Model",binding:l.modelSelector,defaultBinding:js.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:l.sessionSearch,defaultBinding:js.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:l.criteriaSidebar,defaultBinding:js.criteriaSidebar},...l.agentSwitching.map((x,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:x,defaultBinding:js.agentSwitching[w]??null}))],h=x=>{u(x)},p=j.useCallback((x,w)=>{const C=Px(r);if(x.startsWith("agentSwitching.")){const _=parseInt(x.split(".")[1],10);C.agentSwitching[_]=w}else x==="terminalToggle"?C.terminalToggle=w:x==="quickAction"?C.quickAction=w:x==="modelSelector"?C.modelSelector=w:x==="sessionSearch"?C.sessionSearch=w:x==="criteriaSidebar"&&(C.criteriaSidebar=w);n(Ee.KEYBINDINGS,JSON.stringify(C))},[r,n]),m=j.useCallback(x=>{c&&(u(null),p(c,x))},[c,p]),g=()=>{n(Ee.KEYBINDINGS,JSON.stringify(js))};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),s.jsx("button",{type:"button",onClick:g,disabled:a,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),a?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsx("div",{className:"space-y-1",children:d.map(x=>s.jsx(UF,{label:x.label,binding:x.binding,defaultBinding:x.defaultBinding,isRecording:c===x.id,onStartRecording:()=>h(x.id),onBindingRecorded:m,onClear:()=>p(x.id,null),onReset:()=>p(x.id,x.defaultBinding),onCancelRecording:()=>u(null)},x.id))})]})}function Ib(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 Mb(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function Kh(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function $N({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:l,onToolToggle:c,statusDot:u,statusColor:d,actions:h,authPanel:p}){var w;const[m,g]=j.useState(new Set),x=e.name;return s.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-bg-primary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer",onClick:()=>n(x),children:[s.jsx("span",{className:`text-sm ${d}`,children:u}),s.jsx("span",{className:"text-sm font-medium text-text-primary",children:x}),s.jsx("span",{className:"text-xs text-text-muted",children:e.config.transport}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",l.length," tools)"]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[Kh(e.estimatedTokens)," tokens"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ds,{enabled:r,onClick:a}),h,s.jsx("span",{className:"text-xs text-text-muted",children:t?"▲":"▼"})]})]}),t&&s.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[e.config.command&&s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[e.config.command," ",((w=e.config.args)==null?void 0:w.join(" "))??""]}),e.config.url&&s.jsx("div",{className:"text-xs text-text-muted font-mono",children:e.config.url}),p,l.length===0?s.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):s.jsx("div",{className:"space-y-1",children:l.map(C=>s.jsxs("div",{className:"py-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[s.jsx("span",{className:"text-xs text-text-primary font-mono",children:C.name}),C.description&&C.description.length>80?s.jsxs("button",{onClick:()=>{const _=C.name;g(S=>{const v=new Set(S);return v.has(_)?v.delete(_):v.add(_),v})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[s.jsx("span",{className:"truncate max-w-[300px]",children:C.description}),s.jsx(pn,{rotate:m.has(C.name)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):C.description?s.jsx("span",{className:"text-xs text-text-muted ml-2",children:C.description}):null]}),s.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:Kh(C.estimatedTokens)}),s.jsx(ds,{enabled:C.enabled,onClick:()=>c(C.name)})]}),C.description&&C.description.length>80&&m.has(C.name)&&s.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:C.description})]},C.name))})]})]},x)}function OC(e){const t={};return e.split(`
251
+ `).filter(Boolean).forEach(n=>{const r=n.indexOf("=");r>0&&(t[n.slice(0,r).trim()]=n.slice(r+1).trim())}),t}function IC({formData:e,onChange:t}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>t({...e,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),s.jsx("button",{onClick:()=>t({...e,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),e.transport==="stdio"?s.jsxs(s.Fragment,{children:[s.jsx(Xr,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),s.jsx(Xr,{label:"Arguments",value:e.args,onChange:n=>t({...e,args:n}),placeholder:"space-separated args"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.jsx("textarea",{value:e.env,onChange:n=>t({...e,env:n.target.value}),placeholder:"API_KEY=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Xr,{label:"URL",value:e.url,onChange:n=>t({...e,url:n}),placeholder:"e.g. https://mcp.example.com/mcp"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.jsx("textarea",{value:e.headers,onChange:n=>t({...e,headers:n.target.value}),placeholder:"X-API-Key=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e.oauth,onChange:n=>t({...e,oauth:n.target.checked}),className:"mt-0.5"}),s.jsxs("span",{className:"text-xs text-text-secondary",children:["Authorize with OAuth",s.jsx("span",{className:"block text-text-muted",children:"For servers that require a sign in rather than a static credential. Expand the server afterwards to authorize."})]})]})]}),s.jsx(Xr,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}const cx="px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors disabled:opacity-50";function GF({serverName:e,onChanged:t}){const[n,r]=j.useState(!1),[a,l]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(""),p=`/api/mcp/servers/${encodeURIComponent(e)}/oauth`,m=async _=>{r(!0),h("");try{await _()}catch(S){h(S instanceof Error?S.message:String(S))}finally{r(!1)}},g=async(_,S)=>{const v=await xe(_,{method:"POST",headers:{"Content-Type":"application/json"},...S!==void 0?{body:JSON.stringify(S)}:{}}),b=await v.json();if(!v.ok)throw new Error(b.error??"Request failed");return b},x=()=>m(async()=>{const _=await g(`${p}/start`);if(_.status!=="redirect"){t();return}l(_.redirectUri??""),window.open(_.authorizationUrl,"_blank","noopener,noreferrer")}),w=()=>m(async()=>{await g(`${p}/complete`,{response:c}),u(""),l(""),t()}),C=()=>m(async()=>{if(!(await xe(p,{method:"DELETE"})).ok)throw new Error("Could not clear the stored credentials");t()});return s.jsxs("div",{className:"space-y-1.5 py-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:x,disabled:n,className:cx,children:"Authorize"}),s.jsx("button",{onClick:C,disabled:n,className:cx,children:"Forget credentials"})]}),a&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"text-xs text-text-muted",children:"A tab opened for you to sign in. If it ends up on a page that will not load, copy the whole address from it and paste it below."}),s.jsx("div",{className:"text-xs text-text-muted font-mono break-all",children:a}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{value:c,onChange:_=>u(_.target.value),placeholder:"paste the callback URL",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("button",{onClick:w,disabled:n||!c,className:cx,children:"Finish"})]})]}),d&&s.jsx("div",{className:"text-xs text-accent-error",children:d})]})}function ux(e,t,n,r=250){const a=j.useRef(!0);j.useEffect(()=>{if(a.current){a.current=!1;return}const l=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(l)},[e,t,r,n])}function MC({saving:e,saveLabel:t,savingLabel:n,onCancel:r,onSave:a}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[s.jsx(rt,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),s.jsx(rt,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function WF(){const{settings:e,getSetting:t,setSetting:n}=na(),[r,a]=j.useState(""),[l,c]=j.useState(""),[u,d]=j.useState(""),[h,p]=j.useState("");ux(l,Ee.SEARCH_TAVILY_API_KEY,n),ux(u,Ee.SEARCH_SEARXNG_URL,n),ux(h,Ee.SEARCH_SEARXNG_API_KEY,n);const[m,g,x,w]=Bx(),[C,_,S,v]=Bx();j.useEffect(()=>{t(Ee.SEARCH_ENGINE),t(Ee.SEARCH_TAVILY_API_KEY),t(Ee.SEARCH_SEARXNG_URL),t(Ee.SEARCH_SEARXNG_API_KEY),t(Ee.TOOLS_USE_RTK),t(Ee.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),j.useEffect(()=>{e[Ee.SEARCH_ENGINE]!==void 0&&(a(e[Ee.SEARCH_ENGINE]??""),c(e[Ee.SEARCH_TAVILY_API_KEY]??""),d(e[Ee.SEARCH_SEARXNG_URL]??""),p(e[Ee.SEARCH_SEARXNG_API_KEY]??""))},[e]);function b(fe){a(fe),n(Ee.SEARCH_ENGINE,fe)}function k(){w(async()=>(await xe("/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 xe("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:u||void 0,searxngApiKey:h||void 0})})).json())}const[E,D]=j.useState("checking");j.useEffect(()=>{xe("/api/tools/rtk-check").then(fe=>fe.json()).then(fe=>D(fe.available?"available":"unavailable")).catch(()=>D("unavailable"))},[]);const[A,O]=j.useState([]);j.useEffect(()=>{t(Ee.TOOLS_SHELL),xe("/api/tools/shells").then(fe=>fe.json()).then(fe=>O(fe.shells??[])).catch(()=>O([]))},[t]);const P=e[Ee.TOOLS_SHELL]||"cmd",[G,z]=j.useState([]),[V,$]=j.useState(!0),[H,q]=j.useState(!1),[X,Y]=j.useState(null),[F,I]=j.useState(new Set),[R,W]=j.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""}),[B,Z]=j.useState(""),[Q,J]=j.useState(""),[U,M]=j.useState(!1),{requestDelete:te,clearConfirm:se,isConfirming:re}=fu(),le=j.useCallback(async()=>{try{const He=((await(await xe("/api/mcp/servers")).json()).servers??[]).sort((ie,Se)=>ie.name.localeCompare(Se.name));z(He)}catch{}$(!1)},[]);j.useEffect(()=>{le()},[le]),j.useEffect(()=>{const fe=()=>le();return window.addEventListener("mcp-servers-changed",fe),()=>window.removeEventListener("mcp-servers-changed",fe)},[le]);const ye=fe=>{I(Fe=>{const He=new Set(Fe);return He.has(fe)?(He.delete(fe),He):(He.add(fe),He)})};function _e(){if(R.transport==="stdio"&&!R.command)return"Command is required for stdio transport";if(R.transport==="http"&&!R.url)return"URL is required for HTTP transport";if(R.timeout){const fe=parseFloat(R.timeout);if(isNaN(fe)||fe<=0)return"Timeout must be a positive number"}return null}function Oe(fe){const Fe=fe?{name:R.name,transport:R.transport}:{transport:R.transport};if(R.transport==="stdio"?(Fe.command=R.command,Fe.args=R.args?R.args.split(" ").filter(Boolean):[],Fe.env=OC(R.env)):(Fe.url=R.url,Fe.headers=OC(R.headers),Fe.oauth=R.oauth),R.timeout){const He=parseFloat(R.timeout);!isNaN(He)&&He>0&&(Fe.timeout=He)}return Fe}const Be={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""},ke=async()=>{if(Z(""),!R.name){Z("Name is required");return}const fe=_e();if(fe){Z(fe);return}M(!0);try{const Fe=Oe(!0),He=await xe("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Fe)});if(!He.ok){const ie=await He.json();throw new Error(ie.error??"Failed to add server")}q(!1),W(Be),await le()}catch(Fe){Z(Fe instanceof Error?Fe.message:String(Fe))}finally{M(!1)}},Ge=fe=>{var Fe;W({name:fe.name,transport:fe.config.transport,command:fe.config.command??"",args:((Fe=fe.config.args)==null?void 0:Fe.join(" "))??"",env:fe.config.env?Object.entries(fe.config.env).map(([He,ie])=>`${He}=${ie}`).join(`
252
+ `):"",url:fe.config.url??"",headers:fe.config.headers?Object.entries(fe.config.headers).map(([He,ie])=>`${He}=${ie}`).join(`
253
+ `):"",oauth:fe.config.oauth??!1,timeout:fe.config.timeout!==void 0?String(fe.config.timeout):""}),Z(""),Y(fe.name)},Je=async()=>{Z("");const fe=_e();if(fe){Z(fe);return}M(!0);try{const Fe=Oe(!1),He=await xe(`/api/mcp/servers/${encodeURIComponent(X)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Fe)});if(!He.ok){const ie=await He.json();throw new Error(ie.error??"Failed to update server")}Y(null),W(Be),await le()}catch(Fe){Z(Fe instanceof Error?Fe.message:String(Fe))}finally{M(!1)}},ae=async fe=>{try{const Fe=await xe(`/api/mcp/servers/${encodeURIComponent(fe)}`,{method:"DELETE"});if(!Fe.ok){const He=await Fe.json().catch(()=>({}));throw new Error(He.error??"Failed to remove server")}se(),J(""),await le()}catch(Fe){J(Fe instanceof Error?Fe.message:String(Fe))}},ue=async(fe,Fe,He)=>{try{const ie=await xe(`/api/mcp/servers/${encodeURIComponent(fe)}/tools/${encodeURIComponent(Fe)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})});if(!ie.ok){const Se=await ie.json().catch(()=>({}));throw new Error(Se.error??"Failed to toggle tool")}J(""),await le()}catch(ie){J(ie instanceof Error?ie.message:String(ie))}},Me=async(fe,Fe)=>{try{const He=await xe(`/api/mcp/servers/${encodeURIComponent(fe)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:Fe})});if(!He.ok){const ie=await He.json().catch(()=>({}));throw new Error(ie.error??"Failed to toggle server")}J(""),await le()}catch(He){J(He instanceof Error?He.message:String(He))}};return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),s.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(fe=>s.jsx("button",{onClick:()=>b(fe),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===fe?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:fe||"Off"},fe))})]}),r==="tavily"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(Ns,{type:"password",value:l,onChange:fe=>c(fe.target.value),placeholder:"tvly-...",className:"flex-1"}),s.jsx(rt,{variant:"secondary",onClick:k,style:x?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),g&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:g}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",s.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),s.jsx(Ns,{type:"url",value:u,onChange:fe=>d(fe.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx(Ns,{type:"password",value:h,onChange:fe=>p(fe.target.value),placeholder:"Optional API key",className:"w-full"})]}),s.jsx(rt,{variant:"secondary",onClick:N,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),_&&s.jsx("p",{className:"text-xs text-red-500",children:_})]})]})]}),A.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Shell used to run agent commands and integrated terminals. Git Bash gives the agent a Unix-like toolset (grep, sed, ls…) and usually works better than cmd.exe."}),s.jsx("div",{className:"flex gap-2",children:A.map(fe=>s.jsxs("button",{onClick:()=>n(Ee.TOOLS_SHELL,fe.id),disabled:!fe.available,title:fe.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${P===fe.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":fe.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[fe.label,!fe.available&&" (not found)"]},fe.id))}),s.jsx("p",{className:"text-xs text-text-muted mt-2",children:"Applies to new commands and newly opened terminals. Running terminals keep their current shell."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",s.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),E==="checking"&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),E==="available"&&s.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),E==="unavailable"&&s.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),s.jsx(ds,{enabled:e[Ee.TOOLS_USE_RTK]==="true",onClick:()=>n(Ee.TOOLS_USE_RTK,e[Ee.TOOLS_USE_RTK]==="true"?"false":"true")})]}),A.length>0&&e[Ee.TOOLS_USE_RTK]==="true"&&P!=="gitbash"&&s.jsx("p",{className:"text-xs text-accent-warning mt-1",children:"RTK only rewrites Unix-style commands — with this shell it will rarely apply and can break some commands. Git Bash is recommended."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Agent Confirmations"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Require confirmation for workspace changes and git mutations. When disabled, the agent proceeds without interruption."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Confirm on workspace & git actions"})}),s.jsx(ds,{enabled:e[Ee.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(Ee.CONFIRM_ON_WORKSPACE_ACTIONS,e[Ee.CONFIRM_ON_WORKSPACE_ACTIONS]==="true"?"false":"true")})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary","data-testid":"mcp-servers-heading",children:"MCP Servers"}),s.jsx(rt,{variant:"primary",size:"sm",onClick:()=>q(!0),children:"+ Add Server"})]}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Show per-conversation MCP toggle in chat bar"})}),s.jsx(ds,{enabled:e[Ee.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(Ee.FEATURES_PER_SESSION_MCP,e[Ee.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),Q&&s.jsx(il,{message:Q}),s.jsx(Jy,{loading:V,hasItems:G.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:G.map(fe=>{const Fe=F.has(fe.name)?re(fe.name,"delete")?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ie=>{ie.stopPropagation(),ae(fe.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),s.jsx("button",{onClick:ie=>{ie.stopPropagation(),se()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ie=>{ie.stopPropagation(),Ge(fe)},className:"px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",children:"Edit"}),s.jsx("button",{onClick:ie=>{ie.stopPropagation(),te(fe.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,He=fe.status==="error"&&fe.error?s.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:fe.error,children:fe.error}):null;return s.jsx($N,{server:fe,expanded:F.has(fe.name),onToggleExpand:ye,serverToggleEnabled:!fe.config.disabled,onServerToggle:()=>Me(fe.name,!fe.config.disabled),tools:fe.tools,onToolToggle:ie=>{var Se;return ue(fe.name,ie,!((Se=fe.tools.find(Le=>Le.name===ie))!=null&&Se.enabled))},statusDot:Mb(fe.status),statusColor:Ib(fe.status),authPanel:fe.config.oauth?s.jsx(GF,{serverName:fe.name,onChanged:le}):null,actions:s.jsxs(s.Fragment,{children:[He,Fe]})},fe.name)})}),H&&s.jsx(St,{isOpen:H,onClose:()=>{q(!1),Z("")},title:"Add MCP Server",size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(Xr,{label:"Name",value:R.name,onChange:fe=>W({...R,name:fe}),placeholder:"e.g. filesystem"}),s.jsx(IC,{formData:R,onChange:W}),B&&s.jsx(il,{message:B}),s.jsx(MC,{saving:U,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{q(!1),Z(""),M(!1),W(Be)},onSave:ke})]})}),X!==null&&s.jsx(St,{isOpen:!0,onClose:()=>{Y(null),Z("")},title:`Edit MCP Server: ${X}`,size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(IC,{formData:R,onChange:W}),B&&s.jsx(il,{message:B}),s.jsx(MC,{saving:U,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{Y(null),Z(""),M(!1),W(Be)},onSave:Je})]})})]})]})}const zN="openfox_user_plugins";function qF(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function dx(e){const t=qF(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 eh(){try{return JSON.parse(localStorage.getItem(zN)??"[]")}catch{return[]}}function PC(e){localStorage.setItem(zN,JSON.stringify(e))}function KF({onAdd:e}){const[t,n]=j.useState(""),[r,a]=j.useState(""),[l,c]=j.useState(!1),u=d=>{d.preventDefault(),!(!t.trim()||!r.trim())&&(e({name:t.trim(),displayName:t.trim(),description:"User-added plugin",githubUrl:r.trim()}),n(""),a(""),c(!0),setTimeout(()=>c(!1),2e3))};return s.jsxs("form",{onSubmit:u,className:"flex gap-2 items-end",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.jsx("input",{type:"text",value:t,onChange: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"})]}),s.jsxs("div",{className:"flex-[2]",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"GitHub URL"}),s.jsx("input",{type:"text",value:r,onChange: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"})]}),s.jsx(rt,{type:"submit",variant:"primary",size:"sm",children:l?"Added":"Add"})]})}function YF({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[l,c]=j.useState(t?"installed":"idle"),[u,d]=j.useState(!1),[h,p]=j.useState(""),[m,g]=j.useState(n),[x,w]=j.useState(!1),[C,_]=j.useState(!1);j.useEffect(()=>{g(n)},[n]);const S=j.useCallback(async()=>{const P=await xe("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),G=await P.json();if(P.ok)c("installed"),e.latestVersion&&g(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()=>{c("installing"),p("");try{await S()}catch(P){c("error"),p(P instanceof Error?P.message:"Connection error")}},b=()=>{w(!0)},k=async()=>{_(!0);try{(await xe(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(c("idle"),r(e.name))}catch{}_(!1),w(!1)},N=async()=>{d(!0),p("");try{await S()}catch(P){p(P instanceof Error?P.message:"Update failed")}d(!1)},E=m??n,D=e.latestVersion&&E&&E!=="unknown"&&e.latestVersion!==E,A=l==="installing"?"Installing…":u?"Updating…":l==="installed"?"Installed ✓":"Install",O=l==="installing"||l==="installed"||u;return s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&s.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?s.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?s.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,E&&E!=="unknown"&&s.jsxs("span",{className:"text-text-muted",children:["installed: v",E]})]}),l==="error"&&h&&s.jsx("p",{className:"text-xs text-accent-error mt-1",children:h})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[s.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&s.jsx(rt,{variant:l==="installed"?"secondary":"primary",size:"sm",onClick:v,disabled:O,children:A}),D&&s.jsx(rt,{variant:"primary",size:"sm",onClick:N,children:"Update"}),l==="installed"&&s.jsx(rt,{variant:"danger",size:"sm",onClick:b,children:"Remove"})]}),l==="installed"&&s.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),s.jsx(hl,{isOpen:x,onClose:()=>w(!1),onConfirm:k,title:`Remove "${e.displayName}"?`,message:`Remove the "${e.displayName}" plugin from your installation.`,confirmLabel:"Remove",confirmVariant:"danger",disabled:C})]})}function XF(){const[e,t]=j.useState([]),[n,r]=j.useState([]),[a,l]=j.useState({}),[c,u]=j.useState(!0),[d,h]=j.useState(""),[p,m]=j.useState("");j.useEffect(()=>{let S=!1;Promise.all([xe("/api/plugins/registry").then(b=>{if(!b.ok)throw new Error(`HTTP ${b.status}`);return b.json()}),xe("/api/plugins/installed").then(b=>b.ok?b.json():{installed:[]})]).then(([b,k])=>{if(S)return;const N={},E=k.installed;for(const G of E)N[G.name]=G.version;l(N);const D=b.plugins.map(G=>({...G,latestVersion:null,versionLoading:!0}));t(D),D.forEach(G=>{dx(G.githubUrl).then(z=>{S||t(V=>V.map($=>$.name===G.name?{...$,latestVersion:z,versionLoading:!1}:$))})});const A=new Set(D.map(G=>G.name)),O=eh(),P=[];for(const G of E)!A.has(G.name)&&!O.some(z=>z.name===G.name)&&P.push({name:G.name,displayName:G.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});P.length>0&&r(G=>[...G,...P])}).catch(b=>{S||h(b instanceof Error?b.message:"Failed to load plugins")}).finally(()=>{S||u(!1)});const v=eh();return v.length>0&&(r(v.map(b=>({...b,latestVersion:null,versionLoading:!0}))),v.forEach(b=>{dx(b.githubUrl).then(k=>{S||r(N=>N.map(E=>E.name===b.name?{...E,latestVersion:k,versionLoading:!1}:E))})})),()=>{S=!0}},[]);const g=async S=>{try{S?await xe(`/api/plugins/${S}/open-folder`):await xe("/api/plugins/open-folder")}catch{}},x=j.useCallback(S=>{l(k=>{const N={...k};return delete N[S],N});const v=eh(),b=v.filter(k=>k.name!==S);b.length!==v.length&&PC(b),r(k=>k.filter(N=>N.name!==S))},[]),w=j.useCallback(S=>{if(new Set(e.map(k=>k.name)).has(S.name)){m(`"${S.displayName}" is already listed in the registry and won't be added again.`);return}const b=eh();PC([...b,S]),r(k=>[...k,{...S,latestVersion:null,versionLoading:!0}]),dx(S.githubUrl).then(k=>{r(N=>N.map(E=>E.name===S.name?{...E,latestVersion:k,versionLoading:!1}:E))})},[e]),C=new Set,_=[...e,...n].filter(S=>C.has(S.name)?!1:(C.add(S.name),!0));return c?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading plugins..."}):s.jsxs("div",{className:"space-y-4",children:[d&&s.jsxs("div",{className:"text-sm text-accent-error bg-accent-error/10 border border-accent-error/30 rounded-lg p-3",children:["Failed to load plugin registry: ",d]}),p&&s.jsxs("div",{className:"text-sm text-accent-warning bg-accent-warning/10 border border-accent-warning/30 rounded-lg p-3 flex justify-between items-center",children:[s.jsx("span",{children:p}),s.jsx("button",{onClick:()=>m(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),s.jsx(KF,{onAdd:w})]}),_.length===0&&!d&&s.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),_.map(S=>s.jsx(YF,{plugin:S,initiallyInstalled:S.name in a,installedVersion:a[S.name]??null,onRemove:x,onOpenFolder:g},S.name))]})}function JF({isOpen:e,onClose:t}){const[n,r]=j.useState("instructions"),a=ui(c=>c.status==="available"),l=()=>{try{Bt.send("context.checkDynamic",{})}catch{}t()};return s.jsx(St,{isOpen:e,onClose:l,title:"Settings",size:"xl",scrollable:!1,children:s.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full min-h-0 -m-4",children:[s.jsxs(dt,{horizontal:!0,options:{scrollbars:{visibility:"hidden"}},className:"flex border-b border-border mb-4 flex-shrink-0 px-4 pt-4",children:[s.jsx(zi,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),s.jsx(zi,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),s.jsx(zi,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),s.jsx(zi,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),s.jsx(zi,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),s.jsx(zi,{label:"Display",active:n==="display",onClick:()=>r("display")}),s.jsx(zi,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),s.jsx(zi,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),s.jsxs(dt,{className:"flex-1 min-h-0 px-4 pb-4",children:[n==="instructions"&&s.jsx(_3,{isOpen:e}),n==="skills"&&s.jsx(v3,{isOpen:e}),n==="plugins"&&s.jsx(XF,{}),n==="notifications"&&s.jsx(u3,{}),n==="display"&&s.jsx(I3,{}),n==="keybindings"&&s.jsx(VF,{}),n==="tools"&&s.jsx(WF,{}),n==="advanced"&&s.jsx(HF,{onClose:t})]})]})})}function zi({label:e,active:t,onClick:n,showDot:r}){return s.jsxs("button",{onClick:n,className:`relative px-4 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:[e,r&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]})}var hx={exports:{}},BC;function QF(){return BC||(BC=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(c,u,d){var h=this&&this.__decorate||function(v,b,k,N){var E,D=arguments.length,A=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,k):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,k,N);else for(var O=v.length-1;O>=0;O--)(E=v[O])&&(A=(D<3?E(A):D>3?E(b,k,A):E(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(v,b){return function(k,N){b(k,N,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.AccessibilityManager=void 0;const m=d(9042),g=d(9924),x=d(844),w=d(4725),C=d(2585),_=d(3656);let S=u.AccessibilityManager=class extends x.Disposable{constructor(v,b,k,N){super(),this._terminal=v,this._coreBrowserService=k,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 E=0;E<this._terminal.rows;E++)this._rowElements[E]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[E]);if(this._topBoundaryFocusListener=E=>this._handleBoundaryFocus(E,0),this._bottomBoundaryFocusListener=E=>this._handleBoundaryFocus(E,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new g.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((E=>this._handleResize(E.rows)))),this.register(this._terminal.onRender((E=>this._refreshRows(E.start,E.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((E=>this._handleChar(E)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
254
+ `)))),this.register(this._terminal.onA11yTab((E=>this._handleTab(E)))),this.register(this._terminal.onKey((E=>this._handleKey(E.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,x.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===`
255
+ `&&(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 k=this._terminal.buffer,N=k.lines.length.toString();for(let E=v;E<=b;E++){const D=k.lines.get(k.ydisp+E),A=[],O=(D==null?void 0:D.translateToString(!0,void 0,void 0,A))||"",P=(k.ydisp+E+1).toString(),G=this._rowElements[E];G&&(O.length===0?(G.innerText=" ",this._rowColumns.set(G,[0,1])):(G.textContent=O,this._rowColumns.set(G,A)),G.setAttribute("aria-posinset",P),G.setAttribute("aria-setsize",N))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,b){const k=v.target,N=this._rowElements[b===0?1:this._rowElements.length-2];if(k.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==N)return;let E,D;if(b===0?(E=k,D=this._rowElements.pop(),this._rowContainer.removeChild(D)):(E=this._rowElements.shift(),D=k,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),D.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const A=this._createAccessibilityTreeNode();this._rowElements.unshift(A),this._rowContainer.insertAdjacentElement("afterbegin",A)}else{const A=this._createAccessibilityTreeNode();this._rowElements.push(A),this._rowContainer.appendChild(A)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){var O;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},k={node:v.focusNode,offset:v.focusOffset};if((b.node.compareDocumentPosition(k.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===k.node&&b.offset>k.offset)&&([b,k]=[k,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(k.node.compareDocumentPosition(N)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(k={node:N,offset:((O=N.textContent)==null?void 0:O.length)??0}),!this._rowContainer.contains(k.node))return;const E=({node:P,offset:G})=>{const z=P instanceof Text?P.parentNode:P;let V=parseInt(z==null?void 0:z.getAttribute("aria-posinset"),10)-1;if(isNaN(V))return console.warn("row is invalid. Race condition?"),null;const $=this._rowColumns.get(z);if(!$)return console.warn("columns is null. Race condition?"),null;let H=G<$.length?$[G]:$.slice(-1)[0]+1;return H>=this._terminal.cols&&(++V,H=0),{row:V,column:H}},D=E(b),A=E(k);if(D&&A){if(D.row>A.row||D.row===A.row&&D.column>=A.column)throw new Error("invalid range");this._terminal.select(D.column,D.row,(A.row-D.row)*this._terminal.cols-D.column+A.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`}};u.AccessibilityManager=S=h([p(1,C.IInstantiationService),p(2,w.ICoreBrowserService),p(3,w.IRenderService)],S)},3614:(c,u)=>{function d(g){return g.replace(/\r?\n/g,"\r")}function h(g,x){return x?"\x1B[200~"+g+"\x1B[201~":g}function p(g,x,w,C){g=h(g=d(g),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(g,!0),x.value=""}function m(g,x,w){const C=w.getBoundingClientRect(),_=g.clientX-C.left-10,S=g.clientY-C.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${_}px`,x.style.top=`${S}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(u,"__esModule",{value:!0}),u.rightClickHandler=u.moveTextAreaUnderMouseCursor=u.paste=u.handlePasteEvent=u.copyHandler=u.bracketTextForPaste=u.prepareTextForTerminal=void 0,u.prepareTextForTerminal=d,u.bracketTextForPaste=h,u.copyHandler=function(g,x){g.clipboardData&&g.clipboardData.setData("text/plain",x.selectionText),g.preventDefault()},u.handlePasteEvent=function(g,x,w,C){g.stopPropagation(),g.clipboardData&&p(g.clipboardData.getData("text/plain"),x,w,C)},u.paste=p,u.moveTextAreaUnderMouseCursor=m,u.rightClickHandler=function(g,x,w,C,_){m(g,x,w),_&&C.rightClickSelect(g),x.value=C.selectionText,x.select()}},7239:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ColorContrastCache=void 0;const h=d(1505);u.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(p,m,g){this._css.set(p,m,g)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,g){this._color.set(p,m,g)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.addDisposableDomListener=void 0,u.addDisposableDomListener=function(d,h,p,m){d.addEventListener(h,p,m);let g=!1;return{dispose:()=>{g||(g=!0,d.removeEventListener(h,p,m))}}}},3551:function(c,u,d){var h=this&&this.__decorate||function(S,v,b,k){var N,E=arguments.length,D=E<3?v:k===null?k=Object.getOwnPropertyDescriptor(v,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,v,b,k);else for(var A=S.length-1;A>=0;A--)(N=S[A])&&(D=(E<3?N(D):E>3?N(v,b,D):N(v,b))||D);return E>3&&D&&Object.defineProperty(v,b,D),D},p=this&&this.__param||function(S,v){return function(b,k){v(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Linkifier=void 0;const m=d(3656),g=d(8460),x=d(844),w=d(2585),C=d(4725);let _=u.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(S,v,b,k,N){super(),this._element=S,this._mouseService=v,this._renderService=b,this._bufferService=k,this._linkProviderService=N,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{var E;this._lastMouseEvent=void 0,(E=this._activeProviderReplies)==null||E.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 k=0;k<b.length;k++){const N=b[k];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 k,N;this._activeProviderReplies&&v||((k=this._activeProviderReplies)==null||k.forEach((E=>{E==null||E.forEach((D=>{D.link.dispose&&D.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let b=!1;for(const[E,D]of this._linkProviderService.linkProviders.entries())v?(N=this._activeProviderReplies)!=null&&N.get(E)&&(b=this._checkLinkProviderResult(E,S,b)):D.provideLinks(S.y,(A=>{var P,G;if(this._isMouseOut)return;const O=A==null?void 0:A.map((z=>({link:z})));(P=this._activeProviderReplies)==null||P.set(E,O),b=this._checkLinkProviderResult(E,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 k=0;k<v.size;k++){const N=v.get(k);if(N)for(let E=0;E<N.length;E++){const D=N[E],A=D.link.range.start.y<S?0:D.link.range.start.x,O=D.link.range.end.y>S?this._bufferService.cols:D.link.range.end.x;for(let P=A;P<=O;P++){if(b.has(P)){N.splice(E--,1);break}b.add(P)}}}}_checkLinkProviderResult(S,v,b){var E;if(!this._activeProviderReplies)return b;const k=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&&k){const D=k.find((A=>this._linkAtPosition(A.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 A=(E=this._activeProviderReplies.get(D))==null?void 0:E.find((O=>this._linkAtPosition(O.link,v)));if(A){b=!0,this._handleNewLink(A);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,x.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,k;return(k=(b=this._currentLink)==null?void 0:b.state)==null?void 0:k.decorations.pointerCursor},set:b=>{var k;(k=this._currentLink)!=null&&k.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,k;return(k=(b=this._currentLink)==null?void 0:b.state)==null?void 0:k.decorations.underline},set:b=>{var k,N,E;(k=this._currentLink)!=null&&k.state&&((E=(N=this._currentLink)==null?void 0:N.state)==null?void 0:E.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 k=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>=k&&this._currentLink.link.range.end.y<=N&&(this._clearCurrentLink(k,N),this._lastMouseEvent)){const E=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);E&&this._askForLink(E,!1)}}))))}_linkHover(S,v,b){var k;(k=this._currentLink)!=null&&k.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,k=this._bufferService.buffer.ydisp,N=this._createLinkUnderlineEvent(b.start.x-1,b.start.y-k-1,b.end.x,b.end.y-k-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(N)}_linkLeave(S,v,b){var k;(k=this._currentLink)!=null&&k.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,k=S.range.end.y*this._bufferService.cols+S.range.end.x,N=v.y*this._bufferService.cols+v.x;return b<=N&&N<=k}_positionFromMouseEvent(S,v,b){const k=b.getCoords(S,v,this._bufferService.cols,this._bufferService.rows);if(k)return{x:k[0],y:k[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,v,b,k,N){return{x1:S,y1:v,x2:b,y2:k,cols:this._bufferService.cols,fg:N}}};u.Linkifier=_=h([p(1,C.IMouseService),p(2,C.IRenderService),p(3,w.IBufferService),p(4,C.ILinkProviderService)],_)},9042:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.tooMuchOutput=u.promptLabel=void 0,u.promptLabel="Terminal input",u.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(c,u,d){var h=this&&this.__decorate||function(C,_,S,v){var b,k=arguments.length,N=k<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 E=C.length-1;E>=0;E--)(b=C[E])&&(N=(k<3?b(N):k>3?b(_,S,N):b(_,S))||N);return k>3&&N&&Object.defineProperty(_,S,N),N},p=this&&this.__param||function(C,_){return function(S,v){_(S,v,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkProvider=void 0;const m=d(511),g=d(2585);let x=u.OscLinkProvider=class{constructor(C,_,S){this._bufferService=C,this._optionsService=_,this._oscLinkService=S}provideLinks(C,_){var O;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void _(void 0);const v=[],b=this._optionsService.rawOptions.linkHandler,k=new m.CellData,N=S.getTrimmedLength();let E=-1,D=-1,A=!1;for(let P=0;P<N;P++)if(D!==-1||S.hasContent(P)){if(S.loadCell(P,k),k.hasExtendedAttrs()&&k.extended.urlId){if(D===-1){D=P,E=k.extended.urlId;continue}A=k.extended.urlId!==E}else D!==-1&&(A=!0);if(A||D!==-1&&P===N-1){const G=(O=this._oscLinkService.getLinkData(E))==null?void 0:O.uri;if(G){const z={start:{x:D+1,y:C},end:{x:P+(A||P!==N-1?0:1),y:C}};let V=!1;if(!(b!=null&&b.allowNonHttpProtocols))try{const $=new URL(G);["http:","https:"].includes($.protocol)||(V=!0)}catch{V=!0}V||v.push({text:G,range:z,activate:($,H)=>b?b.activate($,H,z):w(0,H),hover:($,H)=>{var q;return(q=b==null?void 0:b.hover)==null?void 0:q.call(b,$,H,z)},leave:($,H)=>{var q;return(q=b==null?void 0:b.leave)==null?void 0:q.call(b,$,H,z)}})}A=!1,k.hasExtendedAttrs()&&k.extended.urlId?(D=P,E=k.extended.urlId):(D=-1,E=-1)}}_(v)}};function w(C,_){if(confirm(`Do you want to navigate to ${_}?
256
+
257
+ 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")}}u.OscLinkProvider=x=h([p(0,g.IBufferService),p(1,g.IOptionsService),p(2,g.IOscLinkService)],x)},6193:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.RenderDebouncer=void 0,u.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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const h=d(3614),p=d(3656),m=d(3551),g=d(9042),x=d(3730),w=d(1680),C=d(3107),_=d(5744),S=d(2950),v=d(1296),b=d(428),k=d(4269),N=d(5114),E=d(8934),D=d(3230),A=d(9312),O=d(4725),P=d(6731),G=d(8055),z=d(8969),V=d(8460),$=d(844),H=d(6114),q=d(8437),X=d(2584),Y=d(7399),F=d(5941),I=d(9074),R=d(2585),W=d(5435),B=d(4567),Z=d(779);class Q extends z.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(U={}){super(U),this.browser=H,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new $.MutableDisposable),this._onCursorMove=this.register(new V.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new V.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new V.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new V.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new V.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new V.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new V.EventEmitter),this._onBlur=this.register(new V.EventEmitter),this._onA11yCharEmitter=this.register(new V.EventEmitter),this._onA11yTabEmitter=this.register(new V.EventEmitter),this._onWillOpen=this.register(new V.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(I.DecorationService),this._instantiationService.setService(R.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Z.LinkProviderService),this._instantiationService.setService(O.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((M,te)=>this.refresh(M,te)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((M=>this._reportWindowsOptions(M)))),this.register(this._inputHandler.onColor((M=>this._handleColorEvent(M)))),this.register((0,V.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,V.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,V.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,V.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((M=>this._afterResize(M.cols,M.rows)))),this.register((0,$.toDisposable)((()=>{var M,te;this._customKeyEventHandler=void 0,(te=(M=this.element)==null?void 0:M.parentNode)==null||te.removeChild(this.element)})))}_handleColorEvent(U){if(this._themeService)for(const M of U){let te,se="";switch(M.index){case 256:te="foreground",se="10";break;case 257:te="background",se="11";break;case 258:te="cursor",se="12";break;default:te="ansi",se="4;"+M.index}switch(M.type){case 0:const re=G.color.toColorRGB(te==="ansi"?this._themeService.colors.ansi[M.index]:this._themeService.colors[te]);this.coreService.triggerDataEvent(`${X.C0.ESC}]${se};${(0,F.toRgbString)(re)}${X.C1_ESCAPED.ST}`);break;case 1:if(te==="ansi")this._themeService.modifyColors((le=>le.ansi[M.index]=G.channels.toColor(...M.color)));else{const le=te;this._themeService.modifyColors((ye=>ye[le]=G.channels.toColor(...M.color)))}break;case 2:this._themeService.restoreColor(M.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(U){U?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(B.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(U){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(X.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var U;return(U=this.textarea)==null?void 0:U.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(X.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const U=this.buffer.ybase+this.buffer.y,M=this.buffer.lines.get(U);if(!M)return;const te=Math.min(this.buffer.x,this.cols-1),se=this._renderService.dimensions.css.cell.height,re=M.getWidth(te),le=this._renderService.dimensions.css.cell.width*re,ye=this.buffer.y*this._renderService.dimensions.css.cell.height,_e=te*this._renderService.dimensions.css.cell.width;this.textarea.style.left=_e+"px",this.textarea.style.top=ye+"px",this.textarea.style.width=le+"px",this.textarea.style.height=se+"px",this.textarea.style.lineHeight=se+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(M=>{this.hasSelection()&&(0,h.copyHandler)(M,this._selectionService)})));const U=M=>(0,h.handlePasteEvent)(M,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",U)),this.register((0,p.addDisposableDomListener)(this.element,"paste",U)),H.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(M=>{M.button===2&&(0,h.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(M=>{(0,h.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),H.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(M=>{M.button===1&&(0,h.moveTextAreaUnderMouseCursor)(M,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(U=>this._keyUp(U)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(U=>this._keyDown(U)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(U=>this._keyPress(U)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(U=>this._compositionHelper.compositionupdate(U)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(U=>this._inputEvent(U)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(U){var te;if(!U)throw new Error("Terminal requires a parent element.");if(U.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((te=this.element)==null?void 0:te.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=U.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),U.appendChild(this.element);const M=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),M.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,p.addDisposableDomListener)(this.screenElement,"mousemove",(se=>this.updateCursorStyle(se)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),M.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),H.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,U.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(O.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(se=>this._handleTextAreaFocus(se)))),this.register((0,p.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(b.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(O.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(P.ThemeService),this._instantiationService.setService(O.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(k.CharacterJoinerService),this._instantiationService.setService(O.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(D.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(O.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((se=>this._onRender.fire(se)))),this.onResize((se=>this._renderService.resize(se.cols,se.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(S.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(E.MouseService),this._instantiationService.setService(O.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(M);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(A.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(O.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((se=>this._renderService.handleSelectionChanged(se.start,se.end,se.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((se=>{this.textarea.value=se,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((se=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(se=>this._selectionService.handleMouseDown(se)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(B.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(se=>this._handleScreenReaderModeOptionChange(se)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(se=>{!this._overviewRulerRenderer&&se&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(v.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const U=this,M=this.element;function te(le){const ye=U._mouseService.getMouseReportCoords(le,U.screenElement);if(!ye)return!1;let _e,Oe;switch(le.overrideType||le.type){case"mousemove":Oe=32,le.buttons===void 0?(_e=3,le.button!==void 0&&(_e=le.button<3?le.button:3)):_e=1&le.buttons?0:4&le.buttons?1:2&le.buttons?2:3;break;case"mouseup":Oe=0,_e=le.button<3?le.button:3;break;case"mousedown":Oe=1,_e=le.button<3?le.button:3;break;case"wheel":if(U._customWheelEventHandler&&U._customWheelEventHandler(le)===!1||U.viewport.getLinesScrolled(le)===0)return!1;Oe=le.deltaY<0?0:1,_e=4;break;default:return!1}return!(Oe===void 0||_e===void 0||_e>4)&&U.coreMouseService.triggerMouseEvent({col:ye.col,row:ye.row,x:ye.x,y:ye.y,button:_e,action:Oe,ctrl:le.ctrlKey,alt:le.altKey,shift:le.shiftKey})}const se={mouseup:null,wheel:null,mousedrag:null,mousemove:null},re={mouseup:le=>(te(le),le.buttons||(this._document.removeEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.removeEventListener("mousemove",se.mousedrag)),this.cancel(le)),wheel:le=>(te(le),this.cancel(le,!0)),mousedrag:le=>{le.buttons&&te(le)},mousemove:le=>{le.buttons||te(le)}};this.register(this.coreMouseService.onProtocolChange((le=>{le?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(le)),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&le?se.mousemove||(M.addEventListener("mousemove",re.mousemove),se.mousemove=re.mousemove):(M.removeEventListener("mousemove",se.mousemove),se.mousemove=null),16&le?se.wheel||(M.addEventListener("wheel",re.wheel,{passive:!1}),se.wheel=re.wheel):(M.removeEventListener("wheel",se.wheel),se.wheel=null),2&le?se.mouseup||(se.mouseup=re.mouseup):(this._document.removeEventListener("mouseup",se.mouseup),se.mouseup=null),4&le?se.mousedrag||(se.mousedrag=re.mousedrag):(this._document.removeEventListener("mousemove",se.mousedrag),se.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(M,"mousedown",(le=>{if(le.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(le))return te(le),se.mouseup&&this._document.addEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.addEventListener("mousemove",se.mousedrag),this.cancel(le)}))),this.register((0,p.addDisposableDomListener)(M,"wheel",(le=>{if(!se.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(le)===!1)return!1;if(!this.buffer.hasScrollback){const ye=this.viewport.getLinesScrolled(le);if(ye===0)return;const _e=X.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(le.deltaY<0?"A":"B");let Oe="";for(let Be=0;Be<Math.abs(ye);Be++)Oe+=_e;return this.coreService.triggerDataEvent(Oe,!0),this.cancel(le,!0)}return this.viewport.handleWheel(le)?this.cancel(le):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(M,"touchstart",(le=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(le),this.cancel(le)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(M,"touchmove",(le=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(le)?void 0:this.cancel(le)}),{passive:!1}))}refresh(U,M){var te;(te=this._renderService)==null||te.refreshRows(U,M)}updateCursorStyle(U){var M;(M=this._selectionService)!=null&&M.shouldColumnSelect(U)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(U,M,te=0){var se;te===1?(super.scrollLines(U,M,te),this.refresh(0,this.rows-1)):(se=this.viewport)==null||se.scrollLines(U)}paste(U){(0,h.paste)(U,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(U){this._customKeyEventHandler=U}attachCustomWheelEventHandler(U){this._customWheelEventHandler=U}registerLinkProvider(U){return this._linkProviderService.registerLinkProvider(U)}registerCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const M=this._characterJoinerService.register(U);return this.refresh(0,this.rows-1),M}deregisterCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(U)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(U){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+U)}registerDecoration(U){return this._decorationService.registerDecoration(U)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(U,M,te){this._selectionService.setSelection(U,M,te)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var U;(U=this._selectionService)==null||U.clearSelection()}selectAll(){var U;(U=this._selectionService)==null||U.selectAll()}selectLines(U,M){var te;(te=this._selectionService)==null||te.selectLines(U,M)}_keyDown(U){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;const M=this.browser.isMac&&this.options.macOptionIsMeta&&U.altKey;if(!M&&!this._compositionHelper.keydown(U))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;M||U.key!=="Dead"&&U.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const te=(0,Y.evaluateKeyboardEvent)(U,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(U),te.type===3||te.type===2){const se=this.rows-1;return this.scrollLines(te.type===2?-se:se),this.cancel(U,!0)}return te.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,U)||(te.cancel&&this.cancel(U,!0),!te.key||!!(U.key&&!U.ctrlKey&&!U.altKey&&!U.metaKey&&U.key.length===1&&U.key.charCodeAt(0)>=65&&U.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(te.key!==X.C0.ETX&&te.key!==X.C0.CR||(this.textarea.value=""),this._onKey.fire({key:te.key,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(te.key,!0),!this.optionsService.rawOptions.screenReaderMode||U.altKey||U.ctrlKey?this.cancel(U,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(U,M){const te=U.isMac&&!this.options.macOptionIsMeta&&M.altKey&&!M.ctrlKey&&!M.metaKey||U.isWindows&&M.altKey&&M.ctrlKey&&!M.metaKey||U.isWindows&&M.getModifierState("AltGraph");return M.type==="keypress"?te:te&&(!M.keyCode||M.keyCode>47)}_keyUp(U){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1||((function(M){return M.keyCode===16||M.keyCode===17||M.keyCode===18})(U)||this.focus(),this.updateCursorStyle(U),this._keyPressHandled=!1)}_keyPress(U){let M;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;if(this.cancel(U),U.charCode)M=U.charCode;else if(U.which===null||U.which===void 0)M=U.keyCode;else{if(U.which===0||U.charCode===0)return!1;M=U.which}return!(!M||(U.altKey||U.ctrlKey||U.metaKey)&&!this._isThirdLevelShift(this.browser,U)||(M=String.fromCharCode(M),this._onKey.fire({key:M,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(M,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(U){if(U.data&&U.inputType==="insertText"&&(!U.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const M=U.data;return this.coreService.triggerDataEvent(M,!0),this.cancel(U),!0}return!1}resize(U,M){U!==this.cols||M!==this.rows?super.resize(U,M):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(U,M){var te,se;(te=this._charSizeService)==null||te.measure(),(se=this.viewport)==null||se.syncScrollArea(!0)}clear(){var U;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let M=1;M<this.rows;M++)this.buffer.lines.push(this.buffer.getBlankLine(q.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(U=this.viewport)==null||U.reset(),this.refresh(0,this.rows-1)}}reset(){var M,te;this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),(M=this._selectionService)==null||M.reset(),this._decorationService.reset(),(te=this.viewport)==null||te.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){var U;(U=this._renderService)==null||U.clearTextureAtlas()}_reportFocus(){var U;(U=this.element)!=null&&U.classList.contains("focus")?this.coreService.triggerDataEvent(X.C0.ESC+"[I"):this.coreService.triggerDataEvent(X.C0.ESC+"[O")}_reportWindowsOptions(U){if(this._renderService)switch(U){case W.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const M=this._renderService.dimensions.css.canvas.width.toFixed(0),te=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${X.C0.ESC}[4;${te};${M}t`);break;case W.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const se=this._renderService.dimensions.css.cell.width.toFixed(0),re=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${X.C0.ESC}[6;${re};${se}t`)}}cancel(U,M){if(this.options.cancelEvents||M)return U.preventDefault(),U.stopPropagation(),!1}}u.Terminal=Q},9924:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.TimeBasedDebouncer=void 0,u.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 g=m-this._lastRefreshMs,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const 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(c,u,d){var h=this&&this.__decorate||function(S,v,b,k){var N,E=arguments.length,D=E<3?v:k===null?k=Object.getOwnPropertyDescriptor(v,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,v,b,k);else for(var A=S.length-1;A>=0;A--)(N=S[A])&&(D=(E<3?N(D):E>3?N(v,b,D):N(v,b))||D);return E>3&&D&&Object.defineProperty(v,b,D),D},p=this&&this.__param||function(S,v){return function(b,k){v(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Viewport=void 0;const m=d(3656),g=d(4725),x=d(8460),w=d(844),C=d(2585);let _=u.Viewport=class extends w.Disposable{constructor(S,v,b,k,N,E,D,A){super(),this._viewportElement=S,this._scrollArea=v,this._bufferService=b,this._optionsService=k,this._charSizeService=N,this._renderService=E,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 x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((O=>this._activeBuffer=O.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((O=>this._renderDimensions=O))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((O=>this._handleThemeChange(O)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(S){if(S)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const 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 A;let b,k="";const N=[],E=v??this._bufferService.buffer.lines.length,D=this._bufferService.buffer.lines;for(let O=S;O<E;O++){const P=D.get(O);if(!P)continue;const G=(A=D.get(O+1))==null?void 0:A.isWrapped;if(k+=P.translateToString(!G),!G||O===D.length-1){const z=document.createElement("div");z.textContent=k,N.push(z),k.length>0&&(b=z),k=""}}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))}};u.Viewport=_=h([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,g.ICharSizeService),p(5,g.IRenderService),p(6,g.ICoreBrowserService),p(7,g.IThemeService)],_)},3107:function(c,u,d){var h=this&&this.__decorate||function(C,_,S,v){var b,k=arguments.length,N=k<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 E=C.length-1;E>=0;E--)(b=C[E])&&(N=(k<3?b(N):k>3?b(_,S,N):b(_,S))||N);return k>3&&N&&Object.defineProperty(_,S,N),N},p=this&&this.__param||function(C,_){return function(S,v){_(S,v,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferDecorationRenderer=void 0;const m=d(4725),g=d(844),x=d(2585);let w=u.BufferDecorationRenderer=class extends g.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((k=>this._removeDecoration(k)))),this.register((0,g.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var 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()}};u.BufferDecorationRenderer=w=h([p(1,x.IBufferService),p(2,m.ICoreBrowserService),p(3,x.IDecorationService),p(4,m.IRenderService)],w)},5871:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ColorZoneStore=void 0,u.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(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(c,u,d){var h=this&&this.__decorate||function(b,k,N,E){var D,A=arguments.length,O=A<3?k:E===null?E=Object.getOwnPropertyDescriptor(k,N):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(b,k,N,E);else for(var P=b.length-1;P>=0;P--)(D=b[P])&&(O=(A<3?D(O):A>3?D(k,N,O):D(k,N))||O);return A>3&&O&&Object.defineProperty(k,N,O),O},p=this&&this.__param||function(b,k){return function(N,E){k(N,E,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OverviewRulerRenderer=void 0;const m=d(5871),g=d(4725),x=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=u.OverviewRulerRenderer=class extends x.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,k,N,E,D,A,O){var G;super(),this._viewportElement=b,this._screenElement=k,this._bufferService=N,this._decorationService=E,this._renderService=D,this._optionsService=A,this._coreBrowserService=O,this._colorZoneStore=new m.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(G=this._viewportElement.parentElement)==null||G.insertBefore(this._canvas,this._viewportElement);const P=this._canvas.getContext("2d");if(!P)throw new Error("Ctx cannot be null");this._ctx=P,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,x.toDisposable)((()=>{var z;(z=this._canvas)==null||z.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),k=Math.ceil(this._canvas.width/3);_.full=this._canvas.width,_.left=b,_.center=k,_.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,k=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowserService.dpr);C.left=k,C.center=k,C.right=k}_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 k of this._decorationService.decorations)this._colorZoneStore.addDecoration(k);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const k of b)k.position!=="full"&&this._renderColorZone(k);for(const k of b)k.position==="full"&&this._renderColorZone(k);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,k){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=k||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};u.OverviewRulerRenderer=v=h([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,g.IRenderService),p(5,w.IOptionsService),p(6,g.ICoreBrowserService)],v)},2950:function(c,u,d){var h=this&&this.__decorate||function(C,_,S,v){var b,k=arguments.length,N=k<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 E=C.length-1;E>=0;E--)(b=C[E])&&(N=(k<3?b(N):k>3?b(_,S,N):b(_,S))||N);return k>3&&N&&Object.defineProperty(_,S,N),N},p=this&&this.__param||function(C,_){return function(S,v){_(S,v,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CompositionHelper=void 0;const m=d(4725),g=d(2585),x=d(2584);let w=u.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,_,S,v,b,k){this._textarea=C,this._compositionView=_,this._bufferService=S,this._optionsService=v,this._coreService=b,this._renderService=k,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(`${x.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 k=this._compositionView.getBoundingClientRect();this._textarea.style.left=b+"px",this._textarea.style.top=v+"px",this._textarea.style.width=Math.max(k.width,1)+"px",this._textarea.style.height=Math.max(k.height,1)+"px",this._textarea.style.lineHeight=k.height+"px"}C||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};u.CompositionHelper=w=h([p(2,g.IBufferService),p(3,g.IOptionsService),p(4,g.ICoreService),p(5,m.IRenderService)],w)},9806:(c,u)=>{function d(h,p,m){const g=m.getBoundingClientRect(),x=h.getComputedStyle(m),w=parseInt(x.getPropertyValue("padding-left")),C=parseInt(x.getPropertyValue("padding-top"));return[p.clientX-g.left-w,p.clientY-g.top-C]}Object.defineProperty(u,"__esModule",{value:!0}),u.getCoords=u.getCoordsRelativeToElement=void 0,u.getCoordsRelativeToElement=d,u.getCoords=function(h,p,m,g,x,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),g+(S?1:0)),v[1]=Math.min(Math.max(v[1],1),x),v):void 0}},9504:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.moveToCellSequence=void 0;const h=d(2584);function p(_,S,v,b){const k=_-m(_,v),N=S-m(S,v),E=Math.abs(k-N)-(function(D,A,O){let P=0;const G=D-m(D,O),z=A-m(A,O);for(let V=0;V<Math.abs(G-z);V++){const $=g(D,A)==="A"?-1:1,H=O.buffer.lines.get(G+$*V);H!=null&&H.isWrapped&&P++}return P})(_,S,v);return C(E,w(g(_,S),b))}function m(_,S){let v=0,b=S.buffer.lines.get(_),k=b==null?void 0:b.isWrapped;for(;k&&_>=0&&_<S.rows;)v++,b=S.buffer.lines.get(--_),k=b==null?void 0:b.isWrapped;return v}function g(_,S){return _>S?"A":"B"}function x(_,S,v,b,k,N){let E=_,D=S,A="";for(;E!==v||D!==b;)E+=k?1:-1,k&&E>N.cols-1?(A+=N.buffer.translateBufferLineToString(D,!1,_,E),E=0,_=0,D++):!k&&E<0&&(A+=N.buffer.translateBufferLineToString(D,!1,0,_+1),E=N.cols-1,_=E,D--);return A+N.buffer.translateBufferLineToString(D,!1,_,E)}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}u.moveToCellSequence=function(_,S,v,b){const k=v.buffer.x,N=v.buffer.y;if(!v.buffer.hasScrollback)return(function(A,O,P,G,z,V){return p(O,G,z,V).length===0?"":C(x(A,O,A,O-m(O,z),!1,z).length,w("D",V))})(k,N,0,S,v,b)+p(N,S,v,b)+(function(A,O,P,G,z,V){let $;$=p(O,G,z,V).length>0?G-m(G,z):O;const H=G,q=(function(X,Y,F,I,R,W){let B;return B=p(F,I,R,W).length>0?I-m(I,R):Y,X<F&&B<=I||X>=F&&B<I?"C":"D"})(A,O,P,G,z,V);return C(x(A,$,P,H,q==="C",z).length,w(q,V))})(k,N,_,S,v,b);let E;if(N===S)return E=k>_?"D":"C",C(Math.abs(k-_),w(E,b));E=N>S?"D":"C";const D=Math.abs(N-S);return C((function(A,O){return O.cols-A})(N>S?_:k,v)+(D-1)*v.cols+1+((N>S?k:_)-1),w(E,b))}},1296:function(c,u,d){var h=this&&this.__decorate||function(V,$,H,q){var X,Y=arguments.length,F=Y<3?$:q===null?q=Object.getOwnPropertyDescriptor($,H):q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(V,$,H,q);else for(var I=V.length-1;I>=0;I--)(X=V[I])&&(F=(Y<3?X(F):Y>3?X($,H,F):X($,H))||F);return Y>3&&F&&Object.defineProperty($,H,F),F},p=this&&this.__param||function(V,$){return function(H,q){$(H,q,V)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRenderer=void 0;const m=d(3787),g=d(2550),x=d(2223),w=d(6171),C=d(6052),_=d(4725),S=d(8055),v=d(8460),b=d(844),k=d(2585),N="xterm-dom-renderer-owner-",E="xterm-rows",D="xterm-fg-",A="xterm-bg-",O="xterm-focus",P="xterm-selection";let G=1,z=u.DomRenderer=class extends b.Disposable{constructor(V,$,H,q,X,Y,F,I,R,W,B,Z,Q){super(),this._terminal=V,this._document=$,this._element=H,this._screenElement=q,this._viewportElement=X,this._helperContainer=Y,this._linkifier2=F,this._charSizeService=R,this._optionsService=W,this._bufferService=B,this._coreBrowserService=Z,this._themeService=Q,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(E),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(P),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((J=>this._injectCss(J)))),this._injectCss(this._themeService.colors),this._rowFactory=I.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 g.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const V=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*V,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*V),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/V),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/V),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 H of this._rowElements)H.style.width=`${this.dimensions.css.canvas.width}px`,H.style.height=`${this.dimensions.css.cell.height}px`,H.style.lineHeight=`${this.dimensions.css.cell.height}px`,H.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const $=`${this._terminalSelector} .${E} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=$,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(V){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let $=`${this._terminalSelector} .${E} { color: ${V.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;$+=`${this._terminalSelector} .${E} .xterm-dim { color: ${S.color.multiplyOpacity(V.foreground,.5).css};}`,$+=`${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 H=`blink_underline_${this._terminalClass}`,q=`blink_bar_${this._terminalClass}`,X=`blink_block_${this._terminalClass}`;$+=`@keyframes ${H} { 50% { border-bottom-style: hidden; }}`,$+=`@keyframes ${q} { 50% { box-shadow: none; }}`,$+=`@keyframes ${X} { 0% { background-color: ${V.cursor.css}; color: ${V.cursorAccent.css}; } 50% { background-color: inherit; color: ${V.cursor.css}; }}`,$+=`${this._terminalSelector} .${E}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${H} 1s step-end infinite;}${this._terminalSelector} .${E}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${q} 1s step-end infinite;}${this._terminalSelector} .${E}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${X} 1s step-end infinite;}${this._terminalSelector} .${E} .xterm-cursor.xterm-cursor-block { background-color: ${V.cursor.css}; color: ${V.cursorAccent.css};}${this._terminalSelector} .${E} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${V.cursor.css} !important; color: ${V.cursorAccent.css} !important;}${this._terminalSelector} .${E} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${V.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${E} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${V.cursor.css} inset;}${this._terminalSelector} .${E} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${V.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,$+=`${this._terminalSelector} .${P} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${P} div { position: absolute; background-color: ${V.selectionBackgroundOpaque.css};}${this._terminalSelector} .${P} div { position: absolute; background-color: ${V.selectionInactiveBackgroundOpaque.css};}`;for(const[Y,F]of V.ansi.entries())$+=`${this._terminalSelector} .${D}${Y} { color: ${F.css}; }${this._terminalSelector} .${D}${Y}.xterm-dim { color: ${S.color.multiplyOpacity(F,.5).css}; }${this._terminalSelector} .${A}${Y} { background-color: ${F.css}; }`;$+=`${this._terminalSelector} .${D}${x.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(V.background).css}; }${this._terminalSelector} .${D}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(V.background),.5).css}; }${this._terminalSelector} .${A}${x.INVERTED_DEFAULT_COLOR} { background-color: ${V.foreground.css}; }`,this._themeStyleElement.textContent=$}_setDefaultSpacing(){const V=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${V}px`,this._rowFactory.defaultSpacing=V}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(V,$){for(let H=this._rowElements.length;H<=$;H++){const q=this._document.createElement("div");this._rowContainer.appendChild(q),this._rowElements.push(q)}for(;this._rowElements.length>$;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(V,$){this._refreshRowElements(V,$),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(O),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(O),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(V,$,H){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(V,$,H),this.renderRows(0,this._bufferService.rows-1),!V||!$)return;this._selectionRenderModel.update(this._terminal,V,$,H);const q=this._selectionRenderModel.viewportStartRow,X=this._selectionRenderModel.viewportEndRow,Y=this._selectionRenderModel.viewportCappedStartRow,F=this._selectionRenderModel.viewportCappedEndRow;if(Y>=this._bufferService.rows||F<0)return;const I=this._document.createDocumentFragment();if(H){const R=V[0]>$[0];I.appendChild(this._createSelectionElement(Y,R?$[0]:V[0],R?V[0]:$[0],F-Y+1))}else{const R=q===Y?V[0]:0,W=Y===X?$[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(Y,R,W));const B=F-Y-1;if(I.appendChild(this._createSelectionElement(Y+1,0,this._bufferService.cols,B)),Y!==F){const Z=X===F?$[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(F,0,Z))}}this._selectionContainer.appendChild(I)}_createSelectionElement(V,$,H,q=1){const X=this._document.createElement("div"),Y=$*this.dimensions.css.cell.width;let F=this.dimensions.css.cell.width*(H-$);return Y+F>this.dimensions.css.canvas.width&&(F=this.dimensions.css.canvas.width-Y),X.style.height=q*this.dimensions.css.cell.height+"px",X.style.top=V*this.dimensions.css.cell.height+"px",X.style.left=`${Y}px`,X.style.width=`${F}px`,X}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 V of this._rowElements)V.replaceChildren()}renderRows(V,$){const H=this._bufferService.buffer,q=H.ybase+H.y,X=Math.min(H.x,this._bufferService.cols-1),Y=this._optionsService.rawOptions.cursorBlink,F=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let R=V;R<=$;R++){const W=R+H.ydisp,B=this._rowElements[R],Z=H.lines.get(W);if(!B||!Z)break;B.replaceChildren(...this._rowFactory.createRow(Z,W,W===q,F,I,X,Y,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${N}${this._terminalClass}`}_handleLinkHover(V){this._setCellUnderline(V.x1,V.x2,V.y1,V.y2,V.cols,!0)}_handleLinkLeave(V){this._setCellUnderline(V.x1,V.x2,V.y1,V.y2,V.cols,!1)}_setCellUnderline(V,$,H,q,X,Y){H<0&&(V=0),q<0&&($=0);const F=this._bufferService.rows-1;H=Math.max(Math.min(H,F),0),q=Math.max(Math.min(q,F),0),X=Math.min(X,this._bufferService.cols);const I=this._bufferService.buffer,R=I.ybase+I.y,W=Math.min(I.x,X-1),B=this._optionsService.rawOptions.cursorBlink,Z=this._optionsService.rawOptions.cursorStyle,Q=this._optionsService.rawOptions.cursorInactiveStyle;for(let J=H;J<=q;++J){const U=J+I.ydisp,M=this._rowElements[J],te=I.lines.get(U);if(!M||!te)break;M.replaceChildren(...this._rowFactory.createRow(te,U,U===R,Z,Q,W,B,this.dimensions.css.cell.width,this._widthCache,Y?J===H?V:0:-1,Y?(J===q?$:X)-1:-1))}}};u.DomRenderer=z=h([p(7,k.IInstantiationService),p(8,_.ICharSizeService),p(9,k.IOptionsService),p(10,k.IBufferService),p(11,_.ICoreBrowserService),p(12,_.IThemeService)],z)},3787:function(c,u,d){var h=this&&this.__decorate||function(E,D,A,O){var P,G=arguments.length,z=G<3?D:O===null?O=Object.getOwnPropertyDescriptor(D,A):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(E,D,A,O);else for(var V=E.length-1;V>=0;V--)(P=E[V])&&(z=(G<3?P(z):G>3?P(D,A,z):P(D,A))||z);return G>3&&z&&Object.defineProperty(D,A,z),z},p=this&&this.__param||function(E,D){return function(A,O){D(A,O,E)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRendererRowFactory=void 0;const m=d(2223),g=d(643),x=d(511),w=d(2585),C=d(8055),_=d(4725),S=d(4269),v=d(6171),b=d(3734);let k=u.DomRendererRowFactory=class{constructor(E,D,A,O,P,G,z){this._document=E,this._characterJoinerService=D,this._optionsService=A,this._coreBrowserService=O,this._coreService=P,this._decorationService=G,this._themeService=z,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(E,D,A){this._selectionStart=E,this._selectionEnd=D,this._columnSelectMode=A}createRow(E,D,A,O,P,G,z,V,$,H,q){const X=[],Y=this._characterJoinerService.getJoinedCharacters(D),F=this._themeService.colors;let I,R=E.getNoBgTrimmedLength();A&&R<G+1&&(R=G+1);let W=0,B="",Z=0,Q=0,J=0,U=!1,M=0,te=!1,se=0;const re=[],le=H!==-1&&q!==-1;for(let ye=0;ye<R;ye++){E.loadCell(ye,this._workCell);let _e=this._workCell.getWidth();if(_e===0)continue;let Oe=!1,Be=ye,ke=this._workCell;if(Y.length>0&&ye===Y[0][0]){Oe=!0;const Ue=Y.shift();ke=new S.JoinedCellData(this._workCell,E.translateToString(!0,Ue[0],Ue[1]),Ue[1]-Ue[0]),Be=Ue[1]-1,_e=ke.getWidth()}const Ge=this._isCellInSelection(ye,D),Je=A&&ye===G,ae=le&&ye>=H&&ye<=q;let ue=!1;this._decorationService.forEachDecorationAtCell(ye,D,void 0,(Ue=>{ue=!0}));let Me=ke.getChars()||g.WHITESPACE_CELL_CHAR;if(Me===" "&&(ke.isUnderline()||ke.isOverline())&&(Me=" "),se=_e*V-$.get(Me,ke.isBold(),ke.isItalic()),I){if(W&&(Ge&&te||!Ge&&!te&&ke.bg===Z)&&(Ge&&te&&F.selectionForeground||ke.fg===Q)&&ke.extended.ext===J&&ae===U&&se===M&&!Je&&!Oe&&!ue){ke.isInvisible()?B+=g.WHITESPACE_CELL_CHAR:B+=Me,W++;continue}W&&(I.textContent=B),I=this._document.createElement("span"),W=0,B=""}else I=this._document.createElement("span");if(Z=ke.bg,Q=ke.fg,J=ke.extended.ext,U=ae,M=se,te=Ge,Oe&&G>=ye&&G<=Be&&(G=ye),!this._coreService.isCursorHidden&&Je&&this._coreService.isCursorInitialized){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)z&&re.push("xterm-cursor-blink"),re.push(O==="bar"?"xterm-cursor-bar":O==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(P)switch(P){case"outline":re.push("xterm-cursor-outline");break;case"block":re.push("xterm-cursor-block");break;case"bar":re.push("xterm-cursor-bar");break;case"underline":re.push("xterm-cursor-underline")}}if(ke.isBold()&&re.push("xterm-bold"),ke.isItalic()&&re.push("xterm-italic"),ke.isDim()&&re.push("xterm-dim"),B=ke.isInvisible()?g.WHITESPACE_CELL_CHAR:ke.getChars()||g.WHITESPACE_CELL_CHAR,ke.isUnderline()&&(re.push(`xterm-underline-${ke.extended.underlineStyle}`),B===" "&&(B=" "),!ke.isUnderlineColorDefault()))if(ke.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${b.AttributeData.toColorRGB(ke.getUnderlineColor()).join(",")})`;else{let Ue=ke.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ke.isBold()&&Ue<8&&(Ue+=8),I.style.textDecorationColor=F.ansi[Ue].css}ke.isOverline()&&(re.push("xterm-overline"),B===" "&&(B=" ")),ke.isStrikethrough()&&re.push("xterm-strikethrough"),ae&&(I.style.textDecoration="underline");let fe=ke.getFgColor(),Fe=ke.getFgColorMode(),He=ke.getBgColor(),ie=ke.getBgColorMode();const Se=!!ke.isInverse();if(Se){const Ue=fe;fe=He,He=Ue;const Qe=Fe;Fe=ie,ie=Qe}let Le,he,me,We=!1;switch(this._decorationService.forEachDecorationAtCell(ye,D,void 0,(Ue=>{Ue.options.layer!=="top"&&We||(Ue.backgroundColorRGB&&(ie=50331648,He=Ue.backgroundColorRGB.rgba>>8&16777215,Le=Ue.backgroundColorRGB),Ue.foregroundColorRGB&&(Fe=50331648,fe=Ue.foregroundColorRGB.rgba>>8&16777215,he=Ue.foregroundColorRGB),We=Ue.options.layer==="top")})),!We&&Ge&&(Le=this._coreBrowserService.isFocused?F.selectionBackgroundOpaque:F.selectionInactiveBackgroundOpaque,He=Le.rgba>>8&16777215,ie=50331648,We=!0,F.selectionForeground&&(Fe=50331648,fe=F.selectionForeground.rgba>>8&16777215,he=F.selectionForeground)),We&&re.push("xterm-decoration-top"),ie){case 16777216:case 33554432:me=F.ansi[He],re.push(`xterm-bg-${He}`);break;case 50331648:me=C.channels.toColor(He>>16,He>>8&255,255&He),this._addStyle(I,`background-color:#${N((He>>>0).toString(16),"0",6)}`);break;default:Se?(me=F.foreground,re.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):me=F.background}switch(Le||ke.isDim()&&(Le=C.color.multiplyOpacity(me,.5)),Fe){case 16777216:case 33554432:ke.isBold()&&fe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(fe+=8),this._applyMinimumContrast(I,me,F.ansi[fe],ke,Le,void 0)||re.push(`xterm-fg-${fe}`);break;case 50331648:const Ue=C.channels.toColor(fe>>16&255,fe>>8&255,255&fe);this._applyMinimumContrast(I,me,Ue,ke,Le,he)||this._addStyle(I,`color:#${N(fe.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,me,F.foreground,ke,Le,he)||Se&&re.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}re.length&&(I.className=re.join(" "),re.length=0),Je||Oe||ue?I.textContent=B:W++,se!==this.defaultSpacing&&(I.style.letterSpacing=`${se}px`),X.push(I),ye=Be}return I&&W&&(I.textContent=B),X}_applyMinimumContrast(E,D,A,O,P,G){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,v.treatGlyphAsBackgroundColor)(O.getCode()))return!1;const z=this._getContrastCache(O);let V;if(P||G||(V=z.getColor(D.rgba,A.rgba)),V===void 0){const $=this._optionsService.rawOptions.minimumContrastRatio/(O.isDim()?2:1);V=C.color.ensureContrastRatio(P||D,G||A,$),z.setColor((P||D).rgba,(G||A).rgba,V??null)}return!!V&&(this._addStyle(E,`color:${V.css}`),!0)}_getContrastCache(E){return E.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(E,D){E.setAttribute("style",`${E.getAttribute("style")||""}${D};`)}_isCellInSelection(E,D){const A=this._selectionStart,O=this._selectionEnd;return!(!A||!O)&&(this._columnSelectMode?A[0]<=O[0]?E>=A[0]&&D>=A[1]&&E<O[0]&&D<=O[1]:E<A[0]&&D>=A[1]&&E>=O[0]&&D<=O[1]:D>A[1]&&D<O[1]||A[1]===O[1]&&D===A[1]&&E>=A[0]&&E<O[0]||A[1]<O[1]&&D===O[1]&&E<O[0]||A[1]<O[1]&&D===A[1]&&E>=A[0])}};function N(E,D,A){for(;E.length<A;)E=D+E;return E}u.DomRendererRowFactory=k=h([p(1,_.ICharacterJoinerService),p(2,w.IOptionsService),p(3,_.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(6,_.IThemeService)],k)},2550:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WidthCache=void 0,u.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 g=d.createElement("span");g.classList.add("xterm-char-measure-element"),g.style.fontStyle="italic";const x=d.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontWeight="bold",x.style.fontStyle="italic",this._measureElements=[p,m,g,x],this._container.appendChild(p),this._container.appendChild(m),this._container.appendChild(g),this._container.appendChild(x),h.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(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 g=d;h&&(g+="B"),p&&(g+="I");let x=this._holey.get(g);if(x===void 0){let w=0;h&&(w|=1),p&&(w|=2),x=this._measure(d,w),x>0&&this._holey.set(g,x)}return x}_measure(d,h){const p=this._measureElements[h];return p.textContent=d.repeat(32),p.offsetWidth/32}}},2223:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.TEXT_BASELINE=u.DIM_OPACITY=u.INVERTED_DEFAULT_COLOR=void 0;const h=d(6114);u.INVERTED_DEFAULT_COLOR=257,u.DIM_OPACITY=.5,u.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(c,u)=>{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(u,"__esModule",{value:!0}),u.computeNextVariantOffset=u.createRenderDimensions=u.treatGlyphAsBackgroundColor=u.allowRescaling=u.isEmoji=u.isRestrictedPowerlineGlyph=u.isPowerlineGlyph=u.throwIfFalsy=void 0,u.throwIfFalsy=function(p){if(!p)throw new Error("value must not be falsy");return p},u.isPowerlineGlyph=d,u.isRestrictedPowerlineGlyph=function(p){return 57520<=p&&p<=57527},u.isEmoji=h,u.allowRescaling=function(p,m,g,x){return m===1&&g>Math.ceil(1.5*x)&&p!==void 0&&p>255&&!h(p)&&!d(p)&&!(function(w){return 57344<=w&&w<=63743})(p)},u.treatGlyphAsBackgroundColor=function(p){return d(p)||(function(m){return 9472<=m&&m<=9631})(p)},u.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},u.computeNextVariantOffset=function(p,m,g=0){return(p-(2*Math.round(m)-g))%(2*Math.round(m))}},6052:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.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,g,x=!1){if(this.selectionStart=m,this.selectionEnd=g,!m||!g||m[0]===g[0]&&m[1]===g[1])return void this.clear();const w=p.buffers.active.ydisp,C=m[1]-w,_=g[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=x,this.viewportStartRow=C,this.viewportEndRow=_,this.viewportCappedStartRow=S,this.viewportCappedEndRow=v,this.startCol=m[0],this.endCol=g[0])}isCellSelected(p,m,g){return!!this.hasSelection&&(g-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&g>=this.viewportCappedStartRow&&m<this.endCol&&g<=this.viewportCappedEndRow:m<this.startCol&&g>=this.viewportCappedStartRow&&m>=this.endCol&&g<=this.viewportCappedEndRow:g>this.viewportStartRow&&g<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&g===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportStartRow&&m>=this.startCol)}}u.createSelectionRenderModel=function(){return new d}},456:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionModel=void 0,u.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(c,u,d){var h=this&&this.__decorate||function(v,b,k,N){var E,D=arguments.length,A=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,k):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,k,N);else for(var O=v.length-1;O>=0;O--)(E=v[O])&&(A=(D<3?E(A):D>3?E(b,k,A):E(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(v,b){return function(k,N){b(k,N,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharSizeService=void 0;const m=d(2585),g=d(8460),x=d(844);let w=u.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(v,b,k){super(),this._optionsService=k,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(this._optionsService))}catch{this._measureStrategy=this.register(new _(v,b,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const v=this._measureStrategy.measure();v.width===this.width&&v.height===this.height||(this.width=v.width,this.height=v.height,this._onCharSizeChange.fire())}};u.CharSizeService=w=h([p(2,m.IOptionsService)],w);class C extends x.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(b,k){b!==void 0&&b>0&&k!==void 0&&k>0&&(this._result.width=b,this._result.height=k)}}class _ extends C{constructor(b,k,N){super(),this._document=b,this._parentElement=k,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 k=this._ctx.measureText("W");if(!("width"in k&&"fontBoundingBoxAscent"in k&&"fontBoundingBoxDescent"in k))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(c,u,d){var h=this&&this.__decorate||function(S,v,b,k){var N,E=arguments.length,D=E<3?v:k===null?k=Object.getOwnPropertyDescriptor(v,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,v,b,k);else for(var A=S.length-1;A>=0;A--)(N=S[A])&&(D=(E<3?N(D):E>3?N(v,b,D):N(v,b))||D);return E>3&&D&&Object.defineProperty(v,b,D),D},p=this&&this.__param||function(S,v){return function(b,k){v(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharacterJoinerService=u.JoinedCellData=void 0;const m=d(3734),g=d(643),x=d(511),w=d(2585);class C extends m.AttributeData{constructor(v,b,k){super(),this.content=0,this.combinedData="",this.fg=v.fg,this.bg=v.bg,this.combinedData=b,this._width=k}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()]}}u.JoinedCellData=C;let _=u.CharacterJoinerService=class HN{constructor(v){this._bufferService=v,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.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 k=[],N=b.translateToString(!0);let E=0,D=0,A=0,O=b.getFg(0),P=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!==O||this._workCell.bg!==P){if(G-E>1){const z=this._getJoinedRanges(N,A,D,b,E);for(let V=0;V<z.length;V++)k.push(z[V])}E=G,A=D,O=this._workCell.fg,P=this._workCell.bg}D+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-E>1){const G=this._getJoinedRanges(N,A,D,b,E);for(let z=0;z<G.length;z++)k.push(G[z])}return k}_getJoinedRanges(v,b,k,N,E){const D=v.substring(b,k);let A=[];try{A=this._characterJoiners[0].handler(D)}catch(O){console.error(O)}for(let O=1;O<this._characterJoiners.length;O++)try{const P=this._characterJoiners[O].handler(D);for(let G=0;G<P.length;G++)HN._mergeRanges(A,P[G])}catch(P){console.error(P)}return this._stringRangesToCellRanges(A,N,E),A}_stringRangesToCellRanges(v,b,k){let N=0,E=!1,D=0,A=v[N];if(A){for(let O=k;O<this._bufferService.cols;O++){const P=b.getWidth(O),G=b.getString(O).length||g.WHITESPACE_CELL_CHAR.length;if(P!==0){if(!E&&A[0]<=D&&(A[0]=O,E=!0),A[1]<=D){if(A[1]=O,A=v[++N],!A)break;A[0]<=D?(A[0]=O,E=!0):E=!1}D+=G}}A&&(A[1]=this._bufferService.cols)}}static _mergeRanges(v,b){let k=!1;for(let N=0;N<v.length;N++){const E=v[N];if(k){if(b[1]<=E[0])return v[N-1][1]=b[1],v;if(b[1]<=E[1])return v[N-1][1]=Math.max(b[1],E[1]),v.splice(N,1),v;v.splice(N,1),N--}else{if(b[1]<=E[0])return v.splice(N,0,b),v;if(b[1]<=E[1])return E[0]=Math.min(b[0],E[0]),v;b[0]<E[1]&&(E[0]=Math.min(b[0],E[0]),k=!0)}}return k?v[v.length-1][1]=b[1]:v.push(b),v}};u.CharacterJoinerService=_=h([p(0,w.IBufferService)],_)},5114:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreBrowserService=void 0;const h=d(844),p=d(8460),m=d(3656);class g 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 x(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}}u.CoreBrowserService=g;class x extends h.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new 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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.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(g){return this.linkProviders.push(g),{dispose:()=>{const x=this.linkProviders.indexOf(g);x!==-1&&this.linkProviders.splice(x,1)}}}}u.LinkProviderService=p},8934:function(c,u,d){var h=this&&this.__decorate||function(w,C,_,S){var v,b=arguments.length,k=b<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(w,C,_,S);else for(var N=w.length-1;N>=0;N--)(v=w[N])&&(k=(b<3?v(k):b>3?v(C,_,k):v(C,_))||k);return b>3&&k&&Object.defineProperty(C,_,k),k},p=this&&this.__param||function(w,C){return function(_,S){C(_,S,w)}};Object.defineProperty(u,"__esModule",{value:!0}),u.MouseService=void 0;const m=d(4725),g=d(9806);let x=u.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,_,S,v){return(0,g.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,g.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])}}};u.MouseService=x=h([p(0,m.IRenderService),p(1,m.ICharSizeService)],x)},3230:function(c,u,d){var h=this&&this.__decorate||function(v,b,k,N){var E,D=arguments.length,A=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,k):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,k,N);else for(var O=v.length-1;O>=0;O--)(E=v[O])&&(A=(D<3?E(A):D>3?E(b,k,A):E(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(v,b){return function(k,N){b(k,N,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.RenderService=void 0;const m=d(6193),g=d(4725),x=d(8460),w=d(844),C=d(7226),_=d(2585);let S=u.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(v,b,k,N,E,D,A,O){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 x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(((P,G)=>this._renderRows(P,G)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(D.onResize((()=>this._fullRefresh()))),this.register(D.buffers.onBufferActivate((()=>{var P;return(P=this._renderer.value)==null?void 0:P.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(E.onDecorationRegistered((()=>this._fullRefresh()))),this.register(E.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(D.cols,D.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(D.buffer.y,D.buffer.y,!0)))),this.register(O.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,b),this.register(A.onWindowChange((P=>this._registerIntersectionObserver(P,b))))}_registerIntersectionObserver(v,b){if("IntersectionObserver"in v){const k=new v.IntersectionObserver((N=>this._handleIntersectionChange(N[N.length-1])),{threshold:0});k.observe(b),this._observerDisposable.value=(0,w.toDisposable)((()=>k.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,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(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 k;return(k=this._renderer.value)==null?void 0:k.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,k){var N;this._selectionState.start=v,this._selectionState.end=b,this._selectionState.columnSelectMode=k,(N=this._renderer.value)==null||N.handleSelectionChanged(v,b,k)}handleCursorMove(){var v;(v=this._renderer.value)==null||v.handleCursorMove()}clear(){var v;(v=this._renderer.value)==null||v.clear()}};u.RenderService=S=h([p(2,_.IOptionsService),p(3,g.ICharSizeService),p(4,_.IDecorationService),p(5,_.IBufferService),p(6,g.ICoreBrowserService),p(7,g.IThemeService)],S)},9312:function(c,u,d){var h=this&&this.__decorate||function(A,O,P,G){var z,V=arguments.length,$=V<3?O:G===null?G=Object.getOwnPropertyDescriptor(O,P):G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")$=Reflect.decorate(A,O,P,G);else for(var H=A.length-1;H>=0;H--)(z=A[H])&&($=(V<3?z($):V>3?z(O,P,$):z(O,P))||$);return V>3&&$&&Object.defineProperty(O,P,$),$},p=this&&this.__param||function(A,O){return function(P,G){O(P,G,A)}};Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionService=void 0;const m=d(9806),g=d(9504),x=d(456),w=d(4725),C=d(8460),_=d(844),S=d(6114),v=d(4841),b=d(511),k=d(2585),N=" ",E=new RegExp(N,"g");let D=u.SelectionService=class extends _.Disposable{constructor(A,O,P,G,z,V,$,H,q){super(),this._element=A,this._screenElement=O,this._linkifier=P,this._bufferService=G,this._coreService=z,this._mouseService=V,this._optionsService=$,this._renderService=H,this._coreBrowserService=q,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=X=>this._handleMouseMove(X),this._mouseUpListener=X=>this._handleMouseUp(X),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((X=>this._handleTrim(X))),this.register(this._bufferService.buffers.onBufferActivate((X=>this._handleBufferActivate(X)))),this.enable(),this._model=new x.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 A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;return!(!A||!O||A[0]===O[0]&&A[1]===O[1])}get selectionText(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;if(!A||!O)return"";const P=this._bufferService.buffer,G=[];if(this._activeSelectionMode===3){if(A[0]===O[0])return"";const z=A[0]<O[0]?A[0]:O[0],V=A[0]<O[0]?O[0]:A[0];for(let $=A[1];$<=O[1];$++){const H=P.translateBufferLineToString($,!0,z,V);G.push(H)}}else{const z=A[1]===O[1]?O[0]:void 0;G.push(P.translateBufferLineToString(A[1],!0,A[0],z));for(let V=A[1]+1;V<=O[1]-1;V++){const $=P.lines.get(V),H=P.translateBufferLineToString(V,!0);$!=null&&$.isWrapped?G[G.length-1]+=H:G.push(H)}if(A[1]!==O[1]){const V=P.lines.get(O[1]),$=P.translateBufferLineToString(O[1],!0,0,O[0]);V&&V.isWrapped?G[G.length-1]+=$:G.push($)}}return G.map((z=>z.replace(E," "))).join(S.isWindows?`\r
258
+ `:`
259
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(A){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),S.isLinux&&A&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(A){const O=this._getMouseBufferCoords(A),P=this._model.finalSelectionStart,G=this._model.finalSelectionEnd;return!!(P&&G&&O)&&this._areCoordsInSelection(O,P,G)}isCellInSelection(A,O){const P=this._model.finalSelectionStart,G=this._model.finalSelectionEnd;return!(!P||!G)&&this._areCoordsInSelection([A,O],P,G)}_areCoordsInSelection(A,O,P){return A[1]>O[1]&&A[1]<P[1]||O[1]===P[1]&&A[1]===O[1]&&A[0]>=O[0]&&A[0]<P[0]||O[1]<P[1]&&A[1]===P[1]&&A[0]<P[0]||O[1]<P[1]&&A[1]===O[1]&&A[0]>=O[0]}_selectWordAtCursor(A,O){var z,V;const P=(V=(z=this._linkifier.currentLink)==null?void 0:z.link)==null?void 0:V.range;if(P)return this._model.selectionStart=[P.start.x-1,P.start.y-1],this._model.selectionStartLength=(0,v.getRangeLength)(P,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const G=this._getMouseBufferCoords(A);return!!G&&(this._selectWordAt(G,O),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,O){this._model.clearSelection(),A=Math.max(A,0),O=Math.min(O,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,O],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const O=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(O)return O[0]--,O[1]--,O[1]+=this._bufferService.buffer.ydisp,O}_getMouseEventScrollAmount(A){let O=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const P=this._renderService.dimensions.css.canvas.height;return O>=0&&O<=P?0:(O>P&&(O-=P),O=Math.min(Math.max(O,-50),50),O/=50,O/Math.abs(O)+Math.round(14*O))}shouldForceSelection(A){return S.isMac?A.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:A.shiftKey}handleMouseDown(A){if(this._mouseDownTimeStamp=A.timeStamp,(A.button!==2||!this.hasSelection)&&A.button===0){if(!this._enabled){if(!this.shouldForceSelection(A))return;A.stopPropagation()}A.preventDefault(),this._dragScrollAmount=0,this._enabled&&A.shiftKey?this._handleIncrementalClick(A):A.detail===1?this._handleSingleClick(A):A.detail===2?this._handleDoubleClick(A):A.detail===3&&this._handleTripleClick(A),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(A){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(A))}_handleSingleClick(A){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(A)?3:0,this._model.selectionStart=this._getMouseBufferCoords(A),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const O=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);O&&O.length!==this._model.selectionStart[0]&&O.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const O=this._getMouseBufferCoords(A);O&&(this._activeSelectionMode=2,this._selectLineAt(O[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const O=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(A),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(A),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const P=this._bufferService.buffer;if(this._model.selectionEnd[1]<P.lines.length){const G=P.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]++}O&&O[0]===this._model.selectionEnd[0]&&O[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const A=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(A.ydisp+this._bufferService.rows,A.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=A.ydisp),this.refresh()}}_handleMouseUp(A){const O=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&O<500&&A.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const P=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(P&&P[0]!==void 0&&P[1]!==void 0){const G=(0,g.moveToCellSequence)(P[0]-1,P[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(G,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd,P=!(!A||!O||A[0]===O[0]&&A[1]===O[1]);P?A&&O&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&O[0]===this._oldSelectionEnd[0]&&O[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,O,P)):this._oldHasSelection&&this._fireOnSelectionChange(A,O,P)}_fireOnSelectionChange(A,O,P){this._oldSelectionStart=A,this._oldSelectionEnd=O,this._oldHasSelection=P,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((O=>this._handleTrim(O)))}_convertViewportColToCharacterIndex(A,O){let P=O;for(let G=0;O>=G;G++){const z=A.loadCell(G,this._workCell).getChars().length;this._workCell.getWidth()===0?P--:z>1&&O!==G&&(P+=z-1)}return P}setSelection(A,O,P){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,O],this._model.selectionStartLength=P,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,O,P=!0,G=!0){if(A[0]>=this._bufferService.cols)return;const z=this._bufferService.buffer,V=z.lines.get(A[1]);if(!V)return;const $=z.translateBufferLineToString(A[1],!1);let H=this._convertViewportColToCharacterIndex(V,A[0]),q=H;const X=A[0]-H;let Y=0,F=0,I=0,R=0;if($.charAt(H)===" "){for(;H>0&&$.charAt(H-1)===" ";)H--;for(;q<$.length&&$.charAt(q+1)===" ";)q++}else{let Z=A[0],Q=A[0];V.getWidth(Z)===0&&(Y++,Z--),V.getWidth(Q)===2&&(F++,Q++);const J=V.getString(Q).length;for(J>1&&(R+=J-1,q+=J-1);Z>0&&H>0&&!this._isCharWordSeparator(V.loadCell(Z-1,this._workCell));){V.loadCell(Z-1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===0?(Y++,Z--):U>1&&(I+=U-1,H-=U-1),H--,Z--}for(;Q<V.length&&q+1<$.length&&!this._isCharWordSeparator(V.loadCell(Q+1,this._workCell));){V.loadCell(Q+1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===2?(F++,Q++):U>1&&(R+=U-1,q+=U-1),q++,Q++}}q++;let W=H+X-Y+I,B=Math.min(this._bufferService.cols,q-H+Y+F-I-R);if(O||$.slice(H,q).trim()!==""){if(P&&W===0&&V.getCodePoint(0)!==32){const Z=z.lines.get(A[1]-1);if(Z&&V.isWrapped&&Z.getCodePoint(this._bufferService.cols-1)!==32){const Q=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(Q){const J=this._bufferService.cols-Q.start;W-=J,B+=J}}}if(G&&W+B===this._bufferService.cols&&V.getCodePoint(this._bufferService.cols-1)!==32){const Z=z.lines.get(A[1]+1);if(Z!=null&&Z.isWrapped&&Z.getCodePoint(0)!==32){const Q=this._getWordAt([0,A[1]+1],!1,!1,!0);Q&&(B+=Q.length)}}return{start:W,length:B}}}_selectWordAt(A,O){const P=this._getWordAt(A,O);if(P){for(;P.start<0;)P.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[P.start,A[1]],this._model.selectionStartLength=P.length}}_selectToWordAt(A){const O=this._getWordAt(A,!0);if(O){let P=A[1];for(;O.start<0;)O.start+=this._bufferService.cols,P--;if(!this._model.areSelectionValuesReversed())for(;O.start+O.length>this._bufferService.cols;)O.length-=this._bufferService.cols,P++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?O.start:O.start+O.length,P]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const O=this._bufferService.buffer.getWrappedRangeForLine(A),P={start:{x:0,y:O.first},end:{x:this._bufferService.cols-1,y:O.last}};this._model.selectionStart=[0,O.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,v.getRangeLength)(P,this._bufferService.cols)}};u.SelectionService=D=h([p(3,k.IBufferService),p(4,k.ICoreService),p(5,w.IMouseService),p(6,k.IOptionsService),p(7,w.IRenderService),p(8,w.ICoreBrowserService)],D)},4725:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ILinkProviderService=u.IThemeService=u.ICharacterJoinerService=u.ISelectionService=u.IRenderService=u.IMouseService=u.ICoreBrowserService=u.ICharSizeService=void 0;const h=d(8343);u.ICharSizeService=(0,h.createDecorator)("CharSizeService"),u.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),u.IMouseService=(0,h.createDecorator)("MouseService"),u.IRenderService=(0,h.createDecorator)("RenderService"),u.ISelectionService=(0,h.createDecorator)("SelectionService"),u.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),u.IThemeService=(0,h.createDecorator)("ThemeService"),u.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(c,u,d){var h=this&&this.__decorate||function(D,A,O,P){var G,z=arguments.length,V=z<3?A:P===null?P=Object.getOwnPropertyDescriptor(A,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate(D,A,O,P);else for(var $=D.length-1;$>=0;$--)(G=D[$])&&(V=(z<3?G(V):z>3?G(A,O,V):G(A,O))||V);return z>3&&V&&Object.defineProperty(A,O,V),V},p=this&&this.__param||function(D,A){return function(O,P){A(O,P,D)}};Object.defineProperty(u,"__esModule",{value:!0}),u.ThemeService=u.DEFAULT_ANSI_COLORS=void 0;const m=d(7239),g=d(8055),x=d(8460),w=d(844),C=d(2585),_=g.css.toColor("#ffffff"),S=g.css.toColor("#000000"),v=g.css.toColor("#ffffff"),b=g.css.toColor("#000000"),k={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};u.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const D=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],A=[0,95,135,175,215,255];for(let O=0;O<216;O++){const P=A[O/36%6|0],G=A[O/6%6|0],z=A[O%6];D.push({css:g.channels.toCss(P,G,z),rgba:g.channels.toRgba(P,G,z)})}for(let O=0;O<24;O++){const P=8+10*O;D.push({css:g.channels.toCss(P,P,P),rgba:g.channels.toRgba(P,P,P)})}return D})());let N=u.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 x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_,background:S,cursor:v,cursorAccent:b,selectionForeground:void 0,selectionBackgroundTransparent:k,selectionBackgroundOpaque:g.color.blend(S,k),selectionInactiveBackgroundTransparent:k,selectionInactiveBackgroundOpaque:g.color.blend(S,k),ansi:u.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(D={}){const A=this._colors;if(A.foreground=E(D.foreground,_),A.background=E(D.background,S),A.cursor=E(D.cursor,v),A.cursorAccent=E(D.cursorAccent,b),A.selectionBackgroundTransparent=E(D.selectionBackground,k),A.selectionBackgroundOpaque=g.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=E(D.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=g.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=D.selectionForeground?E(D.selectionForeground,g.NULL_COLOR):void 0,A.selectionForeground===g.NULL_COLOR&&(A.selectionForeground=void 0),g.color.isOpaque(A.selectionBackgroundTransparent)&&(A.selectionBackgroundTransparent=g.color.opacity(A.selectionBackgroundTransparent,.3)),g.color.isOpaque(A.selectionInactiveBackgroundTransparent)&&(A.selectionInactiveBackgroundTransparent=g.color.opacity(A.selectionInactiveBackgroundTransparent,.3)),A.ansi=u.DEFAULT_ANSI_COLORS.slice(),A.ansi[0]=E(D.black,u.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=E(D.red,u.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=E(D.green,u.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=E(D.yellow,u.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=E(D.blue,u.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=E(D.magenta,u.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=E(D.cyan,u.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=E(D.white,u.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=E(D.brightBlack,u.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=E(D.brightRed,u.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=E(D.brightGreen,u.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=E(D.brightYellow,u.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=E(D.brightBlue,u.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=E(D.brightMagenta,u.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=E(D.brightCyan,u.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=E(D.brightWhite,u.DEFAULT_ANSI_COLORS[15]),D.extendedAnsi){const O=Math.min(A.ansi.length-16,D.extendedAnsi.length);for(let P=0;P<O;P++)A.ansi[P+16]=E(D.extendedAnsi[P],u.DEFAULT_ANSI_COLORS[P+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(D){this._restoreColor(D),this._onChangeColors.fire(this.colors)}_restoreColor(D){if(D!==void 0)switch(D){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[D]=this._restoreColors.ansi[D]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}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 E(D,A){if(D!==void 0)try{return g.css.toColor(D)}catch{}return A}u.ThemeService=N=h([p(0,C.IOptionsService)],N)},6349:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CircularList=void 0;const h=d(8460),p=d(844);class m extends p.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(x){if(this._maxLength===x)return;const w=new Array(x);for(let C=0;C<Math.min(x,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,w,...C){if(w){for(let _=x;_<this._length-w;_++)this._array[this._getCyclicIndex(_)]=this._array[this._getCyclicIndex(_+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let _=this._length-1;_>=x;_--)this._array[this._getCyclicIndex(_+C.length)]=this._array[this._getCyclicIndex(_)];for(let _=0;_<C.length;_++)this._array[this._getCyclicIndex(x+_)]=C[_];if(C.length&&this.onInsertEmitter.fire({index:x,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(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,C){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(x+S+C,this.get(x+S));const _=x+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(x+_+C,this.get(x+_))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}u.CircularList=m},1439:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.clone=void 0,u.clone=function d(h,p=5){if(typeof h!="object")return h;const m=Array.isArray(h)?[]:{};for(const g in h)m[g]=p<=1?h[g]:h[g]&&d(h[g],p-1);return m}},8055:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.contrastRatio=u.toPaddedHex=u.rgba=u.rgb=u.css=u.color=u.channels=u.NULL_COLOR=void 0;let d=0,h=0,p=0,m=0;var g,x,w,C,_;function S(b){const k=b.toString(16);return k.length<2?"0"+k:k}function v(b,k){return b<k?(k+.05)/(b+.05):(b+.05)/(k+.05)}u.NULL_COLOR={css:"#00000000",rgba:0},(function(b){b.toCss=function(k,N,E,D){return D!==void 0?`#${S(k)}${S(N)}${S(E)}${S(D)}`:`#${S(k)}${S(N)}${S(E)}`},b.toRgba=function(k,N,E,D=255){return(k<<24|N<<16|E<<8|D)>>>0},b.toColor=function(k,N,E,D){return{css:b.toCss(k,N,E,D),rgba:b.toRgba(k,N,E,D)}}})(g||(u.channels=g={})),(function(b){function k(N,E){return m=Math.round(255*E),[d,h,p]=_.toChannels(N.rgba),{css:g.toCss(d,h,p,m),rgba:g.toRgba(d,h,p,m)}}b.blend=function(N,E){if(m=(255&E.rgba)/255,m===1)return{css:E.css,rgba:E.rgba};const D=E.rgba>>24&255,A=E.rgba>>16&255,O=E.rgba>>8&255,P=N.rgba>>24&255,G=N.rgba>>16&255,z=N.rgba>>8&255;return d=P+Math.round((D-P)*m),h=G+Math.round((A-G)*m),p=z+Math.round((O-z)*m),{css:g.toCss(d,h,p),rgba:g.toRgba(d,h,p)}},b.isOpaque=function(N){return(255&N.rgba)==255},b.ensureContrastRatio=function(N,E,D){const A=_.ensureContrastRatio(N.rgba,E.rgba,D);if(A)return g.toColor(A>>24&255,A>>16&255,A>>8&255)},b.opaque=function(N){const E=(255|N.rgba)>>>0;return[d,h,p]=_.toChannels(E),{css:g.toCss(d,h,p),rgba:E}},b.opacity=k,b.multiplyOpacity=function(N,E){return m=255&N.rgba,k(N,m*E/255)},b.toColorRGB=function(N){return[N.rgba>>24&255,N.rgba>>16&255,N.rgba>>8&255]}})(x||(u.color=x={})),(function(b){let k,N;try{const E=document.createElement("canvas");E.width=1,E.height=1;const D=E.getContext("2d",{willReadFrequently:!0});D&&(k=D,k.globalCompositeOperation="copy",N=k.createLinearGradient(0,0,1,1))}catch{}b.toColor=function(E){if(E.match(/#[\da-f]{3,8}/i))switch(E.length){case 4:return d=parseInt(E.slice(1,2).repeat(2),16),h=parseInt(E.slice(2,3).repeat(2),16),p=parseInt(E.slice(3,4).repeat(2),16),g.toColor(d,h,p);case 5:return d=parseInt(E.slice(1,2).repeat(2),16),h=parseInt(E.slice(2,3).repeat(2),16),p=parseInt(E.slice(3,4).repeat(2),16),m=parseInt(E.slice(4,5).repeat(2),16),g.toColor(d,h,p,m);case 7:return{css:E,rgba:(parseInt(E.slice(1),16)<<8|255)>>>0};case 9:return{css:E,rgba:parseInt(E.slice(1),16)>>>0}}const D=E.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]))),g.toColor(d,h,p,m);if(!k||!N)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=N,k.fillStyle=E,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,h,p,m]=k.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:g.toRgba(d,h,p,m),css:E}}})(w||(u.css=w={})),(function(b){function k(N,E,D){const A=N/255,O=E/255,P=D/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(O<=.03928?O/12.92:Math.pow((O+.055)/1.055,2.4))+.0722*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))}b.relativeLuminance=function(N){return k(N>>16&255,N>>8&255,255&N)},b.relativeLuminance2=k})(C||(u.rgb=C={})),(function(b){function k(E,D,A){const O=E>>24&255,P=E>>16&255,G=E>>8&255;let z=D>>24&255,V=D>>16&255,$=D>>8&255,H=v(C.relativeLuminance2(z,V,$),C.relativeLuminance2(O,P,G));for(;H<A&&(z>0||V>0||$>0);)z-=Math.max(0,Math.ceil(.1*z)),V-=Math.max(0,Math.ceil(.1*V)),$-=Math.max(0,Math.ceil(.1*$)),H=v(C.relativeLuminance2(z,V,$),C.relativeLuminance2(O,P,G));return(z<<24|V<<16|$<<8|255)>>>0}function N(E,D,A){const O=E>>24&255,P=E>>16&255,G=E>>8&255;let z=D>>24&255,V=D>>16&255,$=D>>8&255,H=v(C.relativeLuminance2(z,V,$),C.relativeLuminance2(O,P,G));for(;H<A&&(z<255||V<255||$<255);)z=Math.min(255,z+Math.ceil(.1*(255-z))),V=Math.min(255,V+Math.ceil(.1*(255-V))),$=Math.min(255,$+Math.ceil(.1*(255-$))),H=v(C.relativeLuminance2(z,V,$),C.relativeLuminance2(O,P,G));return(z<<24|V<<16|$<<8|255)>>>0}b.blend=function(E,D){if(m=(255&D)/255,m===1)return D;const A=D>>24&255,O=D>>16&255,P=D>>8&255,G=E>>24&255,z=E>>16&255,V=E>>8&255;return d=G+Math.round((A-G)*m),h=z+Math.round((O-z)*m),p=V+Math.round((P-V)*m),g.toRgba(d,h,p)},b.ensureContrastRatio=function(E,D,A){const O=C.relativeLuminance(E>>8),P=C.relativeLuminance(D>>8);if(v(O,P)<A){if(P<O){const V=k(E,D,A),$=v(O,C.relativeLuminance(V>>8));if($<A){const H=N(E,D,A);return $>v(O,C.relativeLuminance(H>>8))?V:H}return V}const G=N(E,D,A),z=v(O,C.relativeLuminance(G>>8));if(z<A){const V=k(E,D,A);return z>v(O,C.relativeLuminance(V>>8))?G:V}return G}},b.reduceLuminance=k,b.increaseLuminance=N,b.toChannels=function(E){return[E>>24&255,E>>16&255,E>>8&255,255&E]}})(_||(u.rgba=_={})),u.toPaddedHex=S,u.contrastRatio=v},8969:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreTerminal=void 0;const h=d(844),p=d(2585),m=d(4348),g=d(7866),x=d(744),w=d(7302),C=d(6975),_=d(8460),S=d(1753),v=d(1480),b=d(7994),k=d(9282),N=d(5435),E=d(5981),D=d(2660);let A=!1;class O extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new _.EventEmitter),this._onScroll.event((G=>{var z;(z=this._onScrollApi)==null||z.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 z in G)this.optionsService.options[z]=G[z]}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(x.BufferService)),this._instantiationService.setService(p.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.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((z=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((z=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new E.WriteBuffer(((z,V)=>this._inputHandler.parse(z,V)))),this.register((0,_.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(G,z){this._writeBuffer.write(G,z)}writeSync(G,z){this._logService.logLevel<=p.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(G,z)}input(G,z=!0){this.coreService.triggerDataEvent(G,z)}resize(G,z){isNaN(G)||isNaN(z)||(G=Math.max(G,x.MINIMUM_COLS),z=Math.max(z,x.MINIMUM_ROWS),this._bufferService.resize(G,z))}scroll(G,z=!1){this._bufferService.scroll(G,z)}scrollLines(G,z,V){this._bufferService.scrollLines(G,z,V)}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 z=G-this._bufferService.buffer.ydisp;z!==0&&this.scrollLines(z)}registerEscHandler(G,z){return this._inputHandler.registerEscHandler(G,z)}registerDcsHandler(G,z){return this._inputHandler.registerDcsHandler(G,z)}registerCsiHandler(G,z){return this._inputHandler.registerCsiHandler(G,z)}registerOscHandler(G,z){return this._inputHandler.registerOscHandler(G,z)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let G=!1;const z=this.optionsService.rawOptions.windowsPty;z&&z.buildNumber!==void 0&&z.buildNumber!==void 0?G=z.backend==="conpty"&&z.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(k.updateWindowsModeWrappedState.bind(null,this._bufferService))),G.push(this.registerCsiHandler({final:"H"},(()=>((0,k.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const z of G)z.dispose()}))}}}u.CoreTerminal=O},8460:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.runAndSubscribe=u.forwardEvent=u.EventEmitter=void 0,u.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=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)}},u.forwardEvent=function(d,h){return d((p=>h.fire(p)))},u.runAndSubscribe=function(d,h){return h(void 0),d((p=>h(p)))}},5435:function(c,u,d){var h=this&&this.__decorate||function(Y,F,I,R){var W,B=arguments.length,Z=B<3?F:R===null?R=Object.getOwnPropertyDescriptor(F,I):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Z=Reflect.decorate(Y,F,I,R);else for(var Q=Y.length-1;Q>=0;Q--)(W=Y[Q])&&(Z=(B<3?W(Z):B>3?W(F,I,Z):W(F,I))||Z);return B>3&&Z&&Object.defineProperty(F,I,Z),Z},p=this&&this.__param||function(Y,F){return function(I,R){F(I,R,Y)}};Object.defineProperty(u,"__esModule",{value:!0}),u.InputHandler=u.WindowsOptionsReportType=void 0;const m=d(2584),g=d(7116),x=d(2015),w=d(844),C=d(482),_=d(8437),S=d(8460),v=d(643),b=d(511),k=d(3734),N=d(2585),E=d(1480),D=d(6242),A=d(6351),O=d(5941),P={"(":0,")":1,"*":2,"+":3,"-":1,".":2},G=131072;function z(Y,F){if(Y>24)return F.setWinLines||!1;switch(Y){case 1:return!!F.restoreWin;case 2:return!!F.minimizeWin;case 3:return!!F.setWinPosition;case 4:return!!F.setWinSizePixels;case 5:return!!F.raiseWin;case 6:return!!F.lowerWin;case 7:return!!F.refreshWin;case 8:return!!F.setWinSizeChars;case 9:return!!F.maximizeWin;case 10:return!!F.fullscreenWin;case 11:return!!F.getWinState;case 13:return!!F.getWinPosition;case 14:return!!F.getWinSizePixels;case 15:return!!F.getScreenSizePixels;case 16:return!!F.getCellSizePixels;case 18:return!!F.getWinSizeChars;case 19:return!!F.getScreenSizeChars;case 20:return!!F.getIconTitle;case 21:return!!F.getWinTitle;case 22:return!!F.pushTitle;case 23:return!!F.popTitle;case 24:return!!F.setWinLines}return!1}var V;(function(Y){Y[Y.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",Y[Y.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(V||(u.WindowsOptionsReportType=V={}));let $=0;class H extends w.Disposable{getAttrData(){return this._curAttrData}constructor(F,I,R,W,B,Z,Q,J,U=new x.EscapeSequenceParser){super(),this._bufferService=F,this._charsetService=I,this._coreService=R,this._logService=W,this._optionsService=B,this._oscLinkService=Z,this._coreMouseService=Q,this._unicodeService=J,this._parser=U,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new b.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_.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 q(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((M=>this._activeBuffer=M.activeBuffer))),this._parser.setCsiHandlerFallback(((M,te)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(M),params:te.toArray()})})),this._parser.setEscHandlerFallback((M=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(M)})})),this._parser.setExecuteHandlerFallback((M=>{this._logService.debug("Unknown EXECUTE code: ",{code:M})})),this._parser.setOscHandlerFallback(((M,te,se)=>{this._logService.debug("Unknown OSC code: ",{identifier:M,action:te,data:se})})),this._parser.setDcsHandlerFallback(((M,te,se)=>{te==="HOOK"&&(se=se.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(M),action:te,payload:se})})),this._parser.setPrintHandler(((M,te,se)=>this.print(M,te,se))),this._parser.registerCsiHandler({final:"@"},(M=>this.insertChars(M))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(M=>this.scrollLeft(M))),this._parser.registerCsiHandler({final:"A"},(M=>this.cursorUp(M))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(M=>this.scrollRight(M))),this._parser.registerCsiHandler({final:"B"},(M=>this.cursorDown(M))),this._parser.registerCsiHandler({final:"C"},(M=>this.cursorForward(M))),this._parser.registerCsiHandler({final:"D"},(M=>this.cursorBackward(M))),this._parser.registerCsiHandler({final:"E"},(M=>this.cursorNextLine(M))),this._parser.registerCsiHandler({final:"F"},(M=>this.cursorPrecedingLine(M))),this._parser.registerCsiHandler({final:"G"},(M=>this.cursorCharAbsolute(M))),this._parser.registerCsiHandler({final:"H"},(M=>this.cursorPosition(M))),this._parser.registerCsiHandler({final:"I"},(M=>this.cursorForwardTab(M))),this._parser.registerCsiHandler({final:"J"},(M=>this.eraseInDisplay(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(M=>this.eraseInDisplay(M,!0))),this._parser.registerCsiHandler({final:"K"},(M=>this.eraseInLine(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(M=>this.eraseInLine(M,!0))),this._parser.registerCsiHandler({final:"L"},(M=>this.insertLines(M))),this._parser.registerCsiHandler({final:"M"},(M=>this.deleteLines(M))),this._parser.registerCsiHandler({final:"P"},(M=>this.deleteChars(M))),this._parser.registerCsiHandler({final:"S"},(M=>this.scrollUp(M))),this._parser.registerCsiHandler({final:"T"},(M=>this.scrollDown(M))),this._parser.registerCsiHandler({final:"X"},(M=>this.eraseChars(M))),this._parser.registerCsiHandler({final:"Z"},(M=>this.cursorBackwardTab(M))),this._parser.registerCsiHandler({final:"`"},(M=>this.charPosAbsolute(M))),this._parser.registerCsiHandler({final:"a"},(M=>this.hPositionRelative(M))),this._parser.registerCsiHandler({final:"b"},(M=>this.repeatPrecedingCharacter(M))),this._parser.registerCsiHandler({final:"c"},(M=>this.sendDeviceAttributesPrimary(M))),this._parser.registerCsiHandler({prefix:">",final:"c"},(M=>this.sendDeviceAttributesSecondary(M))),this._parser.registerCsiHandler({final:"d"},(M=>this.linePosAbsolute(M))),this._parser.registerCsiHandler({final:"e"},(M=>this.vPositionRelative(M))),this._parser.registerCsiHandler({final:"f"},(M=>this.hVPosition(M))),this._parser.registerCsiHandler({final:"g"},(M=>this.tabClear(M))),this._parser.registerCsiHandler({final:"h"},(M=>this.setMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(M=>this.setModePrivate(M))),this._parser.registerCsiHandler({final:"l"},(M=>this.resetMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(M=>this.resetModePrivate(M))),this._parser.registerCsiHandler({final:"m"},(M=>this.charAttributes(M))),this._parser.registerCsiHandler({final:"n"},(M=>this.deviceStatus(M))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(M=>this.deviceStatusPrivate(M))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(M=>this.softReset(M))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(M=>this.setCursorStyle(M))),this._parser.registerCsiHandler({final:"r"},(M=>this.setScrollRegion(M))),this._parser.registerCsiHandler({final:"s"},(M=>this.saveCursor(M))),this._parser.registerCsiHandler({final:"t"},(M=>this.windowOptions(M))),this._parser.registerCsiHandler({final:"u"},(M=>this.restoreCursor(M))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(M=>this.insertColumns(M))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(M=>this.deleteColumns(M))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(M=>this.selectProtected(M))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(M=>this.requestMode(M,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(M=>this.requestMode(M,!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((M=>(this.setTitle(M),this.setIconName(M),!0)))),this._parser.registerOscHandler(1,new D.OscHandler((M=>this.setIconName(M)))),this._parser.registerOscHandler(2,new D.OscHandler((M=>this.setTitle(M)))),this._parser.registerOscHandler(4,new D.OscHandler((M=>this.setOrReportIndexedColor(M)))),this._parser.registerOscHandler(8,new D.OscHandler((M=>this.setHyperlink(M)))),this._parser.registerOscHandler(10,new D.OscHandler((M=>this.setOrReportFgColor(M)))),this._parser.registerOscHandler(11,new D.OscHandler((M=>this.setOrReportBgColor(M)))),this._parser.registerOscHandler(12,new D.OscHandler((M=>this.setOrReportCursorColor(M)))),this._parser.registerOscHandler(104,new D.OscHandler((M=>this.restoreIndexedColor(M)))),this._parser.registerOscHandler(110,new D.OscHandler((M=>this.restoreFgColor(M)))),this._parser.registerOscHandler(111,new D.OscHandler((M=>this.restoreBgColor(M)))),this._parser.registerOscHandler(112,new D.OscHandler((M=>this.restoreCursorColor(M)))),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 M in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:M},(()=>this.selectCharset("("+M))),this._parser.registerEscHandler({intermediates:")",final:M},(()=>this.selectCharset(")"+M))),this._parser.registerEscHandler({intermediates:"*",final:M},(()=>this.selectCharset("*"+M))),this._parser.registerEscHandler({intermediates:"+",final:M},(()=>this.selectCharset("+"+M))),this._parser.registerEscHandler({intermediates:"-",final:M},(()=>this.selectCharset("-"+M))),this._parser.registerEscHandler({intermediates:".",final:M},(()=>this.selectCharset("."+M))),this._parser.registerEscHandler({intermediates:"/",final:M},(()=>this.selectCharset("/"+M)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((M=>(this._logService.error("Parsing error: ",M),M))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((M,te)=>this.requestStatusString(M,te))))}_preserveStack(F,I,R,W){this._parseStack.paused=!0,this._parseStack.cursorStartX=F,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=R,this._parseStack.position=W}_logSlowResolvingAsync(F){this._logService.logLevel<=N.LogLevelEnum.WARN&&Promise.race([F,new Promise(((I,R)=>setTimeout((()=>R("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(F,I){let R,W=this._activeBuffer.x,B=this._activeBuffer.y,Z=0;const Q=this._parseStack.paused;if(Q){if(R=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync(R),R;W=this._parseStack.cursorStartX,B=this._parseStack.cursorStartY,this._parseStack.paused=!1,F.length>G&&(Z=this._parseStack.position+G)}if(this._logService.logLevel<=N.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof F=="string"?` "${F}"`:` "${Array.prototype.map.call(F,(M=>String.fromCharCode(M))).join("")}"`),typeof F=="string"?F.split("").map((M=>M.charCodeAt(0))):F),this._parseBuffer.length<F.length&&this._parseBuffer.length<G&&(this._parseBuffer=new Uint32Array(Math.min(F.length,G))),Q||this._dirtyRowTracker.clearRange(),F.length>G)for(let M=Z;M<F.length;M+=G){const te=M+G<F.length?M+G:F.length,se=typeof F=="string"?this._stringDecoder.decode(F.substring(M,te),this._parseBuffer):this._utf8Decoder.decode(F.subarray(M,te),this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,se))return this._preserveStack(W,B,se,M),this._logSlowResolvingAsync(R),R}else if(!Q){const M=typeof F=="string"?this._stringDecoder.decode(F,this._parseBuffer):this._utf8Decoder.decode(F,this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,M))return this._preserveStack(W,B,M,0),this._logSlowResolvingAsync(R),R}this._activeBuffer.x===W&&this._activeBuffer.y===B||this._onCursorMove.fire();const J=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),U=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);U<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(U,this._bufferService.rows-1),Math.min(J,this._bufferService.rows-1))}print(F,I,R){let W,B;const Z=this._charsetService.charset,Q=this._optionsService.rawOptions.screenReaderMode,J=this._bufferService.cols,U=this._coreService.decPrivateModes.wraparound,M=this._coreService.modes.insertMode,te=this._curAttrData;let se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&R-I>0&&se.getWidth(this._activeBuffer.x-1)===2&&se.setCellFromCodepoint(this._activeBuffer.x-1,0,1,te);let re=this._parser.precedingJoinState;for(let le=I;le<R;++le){if(W=F[le],W<127&&Z){const Be=Z[String.fromCharCode(W)];Be&&(W=Be.charCodeAt(0))}const ye=this._unicodeService.charProperties(W,re);B=E.UnicodeService.extractWidth(ye);const _e=E.UnicodeService.extractShouldJoin(ye),Oe=_e?E.UnicodeService.extractWidth(re):0;if(re=ye,Q&&this._onA11yChar.fire((0,C.stringFromCodePoint)(W)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+B-Oe>J){if(U){const Be=se;let ke=this._activeBuffer.x-Oe;for(this._activeBuffer.x=Oe,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Oe>0&&se instanceof _.BufferLine&&se.copyCellsFrom(Be,ke,0,Oe,!1);ke<J;)Be.setCellFromCodepoint(ke++,0,1,te)}else if(this._activeBuffer.x=J-1,B===2)continue}if(_e&&this._activeBuffer.x){const Be=se.getWidth(this._activeBuffer.x-1)?1:2;se.addCodepointToCell(this._activeBuffer.x-Be,W,B);for(let ke=B-Oe;--ke>=0;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}else if(M&&(se.insertCells(this._activeBuffer.x,B-Oe,this._activeBuffer.getNullCell(te)),se.getWidth(J-1)===2&&se.setCellFromCodepoint(J-1,v.NULL_CELL_CODE,v.NULL_CELL_WIDTH,te)),se.setCellFromCodepoint(this._activeBuffer.x++,W,B,te),B>0)for(;--B;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}this._parser.precedingJoinState=re,this._activeBuffer.x<J&&R-I>0&&se.getWidth(this._activeBuffer.x)===0&&!se.hasContent(this._activeBuffer.x)&&se.setCellFromCodepoint(this._activeBuffer.x,0,1,te),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(F,I){return F.final!=="t"||F.prefix||F.intermediates?this._parser.registerCsiHandler(F,I):this._parser.registerCsiHandler(F,(R=>!z(R.params[0],this._optionsService.rawOptions.windowOptions)||I(R)))}registerDcsHandler(F,I){return this._parser.registerDcsHandler(F,new A.DcsHandler(I))}registerEscHandler(F,I){return this._parser.registerEscHandler(F,I)}registerOscHandler(F,I){return this._parser.registerOscHandler(F,new D.OscHandler(I))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var F;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&&((F=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&F.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);I.hasWidth(this._activeBuffer.x)&&!I.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const F=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-F),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(F=this._bufferService.cols-1){this._activeBuffer.x=Math.min(F,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(F,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=F,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=F,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(F,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+F,this._activeBuffer.y+I)}cursorUp(F){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,F.params[0]||1)):this._moveCursor(0,-(F.params[0]||1)),!0}cursorDown(F){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,F.params[0]||1)):this._moveCursor(0,F.params[0]||1),!0}cursorForward(F){return this._moveCursor(F.params[0]||1,0),!0}cursorBackward(F){return this._moveCursor(-(F.params[0]||1),0),!0}cursorNextLine(F){return this.cursorDown(F),this._activeBuffer.x=0,!0}cursorPrecedingLine(F){return this.cursorUp(F),this._activeBuffer.x=0,!0}cursorCharAbsolute(F){return this._setCursor((F.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(F){return this._setCursor(F.length>=2?(F.params[1]||1)-1:0,(F.params[0]||1)-1),!0}charPosAbsolute(F){return this._setCursor((F.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(F){return this._moveCursor(F.params[0]||1,0),!0}linePosAbsolute(F){return this._setCursor(this._activeBuffer.x,(F.params[0]||1)-1),!0}vPositionRelative(F){return this._moveCursor(0,F.params[0]||1),!0}hVPosition(F){return this.cursorPosition(F),!0}tabClear(F){const I=F.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(F){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=F.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(F){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=F.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(F){const I=F.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(F,I,R,W=!1,B=!1){const Z=this._activeBuffer.lines.get(this._activeBuffer.ybase+F);Z.replaceCells(I,R,this._activeBuffer.getNullCell(this._eraseAttrData()),B),W&&(Z.isWrapped=!1)}_resetBufferLine(F,I=!1){const R=this._activeBuffer.lines.get(this._activeBuffer.ybase+F);R&&(R.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+F),R.isWrapped=!1)}eraseInDisplay(F,I=!1){let R;switch(this._restrictCursor(this._bufferService.cols),F.params[0]){case 0:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);R<this._bufferService.rows;R++)this._resetBufferLine(R,I);this._dirtyRowTracker.markDirty(R);break;case 1:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R,0,this._activeBuffer.x+1,!0,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(R+1).isWrapped=!1);R--;)this._resetBufferLine(R,I);this._dirtyRowTracker.markDirty(0);break;case 2:for(R=this._bufferService.rows,this._dirtyRowTracker.markDirty(R-1);R--;)this._resetBufferLine(R,I);this._dirtyRowTracker.markDirty(0);break;case 3:const W=this._activeBuffer.lines.length-this._bufferService.rows;W>0&&(this._activeBuffer.lines.trimStart(W),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-W,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-W,0),this._onScroll.fire(0))}return!0}eraseInLine(F,I=!1){switch(this._restrictCursor(this._bufferService.cols),F.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(F){this._restrictCursor();let I=F.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=this._activeBuffer.ybase+this._activeBuffer.y,W=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-W+1;for(;I--;)this._activeBuffer.lines.splice(B-1,1),this._activeBuffer.lines.splice(R,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(F){this._restrictCursor();let I=F.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=this._activeBuffer.ybase+this._activeBuffer.y;let W;for(W=this._bufferService.rows-1-this._activeBuffer.scrollBottom,W=this._bufferService.rows-1+this._activeBuffer.ybase-W;I--;)this._activeBuffer.lines.splice(R,1),this._activeBuffer.lines.splice(W,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(F){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,F.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(F){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,F.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(F){let I=F.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(F){let I=F.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(_.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=F.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);W.deleteCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),W.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=F.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);W.insertCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),W.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=F.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);W.insertCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),W.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=F.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);W.deleteCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),W.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(F){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(F.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(F){const I=this._parser.precedingJoinState;if(!I)return!0;const R=F.params[0]||1,W=E.UnicodeService.extractWidth(I),B=this._activeBuffer.x-W,Z=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(B),Q=new Uint32Array(Z.length*R);let J=0;for(let M=0;M<Z.length;){const te=Z.codePointAt(M)||0;Q[J++]=te,M+=te>65535?2:1}let U=J;for(let M=1;M<R;++M)Q.copyWithin(U,0,J),U+=J;return this.print(Q,0,U),!0}sendDeviceAttributesPrimary(F){return F.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(F){return F.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(F.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is(F){return(this._optionsService.rawOptions.termName+"").indexOf(F)===0}setMode(F){for(let I=0;I<F.length;I++)switch(F.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(F){for(let I=0;I<F.length;I++)switch(F.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(F){for(let I=0;I<F.length;I++)switch(F.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(F){for(let I=0;I<F.length;I++)switch(F.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),F.params[I]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(F,I){const R=this._coreService.decPrivateModes,{activeProtocol:W,activeEncoding:B}=this._coreMouseService,Z=this._coreService,{buffers:Q,cols:J}=this._bufferService,{active:U,alt:M}=Q,te=this._optionsService.rawOptions,se=_e=>_e?1:2,re=F.params[0];return le=re,ye=I?re===2?4:re===4?se(Z.modes.insertMode):re===12?3:re===20?se(te.convertEol):0:re===1?se(R.applicationCursorKeys):re===3?te.windowOptions.setWinLines?J===80?2:J===132?1:0:0:re===6?se(R.origin):re===7?se(R.wraparound):re===8?3:re===9?se(W==="X10"):re===12?se(te.cursorBlink):re===25?se(!Z.isCursorHidden):re===45?se(R.reverseWraparound):re===66?se(R.applicationKeypad):re===67?4:re===1e3?se(W==="VT200"):re===1002?se(W==="DRAG"):re===1003?se(W==="ANY"):re===1004?se(R.sendFocus):re===1005?4:re===1006?se(B==="SGR"):re===1015?4:re===1016?se(B==="SGR_PIXELS"):re===1048?1:re===47||re===1047||re===1049?se(U===M):re===2004?se(R.bracketedPasteMode):0,Z.triggerDataEvent(`${m.C0.ESC}[${I?"":"?"}${le};${ye}$y`),!0;var le,ye}_updateAttrColor(F,I,R,W,B){return I===2?(F|=50331648,F&=-16777216,F|=k.AttributeData.fromColorRGB([R,W,B])):I===5&&(F&=-50331904,F|=33554432|255&R),F}_extractColor(F,I,R){const W=[0,0,-1,0,0,0];let B=0,Z=0;do{if(W[Z+B]=F.params[I+Z],F.hasSubParams(I+Z)){const Q=F.getSubParams(I+Z);let J=0;do W[1]===5&&(B=1),W[Z+J+1+B]=Q[J];while(++J<Q.length&&J+Z+1+B<W.length);break}if(W[1]===5&&Z+B>=2||W[1]===2&&Z+B>=5)break;W[1]&&(B=1)}while(++Z+I<F.length&&Z+B<W.length);for(let Q=2;Q<W.length;++Q)W[Q]===-1&&(W[Q]=0);switch(W[0]){case 38:R.fg=this._updateAttrColor(R.fg,W[1],W[3],W[4],W[5]);break;case 48:R.bg=this._updateAttrColor(R.bg,W[1],W[3],W[4],W[5]);break;case 58:R.extended=R.extended.clone(),R.extended.underlineColor=this._updateAttrColor(R.extended.underlineColor,W[1],W[3],W[4],W[5])}return Z}_processUnderline(F,I){I.extended=I.extended.clone(),(!~F||F>5)&&(F=1),I.extended.underlineStyle=F,I.fg|=268435456,F===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0(F){F.fg=_.DEFAULT_ATTR_DATA.fg,F.bg=_.DEFAULT_ATTR_DATA.bg,F.extended=F.extended.clone(),F.extended.underlineStyle=0,F.extended.underlineColor&=-67108864,F.updateExtended()}charAttributes(F){if(F.length===1&&F.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=F.length;let R;const W=this._curAttrData;for(let B=0;B<I;B++)R=F.params[B],R>=30&&R<=37?(W.fg&=-50331904,W.fg|=16777216|R-30):R>=40&&R<=47?(W.bg&=-50331904,W.bg|=16777216|R-40):R>=90&&R<=97?(W.fg&=-50331904,W.fg|=16777224|R-90):R>=100&&R<=107?(W.bg&=-50331904,W.bg|=16777224|R-100):R===0?this._processSGR0(W):R===1?W.fg|=134217728:R===3?W.bg|=67108864:R===4?(W.fg|=268435456,this._processUnderline(F.hasSubParams(B)?F.getSubParams(B)[0]:1,W)):R===5?W.fg|=536870912:R===7?W.fg|=67108864:R===8?W.fg|=1073741824:R===9?W.fg|=2147483648:R===2?W.bg|=134217728:R===21?this._processUnderline(2,W):R===22?(W.fg&=-134217729,W.bg&=-134217729):R===23?W.bg&=-67108865:R===24?(W.fg&=-268435457,this._processUnderline(0,W)):R===25?W.fg&=-536870913:R===27?W.fg&=-67108865:R===28?W.fg&=-1073741825:R===29?W.fg&=2147483647:R===39?(W.fg&=-67108864,W.fg|=16777215&_.DEFAULT_ATTR_DATA.fg):R===49?(W.bg&=-67108864,W.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):R===38||R===48||R===58?B+=this._extractColor(F,B,W):R===53?W.bg|=1073741824:R===55?W.bg&=-1073741825:R===59?(W.extended=W.extended.clone(),W.extended.underlineColor=-1,W.updateExtended()):R===100?(W.fg&=-67108864,W.fg|=16777215&_.DEFAULT_ATTR_DATA.fg,W.bg&=-67108864,W.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",R);return!0}deviceStatus(F){switch(F.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${I};${R}R`)}return!0}deviceStatusPrivate(F){if(F.params[0]===6){const I=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${I};${R}R`)}return!0}softReset(F){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(F){const I=F.params[0]||1;switch(I){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const R=I%2==1;return this._optionsService.options.cursorBlink=R,!0}setScrollRegion(F){const I=F.params[0]||1;let R;return(F.length<2||(R=F.params[1])>this._bufferService.rows||R===0)&&(R=this._bufferService.rows),R>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=R-1,this._setCursor(0,0)),!0}windowOptions(F){if(!z(F.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=F.length>1?F.params[1]:0;switch(F.params[0]){case 14:I!==2&&this._onRequestWindowsOptionsReport.fire(V.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(V.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(F){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(F){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(F){return this._windowTitle=F,this._onTitleChange.fire(F),!0}setIconName(F){return this._iconName=F,!0}setOrReportIndexedColor(F){const I=[],R=F.split(";");for(;R.length>1;){const W=R.shift(),B=R.shift();if(/^\d+$/.exec(W)){const Z=parseInt(W);if(X(Z))if(B==="?")I.push({type:0,index:Z});else{const Q=(0,O.parseColor)(B);Q&&I.push({type:1,index:Z,color:Q})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink(F){const I=F.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink(F,I){this._getCurrentLinkId()&&this._finishHyperlink();const R=F.split(":");let W;const B=R.findIndex((Z=>Z.startsWith("id=")));return B!==-1&&(W=R[B].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:W,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(F,I){const R=F.split(";");for(let W=0;W<R.length&&!(I>=this._specialColors.length);++W,++I)if(R[W]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const B=(0,O.parseColor)(R[W]);B&&this._onColor.fire([{type:1,index:this._specialColors[I],color:B}])}return!0}setOrReportFgColor(F){return this._setOrReportSpecialColor(F,0)}setOrReportBgColor(F){return this._setOrReportSpecialColor(F,1)}setOrReportCursorColor(F){return this._setOrReportSpecialColor(F,2)}restoreIndexedColor(F){if(!F)return this._onColor.fire([{type:2}]),!0;const I=[],R=F.split(";");for(let W=0;W<R.length;++W)if(/^\d+$/.exec(R[W])){const B=parseInt(R[W]);X(B)&&I.push({type:2,index:B})}return I.length&&this._onColor.fire(I),!0}restoreFgColor(F){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(F){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(F){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(F){return F.length!==2?(this.selectDefaultCharset(),!0):(F[0]==="/"||this._charsetService.setgCharset(P[F[0]],g.CHARSETS[F[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const F=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,F,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(F){return this._charsetService.setgLevel(F),!0}screenAlignmentPattern(){const F=new b.CellData;F.content=4194373,F.fg=this._curAttrData.fg,F.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const R=this._activeBuffer.ybase+this._activeBuffer.y+I,W=this._activeBuffer.lines.get(R);W&&(W.fill(F),W.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(F,I){const R=this._bufferService.buffer,W=this._optionsService.rawOptions;return(B=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${B}${m.C0.ESC}\\`),!0))(F==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:F==='"p'?'P1$r61;1"p':F==="r"?`P1$r${R.scrollTop+1};${R.scrollBottom+1}r`:F==="m"?"P1$r0m":F===" q"?`P1$r${{block:2,underline:4,bar:6}[W.cursorStyle]-(W.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(F,I){this._dirtyRowTracker.markRangeDirty(F,I)}}u.InputHandler=H;let q=class{constructor(Y){this._bufferService=Y,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(Y){Y<this.start?this.start=Y:Y>this.end&&(this.end=Y)}markRangeDirty(Y,F){Y>F&&($=Y,Y=F,F=$),Y<this.start&&(this.start=Y),F>this.end&&(this.end=F)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function X(Y){return 0<=Y&&Y<256}q=h([p(0,N.IBufferService)],q)},844:(c,u)=>{function d(h){for(const p of h)p.dispose();h.length=0}Object.defineProperty(u,"__esModule",{value:!0}),u.getDisposeArrayDisposable=u.disposeArray=u.toDisposable=u.MutableDisposable=u.Disposable=void 0,u.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const p=this._disposables.indexOf(h);p!==-1&&this._disposables.splice(p,1)}},u.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}},u.toDisposable=function(h){return{dispose:h}},u.disposeArray=d,u.getDisposeArrayDisposable=function(h){return{dispose:()=>d(h)}}},1505:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.FourKeyMap=u.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(p,m,g){this._data[p]||(this._data[p]={}),this._data[p][m]=g}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}u.TwoKeyMap=d,u.FourKeyMap=class{constructor(){this._data=new d}set(h,p,m,g,x){this._data.get(h,p)||this._data.set(h,p,new d),this._data.get(h,p).set(m,g,x)}get(h,p,m,g){var x;return(x=this._data.get(h,p))==null?void 0:x.get(m,g)}clear(){this._data.clear()}}},6114:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.isChromeOS=u.isLinux=u.isWindows=u.isIphone=u.isIpad=u.isMac=u.getSafariVersion=u.isSafari=u.isLegacyEdge=u.isFirefox=u.isNode=void 0,u.isNode=typeof process<"u"&&"title"in process;const d=u.isNode?"node":navigator.userAgent,h=u.isNode?"node":navigator.platform;u.isFirefox=d.includes("Firefox"),u.isLegacyEdge=d.includes("Edge"),u.isSafari=/^((?!chrome|android).)*safari/i.test(d),u.getSafariVersion=function(){if(!u.isSafari)return 0;const p=d.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},u.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h),u.isIpad=h==="iPad",u.isIphone=h==="iPhone",u.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),u.isLinux=h.indexOf("Linux")>=0,u.isChromeOS=/\bCrOS\b/.test(d)},6106:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.SortedList=void 0;let d=0;u.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 g=p+m>>1;const x=this._getKey(this._array[g]);if(x>h)m=g-1;else{if(!(x<h)){for(;g>0&&this._getKey(this._array[g-1])===h;)g--;return g}p=g+1}}return p}}},7226:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DebouncedIdleTask=u.IdleTaskQueue=u.PriorityTaskQueue=void 0;const h=d(6114);class p{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let w=0,C=0,_=x.timeRemaining(),S=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),S=x.timeRemaining(),1.5*C>S)return _-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(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}u.PriorityTaskQueue=m,u.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:m,u.DebouncedIdleTask=class{constructor(){this._queue=new u.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.updateWindowsModeWrappedState=void 0;const h=d(643);u.updateWindowsModeWrappedState=function(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),g=m==null?void 0:m.get(p.cols-1),x=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);x&&g&&(x.isWrapped=g[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&g[h.CHAR_DATA_CODE_INDEX]!==h.WHITESPACE_CELL_CODE)}},3734:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ExtendedAttrs=u.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}}u.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,g=0){this._ext=0,this._urlId=0,this._ext=m,this._urlId=g}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}u.ExtendedAttrs=h},9092:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Buffer=u.MAX_BUFFER_SIZE=void 0;const h=d(6349),p=d(7226),m=d(3734),g=d(8437),x=d(4634),w=d(511),C=d(643),_=d(4863),S=d(7116);u.MAX_BUFFER_SIZE=4294967295,u.Buffer=class{constructor(v,b,k){this._hasScrollback=v,this._optionsService=b,this._bufferService=k,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new 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 g.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>u.MAX_BUFFER_SIZE?u.MAX_BUFFER_SIZE:b}fillViewportRows(v){if(this.lines.length===0){v===void 0&&(v=g.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 k=this.getNullCell(g.DEFAULT_ATTR_DATA);let N=0;const E=this._getCorrectBufferLength(b);if(E>this.lines.maxLength&&(this.lines.maxLength=E),this.lines.length>0){if(this._cols<v)for(let A=0;A<this.lines.length;A++)N+=+this.lines.get(A).resize(v,k);let D=0;if(this._rows<b)for(let A=this._rows;A<b;A++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(v,k)):this.ybase>0&&this.lines.length<=this.ybase+this.y+D+1?(this.ybase--,D++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(v,k)));else for(let A=this._rows;A>b;A--)this.lines.length>b+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(E<this.lines.maxLength){const A=this.lines.length-E;A>0&&(this.lines.trimStart(A),this.ybase=Math.max(this.ybase-A,0),this.ydisp=Math.max(this.ydisp-A,0),this.savedY=Math.max(this.savedY-A,0)),this.lines.maxLength=E}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,k);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 k=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,v,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(k.length>0){const N=(0,x.reflowLargerCreateNewLayout)(this.lines,k);(0,x.reflowLargerApplyNewLayout)(this.lines,N.layout),this._reflowLargerAdjustViewport(v,b,N.countRemoved)}}_reflowLargerAdjustViewport(v,b,k){const N=this.getNullCell(g.DEFAULT_ATTR_DATA);let E=k;for(;E-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new g.BufferLine(v,N))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-k,0)}_reflowSmaller(v,b){const k=this.getNullCell(g.DEFAULT_ATTR_DATA),N=[];let E=0;for(let D=this.lines.length-1;D>=0;D--){let A=this.lines.get(D);if(!A||!A.isWrapped&&A.getTrimmedLength()<=v)continue;const O=[A];for(;A.isWrapped&&D>0;)A=this.lines.get(--D),O.unshift(A);const P=this.ybase+this.y;if(P>=D&&P<D+O.length)continue;const G=O[O.length-1].getTrimmedLength(),z=(0,x.reflowSmallerGetNewLineLengths)(O,this._cols,v),V=z.length-O.length;let $;$=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+V):Math.max(0,this.lines.length-this.lines.maxLength+V);const H=[];for(let R=0;R<V;R++){const W=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);H.push(W)}H.length>0&&(N.push({start:D+O.length+E,newLines:H}),E+=H.length),O.push(...H);let q=z.length-1,X=z[q];X===0&&(q--,X=z[q]);let Y=O.length-V-1,F=G;for(;Y>=0;){const R=Math.min(F,X);if(O[q]===void 0)break;if(O[q].copyCellsFrom(O[Y],F-R,X-R,R,!0),X-=R,X===0&&(q--,X=z[q]),F-=R,F===0){Y--;const W=Math.max(Y,0);F=(0,x.getWrappedLineTrimmedLength)(O,W,this._cols)}}for(let R=0;R<O.length;R++)z[R]<v&&O[R].setCell(z[R],k);let I=V-$;for(;I-- >0;)this.ybase===0?this.y<b-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+E)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+V,this.ybase+b-1)}if(N.length>0){const D=[],A=[];for(let q=0;q<this.lines.length;q++)A.push(this.lines.get(q));const O=this.lines.length;let P=O-1,G=0,z=N[G];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+E);let V=0;for(let q=Math.min(this.lines.maxLength-1,O+E-1);q>=0;q--)if(z&&z.start>P+V){for(let X=z.newLines.length-1;X>=0;X--)this.lines.set(q--,z.newLines[X]);q++,D.push({index:P+1,amount:z.newLines.length}),V+=z.newLines.length,z=N[++G]}else this.lines.set(q,A[P--]);let $=0;for(let q=D.length-1;q>=0;q--)D[q].index+=$,this.lines.onInsertEmitter.fire(D[q]),$+=D[q].amount;const H=Math.max(0,O+E-this.lines.maxLength);H>0&&this.lines.onTrimEmitter.fire(H)}}translateBufferLineToString(v,b,k=0,N){const E=this.lines.get(v);return E?E.translateToString(b,k,N):""}getWrappedRangeForLine(v){let b=v,k=v;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;k+1<this.lines.length&&this.lines.get(k+1).isWrapped;)k++;return{first:b,last:k}}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((k=>{b.line-=k,b.line<0&&b.dispose()}))),b.register(this.lines.onInsert((k=>{b.line>=k.index&&(b.line+=k.amount)}))),b.register(this.lines.onDelete((k=>{b.line>=k.index&&b.line<k.index+k.amount&&b.dispose(),b.line>k.index&&(b.line-=k.amount)}))),b.register(b.onDispose((()=>this._removeMarker(b)))),b}_removeMarker(v){this._isClearing||this.markers.splice(this.markers.indexOf(v),1)}}},8437:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLine=u.DEFAULT_ATTR_DATA=void 0;const h=d(3734),p=d(511),m=d(643),g=d(482);u.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let x=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 k=0;k<_;++k)this.setCell(k,b);this.length=_}get(_){const S=this._data[3*_+0],v=2097151&S;return[this._data[3*_+1],2097152&S?this._combined[_]:v?(0,g.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,g.stringFromCodePoint)(2097151&S):""}isProtected(_){return 536870912&this._data[3*_+2]}loadCell(_,S){return x=3*_,S.content=this._data[x+0],S.fg=this._data[x+1],S.bg=this._data[x+2],2097152&S.content&&(S.combinedData=this._combined[_]),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,g.stringFromCodePoint)(S):2097151&b?(this._combined[_]=(0,g.stringFromCodePoint)(2097151&b)+(0,g.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 k=this.length-_-S-1;k>=0;--k)this.setCell(_+S+k,this.loadCell(_+k,b));for(let k=0;k<S;++k)this.setCell(_+k,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 k=0;k<this.length-_-S;++k)this.setCell(_+k,this.loadCell(_+S+k,b));for(let k=this.length-S;k<this.length;++k)this.setCell(k,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 E=parseInt(b[N],10);E>=_&&delete this._combined[E]}const k=Object.keys(this._extendedAttrs);for(let N=0;N<k.length;N++){const E=parseInt(k[N],10);E>=_&&delete this._extendedAttrs[E]}}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,k){const N=_._data;if(k)for(let D=b-1;D>=0;D--){for(let A=0;A<3;A++)this._data[3*(v+D)+A]=N[3*(S+D)+A];268435456&N[3*(S+D)+2]&&(this._extendedAttrs[v+D]=_._extendedAttrs[S+D])}else for(let D=0;D<b;D++){for(let A=0;A<3;A++)this._data[3*(v+D)+A]=N[3*(S+D)+A];268435456&N[3*(S+D)+2]&&(this._extendedAttrs[v+D]=_._extendedAttrs[S+D])}const E=Object.keys(_._combined);for(let D=0;D<E.length;D++){const A=parseInt(E[D],10);A>=S&&(this._combined[A-S+v]=_._combined[A])}}translateToString(_,S,v,b){S=S??0,v=v??this.length,_&&(v=Math.min(v,this.getTrimmedLength())),b&&(b.length=0);let k="";for(;S<v;){const N=this._data[3*S+0],E=2097151&N,D=2097152&N?this._combined[S]:E?(0,g.stringFromCodePoint)(E):m.WHITESPACE_CELL_CHAR;if(k+=D,b)for(let A=0;A<D.length;++A)b.push(S);S+=N>>22||1}return b&&b.push(S),k}}u.BufferLine=w},4841:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.getRangeLength=void 0,u.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:(c,u)=>{function d(h,p,m){if(p===h.length-1)return h[p].getTrimmedLength();const g=!h[p].hasContent(m-1)&&h[p].getWidth(m-1)===1,x=h[p+1].getWidth(0)===2;return g&&x?m-1:m}Object.defineProperty(u,"__esModule",{value:!0}),u.getWrappedLineTrimmedLength=u.reflowSmallerGetNewLineLengths=u.reflowLargerApplyNewLayout=u.reflowLargerCreateNewLayout=u.reflowLargerGetLinesToRemove=void 0,u.reflowLargerGetLinesToRemove=function(h,p,m,g,x){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(g>=C&&g<_){C+=v.length-1;continue}let b=0,k=d(v,b,p),N=1,E=0;for(;N<v.length;){const A=d(v,N,p),O=A-E,P=m-k,G=Math.min(O,P);v[b].copyCellsFrom(v[N],E,k,G,!1),k+=G,k===m&&(b++,k=0),E+=G,E===A&&(N++,E=0),k===0&&b!==0&&v[b-1].getWidth(m-1)===2&&(v[b].copyCellsFrom(v[b-1],m-1,k++,1,!1),v[b-1].setCell(m-1,x))}v[b].replaceCells(k,m,x);let D=0;for(let A=v.length-1;A>0&&(A>b||v[A].getTrimmedLength()===0);A--)D++;D>0&&(w.push(C+v.length-D),w.push(D)),C+=v.length-1}return w},u.reflowLargerCreateNewLayout=function(h,p){const m=[];let g=0,x=p[g],w=0;for(let C=0;C<h.length;C++)if(x===C){const _=p[++g];h.onDeleteEmitter.fire({index:C-w,amount:_}),C+=_-1,w+=_,x=p[++g]}else m.push(C);return{layout:m,countRemoved:w}},u.reflowLargerApplyNewLayout=function(h,p){const m=[];for(let g=0;g<p.length;g++)m.push(h.get(p[g]));for(let g=0;g<m.length;g++)h.set(g,m[g]);h.length=p.length},u.reflowSmallerGetNewLineLengths=function(h,p,m){const g=[],x=h.map(((S,v)=>d(h,v,p))).reduce(((S,v)=>S+v));let w=0,C=0,_=0;for(;_<x;){if(x-_<m){g.push(x-_);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;g.push(b),_+=b}return g},u.getWrappedLineTrimmedLength=d},5295:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferSet=void 0;const h=d(8460),p=d(844),m=d(9092);class g 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)}}u.BufferSet=g},511:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CellData=void 0;const h=d(482),p=d(643),m=d(3734);class g 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 g;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[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()]}}u.CellData=g},643:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WHITESPACE_CELL_CODE=u.WHITESPACE_CELL_WIDTH=u.WHITESPACE_CELL_CHAR=u.NULL_CELL_CODE=u.NULL_CELL_WIDTH=u.NULL_CELL_CHAR=u.CHAR_DATA_CODE_INDEX=u.CHAR_DATA_WIDTH_INDEX=u.CHAR_DATA_CHAR_INDEX=u.CHAR_DATA_ATTR_INDEX=u.DEFAULT_EXT=u.DEFAULT_ATTR=u.DEFAULT_COLOR=void 0,u.DEFAULT_COLOR=0,u.DEFAULT_ATTR=256|u.DEFAULT_COLOR<<9,u.DEFAULT_EXT=0,u.CHAR_DATA_ATTR_INDEX=0,u.CHAR_DATA_CHAR_INDEX=1,u.CHAR_DATA_WIDTH_INDEX=2,u.CHAR_DATA_CODE_INDEX=3,u.NULL_CELL_CHAR="",u.NULL_CELL_WIDTH=1,u.NULL_CELL_CODE=0,u.WHITESPACE_CELL_CHAR=" ",u.WHITESPACE_CELL_WIDTH=1,u.WHITESPACE_CELL_CODE=32},4863:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Marker=void 0;const h=d(8460),p=d(844);class m{get id(){return this._id}constructor(x){this.line=x,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(x){return this._disposables.push(x),x}}u.Marker=m,m._nextId=1},7116:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DEFAULT_CHARSET=u.CHARSETS=void 0,u.CHARSETS={},u.DEFAULT_CHARSET=u.CHARSETS.B,u.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},u.CHARSETS.A={"#":"£"},u.CHARSETS.B=void 0,u.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},u.CHARSETS.C=u.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},u.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},u.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},u.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},u.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},u.CHARSETS.E=u.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},u.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},u.CHARSETS.H=u.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},u.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(c,u)=>{var d,h,p;Object.defineProperty(u,"__esModule",{value:!0}),u.C1_ESCAPED=u.C1=u.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=`
260
+ `,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||(u.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||(u.C1=h={})),(function(m){m.ST=`${d.ESC}\\`})(p||(u.C1_ESCAPED=p={}))},7399:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.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:["'",'"']};u.evaluateKeyboardEvent=function(m,g,x,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=g?h.C0.ESC+"OA":h.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=g?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+(x?"b":"[1;5D"))):C.key=g?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+(x?"f":"[1;5C"))):C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"A",x||C.key!==h.C0.ESC+"[1;3A"||(C.key=h.C0.ESC+"[1;5A")):C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"B",x||C.key!==h.C0.ESC+"[1;3B"||(C.key=h.C0.ESC+"[1;5B")):C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45: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":g?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:C.key=_?h.C0.ESC+"[1;"+(_+1)+"F":g?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(x&&!w||!m.altKey||m.metaKey)!x||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 k=String.fromCharCode(b);m.shiftKey&&(k=k.toUpperCase()),C.key=h.C0.ESC+k}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:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Utf8ToUtf32=u.StringToUtf32=u.utf32ToString=u.stringFromCodePoint=void 0,u.stringFromCodePoint=function(d){return d>65535?(d-=65536,String.fromCharCode(55296+(d>>10))+String.fromCharCode(d%1024+56320)):String.fromCharCode(d)},u.utf32ToString=function(d,h=0,p=d.length){let m="";for(let g=h;g<p;++g){let x=d[g];x>65535?(x-=65536,m+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):m+=String.fromCharCode(x)}return m},u.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,h){const p=d.length;if(!p)return 0;let m=0,g=0;if(this._interim){const x=d.charCodeAt(g++);56320<=x&&x<=57343?h[m++]=1024*(this._interim-55296)+x-56320+65536:(h[m++]=this._interim,h[m++]=x),this._interim=0}for(let x=g;x<p;++x){const w=d.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=p)return this._interim=w,m;const C=d.charCodeAt(x);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}},u.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,g,x,w,C=0,_=0,S=0;if(this.interim[0]){let k=!1,N=this.interim[0];N&=(224&N)==192?31:(240&N)==224?15:7;let E,D=0;for(;(E=63&this.interim[++D])&&D<4;)N<<=6,N|=E;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=A-D;for(;S<O;){if(S>=p)return 0;if(E=d[S++],(192&E)!=128){S--,k=!0;break}this.interim[D++]=E,N<<=6,N|=63&E}k||(A===2?N<128?S--:h[C++]=N:A===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&(g=d[b+1])||128&(x=d[b+2])||128&(w=d[b+3]));)h[C++]=m,h[C++]=g,h[C++]=x,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(g=d[b++],(192&g)!=128){b--;continue}if(_=(31&m)<<6|63&g,_<128){b--;continue}h[C++]=_}else if((240&m)==224){if(b>=p)return this.interim[0]=m,C;if(g=d[b++],(192&g)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=g,C;if(x=d[b++],(192&x)!=128){b--;continue}if(_=(15&m)<<12|(63&g)<<6|63&x,_<2048||_>=55296&&_<=57343||_===65279)continue;h[C++]=_}else if((248&m)==240){if(b>=p)return this.interim[0]=m,C;if(g=d[b++],(192&g)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=g,C;if(x=d[b++],(192&x)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=g,this.interim[2]=x,C;if(w=d[b++],(192&w)!=128){b--;continue}if(_=(7&m)<<18|(63&g)<<12|(63&x)<<6|63&w,_<65536||_>1114111)continue;h[C++]=_}}return C}}},225:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.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 g;u.UnicodeV6=class{constructor(){if(this.version="6",!g){g=new Uint8Array(65536),g.fill(1),g[0]=0,g.fill(0,1,32),g.fill(0,127,160),g.fill(2,4352,4448),g[9001]=2,g[9002]=2,g.fill(2,11904,42192),g[12351]=1,g.fill(2,44032,55204),g.fill(2,63744,64256),g.fill(2,65040,65050),g.fill(2,65072,65136),g.fill(2,65280,65377),g.fill(2,65504,65511);for(let x=0;x<p.length;++x)g.fill(0,p[x][0],p[x][1]+1)}}wcwidth(x){return x<32?0:x<127?1:x<65536?g[x]:(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})(x,m)?0:x>=131072&&x<=196605||x>=196608&&x<=262141?2:1}charProperties(x,w){let C=this.wcwidth(x),_=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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WriteBuffer=void 0;const h=d(8460),p=d(844);class m extends p.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const _=this._callbacks.shift();_&&_()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w)}_innerWrite(x=0,w=!0){const C=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const _=this._writeBuffer[this._bufferOffset],S=this._action(_,w);if(S){const b=k=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,k))):this._innerWrite(C,k);return void S.catch((k=>(queueMicrotask((()=>{throw k})),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()}}u.WriteBuffer=m},5941:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.toRgbString=u.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,g){const x=m.toString(16),w=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}u.parseColor=function(m){if(!m)return;let g=m.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const x=d.exec(g);if(x){const w=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/w*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/w*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/w*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),h.exec(g)&&[3,6,9,12].includes(g.length))){const x=g.length/3,w=[0,0,0];for(let C=0;C<3;++C){const _=parseInt(g.slice(x*C,x*C+x),16);w[C]=x===1?_<<4:x===2?_:x===3?_>>4:_>>8}return w}},u.toRgbString=function(m,g=16){const[x,w,C]=m;return`rgb:${p(x,g)}/${p(w,g)}/${p(C,g)}`}},5770:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.PAYLOAD_LIMIT=void 0,u.PAYLOAD_LIMIT=1e7},6351:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DcsHandler=u.DcsParser=void 0;const h=d(482),p=d(8742),m=d(5770),g=[];u.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const _=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=g,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||g,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=g,this._ident=0}};const x=new p.Params;x.addParam(0),u.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=x,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():x,this._data="",this._hitLimit=!1}put(w,C,_){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=x,this._data="",this._hitLimit=!1,_)));return this._params=x,this._data="",this._hitLimit=!1,C}}},2015:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.EscapeSequenceParser=u.VT500_TRANSITION_TABLE=u.TransitionTable=void 0;const h=d(844),p=d(8742),m=d(6242),g=d(6351);class x{constructor(S){this.table=new Uint8Array(S)}setDefault(S,v){this.table.fill(S<<4|v)}add(S,v,b,k){this.table[v<<8|S]=b<<4|k}addMany(S,v,b,k){for(let N=0;N<S.length;N++)this.table[v<<8|S[N]]=b<<4|k}}u.TransitionTable=x;const w=160;u.VT500_TRANSITION_TABLE=(function(){const _=new x(4095),S=Array.apply(null,Array(256)).map(((D,A)=>A)),v=(D,A)=>S.slice(D,A),b=v(32,127),k=v(0,24);k.push(25),k.push.apply(k,v(28,32));const N=v(0,14);let E;for(E in _.setDefault(1,0),_.addMany(b,0,2,0),N)_.addMany([24,26,153,154],E,3,0),_.addMany(v(128,144),E,3,0),_.addMany(v(144,152),E,3,0),_.add(156,E,0,0),_.add(27,E,11,1),_.add(157,E,4,8),_.addMany([152,158,159],E,0,7),_.add(155,E,11,3),_.add(144,E,11,9);return _.addMany(k,0,3,0),_.addMany(k,1,3,1),_.add(127,1,0,1),_.addMany(k,8,0,8),_.addMany(k,3,3,3),_.add(127,3,0,3),_.addMany(k,4,3,4),_.add(127,4,0,4),_.addMany(k,6,3,6),_.addMany(k,5,3,5),_.add(127,5,0,5),_.addMany(k,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(k,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(k,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(k,11,0,11),_.addMany(v(32,128),11,0,11),_.addMany(v(28,32),11,0,11),_.addMany(k,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(k,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(k,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=u.VT500_TRANSITION_TABLE){super(),this._transitions=S,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(v,b,k)=>{},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 g.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 E=S.intermediates.charCodeAt(N);if(32>E||E>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");b<<=8,b|=E}}if(S.final.length!==1)throw new Error("final must be a single byte");const k=S.final.charCodeAt(0);if(v[0]>k||k>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return b<<=8,b|=k,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 k=this._escHandlers[b];return k.push(v),{dispose:()=>{const N=k.indexOf(v);N!==-1&&k.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 k=this._csiHandlers[b];return k.push(v),{dispose:()=>{const N=k.indexOf(v);N!==-1&&k.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,k,N){this._parseStack.state=S,this._parseStack.handlers=v,this._parseStack.handlerPos=b,this._parseStack.transition=k,this._parseStack.chunkPos=N}parse(S,v,b){let k,N=0,E=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 A=this._parseStack.handlers;let O=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(b===!1&&O>-1){for(;O>=0&&(k=A[O](this._params),k!==!0);O--)if(k instanceof Promise)return this._parseStack.handlerPos=O,k}this._parseStack.handlers=[];break;case 4:if(b===!1&&O>-1){for(;O>=0&&(k=A[O](),k!==!0);O--)if(k instanceof Promise)return this._parseStack.handlerPos=O,k}this._parseStack.handlers=[];break;case 6:if(N=S[this._parseStack.chunkPos],k=this._dcsParser.unhook(N!==24&&N!==26,b),k)return k;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],k=this._oscParser.end(N!==24&&N!==26,b),k)return k;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 A=D;A<v;++A){switch(N=S[A],E=this._transitions.table[this.currentState<<8|(N<160?N:w)],E>>4){case 2:for(let V=A+1;;++V){if(V>=v||(N=S[V])<32||N>126&&N<w){this._printHandler(S,A,V),A=V-1;break}if(++V>=v||(N=S[V])<32||N>126&&N<w){this._printHandler(S,A,V),A=V-1;break}if(++V>=v||(N=S[V])<32||N>126&&N<w){this._printHandler(S,A,V),A=V-1;break}if(++V>=v||(N=S[V])<32||N>126&&N<w){this._printHandler(S,A,V),A=V-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:A,code:N,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const O=this._csiHandlers[this._collect<<8|N];let P=O?O.length-1:-1;for(;P>=0&&(k=O[P](this._params),k!==!0);P--)if(k instanceof Promise)return this._preserveStack(3,O,P,E,A),k;P<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(++A<v&&(N=S[A])>47&&N<60);A--;break;case 9:this._collect<<=8,this._collect|=N;break;case 10:const G=this._escHandlers[this._collect<<8|N];let z=G?G.length-1:-1;for(;z>=0&&(k=G[z](),k!==!0);z--)if(k instanceof Promise)return this._preserveStack(4,G,z,E,A),k;z<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 V=A+1;;++V)if(V>=v||(N=S[V])===24||N===26||N===27||N>127&&N<w){this._dcsParser.put(S,A,V),A=V-1;break}break;case 14:if(k=this._dcsParser.unhook(N!==24&&N!==26),k)return this._preserveStack(6,[],0,E,A),k;N===27&&(E|=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 V=A+1;;V++)if(V>=v||(N=S[V])<32||N>127&&N<w){this._oscParser.put(S,A,V),A=V-1;break}break;case 6:if(k=this._oscParser.end(N!==24&&N!==26),k)return this._preserveStack(5,[],0,E,A),k;N===27&&(E|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&E}}}u.EscapeSequenceParser=C},6242:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OscHandler=u.OscParser=void 0;const h=d(5770),p=d(482),m=[];u.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(g,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const w=this._handlers[g];return w.push(x),{dispose:()=>{const C=w.indexOf(x);C!==-1&&w.splice(C,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,x,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(g,x,w);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(g,x,w))}start(){this.reset(),this._state=1}put(g,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const C=g[x++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-x>0&&this._put(g,x,w)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,_=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=x,_=this._stack.fallThrough,this._stack.paused=!1),!_&&w===!1){for(;C>=0&&(w=this._active[C].end(g),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",g);this._active=m,this._id=-1,this._state=0}}},u.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,x,w){this._hitLimit||(this._data+=(0,p.utf32ToString)(g,x,w),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,x}}},8742:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Params=void 0;const d=2147483647;class h{static fromArray(m){const g=new h;if(!m.length)return g;for(let x=Array.isArray(m[0])?1:0;x<m.length;++x){const w=m[x];if(Array.isArray(w))for(let C=0;C<w.length;++C)g.addSubParam(w[C]);else g.addParam(w)}return g}constructor(m=32,g=32){if(this.maxLength=m,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(g),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 g=0;g<this.length;++g){m.push(this.params[g]);const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&m.push(Array.prototype.slice.call(this._subParams,x,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 g=this._subParamsIdx[m]>>8,x=255&this._subParamsIdx[m];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const m={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&(m[g]=this._subParams.slice(x,w))}return m}addDigit(m){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[g-1];x[g-1]=~w?Math.min(10*w+m,d):m}}u.Params=h},5741:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.AddonManager=void 0,u.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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferApiView=void 0;const h=d(3785),p=d(511);u.BufferApiView=class{constructor(m,g){this._buffer=m,this.type=g}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 g=this._buffer.lines.get(m);if(g)return new h.BufferLineApiView(g)}getNullCell(){return new p.CellData}}},3785:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLineApiView=void 0;const h=d(511);u.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,g){return this._line.translateToString(p,m,g)}}},8285:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferNamespaceApi=void 0;const h=d(8771),p=d(8460),m=d(844);class g 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)}}u.BufferNamespaceApi=g},7975:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ParserApi=void 0,u.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:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeApi=void 0,u.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(c,u,d){var h=this&&this.__decorate||function(_,S,v,b){var k,N=arguments.length,E=N<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,v):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(_,S,v,b);else for(var D=_.length-1;D>=0;D--)(k=_[D])&&(E=(N<3?k(E):N>3?k(S,v,E):k(S,v))||E);return N>3&&E&&Object.defineProperty(S,v,E),E},p=this&&this.__param||function(_,S){return function(v,b){S(v,b,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferService=u.MINIMUM_ROWS=u.MINIMUM_COLS=void 0;const m=d(8460),g=d(844),x=d(5295),w=d(2585);u.MINIMUM_COLS=2,u.MINIMUM_ROWS=1;let C=u.BufferService=class extends g.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,u.MINIMUM_COLS),this.rows=Math.max(_.rawOptions.rows||0,u.MINIMUM_ROWS),this.buffers=this.register(new x.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 k=v.ybase+v.scrollTop,N=v.ybase+v.scrollBottom;if(v.scrollTop===0){const E=v.lines.isFull;N===v.lines.length-1?E?v.lines.recycle().copyFrom(b):v.lines.push(b.clone()):v.lines.splice(N+1,0,b.clone()),E?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const E=N-k+1;v.lines.shiftElements(k+1,E-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 k=b.ydisp;b.ydisp=Math.max(Math.min(b.ydisp+_,b.ybase),0),k!==b.ydisp&&(S||this._onScroll.fire(b.ydisp))}};u.BufferService=C=h([p(0,w.IOptionsService)],C)},7994:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CharsetService=void 0,u.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(d){this.glevel=d,this.charset=this._charsets[d]}setgCharset(d,h){this._charsets[d]=h,this.glevel===d&&(this.charset=h)}}},1753:function(c,u,d){var h=this&&this.__decorate||function(b,k,N,E){var D,A=arguments.length,O=A<3?k:E===null?E=Object.getOwnPropertyDescriptor(k,N):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(b,k,N,E);else for(var P=b.length-1;P>=0;P--)(D=b[P])&&(O=(A<3?D(O):A>3?D(k,N,O):D(k,N))||O);return A>3&&O&&Object.defineProperty(k,N,O),O},p=this&&this.__param||function(b,k){return function(N,E){k(N,E,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreMouseService=void 0;const m=d(2585),g=d(8460),x=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,k){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||k||(N|=3)),N}const _=String.fromCharCode,S={DEFAULT:b=>{const k=[C(b,!1)+32,b.col+32,b.row+32];return k[0]>255||k[1]>255||k[2]>255?"":`\x1B[M${_(k[0])}${_(k[1])}${_(k[2])}`},SGR:b=>{const k=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.col};${b.row}${k}`},SGR_PIXELS:b=>{const k=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.x};${b.y}${k}`}};let v=u.CoreMouseService=class extends x.Disposable{constructor(b,k){super(),this._bufferService=b,this._coreService=k,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const 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,k){this._protocols[b]=k}addEncoding(b,k){this._encodings[b]=k}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 k=this._encodings[this._activeEncoding](b);return k&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(k):this._coreService.triggerDataEvent(k,!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,k,N){if(N){if(b.x!==k.x||b.y!==k.y)return!1}else if(b.col!==k.col||b.row!==k.row)return!1;return b.button===k.button&&b.action===k.action&&b.ctrl===k.ctrl&&b.alt===k.alt&&b.shift===k.shift}};u.CoreMouseService=v=h([p(0,m.IBufferService),p(1,m.ICoreService)],v)},6975:function(c,u,d){var h=this&&this.__decorate||function(v,b,k,N){var E,D=arguments.length,A=D<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,k):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,k,N);else for(var O=v.length-1;O>=0;O--)(E=v[O])&&(A=(D<3?E(A):D>3?E(b,k,A):E(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(v,b){return function(k,N){b(k,N,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreService=void 0;const m=d(1439),g=d(8460),x=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=u.CoreService=class extends x.Disposable{constructor(v,b,k){super(),this._bufferService=v,this._logService=b,this._optionsService=k,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,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 k=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&k.ybase!==k.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))}};u.CoreService=S=h([p(0,w.IBufferService),p(1,w.ILogService),p(2,w.IOptionsService)],S)},9074:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DecorationService=void 0;const h=d(8055),p=d(8460),m=d(844),g=d(6106);let x=0,w=0;class C extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.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 k=b.marker.onDispose((()=>b.dispose()));b.onDispose((()=>{b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),k.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,k){let N=0,E=0;for(const D of this._decorations.getKeyIterator(b))N=D.options.x??0,E=N+(D.options.width??1),v>=N&&v<E&&(!k||(D.options.layer??"bottom")===k)&&(yield D)}forEachDecorationAtCell(v,b,k,N){this._decorations.forEachByKey(b,(E=>{x=E.options.x??0,w=x+(E.options.width??1),v>=x&&v<w&&(!k||(E.options.layer??"bottom")===k)&&N(E)}))}}u.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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.InstantiationService=u.ServiceCollection=void 0;const h=d(2585),p=d(8343);class m{constructor(...x){this._entries=new Map;for(const[w,C]of x)this.set(w,C)}set(x,w){const C=this._entries.get(x);return this._entries.set(x,w),C}forEach(x){for(const[w,C]of this._entries.entries())x(w,C)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}u.ServiceCollection=m,u.InstantiationService=class{constructor(){this._services=new m,this._services.set(h.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const w=(0,p.getServiceDependencies)(g).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] ${g.name} depends on UNKNOWN service ${S.id}.`);C.push(v)}const _=w.length>0?w[0].index:x.length;if(x.length!==_)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${_+1} conflicts with ${x.length} static arguments`);return new g(...x,...C)}}},7866:function(c,u,d){var h=this&&this.__decorate||function(_,S,v,b){var k,N=arguments.length,E=N<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,v):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(_,S,v,b);else for(var D=_.length-1;D>=0;D--)(k=_[D])&&(E=(N<3?k(E):N>3?k(S,v,E):k(S,v))||E);return N>3&&E&&Object.defineProperty(S,v,E),E},p=this&&this.__param||function(_,S){return function(v,b){S(v,b,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.traceCall=u.setTraceLogger=u.LogService=void 0;const m=d(844),g=d(2585),x={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let w,C=u.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(_){super(),this._optionsService=_,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(_){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<=g.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<=g.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<=g.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<=g.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<=g.LogLevelEnum.ERROR&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.error.bind(this._optionsService.options.logger))??console.error,_,S)}};u.LogService=C=h([p(0,g.IOptionsService)],C),u.setTraceLogger=function(_){w=_},u.traceCall=function(_,S,v){if(typeof v.value!="function")throw new Error("not supported");const b=v.value;v.value=function(...k){if(w.logLevel!==g.LogLevelEnum.TRACE)return b.apply(this,k);w.trace(`GlyphRenderer#${b.name}(${k.map((E=>JSON.stringify(E))).join(", ")})`);const N=b.apply(this,k);return w.trace(`GlyphRenderer#${b.name} return`,N),N}}},7302:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OptionsService=u.DEFAULT_OPTIONS=void 0;const h=d(8460),p=d(844),m=d(6114);u.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:m.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends p.Disposable{constructor(C){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const _={...u.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 u.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},_=(S,v)=>{if(!(S in u.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(_||(_=u.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":_||(_=u.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof _=="number"&&1<=_&&_<=1e3)break;_=g.includes(_)?_:u.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 _}}u.OptionsService=x},2660:function(c,u,d){var h=this&&this.__decorate||function(x,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(x,w,C,_);else for(var k=x.length-1;k>=0;k--)(S=x[k])&&(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(x,w){return function(C,_){w(C,_,x)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkService=void 0;const m=d(2585);let g=u.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const w=this._bufferService.buffer;if(x.id===void 0){const k=w.addMarker(w.ybase+w.y),N={data:x,id:this._nextId++,lines:[k]};return k.onDispose((()=>this._removeMarkerFromLink(N,k))),this._dataByLinkId.set(N.id,N),N.id}const C=x,_=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(x,w){const C=this._dataByLinkId.get(x);if(C&&C.lines.every((_=>_.line!==w))){const _=this._bufferService.buffer.addMarker(w);C.lines.push(_),_.onDispose((()=>this._removeMarkerFromLink(C,_)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))==null?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const C=x.lines.indexOf(w);C!==-1&&(x.lines.splice(C,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};u.OscLinkService=g=h([p(0,m.IBufferService)],g)},8343:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createDecorator=u.getServiceDependencies=u.serviceRegistry=void 0;const d="di$target",h="di$dependencies";u.serviceRegistry=new Map,u.getServiceDependencies=function(p){return p[h]||[]},u.createDecorator=function(p){if(u.serviceRegistry.has(p))return u.serviceRegistry.get(p);const m=function(g,x,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,g,w)};return m.toString=()=>p,u.serviceRegistry.set(p,m),m}},2585:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.IDecorationService=u.IUnicodeService=u.IOscLinkService=u.IOptionsService=u.ILogService=u.LogLevelEnum=u.IInstantiationService=u.ICharsetService=u.ICoreService=u.ICoreMouseService=u.IBufferService=void 0;const h=d(8343);var p;u.IBufferService=(0,h.createDecorator)("BufferService"),u.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),u.ICoreService=(0,h.createDecorator)("CoreService"),u.ICharsetService=(0,h.createDecorator)("CharsetService"),u.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(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||(u.LogLevelEnum=p={})),u.ILogService=(0,h.createDecorator)("LogService"),u.IOptionsService=(0,h.createDecorator)("OptionsService"),u.IOscLinkService=(0,h.createDecorator)("OscLinkService"),u.IUnicodeService=(0,h.createDecorator)("UnicodeService"),u.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeService=void 0;const h=d(8460),p=d(225);class m{static extractShouldJoin(x){return(1&x)!=0}static extractWidth(x){return x>>1&3}static extractCharKind(x){return x>>3}static createPropertyValue(x,w,C=!1){return(16777215&x)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new h.EventEmitter,this.onChange=this._onChange.event;const x=new p.UnicodeV6;this.register(x),this._active=x.version,this._activeProvider=x}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(x){if(!this._providers[x])throw new Error(`unknown Unicode version "${x}"`);this._active=x,this._activeProvider=this._providers[x],this._onChange.fire(x)}register(x){this._providers[x.version]=x}wcwidth(x){return this._activeProvider.wcwidth(x)}getStringCellWidth(x){let w=0,C=0;const _=x.length;for(let S=0;S<_;++S){let v=x.charCodeAt(S);if(55296<=v&&v<=56319){if(++S>=_)return w+this.wcwidth(v);const N=x.charCodeAt(S);56320<=N&&N<=57343?v=1024*(v-55296)+N-56320+65536:w+=this.wcwidth(N)}const b=this.charProperties(v,C);let k=m.extractWidth(b);m.extractShouldJoin(b)&&(k-=m.extractWidth(C)),w+=k,C=b}return w}charProperties(x,w){return this._activeProvider.charProperties(x,w)}}u.UnicodeService=m}},r={};function a(c){var u=r[c];if(u!==void 0)return u.exports;var d=r[c]={exports:{}};return n[c].call(d.exports,d,d.exports,a),d.exports}var l={};return(()=>{var c=l;Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const u=a(9042),d=a(3236),h=a(844),p=a(5741),m=a(8285),g=a(7975),x=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=k=>this._core.options[k],b=(k,N)=>{this._checkReadonlyOptions(k),this._core.options[k]=N};for(const k in this._core.options){const N={get:v.bind(this,k),set:b.bind(this,k)};Object.defineProperty(this._publicOptions,k,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 g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new 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
261
+ `,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 u}_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")}}c.Terminal=C})(),l})()))})(hx)),hx.exports}var ZF=QF();/**
262
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
263
+ * @license MIT
264
+ *
265
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
266
+ * @license MIT
267
+ *
268
+ * Originally forked from (with the author's permission):
269
+ * Fabrice Bellard's javascript vt100 for jslinux:
270
+ * http://bellard.org/jslinux/
271
+ * Copyright (c) 2011 Fabrice Bellard
272
+ */var e7=2,t7=1,n7=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),c={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},u=c.top+c.bottom,d=c.right+c.left,h=r-u,p=a-d-t;return{cols:Math.max(e7,Math.floor(p/e.css.cell.width)),rows:Math.max(t7,Math.floor(h/e.css.cell.height))}}};function r7({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=j.useRef(null),l=j.useRef(e),c=j.useRef(null),u=j.useRef(null),d=os(m=>m.writeSession),h=os(m=>m.resizeSession),p=Lt(m=>m.settings[Ee.DISPLAY_TERMINAL_FONT]??yh);return j.useEffect(()=>{l.current=e},[e]),j.useEffect(()=>{Lt.getState().getSetting(Ee.DISPLAY_TERMINAL_FONT)},[]),j.useEffect(()=>{if(!n)return;const m=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),j.useEffect(()=>{if(!a.current)return;const m=new ZF.Terminal({fontFamily:p,fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new n7;m.loadAddon(g),c.current={term:m,fitAddon:g},a.current.addEventListener("keydown",_=>{_.key==="Escape"&&n&&(_.preventDefault(),_.stopPropagation(),n())}),m.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),g.fit(),r&&setTimeout(()=>{m.focus()},150);const w=new ResizeObserver(()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{requestAnimationFrame(()=>{var S;g.fit&&g.fit();const _=(S=c.current)==null?void 0:S.term;_&&_.cols>0&&_.rows>0&&h(l.current,_.cols,_.rows)})},100)});w.observe(a.current),m.onData(_=>{if(_==="\x1B"&&n){n();return}d(l.current,_)}),m.onKey(_=>{_.key==="\x1B"&&n&&(_.domEvent.stopPropagation(),n())});const C=Bt.subscribe(_=>{const S=_.payload;if(_.type==="terminal.output"&&(S==null?void 0:S.sessionId)===l.current){const v=S==null?void 0:S.data;v&&m.write(v)}});return()=>{C(),w.disconnect(),u.current&&clearTimeout(u.current),m.dispose(),c.current=null}},[e,d,h]),j.useEffect(()=>{const m=c.current;if(!m)return;m.term.options.fontFamily=p,m.fitAddon.fit();const{cols:g,rows:x}=m.term;g>0&&x>0&&h(l.current,g,x)},[p,h]),s.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[s.jsx("div",{}),s.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:s.jsx(Yy,{})})]}),s.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:m=>{m.key==="Escape"&&n&&(m.preventDefault(),m.stopPropagation(),n())}})]})}const FN="openfox-chat-textarea";function cu(e){if(!zt())return;const t=document.getElementById(FN);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function s7(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 i7({isOpen:e,onClose:t}){const n=os(C=>C.createSession),r=os(C=>C.killSession),a=os(C=>C.sessions),l=os(C=>C.setWorkdir),c=os(C=>C.fetchSessions),u=Yt(C=>C.currentProject),d=Re(C=>C.currentSession),[h,p]=j.useState(!0),m=j.useRef(null),g=j.useRef(!1),x=j.useRef(!1),w=j.useCallback(()=>{t()},[t]);return j.useEffect(()=>{const C=(d==null?void 0:d.workspace)??(u==null?void 0:u.workdir);C&&l(C)},[d==null?void 0:d.workspace,u==null?void 0:u.workdir,l]),j.useEffect(()=>{e?(p(!0),c(u==null?void 0:u.id).finally(()=>p(!1))):cu()},[e,c,u==null?void 0:u.id]),j.useEffect(()=>{e&&a.length===0&&!h&&!x.current&&(x.current=!0,n(void 0,(d==null?void 0:d.projectId)??(u==null?void 0:u.id)))},[e,a.length,h,n,d==null?void 0:d.projectId,u==null?void 0:u.id]),j.useEffect(()=>{e?(g.current=!0,setTimeout(()=>{var C;zt()&&((C=m.current)==null||C.focus()),setTimeout(()=>{g.current=!1},200)},100)):x.current=!1},[e]),j.useEffect(()=>{if(!e)return;const C=_=>{g.current||_.key==="Escape"&&(_.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:w}),s.jsxs("div",{ref: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:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(u==null?void 0:u.id)),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:s.jsx(K5,{})}),s.jsx("button",{onClick:t,className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:s.jsx(ea,{})})]})]}),s.jsx(dt,{className:"flex-1 min-h-0 p-2",children:h?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"mb-4",children:"No terminal sessions"}),s.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(u==null?void 0:u.id)),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):s.jsx("div",{className:`grid ${s7(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>s.jsx(r7,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1&&zt()},C.id))})})]})]}):null}function jl({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",align:a="left",isOpen:l,onOpenChange:c,labelActionClassName:u}){const[d,h]=j.useState(!1),p=l!==void 0,m=p?l:d,g=H=>{if(p){const q=typeof H=="function"?H(d):H;c==null||c(q)}else h(H)},[x,w]=j.useState(null),C=j.useRef(null),_=j.useRef(null),[S,v]=j.useState(0),b=j.useRef(0),k=j.useMemo(()=>[...e,...t],[e,t]),N=j.useRef(k),E=j.useCallback(()=>{if(!C.current)return;const H=C.current.getBoundingClientRect(),q=200,X=Number.parseInt(r,10)||120,F=window.innerHeight-H.bottom<q;w({top:F?H.top-q-4:H.bottom+4,left:a==="right"?H.right-X:H.left,alignToTop:F})},[a,r]);j.useEffect(()=>{N.current=k},[k]),j.useEffect(()=>{function H(q){if(_.current){const X=q.target;_.current.contains(X)||g(!1)}}return m&&document.addEventListener("mousedown",H),()=>{document.removeEventListener("mousedown",H)}},[m]),j.useEffect(()=>{m&&E()},[m,E]),j.useEffect(()=>{if(!m)return;setTimeout(()=>{var q;(q=_.current)==null||q.focus()},0);function H(q){const X=N.current,Y=X.filter(I=>!D(I)),F=A(b.current,X);switch(q.key){case"ArrowDown":if(q.preventDefault(),q.stopPropagation(),F<Y.length-1){const I=O(b.current+1,X);b.current=I,v(I)}break;case"ArrowUp":if(q.preventDefault(),q.stopPropagation(),F>0){const I=P(b.current-1,X);b.current=I,v(I)}break;case"Enter":q.preventDefault(),q.stopPropagation(),G(b.current,X);break;case"Escape":q.preventDefault(),q.stopPropagation(),g(!1);break}}return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[m,k]);function D(H){var Y;const q=H.label;return q?String(((Y=q.props)==null?void 0:Y.className)??"").includes("cursor-default"):!1}function A(H,q){let X=0;for(let Y=0;Y<H;Y++){const F=q[Y];F&&!D(F)&&X++}return X}function O(H,q){for(let X=H;X<q.length;X++){const Y=q[X];if(Y&&!D(Y))return X}return H}function P(H,q){for(let X=H;X>=0;X--){const Y=q[X];if(Y&&!D(Y))return X}return H}function G(H,q){var Y;const X=q[H];!X||D(X)||((Y=X.onClick)==null||Y.call(X),X.href&&(window.history.pushState(null,"",X.href),window.dispatchEvent(new PopStateEvent("popstate"))),g(!1))}j.useEffect(()=>{m&&(v(k.findIndex(H=>!D(H))),b.current=k.findIndex(H=>!D(H)))},[m,k]);const z=H=>{H.stopPropagation(),m||E(),g(!m)};function V(H,q,X,Y){const I=!D(H)&&Y===S,R=s.jsxs(s.Fragment,{children:[H.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:H.icon}),s.jsx("span",{className:"min-w-0",children:H.label})]}),B=q!==X-1?"border-b border-border":"",Q=`px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${H.danger?"text-accent-error hover:bg-accent-error/10":I?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,J=H.href?s.jsx(yr,{href:H.href,onClick:U=>{var M;(M=H.onClick)==null||M.call(H,U),g(!1)},onAuxClick:()=>g(!1),className:`w-full ${Q}`,children:R}):s.jsx("button",{onClick:U=>{var M;(M=H.onClick)==null||M.call(H,U),H.closeOnClick!==!1&&g(!1)},className:`w-full ${Q}`,children:R});return H.labelAction?s.jsxs("div",{className:`flex items-center gap-1 pr-1 ${B} ${u??""}`,children:[J,s.jsx("span",{className:"flex-shrink-0",children:H.labelAction})]},Y):s.jsx("div",{className:B,children:J},Y)}const $=x&&s.jsxs("div",{ref:_,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${x.alignToTop?"mb-1":"mt-1"}`,style:{top:x.top,left:x.left,minWidth:r},tabIndex:-1,children:[s.jsx(dt,{className:"max-h-[60vh]",children:e.map((H,q)=>V(H,q,e.length,q))}),t.length>0&&s.jsx("div",{className:"border-t border-border",children:t.map((H,q)=>V(H,q,t.length,e.length+q))})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative",children:s.jsx("div",{ref:C,onClick:z,children:n})}),m&&mi.createPortal($,document.body)]})}function a7(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 UN({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,l]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(null);j.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const k=await(await xe("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:k.sudoAvailable,userInGroup:k.userInGroup,groupHasWrite:k.groupHasWrite,groupName:k.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=j.useCallback(async b=>{l(!0),u(null);try{const N=await(await xe("/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?u("Failed to fix permissions: "+(N.error||"Unknown error")):u(`Passwordless sudo is not available. Please fix permissions manually:
273
+
274
+ `+(b==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(k){u("Failed to fix permissions: "+(k instanceof Error?k.message:"Unknown error"))}finally{l(!1)}},[n,r,t]),g=(d==null?void 0:d.userInGroup)??!1,x=(d==null?void 0:d.groupHasWrite)??!1,w=(d==null?void 0:d.sudoAvailable)??!1,C=(d==null?void 0:d.groupName)??"",_=g&&!x,S=!g&&x,v=!g&&!x;return s.jsx(St,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-sm text-text-secondary",children:[s.jsx("p",{children:_?s.jsxs(s.Fragment,{children:["The group ",s.jsx("strong",{children:C})," doesn't have write access:"]}):S?s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C}),":"]}):s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C})," and it doesn't have write access:"]})}),s.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),c?s.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:c}):d?s.jsxs("div",{className:"flex flex-col gap-2",children:[_&&s.jsxs(s.Fragment,{children:[s.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),v&&s.jsxs(s.Fragment,{children:[s.jsx(rt,{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"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",s.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!c&&s.jsxs("div",{className:"text-xs text-text-secondary",children:[s.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),s.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),s.jsx("div",{className:"flex justify-end",children:s.jsx(rt,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function VN({isOpen:e,onClose:t}){const[,n]=Ln(),r=Yt(N=>N.listProjects),[a,l]=j.useState(""),[c,u]=j.useState(null),[d,h]=j.useState(!1),[p,m]=j.useState(""),[g,x]=j.useState(null),w=j.useRef(null);j.useEffect(()=>{e&&(xe("/api/config").then(N=>N.json()).then(N=>{N.workdir&&m(N.workdir)}),l(""),u(null),h(!1),x(null),setTimeout(()=>{var N;zt()&&((N=w.current)==null||N.focus())},100))},[e]);const C=j.useCallback(async N=>{N.preventDefault();const E=a7(a);if(!E.valid){u(E.error);return}const D=`${p}/${a}`;await v(D)},[a,n,t,p]),_=j.useCallback(()=>{x(null)},[]),S=j.useCallback(async()=>{const N=`${p}/${a}`;await v(N)},[p,a,n,t,x,u,h]);async function v(N){h(!0),u(null),x(null);try{const E=await xe("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:N})});if(!E.ok){const O=await E.json().catch(()=>({}));if(O.code==="EACCES"){x(N),h(!1);return}throw new Error(O.error||"Failed to create project")}const A=(await E.json()).project;t(),await r(),n(`/p/${A.id}`)}catch(E){u(E instanceof Error?E.message:"Failed to create project"),h(!1)}}const b=j.useCallback(()=>{l(""),u(null),t()},[t]),k=a?`${p}/${a}`:"";return s.jsxs(s.Fragment,{children:[s.jsx(St,{isOpen:e,onClose:b,title:"Create New Project",size:"sm",children:s.jsxs("form",{onSubmit:C,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),s.jsx(Ns,{ref:w,id:"project-name",value:a,onChange:N=>{l(N.target.value),u(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),a&&s.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",s.jsx("span",{className:"font-mono",children:k})]}),c&&s.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:c})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(rt,{type:"button",variant:"secondary",onClick:b,disabled:d,children:"Cancel"}),s.jsx(rt,{type:"submit",variant:"primary",disabled:d||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(es,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&s.jsx(UN,{isOpen:!!g,onClose:_,path:g,onRetry:S})]})}function GN(){return en(e=>e.workdir)}function $C({projects:e,currentProject:t}){const[,n]=Ln(),r=Yt(_=>_.loadProject),a=Yt(_=>_.toggleStar),l=Yt(_=>_.createProject),c=Yt(_=>_.listProjects),[u,d]=j.useState(!1),[h,p]=j.useState(!1),m=GN(),g=j.useCallback(async _=>{const S=mu(_),v=await l(S,_);return v&&"id"in v?(await c(),p(!1),n(`/p/${v.id}`),!0):!1},[l,c,n]),w=j.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:s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsx("span",{className:"truncate flex-1",children:_.name}),s.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?s.jsx(Zc,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Cf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:_.id===(t==null?void 0:t.id)?s.jsx(Rs,{}):void 0,href:`/p/${_.id}`,closeOnClick:!0,onClick:()=>{r(_.id)}})),C=[{label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qr,{className:"w-4 h-4"}),s.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:s.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[s.jsx(es,{className:"w-4 h-4"}),s.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(jl,{items:w,footerItems:C,trigger:s.jsxs("button",{className:`text-text-secondary hover:text-text-primary text-sm truncate flex items-center gap-1 ${t?"hover:underline":""}`,title:(t==null?void 0:t.name)??"Select project",children:[(t==null?void 0:t.name)??s.jsx("span",{className:"text-text-muted",children:"Select project..."}),s.jsx(pn,{})]}),minWidth:"250px"}),u&&s.jsx(VN,{isOpen:u,onClose:()=>d(!1)}),h&&s.jsx(Ef,{initialPath:m??void 0,onSelect:g,onClose:()=>p(!1)})]})}function WN(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"),c=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${l}/${c}`}function Kf(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function o7(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)),c=Kf(e);if(l===0)return`today ${c}`;if(l===1)return`yesterday ${c}`;if(l<7)return`${l} days ago ${c}`;{const u=t.getFullYear(),d=String(t.getMonth()+1).padStart(2,"0"),h=String(t.getDate()).padStart(2,"0");return`${u}/${d}/${h} ${c}`}}function qN(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 l7(e){const{year:t,month:n,day:r}=qN(e);return`${t}-${n}-${r}`}function KN(e){const t=new Map;for(const a of e){const l=l7(a.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(a)}for(const[a,l]of t)l.sort((c,u)=>{const d=new Date(c.updatedAt).getTime();return new Date(u.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 c7(e){const{year:t,month:n,day:r}=qN(e);return`${t}/${n}/${r} ${Kf(e)}`}function Yh(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function u7({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var w;const l=Re(C=>C.loadSession),c=Re(C=>C.toggleFavorite),u=50,d=e.filter(C=>C.projectId===t.id).slice(0,15),h=d.filter(C=>C.isFavorite),p=d.filter(C=>!C.isFavorite),m=j.useMemo(()=>{const C=[];C.push({label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(es,{className:"w-4 h-4 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});const _=(v,b)=>{C.push({label:s.jsxs("div",{className:"min-w-[160px]",children:[s.jsx("div",{className:"truncate text-sm",children:Yh(v.title??v.id.slice(0,8),u)}),b&&s.jsx("div",{className:"text-text-muted text-xs",children:Kf(v.updatedAt)})]}),icon:v.id===(n==null?void 0:n.id)?s.jsx(Rs,{}):void 0,href:`/p/${t.id}/s/${v.id}`,onClick:()=>{l(v.id)},labelAction:s.jsx("button",{onClick:()=>c(v.id,!v.isFavorite),className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:v.isFavorite?"Unfavorite session":"Favorite session",children:v.isFavorite?s.jsx(Zc,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Cf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})})},S=v=>{const b=KN(v);for(const[k,N]of b){const E=N[0];if(E){C.push({label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:WN(E.updatedAt)}),onClick:()=>{}});for(const D of N)_(D,!0)}}};if(h.length>0)for(const v of h)_(v,!1);return S(p),C},[t.id,h,p,n==null?void 0:n.id]),g=((w=n==null?void 0:n.metadata)==null?void 0:w.title)??(n?n.id.slice(0,8):null),x=g?Yh(g,u):"No session selected";return s.jsx(jl,{items:m,isOpen:r,onOpenChange:a,trigger:s.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:g??"","data-testid":"header-session-dropdown",children:[x,s.jsx(pn,{})]}),minWidth:"280px",labelActionClassName:"pr-3"})}function d7({items:e,trigger:t,isActive:n=!1}){const[r,a]=j.useState(!1),l=j.useRef(null);return j.useEffect(()=>{function c(u){l.current&&!l.current.contains(u.target)&&a(!1)}if(r)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),s.jsxs("div",{className:"relative",ref:l,children:[s.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,s.jsx(pn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((c,u)=>{const d=c.label&&typeof c.label=="object"&&c.label.type===yr?c.label:null;if(d){const h=d.props.href||"";return s.jsxs(yr,{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:[c.icon,d.props.children]},u)}return c.href?s.jsxs("a",{href:c.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[c.icon,c.label]},u):s.jsxs("button",{type:"button",onClick:()=>{var h;(h=c.onClick)==null||h.call(c),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:[c.icon,c.label]},u)})})]})}function h7({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const a=t.filter(c=>c.projectId===e.id).sort((c,u)=>new Date(u.updatedAt).getTime()-new Date(c.updatedAt).getTime()).slice(0,5),l=[{label:s.jsxs(yr,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[s.jsx(es,{className:"w-3 h-3 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(c=>({label:s.jsx(yr,{href:`/p/${e.id}/s/${c.id}`,className:"flex items-center gap-2 truncate text-sm",children:s.jsx("span",{children:Yh(c.title??c.id.slice(0,8),50)})}),icon:c.id===(n==null?void 0:n.id)?s.jsx(Rs,{className:"w-3 h-3"}):void 0})),{label:s.jsxs(yr,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[s.jsx(F5,{className:"w-3 h-3"}),s.jsx("span",{className:"text-sm",children:"Projects"})]})}];return s.jsx(d7,{items:l,trigger:s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function YN(){const e=ut(a=>a.defaults),t=ut(a=>a.userItems),n=ut(a=>a.projectItems),r=ut(a=>a.fetchAgents);return{agents:[...e,...t,...n],fetchAgents:r}}function f7({task:e,projectId:t,agents:n,queuePosition:r,onEdit:a,onMove:l,onMoveUp:c,onMoveDown:u,onDuplicate:d,onDelete:h,onDragStart:p,onDropOnCard:m}){const[,g]=Ln(),[x,w]=j.useState(!1),C=n.find(E=>E.id===e.agentId),_=e.agentId?Ja(n,e.agentId):void 0,S=e.attachments.filter(E=>E.mimeType.startsWith("image/")),v=e.activeSessionId??e.sessionIds[e.sessionIds.length-1],b=E=>{g(`/p/${t}/s/${E}`)},k=[{label:"Edit",icon:s.jsx(Uy,{className:"w-3.5 h-3.5"}),onClick:()=>a(e)},{label:"History & evidence",icon:s.jsx(_f,{className:"w-3.5 h-3.5"}),onClick:()=>w(E=>!E)},{label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:"Move to…"}),onClick:()=>{}},{label:"To Do",onClick:()=>l(e,"todo")},{label:"In Progress",onClick:()=>l(e,"in_progress")},{label:"Done",onClick:()=>l(e,"done")},{label:"Move up",icon:s.jsx(Bj,{className:"w-3.5 h-3.5"}),onClick:()=>c(e)},{label:"Move down",icon:s.jsx(pn,{className:"w-3.5 h-3.5"}),onClick:()=>u(e)}],N=[{label:"Duplicate",icon:s.jsx(dl,{className:"w-3.5 h-3.5"}),onClick:()=>d(e)},{label:"Delete",icon:s.jsx(fi,{className:"w-3.5 h-3.5"}),danger:!0,onClick:()=>h(e)}];return s.jsxs("div",{draggable:!0,onClick:()=>a(e),onDragStart:E=>{E.dataTransfer.effectAllowed="move",p(e)},onDragOver:E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},onDrop:E=>{E.preventDefault(),m(e)},className:`group relative cursor-pointer bg-bg-tertiary border border-border rounded-lg p-2.5 hover:border-accent-primary/40 transition-colors ${e.status==="in_progress"?"ring-1 ring-inset ring-accent-primary/20":""}`,children:[e.status==="in_progress"&&s.jsxs("span",{className:`mb-1.5 inline-flex items-center gap-1 text-xs font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded ${e.runState==="running"?"bg-emerald-500/15 text-emerald-400":"bg-amber-500/15 text-amber-400"}`,children:[e.runState==="running"?s.jsx(Sf,{className:"w-2.5 h-2.5"}):s.jsx(Hj,{className:"w-2.5 h-2.5"}),e.runState==="running"?"Running":`Queued${r!==void 0?` · ${r}`:""}`]}),s.jsx("p",{className:"pr-8 text-sm text-text-primary leading-relaxed line-clamp-3 break-words whitespace-pre-wrap",children:e.prompt}),s.jsx("div",{className:"absolute top-2 right-2",onClick:E=>E.stopPropagation(),children:s.jsx(jl,{items:k,footerItems:N,minWidth:"176px",align:"right",trigger:s.jsx("button",{type:"button",className:"p-1 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Task actions","aria-label":`Actions for ${e.prompt.slice(0,40)}`,children:s.jsx(Vy,{className:"w-4 h-4"})})})}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.attachments.length>0&&s.jsxs("span",{className:"text-xs text-text-muted flex items-center gap-1",title:`${e.attachments.length} attachment(s)`,children:["📎 ",e.attachments.length]}),S.length>0&&s.jsx("span",{className:"flex -space-x-1",children:S.slice(0,3).map(E=>s.jsx("img",{src:E.data,alt:"",className:"w-6 h-6 rounded object-cover ring-2 ring-bg-tertiary"},E.id))}),e.model&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-secondary border border-border text-text-muted truncate max-w-36",title:e.model,children:e.model}),C&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-secondary border border-border flex items-center gap-1",style:{color:_},children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:_}}),C.name]}),v&&s.jsxs(rt,{size:"sm",onClick:E=>{E.stopPropagation(),b(v)},className:"ml-auto text-xs bg-accent-primary/10 text-accent-primary hover:bg-accent-primary/20 flex items-center gap-1",children:["Open session ",s.jsx(Wy,{className:"w-2.5 h-2.5"})]})]}),x&&e.auditTrail.length>0&&s.jsxs("div",{className:"mt-2 pt-2 border-t border-border space-y-1",children:[s.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"History"}),e.auditTrail.map(E=>s.jsxs("div",{className:"text-xs text-text-muted leading-relaxed",children:[s.jsx("span",{className:"text-text-primary",children:E.action}),E.detail&&s.jsxs("span",{children:[" — ",E.detail]}),s.jsxs("span",{className:"text-text-muted/70",children:[" ","· ",E.actor,E.actorName&&E.actorName!==E.actor?` (${E.actorName})`:""," ·"," ",new Date(E.timestamp).toLocaleString()]})]},E.id))]})]})}function m7({title:e,accentClass:t,hint:n,tasks:r,projectId:a,agents:l,queuePositionOf:c,headerAction:u,footer:d,onEdit:h,onMove:p,onMoveUp:m,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnColumn:_,onDropOnCard:S}){return s.jsxs("section",{onDragOver:v=>{v.preventDefault(),v.dataTransfer.dropEffect="move"},onDrop:v=>{v.preventDefault(),_()},className:"flex flex-col min-w-64 w-72 max-w-72 bg-bg-secondary/60 border border-border rounded-lg overflow-hidden",children:[s.jsxs("header",{className:`flex items-center gap-2 min-h-[51px] px-3 py-2 border-b border-border ${t}`,children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[s.jsx("span",{className:"text-sm font-semibold uppercase tracking-wide text-text-primary",children:e}),s.jsx("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded-full",children:r.length})]}),u]}),n&&s.jsx("p",{className:"px-3 pt-2 text-sm text-text-muted italic",children:n}),s.jsxs("div",{className:"p-2 space-y-2 overflow-y-auto flex-1 min-h-24",children:[r.map(v=>s.jsx(f7,{task:v,projectId:a,agents:l,queuePosition:c(v),onEdit:h,onMove:p,onMoveUp:m,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnCard:S},v.id)),r.length===0&&s.jsx("div",{className:"text-sm text-text-muted text-center py-6 border border-dashed border-border rounded-lg",children:"Empty"})]}),d&&s.jsx("div",{className:"border-t border-border",children:d})]})}const p7={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},g7="M6 18L18 6M6 6l12 12";function _u({onClick:e,className:t="",size:n="md",variant:r="default","aria-label":a,title:l="Close"}){const c=r==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":r==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":r==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return s.jsx(kf,{onClick:e,icon:g7,iconSize:p7[n],className:`${c} ${t}`,title:l,...a!==void 0?{"aria-label":a}:{}})}const x7=["text/"],y7=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function wh(e){return e.startsWith("image/")}function XN(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function Pb(e){return y7.includes(e)||x7.some(t=>e.startsWith(t))}function tl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function JN(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const b7={"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 v7(e){var t;return b7[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function _7(e){return wh(e)||Pb(e)||e==="application/pdf"}function Bb({attachment:e,onRemove:t}){const n=JN(e.filename);return s.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[s.jsx(_u,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),XN(e.mimeType)?s.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):s.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-md bg-bg-secondary text-xs font-bold text-text-muted",children:n}),s.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:tl(e.size)})]})}function S7(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function w7(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 zC(e){return e.models.some(n=>n.selected)?e.models.filter(n=>n.selected):e.models}function QN({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:l,settingDefault:c,highlighted:u,onModelClick:d,onSetDefault:h,onEditModel:p}){var m;return s.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${u?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[s.jsx("button",{type:"button",onClick:()=>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}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[s.jsx("span",{className:"text-xs text-text-muted",children:S7(t.contextWindow)}),l&&h&&s.jsx("button",{type:"button",onClick:g=>h(g,e,t.id),disabled:c,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:r?"Default model":"Set as default model",children:r?s.jsx(Zc,{className:"w-3.5 h-3.5 text-accent-warning"}):s.jsx(Cf,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),p&&s.jsx("button",{type:"button",onClick:g=>{g.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:s.jsx(Uy,{className:"w-3 h-3 text-text-muted"})}),n&&s.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:s.jsx(Rs,{className:"w-3.5 h-3.5"})})]})]})}function ZN({providers:e,onSelect:t,onEscape:n,extraItemCount:r=0}){const[a,l]=j.useState(""),[c,u]=j.useState(-1),d=j.useRef(null),h=j.useRef(null),p=j.useMemo(()=>a.trim()?e.map(w=>({provider:w,models:zC(w).filter(C=>w7(C,a))})).filter(w=>w.models.length>0):e.map(w=>({provider:w,models:zC(w)})),[e,a]),m=j.useMemo(()=>p.flatMap(w=>w.models.map(C=>({providerId:w.provider.id,modelConfig:C}))),[p]),g=m.length+r;return j.useEffect(()=>{g<=1?u(-1):c>=g?u(g-1):c<0&&a.trim()&&u(0)},[g,c,a]),j.useEffect(()=>{c>=0&&d.current&&d.current.scrollIntoView({block:"nearest"})},[c]),{searchQuery:a,setSearchQuery:l,highlightedIndex:c,setHighlightedIndex:u,visibleGroups:p,flatItems:m,totalNavItems:g,handleSearchKeyDown:w=>{switch(w.key){case"Escape":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),g>0&&u(C=>C<g-1?C+1:0);break;case"ArrowUp":w.preventDefault(),g>0&&u(C=>C>0?C-1:g-1);break;case"Home":w.preventDefault(),u(0);break;case"End":w.preventDefault(),u(g-1);break;case"Enter":if(w.preventDefault(),c>=0&&c<m.length){const C=m[c];C&&t(C.providerId,C.modelConfig.id)}break}},highlightedRef:d,inputRef:h}}function $b({providers:e,value:t,onChange:n,defaultLabel:r="Default (global model)"}){var E;const[a,l]=j.useState(!1),c=j.useRef(null),u=j.useRef(null),[d,h]=j.useState({}),p=t==null?void 0:t.split("/").slice(1).join("/"),m=p?((E=p.split("/").pop())==null?void 0:E.replace(/-/g," "))??p:void 0,{searchQuery:g,setSearchQuery:x,highlightedIndex:w,setHighlightedIndex:C,visibleGroups:_,flatItems:S,handleSearchKeyDown:v,highlightedRef:b,inputRef:k}=ZN({providers:e,onSelect:(D,A)=>{n(`${D}/${A}`),l(!1)},onEscape:()=>l(!1)}),N=j.useCallback(()=>{if(!a||!u.current)return;const D=u.current.getBoundingClientRect();h({position:"fixed",top:`${D.bottom+4}px`,left:`${D.left}px`,width:`${Math.max(D.width,288)}px`})},[a]);return j.useEffect(()=>(N(),window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}),[N]),j.useEffect(()=>{if(!a)return;function D(O){var P;c.current&&!c.current.contains(O.target)&&!((P=O.target)!=null&&P.closest("[data-model-picker-dropdown]"))&&(l(!1),x(""),C(-1))}const A=setTimeout(()=>{document.addEventListener("mousedown",D)},0);return()=>{clearTimeout(A),document.removeEventListener("mousedown",D)}},[a,x,C]),j.useEffect(()=>{var D;a?(N(),zt()&&((D=k.current)==null||D.focus())):(x(""),C(-1))},[a,x,C,k,N]),s.jsxs("div",{className:"relative",ref:c,children:[s.jsxs("button",{ref:u,type:"button",onClick:()=>l(!a),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary hover:bg-bg-secondary transition-colors",children:[s.jsx("span",{className:m?"text-text-primary":"text-text-muted",children:m??r}),s.jsx(pn,{className:`w-3 h-3 text-text-muted transition-transform ${a?"rotate-180":""}`})]}),a&&typeof document<"u"&&mi.createPortal(s.jsx("div",{"data-model-picker-dropdown":!0,className:"z-50",style:d,children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg flex flex-col max-h-80",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(hi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:k,type:"text",value:g,onInput:D=>{x(D.currentTarget.value),C(-1)},onKeyDown:v,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsxs(dt,{className:"flex-1",children:[s.jsx("button",{type:"button",onClick:()=>{n(void 0),l(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors hover:bg-bg-tertiary ${t?"text-text-muted":"text-accent-primary bg-accent-primary/5"}`,children:r}),_.map(D=>s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-1.5 text-xs font-medium text-text-muted uppercase tracking-wider bg-bg-tertiary/50",children:D.provider.name}),D.models.map(A=>{const P=S.findIndex(z=>z.providerId===D.provider.id&&z.modelConfig.id===A.id)===w,G=t===`${D.provider.id}/${A.id}`;return s.jsx("div",{ref:P?b:void 0,children:s.jsx(QN,{providerId:D.provider.id,modelConfig:A,isActive:G,highlighted:P,onModelClick:(z,V)=>{n(`${z}/${V}`),l(!1)}})},`${D.provider.id}/${A.id}`)})]},D.provider.id)),_.length===0&&g.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})]})}),document.body)]})}function C7(e,t){const n=e.slice(0,t);if(n.length===0||n[0]!=="/")return null;const r=n.slice(1);return r.includes(" ")||r.includes(`
275
+ `)||r.includes(" ")?null:{query:r,startIndex:0}}const zb={builtin:"Built-in",user:"Global",project:"Project"};function Xh(e,t){const n=e.filter(r=>r.id===t);if(n.length!==0)return n.find(r=>r.scope==="project")??n.find(r=>r.scope==="user")??n.find(r=>r.scope==="builtin")}function py(e,t,n){return n!=="auto"?e.find(r=>r.id===t&&r.scope===n)??Xh(e,t):Xh(e,t)}const eT=j.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:l},c){const u=C7(t,n),[d,h]=j.useState(0),p=j.useRef(null),m=j.useRef([]),g=j.useRef(0),x=j.useRef([]);j.useEffect(()=>{g.current=d},[d]),j.useEffect(()=>{x.current=C});const w=(u==null?void 0:u.query)??"",C=(()=>{if(!u)return[];const S=w.toLowerCase(),v=r.filter(k=>k.id.toLowerCase().includes(S)||k.name.toLowerCase().includes(S)).map(k=>({type:"workflow",id:k.id,name:k.name,scope:k.scope,paramCount:(k.parameters??[]).length})),b=a.filter(k=>k.id.toLowerCase().includes(S)||k.name.toLowerCase().includes(S)).map(k=>({type:"command",id:k.id,name:k.name,paramCount:0}));return[...v,...b]})();j.useEffect(()=>{h(0),g.current=0},[C.length]);const _=j.useCallback(S=>{if(!u||C.length===0)return!1;switch(S.key){case"ArrowDown":return S.preventDefault(),h(v=>{var k;const b=Math.min(v+1,C.length-1);return(k=m.current[b])==null||k.scrollIntoView({block:"nearest"}),b}),!0;case"ArrowUp":return S.preventDefault(),h(v=>{var k;const b=Math.max(v-1,0);return(k=m.current[b])==null||k.scrollIntoView({block:"nearest"}),b}),!0;case"Enter":case"Tab":{const v=C[g.current];return v?(S.preventDefault(),l(v,u.startIndex),!0):!1}case"Escape":return S.preventDefault(),!0}return!1},[u,C,l]);return j.useImperativeHandle(c,()=>({handleKeyDown:_}),[_]),!u||C.length===0?null:s.jsx("div",{ref:p,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:s.jsx(dt,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("div",{children:C.map((S,v)=>s.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:()=>{u&&l(S,u.startIndex)},children:[s.jsxs("span",{className:`font-medium ${S.type==="workflow"?"text-accent-primary":"text-accent-warning"}`,children:["/",S.id]}),s.jsx("span",{className:"truncate flex-1",children:S.name}),S.type==="workflow"&&s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:zb[S.scope]}),S.paramCount>0&&s.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}-${S.type==="workflow"?S.scope:""}`))})})})});function k7(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return null;const a=n.slice(r+1);return a.includes(" ")||a.includes(`
276
+ `)||a.includes(" ")?null:{query:a,startIndex:r}}const tT=j.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},l){const c=k7(t,n),[u,d]=j.useState([]),[h,p]=j.useState(!1),[m,g]=j.useState(0),x=j.useRef(null),w=j.useRef([]),C=j.useRef(0),_=j.useRef([]);j.useEffect(()=>{C.current=m},[m]),j.useEffect(()=>{_.current=u},[u]),j.useEffect(()=>{if(!c){d([]);return}const b=setTimeout(()=>{S(c.query)},150);return()=>clearTimeout(b)},[c==null?void 0:c.query,r]);const S=async b=>{p(!0);try{const k=new URLSearchParams({q:b});r&&k.set("workdir",r);const E=await(await xe(`/api/files?${k.toString()}`)).json();d(E),g(0),C.current=0}catch(k){console.error("File search failed:",k),d([])}finally{p(!1)}},v=j.useCallback(b=>{if(!c)return!1;switch(b.key){case"ArrowDown":return b.preventDefault(),g(k=>{var E;const N=Math.min(k+1,_.current.length-1);return w.current[N]&&((E=w.current[N])==null||E.scrollIntoView({block:"nearest"})),N}),C.current=Math.min(C.current+1,_.current.length-1),!0;case"ArrowUp":return b.preventDefault(),g(k=>{var E;const N=Math.max(k-1,0);return w.current[N]&&((E=w.current[N])==null||E.scrollIntoView({block:"nearest"})),N}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const k=_.current;return k[C.current]?(b.preventDefault(),a(k[C.current],c.startIndex),!0):!1}case"Escape":return b.preventDefault(),d([]),!0}return!1},[c,a]);return j.useImperativeHandle(l,()=>({handleKeyDown:v}),[v]),j.useEffect(()=>{if(!c)return;const b=k=>{x.current&&!x.current.contains(k.target)&&d([])};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[c]),c?h?s.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:s.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:s.jsx("div",{className:"p-4 text-center",children:s.jsx(ta,{size:"sm"})})})}):u.length===0?null:s.jsx("div",{ref:x,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:s.jsx(dt,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("ul",{children:u.map((b,k)=>s.jsxs("li",{ref:N=>{w.current[k]=N},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${k===m?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{c&&a(b,c.startIndex)},children:[b.type==="directory"?s.jsx(Qr,{className:"w-4 h-4 shrink-0"}):s.jsx("span",{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"truncate",children:b.path})]},b.path))})})}):null}),HC=e=>Symbol.iterator in e,FC=e=>"entries"in e,UC=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[a,l]of n)if(!r.has(a)||!Object.is(l,r.get(a)))return!1;return!0},j7=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let a=n.next(),l=r.next();for(;!a.done&&!l.done;){if(!Object.is(a.value,l.value))return!1;a=n.next(),l=r.next()}return!!a.done&&!!l.done};function E7(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:HC(e)&&HC(t)?FC(e)&&FC(t)?UC(e,t):j7(e,t):UC({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function N7(e){const t=cs.useRef(void 0);return n=>{const r=e(n);return E7(t.current,r)?t.current:t.current=r}}const Ea=e=>e?`?workdir=${encodeURIComponent(e)}`:"",fx=e=>e?`&scope=${e}`:"",Qa=e=>[...e.defaults,...e.userItems,...e.projectItems],Yf=()=>$t(N7(Qa)),$t=Kn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],setWorkdir:n=>e({workdir:n}),fetchTemplateVariables:async()=>{try{const r=await(await xe("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async n=>{e({loading:!0});try{const a=await(await xe(`/api/workflows${Ea(n??t().workdir)}`)).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],activeWorkflowId:a.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async(n,r,a)=>{try{const l=await xe(`/api/workflows/${n}${Ea(r??t().workdir)}${fx(a)}`);return l.ok?await l.json():null}catch{return null}},fetchDefaultContent:async(n,r)=>{try{const a=await xe(`/api/workflows/defaults/${n}${Ea(r??t().workdir)}`);return a.ok?await a.json():null}catch{return null}},createWorkflow:async(n,r,a)=>{const l=a??t().workdir,c=await Qi("POST",`/api/workflows${Ea(l)}`,{...n,destination:r});return c.success&&await t().fetchWorkflows(l),c},updateWorkflow:async(n,r,a,l)=>{const c=a??t().workdir,u=await Qi("PUT",`/api/workflows/${n}${Ea(c)}${fx(l)}`,r);return u.success&&await t().fetchWorkflows(c),u},deleteWorkflow:async(n,r,a)=>{try{const l=await xe(`/api/workflows/${n}${Ea(a??t().workdir)}${fx(r)}`,{method:"DELETE"}),c=await l.json();return l.ok?(e(u=>({...r==="user"?{userItems:u.userItems.filter(d=>d.id!==n)}:{},...r==="project"?{projectItems:u.projectItems.filter(d=>d.id!==n)}:{}})),{success:!0}):{success:!1,error:c.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r,a)=>{const l=a??t().workdir;return yf(`/api/workflows/${n}/duplicate${Ea(l)}`,()=>t().fetchWorkflows(l),r)}}));async function T7(e,t,n){t({loading:!0});try{const a=await(await xe(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const ln=Kn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await T7("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await xe(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await xe(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const a=await Qi("POST","/api/commands",{...n,destination:r});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,r)=>{const a=await Qi("PUT",`/api/commands/${n}`,r);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const r=await xe(`/api/commands/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(c=>c.id!==n),projectItems:l.projectItems.filter(c=>c.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r)=>yf(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function Qn(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function gy(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 c=Array.from(e),u=[];let d="",h=a[0]??!1;for(let p=0;p<c.length;p++){const m=c[p]??"";a[p]===h?d+=m:(u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},u.length):d),d=m,h=a[p]??!1)}return u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},u.length):d),s.jsx(s.Fragment,{children:u})}function qi(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 c=0;for(let u=0;u<l.length&&c<a.length;u++)l[u]===a[c]&&c++;if(c===a.length)return!0}return!1})}function nT(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 Jh(e,t,n,r){const a=e.slice(0,n),l=e.slice(t);return{newText:`${a}${r}${l}`,newCursorPos:n+r.length}}function Qh(e,t){e&&(e.selectionStart=t,e.selectionEnd=t,e.focus())}function rT(e){if(e.type==="workflow"){const r=Qa($t.getState()).find(a=>a.id===e.id&&a.scope===e.scope);return((r==null?void 0:r.parameters)??[]).map(a=>a.id)}const t=ln.getState(),n=Qn(Qn(t.defaults,t.userItems),t.projectItems).find(r=>r.id===e.id);return(n==null?void 0:n.paramNames)??[]}const A7={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function L7(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=B7(a),c=`data:${e.type};base64,${l}`,u=await sT(c);return{dataUrl:c,mimeType:e.type,size:e.size,width:u.width,height:u.height}}return await D7(e,n)}async function D7(e,t){const n=await O7(e),r=await sT(n),{width:a,height:l}=R7(r.width,r.height,t.maxWidth,t.maxHeight),c=I7();c.width=a,c.height=l;const u=c.getContext("2d");if(!u)throw new Error("Failed to get canvas context");u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(r,0,0,a,l);let d=t.quality,h="";for(let m=0;m<10&&(h=c.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(VC(h)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=VC(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:l}}function R7(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 O7(e){return new Promise((t,n)=>{const r=P7(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function sT(e){return new Promise((t,n)=>{const r=M7(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function I7(){var t;const e=Hb();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function M7(){const e=Hb();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function P7(){const e=Hb();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Hb(){return globalThis}function B7(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 VC(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const GC=50*1024*1024,WC=1024*1024,$7=["image/png","image/jpeg","image/gif"];function z7(e){return e==="application/pdf"}function H7(e){return $7.includes(e.type)}async function F7(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 xy(e,t,n){try{if(Pb(e.type)){if(e.size>WC){n(`Text file too large (${tl(e.size)}). Maximum is ${tl(WC)}.`);return}const r=await e.text(),a={id:gh(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(wh(e.type)||z7(e.type)){if(e.size>GC){const r=wh(e.type)?"Image":"PDF";n(`${r} file too large (${tl(e.size)}). Maximum is ${tl(GC)}.`);return}if(wh(e.type)&&H7(e)){const r=await L7(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:gh(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await F7(e),a={id:gh(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}}else n(`Unsupported file type: ${e.type}. Supported types: images (PNG, JPG, GIF, WebP, BMP, SVG), PDF, text files, JSON, XML, YAML, and other common text-based formats.`)}catch(r){const a=r instanceof Error?r.message??"Failed to process file":"Failed to process file";n(a)}}const U7="openfox:task-draft";function V7({projectId:e,initialTask:t,onClose:n,onSaved:r}){var Je;const a=!!t,l=It(ae=>ae.createTask),c=It(ae=>ae.updateTask),u=It(ae=>ae.lastError),{agents:d,fetchAgents:h}=YN(),p=d.filter(ae=>!ae.subagent),m=en(ae=>ae.providers),x=(Je=Yt(ae=>ae.projects).find(ae=>ae.id===e))==null?void 0:Je.workdir;j.useEffect(()=>{h()},[h]);const w=`${U7}:${e}:${(t==null?void 0:t.id)??"new"}`,[C,_]=j.useState(()=>(t==null?void 0:t.prompt)??""),[S,v]=j.useState(()=>(t==null?void 0:t.attachments)??[]),[b,k]=j.useState(()=>(t==null?void 0:t.agentId)??void 0),[N,E]=j.useState(()=>t==null?void 0:t.providerId),[D,A]=j.useState(()=>t==null?void 0:t.model),[O,P]=j.useState(null),[G,z]=j.useState(!1),[V,$]=j.useState([]),H=j.useRef(null),q=j.useRef(null),X=j.useRef(null),Y=j.useRef(null),F=j.useRef(0),I=j.useRef([]),[R,W]=j.useState(!1);j.useEffect(()=>{if(x)return;let ae=!1;return xe(`/api/projects/${e}`).then(ue=>ue.ok?ue.json():null).then(ue=>{var Me;!ae&&((Me=ue==null?void 0:ue.project)!=null&&Me.workdir)&&Yt.setState({currentProject:ue.project})}).catch(()=>{}),()=>{ae=!0}},[e,x]),j.useEffect(()=>{try{const ae=localStorage.getItem(w);if(ae){const ue=JSON.parse(ae);ue.prompt&&_(ue.prompt)}}catch{}},[]),j.useEffect(()=>{const ae=setTimeout(()=>{try{localStorage.setItem(w,JSON.stringify({prompt:C}))}catch{}},300);return()=>clearTimeout(ae)},[C,w]);const B=j.useCallback(ae=>{for(const ue of Array.from(ae))xy(ue,Me=>v(fe=>[...fe,Me]),Me=>P(Me))},[]),Z=ae=>{ae.clipboardData.files.length>0&&B(ae.clipboardData.files)},Q=ae=>{ae.preventDefault()},J=ae=>{ae.preventDefault(),ae.dataTransfer.files.length>0&&B(ae.dataTransfer.files)},U=ae=>{I.current.push(ae),I.current.length>50&&I.current.shift(),W(!0)},M=ae=>{ae!==C&&(U(C),_(ae))},te=()=>{var ue;const ae=I.current.pop();ae!==void 0&&(_(ae),W(I.current.length>0),(ue=H.current)==null||ue.focus())},se=j.useCallback((ae,ue)=>{const{newText:Me,newCursorPos:fe}=Jh(C,F.current,ue,`/${ae.id} `);U(C),_(Me),F.current=fe,Qh(H.current,fe),$(rT(ae))},[C]),re=j.useCallback((ae,ue)=>{const fe=ae.type==="directory"?"/":" ",{newText:Fe,newCursorPos:He}=Jh(C,F.current,ue,`@${ae.path}${fe}`);U(C),_(Fe),F.current=He,Qh(H.current,He)},[C]),le=async()=>{const ae=C.trim().length>0,ue=S.length>0;if(!ae&&!ue){P("Add a prompt or an attachment");return}z(!0),P(null);const Me={prompt:C,...S.length>0?{attachments:S}:{},...a?{agentId:b??null}:b?{agentId:b}:{},...a&&(t!=null&&t.providerId)&&!N?{providerId:null}:N?{providerId:N}:{},...a&&(t!=null&&t.model)&&!D?{model:null}:D?{model:D}:{}},fe=a?await c(e,t.id,Me):await l(e,Me);if(z(!1),fe){try{localStorage.removeItem(w)}catch{}r(fe)}else P(u??"Could not save the task")},ye=ae=>{var ue,Me;if(!((ue=Y.current)!=null&&ue.handleKeyDown(ae))&&!((Me=X.current)!=null&&Me.handleKeyDown(ae))){if(ae.key==="z"&&(ae.metaKey||ae.ctrlKey)){ae.preventDefault(),te();return}ae.key==="Enter"&&!ae.shiftKey&&!ae.nativeEvent.isComposing&&(ae.preventDefault(),le())}},_e=Qa($t.getState()),Oe=(()=>{const ae=ln.getState();return Qn(Qn(ae.defaults,ae.userItems),ae.projectItems)})(),Be=(()=>{if(V.length===0)return 0;const ae=C.match(/\/(\w+)\s+(.*)$/),Me=(ae?ae[2].trim().split(/\s+/):[]).filter(Boolean).length;return V[Me]?V.length-Me:0})(),ke=N&&D?`${N}/${D}`:void 0,Ge=a&&t.status==="in_progress"&&t.runState==="running";return s.jsxs(St,{isOpen:!0,onClose:n,title:a?"Edit task":"New task",size:"lg",showCloseButton:!0,footer:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-sm text-text-muted truncate",children:Ge?"This task is already in progress — changes apply to the next run.":"Enter to save · Shift+Enter for a new line"}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(rt,{onClick:n,children:"Cancel"}),s.jsx(rt,{variant:"primary",onClick:()=>void le(),disabled:G,children:G?"Saving…":a?"Save changes":"Create task"})]})]}),children:[Ge&&s.jsx("div",{className:"mb-3 px-3 py-2 rounded bg-accent-primary/10 border border-accent-primary/30 text-sm text-text-primary",children:"This task is already in progress — changes apply to the next run."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Prompt"}),s.jsxs("div",{className:"relative",onDragOver:Q,onDrop:J,children:[s.jsx("textarea",{ref:H,value:C,onChange:ae=>M(ae.target.value),onSelect:ae=>{F.current=ae.currentTarget.selectionStart},onPaste:Z,onKeyDown:ye,rows:6,placeholder:"Describe the task. Slash commands (/cmd) and workflows resolve exactly as in chat when the task launches.",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary resize-y min-h-32"}),s.jsx(tT,{ref:X,text:C,cursorPos:F.current,workdir:x,onSelect:re}),s.jsx(eT,{ref:Y,text:C,cursorPos:F.current,workflows:_e,commands:Oe,onSelect:se}),V.length>0&&Be>0&&s.jsxs("div",{className:"absolute top-2 right-14 text-xs text-text-muted bg-bg-secondary/90 border border-border rounded px-2 py-1",children:[Be," required param",Be>1?"s":""," — tab through after the command"]}),s.jsxs("div",{className:"absolute bottom-2 right-2 flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:te,disabled:!R,className:"p-1.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors disabled:opacity-40 disabled:hover:bg-transparent",title:"Undo (Ctrl+Z)",children:"↩︎"}),s.jsx("button",{type:"button",onClick:()=>{var ae;return(ae=q.current)==null?void 0:ae.click()},className:"p-1.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors",title:"Attach files",children:s.jsx(Mj,{})})]}),s.jsx("input",{ref:q,type:"file",multiple:!0,className:"hidden",onChange:ae=>{ae.target.files&&B(ae.target.files),ae.target.value=""}})]})]}),S.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(ae=>s.jsx(Bb,{attachment:ae,onRemove:ue=>v(Me=>Me.filter(fe=>fe.id!==ue))},ae.id))}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Agent"}),s.jsxs("select",{value:b??"",onChange:ae=>k(ae.target.value||void 0),className:"w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"",children:"Default agent"}),p.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Model"}),s.jsx($b,{providers:m,value:ke,onChange:ae=>{if(ae){const ue=ae.indexOf("/");E(ae.slice(0,ue)),A(ae.slice(ue+1))}else E(void 0),A(void 0)}})]})]}),O&&s.jsx("div",{className:"text-sm text-accent-error",children:O})]})]})}const G7=()=>`gate_${crypto.randomUUID().slice(0,8)}`;function W7({projectId:e,onClose:t}){const n=It(x=>x.gates),r=It(x=>x.loadGates),a=It(x=>x.setGateConfig),[l,c]=j.useState([]),[u,d]=j.useState(!1);j.useEffect(()=>{r(e)},[e,r]),j.useEffect(()=>{c(n)},[n]);const h=(x,w)=>{c(C=>C.map((_,S)=>S===x?{..._,...w}:_))},p=()=>{c(x=>[...x,{id:G7(),name:"",description:"",required:!0,variant:"done"}])},m=x=>{c(w=>w.filter((C,_)=>_!==x))},g=async()=>{const x=l.filter(w=>w.name.trim().length>0).map((w,C)=>({...w,id:w.id||`gate_${C}`,name:w.name.trim()}));d(!0),await a(e,x),d(!1),t()};return s.jsx(St,{isOpen:!0,onClose:t,title:"Definition of Done",size:"lg",footer:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"text-sm text-text-muted",children:["Gates define what a task must carry before it may enter ",s.jsx("strong",{children:"Done"}),". Values are set by you or the agent, each recorded with actor + timestamp."]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(rt,{onClick:t,children:"Cancel"}),s.jsx(rt,{variant:"primary",onClick:()=>void g(),disabled:u,children:u?"Saving…":"Save gates"})]})]}),children:s.jsxs("div",{className:"space-y-3",children:[l.length===0&&s.jsx("p",{className:"text-sm text-text-muted",children:"No gates configured — any task can move straight to Done. Add a gate like “all green” (every criterion passes with evidence) or “commit” (work committed with a commit reference)."}),l.map((x,w)=>s.jsxs("div",{className:"border border-border rounded-lg p-3 space-y-2 bg-bg-tertiary/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ns,{type:"text",value:x.name,onChange:C=>h(w,{name:C.target.value}),placeholder:"Gate name, e.g. “all green” or “commit”",className:"flex-1 text-sm"}),s.jsx("button",{type:"button",onClick:()=>m(w),className:"p-1.5 rounded hover:bg-accent-error/10 text-text-muted hover:text-accent-error transition-colors",title:"Remove gate",children:s.jsx(fi,{className:"w-4 h-4"})})]}),s.jsx("textarea",{value:x.description,onChange:C=>h(w,{description:C.target.value}),rows:2,placeholder:"What counts as acceptable proof? e.g. “every acceptance criterion passes with evidence, or work is committed with a commit SHA”",className:"w-full px-2.5 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary resize-y"}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-text-muted",children:[s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"checkbox",checked:x.required,onChange:C=>h(w,{required:C.target.checked})}),"Required"]}),s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"radio",name:`variant-${x.id}`,checked:x.variant==="done",onChange:()=>h(w,{variant:"done"})}),"Blocks Done"]}),s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"radio",name:`variant-${x.id}`,checked:x.variant==="ready",onChange:()=>h(w,{variant:"ready"})}),"Definition of ready (blocks In Progress)"]})]})]},x.id)),s.jsxs(rt,{onClick:p,children:[s.jsx(es,{className:"w-3.5 h-3.5 mr-1 inline-block"})," Add gate"]})]})})}function Fb({isOpen:e,onClose:t,projectId:n}){const[,r]=Ln(),a=It(U=>U.tasks),l=It(U=>U.settings),c=It(U=>U.loadBoard),u=It(U=>U.loadGates),d=It(U=>U.moveTask),h=It(U=>U.reorderTask),p=It(U=>U.deleteTask),m=It(U=>U.duplicateTask),g=It(U=>U.setSettings),x=It(U=>U.lastError),{agents:w,fetchAgents:C}=YN(),[_,S]=j.useState(null),[v,b]=j.useState(!1),[k,N]=j.useState(""),[E,D]=j.useState(null),A=j.useRef(null);j.useEffect(()=>{e&&(c(n),u(n),C())},[e,n,c,u,C]);const O=j.useMemo(()=>{if(!k.trim())return a;const U=k.toLowerCase();return a.filter(M=>M.prompt.toLowerCase().includes(U))},[a,k]),P=j.useMemo(()=>{const U=O.filter(se=>se.status==="todo").sort((se,re)=>se.position-re.position),M=O.filter(se=>se.status==="in_progress").sort((se,re)=>se.runState==="running"!=(re.runState==="running")?se.runState==="running"?-1:1:se.position-re.position),te=O.filter(se=>se.status==="done").sort((se,re)=>se.position-re.position);return{todo:U,in_progress:M,done:te}},[O]),G=j.useMemo(()=>{const U=a.filter(te=>te.status==="in_progress"&&te.runState==="queued").sort((te,se)=>te.position-se.position),M=new Map;return U.forEach((te,se)=>M.set(te.id,se+1)),M},[a]),z=j.useMemo(()=>a.filter(U=>U.status==="in_progress"&&U.runState==="running").length,[a]),V=j.useMemo(()=>a.filter(U=>U.status==="in_progress"&&U.runState==="queued").length,[a]),$=j.useCallback(U=>{if(U.runState==="queued")return U.queuePosition!==void 0?U.queuePosition:G.get(U.id)},[G]),H=j.useCallback(async(U,M)=>{const te=await d(n,U.id,M);te!=null&&te.sessionId&&r(`/p/${n}/s/${te.sessionId}`)},[d,n,r]),q=j.useCallback(async U=>{const M=A.current;A.current=null,M&&M.task.status!==U&&await H(M.task,U)},[H]),X=j.useCallback(async U=>{const M=A.current;if(A.current=null,!M||M.task.id===U.task.id)return;const te=P[U.task.status].findIndex(se=>se.id===U.task.id);te<0||(M.task.status===U.task.status?await h(n,M.task.id,U.task.status,te):(await H(M.task,U.task.status),await h(n,M.task.id,U.task.status,te)))},[P,h,n,H]),Y=j.useCallback(U=>{const M=P[U.status].findIndex(te=>te.id===U.id);M>0&&h(n,U.id,U.status,M-1)},[P,h,n]),F=j.useCallback(U=>{const M=P[U.status].findIndex(te=>te.id===U.id);M>=0&&M<P[U.status].length-1&&h(n,U.id,U.status,M+1)},[P,h,n]),I=j.useCallback(U=>{m(n,U.id)},[m,n]),R=j.useCallback(async()=>{E&&(await p(n,E.id),D(null))},[E,p,n]),W=U=>{const M=It.getState().settings.slotLimit,te=Math.max(1,Math.min(10,M+U));te!==M&&g(n,{slotLimit:te})},B=()=>{const U=It.getState().settings.queuePaused;g(n,{queuePaused:!U})},Z={projectId:n,agents:w,queuePositionOf:$,onEdit:U=>S({mode:"edit",task:U}),onMove:(U,M)=>void H(U,M),onMoveUp:Y,onMoveDown:F,onDuplicate:I,onDelete:U=>D(U),onDragStart:U=>{A.current={task:U}}},Q=U=>{const M={todo:{title:"To Do",accentClass:"border-t-2 border-t-blue-500/60"},in_progress:{title:"In Progress",accentClass:"border-t-2 border-t-amber-500/60",hint:"Moving a task here starts it automatically."},done:{title:"Done",accentClass:"border-t-2 border-t-emerald-500/60"}}[U];return s.jsx(m7,{title:M.title,accentClass:M.accentClass,hint:"hint"in M?M.hint:void 0,tasks:P[U],headerAction:U==="todo"?s.jsxs(rt,{variant:"primary",onClick:()=>S({mode:"create"}),children:[s.jsx(es,{className:"w-4 h-4 mr-1 inline-block"})," New Task"]}):U==="done"?s.jsx(rt,{onClick:()=>b(!0),children:"Gates"}):void 0,footer:U==="in_progress"?J:void 0,onDropOnColumn:()=>void q(U),onDropOnCard:te=>void X({task:te}),...Z},U)},J=s.jsxs("div",{className:"px-3 py-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-muted",children:"Parallel slots"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>W(-1),disabled:l.slotLimit<=1,"aria-label":"Decrease slot limit",className:"w-7 h-7 rounded-md bg-bg-tertiary border border-border text-text-primary text-lg leading-none hover:bg-border disabled:opacity-40 disabled:hover:bg-bg-tertiary transition-colors",children:"−"}),s.jsx("span",{className:"w-9 text-center text-sm font-semibold text-text-primary tabular-nums",title:"Parallel-slot limit",children:l.slotLimit}),s.jsx("button",{type:"button",onClick:()=>W(1),disabled:l.slotLimit>=10,"aria-label":"Increase slot limit",className:"w-7 h-7 rounded-md bg-bg-tertiary border border-border text-text-primary text-lg leading-none hover:bg-border disabled:opacity-40 disabled:hover:bg-bg-tertiary transition-colors",children:"+"})]})]}),s.jsx("div",{className:"pt-3 border-t border-border/70",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm text-text-muted",title:"Active tasks / limit",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 shrink-0"}),s.jsx("strong",{className:"text-text-primary tabular-nums",children:z})," / ",l.slotLimit," running"]}),V>0&&s.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"}),s.jsx("strong",{className:"text-text-primary tabular-nums",children:V})," queued"]})]}),s.jsxs(rt,{size:"sm",onClick:B,className:`shrink-0 flex items-center gap-1 whitespace-nowrap border ${l.queuePaused?"border-amber-400/40 text-amber-400 hover:bg-amber-400/10":"border-border text-text-muted hover:bg-bg-tertiary"}`,title:l.queuePaused?"Resume auto-launch of queued tasks":"Pause auto-launch of queued tasks",children:[l.queuePaused?s.jsx(Sf,{className:"w-3 h-3"}):s.jsx(Hj,{className:"w-3 h-3"}),l.queuePaused?"Resume":"Pause"]})]})})]});return s.jsxs(s.Fragment,{children:[s.jsxs(St,{isOpen:e,onClose:t,title:"Tasks",size:"full",showCloseButton:!0,closeOnBackdropClick:!0,scrollable:!1,headerRight:s.jsx("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:s.jsxs("div",{className:"relative flex-1 min-w-0 sm:min-w-64",children:[s.jsx(hi,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-text-muted"}),s.jsx(Ns,{type:"text",value:k,onChange:U=>N(U.target.value),placeholder:"Search tasks…",className:"pl-7 pr-2 w-full text-sm"})]})}),children:[x&&s.jsxs("div",{className:"mb-2 px-3 py-2 rounded bg-accent-error/10 border border-accent-error/30 text-sm text-accent-error flex items-center justify-between",children:[s.jsx("span",{children:x}),s.jsx("button",{type:"button",onClick:()=>It.setState({lastError:null}),className:"text-sm underline",children:"Dismiss"})]}),s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2 h-full",children:[Q("todo"),Q("in_progress"),Q("done")]})]}),_&&s.jsx(V7,{projectId:n,initialTask:_.mode==="edit"?_.task:null,onClose:()=>S(null),onSaved:()=>S(null)}),v&&s.jsx(W7,{projectId:n,onClose:()=>b(!1)}),E&&s.jsx(hl,{isOpen:!0,onClose:()=>D(null),onConfirm:()=>void R(),title:"Delete task?",message:`“${E.prompt.slice(0,60)}” will be removed from the board. Its sessions and history stay untouched.`,confirmLabel:"Delete task",confirmVariant:"danger"})]})}function q7({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=j.useState(!1),[a,l]=j.useState(!1),[c,u]=j.useState(!!document.fullscreenElement),[d,h]=Ln(),[p,m]=j.useState(!1),g=It($=>$.counts.open),x=It($=>$.loadCounts),w=It($=>$.activeProjectId),C=It($=>$.lastAutoLaunch),_=It($=>$.clearAutoLaunch);j.useEffect(()=>{const $=()=>u(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]);const S=d.startsWith("/p/"),v=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),b=Re($=>$.currentSession),k=Re($=>$.sessions),N=Yt($=>$.currentProject),E=Yt($=>$.projects),D=en($=>$.startAutoRefresh),A=en($=>$.stopAutoRefresh),O=os($=>$.setOpen),P=os($=>$.isOpen),G=ui($=>$.status==="available"),z=ui($=>$.check);j.useEffect(()=>{ui.getState().status==="idle"&&z()},[z]),j.useEffect(()=>{const $=()=>l(!0);return window.addEventListener("open-session-dropdown",$),()=>window.removeEventListener("open-session-dropdown",$)},[]);const V=hu();return eu(V.terminalToggle,()=>{os.getState().toggleOpen()},{capture:!0}),j.useEffect(()=>{N!=null&&N.id&&w!==N.id&&x(N.id)},[N==null?void 0:N.id,w,x]),j.useEffect(()=>(D(),()=>A()),[D,A]),s.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&v&&s.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:V.sessionSearch?`Toggle session list (${Ah(V.sessionSearch)})`:"Toggle session list",children:s.jsx(Uw,{})}),s.jsx(yr,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),N&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx($C,{projects:E,currentProject:N})}),s.jsx("span",{className:"md:hidden",children:s.jsx(h7,{currentProject:N,sessions:k,currentSession:b,projectIdFromUrl:S&&d.split("/")[2]||null},N==null?void 0:N.id)}),s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(u7,{sessions:k,currentProject:N,currentSession:b,isOpen:a,onOpenChange:l})})]}),!N&&s.jsx("span",{className:"hidden md:inline",children:s.jsx($C,{projects:E})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[v&&s.jsx("button",{onClick:()=>{var $,H,q;document.fullscreenElement?($=document.exitFullscreen)==null||$.call(document):(q=(H=document.documentElement).requestFullscreen)==null||q.call(H)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:c?"Exit fullscreen":"Enter fullscreen",children:c?s.jsx(V5,{}):s.jsx(G5,{})}),S&&s.jsxs("button",{onClick:()=>m(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Project tasks","aria-label":"Open project tasks",children:[s.jsx(Ky,{className:"w-4 h-4"}),g>0&&s.jsx("span",{className:"absolute top-0.5 right-0.5 min-w-3.5 h-3.5 px-0.5 rounded-full bg-accent-primary text-white text-[9px] font-semibold flex items-center justify-center",children:g>99?"99+":g})]}),S&&s.jsx("button",{onClick:()=>O(!P),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${P?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:s.jsx(J5,{})}),S&&N&&s.jsx("button",{onClick:()=>xe(`/api/projects/${N.id}/open-folder`).catch(()=>{}),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Open project folder",children:s.jsx(Qr,{className:"w-4 h-4"})}),s.jsxs("button",{onClick:()=>r(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:G?"Settings — update available":"Settings",children:[s.jsx(zj,{}),G&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),s.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:s.jsx(q5,{})}),t&&v&&s.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:V.criteriaSidebar?`Toggle criteria sidebar (${Ah(V.criteriaSidebar)})`:"Toggle criteria sidebar",children:s.jsx(Uw,{})})]}),s.jsx(JF,{isOpen:n,onClose:()=>r(!1)}),s.jsx(i7,{isOpen:P,onClose:()=>O(!1)}),N&&s.jsx(Fb,{isOpen:p,onClose:()=>m(!1),projectId:N.id}),C&&s.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg bg-bg-secondary border border-border shadow-xl text-sm text-text-primary",children:[s.jsxs("span",{children:["“",C.taskTitle,"” auto-launched — a slot freed up."]}),s.jsxs("button",{type:"button",onClick:()=>{const $=C.sessionId,H=C.projectId;_(),h(`/p/${H}/s/${$}`)},className:"flex items-center gap-1 px-2.5 py-1 rounded bg-accent-primary/25 hover:bg-accent-primary/40 font-medium transition-colors",children:["Open session ",s.jsx(vf,{className:"w-3 h-3"})]}),s.jsx("button",{type:"button",onClick:_,className:"text-xs text-text-muted underline",children:"Dismiss"})]})]})}function iT({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:l=n?"Saving...":"Save"}){return s.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[s.jsx(rt,{variant:"secondary",onClick:e,children:a}),s.jsx(rt,{variant:"primary",onClick:t,disabled:r??n,children:l})]})}const th=Kn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await xe(`/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 xe(`/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})}})),K7=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],Y7=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"],aT=/^[a-zA-Z]:$/;function X7(e,t=K7,n=Y7){if(!e)return null;const r=e.replace(/[\\/]+$/,"")||"/";if(aT.test(r)||t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function oT(e){const t=e.replace(/[\\/]+$/,"");return t?aT.test(t)?`${t}\\`:t:"/"}function J7(e,t){const n=oT(e);return/[\\/]$/.test(n)?`${n}${t}`:`${n}/${t}`}function Q7({isOpen:e,onClose:t,project:n}){const r=Yt(ie=>ie.updateProject),a=th(ie=>ie.config),l=th(ie=>ie.loading),c=th(ie=>ie.fetchConfig),u=th(ie=>ie.saveConfig),d=()=>{try{Bt.send("context.checkDynamic",{})}catch{}t()},[h,p]=j.useState(n.customInstructions??""),[m,g]=j.useState(n.dangerLevel??""),[x,w]=j.useState(!1),[C,_]=j.useState(!1),[S,v]=j.useState(!1),[b,k]=j.useState(null),[N,E]=j.useState(""),[D,A]=j.useState(!1),[O,P]=j.useState(""),[G,z]=j.useState(!1),[V,$]=j.useState(""),[H,q]=j.useState(!1),[X,Y]=j.useState(!1),[F,I]=j.useState([]),[R,W]=j.useState(""),[B,Z]=j.useState({}),[Q,J]=j.useState(!1),[U,M]=j.useState(new Set),te=x||C||D||G||Q;j.useEffect(()=>{e&&(p(n.customInstructions??""),g(n.dangerLevel??""),w(!1),_(!1),A(!1),z(!1),J(!1),M(new Set),c(n.workdir))},[e,n,c]),j.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?E(a.setup.join(" && ")):E(""),P((a==null?void 0:a.rootDir)??""),Z((a==null?void 0:a.mcpOverrides)??{})},[a]);const se=Qc(ie=>ie.servers),re=ie=>B[ie]??{},le=ie=>{var he;const Se=re(ie);if(Se.disabled!==void 0)return Se.disabled;const Le=se.find(me=>me.name===ie);return!!((he=Le==null?void 0:Le.config)!=null&&he.disabled)},ye=(ie,Se)=>{var he;return((he=re(ie).disabledTools)==null?void 0:he.includes(Se))??!1},_e=ie=>{Z(Se=>({...Se,[ie]:{...Se[ie],disabled:!le(ie)}})),J(!0)},Oe=(ie,Se)=>{Z(Le=>{const he=Le[ie]??{},me=he.disabledTools??[],We=me.includes(Se)?me.filter(Ue=>Ue!==Se):[...me,Se];return{...Le,[ie]:{...he,disabledTools:We.length>0?We:void 0}}}),J(!0)},Be=ie=>{M(Se=>{if(Se.has(ie)){const he=new Set(Se);return he.delete(ie),he}const Le=new Set(Se);return Le.add(ie),Le})},ke=ie=>{p(ie.target.value),w(!0)},Ge=ie=>{g(ie),_(!0)},Je=ie=>{E(ie.target.value),A(!0)},ae=ie=>{P(ie.target.value),z(!0)},ue=j.useCallback(async()=>{const ie=m===""?null:m;if(await r(n.id,{customInstructions:h||null,dangerLevel:ie}),D||G||Q){const Se=N.trim()?N.split("&&").map(he=>he.trim()).filter(Boolean):[],Le={};D&&(Le.setup=Se),G&&(Le.rootDir=O.trim()),Object.keys(B).length>0&&(Le.mcpOverrides=B),await u(n.workdir,Le)}w(!1),_(!1),A(!1),z(!1),J(!1),d()},[n.id,m,h,N,O,B,D,G,Q,r,u,n.workdir,d]),Me=async()=>{const ie=O.trim(),Se=(a==null?void 0:a.rootDir)??"";if(ie){const Le=X7(ie);if(Le==="exact"){const he=oT(ie);k(`Cannot use "${he}" directly as workspace root. Use a subdirectory like "${J7(ie,n.name)}" instead.`);return}if(Le==="virtual_fs"){k(`Cannot use paths under "${ie}" for workspaces.`);return}}if(!G||!ie||ie===Se){v(!0),k(null);try{await ue()}catch(Le){k(Le instanceof Error?Le.message:"Failed to save settings")}finally{v(!1)}return}$(ie),v(!0),k(null);try{const Le=await xe(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:ie,workdir:n.workdir,projectName:n.name})});if(!Le.ok){const me=await Le.json().catch(()=>({}));k((me==null?void 0:me.error)??"Failed to validate workspace root directory");return}const he=await Le.json();if(!he.exists){W(he.resolvedPath),q(!0);return}if(he.workspaces&&he.workspaces.length>0){I(he.workspaces),Y(!0);return}k(null),await ue()}catch(Le){k(Le instanceof Error?Le.message:"Failed to validate settings")}finally{v(!1)}},fe=async()=>{q(!1),v(!0);try{const ie=await xe(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:V,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!ie.ok){const Le=await ie.json().catch(()=>({}));k((Le==null?void 0:Le.error)??"Failed to create directory"),v(!1);return}const Se=await ie.json();if(Se.workspaces&&Se.workspaces.length>0){I(Se.workspaces),Y(!0),v(!1);return}await ue()}catch(ie){k(ie instanceof Error?ie.message:"Failed to create directory")}finally{v(!1)}},Fe=async()=>{Y(!1),v(!0),k(null);try{await ue()}catch(ie){k(ie instanceof Error?ie.message:"Failed to save settings")}finally{v(!1)}},He=()=>{q(!1),Y(!1),p(n.customInstructions??""),g(n.dangerLevel??""),w(!1),_(!1),A(!1),z(!1),d()};return s.jsxs(St,{isOpen:e,onClose:He,title:`${n.name} Settings`,size:"lg",footer:s.jsx(iT,{onCancel:He,onSave:Me,saving:S,saveDisabled:!te||S}),children:[s.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Default danger level for new sessions in this project. Existing sessions are not affected."}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[s.jsx("button",{type:"button",onClick:()=>Ge(""),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"}),s.jsx("button",{type:"button",onClick:()=>Ge("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"}),s.jsx("button",{type:"button",onClick:()=>Ge("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"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),s.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files."}),s.jsx("textarea",{value:h,onChange:ke,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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),l&&s.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),s.jsx("input",{type:"text",value:N,onChange:Je,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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Root Directory"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Override the default workspace location. Leave empty to use the global directory"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"~/.local/share/openfox/workspaces/"}),". Supports absolute paths or paths relative to the project."]}),s.jsx("input",{type:"text",value:O,onChange:ae,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})]}),se.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"MCP Servers"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Override MCP server availability for this project. These overrides apply to new conversations in this project and can be further overridden per conversation from the chat MCP selector."}),s.jsx("div",{className:"space-y-2",children:se.map(ie=>{const Se=le(ie.name);return s.jsx($N,{server:ie,expanded:U.has(ie.name),onToggleExpand:Be,serverToggleEnabled:!Se,onServerToggle:()=>_e(ie.name),tools:ie.tools.map(Le=>({...Le,enabled:!ye(ie.name,Le.name)})),onToolToggle:Le=>Oe(ie.name,Le),statusDot:Mb(Se?"disabled":ie.status),statusColor:Ib(Se?"disabled":ie.status)},ie.name)})})]}),b&&s.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:b})]}),H&&s.jsxs(St,{isOpen:H,onClose:()=>q(!1),title:"Directory not found",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>q(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:fe,className:"px-4 py-2 text-sm font-medium rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:"Create"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:["The directory ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:R})," does not exist."]}),s.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),X&&s.jsxs(St,{isOpen:X,onClose:()=>Y(!1),title:"Orphaned workspaces",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>Y(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Fe,className:"px-4 py-2 text-sm font-medium rounded bg-red-500 text-white hover:opacity-90 transition-colors",children:"Confirm change"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:[F.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),s.jsx("ul",{className:"mt-2 space-y-1",children:F.map(ie=>s.jsx("li",{className:"text-sm font-mono text-text-muted",children:ie.name},ie.name))}),s.jsx("p",{className:"text-sm text-text-muted mt-3",children:"Existing workspaces will remain in the old location but will no longer be accessible from this project."})]})]})}function lT({initialWidth:e,minWidth:t,maxWidth:n,direction:r}){const[a,l]=j.useState(e),[c,u]=j.useState(!1),d=j.useRef({startX:0,startWidth:e}),h=j.useCallback(p=>{p.preventDefault(),p.stopPropagation(),d.current={startX:p.clientX,startWidth:a},u(!0)},[a]);return j.useEffect(()=>{if(!c)return;const p=w=>{const{startX:C,startWidth:_}=d.current,S=w.clientX-C,v=r==="left"?_+S:_-S;l(Math.max(t,Math.min(n,v)))},m=()=>{u(!1)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",m);const g=document.body.style.userSelect,x=document.body.style.cursor;return document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.userSelect=g,document.body.style.cursor=x}},[c,r,t,n]),{width:a,isResizing:c,handleMouseDown:h}}function cT({side:e,onMouseDown:t,className:n=""}){return s.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:t,className:`absolute top-0 bottom-0 w-1 z-20 cursor-col-resize hover:bg-accent-primary/30 transition-colors ${e==="left"?"left-0 -ml-0.5":"right-0 -mr-0.5"} ${n}`})}function uT({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Ln(),[a,l]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(null),[p,m]=j.useState(""),[g,x]=j.useState(!1),w=Re(ue=>ue.sessions),C=Re(ue=>ue.currentSession),_=Re(ue=>ue.unreadSessionIds),S=Re(ue=>ue.deleteSession),v=Re(ue=>ue.deleteAllSessions),b=Re(ue=>ue.loadMoreSessions),k=Re(ue=>ue.sessionsHasMore),N=Re(ue=>ue.sessionsPaginationLoading),E=Re(ue=>ue.sessionsWithPendingConfirmations),D=Re(ue=>ue.pendingPathConfirmations),A=Re(ue=>ue.toggleFavorite),O=Yt(ue=>ue.currentProject),[P,G]=j.useState(""),[z,V]=j.useState(-1),$=j.useRef(null),H=j.useRef(null),{width:q,handleMouseDown:X}=lT({initialWidth:300,minWidth:200,maxWidth:600,direction:"left"}),Y=j.useRef(!1),F=hu();eu(F.sessionSearch,()=>{var ue;if(t&&document.activeElement===$.current){n==null||n();return}t||(Y.current=!0,n==null||n()),zt()&&((ue=$.current)==null||ue.focus())});const I=j.useRef(null),R=j.useCallback(()=>{k&&!N&&O&&b(O.id)},[k,N,O,b]);j.useEffect(()=>{if(!I.current||!k)return;const ue=new IntersectionObserver(Me=>{const fe=Me[0];fe&&fe.isIntersecting&&R()},{threshold:.1});return ue.observe(I.current),()=>ue.disconnect()},[k,R]);const W=w.filter(ue=>ue.projectId===(O==null?void 0:O.id)),[B,Z]=j.useMemo(()=>{const ue=[],Me=[];for(const fe of W)fe.isFavorite?ue.push(fe):Me.push(fe);return[ue,Me]},[W]),Q=ue=>P?ue.filter(Me=>{var He;const fe=Me.title??"",Fe=(((He=Me.recentUserPrompts)==null?void 0:He.map(ie=>ie.content))??[]).join(" ");return qi(fe,P)||qi(Fe,P)}):ue,J=j.useMemo(()=>Q(B),[B,P]),U=j.useMemo(()=>Q(Z),[Z,P]),M=[...J,...U],te=P.length>0,se=te&&M.length===0;j.useEffect(()=>{V(M.length>0?0:-1)},[M.length]),j.useEffect(()=>{var Me;if(z<0)return;const ue=(Me=H.current)==null?void 0:Me.querySelector(`[data-sidx="${z}"]`);ue==null||ue.scrollIntoView({block:"nearest"})},[z]);const re=(ue,Me)=>{Me==null||Me.stopPropagation(),u(ue)},le=()=>{c&&(S(c),(C==null?void 0:C.id)===c&&r(`/p/${e}`),u(null))},ye=(ue,Me)=>{Me==null||Me.stopPropagation();const fe=w.find(He=>He.id===ue),Fe=(fe==null?void 0:fe.title)??ue.slice(0,6);m(Fe),h(ue)},_e=()=>{if(!d||p.trim()==="")return;const ue=Re.getState().renameSession;ue(d,p.trim()),h(null),m("")},Oe=()=>{x(!0)},Be=()=>{v(e),r(`/p/${e}`),x(!1)},ke=(ue,Me)=>{A(ue,!Me)},Ge=ue=>{if(!Y.current)return;ue.target.closest('a[href*="/s/"]')&&(Y.current=!1,n==null||n())},Je=()=>{var ue;G(""),zt()&&((ue=$.current)==null||ue.focus())},ae=ue=>{var Me;switch(ue.key){case"Escape":G(""),(Me=$.current)==null||Me.blur();break;case"ArrowDown":ue.preventDefault(),V(fe=>fe<M.length-1?fe+1:fe);break;case"ArrowUp":ue.preventDefault(),V(fe=>fe>0?fe-1:0);break;case"Enter":{ue.preventDefault();const fe=M[z];fe&&(r(`/p/${e}/s/${fe.id}`),Y.current&&(Y.current=!1,n==null||n()));break}}};return s.jsxs(s.Fragment,{children:[t&&n&&s.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),(()=>{const ue=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[s.jsx(yr,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),s.jsx(jl,{items:[{label:"Edit project settings",onClick:()=>l(!0)},{label:"Delete all sessions",onClick:Oe,danger:!0}],trigger:s.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:s.jsx(Vy,{})})}),n&&s.jsx(_u,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),s.jsxs("div",{className:"px-4 py-2 border-b border-border",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(hi,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{ref:$,type:"text",value:P,onChange:Me=>G(Me.target.value),onKeyDown:ae,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"}),P&&s.jsx("button",{type:"button",onClick:Je,className:"absolute right-1.5 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:s.jsx(ea,{className:"w-3.5 h-3.5"})})]}),te&&!se&&s.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[M.length," ",M.length===1?"match":"matches"]})]}),O&&s.jsx(Q7,{isOpen:a,onClose:()=>l(!1),project:O}),s.jsx(hl,{isOpen:c!==null,onClose:()=>u(null),onConfirm:le,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),s.jsx(hl,{isOpen:g,onClose:()=>x(!1),onConfirm:Be,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),s.jsx(St,{isOpen:d!==null,onClose:()=>{h(null),m("")},title:"Rename session",size:"sm",footer:s.jsx(iT,{onCancel:()=>{h(null),m("")},onSave:_e,saving:!1,saveDisabled:p.trim()==="",saveLabel:"Rename"}),children:s.jsx("input",{type:"text",value:p,onChange:Me=>m(Me.target.value),onKeyDown:Me=>{Me.key==="Enter"&&_e()},onFocus:Me=>Me.target.select(),className:"w-full px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:zt()})}),s.jsx(dt,{className:"flex-1",children:M.length===0?s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:te?"No matching sessions":"No sessions"}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"divide-y divide-border",ref:H,onClick:Ge,children:Z7(J,U,C,_,re,ye,ke,e,E,D,P,z)}),N&&s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),s.jsx("div",{ref:I,className:"h-px"})]})})]});return s.jsxs("aside",{className:`
277
+ ${t?"md:w-[var(--sidebar-w)] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden md:border-r-0"}
278
+ md:relative md:h-auto md:translate-x-0
279
+
280
+ fixed z-50 h-[calc(100vh-32px)]
281
+ w-[300px] bg-secondary border-r border-border flex flex-col
282
+ transition-transform duration-300 ease-in-out
283
+ ${t?"translate-x-0":"-translate-x-full"}
284
+ `,style:{"--sidebar-w":`${q}px`},children:[ue,t&&s.jsx(cT,{side:"right",onMouseDown:X,className:"hidden md:block"})]})})()]})}function Z7(e,t,n,r,a,l,c,u,d,h,p,m){let g=0;const x=C=>{const _=g++,S=(n==null?void 0:n.id)===C.id,v=_===m,b=r.includes(C.id),k=C.isRunning,N=C.isFavorite,E=d.includes(C.id)||S&&h.length>0;return s.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:s.jsxs(yr,{href:`/p/${u}/s/${C.id}`,className:`block ${S?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[s.jsxs("div",{className:"flex justify-between items-center mb-1",children:[s.jsx("span",{className:`font-medium truncate text-sm ${S?"text-accent-primary":"text-text-primary"}`,children:p?gy(C.title??C.id.slice(0,6),p):C.title??C.id.slice(0,6)}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(jl,{items:[{label:N?"Remove from favorites":"Add to favorites",icon:N?s.jsx(Zc,{className:"w-3.5 h-3.5 text-amber-400"}):s.jsx(Cf,{className:"w-3.5 h-3.5"}),onClick:()=>c(C.id,N)},{label:"Rename session",onClick:D=>l(C.id,D)},{label:"Delete session",onClick:D=>a(C.id,D),danger:!0}],trigger:s.jsx("button",{onClick:D=>{D.preventDefault()},className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:s.jsx(Vy,{})})})})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[E?s.jsx("span",{title:"Awaiting confirmation",children:s.jsx(qy,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):k?s.jsx(Y5,{}):b&&!S?s.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,!N&&s.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Kf(C.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)},w=C=>{const _=KN(C);return Array.from(_).map(([S,v])=>{const b=v[0];return b?s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:WN(b.updatedAt)}),v.map(k=>x(k))]},S):null})};return s.jsxs(s.Fragment,{children:[e.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"px-4 py-2 bg-bg-tertiary/50 text-text-primary text-xs font-semibold flex items-center gap-1",children:[s.jsx(Zc,{className:"w-3 h-3 text-amber-400"}),"Favorites"]}),e.map(C=>x(C))]}),t.length>0&&w(t)]})}const qC=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function eU(){var c;const e=Yt(u=>u.currentProject),t=Re(u=>u.currentSession),n=bf(),r=j.useRef(0),a=j.useRef(null);j.useEffect(()=>(n?(a.current||(r.current=0),a.current=window.setInterval(()=>{r.current=(r.current+1)%qC.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?`${qC[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"&&((c=t==null?void 0:t.metadata)!=null&&c.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function dT({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return s.jsx(hl,{isOpen:e,onClose:t,onConfirm:a,title:"Delete Project",confirmLabel:"Delete",confirmVariant:"danger",message:s.jsxs(s.Fragment,{children:["This will permanently delete the project"," ",s.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]})})}function tU({isOpen:e,onClose:t}){const[,n]=Ln(),[r,a]=j.useState(!1),l=GN(),[c,u]=j.useState(!1),d=Yt(A=>A.projects),h=Yt(A=>A.createProject),p=Yt(A=>A.listProjects),m=Yt(A=>A.deleteProject),[g,x]=j.useState(null),[w,C]=j.useState(null);j.useEffect(()=>{e&&p()},[e,p]);const _=A=>{n(`/p/${A}`),t()},S=(A,O)=>{O.stopPropagation(),x(A)},v=()=>{g&&(m(g.id),x(null))},b=async A=>N(A);function k(A){return A!=null&&typeof A=="object"&&"error"in A&&A.error!=null&&typeof A.error=="object"&&"code"in A.error&&A.error.code==="EACCES"}async function N(A){const O=mu(A),P=await h(O,A);return p(),k(P)?(C(P.error.path||A),!1):P&&"id"in P?(n(`/p/${P.id}`),t(),!0):!1}const E=j.useCallback(()=>{C(null)},[]),D=j.useCallback(async()=>{const A=w;C(null),A&&await N(A)},[w]);return e?s.jsxs(St,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:s.jsx("div",{className:"flex justify-end gap-2",children:s.jsx(rt,{variant:"secondary",onClick:t,children:"Close"})}),children:[s.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[s.jsxs("div",{className:"w-full sm:w-1/2 border-b sm:border-b-0 sm:border-r border-border flex flex-col max-h-[40vh] sm:max-h-[50vh]",children:[s.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:s.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),s.jsx(dt,{className:"flex-1",children:d.length===0?s.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[s.jsx("p",{className:"mb-2",children:"No recent projects"}),s.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):s.jsx("div",{className:"divide-y divide-border",children:d.map(A=>s.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[s.jsxs("button",{onClick:()=>_(A.id),className:"flex-1 flex items-center gap-3 text-left",children:[s.jsx(Qr,{className:"w-5 h-5 text-accent-primary"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"font-medium truncate",children:A.name}),s.jsx("div",{className:"text-xs text-text-muted truncate",children:Xj(A.workdir,32)})]})]}),s.jsx("button",{onClick:O=>S(A,O),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:s.jsx(fi,{className:"w-4 h-4"})})]},A.id))})})]}),s.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:s.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[s.jsx(rt,{variant:"primary",onClick:()=>u(!0),children:"Select existing project"}),s.jsx(rt,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&s.jsx(VN,{isOpen:r,onClose:()=>a(!1)}),g&&s.jsx(dT,{isOpen:!0,onClose:()=>x(null),projectName:g.name,onConfirm:v}),c&&s.jsx(Ef,{initialPath:l??void 0,onSelect:A=>{b(A)},onClose:()=>u(!1)}),w&&s.jsx(UN,{isOpen:!0,onClose:E,path:w,onRetry:D})]}):null}const nU=[{key:"todo",label:"To Do",color:"text-blue-400"},{key:"queued",label:"Queued",color:"text-amber-400"},{key:"running",label:"Running",color:"text-emerald-400"},{key:"done",label:"Done",color:"text-text-muted"}];function rU({counts:e}){return!e||e.todo+e.queued+e.running+e.done===0?null:s.jsx("span",{className:"flex items-center gap-1.5",children:nU.map(n=>{const r=e[n.key];return r===0?null:s.jsxs("span",{title:n.label,className:`flex items-center gap-1 ${n.color}`,children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current"}),r]},n.key)})})}function sU(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,l]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(null),p=j.useRef(null),m=Re(R=>R.searchSessions??R.sessions),g=Re(R=>R.searchSessions!==null),x=Yt(R=>R.projects),w=Yt(R=>R.loading),C=Yt(R=>R.listProjects),_=Re(R=>R.listHomeSessions),S=Re(R=>R.ensureFullSessionList),v=Yt(R=>R.deleteProject),b=Re(R=>R.connectionStatus),k=It(R=>R.summaries),N=It(R=>R.loadSummaries);j.useEffect(()=>{b==="connected"&&(C(),_())},[b,C,_]);const E=x.map(R=>R.id).sort().join(",");j.useEffect(()=>{E&&N(E.split(","))},[E,N]),j.useEffect(()=>{const R=setTimeout(()=>u(a),150);return()=>clearTimeout(R)},[a]),j.useEffect(()=>{c&&!g&&S()},[c,g,S]);const{matchCount:D,filteredSessionIds:A,relevanceScores:O,matchTypes:P,promptSnippets:G}=j.useMemo(()=>{if(!c)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const R=new Map(x.map(J=>[J.id,J])),W=new Map,B=new Map,Z=new Map,Q=m.filter(J=>{var _e;const U=R.get(J.projectId),M=(U==null?void 0:U.name)??"",te=J.title??"",se=((_e=J.recentUserPrompts)==null?void 0:_e.map(Oe=>Oe.content))??[],re=se.join(" ");let le=0,ye="";if(qi(te,c)&&(le+=10,ye="title"),qi(re,c)){le+=3,ye=ye==="title"?"title":"prompts";const Oe=se.find(Be=>qi(Be,c));if(Oe){const Be=Oe.toLowerCase().indexOf(c.toLowerCase());if(Be>=0){const ke=Math.max(0,Be-30),Ge=Math.min(Oe.length,Be+c.length+30);Z.set(J.id,(ke>0?"…":"")+Oe.slice(ke,Ge)+(Ge<Oe.length?"…":""))}else Z.set(J.id,Oe.slice(0,80)+(Oe.length>80?"…":""))}}return qi(M,c)&&(le+=1,ye=ye||"project"),W.set(J.id,le),B.set(J.id,ye),le>0});return{matchCount:Q.length,filteredSessionIds:new Set(Q.map(J=>J.id)),relevanceScores:W,matchTypes:B,promptSnippets:Z}},[m,c,x]),z=j.useMemo(()=>{const R=new Map;for(const W of m){const B=new Date(W.updatedAt).getTime(),Z=R.get(W.projectId)??0;B>Z&&R.set(W.projectId,B)}return R},[m]),V=j.useMemo(()=>{const R=new Map;for(const W of m){const B=R.get(W.projectId);B?B.push(W):R.set(W.projectId,[W])}for(const[,W]of R)W.sort((B,Z)=>new Date(Z.updatedAt).getTime()-new Date(B.updatedAt).getTime());return R},[m]),$=j.useMemo(()=>{let R=x;return c&&A&&(R=x.filter(W=>{const B=V.get(W.id);return B==null?void 0:B.some(Z=>A.has(Z.id))})),[...R].sort((W,B)=>{const Z=z.get(W.id)??new Date(W.updatedAt).getTime();return(z.get(B.id)??new Date(B.updatedAt).getTime())-Z})},[x,V,c,A,z]),H=j.useCallback(R=>{const W=V.get(R);return W?c&&A&&O?W.filter(B=>A.has(B.id)).sort((B,Z)=>{const Q=(O.get(Z.id)??0)-(O.get(B.id)??0);return Q!==0?Q:new Date(Z.updatedAt).getTime()-new Date(B.updatedAt).getTime()}):W.slice(0,5):[]},[V,c,A,O]),q=()=>{t(!0)},X=()=>{var R;l(""),u(""),zt()&&((R=p.current)==null||R.focus())},Y=R=>{var W;R.key==="Escape"&&(X(),(W=p.current)==null||W.blur())},F=c.length>0,I=F&&D===0;return s.jsxs(dt,{className:"flex-1 flex flex-col bg-primary",children:[s.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),s.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),s.jsx(rt,{variant:"primary",onClick:q,children:"Open Project"})]}),m.length>0&&s.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(hi,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),s.jsx("input",{ref:p,type:"text",value:a,onChange:R=>l(R.target.value),onKeyDown:Y,placeholder:"Search sessions by title or keyword...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-10 pr-10 py-2.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),a&&s.jsx("button",{type:"button",onClick:X,className:"absolute right-3 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:s.jsx(ea,{className:"w-4 h-4"})})]}),F&&!I&&s.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[D," ",D===1?"match":"matches"]})]}),I?s.jsxs("div",{className:"text-center py-16 text-text-muted",children:[s.jsx(hi,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),s.jsxs("p",{className:"text-lg",children:["No sessions matching ",s.jsxs("span",{className:"text-text-primary font-medium",children:["“",c,"”"]})]}),s.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):$.map(R=>{const W=H(R.id);return s.jsx("div",{className:"mb-6 md:mb-8",children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[s.jsxs(yr,{href:`/p/${R.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[s.jsx(Qr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),s.jsx("span",{className:"text-text-primary font-semibold",children:R.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(rt,{variant:"secondary",size:"sm",onClick:()=>h(R.id),title:`Tasks for ${R.name}`,"aria-label":`Tasks for ${R.name}`,className:"flex items-center gap-1.5",children:[s.jsx(Ky,{className:"w-4 h-4"}),s.jsx("span",{children:"Tasks"}),s.jsx(rU,{counts:k[R.id]})]}),s.jsx(yr,{href:`/p/${R.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"})]}),s.jsx("button",{type:"button",onClick:()=>r({id:R.id,name:R.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:s.jsx(fi,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"divide-y divide-border",children:W.length>0?W.map(B=>{const Z=x.find(M=>B.projectId===M.id),Q=Z?`/p/${Z.id}/s/${B.id}`:"#",J=B.title??B.id.slice(0,8),U=P==null?void 0:P.get(B.id);return s.jsx(yr,{href:Q,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-muted truncate",children:F&&U==="title"?gy(J,c):J}),F&&U&&U!=="title"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[s.jsx("span",{className:"text-[10px] font-medium text-accent-primary border border-accent-primary/30 bg-accent-primary/8 rounded px-1 py-0.5 leading-none",children:U==="prompts"?"prompts":"project"}),U==="prompts"&&(G==null?void 0:G.get(B.id))&&s.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:gy(G.get(B.id),c)})]})]})}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:"text-text-muted text-xs",children:o7(B.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs",children:[B.messageCount," msgs"]})]})]})},B.id)}):s.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},R.id)}),!F&&$.length===0&&!w&&s.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),w&&s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ta,{})})]}),e&&s.jsx(tU,{isOpen:e,onClose:()=>t(!1)}),d&&s.jsx(Fb,{isOpen:!0,onClose:()=>h(null),projectId:d}),n&&s.jsx(dT,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>v(n.id)})]})}function iU(){const[,e]=xl("/p/:projectId/new"),[,t]=Ln(),n=e==null?void 0:e.projectId,r=Re(c=>c.createSession),a=Re(c=>c.resetPendingSessionCreate),l=j.useCallback(async()=>{if(!n)return;const c=await r(n);c?(t(`/p/${n}/s/${c.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return j.useEffect(()=>{l()},[l]),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ta,{})})}function aU(){const e=Yt(t=>t.currentProject);return s.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),s.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),s.jsxs("div",{className:"flex flex-col gap-3",children:[e&&s.jsx(yr,{href:`/p/${e.id}/new`,"data-testid":"create-new-session-button",className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),s.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const Ac=e=>Math.round(e*10)/10;function oU(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function yy(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function lU(e){return`${e.providerId}::${e.model}`}function cU(e){return`${e.providerName} > ${e.model}`}function KC(e){let t=0,n=0,r=0,a=0,l=0,c=0;const u=[],d=[];let h=0;for(const[g,x]of e.entries()){const w=x.stats,C=yy(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+=_,c+=S,u.push({messageId:x.id,timestamp:x.timestamp,...C,mode:w.mode,responseIndex:g+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const v=w.llmCalls??[];for(const b of v)h+=1,d.push({messageId:x.id,timestamp:b.timestamp??x.timestamp,providerId:b.providerId,providerName:b.providerName,backend:b.backend,model:b.model,mode:w.mode,responseIndex:g+1,sessionCallIndex:h,callIndex:b.callIndex,promptTokens:b.promptTokens,completionTokens:b.completionTokens,ttft:b.ttft,completionTime:b.completionTime,prefillSpeed:b.prefillSpeed,generationSpeed:b.generationSpeed,totalTime:b.totalTime,...b.temperature!==void 0&&{temperature:b.temperature},...b.topP!==void 0&&{topP:b.topP},...b.topK!==void 0&&{topK:b.topK},...b.maxTokens!==void 0&&{maxTokens:b.maxTokens}})}const p=l>0?Ac(r/l):0,m=c>0?Ac(a/c):0;return{totalTime:Ac(t),aiTime:Ac(t-n),toolTime:Ac(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:u,callDataPoints:d}}function uU(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&oU(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=lU(yy(a.stats)),c=n.get(l)??[];n.set(l,[...c,a])}const r=Array.from(n.entries()).map(([a,l])=>{const c=yy(l[0].stats),u=KC(l);return{...c,key:a,label:cU(c),...u}});return{...KC(t),modelGroups:r}}function dU(e){return j.useMemo(()=>uU(e),[e])}function Ub(){var a;const e=Re(l=>l.gitStatus),t=Re(l=>l.currentSession),[n,r]=j.useState(!0);return j.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 ml(e){return e.toLocaleString("en-US").replace(/,/g," ")}function YC(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Ts(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 c=Math.floor(t/60),u=t%60;return`${c}m ${u}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 XC=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),JC=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function ol(e){return Object.hasOwn(XC,e)?XC[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function hU(e){return Object.hasOwn(JC,e)?JC[e]:e.replace(/_/g," ")}const QC=["▁","▂","▃","▄","▅","▆","▇","█"];function fU(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 mU(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 pU(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,x)=>g.x-x.x),r=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(g=>g.y)),c=Math.max(...n.map(g=>g.y)),{minY:u,maxY:d}=mU(l,c),h=Math.max(0,u),p=Array.from({length:t},()=>" "),m=new Map;for(const g of n){const x=a===r?0:Math.round((g.x-r)/(a-r)*(t-1)),w=m.get(x)??[];m.set(x,[...w,g.y])}for(const[g,x]of m){const w=Math.max(...x);p[g]=QC[fU(w,u,d)]??QC[0]}return{blocks:p.join(""),minX:r,maxX:a,minY:h,maxY:d}}function ZC(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function ek({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:l,showAxes:c=!0,formatY:u=ZC,formatX:d=ZC}){const h=j.useMemo(()=>{const p=pU(e,t),m=Math.max(t*6,240),g=10,x=8,C=[...e].sort((b,k)=>b.x-k.x).map(b=>{const k=p.maxX===p.minX?m/2:g+(b.x-p.minX)/(p.maxX-p.minX)*(m-g*2),N=p.maxY===p.minY?n/2:x+(p.maxY-b.y)/(p.maxY-p.minY)*(n-x*2);return{...b,cx:k,cy:N,leftPercent:k/m*100,topPercent:N/n*100}}),_=C.map((b,k)=>`${k===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:x+(p.maxY-b)/(p.maxY-p.minY)*(n-x*2)}));return{...p,chartWidth:m,points:C,path:_,gridLines:v}},[e,n,t]);return e.length===0?s.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&s.jsx("div",{className:"mb-1",children:r}),s.jsx("div",{children:"No data"})]}):s.jsxs("div",{className:"font-mono text-xs",children:[r&&s.jsx("div",{className:"text-text-secondary mb-2",children:r}),s.jsxs("div",{className:"flex gap-3",children:[c&&s.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(p=>s.jsx("span",{children:u(p.value)},`${p.value}-${p.y}`))}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"relative h-[78px]",children:[s.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(p=>s.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=>s.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&&s.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(p=>s.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${u(p.y)}`,children:s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),c&&s.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[s.jsx("span",{className:"w-12"}),s.jsxs("span",{className:"flex-1 flex justify-between",children:[s.jsx("span",{children:d(h.minX)}),s.jsx("span",{children:a}),s.jsx("span",{children:d(h.maxX)})]})]}),l&&c&&s.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function gU({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(u=>({x:u.x,y:u.ppSpeed})),c=e.map(u=>({x:u.x,y:u.tgSpeed}));return s.jsxs("div",{className:"space-y-5",children:[s.jsx(ek,{data:l,width:a,label:t,xLabel:r}),s.jsx(ek,{data:c,width:a,label:n,xLabel:r})]})}function xU(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 yU(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 bU(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 vU(e){return e.callDataPoints.length>0?bU(e):yU(e)}function Ka(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function zc(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function _U(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Ka(t)} ctx`:`${Ka(t)}-${Ka(n)} ctx`}function Zh(e){return`${zc(e)} t/s`}function hT(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function SU(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 wU({isOpen:e,onClose:t,stats:n}){const r=j.useRef(null),[a,l]=j.useState({}),[c,u]=j.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});j.useEffect(()=>{var w;n.modelGroups.some(C=>C.key===c)||u(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[c,n.modelGroups]);const d=j.useMemo(()=>n.modelGroups.find(w=>w.key===c)??n.modelGroups[0],[c,n.modelGroups]),h=j.useMemo(()=>d?xU(d):[],[d]),p=j.useMemo(()=>d?vU(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=j.useCallback(w=>{l(C=>({...C,[w]:!C[w]}))},[]),g=j.useCallback(()=>{if(!d)return;const w=SU(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),x=j.useCallback(async()=>{if(r.current)try{const w=(await ne(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),g()}},[g]);return s.jsx(St,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:s.jsxs("div",{ref:r,className:"space-y-6",children:[s.jsx("section",{children:s.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>s.jsx("button",{onClick:()=>u(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.key===(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&&s.jsxs("section",{children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[s.jsx(ti,{label:"AI Time",value:Ts(d.aiTime)}),s.jsx(ti,{label:"Total Time",value:Ts(d.totalTime)}),s.jsx(ti,{label:"Tool Time",value:Ts(d.toolTime)}),s.jsx(ti,{label:"Responses",value:d.responseCount.toString()}),s.jsx(ti,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[s.jsx(ti,{label:"Prefill Tokens",value:Ka(d.prefillTokens),subValue:`@ ${zc(d.avgPrefillSpeed)} tok/s`}),s.jsx(ti,{label:"Gen Tokens",value:Ka(d.generationTokens),subValue:`@ ${zc(d.avgGenerationSpeed)} tok/s`}),s.jsx(ti,{label:"Avg PP Speed",value:`${zc(d.avgPrefillSpeed)}`,subValue:"tok/s"}),s.jsx(ti,{label:"Avg TG Speed",value:`${zc(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.points.length>1&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:g,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),s.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),s.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:s.jsx(gU,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),d&&s.jsxs("section",{children:[s.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.responseCount," responses)"]}),s.jsx(dt,{className:"bg-bg-tertiary/30 rounded",children:s.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"w-[7%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[10%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[11%]"}),s.jsx("col",{className:"w-[2%]"})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[s.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),s.jsx("th",{className:"px-2 py-2"})]})}),s.jsx("tbody",{children:h.map((w,C)=>s.jsxs(j.Fragment,{children:[s.jsx(CU,{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)=>s.jsx(kU,{dataPoint:_,index:S},`${_.messageId}-${_.callIndex}`))]},w.messageId))})]})})]})]})})}function ti({label:e,value:t,subValue:n}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),s.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&s.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function CU({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?_U(e.calls.map(l=>l.promptTokens)):`${Ka(e.prefillTokens)} ctx`;return s.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[s.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:hT(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ts(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Zh(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Zh(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function kU({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[s.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:hT(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ts(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Ka(e.promptTokens)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Zh(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Zh(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),s.jsx("td",{className:"px-2 py-2"})]}),n&&s.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:s.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:s.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&s.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&s.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&s.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&s.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const jU={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"}},fT=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function EU(e){return jU[e]??{icon:"○",color:"text-text-muted"}}function Vb(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const El=j.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=EU(t);return s.jsx("span",{className:`${a} ${n}`,children:r})});function ef({entries:e,title:t}){const n=j.useMemo(()=>e.reduce((r,a)=>(r[a.status]=(r[a.status]??0)+1,r),{}),[e]);return s.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[s.jsx("span",{children:t}),Object.keys(n).length>0&&s.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:fT.map(r=>{const a=n[r];return a?s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(El,{status:r}),s.jsx("span",{children:a})]},r):null})})]})}const mT=j.memo(function({entries:t,title:n,onClearAll:r}){const[a,l]=j.useState(!1),c=j.useCallback(()=>{l(!1),r==null||r()},[r]);return t.length===0?null:s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&s.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),s.jsx("div",{className:"bg-primary",children:t.map((u,d)=>s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[s.jsx(El,{status:u.status}),s.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[s.jsxs("span",{className:"text-text-muted",children:["[",u.id,"]"]})," ",Vb(u.description)]})]},u.id??d))}),r&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:s.jsxs("button",{onClick:()=>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:[s.jsx(fi,{className:"w-3 h-3"}),"Clear all"]})}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:c,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>l(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),NU={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},TU=["pending","completed","failed","dismissed"];function AU(e){return NU[e]??TU}function LU(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function pT({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:l}){const[c,u]=j.useState(e),[d,h]=j.useState(null),[p,m]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(""),_=j.useRef(null),S=j.useRef(null),v=j.useCallback(()=>{const z=S.current;z&&(z.style.height="auto",z.style.height=z.scrollHeight+"px")},[]);j.useEffect(()=>{u(e)},[e]),j.useEffect(()=>{var z;d&&(v(),zt()&&((z=S.current)==null||z.focus()))},[d,v]),j.useEffect(()=>{var z;g&&zt()&&((z=_.current)==null||z.focus())},[g]);const b=j.useCallback(z=>{u(z),xe(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:z})}).catch(V=>console.error(`Failed to sync ${n}:`,V))},[t,n]),k=j.useCallback(z=>{const V=AU(n),$=c.map(H=>H.id===z?{...H,status:LU(H.status,V)}:H);b($)},[c,n,b]),N=j.useCallback((z,V)=>{h(z),m(V)},[]),E=j.useCallback((z,V,$)=>{var X;const H=(V.trim()||((X=$.find(Y=>Y.id===z))==null?void 0:X.description))??"",q=$.map(Y=>Y.id===z?{...Y,description:H}:Y);b(q)},[b]),D=j.useCallback(()=>{d&&(E(d,p,c),h(null))},[d,p,c,E]),A=j.useCallback(z=>{z.key==="Enter"&&D(),z.key==="Escape"&&(z.stopPropagation(),h(null))},[D]),O=j.useCallback(z=>{b(c.filter(V=>V.id!==z))},[c,b]),P=j.useCallback(()=>{const z=w.trim();if(!z)return;const V=c.map(H=>Number(H.id)).filter(H=>Number.isInteger(H)&&H>=0),$=String(Math.max(-1,...V)+1);b([...c,{id:$,description:z,status:"pending"}]),C("")},[w,c,b]),G=j.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),P()),z.key==="Escape"&&(x(!1),C(""))},[P]);return s.jsxs(St,{isOpen:a,onClose:l,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[s.jsxs("ul",{className:"space-y-1",children:[c.map((z,V)=>{const $=d===z.id,H=s.jsxs("button",{onClick:()=>N(z.id,z.description),className:"text-sm text-text-primary text-left hover:text-accent-primary transition-colors w-full cursor-pointer",title:"Click to edit",children:[s.jsxs("span",{className:"text-text-muted",children:["[",z.id,"]"]})," ",s.jsx("span",{children:Vb(z.description)})]}),q=$?s.jsx("textarea",{ref:S,value:p,onChange:X=>{m(X.target.value),v()},onBlur:D,onKeyDown:A,className:"w-full bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary resize-none",rows:1}):H;return s.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${V>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>k(z.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:s.jsx(El,{status:z.status})}),s.jsx("div",{className:"flex-1 min-w-0",children:q}),s.jsx("button",{onClick:()=>O(z.id),className:"flex-shrink-0 text-text-muted hover:text-accent-error transition-colors cursor-pointer mt-0.5 ml-auto",title:"Delete entry",children:s.jsx("span",{className:"flex",children:s.jsx(ea,{className:"w-4 h-4"})})})]},z.id)}),c.length===0&&s.jsx("p",{className:"text-sm text-text-muted italic text-center py-4",children:"No entries yet."})]}),s.jsx("div",{className:"mt-4 pt-3 border-t border-border",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight",children:"○"}),s.jsx("input",{ref:_,value:w,onChange:z=>C(z.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"}),s.jsxs("button",{onClick:P,className:"flex items-center gap-1 text-sm text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add entry",children:[s.jsx(es,{className:"w-4 h-4"}),"Add"]})]})})]})}const DU={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function RU(e,t){await xe(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function nh({id:e,agents:t}){const n=Ja(t,e),r=t.find(a=>a.id===e);return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function OU({id:e}){const t=$t(c=>c.defaults),n=$t(c=>c.userItems),a=j.useMemo(()=>[...t,...n],[t,n]).find(c=>c.id===e),l=(a==null?void 0:a.color)??"#3b82f6";return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${l}20`,color:l},children:(a==null?void 0:a.name)??e})}function gT({entries:e,sessionId:t}){const[n,r]=j.useState(e),[a,l]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(""),[p,m]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(!1),_=ut(Y=>Y.defaults),S=ut(Y=>Y.userItems),v=ut(Y=>Y.projectItems),b=j.useMemo(()=>[..._,...S,...v],[_,S,v]),k=j.useRef(null),N=j.useRef(null);j.useEffect(()=>{r(e)},[e]),j.useEffect(()=>{var Y;a&&zt()&&((Y=k.current)==null||Y.focus())},[a]),j.useEffect(()=>{var Y;c&&zt()&&((Y=N.current)==null||Y.focus())},[c]);const E=j.useCallback(Y=>{r(Y),RU(t,Y)},[t]),D=j.useCallback(Y=>{var B;const F=Y.map(Z=>Z.trim()).filter(Boolean);if(F.length===0)return;const I=n.map(Z=>Number(Z.id)).filter(Z=>Number.isInteger(Z)&&Z>=0),R=Math.max(-1,...I)+1,W=F.map((Z,Q)=>({id:String(R+Q),description:Z,status:"pending"}));E([...n,...W]),h(""),zt()&&((B=k.current)==null||B.focus())},[n,E]),A=j.useCallback(()=>{D([d])},[D,d]),O=j.useCallback(Y=>{const F=Y.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);F.length<2||(Y.preventDefault(),D(F))},[D]),P=j.useCallback(()=>{l(!1),h("")},[]),G=j.useCallback((Y,F)=>{u(Y),m(F)},[]),z=j.useCallback(()=>{if(!c)return;const Y=p.trim(),F=n.map(I=>I.id===c?{...I,description:Y||I.description}:I);E(F),u(null)},[c,p,n,E]),V=j.useCallback(Y=>{const F=n.map(I=>I.id===Y?{...I,status:DU[I.status]??"pending"}:I);E(F)},[n,E]),$=j.useCallback(Y=>{E(n.filter(F=>F.id!==Y))},[n,E]),H=j.useCallback(()=>{E([]),x(!1)},[E]),q=j.useCallback(Y=>{Y.key==="Enter"&&(Y.preventDefault(),A()),Y.key==="Escape"&&P()},[A,P]),X=j.useCallback(Y=>{Y.key==="Enter"&&z(),Y.key==="Escape"&&u(null)},[z]);return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&s.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",s.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((Y,F)=>{const I=Y.status,R=c===Y.id;return s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${F>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>V(Y.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${Y.status} (click to cycle)`,children:s.jsx(El,{status:I})}),s.jsx("div",{className:"flex-1 min-w-0",children:R?s.jsx("input",{ref:N,value:p,onChange:W=>m(W.target.value),onBlur:z,onKeyDown:X,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):s.jsxs("button",{onClick:()=>G(Y.id,Y.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:["[",Y.id,"] ",Vb(Y.description)]})}),s.jsx("button",{onClick:()=>$(Y.id),className:"flex-shrink-0 opacity-0 group-hover:opacity-100 text-text-muted hover:text-accent-error transition-all ml-0.5 cursor-pointer flex items-center self-center",title:"Delete criterion",children:s.jsx(ea,{className:"w-4 h-4"})})]},Y.id)})]}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),s.jsx("input",{ref:k,value:d,onChange:Y=>h(Y.target.value),onKeyDown:q,onPaste:O,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),s.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:A,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[s.jsx(es,{className:"w-3 h-3"}),"Add"]}),s.jsx("button",{onClick:P,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):s.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:[s.jsx(es,{className:"w-3 h-3"}),"Add"]}),n.length>0&&(g?s.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),s.jsx("button",{onClick:H,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>x(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]}):s.jsxs("button",{onClick:()=>x(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[s.jsx(fi,{className:"w-3 h-3"}),"Clear all"]})),s.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:s.jsx(_f,{className:"w-3 h-3"})})]}),s.jsx(St,{isOpen:w,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:s.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[s.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),s.jsxs("p",{children:["To use this feature, start in ",s.jsx(nh,{id:"planner",agents:b})," mode and",s.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",s.jsx(OU,{id:"default"})," builtin workflow to launch the automation part."]}),s.jsx("p",{children:"This workflow will automatically:"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["Launch the ",s.jsx(nh,{id:"builder",agents:b}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),s.jsxs("li",{children:["Then launch the ",s.jsx(nh,{id:"verifier",agents:b})," subagent, that will verify each criterion. If every criterion is fulfilled, then it goes to the next step, otherwise, it gives feedback to the main agent until 100% of the criteria are met."]}),s.jsxs("li",{children:["Launch a ",s.jsx(nh,{id:"code_reviewer",agents:b})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),s.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:s.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function xT({isOpen:e,onClose:t}){const n=Jn(C=>C.config),r=Jn(C=>C.saveConfig),[a,l]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(!1),[p,m]=j.useState(!1),[g,x]=j.useState(!1);j.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),u((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()||!c.trim()||(x(!0),await r({command:a.trim(),url:c.trim(),hotReload:d,disableInspect:p}),x(!1),t())};return s.jsx(St,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),s.jsx("input",{className:"input w-full",type:"text",value:a,onChange:C=>l(C.target.value),placeholder:"npm run dev"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),s.jsx("input",{className:"input w-full",type:"text",value:c,onChange:C=>u(C.target.value),placeholder:"http://localhost:3000"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>h(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:C=>m(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn btn-primary",onClick:w,disabled:g||!a.trim()||!c.trim(),children:g?"Saving...":"Save"})]})]})})}const tk={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"},IU={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"},nk={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},MU="text-text-primary";function PU(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 c=l[1];if(!c)continue;const u=c.split(";").map(Number);if(u.length===0||u[0]===0){a="text-text-primary";continue}const d=[];for(const h of u)if(h>=30&&h<=37){const p=tk[h];p&&d.push(p)}else if(h>=40&&h<=47){const p=IU[h];p&&d.push(p)}else if(h>=90&&h<=97){const p=tk[h];p&&d.push(p)}else if(h in nk){const p=nk[h];p&&d.push(p)}else h===39?d.push(MU):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 c=e.slice(r);c&&t.push({text:c,className:a})}return t}catch(c){return console.warn("ANSI parsing failed, stripping codes:",c),[{text:BU(e),className:"text-text-primary"}]}}function BU(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function tf(e){const t=PU(e),n=[];return t.forEach((r,a)=>{const l=r.text.split(`
285
+ `);l.forEach((c,u)=>{n.push(cs.createElement("span",{key:`${a}-${u}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},c)),u<l.length-1&&n.push(cs.createElement("br",{key:`${a}-${u}-br`}))})}),n.length===1?n[0]:n}function yT({logs:e,preRef:t,preClassName:n="text-sm font-mono",scrollAreaRef:r,onScrollbarGesture:a}){return s.jsx(dt,{ref:r,options:{overflow:{x:"scroll",y:"scroll"}},className:n,onScrollbarGesture:a,children:s.jsx("pre",{ref:t,className:"contents",children:e.length===0?s.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((l,c)=>l.type==="marker"?s.jsx(j.Fragment,{children:s.jsx("hr",{className:"border-t border-border my-1"})},c):s.jsx("span",{className:l.stream==="stderr"?"text-accent-warning":"",children:tf(l.content)},c))})})}function Gb({isActive:e,onToggle:t,className:n,style:r}){return s.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):s.jsx(pn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const $U=100,zU=6,HU=1500,bT=(e,t)=>e==="down"?!1:t!==null&&t<=zU,Su=(e,t,n)=>{const r=j.useRef(!0),a=j.useRef(null),l=j.useRef(!1),c=j.useRef(0),u=j.useRef(!1),d=j.useRef(0),[h,p]=j.useState(!0),m=j.useCallback(()=>{if(n)return n();const b=e.current;return b instanceof HTMLElement?b:null},[n,e]),g=j.useCallback(b=>{b||(d.current+=1),r.current=b,p(b)},[]),x=j.useCallback(()=>{g(!1)},[g]),w=j.useCallback(()=>{if(!r.current)return;const b=m();b&&(u.current=!0,b.scrollTop=b.scrollHeight,requestAnimationFrame(()=>{requestAnimationFrame(()=>{u.current=!1})}),c.current=Date.now())},[m]),C=j.useCallback((b,k)=>{b==="down"&&(l.current=!0);const N=bT(b,k);g(N),N&&(c.current=Date.now()),b==="up"&&(l.current=!1)},[g]),_=j.useRef(null);j.useEffect(()=>{if(t!=null&&t.id)return _.current!==null&&(cancelAnimationFrame(_.current),_.current=null),g(!0),c.current=Date.now(),_.current=requestAnimationFrame(()=>{requestAnimationFrame(()=>{w(),_.current=null})}),()=>{_.current!==null&&(cancelAnimationFrame(_.current),_.current=null)}},[t==null?void 0:t.id,g,w]),j.useEffect(()=>{const b=m();if(!b)return;const k=()=>{const z=d.current;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(z!==d.current)return;b.scrollHeight-b.scrollTop-b.offsetHeight<$U&&(c.current=Date.now(),g(!0))})})},N=z=>{if(z.deltaY>0){k();return}x()},E=z=>{z.touches[0]&&(a.current=z.touches[0].clientY)},D=z=>{if(a.current===null)return;const V=z.touches[0];if(!V)return;if(V.clientY-a.current>0){x();return}k()},A=()=>{l.current||u.current||Date.now()-c.current<=HU||g(!1)},O=z=>{if(!(z.ctrlKey||z.metaKey||z.altKey)){if(z.key==="ArrowUp"||z.key==="PageUp"||z.key==="Home"){x();return}(z.key==="ArrowDown"||z.key==="PageDown"||z.key==="End")&&k()}},P=new MutationObserver(()=>{r.current&&requestAnimationFrame(w)}),G=setInterval(()=>{r.current&&w()},1e3);return b.addEventListener("wheel",N,{passive:!0}),b.addEventListener("touchstart",E,{passive:!0}),b.addEventListener("touchmove",D,{passive:!0}),b.addEventListener("scroll",A,{passive:!0}),b.addEventListener("keydown",O),b.tabIndex=-1,P.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("wheel",N),b.removeEventListener("touchstart",E),b.removeEventListener("touchmove",D),b.removeEventListener("scroll",A),b.removeEventListener("keydown",O),P.disconnect(),clearInterval(G)}},[t==null?void 0:t.id,m,w,g,x]);const S=j.useCallback(()=>{g(!0),w()},[g,w]),v=j.useCallback(b=>{g(b),b&&w()},[g,w]);return{force_scroll_to_bottom:S,isAutoScrollActive:h,setAutoScroll:v,handleScrollbarGesture:C}},wu=e=>j.useCallback(()=>{var t,n;return((n=(t=e.current)==null?void 0:t.osInstance())==null?void 0:n.elements().viewport)??null},[e]),Wb=j.memo(function({title:t,subtitle:n,logs:r,onClose:a,onClear:l,onInsertMarker:c,preClassName:u}){const d=j.useRef(null),h=wu(d),{isAutoScrollActive:p,setAutoScroll:m,handleScrollbarGesture:g}=Su(d,null,h);return s.jsxs(St,{isOpen:!0,onClose:a,title:t,size:"full",scrollable:!1,headerRight:s.jsx(Gb,{isActive:p,onToggle:m,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),footer:s.jsxs("div",{className:"flex items-center gap-2",children:[c&&s.jsxs("button",{onClick:c,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Insert marker",children:[s.jsx(es,{className:"w-3.5 h-3.5"}),"Marker"]}),l&&s.jsxs("button",{onClick:l,className:"text-xs text-text-muted hover:text-accent-error flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Clear logs",children:[s.jsx(fi,{className:"w-3.5 h-3.5"}),"Clear"]})]}),children:[n&&s.jsxs("div",{className:"subtitle-strip flex items-start gap-2 px-2 py-1.5 mb-2 bg-bg-tertiary rounded text-[11px] font-mono text-text-secondary whitespace-pre-wrap break-all border border-border",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0 select-none",children:"Command:"}),s.jsx("span",{children:n})]}),s.jsx(dt,{ref:d,className:"flex-1 -m-4 p-4",onScrollbarGesture:g,children:s.jsx(yT,{logs:r,preClassName:u})})]})}),FU=j.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:l}){const[c,u]=j.useState(null),d=j.useRef(null),h=j.useRef(l);h.current=l;const p=j.useCallback((g,x)=>{l(bT(g,x))},[l]),m=j.useCallback(()=>{var g,x;return((x=(g=d.current)==null?void 0:g.osInstance())==null?void 0:x.elements().viewport)??null},[]);return j.useEffect(()=>{var x;const g=(x=n.current)==null?void 0:x.getBoundingClientRect();g&&u({bottom:window.innerHeight-g.bottom,right:window.innerWidth-g.right,width:g.width,height:g.height})},[n]),j.useEffect(()=>{const g=m();if(!g)return;const x=w=>{if(w.deltaY<0){h.current(!1);return}w.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{g.scrollHeight-g.scrollTop-g.offsetHeight<100&&h.current(!0)}))};return g.addEventListener("wheel",x,{passive:!0}),()=>g.removeEventListener("wheel",x)},[m]),j.useEffect(()=>{const g=m();g&&a&&(g.scrollTop=g.scrollHeight)},[t,a,c,m]),s.jsx("div",{className:`relative ${c?"":"hidden"}`,children:s.jsx(dt,{ref:d,className:"fixed z-40 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border transition-all duration-150 ease-out select-text",onScrollbarGesture:p,style:c?{bottom:c.bottom,right:c.right,width:c.width*2,maxHeight:c.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:s.jsx("pre",{className:"text-sm font-mono",children:t.map((g,x)=>s.jsx("span",{className:g.stream==="stderr"?"text-accent-warning":"",children:tf(g.content)},x))})})})}),vT=j.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const l=Jn(R=>R.setWorkdir),c=Jn(R=>R.status),u=Jn(R=>R.config),d=Jn(R=>R.logs),h=Jn(R=>R.start),p=Jn(R=>R.stop),m=Jn(R=>R.fetchLogs),g=Jn(R=>R.clearLogs),x=Jn(R=>R.insertMarker),w=()=>{window.confirm("Clear all dev server logs?")&&g()},[C,_]=j.useState(!1),[S,v]=j.useState(!1),[b,k]=j.useState(!1),[N,E]=j.useState(!1),D=j.useRef(null),A=j.useRef(null),O=j.useCallback(()=>{var R,W;return((W=(R=A.current)==null?void 0:R.osInstance())==null?void 0:W.elements().viewport)??null},[]),{isAutoScrollActive:P,setAutoScroll:G,handleScrollbarGesture:z}=Su(A,null,O),V=j.useRef(null),$=j.useRef(null),H=j.useRef(null),q=()=>{const R=c==null?void 0:c.inspectProxyPort;if(!R){c!=null&&c.url&&window.open(c.url,"_blank");return}const W=`${window.location.protocol}//${window.location.hostname}:${R}`;window.open(W,"_blank")},X=(c==null?void 0:c.state)??"off",Y=u!==null,F=X==="running"||X==="warning";j.useEffect(()=>{l(t??null)},[t,l]),j.useEffect(()=>{F&&m()},[F,m]);const I=()=>{F?p():h()};return s.jsxs("div",{className:`space-y-3 ${n?"":"mt-2 pt-3 border-t border-border"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${X==="running"?"bg-accent-success":X==="warning"?"bg-accent-warning":X==="error"?"bg-accent-error":"bg-text-muted"}`}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),s.jsx("button",{onClick:()=>{a?a():_(!0)},className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:s.jsx(W5,{})})]}),Y?s.jsx(s.Fragment,{children:X==="running"||X==="warning"?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:I,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[s.jsx(qy,{}),"Stop"]}),(c==null?void 0:c.url)&&s.jsxs("button",{onClick:()=>q(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:c.url,children:[s.jsx(Wy,{}),"Open"]})]}):s.jsx("button",{onClick:I,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"})}):s.jsx("button",{onClick:()=>{a?a():_(!0)},className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),s.jsxs("div",{ref:H,className:`relative ${Y&&F?"":"hidden"}`,onMouseEnter:()=>{!Y||!F||n||($.current&&clearTimeout($.current),V.current=setTimeout(()=>{k(!0),E(!1)},500))},onMouseLeave:()=>{V.current&&clearTimeout(V.current),E(!0),$.current=setTimeout(()=>k(!1),150)},children:[s.jsx(yT,{logs:d,preRef:D,preClassName:"text-sm bg-bg-primary p-2 rounded max-h-[200px] border border-border",scrollAreaRef:A,onScrollbarGesture:z}),Y&&F&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[!n&&(b||N)&&s.jsx(Gb,{isActive:P,onToggle:G,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),s.jsx("button",{onClick:()=>n?r==null?void 0:r():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)&&H.current&&mi.createPortal(s.jsx(FU,{logs:d,anchorRef:H,isHiding:N,isAutoScrollActive:P,onSetAutoScroll:G}),document.body)]})]}),!a&&s.jsx(xT,{isOpen:C,onClose:()=>_(!1)}),S&&s.jsx(Wb,{title:"Dev Server Logs",logs:d,onClose:()=>v(!1),onClear:w,onInsertMarker:x})]})}),UU=j.memo(function({sessionId:t}){const n=Hc(x=>x.processes),r=Hc(x=>x.stopProcess),[a,l]=j.useState(null),[c,u]=j.useState([]),d=n.filter(x=>x.status!=="exited"),h=d.filter(x=>x.status==="running").length;if(n.length===0)return null;const p=x=>{switch(x){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=x=>{const w=Hc.getState().logs[x]??[];u(w.map(C=>({content:C.content,stream:C.stream}))),l(x)},g=x=>{t&&r(x,t)};return s.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),s.jsx("div",{className:"space-y-2",children:d.map(x=>s.jsx("div",{className:"border border-border rounded p-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(x.status)}`}),s.jsx("span",{className:"text-sm text-text-primary truncate",title:x.name,children:x.name}),s.jsxs("span",{className:"text-xs text-text-muted",children:["[",x.status,"]"]})]}),s.jsxs("div",{className:"flex gap-1 ml-2",children:[s.jsx("button",{onClick:()=>m(x.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),s.jsx("button",{onClick:()=>g(x.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},x.id))}),a&&(()=>{const x=d.find(w=>w.id===a);return s.jsx(Wb,{title:(x==null?void 0:x.name)??"",subtitle:x==null?void 0:x.command,logs:c,onClose:()=>{l(null),u([])}})})()]})});function _T(){return en.getState().platform??null}function ST(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function wT(e,t,n){const r=_T(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,l=ST(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${l}`}:${t??1}`;const c=`vscode://file/${l}`;return t?`${c}:${t}`:c}function VU(e){const t=_T(),n=ST(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function GU({file:e,showEditorLink:t,workdir:n}){const r=Xj(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}`:"",c=t&&n?wT(e.path,void 0,n):void 0,u=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),l&&s.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 c?s.jsx("a",{href:c,className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0 hover:bg-bg-tertiary rounded px-1 transition-colors no-underline",title:`Open ${e.path} in VSCode`,children:u}):s.jsx("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:u})}function WU(){const{diff:e}=Ub(),t=Lt(a=>a.settings[Ee.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",n=Re(a=>a.currentSession),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?s.jsx("div",{className:"mt-3",children:s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[s.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),s.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?s.jsx("div",{className:"mt-3",children:s.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):s.jsx(dt,{className:"mt-3 max-h-[150px]",children:s.jsx("div",{className:"pr-1",children:e.files.map((a,l)=>s.jsx(GU,{file:a,showEditorLink:t,workdir:r},l))})})}function CT(e){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[l,c]=j.useState(!1),[u,d]=j.useState(""),h=j.useCallback(()=>{t||e()},[t,e]),p=u.trim().length>0&&!t,m=j.useCallback(()=>{a(null),n(!1),d(""),c(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:l,setLoading:c,newName:u,setNewName:d,handleClose:h,canCreate:p,resetState:m}}function kT({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:l}){const c=s.jsx("div",{className:"flex gap-2 justify-end",children:s.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Cancel"})});return s.jsx(St,{isOpen:e,onClose:t,title:n,size:"md",footer:c,children:a||r?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ta,{})}):l})}function jT({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:l,onCreate:c,canCreate:u,busy:d}){return s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:t}),s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded border border-border bg-bg-primary focus-within:border-accent-primary mb-3",children:[s.jsx("span",{className:"w-4 h-4 shrink-0 text-text-muted flex items-center",children:e}),s.jsx("input",{type:"text",value:a,onChange:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&u&&c()},placeholder:n,className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),s.jsx("button",{onClick:c,disabled:!u||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 ET({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:l}){const c=Re(V=>V.loadSession),{busy:u,setBusy:d,error:h,setError:p,loading:m,setLoading:g,newName:x,setNewName:w,handleClose:C,canCreate:_,resetState:S}=CT(t),[v,b]=j.useState([]),[k,N]=j.useState(null),[E,D]=j.useState(null),[A,O]=j.useState(!1);j.useEffect(()=>{e&&(S(),N(null),D(null),O(!1),xe(`/api/projects/${n}/workspaces`).then(V=>V.json()).then(V=>{b(V.workspaces),g(!1)}).catch(()=>{b([]),g(!1)}))},[e,n,S,g]);const P=j.useCallback(async V=>{p(null),d(!0);try{const $=await xe(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:V})});if(!$.ok){const H=await $.json().catch(()=>({error:"Failed to switch workspace"}));p(H.error),d(!1);return}await c(r,!0),t()}catch($){p($ instanceof Error?$.message:"Failed to switch workspace"),d(!1)}},[r,c,t,p,d]),G=j.useCallback(async(V,$)=>{p(null),D(null),O(($==null?void 0:$.force)===!0),d(!0);try{const H=await xe(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:V,force:($==null?void 0:$.force)===!0})});if(!H.ok){const Y=await H.json().catch(()=>({error:"Failed to delete workspace"}));p(Y.error),Y.conflictingSessionIds&&D(Y.conflictingSessionIds),O(!1),d(!1);return}N(null),O(!1),await c(r,!0);const X=await(await xe(`/api/projects/${n}/workspaces`)).json();b(X.workspaces),d(!1),g(!1)}catch(H){p(H instanceof Error?H.message:"Failed to delete workspace"),O(!1),d(!1)}},[r,n,c,p,d]),z=j.useCallback(async()=>{p(null),d(!0);try{const V=await xe(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:x.trim()})});if(!V.ok){const $=await V.json().catch(()=>({error:"Failed to create workspace"}));p($.error),d(!1);return}await c(r),t()}catch(V){p(V instanceof Error?V.message:"Failed to create workspace"),d(!1)}},[x,r,c,t,p,d]);return s.jsx(kT,{isOpen:e,onClose:C,title:"Switch Workspace",busy:u,loading:m,children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),s.jsxs(dt,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[s.jsxs("button",{onClick:()=>P("original"),disabled:u,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${a?"hover:bg-bg-tertiary text-text-secondary":"bg-accent-primary/10 text-accent-primary cursor-default"}`,children:[s.jsx(Qr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:"original"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:l??"unknown"}),!a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),v.slice().sort((V,$)=>V.name===a?-1:$.name===a?1:V.name.localeCompare($.name)).map(V=>s.jsx("div",{className:"group relative",children:k===V.name?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[s.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",V.name,"?"]}),s.jsx("button",{onClick:()=>G(V.name),disabled:u,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),s.jsx("button",{onClick:()=>N(null),disabled:u,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>{!u&&V.name!==a&&P(V.name)},disabled:u||V.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${V.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${u?"opacity-70":""}`,children:[s.jsx(Qr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:V.name}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:V.branch??"unknown"}),V.name===a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),V.name!==a&&!u&&s.jsx("button",{onClick:$=>{$.stopPropagation(),p(null),D(null),N(V.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:"✕"})]})},V.path))]}),s.jsx(jT,{icon:s.jsx(Qr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:x,onChange:w,onCreate:z,canCreate:_,busy:u}),h&&s.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[s.jsx("p",{className:"text-accent-error",children:h}),E&&E.length>0&&s.jsxs("div",{className:"mt-2 space-y-1",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),s.jsx("ul",{className:"space-y-0.5",children:E.map(V=>s.jsx("li",{children:s.jsx(yr,{href:`/p/${n}/s/${V}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:V})},V))}),s.jsx("button",{onClick:()=>G(k??"",{force:!0}),disabled:u||!k,className:"mt-2 text-xs px-2 py-1 rounded bg-accent-warning text-black hover:opacity-90 disabled:opacity-50","aria-label":"Force delete workspace, switching other sessions to original",children:A?"Processing...":"Force Delete (switch other sessions to original)"})]})]})]})})}function NT({isOpen:e,onClose:t,sessionId:n}){const r=Re(D=>D.loadSession),{busy:a,setBusy:l,error:c,setError:u,loading:d,setLoading:h,newName:p,setNewName:m,handleClose:g,canCreate:x,resetState:w}=CT(t),[C,_]=j.useState([]),[S,v]=j.useState(""),[b,k]=j.useState("");j.useEffect(()=>{e&&(w(),v(""),_([]),k(""),xe(`/api/sessions/${n}/branches`).then(D=>D.json()).then(D=>{_(D.branches),k(D.defaultBranch??""),h(!1)}).catch(()=>{_([]),h(!1)}))},[e,n,w,h]);const N=j.useCallback(async D=>{u(null),l(!0);try{const A=await xe(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:D})});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to switch branch"}));u(O.error),l(!1);return}await r(n,!0),t()}catch(A){u(A instanceof Error?A.message:"Failed to switch branch"),l(!1)}},[n,r,t,u,l]),E=j.useCallback(async()=>{u(null),l(!0);try{const D={name:p.trim()};S&&(D.sourceBranch=S);const A=await xe(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to create branch"}));u(O.error),l(!1);return}await r(n),t()}catch(D){u(D instanceof Error?D.message:"Failed to create branch"),l(!1)}},[p,S,n,r,t,u,l]);return s.jsx(kT,{isOpen:e,onClose:g,title:"Switch Branch",busy:a,loading:d,children:s.jsxs("div",{children:[C.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Branches"}),s.jsx(dt,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(D=>s.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:[s.jsx(Va,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:D.name}),D.current&&s.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!D.current&&s.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},D.name))})]}),s.jsx(jT,{icon:s.jsx(Va,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:p,onChange:m,onCreate:E,canCreate:x,busy:a}),p.trim()&&s.jsxs("div",{className:"mt-2",children:[s.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",b||"project default",")"]}),s.jsxs("div",{className:"relative",children:[s.jsx(Va,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{type:"text",value:S,onChange: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"})]})]}),c&&s.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:c})]})})}function TT({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:l,onEditWorkspace:c,onEditBranch:u}){const[d,h]=j.useState(!1),[p,m]=j.useState(!1);return t===null?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r&&n?s.jsxs("a",{href:VU(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[s.jsx(Qr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary group-hover:text-accent-primary transition-colors",children:e})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary",children:e})]}),s.jsx("button",{onClick:()=>{c?c():h(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]}),s.jsx("div",{className:"h-px bg-border"}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Va,{}),s.jsx("span",{className:"truncate text-text-secondary",children:t}),s.jsx("button",{onClick:()=>{u?u():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"})]})]}),s.jsx(WU,{}),!c&&s.jsx(ET,{isOpen:d,onClose:()=>h(!1),projectId:l,sessionId:a,currentWorkspace:e,currentBranch:t}),!u&&s.jsx(NT,{isOpen:p,onClose:()=>m(!1),sessionId:a})]})}function qU(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function KU(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function qb({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 s.jsx("div",{className:`${l} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:s.jsx("div",{className:`h-full transition-all duration-300 ${KU(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function YU({dangerZone:e,size:t="md"}){return e?s.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function XU({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return s.jsx(n,{className:"language-",children:s.jsx("code",{className:"language-",children:e})})}const pl=j.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:l=1}){const{showSyntaxHighlighting:c}=Ds(),[u,d]=j.useState(null),h=ON(),p=j.useRef(t);if(j.useEffect(()=>{c&&(p.current=t,RN(t,n,h).then(g=>{p.current===t&&d(g)}))},[t,n,h,c]),!c||!u)return s.jsx(XU,{code:t,variant:r});if(r==="inline")return s.jsx("span",{dangerouslySetInnerHTML:{__html:u}});const m=a?"":"shiki-plain";return s.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:u}})});function AT({src:e,alt:t,isOpen:n,onClose:r}){return n?s.jsx(St,{isOpen:n,onClose:r,title:"",size:"full",children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const nf=j.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",a=t==="removed"?"line-through decoration-red-400/30":"";return s.jsx("div",{className:`border-l-[3px] ${r}`,children:s.jsx("div",{className:`min-w-0 py-3 ${a}`,children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),JU=j.memo(function({oldString:t,newString:n,filePath:r}){const a=j.useMemo(()=>qf(r),[r]),l=t.length>0,c=n.length>0;return!l&&!c?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[l&&s.jsx(nf,{type:"removed",children:s.jsx(pl,{code:t,language:a,variant:"block",showLineNumbers:!0})}),c&&s.jsx(nf,{type:"added",children:s.jsx(pl,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),QU=j.memo(function({content:t,filePath:n}){const r=j.useMemo(()=>qf(n),[n]);return s.jsx(_n,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(nf,{type:"added",children:s.jsx(pl,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),ZU=j.memo(function({regions:t,filePath:n}){const r=j.useMemo(()=>qf(n),[n]);return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsx("div",{className:"space-y-2",children:t.map((a,l)=>s.jsx(t9,{region:a,language:r},l))})});function e9(e){const t=[];function n(r,a,l){const c=t[t.length-1];c&&c.type===r&&c.startLine+c.lines.length===a?c.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(`
286
+ `);for(let c=0;c<a.length;c++)n("removed",r.startLine+c,a[c]);const l=r.newContent.split(`
287
+ `);for(let c=0;c<l.length;c++)n("added",r.startLine+c,l[c])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const t9=j.memo(function({region:t,language:n}){const r=e9(t);return s.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,l)=>s.jsx(n9,{section:a,language:n},l))})}),n9=j.memo(function({section:t,language:n}){const r=t.lines.join(`
288
+ `);return t.type==="context"?s.jsx("div",{children:s.jsx("div",{className:"min-w-0 py-3",children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:s.jsx(pl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):s.jsx(nf,{type:t.type,children:s.jsx(pl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function rk(e){return e.split(`
289
+ `).filter(t=>!t.startsWith(`
290
+ [`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
291
+ `)}const r9=j.memo(function({result:t,metadata:n,filePath:r}){const[a,l]=j.useState(!1),c=j.useMemo(()=>qf(r),[r]),u=n==null?void 0:n.mimeType,d=n==null?void 0:n.base64Data;if(u!=null&&u.startsWith("image/")&&d){const w=`data:${u};base64,${d}`;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors",onClick:()=>l(!0),children:s.jsx("img",{src:w,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),s.jsx(AT,{src:w,alt:r,isOpen:a,onClose:()=>l(!1)})]})}if(!t)return s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const h=t;if(c==="markdown"){const w=rk(h);return s.jsx(_n,{className:"rounded border border-border max-h-[45vh] p-2",children:s.jsx(ar,{content:w})})}const p=rk(h),m=h.split(`
292
+ `)[0],g=m==null?void 0:m.match(/^(\d+)\|/),x=g?parseInt(g[1],10):1;return s.jsx(_n,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(pl,{code:p,language:c,variant:"block",showLineNumbers:!0,startLine:x})})});function s9({type:e,content:t}){const n=e==="added"?"diff-added-bg":e==="removed"?"diff-removed-bg":"bg-transparent",r=e==="added"?"+":e==="removed"?"-":" ";return s.jsxs("div",{className:`${n} px-2`,children:[s.jsx("span",{className:"select-none text-text-muted w-6 inline-block",children:r}),s.jsx("span",{className:"whitespace-pre-wrap break-words",children:t||" "})]})}function i9({diff:e}){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!r||r.type==="unchanged"){n++;continue}if(r.type==="removed"){for(;n<e.length;){const a=e[n];if(!a||a.type!=="removed")break;t.push({type:"removed",content:a.content}),n++}for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}else if(r.type==="added")for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}return t.length===0?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"No changes detected."}):s.jsxs("div",{children:[s.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Changes:"}),s.jsx("div",{className:"font-mono text-xs leading-5",children:t.map((r,a)=>s.jsx(s9,{type:r.type,content:r.content},a))})]})}function Kb({isOpen:e,onClose:t,isRunning:n,onApply:r}){const[a,l]=j.useState(null),[c,u]=j.useState(!1),d=j.useRef(null),h=j.useCallback(()=>{u(!0);const p=Bt.send("context.applyDynamic.preview",{});d.current=p;const m=Bt.subscribe(g=>{if(g.id===p&&g.type==="context.preview"){const x=g.payload;l(x.diff??[]),u(!1),d.current=null,m()}});setTimeout(()=>{d.current===p&&(u(!1),d.current=null,m())},5e3)},[]);return j.useEffect(()=>{e&&(l(null),u(!0),h())},[e,h]),s.jsxs(St,{isOpen:e,onClose:t,title:"Update system prompt",size:"lg",children:[s.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix.",n&&s.jsxs(s.Fragment,{children:[" ","Since the session is currently running, the update will be queued and applied at the start of the next turn."]})]}),c?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):a&&a.length>0?s.jsx(dt,{className:"max-h-[60vh] border border-border rounded-lg",children:s.jsx(i9,{diff:a})}):s.jsx("p",{className:"text-sm text-text-tertiary mb-4",children:"The system prompt hash has changed (e.g., due to tool or skill changes), but the actual prompt text appears identical. Applying the update will still rebuild the cached prompt to ensure consistency."}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:n?"Queue update":"Update"})]})]})}function LT({variant:e="popover",onUpdateSystemPrompt:t}){const n=Re(D=>D.contextState),r=Re(D=>D.currentSession),a=Re(D=>D.compactContext),l=Re(D=>D.queueUpdate),[c,u]=j.useState(!1),[d,h]=j.useState(!1);if(!n||!r)return null;const{currentTokens:p,maxTokens:m,compactionCount:g,dangerZone:x,dynamicContextChanged:w}=n,C=Math.round(p/m*100),_=r.isRunning,S=()=>{_?l():Bt.send("context.applyDynamic",{}),u(!1)},v=e==="sidebar",b=s.jsxs("span",{className:qU(C,x),children:[ml(p)," / ",ml(m)," (",C,"%)"]}),k=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qb,{percent:C,dangerZone:x,className:"flex-1"}),s.jsx(YU,{dangerZone:x}),g>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[g,"x"]})]}),N=s.jsxs("div",{className:"relative",children:[s.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:s.jsx($j,{})}),d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>h(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1.5 z-50 bg-bg-secondary border border-border rounded-lg shadow-xl py-1 min-w-[160px]",children:[s.jsx("button",{onClick:()=>{_||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:s.jsx("span",{className:x?"text-accent-error":"",children:"Compact"})}),w&&s.jsx("button",{onClick:()=>{h(!1),t?t():u(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]}),E=t?null:s.jsx(Kb,{isOpen:c,onClose:()=>u(!1),isRunning:_,onApply:S});return v?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[s.jsx("div",{className:"text-sm",children:b}),k]}),s.jsx("div",{className:"shrink-0 pt-0.5",children:N})]}),E]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("div",{className:"flex items-center justify-between text-sm",children:b}),k]}),s.jsxs("div",{className:"space-y-1",children:[s.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:s.jsx("span",{className:x?"text-accent-error":"",children:"Compact"})}),w&&s.jsx("button",{onClick:()=>{t?t():u(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors rounded",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]}),E]})}function sk({messages:e,workdir:t}){var v,b,k;const[n,r]=j.useState(!1),[a,l]=j.useState(!1),[c,u]=j.useState(null),d=dU(e),{branch:h}=Ub(),p=en(N=>N.version),m=Re(N=>N.currentSession),g=mu((m==null?void 0:m.workspace)??"")||null,x=Lt(N=>N.settings[Ee.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",w=ui(N=>N.status),C=ui(N=>N.check),[_,S]=j.useState(!1);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(LT,{variant:"sidebar"}),d&&s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{onClick:()=>r(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"text-text-secondary",children:Ts(d.aiTime)}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:YC(d.avgPrefillSpeed)}),s.jsx("span",{children:"pp"}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:YC(d.avgGenerationSpeed)}),s.jsx("span",{children:"tg"})]})}),s.jsx(wU,{isOpen:n,onClose:()=>r(!1),stats:d})]}),s.jsx(dt,{className:"flex flex-col flex-1 px-4 -mx-4 pb-4",children:s.jsxs("div",{children:[s.jsx("button",{onClick:()=>u("criteria"),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(ef,{entries:((v=m==null?void 0:m.metadataEntries)==null?void 0:v.criteria)??[],title:"Acceptance Criteria"})}),m&&s.jsx(gT,{entries:((b=m==null?void 0:m.metadataEntries)==null?void 0:b.criteria)??[],sessionId:m.id}),m&&(()=>{const N=["review_findings","todos"],E=m.metadataEntries??{},D=N.filter(O=>O in E),A=Object.keys(E).filter(O=>O!=="criteria"&&!N.includes(O)).sort();return[...D,...A].filter(O=>{var P;return(((P=E[O])==null?void 0:P.length)??0)>0}).map(O=>s.jsxs("div",{className:"mt-6",children:[s.jsx("button",{onClick:()=>u(O),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(ef,{entries:E[O],title:ol(O)})}),s.jsx(mT,{entries:E[O],onClearAll:async()=>{try{await xe(`/api/sessions/${m.id}/metadata/${O}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(P){console.error(`Failed to clear ${O}:`,P)}}})]},O))})()]})}),s.jsx(TT,{workspaceName:g??"original",branch:h,workdir:t,showEditorLink:x,sessionId:(m==null?void 0:m.id)??"",projectId:(m==null?void 0:m.projectId)??""}),s.jsx(vT,{workdir:t}),s.jsx(UU,{sessionId:m==null?void 0:m.id}),p&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[s.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",s.jsxs("span",{className:"font-mono",children:["v",p]}),s.jsx("button",{onClick:()=>{S(!0),C(!0)},disabled:w==="checking",className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:s.jsx(wf,{className:`w-3 h-3 ${w==="checking"?"animate-spin":""}`})})]}),w==="available"&&s.jsx("button",{onClick:()=>l(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),_&&w==="upToDate"&&s.jsx("div",{className:"mt-1",children:"Up to date"}),w==="error"&&s.jsx("div",{className:"mt-1",children:"Update check failed"})]}),s.jsx(nE,{isOpen:a,onClose:()=>l(!1),versionInfo:null}),s.jsx(pT,{isOpen:c!==null,onClose:()=>u(null),entries:((k=m==null?void 0:m.metadataEntries)==null?void 0:k[c??""])??[],sessionId:(m==null?void 0:m.id)??"",metadataKey:c??"",title:ol(c??"")})]})}function a9({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const a=Re(u=>u.currentSession),{width:l,handleMouseDown:c}=lT({initialWidth:320,minWidth:240,maxWidth:600,direction:"right"});return s.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&s.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),s.jsxs("div",{className:"flex h-full",children:[s.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?s.jsxs("aside",{className:"hidden md:block shrink-0 border-l border-border bg-secondary relative",style:{width:l},children:[s.jsx(cT,{side:"left",onMouseDown:c}),s.jsx(dt,{className:"h-full p-4",children:s.jsx(sk,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})]}):s.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),s.jsx("aside",{className:`
293
+ md:hidden
294
+ bg-secondary
295
+ transition-all duration-300 ease-in-out
296
+ fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
297
+ ${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
298
+ `,children:s.jsx("div",{className:"h-full p-4",children:s.jsx(dt,{className:"h-full",children:s.jsx(sk,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})})})]})]})}function o9(){const e=Re(w=>w.contextState),t=Re(w=>w.currentSession),n=Re(w=>w.pendingUpdate),r=Re(w=>w.triggerPendingUpdate),a=Re(w=>w.queueUpdate),[l,c]=j.useState(!1),[u,d]=j.useState(!1),h=j.useRef(!1),p=j.useRef(!1);if(j.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!h.current&&c(!1),h.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),j.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,g=t.isRunning,x=()=>{g?a():Bt.send("context.applyDynamic",{}),c(!0),d(!1)};return s.jsxs(s.Fragment,{children:[m&&!l&&s.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[s.jsx("span",{children:"System prompt has changed —"}),s.jsx("button",{onClick:()=>d(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),s.jsx("button",{onClick:()=>c(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:s.jsx(ea,{})})]})}),s.jsx(Kb,{isOpen:u,onClose:()=>d(!1),isRunning:g,onApply:x})]})}function l9({stats:e,onClose:t}){var u;const n=ut(d=>d.defaults),r=ut(d=>d.userItems),l=[...n,...r].find(d=>d.id===e.mode),c=(l==null?void 0:l.name)??e.mode;return s.jsx(St,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",c]})}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[s.jsx(rh,{label:"Total Time",value:Ts(e.totalTime)}),s.jsx(rh,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),s.jsx(rh,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),s.jsx(rh,{label:"LLM Calls",value:String(((u=e.llmCalls)==null?void 0:u.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((d,h)=>s.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",h+1]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[d.ttft.toFixed(2),"s TTFT · ",d.completionTime.toFixed(2),"s gen"]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",s.jsxs("span",{className:"text-text-primary",children:[d.promptTokens," → ",d.completionTokens]})]}),s.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[d.temperature!==void 0&&s.jsx(sh,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&s.jsx(sh,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&s.jsx(sh,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&s.jsx(sh,{label:"maxTok",value:String(d.maxTokens)})]})]})]},h))]})]})})}function rh({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-xs text-text-muted",children:e}),s.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function sh({label:e,value:t}){return s.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const c9=j.memo(function({content:t,variant:n="default"}){return n==="labeled"?s.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[s.jsx("span",{className:"text-text-thinking",children:"thinking:"}),s.jsx(_n,{horizontal:!0,className:"ml-1.5 mt-0.5",children:s.jsx(ar,{content:t})})]}):s.jsx(_n,{horizontal:!0,className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:s.jsx(ar,{content:t,muted:!0})})});function DT({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}):e==="run_command"||e==="bash"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e==="workspace"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}const u9={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"}},ik=j.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 s.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[s.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[s.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&s.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&s.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&s.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),s.jsx(_n,{className:"max-h-48",children:t.map((l,c)=>{const u=u9[l.severity];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${u.bg} border-b border-border last:border-b-0`,children:[s.jsx("span",{className:`${u.color} text-xs flex-shrink-0 w-4 text-center`,children:u.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",l.range.start.line+1,":",l.range.start.character+1]}),l.code&&s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",l.code,"]"]})]}),s.jsx("div",{className:"text-xs text-text-primary break-words",children:l.message})]})]},c)})})]})}),d9=j.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:l,result:c,error:u,durationMs:d}){const h=j.useRef(null),[p,m]=j.useState(0),g=wu(h),{setAutoScroll:x,force_scroll_to_bottom:w,handleScrollbarGesture:C}=Su(h,null,g);j.useEffect(()=>{l==="pending"?x(!0):(w(),x(!1))},[l,x,w]),j.useEffect(()=>{if(l!=="pending"||!r)return;const b=setInterval(()=>{m(Date.now()-r)},100);return()=>clearInterval(b)},[l,r]);const _=n/1e3,S=l==="pending"?p/1e3:(d??0)/1e3,v=l==="pending"?(a==null?void 0:a.map(b=>b.content).join(""))??"":c??"";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),s.jsx("code",{className:"text-text-primary break-all",children:t})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[l==="pending"&&s.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),l==="interrupted"&&s.jsx("span",{className:"text-red-400",children:"interrupted"}),s.jsxs("span",{className:l==="pending"?"text-text-secondary":"text-text-muted",children:[S.toFixed(1),"s / ",_,"s"]})]})]}),l==="pending"&&s.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(v||l==="pending")&&s.jsx(dt,{ref:h,onScrollbarGesture:C,className:`text-xs bg-bg-primary p-2 rounded max-h-64 ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&a?a.map((b,k)=>s.jsx("span",{className:b.stream==="stderr"?"text-accent-warning":"",children:tf(b.content)},k)):tf(v)}),l==="error"&&u&&s.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})}),Lc=j.memo(function({className:t=""}){return s.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})});function RT(e,t){try{return{success:!0,parsed:JSON.parse(e)}}catch{return console.warn(`${t}: failed to parse result JSON`,e.slice(0,200)),{success:!1,error:s.jsx(dt,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}}}const h9=j.memo(function({result:t,action:n}){const r=RT(t,"DevServerView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?f9(a):m9(a)});function f9(e){if(!e.logs)return s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
299
+ `);return s.jsxs("div",{className:"space-y-2",children:[s.jsx(_n,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((n,r)=>{const a=n.startsWith("[stderr] ");return s.jsx("div",{className:a?"text-accent-warning":"",children:a?n.slice(9):n},r)})}),e.hasMore&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function m9(e){const t=String(e.state??""),n=String(e.url??""),r=e.error?String(e.error):void 0,a=t==="running"?"text-accent-success":t==="stopped"?"text-text-muted":t==="error"?"text-accent-error":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"State:"}),s.jsx("span",{className:`font-medium ${a}`,children:t})]}),n&&n!=="undefined"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"URL:"}),s.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&s.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const p9=j.memo(function({result:t,action:n}){const r=RT(t,"BackgroundProcessView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?g9(a):n==="list"?x9(a):n==="status"?y9(a):n==="start"||n==="stop"?b9(a):s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),s.jsx(_n,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})]})});function g9(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(_n,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((a,l)=>s.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},l))}),n&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function x9(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):s.jsxs("div",{className:"space-y-2",children:[t.map(a=>s.jsx(OT,{process:a},a.id)),n!=null&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function y9(e){const t=e.process,n=e.uptime;return t?s.jsxs("div",{className:"space-y-2",children:[s.jsx(OT,{process:t}),n!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",v9(n)]})]}):s.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function b9(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,l=a==="running"?"text-accent-success":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[n&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Name:"}),s.jsx("span",{className:"font-medium",children:n})]}),t&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"ID:"}),s.jsx("span",{className:"font-mono",children:t})]}),r!=null&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"PID:"}),s.jsx("span",{className:"font-mono",children:r})]}),a&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Status:"}),s.jsx("span",{className:`font-medium ${l}`,children:a})]})]})}function OT({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return s.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&s.jsxs("div",{className:"text-text-muted",children:["PID: ",s.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&s.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function v9(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 _9=j.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(_n,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}switch(n){case"list":return S9(r);case"switch":case"delete":return w9(r);default:return s.jsx(_n,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}});function S9(e){const t=e.workspaces??[];return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No workspaces found"}):s.jsxs("div",{className:"space-y-1 text-xs",children:[s.jsx("div",{className:"text-text-muted mb-1",children:"Workspaces:"}),t.map(n=>s.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[s.jsx("span",{className:n.active?"text-accent-success":"text-text-muted",children:n.active?"●":"○"}),s.jsx("span",{className:n.active?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.branch&&s.jsxs("span",{className:"text-text-muted",children:["· ",n.branch]}),n.active&&s.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function mx({label:e,value:t,mono:n}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]}),s.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function w9(e){return s.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&s.jsx("div",{className:"text-text-primary",children:e.message}),e.workspace&&s.jsx(mx,{label:"Name",value:e.workspace,mono:!0}),e.path&&s.jsx(mx,{label:"Path",value:e.path,mono:!0}),e.branch&&s.jsx(mx,{label:"Branch",value:e.branch,mono:!0})]})}function C9(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 k9({confirmation:e}){const t=Re(m=>m.confirmPath),n=Re(m=>m.currentSession),r=Re(m=>m.switchDangerLevel),{title:a,description:l}=C9(e.reason),c=e.reason==="sensitive_file"||e.reason==="both",u=c?"border-red-500/50":"border-amber-500/50",d=c?"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 s.jsxs("div",{className:`border ${u} ${d} rounded p-3 my-2`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Ix,{}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm font-medium ${c?"text-red-400":"text-amber-400"}`,children:a}),s.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),s.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[s.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),s.jsx(dt,{className:"bg-bg-primary rounded p-2 mb-3 max-h-24",children:s.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,g)=>s.jsx("li",{className:`text-xs font-mono ${c?"text-red-300":"text-amber-300"} break-all`,children:m},g))})}),s.jsxs("div",{className:"flex gap-2",children:[s.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"}),s.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"}),s.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 j9(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,l=t.limit,c=[];return a!==void 0&&a!==1&&c.push(`offset=${a}`),l!==void 0&&c.push(`limit=${l}`),c.length>0?`${r} [${c.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 ak(e,t,n){var a;const r=j9(e,t);if(e==="read_file"&&n){const l=n.format,c=n.pageCount;if(l==="pdf"&&c!=null)return`${r} (PDF, ${c}p)`;if(l==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const l=n.contentType;if(l){const c=((a=l.split(";")[0])==null?void 0:a.trim())??"";if(c&&c!=="text/html")return`${r} (${c})`}}return r}function E9(e){return JSON.stringify(e,null,2)}const ok={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},N9=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),T9=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]),A9=new Set(["-p","-f","-d","-P"]);function lk(e){return e.split(/[\\/]/).pop()??e}function L9(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 c=a+2;const u=e[c]==="-";for(u&&(c+=1);/\s/.test(e[c]??"");)c+=1;let d="",h=null,p=!1,m=!0;for(;c<e.length;){const g=e[c];if(!h&&/\s|[;&|(){}<>]/.test(g))break;if(g==="'"||g==='"'){m=!1,h===g?(h=null,p=!1):h===null&&(h=g),c+=1;continue}if(!h&&g==="$"&&e[c+1]==="'"){m=!1,p=!0,h="'",c+=2;continue}if(g==="\\"&&c+1<e.length){if(m=!1,p){const x=e.slice(c).match(/^\\(?:x([0-9A-Fa-f]{1,2})|([0-7]{1,3})|([abefnrtv\\'"?]))/);if(x){x[1]?d+=String.fromCharCode(Number.parseInt(x[1],16)):x[2]?d+=String.fromCharCode(Number.parseInt(x[2],8)):d+={a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
300
+ `,r:"\r",t:" ",v:"\v"}[x[3]]??x[3],c+=x[0].length;continue}}(h!=='"'||["$","`",'"',"\\",`
301
+ `].includes(e[c+1]))&&(c+=1)}d+=e[c],c+=1}d&&t.push({delimiter:d,stripTabs:u,expandable:m}),a=c}return t}function D9(e){const t=e.split(`
302
+ `),n=[],r=[],a=[];for(const l of t){if(a.length>0){const c=a[0],u=c.stripTabs?l.replace(/^\t+/,""):l;u===c.delimiter?a.shift():c.expandable&&r.push(u);continue}n.push(l),a.push(...L9(l))}return{command:n.join(`
303
+ `),expandableBodies:r}}function ck(e,t=!0){const n=[];let r=null,a=!1,l=!1,c=!1;for(let u=0;u<e.length;u+=1){const d=e[u];if(l){(d===`
304
+ `||d==="\r")&&(l=!1);continue}if(a){a=!1;continue}if(d==="\\"&&r!=="'"){c=!0,a=!0;continue}if(d==="'"){c=!0,r=r==="'"?null:r===null?"'":r;continue}if(d==='"'){c=!0,r=r==='"'?null:r===null?'"':r;continue}if(r!=="'"){if(!r&&/\s|[;&|(){}]/.test(d)?c=!1:d!=="#"&&(c=!0),t&&d==="#"&&!c){l=!0;continue}if(d==="`"){const h=e.indexOf("`",u+1);h!==-1&&(n.push(e.slice(u+1,h)),u=h);continue}if(d==="$"&&e[u+1]==="("&&e[u+2]!=="("){let h=1,p=null,m=!1;for(let g=u+2;g<e.length;g+=1){const x=e[g];if(m){m=!1;continue}if(x==="\\"&&p!=="'"){m=!0;continue}if(x==="'"||x==='"'){p=p===x?null:p===null?x:p;continue}if(!p&&(x==="("&&(h+=1),x===")"&&(h-=1),h===0)){n.push(e.slice(u+2,g)),u=g;break}}}}}return n}function R9(e){const t=[];let n="",r=!1,a=null,l=!1,c=!1;const u=()=>{r&&t.push(n),n="",r=!1};for(let d=0;d<e.length;d+=1){const h=e[d];if(c){(h===`
305
+ `||h==="\r")&&(c=!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 g=d+3;g<e.length-1;g+=1)if(e.slice(g,g+2)==="(("&&(p+=1),e.slice(g,g+2)==="))"&&(p-=1),p===0){r=!0,n+=e.slice(m,g+2),d=g+1;break}continue}if(h==="#"&&!r){c=!0;continue}if(/\s/.test(h)){u(),(h===`
306
+ `||h==="\r")&&t.push(";");continue}if(h===";"||h==="|"||h==="&"||h==="("||h===")"||h==="{"||h==="}"){u(),e[d+1]===h&&(d+=1),t.push(h);continue}r=!0,n+=h}return l&&(n+="\\"),u(),t}function Uo(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 qr(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=lk(e[n]??"").toLowerCase();if(r==="env"){for(let c=n+1;c<e.length;c+=1){const u=e[c];if(u==="-S"||u==="--split-string"){const h=e[c+1];return h?Ba(h,t+1):null}const d=u.match(/^--split-string=(.*)$/s);if(d)return Ba(d[1],t+1)}for(n=Uo(e,n+1,T9);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return qr(e.slice(n),t+1)}if(r==="sudo")return n=Uo(e,n+1,N9),qr(e.slice(n),t+1);if(r==="sshpass")return n=Uo(e,n+1,A9),qr(e.slice(n),t+1);if(r==="nix"){const c=e[n+1];if(c==="shell"||c==="develop"){for(let u=n+2;u<e.length;u+=1)if(e[u]==="-c"||e[u]==="--command")return Ba(e.slice(u+1).join(" "),t+1);return null}if(c==="run"){for(let u=n+2;u<e.length;u+=1)if(e[u]==="--"){for(let d=n+2;d<u;d+=1){const h=e[d],p=h.indexOf("#");if(p!==-1){const m=lk(h.slice(p+1).split("@")[0]),g=ok[m.toLowerCase()];if(g)return g}}return null}return null}return null}const a=r,l=ok[a];if(l)return l;if(a==="command"){if(e.slice(n+1).some(u=>u==="-v"||u==="-V"))return null;const c=Uo(e,n+1,new Set);return qr(e.slice(c),t+1)}if(a==="setsid"||a==="nohup"){const c=Uo(e,n+1,new Set);return qr(e.slice(c),t+1)}if(a==="timeout"){const c=Uo(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return qr(e.slice(c+1),t+1)}if(a==="bash"||a==="sh"||a==="zsh"||a==="fish")for(let c=n+1;c<e.length;c+=1){const u=e[c];if(u!=="--"){if(/^-[^-]*n/.test(u))return null;if(/^-[^-]*c/.test(u)){const d=e[c+1]==="--"?2:1,h=e[c+d];return h?Ba(h,t+1):null}if(!u.startsWith("-"))break}}return null}function Ba(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=D9(e),a=[...ck(n),...r.flatMap(m=>ck(m,!1))];for(const m of a){const g=Ba(m,t+1);if(g)return g}const l=R9(n);let c=[];const u=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 g=qr(c,t);if(g)return g;c=[],h=!0;continue}if(m==="case"){const g=qr(c,t);if(g)return g;c=[],p=!0;continue}if(h){m==="do"&&(h=!1);continue}if(p&&m===")"){c=[];continue}if(u.has(m)){const g=qr(c,t);if(g)return g;c=[]}else if(d.has(m)){const g=qr(c,t);if(g)return g;c=[]}else if(m==="fi"||m==="done"||m==="esac"){const g=qr(c,t);if(g)return g;c=[],m==="esac"&&(p=!1)}else c.push(m)}return qr(c,t)}function O9(e,t){return e!=="run_command"||typeof t.command!="string"?null:Ba(t.command)}const I9=600;function M9(e,t,n){let r=(e==null?void 0:e.length)??0;if(t)for(const l of t)r+=l.content.length;const a=n.content;return typeof a=="string"&&(r+=a.length),r}const P9={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}},B9=j.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:l,result:c,error:u,durationMs:d,diagnostics:h,editContext:p,startedAt:m,streamingOutput:g,metadata:x,truncated:w,callId:C}){var P;const{collapseLargeToolCalls:_}=Ds(),S=!l&&(!_||r==="pending"||M9(c,g,n)<I9),[v,b]=j.useState(S),k=P9[r],N=O9(t,n),E=Lt(G=>G.settings[Ee.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",D=t==="edit_file"?(P=p==null?void 0:p.regions[0])==null?void 0:P.startLine:t==="read_file"?(()=>{const G=c==null?void 0:c.split(`
307
+ `)[0],z=G==null?void 0:G.match(/^(\d+): /);return z?parseInt(z[1],10):void 0})():void 0,A=Re(G=>G.pendingPathConfirmations),O=C?A.find(G=>G.callId===C||G.callId.startsWith(C+"-"))??null:null;return t==="step_done"?s.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary border border-border rounded px-2 py-1.5 my-1",children:[s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:k.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t})]}):a==="compact"?s.jsxs("div",{className:`flex items-center gap-1.5 text-xs rounded px-2 py-1.5 border ${N?"border-text-thinking/60 bg-text-thinking/10":"border-transparent bg-secondary"}`,children:[s.jsx(DT,{tool:t}),s.jsx("span",{className:"text-accent-primary font-medium",children:t}),s.jsx("span",{className:"text-text-muted truncate flex-1",children:ak(t,n,x)}),s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):s.jsxs("div",{className:`border rounded overflow-hidden my-1 min-w-0 ${N?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:[s.jsxs("button",{className:`w-full flex items-center gap-1.5 p-2 text-left ${N?"bg-text-thinking/10 hover:bg-text-thinking/15":"bg-secondary hover:bg-secondary/80"}`,onClick:()=>b(!v),children:[s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:k.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),s.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:ak(t,n,x)}),s.jsx("span",{className:"text-text-muted text-xs",children:v?"▼":"▶"})]}),v&&s.jsxs("div",{className:`p-2 border-t space-y-2 min-w-0 ${N?"border-text-thinking/40 bg-text-thinking/5":"border-border bg-primary"}`,children:[t==="run_command"&&s.jsx(d9,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:g,status:r,result:c,error:u,durationMs:d}),t==="edit_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[p&&p.regions.length>0?s.jsx(ZU,{regions:p.regions,filePath:String(n.path??"")}):s.jsx(JU,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(ik,{diagnostics:h})]}),t==="write_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[s.jsx(QU,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(ik,{diagnostics:h})]}),t==="read_file"&&r==="success"&&s.jsx(r9,{result:c,metadata:x,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const G=(g==null?void 0:g.map(V=>V.content).join(""))??"",z=r==="pending"&&G?G:String(n.content??"");return s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),s.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(ar,{content:z})})]})})(),t==="call_sub_agent"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),s.jsx(_n,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(ar,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&s.jsxs("div",{children:[s.jsx(_n,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(ar,{content:c??""})}),w&&s.jsx(Lc,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),s.jsx(_n,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(ar,{content:c??""})}),w&&s.jsx(Lc,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&s.jsxs("div",{className:"space-y-2",children:[!!(x!=null&&x.url)&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{children:"Source:"}),s.jsx("a",{href:String(x.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(x.url)}),!!(x!=null&&x.contentType)&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(x.contentType),")"]}),(x==null?void 0:x.pageCount)!=null&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(x.pageCount)," pages"]})]}),s.jsx(_n,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(ar,{content:c??""})}),w&&s.jsx(Lc,{})]}),t==="dev_server"&&r==="success"&&c&&s.jsx(h9,{result:c,action:String(n.action??"")}),t==="workspace"&&r==="success"&&c&&s.jsx(_9,{result:c,action:String(n.action??"")}),t==="background_process"&&r==="success"&&c&&s.jsx(p9,{result:c,action:String(n.action??"")}),t==="mcp_config"&&r==="success"&&s.jsxs("div",{children:[s.jsx(_n,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(ar,{content:c??""})}),w&&s.jsx(Lc,{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"&&s.jsxs(s.Fragment,{children:[Object.keys(n).length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),s.jsx(_n,{horizontal:!0,children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:E9(n)})})]}),r==="success"&&c!==void 0&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}ms)`,":"]}),s.jsx(_n,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:c||"No output"})}),w&&s.jsx(Lc,{className:"mt-1"})]})]}),(N||r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file"))&&s.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file")&&s.jsxs("span",{children:["Completed in ",(d/1e3).toFixed(2),"s"]}),s.jsx("span",{className:"flex-1"}),E&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((x==null?void 0:x.path)??n.path??"")&&s.jsx("a",{href:wT(String((x==null?void 0:x.path)??n.path),D),className:"text-accent-primary hover:underline",children:"Open in VSCode"}),N&&s.jsxs("span",{className:"shrink-0 rounded border border-text-thinking/50 bg-text-thinking/15 px-1.5 py-0.5 font-semibold tracking-wide text-text-thinking",children:["REMOTE · ",N]})]}),r==="error"&&u&&t!=="run_command"&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:u})]}),O&&s.jsx(k9,{confirmation:O})]})]})}),$9={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 z9(e,t){const n=$9[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=hU(a);return`${n} ${l}`}}catch{}return n}function H9(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 F9=j.memo(function({name:t,arguments:n}){let a=z9(t,n)+"...",l=null;if(t==="run_command"&&n){const c=H9(n);c&&(a=c,l=Ba(c))}return s.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:s.jsxs("div",{className:`flex items-center gap-1.5 p-2 ${l?"bg-text-thinking/10":"bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),s.jsx(DT,{tool:t}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?s.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):s.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),U9={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},V9=j.memo(function({todos:t}){return Array.isArray(t)?t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):s.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),s.jsx("div",{children:t.map((n,r)=>{const a=U9[n.status];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[s.jsx("span",{className:`${(a==null?void 0:a.color)??"text-text-muted"} ${a!=null&&a.animate?"animate-pulse":""} text-sm leading-tight`,children:(a==null?void 0:a.icon)??"○"}),s.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):s.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function G9(e){if(e==null)return;if(typeof e=="string"){const n=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?n.map(r=>({value:r,label:r})):void 0}if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n=="string"){const r=n.trim();r.length>0&&t.push({value:r,label:r});continue}if(n!=null&&typeof n=="object"){const r=n,a=r.label,l=r.value;if(typeof a=="string"&&a.trim().length>0){const c=a.trim(),u=typeof l=="string"&&l.length>0?l:c,d=r.description,h={value:u,label:c};typeof d=="string"&&d.length>0&&(h.description=d),t.push(h)}}}return t.length>0?t:void 0}function W9({toolCall:e}){var N;const t=Re(E=>E.pendingQuestions),n=Re(E=>E.answerQuestion),[r,a]=j.useState(""),l=j.useRef(null),c=j.useRef(null),u=t.find(E=>E.callId===e.id),d=e.arguments.question??(u==null?void 0:u.question)??"",h=e.arguments.type??(u==null?void 0:u.type)??"text",p=e.arguments.options??(u==null?void 0:u.options)??void 0,m=G9(p),g=e.result!==void 0,x=u!==void 0&&!g,w=((N=e.result)==null?void 0:N.output)??"",C=w==="[user skipped]";j.useEffect(()=>{x&&zt()&&l.current&&l.current.focus()},[x]),j.useEffect(()=>{x&&c.current&&c.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const _=j.useCallback(()=>{u&&n(u.callId,r)},[u,r,n]),S=j.useCallback(()=>{u&&n(u.callId,"",!0)},[u,n]),v=j.useCallback(E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_()),E.key==="Escape"&&!E.shiftKey&&(E.preventDefault(),S())},[_,S]),b=j.useCallback(E=>{u&&n(u.callId,E)},[u,n]),k="px-3 py-1.5 text-xs font-medium rounded transition-colors";return s.jsxs("div",{ref:c,className:"my-1",children:[s.jsx("div",{className:"text-sm text-text-primary",children:d}),x&&s.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:s.jsx("div",{className:"p-3 bg-primary space-y-2",children:h==="confirm"?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>b("yes"),className:`${k} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),s.jsx("button",{onClick:()=>b("no"),className:`${k} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),s.jsx("button",{onClick:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):h==="choice"&&m!==void 0&&m.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-col gap-1.5",children:m.map((E,D)=>s.jsxs("button",{onClick:()=>b(E.value),className:`${k} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:[s.jsx("span",{className:"block font-medium",children:E.label}),E.description!==void 0&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:E.description})]},D))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("textarea",{ref:l,value:r,onChange:E=>a(E.target.value),onKeyDown:v,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),s.jsx("button",{onClick:_,disabled:!r.trim(),className:`${k} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),s.jsx("button",{onClick:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:l,value:r,onChange:E=>a(E.target.value),onKeyDown:v,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:zt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),s.jsx("button",{onClick:_,disabled:!r.trim(),className:`${k} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),g&&s.jsx("div",{className:"mt-1 flex items-center gap-2",children:s.jsx("span",{className:`text-xs ${C?"text-amber-400":"text-accent-success"}`,children:C?"Skipped":`Answered: ${w}`})})]})}const uk={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"}},q9=j.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(u=>[u.id,u]))??[]),a=t.find(u=>{var d,h;return u.arguments.action==="get"&&((d=u.result)==null?void 0:d.success)&&((h=u.result)==null?void 0:h.output)}),l=t.some(u=>u.name==="session_metadata"),c=(()=>{if(!l)return"Acceptance Criteria";const u=new Set(t.map(d=>d.arguments.key).filter(Boolean));if(u.size===1){const d=u.values().next().value;return d?ol(d):"Session Data"}return"Session Data"})();return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:c})}),s.jsx("div",{className:"bg-primary",children:a?(()=>{const u=a.result.output;if(u==="No criteria defined yet.")return s.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(u).map((h,p)=>s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${p>0?"border-t border-border":""}`,children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(ar,{content:`[${h.id}] ${h.description}`})})]},h.id??p))}catch{return t.map((d,h)=>s.jsx(dk,{tc:d,index:h,criteriaMap:r},d.id??h))}})():t.map((u,d)=>s.jsx(dk,{tc:u,index:d,criteriaMap:r},u.id??d))})]})});function dk({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,a=e.arguments,l=e.name==="session_metadata",c=r==="remove",u=a.id,d=a.description,h=u?n.get(u):void 0,p=d??(h==null?void 0:h.description)??(c&&u?`[${u}]`:"Criterion updated"),m=a.reason,g=r==="fail";return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l?s.jsx(El,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const x=r&&uk[r]?uk[r]:{icon:"○",color:"text-text-muted"};return s.jsx("span",{className:`${x.color} text-sm leading-tight flex-shrink-0`,children:x.icon})})(),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:c?"line-through text-text-muted":"",children:s.jsx(ar,{content:p})}),m&&s.jsxs("div",{className:`mt-1 text-sm ${g?"text-accent-error":"text-text-muted"}`,children:[s.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function K9(e){return e==="criterion"||e==="session_metadata"}const Y9="[interrupted by user]";function X9(e){if(!e)return"pending";const t=e.output??"";return!e.success&&t.trimEnd().endsWith(Y9)?"interrupted":e.success?"success":"error"}async function IT(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 J9({items:e,position:t,onClose:n}){const r=j.useRef(null),[a,l]=j.useState(-1);if(j.useEffect(()=>{t&&l(-1)},[t]),j.useEffect(()=>{var p;if(!t)return;function d(m){r.current&&!r.current.contains(m.target)&&n()}function h(m){var g;switch(m.key){case"Escape":m.preventDefault(),n();break;case"ArrowDown":m.preventDefault(),l(x=>x<e.length-1?x+1:0);break;case"ArrowUp":m.preventDefault(),l(x=>x>0?x-1:e.length-1);break;case"Enter":m.preventDefault(),(g=e[a])==null||g.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 c=Math.min(t.x,window.innerWidth-190),u=Math.min(t.y,window.innerHeight-100);return c=Math.max(8,c),u=Math.max(8,u),mi.createPortal(s.jsx("div",{ref:r,tabIndex:-1,className:"fixed bg-bg-secondary border border-border rounded shadow-lg z-50 min-w-[160px] outline-none",style:{left:c,top:u},children:s.jsx(dt,{className:"max-h-[60vh]",onMouseLeave:()=>l(-1),children:e.map((d,h)=>s.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&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:d.icon}),d.label]},h))})}),document.body)}function MT(){const[e,t]=j.useState(null);return{onContextMenu:j.useCallback((a,l)=>{var u;if(!l||(u=window.getSelection())!=null&&u.toString())return;const c=a.target instanceof Element?a.target:null;c!=null&&c.closest("a")||(a.preventDefault(),t({x:a.clientX,y:a.clientY}))},[]),contextMenu:a=>s.jsx(J9,{position:e,onClose:()=>t(null),items:a})}}function Q9(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"&&K9(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function Z9(e,t){if(e.segments&&e.segments.length>0)return eV(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 eV(e,t,n,r,a){const l=[],c=new Map(t.map(u=>[u.id,u]));for(const u of e)switch(u.type){case"text":l.push({type:"text",content:u.content});break;case"thinking":u.content&&u.content.trim().length>0&&l.push({type:"thinking",content:u.content});break;case"tool_call":{const d=c.get(u.toolCallId);d&&l.push({type:"tool_call",toolCall:d});break}}for(const u of n)l.push({type:"preparing_tool_call",preparing:u});return a&&r&&l.push({type:"stats",stats:r}),l}const Yb=j.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:l}){const c=Re(E=>{var D,A;return(A=(D=E.currentSession)==null?void 0:D.metadataEntries)==null?void 0:A.criteria}),u=ut(E=>E.defaults),d=ut(E=>E.userItems),h=[...u,...d],p=Z9(t,n),m=r?p:p.filter(E=>E.type!=="thinking"),g=Q9(m),[x,w]=j.useState(!1),[C,_]=j.useState(null),[,S]=Ln(),{onContextMenu:v,contextMenu:b}=MT();if(g.length===0)return null;const k=()=>{IT(t.content)},N=async()=>{if(!l||x)return;w(!0),_(null);const E=await Ej(l,t.id);w(!1),E!=null&&E.session?S(`/p/${E.session.projectId}/s/${E.session.id}`):_("Failed to fork session")};return s.jsxs("div",{className:"feed-item",onContextMenu:E=>v(E,!!l),children:[s.jsxs("div",{className:"min-w-0",children:[C&&s.jsx("p",{className:"text-xs text-accent-error mb-1 ml-0.5",children:C}),g.map((E,D)=>{switch(E.type){case"thinking":return s.jsx(c9,{content:E.content},D);case"text":return s.jsx("div",{className:"prose prose-sm prose-invert max-w-none feed-item",children:s.jsx(ar,{content:E.content,isStreaming:t.isStreaming})},D);case"preparing_tool_call":return s.jsx(F9,{name:E.preparing.name,arguments:E.preparing.arguments},`preparing-${E.preparing.index}`);case"tool_call":{const A=E.toolCall,O=A.result;if(A.name==="ask_user")return s.jsx(W9,{toolCall:A},D);if(A.name==="todo_write"){const G=A.arguments.todos,z=Array.isArray(G)?G:[];return s.jsx(V9,{todos:z},D)}const P=X9(O);return s.jsx(B9,{tool:A.name,args:A.arguments,status:P,variant:"expandable",forceCompact:!a,result:O==null?void 0:O.output,error:O==null?void 0:O.error,durationMs:O==null?void 0:O.durationMs,diagnostics:O==null?void 0:O.diagnostics,editContext:O==null?void 0:O.editContext,startedAt:A.startedAt,streamingOutput:A.streamingOutput,metadata:O==null?void 0:O.metadata,truncated:(O==null?void 0:O.truncated)??!1,callId:A.id},D)}case"criteria_group":return s.jsx(q9,{toolCalls:E.toolCalls,criteria:c},D);case"stats":{const A=E.stats;if(!A||"error"in A)return null;const O=A.model.split("/").pop()??A.model,P=Ja(h,A.mode),G=h.find(H=>H.id===A.mode),z=(G==null?void 0:G.name)??A.mode,V=H=>H>=1e3?`${(H/1e3).toFixed(1)}k`:H.toString(),$=H=>H>=1e3?`${(H/1e3).toFixed(1)}k`:H.toFixed(1);return s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:"text-text-secondary",children:O}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{style:{color:P},children:z}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{children:Ts(A.totalTime)}),A.toolTime>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[Ts(A.toolTime)," tools"]})]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[V(A.prefillTokens)," @ ",$(A.prefillSpeed)," pp"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[V(A.generationTokens)," @ ",$(A.generationSpeed)," tg"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const H=new CustomEvent("open-turn-stats",{detail:{stats:A}});window.dispatchEvent(H)},children:s.jsx(_f,{className:"w-3 h-3"})}),s.jsx("span",{className:"flex-1 h-px bg-border"})]},D)}}}),t.partial&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[s.jsx(Ix,{}),s.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-text-truncated mt-1",children:[s.jsx(Ix,{}),s.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),b([{label:"Copy",icon:s.jsx(dl,{className:"w-4 h-4"}),onClick:()=>k()},{label:"Fork session from here",icon:s.jsx(Va,{className:"w-4 h-4"}),onClick:()=>void N()}])]})});function rf(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 tV(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const nV=j.memo(function({data:t}){var a;const n=Yf(),r=(t.workflowId?(a=Xh(n,t.workflowId))==null?void 0:a.color:void 0)??t.workflowColor??"#8b949e";return s.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:rf(r,.3),backgroundColor:rf(r,.08)},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(X5,{color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName??"Task Completed"})]}),s.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[s.jsx(Dc,{label:"Iterations",value:String(t.iterations)}),s.jsx(Dc,{label:"Total time",value:Ts(t.totalTimeSeconds)}),s.jsx(Dc,{label:"Tool calls",value:String(t.totalToolCalls)}),s.jsx(Dc,{label:"Tokens",value:tV(t.totalTokensGenerated)}),s.jsx(Dc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function Dc({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[s.jsx("div",{className:"text-sm text-text-muted",children:e}),s.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const rV=j.memo(function({data:t}){var a;const n=Yf(),r=((a=Xh(n,t.workflowId))==null?void 0:a.color)??t.workflowColor??"#6b7280";return s.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:rf(r,.3),backgroundColor:rf(r,.08)},children:[s.jsx(Sf,{className:"w-3 h-3 shrink-0",color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName}),s.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function sV({attachments:e,messageId:t}){const[n,r]=j.useState(null),a=Re(p=>p.visionFallbackByMessage),l=Re(p=>p.messages),c=j.useMemo(()=>{const p=l.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<l.length;m++){const g=l[m];if(g&&g.role==="assistant")return g.id}return null},[l,t]),u=p=>{r(p)},d=()=>{r(null)},h=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(c){const g=`${c}-${p}`;return a[g]}return null};return e.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=h(p.id);return XN(p.mimeType)?s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>u(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:[s.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"&&s.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:s.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&s.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):s.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[s.jsx("div",{className:"w-10 h-10 flex items-center justify-center rounded-md bg-bg-secondary text-sm font-bold text-text-muted shrink-0",children:JN(p.filename)}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:p.filename,children:p.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:tl(p.size)}),Pb(p.mimeType)&&p.data&&s.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&&s.jsx(AT,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function iV({message:e}){const[t,n]=j.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",c=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)??""}`,task:"🗂 task"}[l]??"injected",h=l==="workflow"||l==="subagent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!h&&n(!0)}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!h&&n(!0),children:c}),s.jsx("span",{children:"·"}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:d}),s.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&s.jsx("div",{className:"flex justify-center feed-item mb-4",children:s.jsx(dt,{horizontal:!0,className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${a}`},children:s.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),s.jsx(St,{isOpen:t,onClose:()=>n(!1),title:`${c} Prompt`,size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),s.jsx("span",{className:"text-sm text-text-primary font-medium",children:c}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",l,")"]})]}),s.jsx("div",{className:"h-full min-h-96",children:s.jsx(dt,{horizontal:!0,className:"h-full min-h-96",children:s.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap break-words bg-bg-tertiary rounded p-4 h-full min-h-96 font-mono",children:e.content})})})]})})]})}const by="openfox:feed-reveal",sf="openfox:autoscroll-rearm";function aV({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",l=e.isSystemGenerated,c=Re(R=>R.loadSession),[,u]=Ln(),[d,h]=j.useState(!1),[p,m]=j.useState(!1),[g,x]=j.useState(!1),[w,C]=j.useState(e.content),[_,S]=j.useState(e.attachments??[]),[v,b]=j.useState(!1),[k,N]=j.useState(!1),[E,D]=j.useState(null),[A,O]=j.useState(null),P=j.useRef(null),{onContextMenu:G,contextMenu:z}=MT(),V=j.useCallback(()=>{const R=P.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]),$=async()=>{try{await IT(e.content),m(!0),window.setTimeout(()=>m(!1),1500)}catch{}},H=async()=>{if(!n||!t||k)return;N(!0),D(null);const R=await Ej(n,t);if(N(!1),R!=null&&R.session){const W=R.session.projectId;u(`/p/${W}/s/${R.session.id}`)}else D("Failed to fork session")},q=async()=>{if(!n||!t||v)return;b(!0),O(null);const R=await Ew(n,t);b(!1),R?(window.dispatchEvent(new CustomEvent(sf)),c(n,!0)):O("Failed to replay")},X=async()=>{if(!n||!t||!w.trim()||v)return;b(!0),O(null);const R=await Ew(n,t,w,_);b(!1),R?(window.dispatchEvent(new CustomEvent(sf)),c(n,!0),x(!1)):O("Failed to send")},Y=()=>{C(e.content),S(e.attachments??[]),x(!1),O(null)},I=`flex items-center gap-0.5 self-end transition-[visibility,opacity] focus-within:visible focus-within:opacity-100 ${d&&!g&&!v?"visible opacity-100":"invisible opacity-0"}`;return s.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onContextMenu:R=>G(R,!!n&&!!t),children:[!l&&s.jsxs("div",{className:I,children:[s.jsx("button",{onClick:()=>{$()},title:"Copy",disabled:v,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:p?s.jsx(Rs,{className:"w-3.5 h-3.5 text-accent-success"}):s.jsx(dl,{className:"w-3.5 h-3.5"})}),n&&t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{O(null),C(e.content),S(e.attachments??[]),x(!0)},title:"Edit & resend",disabled:v,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(Uy,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>{q()},title:"Replay",disabled:v,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(wf,{className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:`max-w-[75%] ${g?"w-full":""} rounded p-2 ${l?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[l&&s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),g?s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("textarea",{ref:R=>{P.current=R,R&&(R.style.height="auto",R.style.height=`${R.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:R=>{C(R.target.value),V()},onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),X()),R.key==="Escape"&&Y()},disabled:v,autoFocus:zt()}),_.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(R=>s.jsx(Bb,{attachment:R,onRemove:W=>S(B=>B.filter(Z=>Z.id!==W))},R.id))}),A&&s.jsx("p",{className:"text-xs text-accent-error",children:A}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:Y,disabled:v,className:"px-4 py-1.5 rounded text-sm bg-bg-tertiary/50 text-text-muted hover:bg-bg-tertiary hover:text-text-primary transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),s.jsx("button",{onClick:()=>{X()},disabled:v||!w.trim(),className:"px-4 py-1.5 rounded text-sm bg-accent-primary/20 text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"Send"})]})]}):s.jsxs(s.Fragment,{children:[(A||E)&&s.jsx("p",{className:"text-xs text-accent-error mb-1",children:A??E}),s.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${l?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&s.jsx(sV,{attachments:e.attachments,messageId:e.id})]})]}),z([{label:"Copy",icon:s.jsx(dl,{className:"w-4 h-4"}),onClick:()=>void $()},{label:"Fork session from here",icon:s.jsx(Va,{className:"w-4 h-4"}),onClick:()=>void H()}])]})}const PT=j.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const l=t.role==="user",c=t.role==="assistant",u=t.role==="system",d=t.role==="tool";if(c)return s.jsx(Yb,{message:t,showStats:n});if(u&&t.isCompacted)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[s.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),s.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
308
+ `,"")})]});if(d)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[s.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),s.jsx(_n,{horizontal:!0,className:"max-h-32",children:s.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap break-words",children:[t.content.slice(0,500),t.content.length>500&&"..."]})})]});if(t.messageKind==="workflow-started")try{const h=JSON.parse(t.content);return s.jsx(rV,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return s.jsx(nV,{data:h})}catch{}return t.messageKind==="context-reset"?s.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{children:t.content}),s.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?s.jsx(iV,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?s.jsx("div",{className:"flex justify-end feed-item",children:s.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),s.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):l?s.jsx(aV,{message:t,messageId:r,sessionId:a}):s.jsx("div",{className:"flex justify-start feed-item",children:s.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:s.jsx(ar,{content:t.content})})})}),oV={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function lV(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function hk(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function cV({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,l=Math.round(t/n*100);return s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[s.jsxs("span",{className:hk(l,a),children:[ml(t),"/",ml(n)]}),s.jsxs("span",{className:hk(l,a),children:["(",l,"%)"]}),s.jsx(qb,{percent:l,dangerZone:a,size:"sm"}),a&&s.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&s.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const uV=j.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const l=j.useRef(null),c=j.useRef(null),[u,d]=j.useState(!1),h=ut(O=>O.defaults),p=ut(O=>O.userItems),m=[...h,...p],g=Re(O=>O.subAgentContextStates[r]),{showThinking:x,showVerboseToolOutput:w}=Ds(),C=wu(c),{isAutoScrollActive:_,setAutoScroll:S,handleScrollbarGesture:v}=Su(c,null,C),b=j.useCallback(()=>{const O=!u;d(O),O&&setTimeout(()=>{var P;(P=l.current)==null||P.scrollIntoView({block:"start",behavior:"smooth"})},220)},[u]),k=m.find(O=>O.id===n),N=(k==null?void 0:k.name)??oV[n]??n,E=Ja(m,n),D=lV(E),A=t.filter(O=>O.role!=="tool");return s.jsxs("div",{ref:l,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[s.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:D,children:[s.jsx("span",{className:"text-xs font-medium",children:N}),s.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:g&&s.jsx(cV,{contextState:g})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>S(!_),children:[s.jsx("span",{className:`w-1 h-1 rounded-full ${_?"bg-accent-success":"border border-text-muted"}`}),"live"]}),s.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:b,children:[u?"▼":"▶"," Expand"]})]})]}),s.jsx(dt,{ref:c,className:`${u?"max-h-[calc(100vh-10rem)]":"max-h-80"} p-2 transition-[max-height] duration-200`,onScrollbarGesture:v,children:A.map(O=>O.role==="assistant"?s.jsx(Yb,{message:O,showStats:!0,showThinking:x,showVerboseToolOutput:w},O.id):s.jsx(PT,{message:O,isLastAssistantMessage:!1},O.id))})]})}),dV={contentVisibility:"auto",containIntrinsicSize:"auto 200px"},hV={contentVisibility:"auto",containIntrinsicSize:"160px",minHeight:"160px"},ih=30,px=20,fV=10,mV=5;function ah(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 BT=j.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,scrollContainerRef:a,showThinking:l=!0,showVerboseToolOutput:c=!0,showStats:u=!0,showAgentDefinitions:d=!0,showWorkflowBars:h=!0}){const p=t.length,{feedVirtualization:m}=Ds(),[g,x]=j.useState(()=>Math.max(0,p-ih)),w=j.useRef(null),C=j.useRef(t.length),_=j.useRef(!1),S=m?g:0,v=m?dV:void 0;j.useEffect(()=>{m&&(x(Math.max(0,t.length-ih)),_.current=!1)},[r]),j.useEffect(()=>{const N=C.current;C.current=t.length,m&&t.length-N>=mV&&!_.current&&x(Math.max(0,t.length-ih))},[t.length,m]),j.useEffect(()=>{m&&g>0&&g>=t.length&&x(Math.max(0,t.length-ih))},[t.length,g,m]),j.useEffect(()=>{if(!m||g<=0||typeof IntersectionObserver>"u")return;const N=w.current;if(!N)return;const E=new IntersectionObserver(D=>{D.some(A=>A.isIntersecting)&&x(A=>Math.max(0,A-px))},{rootMargin:"0px 0px 300px 0px"});return E.observe(N),()=>E.disconnect()},[g,m]);const b=j.useRef(g);b.current=g,j.useEffect(()=>{var A,O;if(!m)return;const N=a==null?void 0:a.current;if(!N)return;const E=(O=(A=N.osInstance)==null?void 0:A.call(N))==null?void 0:O.elements().viewport;if(!E)return;const D=()=>{if(E.scrollTop>4){_.current=!0;return}b.current>0&&x(P=>Math.max(0,P-px))};return E.addEventListener("scroll",D,{passive:!0}),()=>E.removeEventListener("scroll",D)},[a,m]),j.useEffect(()=>{var D,A;if(!m||g<=0||!_.current)return;const N=a==null?void 0:a.current,E=(A=(D=N==null?void 0:N.osInstance)==null?void 0:D.call(N))==null?void 0:A.elements().viewport;E&&E.scrollTop<=4&&x(O=>Math.max(0,O-px))},[g,a,m]),j.useEffect(()=>{if(!m)return;const N=E=>{var A;const D=(A=E.detail)==null?void 0:A.index;typeof D=="number"&&x(O=>Math.min(O,Math.max(0,D-fV)))};return window.addEventListener(by,N),()=>window.removeEventListener(by,N)},[m]);const k=t.slice(S);return s.jsxs(s.Fragment,{children:[S>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-xs text-text-muted","data-testid":"feed-unmounted-hint",children:["Scroll up to load ",S," older item",S!==1?"s":""]}),Array.from({length:S},(N,E)=>s.jsx("div",{"data-item-index":E,"data-placeholder":!0,style:hV},`ph-${E}`)),s.jsx("div",{ref:w,"data-testid":"feed-sentinel",style:{height:1}})]}),k.map((N,E)=>{const D=S+E;if(N.type==="context-divider")return s.jsxs("div",{"data-item-index":D,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),s.jsx("div",{className:"flex-1 border-t border-border"})]},ah(N));if(N.type==="subagent"){const G=N.messages.some(z=>z.isStreaming);return s.jsx("div",{"data-item-index":D,className:"px-2 md:px-4",style:v,children:s.jsx(uV,{messages:N.messages,subAgentType:N.subAgentType,subAgentId:N.subAgentId,isStreaming:G})},ah(N))}const A=N.message;if(A.role==="assistant")return s.jsx("div",{"data-item-index":D,className:"px-2 md:px-4",style:v,children:s.jsx(Yb,{message:A,showStats:u,showThinking:l,showVerboseToolOutput:c,sessionId:r??void 0})},ah(N));const O=!d&&A.messageKind==="auto-prompt",P=!h&&(A.messageKind==="workflow-started"||A.messageKind==="task-completed");return O||P?null:s.jsx("div",{"data-item-index":D,className:"px-2 md:px-4",style:v,children:s.jsx("div",{"data-message-id":A.id,className:n===A.id?"rounded animate-highlight-fade":void 0,children:s.jsx(PT,{message:A,messageId:A.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},ah(N))})]})});function Xf(e,t,n=!0){j.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 pV=[],gV=j.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:l,hiddenCount:c=0,onScrollbarGesture:u,emptyState:d}){const h=Re(J=>{var U,M;return((M=(U=J.currentSession)==null?void 0:U.metadataEntries)==null?void 0:M.criteria)??pV}),p=Re(J=>{var U;return(U=J.currentSession)==null?void 0:U.id}),m=Re(J=>{var U;return(U=J.currentSession)==null?void 0:U.phase}),g=Re(J=>J.error),x=Re(J=>J.clearError),w=bf(),C=Re(J=>J.activeWorkflowExecution),_=Re(J=>J.continueWorkflow),{showThinking:S,showVerboseToolOutput:v,showStats:b,showAgentDefinitions:k,showWorkflowBars:N}=Ds(),E=Yf(),D=h.some(J=>J.status==="pending"),A=m==="done",O=t.some(J=>J.type==="message"&&J.message.role==="assistant"),P=(C==null?void 0:C.status)==="running"||(C==null?void 0:C.status)==="waiting",G=D&&!w&&O&&!A&&!P,z=(C==null?void 0:C.status)==="waiting"&&!w,V=Re(J=>{var U;return(U=J.currentSession)==null?void 0:U.projectId}),[$,H]=j.useState(!1),[q,X]=j.useState(!1),[Y,F]=j.useState(!1),I=wu(n);j.useLayoutEffect(()=>{const J=I();J&&X(J.scrollHeight>J.clientHeight+1)},[I,t]),j.useEffect(()=>{const J=I();if(!J)return;const U=()=>F(J.scrollTop>4);return U(),J.addEventListener("scroll",U,{passive:!0}),()=>J.removeEventListener("scroll",U)},[I]);const R=()=>{if(!V||!p)return;H(!1),window.open(`/p/${V}/s/${p}/readonly`,"_blank")||H(!0)},[W,B]=j.useState(!1),Z=j.useCallback(J=>{W||(B(!0),_(J),setTimeout(()=>B(!1),5e3))},[W,_]),Q=j.useCallback(()=>{var J;l==null||l(),(J=I())==null||J.scrollTo({top:0,behavior:"smooth"})},[I,l]);return s.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[s.jsx(dt,{ref:n,"data-testid":"chat-scroll-container",className:"absolute inset-0 bg-primary",onScrollbarGesture:u,children:s.jsxs("div",{className:"flex min-h-full flex-col",children:[s.jsxs("div",{className:"pt-4",children:[c>0&&s.jsxs("div",{className:"px-2 md:px-4 pb-2 space-y-1",children:[s.jsxs("button",{onClick:R,className:"w-full text-sm text-text-muted hover:text-text-primary bg-bg-tertiary/50 hover:bg-bg-tertiary border border-border rounded px-3 py-2 transition-colors text-center",children:[c," older item",c!==1?"s":""," hidden — View full history"]}),$&&s.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",s.jsx("a",{href:V&&p?`/p/${V}/s/${p}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),s.jsx(BT,{displayItems:t,highlightedMessageId:r,sessionId:p,scrollContainerRef:n,showThinking:S,showVerboseToolOutput:v,showStats:b,showAgentDefinitions:k,showWorkflowBars:N})]}),t.length===0&&d&&s.jsx("div",{className:"flex flex-1 items-center justify-center px-2 md:px-4 py-4",children:d}),s.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[g&&s.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:g.code}),s.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:g.message})]}),s.jsx(_u,{onClick:x,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),z&&C&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:(C.pendingChoices&&C.pendingChoices.length>0?C.pendingChoices:[{id:void 0,label:`▶ Continue ${C.workflowName} (${C.currentStepName??"..."})`,goto:"",nextStepName:void 0}]).map(J=>s.jsx("button",{onClick:()=>Z(J.id),disabled:W,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:W?"⏳ Continuing...":J.id==="continue"?`▶ Continue ${C.workflowName} (${J.nextStepName??C.currentStepName??"..."})`:J.label},J.id??"continue"))}),G&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:E.map(J=>{const U=J.color??"#3b82f6",M=parseInt(U.slice(1,3),16),te=parseInt(U.slice(3,5),16),se=parseInt(U.slice(5,7),16),re=`rgba(${M},${te},${se},0.12)`,le=`rgba(${M},${te},${se},0.22)`,ye=`rgba(${M},${te},${se},0.25)`;return s.jsx(xV,{workflowName:J.name,scope:J.scope,color:U,bg:re,bgHover:le,border:ye,subGroups:J.subGroups,onLaunch:_e=>a(J.id,_e,void 0,J.scope)},`${J.id}-${J.scope}`)})})]})]})}),q&&Y&&s.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-10 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:s.jsxs("button",{type:"button",onClick:Q,className:"pointer-events-auto text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors backdrop-blur-sm bg-bg-secondary/60",children:[s.jsx(Bj,{className:"w-3 h-3"}),"scroll to top"]})})]})});function xV({workflowName:e,scope:t,color:n,bg:r,bgHover:a,border:l,subGroups:c,onLaunch:u}){const[d,h]=j.useState(!1),p=j.useRef(null);Xf(p,()=>h(!1),d);const m=c&&c.length>0;return s.jsxs("div",{className:"relative flex",children:[s.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:`px-4 py-1.5 text-sm font-medium transition-colors ${m?"rounded-l":"rounded"}`,style:{backgroundColor:r,color:n,border:`1px solid ${l}`,...m?{borderRight:"none"}:{}},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:["▶ ",e," ",s.jsx("span",{className:"text-[10px] font-normal opacity-70 whitespace-nowrap",children:zb[t]})]}),m&&s.jsxs("div",{ref:p,className:"relative flex",children:[s.jsx("button",{onClick:()=>h(!d),className:"px-2.5 py-1.5 rounded-r text-sm font-medium transition-colors flex items-center",style:{backgroundColor:r,color:n,border:`1px solid ${l}`},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:"⋮"}),d&&s.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[s.jsx("button",{onClick:()=>{u(),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),s.jsx("div",{className:"border-t border-border/50"}),c.map(g=>s.jsx("button",{onClick:()=>{u(g),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:g},g))]})]})]})}function yV(){const e=Re(r=>r.connectionStatus),t=Re(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return s.jsxs("div",{className:`
309
+ flex items-center justify-between px-4 py-2
310
+ text-sm font-medium
311
+ ${n?"bg-amber-500/15 border-b border-amber-500/30 text-amber-300":"bg-red-500/15 border-b border-red-500/30 text-red-300"}
312
+ `,children:[s.jsx("div",{className:"flex items-center gap-2",children:n?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),s.jsx("span",{children:"Reconnecting to server..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Q5,{}),s.jsx("span",{children:"Connection lost"})]})}),s.jsx("button",{onClick:()=>t(),disabled:n,className:`
313
+ px-3 py-1 rounded text-xs font-medium
314
+ transition-colors
315
+ ${n?"bg-amber-500/20 text-amber-400 cursor-not-allowed opacity-50":"bg-red-500/20 text-red-300 hover:bg-red-500/30 hover:text-red-200"}
316
+ `,children:n?"Reconnecting...":"Reconnect"})]})}function bV(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function vV({onClick:e}){return s.jsx("button",{type:"button",onClick:e,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:s.jsx(Gy,{})})}function $T({isOpen:e,onClose:t,initialEditId:n}){const r=ln(ae=>ae.defaults),a=ln(ae=>ae.userItems),l=ln(ae=>ae.projectItems),c=ln(ae=>ae.loading),u=ln(ae=>ae.fetchCommands),d=ln(ae=>ae.fetchCommand),h=ln(ae=>ae.fetchDefaultContent),p=ln(ae=>ae.createCommand),m=ln(ae=>ae.updateCommand),g=ln(ae=>ae.deleteCommand),[x,w]=j.useState(null),[C,_]=j.useState(null),{view:S,editingId:v,formError:b,saving:k,formData:N,setView:E,setEditingId:D,setFormError:A,setFormData:O,setSaving:P}=Yj(),{requestDelete:G,clearConfirm:z,isConfirming:V}=fu(),$=j.useRef(!1),H=ut(ae=>ae.defaults),q=ut(ae=>ae.userItems),X=ut(ae=>ae.fetchAgents),F=[...H,...q].filter(ae=>!ae.subagent),I=j.useRef(u),R=j.useRef(X),W=j.useRef(d),B=j.useRef(h),Z=j.useRef(n),Q=j.useRef(E),J=j.useRef(D),U=j.useRef(A),M=j.useRef(z);j.useEffect(()=>{I.current=u,R.current=X,W.current=d,B.current=h,Z.current=n,Q.current=E,J.current=D,U.current=A,M.current=z}),j.useEffect(()=>{if(e)if(I.current(),R.current(),$.current||(M.current(),$.current=!0),Z.current){const ae=r.some(ue=>ue.id===Z.current);Q.current("edit"),J.current(Z.current),U.current(""),ae?B.current(Z.current).then(ue=>{ue&&O({name:ue.metadata.name+" (copy)",id:`${Z.current}-copy-${Date.now()}`,prompt:ue.prompt,agentMode:ue.metadata.agentMode??"",isDefault:!0,destination:"user"})}):W.current(Z.current).then(ue=>{ue&&O({name:ue.metadata.name,id:ue.metadata.id,prompt:ue.prompt,agentMode:ue.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else Q.current("list"),J.current(null);else $.current=!1},[e]);const te=async ae=>{w(ae);const ue=await h(ae);_((ue==null?void 0:ue.prompt)??null)},se=async ae=>{if(r.some(Me=>Me.id===ae)){const Me=await h(ae);Me&&(D(null),O({name:`${Me.metadata.name} (copy)`,id:`${ae}-copy-${Date.now()}`,prompt:Me.prompt,agentMode:Me.metadata.agentMode??"",isDefault:!0,destination:"user"}),A(""),E("edit"))}else{const Me=await d(ae);Me&&(D(null),O({name:`${Me.metadata.name} (copy)`,id:`${ae}-copy-${Date.now()}`,prompt:Me.prompt,agentMode:Me.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),E("edit"))}},re=()=>{O({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),D(null),E("edit")},le=async ae=>{const ue=await d(ae);ue&&(D(ae),O({name:ue.metadata.name,id:ue.metadata.id,prompt:ue.prompt,agentMode:ue.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),E("edit"))},ye=async ae=>{await g(ae),z()},_e=async()=>{const ae=v??N.id;if(!ae||!N.name||!N.prompt){A("Name and message are required.");return}P(!0),A("");const ue={metadata:{id:ae,name:N.name,...N.agentMode?{agentMode:N.agentMode}:{}},prompt:N.prompt},Me=v?await m(v,ue):await p(ue,N.destination);if(P(!1),!Me.success){A(Me.error??"Failed to save command.");return}n?t():E("list")},Oe=()=>{n?t():(E("list"),w(null),_(null))},Be=ae=>{O(ue=>({...ue,name:ae})),(!v||N.isDefault)&&O(ue=>({...ue,id:bV(ae)}))},ke=()=>{w(null),_(null),E("list")},Ge=()=>{x&&(w(null),E("edit"),D(x),h(x).then(ae=>{ae&&O({name:`${ae.metadata.name} (copy)`,id:`${x}-copy-${Date.now()}`,prompt:ae.prompt,agentMode:ae.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(x){const ae=r.find(ue=>ue.id===x);return s.jsx(St,{isOpen:e,onClose:ke,title:`Default: ${(ae==null?void 0:ae.name)??x}`,size:"xl",children:s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),s.jsx("span",{className:"font-mono",children:x})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:ae==null?void 0:ae.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(ae==null?void 0:ae.agentMode)||"None"})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value: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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[s.jsx(rt,{variant:"secondary",onClick:ke,children:"Close"}),s.jsx(rt,{variant:"primary",onClick:Ge,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return s.jsx(St,{isOpen:e,onClose:Oe,title:v?"Edit Command":"New Command",size:"xl",footer:s.jsx(Vj,{onCancel:Oe,onSave:_e,saving:k,saveDisabled:!N.name||!N.prompt}),children:s.jsxs("div",{className:"flex flex-col h-full",children:[b&&s.jsx(il,{message:b}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(Kj,{name:N.name,id:N.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!v&&!N.isDefault,onNameChange:Be,onIdChange:ae=>O(ue=>({...ue,id:ae}))}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsxs("select",{value:N.agentMode,onChange:ae=>O(ue=>({...ue,agentMode:ae.target.value})),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[s.jsx("option",{value:"",children:"None (keep current mode)"}),F.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),!v&&s.jsx(jf,{value:N.destination,onChange:ae=>O(ue=>({...ue,destination:ae}))})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value:N.prompt,onChange:ae=>O(ue=>({...ue,prompt:ae.target.value})),placeholder:"The message that will be sent when this command is triggered...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]})});const Je=ae=>ae.map(ue=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:ue.name})})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(di,{onClick:()=>le(ue.id)}),s.jsx(tu,{onClick:()=>se(ue.id)}),V(ue.id,"delete")?s.jsx(Lh,{onConfirm:()=>ye(ue.id),onCancel:z}):s.jsx(Dh,{onClick:()=>G(ue.id)})]})]},ue.id));return s.jsxs(St,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[s.jsx(qj,{description:"Commands are pre-defined messages you can send with a single click.",onNew:re}),s.jsxs(Jy,{loading:c,hasItems:r.length>0||a.length>0||l.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:r.map(ae=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:ae.name})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(vV,{onClick:()=>te(ae.id)}),s.jsx(tu,{onClick:()=>se(ae.id)})]})]},ae.id))})]}),a.length>0&&s.jsx(Wj,{children:Je(a)}),l.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:Je(l)})]})]})]})}function _V({title:e,defaultOpen:t=!1,children:n,className:r=""}){return s.jsxs("details",{className:`group ${r}`,open:t,children:[s.jsxs("summary",{className:"text-[11px] text-text-secondary uppercase tracking-wider font-medium cursor-pointer select-none hover:text-text-primary transition-colors list-none flex items-center gap-1",children:[s.jsx(pn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),e]}),s.jsx("div",{className:"mt-2 space-y-2",children:n})]})}const Na=150,ni=54,oh=80,is=30,Vo=70,fk=100,Ta=50,lh=50,mk=4,zT={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},HT=[{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)"}],SV=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"},{value:"user",label:"User (pause)"}];function Xb(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 wV(e,t,n,r){const a=lh+Ta+Na+fk+Na+Ta+lh,l=a/2,c=lh+Ta+Na/2,u=lh+Ta+Na+fk+Na/2,d=[],h=[],p=new Map,m=e.filter(H=>H.type==="agent"||H.type==="shell"||H.type==="user"),g=e.filter(H=>H.type==="sub_agent"),x=g.length>0,w=x?c:l,C=m.length>0?u:l,_=Ta+is/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:_,w:oh,h:is}),p.set("$start",{cx:w,cy:_,w:oh,h:is});const S=H=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:H,w:oh,h:is}),p.set("$done",{cx:w,cy:H,w:oh,h:is})};if(e.length===0){const H=_+is/2+Vo*2+is/2;return S(H),{nodes:d,edges:h,width:a,height:H+is/2+Ta,posMap:p}}const v=_+is/2+Vo,b=(H,q)=>{H.forEach((X,Y)=>{const F=v+Y*(ni+Vo)+ni/2,{name:I,color:R}=Xb(X,r);d.push({id:X.id,type:"step",label:I,color:R,cx:q,cy:F,w:Na,h:ni}),p.set(X.id,{cx:q,cy:F,w:Na,h:ni})})};b(m,w),b(g,C);const k=m.length>0?v+(m.length-1)*(ni+Vo)+ni/2:_,N=x?v+(g.length-1)*(ni+Vo)+ni/2:_,E=Math.max(k,N)+ni/2+Vo+is/2;S(E);const D=[];t&&p.has(t)&&D.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let A=0;for(const H of e)H.transitions.forEach((q,X)=>{var B;if(!q.goto||!p.has(q.goto))return;const Y=p.get(H.id),F=p.get(q.goto),I=q.when.type==="step_result"?`${q.when.result}`:q.when.type==="metadata_all_match"?`${q.when.key??"?"}=${q.when.value??"?"}`:q.when.type==="metadata_all_in"?`${q.when.key??"?"} in [${((B=q.when.values)==null?void 0:B.join(","))??"?"}]`:zT[q.when.type]??q.when.type,R=H.id===q.goto;let W;R?W="back":F.cy>Y.cy+1?W="down":F.cy<Y.cy-1?W="back":W="same",D.push({from:H.id,to:q.goto,label:I,edgeKey:`${H.id}:${X}`,direction:W,backEdgeIndex:W==="back"?A++:0})});const O=new Map,P=new Map,G=new Map,z=new Map;for(const H of D)H.direction==="down"&&(O.set(H.from,(O.get(H.from)??0)+1),P.set(H.to,(P.get(H.to)??0)+1));const V=new Map,$=new Map;for(const H of D){if(H.direction!=="same")continue;const q=[H.from,H.to].sort().join("|");V.set(q,(V.get(q)??0)+1)}for(const H of D){if(H.direction==="back"||H.direction==="same"){let W=0;if(H.direction==="same"){const B=[H.from,H.to].sort().join("|");W=$.get(B)??0,$.set(B,W+1)}h.push({...H,fromPort:0,toPort:0,sameEdgeIndex:W});continue}const q=O.get(H.from)??1,X=P.get(H.to)??1,Y=G.get(H.from)??0,F=z.get(H.to)??0;G.set(H.from,Y+1),z.set(H.to,F+1);const I=q===1?0:-.6+1.2*Y/(q-1),R=X===1?0:-.6+1.2*F/(X-1);h.push({...H,fromPort:I,toPort:R,sameEdgeIndex:0})}return{nodes:d,edges:h,width:a,height:E+is/2+Ta,posMap:p}}function CV({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:l,isReadOnly:c,onSelectNode:u,onSelectEdge:d,onRemoveStep:h,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:g,onDeleteTransition:x}){const w=j.useRef(null),C=j.useRef(!1),[_,S]=j.useState(null),[v,b]=j.useState(null),[k,N]=j.useState(null),{nodes:E,edges:D,width:A,height:O,posMap:P}=j.useMemo(()=>wV(e,t,a,l),[e,t,a,l]),G=j.useCallback(Q=>{var se;const J=w.current;if(!J)return{x:0,y:0};const U=J.createSVGPoint();U.x=Q.clientX,U.y=Q.clientY;const M=(se=J.getScreenCTM())==null?void 0:se.inverse();if(!M)return{x:0,y:0};const te=U.matrixTransform(M);return{x:te.x,y:te.y}},[]),z=j.useCallback(Q=>!Q||!v||Q==="$start"?!1:v.type==="reconnect-from"?Q!=="$done":!0,[v]),V=j.useCallback((Q,J)=>{if(c)return;Q.stopPropagation(),Q.preventDefault();const U=G(Q);b({type:"new",fromNodeId:J,mouseX:U.x,mouseY:U.y})},[G,c]),$=j.useCallback((Q,J)=>{if(c)return;Q.stopPropagation(),Q.preventDefault();const U=G(Q);b({type:"reconnect-to",fromNodeId:J.from,edgeKey:J.edgeKey,mouseX:U.x,mouseY:U.y})},[G,c]),H=j.useCallback((Q,J)=>{if(c)return;Q.stopPropagation(),Q.preventDefault();const U=G(Q);b({type:"reconnect-from",fromNodeId:J.from,fixedTargetId:J.to,edgeKey:J.edgeKey,mouseX:U.x,mouseY:U.y})},[G,c]),q=j.useCallback(Q=>{if(!v)return;const J=G(Q);b(U=>U?{...U,mouseX:J.x,mouseY:J.y}:null)},[v,G]),X=j.useCallback(()=>{v&&(C.current=!0,k&&z(k)&&(v.type==="new"?p(v.fromNodeId,k):v.type==="reconnect-to"?m(v.edgeKey,k):v.type==="reconnect-from"&&g(v.edgeKey,k)),b(null),N(null))},[v,k,z,p,m,g]),Y=j.useCallback(()=>{if(C.current){C.current=!1;return}u(null),d(null)},[u,d]);j.useEffect(()=>{if(c)return;const Q=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||(J.key==="Delete"||J.key==="Backspace")&&r&&r!=="start"&&(J.preventDefault(),x(r),d(null))};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[c,r,x,d]);const F=Q=>{const J=P.get(Q.from),U=P.get(Q.to);if(!J||!U)return null;let M,te,se,re="middle",le,ye;if(Q.direction==="down"){const _e=J.cx+Q.fromPort*(J.w/2-10),Oe=J.cy+J.h/2,Be=U.cx+Q.toPort*(U.w/2-10),ke=U.cy-U.h/2,Ge=ke-Oe,Je=Be-_e;M=`M ${_e} ${Oe} C ${_e} ${Oe+Ge*.4}, ${Be-Je*.2} ${ke-Ge*.1}, ${Be} ${ke}`,te=_e+(Be-_e)*.5,se=Oe+Ge*.6,le={x:_e,y:Oe},ye={x:Be,y:ke}}else if(Q.direction==="back"){const _e=Q.from===Q.to,Oe=J.cx>=A/2,Be=Q.backEdgeIndex*16,ke=Oe?A-20-Be:20+Be;if(_e){const Ge=J.cx>=A/2,Je=30+Q.backEdgeIndex*14,ae=J.cy-J.h/2,ue=Ge?J.cx+J.w/2:J.cx-J.w/2,Me=Ge?ue+Je:ue-Je,fe=J.cx+(Ge?J.w/4:-J.w/4),Fe=ae-20-Q.backEdgeIndex*10;M=`M ${ue} ${J.cy} C ${Me} ${J.cy}, ${Me} ${Fe}, ${fe} ${ae}`,te=Me+10,se=Fe+4,re="middle",le={x:ue,y:J.cy},ye={x:fe,y:ae}}else{const Ge=Oe?J.cx+J.w/2:J.cx-J.w/2,Je=U.cx+(Oe?U.w/4:-U.w/4),ae=Math.min(J.cy,U.cy)-U.h/2-18-Q.backEdgeIndex*14;M=`M ${Ge} ${J.cy} L ${ke} ${J.cy} L ${ke} ${ae} L ${Je} ${ae} L ${Je} ${U.cy-U.h/2}`,te=ke,se=(J.cy+ae)/2,re=Oe?"start":"end",le={x:Ge,y:J.cy},ye={x:Je,y:U.cy-U.h/2}}}else{const _e=U.cx>J.cx,Oe=Q.sameEdgeIndex===0?-12:12,Be=_e?J.cx+J.w/2:J.cx-J.w/2,ke=_e?U.cx-U.w/2:U.cx+U.w/2,Ge=J.cy+Oe,Je=U.cy+Oe,ae=(Be+ke)/2;M=`M ${Be} ${Ge} C ${ae} ${Ge}, ${ae} ${Je}, ${ke} ${Je}`,te=ae,se=(Ge+Je)/2-6,le={x:Be,y:Ge},ye={x:ke,y:Je}}return{path:M,labelX:te,labelY:se,labelAnchor:re,fromPt:le,toPt:ye}},I=(Q,J)=>{const U=F(Q);if(!U)return null;const{path:M,labelX:te,labelY:se,labelAnchor:re}=U,le=r===Q.edgeKey,ye=Q.label&&Q.label!=="otherwise";return s.jsxs("g",{children:[s.jsx("path",{d:M,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:_e=>{_e.stopPropagation(),c||d(le?null:Q.edgeKey)}}),s.jsx("path",{d:M,fill:"none",stroke:le?"#58a6ff":"#484f58",strokeWidth:le?2.2:1.2,markerEnd:le?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),ye&&s.jsx("text",{x:te+(re==="start"?5:re==="end"?-5:0),y:se+3,textAnchor:re,className:"text-[8px]",fill:le?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:Q.label})]},J)},R=()=>{if(!r||v)return null;const Q=D.find(se=>se.edgeKey===r);if(!Q)return null;const J=F(Q);if(!J)return null;const{fromPt:U,toPt:M}=J,te=6;return s.jsxs(s.Fragment,{children:[Q.edgeKey!=="start"&&s.jsx("circle",{cx:U.x,cy:U.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>H(se,Q)}),s.jsx("circle",{cx:M.x,cy:M.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>$(se,Q)})]})},W=()=>{if(!v)return null;let Q,J,U,M;if(v.type==="reconnect-from"){const re=P.get(v.fixedTargetId);if(!re)return null;Q=v.mouseX,J=v.mouseY,U=re.cx,M=re.cy-re.h/2}else{const re=P.get(v.fromNodeId);if(!re)return null;Q=re.cx,J=re.cy+re.h/2,U=v.mouseX,M=v.mouseY}const te=M-J,se=Math.abs(te)>10?`M ${Q} ${J} C ${Q} ${J+te*.4}, ${U} ${M-te*.4}, ${U} ${M}`:`M ${Q} ${J} L ${U} ${M}`;return s.jsx("path",{d:se,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},B=Q=>{const J=Q.cy+Q.h/2,U=(v==null?void 0:v.fromNodeId)===Q.id;return s.jsx("circle",{cx:Q.cx,cy:J,r:mk,fill:U?"#58a6ff":"#1c2128",stroke:U?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:U?1:.5,className:"cursor-crosshair",onMouseDown:M=>V(M,Q.id)})},Z=Q=>{const J=Q.cy-Q.h/2,U=v&&k===Q.id&&z(Q.id);return s.jsx("circle",{cx:Q.cx,cy:J,r:mk,fill:U?"#3fb950":"#1c2128",stroke:U?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:U?1:.5})};return s.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${O}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:q,onMouseUp:X,onClick:Y,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),s.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),D.map((Q,J)=>I(Q,J)),E.map(Q=>{const J=n===Q.id,U=Q.cx-Q.w/2,M=Q.cy-Q.h/2,te=_===Q.id,se=v&&k===Q.id&&z(Q.id);if(Q.type==="terminal"){const le=Q.id==="$start",ye=le?"#58a6ff":"#3fb950",_e=le,Oe=!le;return s.jsxs("g",{onClick:Be=>{Be.stopPropagation(),le&&!c&&d("start")},className:le&&!c?"cursor-pointer":void 0,children:[se&&s.jsx("rect",{x:U-3,y:M-3,width:Q.w+6,height:Q.h+6,rx:Q.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),le&&r==="start"&&s.jsx("rect",{x:U-3,y:M-3,width:Q.w+6,height:Q.h+6,rx:Q.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:U,y:M,width:Q.w,height:Q.h,rx:Q.h/2,fill:ye,fillOpacity:.08,stroke:ye,strokeOpacity:.4,strokeWidth:1.5}),s.jsx("text",{x:Q.cx,y:Q.cy+4,textAnchor:"middle",fill:ye,className:"text-[10px] font-medium",pointerEvents:"none",children:Q.label}),_e&&B(Q),Oe&&Z(Q)]},Q.id)}const re=Q.color??"#6b7280";return s.jsxs("g",{onClick:le=>{le.stopPropagation(),c||u(J?null:Q.id)},onMouseEnter:()=>S(Q.id),onMouseLeave:()=>S(null),className:c?void 0:"cursor-pointer",children:[se&&s.jsx("rect",{x:U-3,y:M-3,width:Q.w+6,height:Q.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),J&&s.jsx("rect",{x:U-3,y:M-3,width:Q.w+6,height:Q.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:U,y:M,width:Q.w,height:Q.h,rx:10,fill:re,fillOpacity:.08,stroke:re,strokeOpacity:.6,strokeWidth:J?2:1.5}),s.jsx("text",{x:Q.cx,y:Q.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:Q.label}),!c&&B(Q),!c&&Z(Q),te&&!v&&!c&&s.jsxs("g",{onClick:le=>{le.stopPropagation(),h(Q.id)},className:"cursor-pointer",children:[s.jsx("circle",{cx:U+Q.w-2,cy:M+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),s.jsx("line",{x1:U+Q.w-5,y1:M-1,x2:U+Q.w+1,y2:M+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),s.jsx("line",{x1:U+Q.w+1,y1:M-1,x2:U+Q.w-5,y2:M+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},Q.id)}),v&&E.map(Q=>z(Q.id)?s.jsx("rect",{x:Q.cx-Q.w/2-8,y:Q.cy-Q.h/2-8,width:Q.w+16,height:Q.h+16,fill:"transparent",rx:12,onMouseEnter:()=>N(Q.id),onMouseLeave:()=>N(null),onMouseUp:J=>{J.stopPropagation(),X()}},`drop-${Q.id}`):null),W(),R()]})}const ch="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",Rc="block text-[11px] text-text-secondary mb-0.5";function kV({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:l,onNameChange:c,onDescriptionChange:u,onMaxIterationsChange:d,onColorChange:h}){return s.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[s.jsxs("div",{className:"min-w-[140px]",children:[s.jsx("label",{className:Rc,children:"Name"}),s.jsx("input",{value:e,onChange:p=>c(p.target.value),placeholder:"Workflow name",className:`${ch} ${l?"opacity-50":""}`,readOnly:l})]}),s.jsxs("div",{className:"min-w-[100px]",children:[s.jsx("label",{className:Rc,children:"ID"}),s.jsx("input",{value:t,readOnly:!0,className:`${ch} font-mono opacity-50`})]}),s.jsxs("div",{className:"flex-1 min-w-[140px]",children:[s.jsx("label",{className:Rc,children:"Description"}),s.jsx("input",{value:n,onChange:p=>!l&&u(p.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${ch} ${l?"opacity-50":""}`})]}),s.jsxs("div",{className:"w-20",children:[s.jsx("label",{className:Rc,children:"Max Iter."}),s.jsx("input",{type:"number",value:r,onChange:p=>!l&&d(Number(p.target.value)),readOnly:l,className:`${ch} font-mono ${l?"opacity-50":""}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:Rc,children:"Color"}),s.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 jV({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:l}){return s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:l})]})}function gx({title:e,items:t,renderActions:n}){return t.length===0?null:s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t.map(r=>s.jsx(jV,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const Aa="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",xx="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",_s="block text-[11px] text-text-secondary mb-0.5";function yx({variables:e,onInsert:t}){return e.length===0?null:s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>s.jsx("button",{type:"button",onClick:()=>t(n.name),title:n.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${n.name}}}`},n.name))})}function EV({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:l,onRemove:c,onSetEntry:u}){const{color:d,name:h}=Xb(e,n);return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:d+"20",color:d},children:h}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[!t&&s.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),s.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Name"}),s.jsx("input",{value:e.name,onChange:p=>l({...e,name:p.target.value}),placeholder:"Step name",className:Aa})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Type"}),s.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,g=m==="sub_agent"?"verification":"build";if(m==="agent"){const x=n.find(w=>!w.subagent);l({...e,type:m,phase:g,agentId:(x==null?void 0:x.id)??"builder",name:(x==null?void 0:x.name)??"Agent"})}else if(m==="sub_agent"){const x=n.find(w=>w.subagent);l({...e,type:m,phase:g,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else l(m==="user"?{...e,type:m,phase:g,name:"User"}:{...e,type:m,phase:g,name:"Shell"})},className:xx,children:SV.map(p=>s.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Agent Type"}),s.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(g=>g.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:xx,children:n.filter(p=>!p.subagent).map(p=>s.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Sub-Agent Type"}),s.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(g=>g.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:xx,children:[s.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>s.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Prompt"}),s.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${Aa} resize-y text-xs`,placeholder:"Injected on first entry..."}),s.jsx(yx,{variables:a,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Nudge Prompt"}),s.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${Aa} resize-y text-xs`,placeholder:"Injected on re-entry..."}),s.jsx(yx,{variables:a,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Command"}),s.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${Aa} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),s.jsx(yx,{variables:a,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Timeout (ms)"}),s.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${Aa} font-mono text-xs`})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Success Codes"}),s.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:`${Aa} font-mono text-xs`})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Sub-group"}),s.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Aa})]}),s.jsx("div",{className:"pt-1 border-t border-border/50",children:s.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Go="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",pk="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",La="block text-[11px] text-text-secondary mb-0.5";function NV({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:l,transitionIndex:c,totalTransitions:u,onUpdateCondition:d,onUpdateSubGroup:h,onDelete:p,onMoveUp:m,onMoveDown:g}){var C;const x=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(_=>_.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(x==null?void 0:x.results)&&x.results.length>0;return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",c+1]}),u>1&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsx("button",{onClick:m,disabled:c===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:s.jsx(pn,{className:"w-3 h-3",rotate:180})}),s.jsx("button",{onClick:g,disabled:c===u-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:s.jsx(pn,{className:"w-3 h-3"})})]})]}),s.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:e}),s.jsx(vf,{}),s.jsx("span",{className:"font-medium text-text-primary",children:t})]}),s.jsxs("div",{children:[s.jsx("label",{className:La,children:"Condition"}),s.jsx("select",{value:n.type,onChange:_=>{d(_.target.value==="step_result"?{type:"step_result",result:"success"}:{type:_.target.value})},className:pk,children:HT.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))})]}),n.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:La,children:"Result"}),w?s.jsx("select",{value:n.result??x.results[0],onChange:_=>{d({type:"step_result",result:_.target.value})},className:pk,children:x.results.map(_=>s.jsx("option",{value:_,children:_},_))}):s.jsx("input",{type:"text",value:n.result??"success",onChange:_=>d({type:"step_result",result:_.target.value}),placeholder:"e.g. success, passed, failed",className:Go})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:La,children:"Metadata Key"}),s.jsx("input",{type:"text",value:n.key??"",onChange:_=>d({...n,key:_.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Go})]}),s.jsxs("div",{children:[s.jsx("label",{className:La,children:"Field"}),s.jsx("input",{type:"text",value:n.field??"",onChange:_=>d({...n,field:_.target.value}),placeholder:"e.g. status",className:Go})]}),n.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:La,children:"Value"}),s.jsx("input",{type:"text",value:n.value??"",onChange:_=>d({...n,value:_.target.value}),placeholder:"e.g. passed, resolved",className:Go})]}):s.jsxs("div",{children:[s.jsx("label",{className:La,children:"Values (comma-separated)"}),s.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:Go})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:La,children:"Sub-group"}),s.jsx("input",{type:"text",value:r??"",onChange:_=>h(_.target.value||void 0),placeholder:"e.g. build, verify",className:Go})]}),(a==null?void 0:a.type)==="user"&&s.jsxs("div",{className:"pt-1 border-t border-border/50 space-y-1",children:[s.jsx("p",{className:"text-text-muted text-[10px]",children:'On a user step, each "Step result is..." transition becomes a choice button; "Always" becomes a Continue button.'}),n.type==="step_result"&&a.transitions.filter(_=>_.when.type==="step_result"&&_.when.result===n.result).length>1&&s.jsxs("p",{className:"text-accent-warning text-[10px]",children:['Duplicate result "',n.result,'" — only the first matching transition is reachable.']}),n.type==="step_result"&&n.result==="continue"&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'"continue" is reserved for the "Always" Continue button — rename this result.'}),n.type==="always"&&a.transitions.some((_,S)=>S>c&&_.when.type==="step_result")&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'This "Always" transition comes before one or more choice transitions — those choice buttons are unreachable. Move it to the end.'}),n.type==="always"&&a.transitions.filter(_=>_.when.type==="always").length>1&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'Multiple "Always" transitions — only the first is reachable.'})]}),s.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function TV(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function AV(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Oc="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",gk="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",Wo="block text-[11px] text-text-secondary mb-0.5",xk=[];function FT({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){var Dt,rn;const a=$t(Ne=>Ne.defaults),l=$t(Ne=>Ne.userItems),c=$t(Ne=>Ne.projectItems),u=$t(Ne=>Ne.loading),d=$t(Ne=>Ne.templateVariables),h=$t(Ne=>Ne.fetchWorkflows),p=$t(Ne=>Ne.fetchWorkflow),m=$t(Ne=>Ne.fetchDefaultContent),g=$t(Ne=>Ne.fetchTemplateVariables),x=$t(Ne=>Ne.createWorkflow),w=$t(Ne=>Ne.updateWorkflow),C=$t(Ne=>Ne.deleteWorkflow),{requestDelete:_,clearConfirm:S,isConfirming:v}=fu(),[b,k]=j.useState("list"),[N,E]=j.useState(null),[D,A]=j.useState(void 0),[O,P]=j.useState(!1),[G,z]=j.useState(null),[V,$]=j.useState(null),[H,q]=j.useState(""),[X,Y]=j.useState(""),[F,I]=j.useState(""),[R,W]=j.useState("1.0.0"),[B,Z]=j.useState("#3b82f6"),[Q,J]=j.useState(""),[U,M]=j.useState(50),[te,se]=j.useState(xk),[re,le]=j.useState({type:"always"}),[ye,_e]=j.useState([]),[Oe,Be]=j.useState("user"),[ke,Ge]=j.useState(""),[Je,ae]=j.useState(!1),ue=ut(Ne=>Ne.defaults),Me=ut(Ne=>Ne.userItems),fe=ut(Ne=>Ne.projectItems),Fe=j.useMemo(()=>[...ue,...Me,...fe],[ue,Me,fe]),He=ut(Ne=>Ne.fetchAgents),[ie]=j.useState(null);j.useEffect(()=>{e&&(h(r),g(),He(),z(null),$(null),n?a.some(Te=>Te.id===n)?m(n,r).then(Te=>{Te&&Se({...Te,metadata:{...Te.metadata,name:Te.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):p(n,r).then(Te=>{Te&&Se(Te,{editingId:n,isReadOnly:!1})}):(k("list"),E(null),P(!1)))},[e,h,p,m,g,n,r]);const Se=(Ne,Te)=>{q(Ne.metadata.name),Y(Ne.metadata.id),I(Ne.metadata.description),W(Ne.metadata.version),Z(Ne.metadata.color??"#3b82f6"),J(Ne.entryStep),M(Ne.settings.maxIterations),se(Ne.steps),le(Ne.startCondition??{type:"always"}),_e(Ne.metadata.parameters??[]),Ge(""),(Te==null?void 0:Te.editingId)!==void 0&&E(Te.editingId),(Te==null?void 0:Te.isReadOnly)!==void 0&&P(Te.isReadOnly),(Te==null?void 0:Te.selectedNodeKey)!==void 0&&z(null),(Te==null?void 0:Te.selectedEdgeKey)!==void 0&&$(null),k("edit")},Le=async(Ne,Te)=>{A(Te);const $e=await p(Ne,r,Te);$e&&Se($e,{editingId:Ne,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},he=async()=>{var mt;const Ne=N??X;if(!Ne||!H)return Ge("Name is required."),!1;if(te.length===0)return Ge("Add at least one step."),!1;const Te=ye.find(_t=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_t.id));if(Te)return Ge(`Invalid parameter ID "${Te.id}". Use letters, digits, and underscores only.`),!1;let $e=Q;if(!$e||!te.some(_t=>_t.id===$e)){if($e=((mt=te.find(_t=>_t.id))==null?void 0:mt.id)??"",!$e)return Ge("All steps need an ID."),!1;J($e)}ae(!0),Ge("");const Xe={metadata:{id:Ne,name:H,description:F,version:R||"1.0.0",color:B,...ye.length>0?{parameters:ye}:{}},entryStep:$e,settings:{maxIterations:U},steps:te,startCondition:re},tt=N?await w(N,Xe,r,D):await x(Xe,Oe,r);return ae(!1),tt.success?(N||E(Ne),!0):(Ge(tt.error??"Failed to save."),!1)},me=async()=>{await he()},We=async()=>{await he()&&(n?t():k("list"))},Ue=()=>{n?t():k("list")},Qe=Ne=>{q(Ne),N||Y(TV(Ne))},it=async(Ne,Te)=>a.some(Xe=>Xe.id===Ne)?await m(Ne,r):await p(Ne,r,Te),ge=async(Ne,Te)=>{const $e=await it(Ne,Te);$e&&Se({...$e,metadata:{...$e.metadata,name:$e.metadata.name+" (copy)",id:`${Ne}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Ve=()=>{E(null),A(void 0),q(""),Y(""),I(""),W("1.0.0"),Z("#3b82f6"),J(""),M(50),se(structuredClone(xk)),le({type:"always"}),_e([]),Be("user"),Ge(""),z(null),$(null),P(!1),k("edit")},at=async(Ne,Te)=>{await C(Ne,Te,r),S()},ht=j.useCallback(Ne=>{z(Ne),$(null)},[]),Ht=j.useCallback(Ne=>{$(Ne),z(null)},[]),Vt=G!==null?Number(G):-1,At=Vt>=0?te[Vt]??null:null,Bn=j.useCallback(Ne=>{se(Te=>Te.map(($e,Xe)=>Xe===Vt?Ne:$e))},[Vt]),Sn=re.type==="step_result"?`${re.result}`:re.type==="metadata_all_match"?`${re.key??"?"}=${re.value??"?"}`:re.type==="metadata_all_in"?`${re.key??"?"} in [${((Dt=re.values)==null?void 0:Dt.join(","))??"?"}]`:zT[re.type]??re.type,hn=()=>{const Ne=te.length,Te=AV(te),$e=Fe.find(Xe=>!Xe.subagent);se([...te,{id:Te,name:($e==null?void 0:$e.name)??"Agent",type:"agent",phase:"build",agentId:($e==null?void 0:$e.id)??"builder",transitions:[]}]),Q||J(Te),ht(String(Ne))},Dn=j.useCallback((Ne,Te)=>{Ne==="$start"?(J(Te),Ht("start")):se($e=>{const Xe=$e.find(mt=>mt.id===Ne),tt=Xe?Xe.transitions.length:0;return Ht(`${Ne}:${tt}`),$e.map(mt=>mt.id===Ne?{...mt,transitions:[...mt.transitions,{when:{type:"always"},goto:Te}]}:mt)})},[Ht]),wn=Ne=>{if(Ne==="start")return null;const Te=Ne.lastIndexOf(":"),$e=Ne.slice(0,Te),Xe=parseInt(Ne.slice(Te+1));return{stepId:$e,transIdx:Xe}},un=j.useCallback((Ne,Te)=>{const $e=wn(Ne);$e&&se(Xe=>Xe.map(tt=>tt.id===$e.stepId?{...tt,transitions:tt.transitions.map((mt,_t)=>_t===$e.transIdx?Te(mt):mt)}:tt))},[]),nr=j.useCallback((Ne,Te)=>{if(Ne==="start"){J(Te);return}un(Ne,$e=>({...$e,goto:Te}))},[un]),we=j.useCallback((Ne,Te)=>{const $e=wn(Ne);$e&&(se(Xe=>{const tt=Xe.find(_t=>_t.id===$e.stepId);if(!tt)return Xe;const mt=tt.transitions[$e.transIdx];return mt?Xe.map(_t=>_t.id===$e.stepId?{..._t,transitions:_t.transitions.filter((Rn,gn)=>gn!==$e.transIdx)}:_t.id===Te?{..._t,transitions:[..._t.transitions,mt]}:_t):Xe}),$(null))},[]),et=j.useCallback(Ne=>{if(Ne==="start"){J(""),$(null);return}const Te=wn(Ne);Te&&(se($e=>$e.map(Xe=>Xe.id===Te.stepId?{...Xe,transitions:Xe.transitions.filter((tt,mt)=>mt!==Te.transIdx)}:Xe)),$(null))},[]),Ye=j.useCallback((Ne,Te)=>{if(Ne==="start"){le(Te);return}un(Ne,$e=>({...$e,when:Te}))},[un]),oe=j.useCallback((Ne,Te)=>{Ne!=="start"&&un(Ne,$e=>({...$e,subGroup:Te||void 0}))},[un]),Pe=Ne=>Xb(Ne,Fe).name,Ze=()=>{if(!V)return null;if(V==="start"){const Rn=te.find(gn=>gn.id===Q);return{type:"start",fromLabel:"Start",toLabel:Rn?Pe(Rn):"(none)",condition:re}}const Ne=V.lastIndexOf(":"),Te=V.slice(0,Ne),$e=parseInt(V.slice(Ne+1)),Xe=te.find(Rn=>Rn.id===Te);if(!Xe)return null;const tt=Xe.transitions[$e];if(!tt)return null;const mt=te.find(Rn=>Rn.id===tt.goto),_t=tt.goto==="$done"?"Done":mt?Pe(mt):tt.goto;return{type:"step",fromLabel:Pe(Xe),toLabel:_t,condition:tt.when,subGroup:tt.subGroup}};if(b==="edit"){const Ne=Ze();return s.jsxs(St,{isOpen:e,onClose:Ue,title:O?H:N?"Edit Workflow":"New Workflow",size:"full",children:[ke&&s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:ke}),s.jsx(kV,{formName:H,formId:X,formDescription:F,formMaxIterations:U,formColor:B,isReadOnly:O,onNameChange:Qe,onDescriptionChange:I,onMaxIterationsChange:M,onColorChange:Z}),!O&&s.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:s.jsxs(_V,{title:`Parameters (${ye.length})`,children:[ye.map((Te,$e)=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{value:Te.id,onChange:Xe=>{const tt=[...ye];tt[$e]={...Te,id:Xe.target.value},_e(tt)},placeholder:"ID",className:"w-28 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("input",{value:Te.label,onChange:Xe=>{const tt=[...ye];tt[$e]={...Te,label:Xe.target.value},_e(tt)},placeholder:"Label",className:"w-36 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("input",{value:Te.description??"",onChange:Xe=>{const tt=[...ye];tt[$e]={...Te,description:Xe.target.value||void 0},_e(tt)},placeholder:"Description",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[s.jsx("input",{type:"checkbox",checked:Te.required??!1,onChange:Xe=>{const tt=[...ye];tt[$e]={...Te,required:Xe.target.checked||void 0},_e(tt)},className:"rounded border-border"}),"Req."]}),s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>{$e!==0&&_e(ye.map((Xe,tt)=>tt===$e?{...ye[$e-1],position:tt}:tt===$e-1?{...ye[$e],position:tt}:{...Xe,position:tt}))},disabled:$e===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${Te.label||Te.id} up`,children:"▲"}),s.jsx("button",{onClick:()=>{$e!==ye.length-1&&_e(ye.map((Xe,tt)=>tt===$e?{...ye[$e+1],position:tt}:tt===$e+1?{...ye[$e],position:tt}:{...Xe,position:tt}))},disabled:$e===ye.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${Te.label||Te.id} down`,children:"▼"})]}),s.jsx("button",{onClick:()=>_e(ye.filter((Xe,tt)=>tt!==$e)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},Te.id)),s.jsx("button",{onClick:()=>{const Te=`param_${ye.length+1}`;_e([...ye,{id:Te,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!N&&!O&&s.jsx(jf,{value:Oe,onChange:Be}),s.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[s.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!O&&s.jsx("button",{onClick:hn,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),s.jsxs(dt,{className:"flex-1 min-h-0 p-2",children:[s.jsx(CV,{steps:te,entryStep:Q,selectedNodeId:(At==null?void 0:At.id)??null,selectedEdgeKey:V,startConditionLabel:Sn,agentTypes:Fe,isReadOnly:O,onSelectNode:Te=>{if(Te===null){ht(null);return}const $e=te.findIndex(Xe=>Xe.id===Te);ht($e>=0?String($e):null)},onSelectEdge:Ht,onRemoveStep:Te=>{var Xe;const $e=te.findIndex(tt=>tt.id===Te);if(se(tt=>tt.filter(mt=>mt.id!==Te)),Vt===$e&&ht(null),Q===Te){const tt=te.filter(mt=>mt.id!==Te);J(((Xe=tt[0])==null?void 0:Xe.id)??"")}},onCreateTransition:Dn,onReconnectTo:nr,onReconnectFrom:we,onDeleteTransition:et}),te.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[s.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),s.jsx("button",{onClick:hn,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),s.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[s.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),s.jsx(dt,{className:"p-3 flex-1 min-h-0",children:O&&(Ne||At)?s.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):Ne?Ne.type==="start"?s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),Q&&s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),s.jsx(vf,{}),s.jsx("span",{className:"text-text-primary font-medium",children:Ne.toLabel})]}),s.jsxs("div",{children:[s.jsx("label",{className:Wo,children:"Activation Condition"}),s.jsx("select",{value:re.type,onChange:Te=>le(Te.target.value==="step_result"?{type:"step_result",result:"success"}:Te.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Te.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Te.target.value}),className:gk,children:HT.map(Te=>s.jsx("option",{value:Te.value,children:Te.label},Te.value))})]}),re.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:Wo,children:"Result"}),Q&&(()=>{const Te=te.find(mt=>mt.id===Q),$e=Te&&(Te.type==="sub_agent"||Te.type==="agent")?Fe.find(mt=>mt.id===(Te.type==="sub_agent"?Te.subAgentType:Te.agentId)):void 0,Xe=($e==null?void 0:$e.results)&&$e.results.length>0,tt=($e==null?void 0:$e.results)??[];return Xe?s.jsx("select",{value:re.result??tt[0],onChange:mt=>le({type:"step_result",result:mt.target.value}),className:gk,children:tt.map(mt=>s.jsx("option",{value:mt,children:mt},mt))}):s.jsx("input",{type:"text",value:re.result??"success",onChange:mt=>le({type:"step_result",result:mt.target.value}),placeholder:"e.g. success, passed, failed",className:Oc})})()]}),(re.type==="metadata_all_match"||re.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Wo,children:"Metadata Key"}),s.jsx("input",{type:"text",value:re.key??"",onChange:Te=>le({...re,key:Te.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Oc})]}),s.jsxs("div",{children:[s.jsx("label",{className:Wo,children:"Field"}),s.jsx("input",{type:"text",value:re.field??"",onChange:Te=>le({...re,field:Te.target.value}),placeholder:"e.g. status",className:Oc})]}),re.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:Wo,children:"Value"}),s.jsx("input",{type:"text",value:re.value??"",onChange:Te=>le({...re,value:Te.target.value}),placeholder:"e.g. passed, resolved",className:Oc})]}):s.jsxs("div",{children:[s.jsx("label",{className:Wo,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((rn=re.values)==null?void 0:rn.join(", "))??"",onChange:Te=>le({...re,values:Te.target.value.split(",").map($e=>$e.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Oc})]})]}),s.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):(()=>{const Te=wn(V),$e=Te==null?void 0:Te.stepId,Xe=(Te==null?void 0:Te.transIdx)??0,tt=$e?te.find(_t=>_t.id===$e):void 0,mt=(tt==null?void 0:tt.transitions.length)??0;return s.jsx(NV,{fromLabel:Ne.fromLabel,toLabel:Ne.toLabel,condition:Ne.condition,subGroup:"subGroup"in Ne?Ne.subGroup:void 0,fromStep:Ne.type==="step"?te.find(_t=>_t.id===Ne.fromLabel):void 0,agentTypes:Fe,transitionIndex:Xe,totalTransitions:mt,onUpdateCondition:_t=>Ye(V,_t),onUpdateSubGroup:_t=>oe(V,_t),onDelete:()=>et(V),onMoveUp:()=>{se(_t=>{const Rn=_t.find(Cn=>Cn.id===$e);if(!Rn||Xe===0)return _t;const gn=[...Rn.transitions];return[gn[Xe-1],gn[Xe]]=[gn[Xe],gn[Xe-1]],_t.map(Cn=>Cn.id===$e?{...Cn,transitions:gn}:Cn)}),$(`${$e}:${Xe-1}`)},onMoveDown:()=>{se(_t=>{const Rn=_t.find(Cn=>Cn.id===$e);if(!Rn||Xe===Rn.transitions.length-1)return _t;const gn=[...Rn.transitions];return[gn[Xe],gn[Xe+1]]=[gn[Xe+1],gn[Xe]],_t.map(Cn=>Cn.id===$e?{...Cn,transitions:gn}:Cn)}),$(`${$e}:${Xe+1}`)}})})():At?s.jsx(EV,{step:At,isEntry:At.id===Q,agentTypes:Fe,transitionCount:At.transitions.length,templateVariables:d,onUpdate:Bn,onRemove:()=>{var Te;if(At&&(se(te.filter(($e,Xe)=>Xe!==Vt)),ht(null),Q===At.id)){const $e=te.filter((Xe,tt)=>tt!==Vt);J(((Te=$e[0])==null?void 0:Te.id)??"")}},onSetEntry:()=>J(At.id)}):s.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",s.jsx("br",{}),"Drag from a port to connect."]})})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[s.jsx(rt,{variant:"secondary",onClick:Ue,children:"Close"}),O?s.jsx(rt,{variant:"primary",onClick:()=>{q(H+" (copy)"),Y(`${N}-copy-${Date.now()}`),E(null),P(!1)},children:"Duplicate & Customize"}):s.jsxs(s.Fragment,{children:[s.jsx(rt,{variant:"primary",onClick:me,children:"Save"}),s.jsx(rt,{variant:"primary",onClick:We,children:"Save & Close"})]})]})]})}return s.jsx(St,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:s.jsx(Gj,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Ve,loading:u,hasItems:a.length>0||l.length>0||c.length>0,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(gx,{title:"Built-in",items:a,renderActions:Ne=>s.jsx(s.Fragment,{children:s.jsx(di,{onClick:()=>ge(Ne.id),children:s.jsx(Gy,{})})})}),s.jsx(gx,{title:"Custom",items:l,renderActions:Ne=>s.jsxs(s.Fragment,{children:[s.jsx(di,{onClick:()=>Le(Ne.id,"user"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(tu,{onClick:()=>ge(Ne.id,"user")}),v(`user:${Ne.id}`,"delete")?s.jsx(Lh,{onConfirm:()=>at(Ne.id,"user"),onCancel:S}):s.jsx(Dh,{onClick:()=>_(`user:${Ne.id}`)})]})}),c.length>0&&s.jsx(gx,{title:"Project",items:c,renderActions:Ne=>s.jsxs(s.Fragment,{children:[s.jsx(di,{onClick:()=>Le(Ne.id,"project"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(tu,{onClick:()=>ge(Ne.id,"project")}),v(`project:${Ne.id}`,"delete")?s.jsx(Lh,{onConfirm:()=>at(Ne.id,"project"),onCancel:S}):s.jsx(Dh,{onClick:()=>_(`project:${Ne.id}`)})]})})]})})})}function LV(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function DV({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:c,onSearchMessages:u,onToggleAutoScroll:d,isAutoScrollActive:h}){const[,p]=Ln(),m=ln(B=>B.fetchCommands),g=$t(B=>B.fetchWorkflows),x=ut(B=>B.fetchAgents),w=ln(B=>B.defaults),C=ln(B=>B.userItems),_=ln(B=>B.projectItems),S=$t(B=>B.defaults),v=$t(B=>B.userItems),b=$t(B=>B.projectItems),k=ut(B=>B.defaults),N=ut(B=>B.userItems),E=ut(B=>B.projectItems),D=Re(B=>{var Z;return(Z=B.currentSession)==null?void 0:Z.mode}),A=Re(B=>{var Z;return((Z=B.currentSession)==null?void 0:Z.dangerLevel)??"normal"}),O=Re(B=>B.switchMode),P=Re(B=>B.switchDangerLevel),G=Re(B=>{var Z;return(Z=B.currentSession)==null?void 0:Z.projectId}),z=j.useRef(void 0),[V,$]=j.useState(""),[H,q]=j.useState(0),X=j.useRef(null),Y=j.useRef(!1);j.useEffect(()=>{e&&(Y.current=!0)},[e]),j.useEffect(()=>{if(e){m(),g(),x(),$(""),q(0);const B=setTimeout(()=>{var Z;zt()&&((Z=X.current)==null||Z.focus())},50);return()=>clearTimeout(B)}},[e,m,g,x]),j.useEffect(()=>{var B;!e&&Y.current&&(n==null||n(),(B=z.current)==null||B.call(z),z.current=void 0)},[e,n]);const I=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const B=G??LV(window.location.pathname);B&&p(`/p/${B}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{z.current=l,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),u==null||u()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!h)}},...Qn(Qn(k,N),E).filter(B=>!B.subagent&&B.id!==D).map(B=>({id:B.id,name:B.name,prefix:"Agent > Switch to",action:()=>O(B.id)})),...Qn(Qn(w,C),_).map(B=>({id:B.id,name:B.name,prefix:"Command > Launch",action:()=>r(B.id,c)})),...Qn(Qn(S,v),b).map(B=>({id:B.id,name:B.name,prefix:"Workflow > Run",action:()=>a(B.id,B.scope)})),...["normal","dangerous"].filter(B=>B!==A).map(B=>({id:B,name:B.charAt(0).toUpperCase()+B.slice(1),prefix:"Mode > Switch to",action:()=>P(B)}))].filter(B=>qi(`${B.prefix} ${B.name}`,V)),R=I.length-1,W=B=>{nT(B,R,q,()=>{var Z;(Z=I[H])==null||Z.action(),t()},t)};return e?mi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx("input",{ref:X,type:"text",value:V,onChange:B=>{$(B.target.value),q(0)},onKeyDown:W,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx(Xy,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),s.jsx(dt,{className:"max-h-[60vh] p-2",children:I.length===0?s.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"}):I.map((B,Z)=>s.jsxs("button",{type:"button",onClick:()=>{B.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${Z===H?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[s.jsxs("span",{className:"text-text-muted font-normal",children:[B.prefix," "]}),s.jsx("span",{children:B.name})]},B.id))})]})]}),document.body):null}const UT="openfox-message-search-filters",RV=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function OV(){try{const e=localStorage.getItem(UT);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function IV(e){localStorage.setItem(UT,JSON.stringify([...e]))}function MV(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 PV(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"),c=String(t.getDate()).padStart(2,"0"),u=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${a}/${l}/${c} ${u}:${d}`}function BV(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 $V(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 zV(e){var n,r;if(e.type!=="message")return s.jsx(Vw,{className:"w-3.5 h-3.5"});const t=e.message;return t.role==="assistant"?(n=t.thinkingContent)!=null&&n.trim()&&!((r=t.content)!=null&&r.trim())?s.jsx(e3,{className:"w-3.5 h-3.5"}):s.jsx(Vw,{className:"w-3.5 h-3.5"}):s.jsx(Z5,{className:"w-3.5 h-3.5"})}function yk(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 HV({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,l]=j.useState(""),[c,u]=j.useState(0),[d,h]=j.useState(OV),p=j.useRef(null),m=j.useRef(null),g=j.useRef(null),x=N=>{h(E=>{const D=new Set(E);return D.has(N)?D.delete(N):D.add(N),IV(D),D})},w=j.useMemo(()=>n.filter(N=>{var E,D;return!(N.type==="context-divider"||N.type==="message"&&(N.message.messageKind==="auto-prompt"||N.message.role==="assistant"&&!((E=N.message.content)!=null&&E.trim())&&!((D=N.message.thinkingContent)!=null&&D.trim())))}),[n]),C=j.useMemo(()=>w.filter(N=>{const E=MV(N);return!(E&&!d.has(E))}),[w,d]),_=j.useMemo(()=>a?w.filter(N=>{const E=yk(N);return qi(E,a)}):C,[C,a]),S=_.length-1;j.useEffect(()=>{if(e){l(""),u(0);const N=setTimeout(()=>{var E;zt()&&((E=p.current)==null||E.focus())},50);return()=>clearTimeout(N)}},[e]),j.useEffect(()=>{var N;if(e&&m.current){const E=(N=m.current.osInstance())==null?void 0:N.elements().viewport;E&&(E.scrollTop=E.scrollHeight)}},[e]),j.useEffect(()=>{g.current&&g.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[c]);const v=N=>{nT(N,S,u,()=>{const E=_[c];if(E){const D=n.indexOf(E);D>=0&&r(D),t()}},t)},b=N=>{const E=n.indexOf(N);E>=0&&r(E),t()},k=N=>n.indexOf(N);return e?mi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx(hi,{}),s.jsx("input",{ref:p,type:"text",value:a,onChange:N=>{l(N.target.value),u(0)},onKeyDown:v,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx("button",{type:"button",onClick:t,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Close",children:s.jsx(ea,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:RV.map(N=>{const E=d.has(N.key);return s.jsx("button",{type:"button",onClick:()=>x(N.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${E?"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)})}),s.jsx(dt,{ref:m,className:"max-h-[60vh] p-2",children:_.length===0?s.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:C.length>0?"No matches":"No messages yet"}):_.map((N,E)=>{const D=k(N),A=zV(N),O=yk(N),P=$V(N),G=BV(N),z=N.type==="message"&&N.message.role==="user";return s.jsx("button",{ref:E===c?g:null,type:"button",onClick:()=>b(N),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${E===c?"bg-accent-primary/20 text-text-primary":z?"bg-accent-primary/5 text-text-secondary hover:bg-accent-primary/10 hover:text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[s.jsx("span",{className:"flex-shrink-0",children:A}),s.jsx("span",{className:`truncate flex-1 ${P}`,children:O})]}),G&&s.jsx("span",{className:"text-text-muted text-xs shrink-0",children:PV(G)})]})},`${D}-${N.type}`)})})]})]}),document.body):null}function VT(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 FV(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 c=a.slice(1),u={},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)=>{c[m]!==void 0&&(u[p.id]=c[m])}):c.forEach((h,p)=>{u[String(p)]=h}),{workflowId:l,params:u}):n&&n.find(p=>p.id===l)?(c.forEach((p,m)=>{u[String(m)]=p}),{commandId:l,params:u}):null}function UV({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const l=j.useRef(null),c=j.useRef(null);j.useEffect(()=>{var h;c.current&&((h=l.current)!=null&&h.getElement())&&c.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const u=h=>{switch(h.key){case"Enter":h.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":h.preventDefault(),r();break;case"ArrowUp":h.preventDefault(),a("up");break;case"ArrowDown":h.preventDefault(),a("down");break}},d=h=>{n(h)};return s.jsx(dt,{ref:l,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg max-h-64",onKeyDown:u,children:e.map((h,p)=>s.jsxs("div",{ref:p===t?c:null,role:"listitem",onClick:()=>d(h.content),className:`
317
+ p-2 rounded cursor-pointer transition-colors
318
+ ${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
319
+ `,children:[s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&s.jsxs(s.Fragment,{children:[" | ",s.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),s.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function VV(){const e=D5(),t=e?"bg-amber-400":"bg-accent-primary";return s.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"flex gap-0.5",children:[s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),s.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&s.jsx("span",{className:"text-text-muted hidden sm:inline",children:"esc to interrupt"})]})}function GV(){const e=Re(c=>c.activeWorkflowExecution),t=Re(c=>c.exitWorkflow),[n,r]=j.useState(!1);j.useEffect(()=>{r(!1)},[e==null?void 0:e.id]);const a=j.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 s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border",children:[s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l}}),s.jsx("span",{className:"font-medium text-text-primary truncate",children:e.workflowName}),e.currentStepName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{className:"text-text-muted truncate",children:e.currentStepName})]}),s.jsx("div",{className:"ml-auto shrink-0",children:s.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"})})]})}function GT(e){const t=Re(l=>l.sendMessage),n=Re(l=>l.launchWorkflow),r=j.useCallback((l,c,u)=>{e(!0),t(l,c,u)},[e,t]),a=j.useCallback((l,c,u,d,h,p="auto")=>{e(!0),n(l,c,u,d,h,p)},[e,n]);return{sendMessage:r,launchWorkflow:a}}function WV({children:e}){return mi.createPortal(e,document.body)}function qV(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 KV({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:l,textareaContent:c,attachments:u}){const[d,h]=j.useState(!1),[p,m]=j.useState("commands"),[g,x]=j.useState(""),[w,C]=j.useState(0),[_,S]=j.useState(null),[v,b]=j.useState(null),k=j.useRef(null),N=j.useRef(null),E=ln(R=>R.defaults),D=ln(R=>R.userItems),A=ln(R=>R.projectItems),O=ln(R=>R.fetchCommands),P=$t(R=>R.fetchWorkflows),G=Qn(Qn(E,D),A),z=Yf();j.useEffect(()=>{d&&(p==="commands"?O():p==="workflows"&&P())},[d,p,O,P]),j.useEffect(()=>{d&&(x(""),C(0),requestAnimationFrame(()=>{var R;zt()&&((R=k.current)==null||R.focus())}))},[d,p]),j.useEffect(()=>{if(!d)return;const R=W=>{var B;(B=N.current)!=null&&B.contains(W.target)||h(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[d]);const V=R=>{switch(R.key){case"ArrowDown":R.preventDefault(),C(W=>{const Z=(p==="commands"?G:z).filter(Q=>{const J=g.toLowerCase();return!J||Q.name.toLowerCase().includes(J)});return Math.min(W+1,Z.length-1)});break;case"ArrowUp":R.preventDefault(),C(W=>Math.max(W-1,0));break;case"Enter":R.preventDefault();break;case"Escape":R.preventDefault(),h(!1);break}},$=R=>{x(R),C(0)},H=G.filter(R=>!g||R.name.toLowerCase().includes(g.toLowerCase())),q=z.filter(R=>!g||R.name.toLowerCase().includes(g.toLowerCase())),X=async R=>{const W=await ln.getState().fetchCommand(R);W&&e(W.prompt,W.metadata.agentMode,c,u),h(!1)},Y=(R,W)=>{t(R,W),h(!1)},F=(R,W)=>{W.stopPropagation(),h(!1),S(R)},I=(R,W)=>{W.stopPropagation(),h(!1),b(R)};return s.jsxs("div",{ref:N,className:"relative",children:[s.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:s.jsx($j,{className:"w-4 h-4"})}),d&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 max-w-[calc(100vw-2rem)] bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[s.jsxs("div",{className:"flex border-b border-border",children:[s.jsx("button",{type:"button",onClick:()=>{m("commands"),x(""),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"}),s.jsx("button",{type:"button",onClick:()=>{m("workflows"),x(""),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"}),s.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"&&s.jsx("div",{className:"p-2 border-b border-border",children:s.jsx("input",{ref:k,value:g,onChange:R=>$(R.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"})}),s.jsx(dt,{className:"max-h-64 p-1",children:p==="commands"?H.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:G.length===0?"No commands yet":"No matches"}):H.map((R,W)=>s.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${W===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsx("button",{type:"button",onClick:()=>X(R.id),className:"flex-1 text-left",children:s.jsx("div",{className:"text-sm text-text-primary font-medium",children:R.name})}),s.jsx(di,{className:"opacity-0 group-hover:opacity-100",onClick:B=>F(R.id,B)})]},R.id)):p==="workflows"?q.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:z.length===0?"No workflows yet":"No matches"}):q.map((R,W)=>{const B=qV(R),Z=R.color??"#3b82f6";return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${W===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsxs("button",{type:"button",onClick:()=>Y(R.id,R.scope),className:"flex-1 text-left flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:Z}}),s.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:R.name}),s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:zb[R.scope]}),B!==null&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:B?"#22c55e":"#6b7280"},title:B?"Entry condition met":"Entry condition not met"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[R.subGroups&&R.subGroups.length>0&&s.jsx(YV,{subGroups:R.subGroups,onSelect:Q=>{h(!1),n(R.id,Q,R.scope)}}),s.jsx(di,{className:"opacity-0 group-hover:opacity-100",onClick:Q=>I(R.id,Q)})]})]},`${R.id}-${R.scope}`)}):s.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[s.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:[s.jsx(Mj,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),s.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&s.jsx("div",{className:"border-t border-border p-1",children:s.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..."})})]}),s.jsx($T,{isOpen:!!_,onClose:()=>S(null),initialEditId:_}),s.jsx(FT,{isOpen:!!v,onClose:()=>b(null),initialEditId:v})]})}function YV({subGroups:e,onSelect:t}){const[n,r]=j.useState(!1),[a,l]=j.useState({top:0,right:0}),c=j.useRef(null),u=j.useRef(null);Xf(u,()=>r(!1),n);const d=h=>{if(h.stopPropagation(),!n&&c.current){const p=c.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:c,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&s.jsx(WV,{children:s.jsx("div",{ref:u,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(h=>s.jsx("button",{type:"button",onClick: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 XV({messages:e,onCancel:t}){return e.length===0?null:s.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>s.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${n.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[s.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),s.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),s.jsx(_u,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function JV({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,model:a,onView:l,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h}){var g;const p=e.allowedTools.filter(x=>!(r!=null&&r.has(x))),m=a?(g=a.split("/").pop())==null?void 0:g.replace(/-/g," "):void 0;return s.jsxs(Zj,{isBuiltIn:t,isConfirmingDelete:n,onView:l,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"}),m&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent-primary/10 text-accent-primary",children:m})]}),e.description&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[p.slice(0,5).map(x=>s.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:x},x)),p.length>5&&s.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",p.length-5," more"]})]})]})}function bk({title:e,agentTitle:t="Agents",subagentTitle:n="Sub-agents",agents:r,subagents:a,isBuiltIn:l,alwaysAllowedNames:c,modelOverrides:u,onView:d,onDuplicate:h,onEdit:p,onDelete:m,onCancelDelete:g,isConfirmingDelete:x}){if(r.length===0&&a.length===0)return null;const w=C=>s.jsx(JV,{agent:C,model:u==null?void 0:u[C.id],isBuiltIn:l,isConfirmingDelete:(x==null?void 0:x(C.id))??!1,alwaysAllowedNames:c,onView:()=>d(C.id),onEdit:p?()=>p(C.id):void 0,onDuplicate:()=>h(C.id),onDelete:l?void 0:()=>m==null?void 0:m(C.id),onCancelDelete:l?void 0:()=>g==null?void 0:g(C.id)},C.id);return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),r.length>0&&s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:t}),s.jsxs("div",{className:"space-y-2",children:[r.map(w),a.length>0&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:n}),s.jsx("div",{className:"space-y-2",children:a.map(w)})]})]})]})}function QV(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),c=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(c))}}return t}function uh(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function ZV({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:l,formModel:c,formPrompt:u,formError:d,isReadOnly:h,availableTools:p,providers:m,onNameChange:g,onIdChange:x,onDescriptionChange:w,onSubagentChange:C,onToolsChange:_,onColorChange:S,onModelChange:v,onPromptChange:b}){const k=QV(a),N=p.filter(P=>!(r&&P.topLevelOnly)&&!P.isMcp),E=p.filter(P=>P.isMcp&&!(r&&P.topLevelOnly)),D=new Map;for(const P of E){const G=P.mcpServer??P.name,z=D.get(G)??[];z.push(P),D.set(G,z)}const A=(P,G)=>{const z=new Map(k),V=z.get(P)||new Set,$=new Set(V);$.has(G)?$.delete(G):$.add(G),$.size===0?z.set(P,new Set):z.set(P,$),_(uh(z))},O=P=>{const G=new Map(k);G.has(P)?G.delete(P):G.set(P,new Set),_(uh(G))};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3",children:[d&&s.jsx(il,{message:d}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Xr,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),s.jsx(Xr,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Xr,{label:"Description",value:n,onChange:w,placeholder:"What this agent does",readOnly:h}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),s.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[s.jsx("button",{onClick:()=>!h&&C(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${h?"pointer-events-none opacity-60":""}`,children:"Agent"}),s.jsx("button",{onClick:()=>!h&&C(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),s.jsx("input",{type:"color",value:l,onChange:P=>!h&&S(P.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),!h&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Model override"}),s.jsx($b,{providers:m,value:c,onChange:v,defaultLabel:"Default (global model)"}),s.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"When set, this model will be used when this agent is active (overrides the session model)."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),s.jsx(dt,{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32",children:N.map(P=>{const G=k.has(P.name),z=P.actions.length>0,V=k.get(P.name)||new Set;return z?h?s.jsxs("button",{className:"px-1.5 py-0.5 rounded text-xs font-mono flex items-center gap-1 bg-bg-primary text-text-muted pointer-events-none opacity-60",children:[s.jsx("span",{children:P.name}),s.jsx("span",{className:"text-[10px]",children:"*"})]},P.name):s.jsx(jl,{trigger:s.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${G?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} cursor-pointer`,children:[s.jsx("span",{children:P.name}),V.size>0&&s.jsx("span",{className:"text-[10px]",children:"*"})]}),minWidth:"160px",items:[...P.actions.map($=>({label:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${P.name}-${$}`,children:[s.jsx("input",{type:"checkbox",id:`${P.name}-${$}`,checked:V.has($),onChange:()=>A(P.name,$),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),s.jsx("span",{children:$})]}),closeOnClick:!1})),{label:G?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(G)O(P.name);else{const $=new Map(k);$.set(P.name,new Set(P.actions)),_(uh($))}}}]},P.name):s.jsx("button",{onClick:()=>!h&&O(P.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${G?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:s.jsx("span",{children:P.name})},P.name)})})]}),D.size>0&&(()=>{const P=new Set(E.map(H=>H.name)),G=k.has("__mcp_none__"),z=[...k.keys()].some(H=>P.has(H)),V=G?"none":z?"partial":"all",$=H=>{const q=new Map(k);for(const X of q.keys())(X==="__mcp_none__"||P.has(X))&&q.delete(X);if(H==="none"&&q.set("__mcp_none__",new Set),H==="partial")for(const X of P)q.set(X,new Set);_(uh(q))};return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["MCP Tools ",s.jsx("span",{className:"text-text-muted font-normal",children:"— from connected MCP servers"})]}),s.jsxs("div",{className:"bg-bg-tertiary border border-border rounded overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-4 px-3 py-1.5",children:["all","none","partial"].map(H=>s.jsxs("label",{className:`flex items-center gap-1.5 text-xs cursor-pointer ${h?"pointer-events-none opacity-60":""}`,children:[s.jsx("input",{type:"radio",name:"mcp-mode",checked:V===H,onChange:()=>$(H),disabled:h,className:"w-3 h-3 accent-accent-primary"}),s.jsxs("span",{className:V===H?"text-text-primary font-medium":"text-text-muted",children:[H.charAt(0).toUpperCase()+H.slice(1),H==="partial"&&P.size>0&&s.jsxs("span",{className:"ml-1 text-text-muted font-normal",children:["(",[...k.keys()].filter(q=>P.has(q)).length,"/",P.size,")"]})]})]},H))}),V==="partial"&&(()=>{const[H,q]=j.useState(""),[X,Y]=j.useState(0),F=j.useRef(null),I=B=>{var Q;const Z=(Q=F.current)==null?void 0:Q.querySelector(`[data-idx="${B}"]`);Z==null||Z.scrollIntoView({block:"nearest"})};j.useEffect(()=>{I(X)},[X]);const R=H?E.filter(B=>B.name.toLowerCase().includes(H.toLowerCase())):E,W=B=>{B.key==="ArrowDown"?(B.preventDefault(),Y(Z=>Math.min(Z+1,R.length-1))):B.key==="ArrowUp"?(B.preventDefault(),Y(Z=>Math.max(Z-1,0))):B.key==="Enter"&&R[X]&&(B.preventDefault(),O(R[X].name))};return s.jsxs("div",{children:[s.jsx("div",{className:"px-3 py-2 border-b border-border",children:s.jsx("input",{type:"text",value:H,onChange:B=>{q(B.target.value),Y(0)},onKeyDown:W,placeholder:"Search MCP tools...",className:"w-full px-2 py-1 text-xs bg-bg-primary border border-border rounded font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),s.jsx(dt,{className:"max-h-60",children:s.jsxs("div",{ref:F,children:[R.map((B,Z)=>{const Q=k.has(B.name),J=Z===X;return s.jsxs("div",{"data-idx":Z,className:`flex items-center justify-between px-3 py-1.5 transition-colors ${J?"bg-bg-primary":"hover:bg-bg-primary/30"}`,onMouseEnter:()=>Y(Z),children:[s.jsx("span",{className:`text-xs font-mono ${Q?"text-text-primary":"text-text-muted"}`,children:B.name}),s.jsx(ds,{enabled:Q,onClick:()=>O(B.name),label:B.name})]},B.name)}),R.length===0&&s.jsx("div",{className:"px-3 py-2 text-xs text-text-muted",children:"No MCP tools match your search."})]})})]})})()]})]})})()]}),s.jsxs("div",{className:"flex-1 min-h-[150px] pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:u,onChange:P=>!h&&b(P.target.value),readOnly:h,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"opacity-60":""}`})]})]})}function eG(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function tG({isOpen:e,onClose:t,initialEditId:n}){const r=ut(ge=>ge.defaults),a=ut(ge=>ge.userItems),l=ut(ge=>ge.projectItems),c=ut(ge=>ge.loading),u=ut(ge=>ge.fetchAgents),d=ut(ge=>ge.fetchAgent),h=ut(ge=>ge.fetchDefaultContent),p=ut(ge=>ge.createAgent),m=ut(ge=>ge.updateAgent),g=ut(ge=>ge.deleteAgent),[x,w]=j.useState("list"),[C,_]=j.useState(null),[S,v]=j.useState(!1),[b,k]=j.useState(""),[N,E]=j.useState(""),[D,A]=j.useState(""),[O,P]=j.useState(!0),[G,z]=j.useState([]),[V,$]=j.useState("#6b7280"),[H,q]=j.useState(void 0),[X,Y]=j.useState(""),[F,I]=j.useState("user"),[R,W]=j.useState(""),[B,Z]=j.useState(!1),[Q,J]=j.useState(!1),[U,M]=j.useState(null),[te,se]=j.useState([]),[re,le]=j.useState(new Set),{requestDelete:ye,clearConfirm:_e,isConfirming:Oe}=fu(),Be=ge=>{k(ge.metadata.name),E(ge.metadata.id),A(ge.metadata.description),P(ge.metadata.subagent),z(ge.metadata.allowedTools),$(ge.metadata.color??"#6b7280"),Y(ge.prompt),W(""),J(!0),xe(`/api/agents/${ge.metadata.id}/model`).then(Ve=>Ve.json()).then(Ve=>{Ve.providerId&&Ve.model?q(`${Ve.providerId}/${Ve.model}`):q(void 0)}).catch(()=>q(void 0)).finally(()=>J(!1))},ke=(ge,Ve,at)=>{k(ge.metadata.name+" (copy)"),E(`${Ve}-copy-${Date.now()}`),A(ge.metadata.description),P(ge.metadata.subagent),z(ge.metadata.allowedTools),$(ge.metadata.color??"#6b7280"),Y(ge.prompt),W(""),_(null),v(!1),w("edit")},Ge=(ge,Ve)=>{Be(ge),_(Ve),v(!0),w("edit")};j.useEffect(()=>{e&&(u(),xe("/api/tools").then(ge=>ge.json()).then(ge=>{const Ve=ge.tools||[];le(new Set(Ve.filter(at=>at.alwaysAllowed).map(at=>at.name))),se(Ve.filter(at=>!at.alwaysAllowed))}).catch(()=>{se([]),le(new Set)}),n?r.some(Ve=>Ve.id===n)?h(n).then(Ve=>{Ve&&ke(Ve,n)}):d(n).then(Ve=>{Ve&&(Be(Ve),_(n),v(!1),w("edit"))}):(w("list"),_(null),v(!1)))},[e,u,d,h,n]);const Je=async ge=>{if(r.some(at=>at.id===ge)){const at=await h(ge);if(!at)return;Ge(at,ge)}else{const at=await d(ge);if(!at)return;Ge(at,ge)}},ae=async ge=>{let Ve=await h(ge);Ve||(Ve=await d(ge)),Ve&&ke(Ve,ge)},ue=()=>{_(null),k(""),E(""),A(""),P(!0),z(["read_file"]),$("#6b7280"),Y(""),I("user"),W(""),v(!1),w("edit")},Me=async ge=>{const Ve=await d(ge);Ve&&(Be(Ve),_(ge),v(!1),w("edit"))},fe=ge=>{M(ge)},Fe=async ge=>{await g(ge)},He=async()=>{const ge=C??N;if(!ge||!b||!X){W("Name and prompt are required.");return}Z(!0),W("");const Ve={metadata:{id:ge,name:b,description:D,subagent:O,allowedTools:G.filter(Vt=>!re.has(Vt)),color:V},prompt:X},at=C?await m(C,Ve):await p(Ve,F);if(!at.success){Z(!1),W(at.error??"Failed to save agent.");return}await WT(C??N,H),await u();const ht=C??N,Ht=Re.getState().currentSession;if((Ht==null?void 0:Ht.mode)===ht&&H){const{providerId:Vt,model:At}=Jb(H);Re.getState().setSessionProvider(Vt,At)}Z(!1),n?t():w("list")},ie=()=>{n?t():(w("list"),v(!1))},Se=ge=>{k(ge),C||E(eG(ge))},Le=ut(ge=>ge.modelOverrides),he=r.filter(ge=>ge.subagent),me=r.filter(ge=>!ge.subagent),We=a.filter(ge=>ge.subagent),Ue=a.filter(ge=>!ge.subagent),Qe=l.filter(ge=>ge.subagent),it=l.filter(ge=>!ge.subagent);return x==="edit"?s.jsxs(s.Fragment,{children:[s.jsxs(St,{isOpen:e,onClose:ie,title:S?`${b}`:C?"Edit Agent":"New Agent",size:"xl",footer:S?s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{onClick:()=>{k(b+" (copy)"),E(`${C}-copy-${Date.now()}`),_(null),v(!1)},className:"px-3 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors",children:"Duplicate & Customize"})}):s.jsx(Vj,{onCancel:ie,onSave:He,saving:B,saveDisabled:!b||!X||Q}),children:[!C&&!S&&s.jsx(jf,{value:F,onChange:I}),s.jsx(ZV,{formName:b,formId:N,formDescription:D,formSubagent:O,formTools:G,formColor:V,formModel:H,formPrompt:X,formError:R,isReadOnly:S,availableTools:te,providers:en.getState().providers,onNameChange:Se,onIdChange:E,onDescriptionChange:A,onSubagentChange:ge=>{P(ge),ge&&z(Ve=>Ve.filter(at=>{var ht;return!((ht=te.find(Ht=>Ht.name===at))!=null&&ht.topLevelOnly)}))},onToolsChange:z,onColorChange:$,onModelChange:q,onPromptChange:Y})]}),s.jsx(vk,{agentId:U,onClose:()=>M(null),onSaved:()=>u()})]}):s.jsxs(s.Fragment,{children:[s.jsx(St,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:s.jsx(Gj,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:ue,loading:c,hasItems:r.length>0||a.length>0||l.length>0,children:s.jsxs("div",{className:"space-y-4",children:[r.length>0&&s.jsx(bk,{title:"Built-in",agents:me,subagents:he,isBuiltIn:!0,alwaysAllowedNames:re,modelOverrides:Le,onView:Je,onEdit:fe,onDuplicate:ae}),(Ue.length>0||We.length>0||it.length>0||Qe.length>0)&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Custom"}),s.jsx("div",{className:"ml-3 space-y-3",children:[{title:"Global",agents:Ue,subagents:We},{title:"Project",agents:it,subagents:Qe}].map(ge=>(ge.agents.length>0||ge.subagents.length>0)&&s.jsx(bk,{title:ge.title,agents:ge.agents,subagents:ge.subagents,isBuiltIn:!1,alwaysAllowedNames:re,modelOverrides:Le,isConfirmingDelete:Ve=>Oe(Ve,"delete"),onView:Je,onDuplicate:ae,onEdit:Me,onDelete:Ve=>{Oe(Ve,"delete")?(Fe(Ve),_e()):ye(Ve)},onCancelDelete:_e},ge.title))})]})]})})}),s.jsx(vk,{agentId:U,onClose:()=>M(null),onSaved:()=>u()})]})}function Jb(e){const t=e.indexOf("/");return t>0?{providerId:e.substring(0,t),model:e.substring(t+1)}:{providerId:e,model:e}}async function WT(e,t){if(t){const{providerId:n,model:r}=Jb(t);await xe(`/api/agents/${e}/model`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})})}else await xe(`/api/agents/${e}/model`,{method:"DELETE"})}function vk({agentId:e,onClose:t,onSaved:n}){const[r,a]=j.useState(void 0),[l,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(null),m=ut(v=>v.defaults),g=ut(v=>v.userItems),x=ut(v=>v.projectItems),w=[...m,...g,...x],C=e?w.find(v=>v.id===e):void 0,_=en(v=>v.providers);j.useEffect(()=>{e&&(c(!0),xe(`/api/agents/${e}/model`).then(v=>v.json()).then(v=>{a(v.providerId&&v.model?`${v.providerId}/${v.model}`:void 0)}).catch(()=>a(void 0)).finally(()=>c(!1)))},[e]);const S=async()=>{if(e){d(!0),p(null);try{await WT(e,r);const v=Re.getState().currentSession;if((v==null?void 0:v.mode)===e&&r){const{providerId:b,model:k}=Jb(r);Re.getState().setSessionProvider(b,k)}n(),t()}catch{p("Failed to save. Please try again.")}d(!1)}};return s.jsx(St,{isOpen:!!e,onClose:t,title:`Model — ${(C==null?void 0:C.name)??e??""}`,size:"md",children:s.jsxs("div",{className:"space-y-4 p-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Choose which model to use when this agent is active. This overrides the session/global model."}),l?s.jsx("div",{className:"text-sm text-text-muted py-2",children:"Loading..."}):s.jsx($b,{providers:_,value:r,onChange:a,defaultLabel:"Default (global model)"}),h&&s.jsx("p",{className:"text-xs text-red-500",children:h}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{onClick:t,className:"px-4 py-1.5 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),s.jsx("button",{onClick:S,disabled:u,className:"px-4 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-50 transition-colors",children:u?"Saving...":"Save"})]})]})})}function nG(){const e=Re(b=>{var k;return(k=b.currentSession)==null?void 0:k.mode}),t=Re(b=>b.switchMode),n=ut(b=>b.defaults),r=ut(b=>b.userItems),a=ut(b=>b.projectItems),l=ut(b=>b.fetchAgents),c=[...n,...r,...a],[u,d]=j.useState(!1),[h,p]=j.useState(!1),[m,g]=j.useState(null),x=j.useRef(null);j.useEffect(()=>{l()},[l]),Xf(x,()=>d(!1));const w=hu();if(!e)return null;const C=c.filter(b=>!b.subagent),_=C.find(b=>b.id===e),S=(_==null?void 0:_.name)??e,v=Ja(c,e);return s.jsxs("div",{className:"relative",ref:x,children:[s.jsxs("button",{type:"button",onClick:()=>d(!u),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[s.jsx("span",{className:"text-sm font-medium",style:{color:v},children:S}),s.jsx(pn,{className:`w-3 h-3 text-text-muted transition-transform ${u?"rotate-180":""}`})]}),u&&C.length>0&&s.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[C.map((b,k)=>{const N=b.id===e,E=Ja(c,b.id),D=w.agentSwitching[k],A=D?Ah(D):null;return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${N?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{N||t(b.id),d(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",style:{color:E},children:b.name}),N&&s.jsx(Rs,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),A&&s.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:A})]},b.id)}),s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{d(!1),p(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),s.jsx(tG,{isOpen:h,onClose:()=>{p(!1),g(null)},initialEditId:m})]})}function rG(){const e=Re(r=>r.currentSession),t=Re(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[s.jsx("button",{type:"button",onClick:()=>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"}),s.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 _k({value:e,onChange:t}){return s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",s.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),s.jsx("input",{type:"text",value:e??"",onChange:n=>t(n.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]})}const sG=[8080,11434,8e3,1234];function vy(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function qT(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 iG({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:l,onTestParams:c,onShowRaw:u}){var d,h,p,m,g,x,w,C,_,S,v,b,k,N,E,D,A,O,P,G,z,V,$,H,q,X,Y,F,I,R,W,B,Z,Q,J,U,M,te,se,re,le,ye,_e,Oe,Be;return s.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>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"&&s.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&s.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),s.jsxs("div",{className:"flex gap-3 items-end",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),s.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:ke=>a(e.id,{contextWindow:parseInt(ke.target.value)||e.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[s.jsx("input",{type:"checkbox",checked:((h=t[e.id])==null?void 0:h.supportsVision)??!1,onChange:ke=>a(e.id,{supportsVision:ke.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>c(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"}),((g=r[e.id+"-thinking"])==null?void 0:g.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((x=r[e.id+"-thinking"])==null?void 0:x.error)&&s.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)&&s.jsx("button",{onClick:()=>u(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>c(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)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.error)&&s.jsx("span",{className:"text-xs text-red-500",title:(k=r[e.id+"-non-thinking"])==null?void 0:k.error,children:"Fail"}),((N=r[e.id+"-non-thinking"])==null?void 0:N.result)&&s.jsx("button",{onClick:()=>u(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),s.jsxs("details",{className:"group",children:[s.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[s.jsx(pn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((E=t[e.id])==null?void 0:E.thinkingEnabled)??!1,onChange:ke=>a(e.id,{thinkingEnabled:ke.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((D=t[e.id])==null?void 0:D.thinkingEnabled)&&s.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(A=e.reasoningEfforts)!=null&&A.length?s.jsx("select",{"aria-label":"Reasoning effort",value:((O=t[e.id])==null?void 0:O.thinkingLevel)??vy(e.reasoningEfforts),onChange:ke=>a(e.id,{thinkingLevel:ke.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(ke=>s.jsx("option",{value:ke,children:ke},ke))}):s.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((P=t[e.id])==null?void 0:P.thinkingLevel)??"",onChange:ke=>a(e.id,{thinkingLevel:ke.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsx(_k,{value:(G=t[e.id])==null?void 0:G.thinkingQueryParams,onChange:ke=>a(e.id,{thinkingQueryParams:ke})})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((z=t[e.id])==null?void 0:z.nonThinkingEnabled)??!1,onChange:ke=>a(e.id,{nonThinkingEnabled:ke.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((V=t[e.id])==null?void 0:V.nonThinkingEnabled)&&s.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:s.jsx(_k,{value:($=t[e.id])==null?void 0:$.nonThinkingQueryParams,onChange:ke=>a(e.id,{nonThinkingQueryParams:ke})})})]}),s.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),s.jsx("input",{type:"number",step:"0.1",value:((H=t[e.id])==null?void 0:H.temperature)??"",onChange:ke=>a(e.id,{temperature:ke.target.value?parseFloat(ke.target.value):void 0}),placeholder:((X=(q=t[e.id])==null?void 0:q.defaultTemperature)==null?void 0:X.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((Y=t[e.id])==null?void 0:Y.defaultTemperature)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(F=t[e.id])==null?void 0:F.defaultTemperature]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),s.jsx("input",{type:"number",step:"0.05",value:((I=t[e.id])==null?void 0:I.topP)??"",onChange:ke=>a(e.id,{topP:ke.target.value?parseFloat(ke.target.value):void 0}),placeholder:((W=(R=t[e.id])==null?void 0:R.defaultTopP)==null?void 0:W.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((B=t[e.id])==null?void 0:B.defaultTopP)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Z=t[e.id])==null?void 0:Z.defaultTopP]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),s.jsx("input",{type:"number",value:((Q=t[e.id])==null?void 0:Q.topK)??"",onChange:ke=>a(e.id,{topK:ke.target.value?parseInt(ke.target.value):void 0}),placeholder:((U=(J=t[e.id])==null?void 0:J.defaultTopK)==null?void 0:U.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((M=t[e.id])==null?void 0:M.defaultTopK)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(te=t[e.id])==null?void 0:te.defaultTopK]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),s.jsx("input",{type:"number",value:((se=t[e.id])==null?void 0:se.maxTokens)??"",onChange:ke=>a(e.id,{maxTokens:ke.target.value?parseInt(ke.target.value):void 0}),placeholder:((le=(re=t[e.id])==null?void 0:re.defaultMaxTokens)==null?void 0:le.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ye=t[e.id])==null?void 0:ye.defaultMaxTokens)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(_e=t[e.id])==null?void 0:_e.defaultMaxTokens]})]})]})]}),s.jsx("div",{className:"pt-3 border-t border-border",children:s.jsx(aG,{value:(Oe=t[e.id])==null?void 0:Oe.compactionThreshold,maxTokens:((Be=t[e.id])==null?void 0:Be.contextWindow)??e.contextWindow,onChange:ke=>a(e.id,{compactionThreshold:ke})})})]})]})}function aG({value:e,maxTokens:t,onChange:n}){const l=Math.min(95,Math.floor((t-5e3)/t*100)),c=Math.min(l,Math.ceil(15e3/t*100)),u=Math.min(e??.85,l/100),[d,h]=j.useState(Math.round(u*100));j.useEffect(()=>{const m=Math.min(e??.85,l/100);h(Math.round(m*100))},[e,l]);const p=Math.floor(t*(d/100));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Auto-compaction threshold"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono text-xs text-text-primary",children:[d,"% · ",ml(p)]}),s.jsx("button",{type:"button",onClick:()=>{n(void 0),h(Math.round(.85*100))},disabled:e===void 0,className:"text-xs text-accent-primary hover:underline disabled:text-text-muted disabled:no-underline",children:"Default"})]})]}),s.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:c,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"}),s.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",ml(15e3)," tokens · maximum ",l,"% · default 85%"]})]})}function KT({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:l}){const[c,u]=j.useState(r),[d,h]=j.useState(""),[p,m]=j.useState(""),[g,x]=j.useState("unknown"),[w,C]=j.useState(""),[_,S]=j.useState(!1),[v,b]=j.useState(),[k,N]=j.useState(),[E,D]=j.useState(!1),[A,O]=j.useState(null),[P,G]=j.useState([]),[z,V]=j.useState(null),[$,H]=j.useState(!1),[q,X]=j.useState(""),[Y,F]=j.useState(!0),[I,R]=j.useState({}),[W,B]=j.useState({loading:!1,progress:{}}),[Z,Q]=j.useState({}),[J,U]=j.useState(null),[M,te]=j.useState(new Set),[se,re]=j.useState(""),[le,ye]=j.useState(null),[_e,Oe]=j.useState("disconnected"),[Be,ke]=j.useState(!1),[Ge,Je]=j.useState(null),[ae,ue]=j.useState([]),[Me,fe]=j.useState(!1),[Fe,He]=j.useState(!1),[ie,Se]=j.useState(""),[Le,he]=j.useState(null),me=j.useRef(null),We=j.useRef(!1),Ue=j.useRef(null),Qe=j.useRef(null);j.useEffect(()=>{c===1&&e&&requestAnimationFrame(()=>{var we;zt()&&((we=Ue.current)==null||we.focus())})},[c,e]),j.useEffect(()=>()=>{me.current!==null&&window.clearTimeout(me.current)},[]),j.useEffect(()=>{e&&xe("/api/provider-presets").then(async we=>we.ok?await we.json():{presets:[]}).then(we=>ue(we.presets)).catch(()=>ue([]))},[e]);function it(we,et){R(Ye=>({...Ye,[we]:{...Ye[we],...et}}))}function ge(we){te(et=>new Set(et).add(we.id)),R(et=>({...et,[we.id]:{contextWindow:we.contextWindow,...et[we.id]}}))}function Ve(we){if(!we.trim())return P;const et=we.toLowerCase().split(/\s+/).filter(Boolean);return P.filter(Ye=>et.every(oe=>Ye.id.toLowerCase().includes(oe)))}function at(){const we=ie.trim();if(!we){he("Enter a model name");return}const et=Ze=>Ze.toLowerCase().replace(/[-_\s:.]+/g,""),Ye=et(we),oe=P.find(Ze=>et(Ze.id)===Ye);if(oe){ge(oe),he(`"${oe.id}" is already in the list`),Se(""),!v&&W.progress[oe.id]!=="probing"&&hn(oe.id);return}const Pe={id:we,contextWindow:2e5};G(Ze=>[...Ze,Pe]),te(Ze=>new Set(Ze).add(Pe.id)),R(Ze=>({...Ze,[Pe.id]:{contextWindow:Pe.contextWindow,thinkingEnabled:!0}})),V(Pe.id),Se(""),he(null),O(null)}j.useEffect(()=>{var we,et;if(e)if(u(r),h((a==null?void 0:a.name)??""),m((a==null?void 0:a.url)??""),x((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),b(a==null?void 0:a.authAdapter),N(a==null?void 0:a.transportAdapter),O(null),X((a==null?void 0:a.thinkingField)??""),F((a==null?void 0:a.sendReasoningInMessages)??!0),Q({}),U(null),ye(null),Oe("disconnected"),Je(null),fe(!1),He(!1),Se(""),he(null),(we=a==null?void 0:a.models)!=null&&we.length){const Ye={},oe=new Set;for(const Pe of a.models)Ye[Pe.id]={contextWindow:Pe.contextWindow,supportsVision:Pe.supportsVision,thinkingEnabled:Pe.thinkingEnabled,thinkingLevel:Pe.thinkingLevel??vy(Pe.reasoningEfforts),nonThinkingEnabled:Pe.nonThinkingEnabled,thinkingQueryParams:Pe.thinkingQueryParams,nonThinkingQueryParams:Pe.nonThinkingQueryParams,defaultTemperature:Pe.defaultTemperature,defaultTopP:Pe.defaultTopP,defaultTopK:Pe.defaultTopK,defaultMaxTokens:Pe.defaultMaxTokens,temperature:Pe.temperature,topP:Pe.topP,topK:Pe.topK,maxTokens:Pe.maxTokens,compactionThreshold:Pe.compactionThreshold},Pe.selected&&oe.add(Pe.id);if(oe.size===0)for(const Pe of a.models)oe.add(Pe.id);te(oe),R(Ye),G(a.models),V(l??((et=a.models[0])==null?void 0:et.id)??null)}else G([]),R({}),V(null),te(new Set)},[e,r,a==null?void 0:a.id,l]),j.useEffect(()=>{const we=!!v;c===2&&p&&P.length===0&&!E&&!A&&(!we||_e==="connected")&&Sn(p)},[c,_e]),j.useEffect(()=>{!e||!v||!(a!=null&&a.id)||Ht(a.id)},[e,k,a==null?void 0:a.id]),j.useEffect(()=>{if(!Ge)return;const we=(a==null?void 0:a.id)??le;if(!we)return;let et=!1;const Ye=async()=>{const Pe=await Ht(we);et||Pe!=="connected"||(Je(null),fe(!1),He(!1),await Sn(p))};Ye();const oe=window.setInterval(()=>void Ye(),2e3);return()=>{et=!0,window.clearInterval(oe)}},[Ge,le,a==null?void 0:a.id]);async function ht(){if(a!=null&&a.id)return a.id;if(le)return le;const we=await xe("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:p,backend:g,authAdapter:v,transportAdapter:k,isLocal:!1,models:[]})});if(!we.ok)throw new Error("Unable to create provider");const et=await we.json();return ye(et.provider.id),et.provider.id}async function Ht(we){const et=await xe(`/api/provider-auth/${we}/status`);if(!et.ok)return"error";const Ye=await et.json(),oe=Ye.state==="connected"?"connected":Ye.state==="pending"?"pending":Ye.state==="error"?"error":"disconnected";return Oe(oe),oe}async function Vt(){ke(!0),Oe("pending");try{const we=await ht(),et=await xe(`/api/provider-auth/${we}/login`,{method:"POST"});if(!et.ok)throw new Error("Unable to start provider sign-in");const Ye=await et.json();Je(Ye)}catch{Oe("error")}finally{ke(!1)}}async function At(){var we;Ge!=null&&Ge.userCode&&(await((we=navigator.clipboard)==null?void 0:we.writeText(Ge.userCode)),me.current!==null&&window.clearTimeout(me.current),He(!1),requestAnimationFrame(()=>He(!0)),me.current=window.setTimeout(()=>{He(!1),me.current=null},1500))}function Bn(){Ge&&(window.open(Ge.directUrl??Ge.verificationUrl,"_blank","noopener,noreferrer"),fe(!0))}async function Sn(we){var et,Ye;D(!0),O(null),G([]);try{const oe=new URLSearchParams({url:we});w&&oe.set("apiKey",w),g&&oe.set("backend",g);const Pe=k?await xe(`/api/providers/${await ht()}/models`):await xe(`/api/providers/models?${oe.toString()}`);if(Pe.ok){const Ze=await Pe.json();if((et=Ze.models)!=null&&et.length){G(Ze.models),V(((Ye=Ze.models[0])==null?void 0:Ye.id)??null);const Dt={};for(const rn of Ze.models)Dt[rn.id]={contextWindow:rn.contextWindow,thinkingEnabled:!0,thinkingLevel:vy(rn.reasoningEfforts),defaultTemperature:rn.defaultTemperature,defaultTopP:rn.defaultTopP,defaultTopK:rn.defaultTopK,defaultMaxTokens:rn.defaultMaxTokens};R(Dt),Ze.models.length===1&&(te(new Set([Ze.models[0].id])),V(Ze.models[0].id),hn(Ze.models[0].id))}}else{const Ze=await Pe.json();O(Ze.error??`Failed to fetch models from ${we}`)}}catch(oe){O(`Failed to fetch models from ${we}: ${oe instanceof Error?oe.message:"Unknown error"}`)}D(!1)}async function hn(we){B(et=>({loading:!0,progress:{...et.progress,[we]:"probing"}}));try{const et=await xe("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,apiKey:w||void 0,backend:g||"unknown",models:[{id:we}]})});if(!et.ok){const oe=await et.json();throw new Error(oe.error??"Auto-config failed")}const Ye=await et.json();for(const oe of Ye.models){const Pe={};oe.contextSource!=="default"&&(Pe.contextWindow=oe.contextWindow,Pe.supportsVision=oe.supportsVision),oe.thinkingConfig&&(Pe.thinkingEnabled=!0,Pe.thinkingQueryParams=JSON.stringify(oe.thinkingConfig)),oe.nonThinkingConfig&&(Pe.nonThinkingEnabled=!0,Pe.nonThinkingQueryParams=JSON.stringify(oe.nonThinkingConfig)),it(oe.id,Pe),B(Ze=>({...Ze,progress:{...Ze.progress,[oe.id]:"done"}}))}}catch(et){console.error("Auto-config error:",et),B(Ye=>({...Ye,progress:{...Ye.progress,[we]:"error"}}))}finally{B(et=>({...et,loading:!1}))}}async function Dn(we,et){const Ye=we+"-"+et;Q(oe=>({...oe,[Ye]:{loading:!0}}));try{const oe=I[we],Pe=await xe("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,providerId:(a==null?void 0:a.id)??le??void 0,transportAdapter:k,model:we,apiKey:w||void 0,backend:g||"unknown",thinkingField:q||void 0,mode:et,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}})}),Ze=await Pe.json();Pe.ok?Q(Dt=>({...Dt,[Ye]:{loading:!1,result:JSON.stringify(Ze,null,2),message:Ze.message}})):Q(Dt=>({...Dt,[Ye]:{loading:!1,error:Ze.error??"Test failed"}}))}catch(oe){Q(Pe=>({...Pe,[Ye]:{loading:!1,error:oe instanceof Error?oe.message:"Request failed"}}))}}function wn(){G([]),R({}),B({loading:!1,progress:{}}),Q({}),U(null),te(new Set),re(""),Se(""),he(null)}function un(){le&&!We.current&&xe(`/api/providers/${le}`,{method:"DELETE"}).catch(we=>{console.warn("Failed to clean up draft provider",we)}),t()}function nr(){const we=d||"Provider",et=(a==null?void 0:a.id)??le??`temp-${Date.now()}`;n({id:et,name:we,url:p,backend:g||"unknown",apiKey:w||void 0,isLocal:_,thinkingField:q||void 0,sendReasoningInMessages:Y,authAdapter:v,transportAdapter:k,models:P.map(Ye=>{var oe,Pe,Ze,Dt,rn,Ne,Te,$e,Xe,tt,mt,_t,Rn,gn,Cn,to;return{id:Ye.id,name:Ye.name,apiModelId:Ye.apiModelId,requestBody:Ye.requestBody,reasoningEfforts:Ye.reasoningEfforts,contextWindow:((oe=I[Ye.id])==null?void 0:oe.contextWindow)??Ye.contextWindow,selected:M.has(Ye.id)||void 0,supportsVision:(Pe=I[Ye.id])==null?void 0:Pe.supportsVision,thinkingEnabled:(Ze=I[Ye.id])==null?void 0:Ze.thinkingEnabled,thinkingLevel:(Dt=I[Ye.id])==null?void 0:Dt.thinkingLevel,nonThinkingEnabled:(rn=I[Ye.id])==null?void 0:rn.nonThinkingEnabled,thinkingQueryParams:(Ne=I[Ye.id])==null?void 0:Ne.thinkingQueryParams,nonThinkingQueryParams:(Te=I[Ye.id])==null?void 0:Te.nonThinkingQueryParams,temperature:($e=I[Ye.id])==null?void 0:$e.temperature,topP:(Xe=I[Ye.id])==null?void 0:Xe.topP,topK:(tt=I[Ye.id])==null?void 0:tt.topK,maxTokens:(mt=I[Ye.id])==null?void 0:mt.maxTokens,defaultMaxTokens:(_t=I[Ye.id])==null?void 0:_t.defaultMaxTokens,defaultTemperature:(Rn=I[Ye.id])==null?void 0:Rn.defaultTemperature,defaultTopP:(gn=I[Ye.id])==null?void 0:gn.defaultTopP,defaultTopK:(Cn=I[Ye.id])==null?void 0:Cn.defaultTopK,compactionThreshold:(to=I[Ye.id])==null?void 0:to.compactionThreshold}})}),We.current=!0,t()}return e?s.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[s.jsxs(dt,{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),s.jsx("button",{onClick:un,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(we=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${we<c?"bg-accent-success":we===c?"bg-accent-primary":"bg-border"}`},we))}),c===1&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),s.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[ae.map(we=>s.jsx("button",{type:"button",onClick:()=>{h(we.defaults.name??we.name),m(we.defaults.url),x(we.defaults.backend),S(!1),C(""),b(we.authAdapter),N(we.transportAdapter),O(null),wn()},className:`p-2 rounded border text-center text-sm transition-colors ${k&&k===we.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:we.name},we.id)),s.jsx("button",{type:"button",onClick:()=>{x("unknown"),S(!1),b(void 0),N(void 0),O(null),wn()},className:`p-2 rounded border text-center text-sm transition-colors ${g==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),sG.map(we=>{const et={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},Ye={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return s.jsx("button",{type:"button",onClick:()=>{h(oe=>oe||(Ye[we]??"")),m(oe=>oe||`http://localhost:${we}`),x(et[we]??""),S(!0),b(void 0),N(void 0),O(null),wn()},className:`p-2 rounded border text-center text-sm transition-colors ${g===et[we]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Ye[we]??`localhost:${we}`},we)})]})]}),!v&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),s.jsx("input",{ref:Ue,type:"text",value:p,"data-testid":"provider-modal-url",onChange:we=>{m(we.target.value),O(null),G([]),R({})},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),s.jsx("input",{type:"text",autoComplete:"off",value:d,onChange:we=>h(we.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&&s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx("input",{type:"text",autoComplete:"off",value:w,onChange:we=>C(we.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&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:_,onChange:we=>S(we.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),c===2&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Test & Configure Models"}),s.jsx("button",{type:"button",onClick:()=>H(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:s.jsx(zj,{className:"w-4 h-4"})})]}),!!v&&s.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),_e==="connected"?s.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):s.jsx("button",{type:"button",onClick:()=>void Vt(),disabled:Be||_e==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:Be||_e==="pending"?"Connecting...":_e==="error"?"Retry":"Connect"})]}),Ge&&s.jsx("div",{className:"mt-4 border-t border-border pt-4",children:Ge.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),s.jsx("button",{type:"button",onClick:()=>void At(),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:Ge.userCode??"Continue"}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>void At(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:Fe?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:Bn,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:Me?"Reopen authorization":"Open authorization"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted mb-3",children:Ge.instructions}),s.jsx("button",{type:"button",onClick:Bn,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:Me?"Reopen authorization":"Open authorization"})]})})]}),E&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),A&&s.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[s.jsx("p",{children:A}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>Sn(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),s.jsx("button",{onClick:()=>{wn(),u(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"}),!v&&s.jsx("button",{onClick:()=>{var we;return(we=Qe.current)==null?void 0:we.focus()},className:"text-xs text-accent-primary hover:underline",children:"Add model manually"})]})]}),g&&(!v||_e==="connected")&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Add model manually"}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:A?"Can't discover models automatically? Enter the model name to use:":"Enter a model name manually if it does not appear in the list above:"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:Qe,type:"text",value:ie,onChange:we=>{Se(we.target.value),Le&&he(null)},onKeyDown:we=>{we.key==="Enter"&&(we.preventDefault(),at())},placeholder:"model-name","data-testid":"provider-modal-manual-model-input",className:"flex-1 px-3 py-1.5 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),s.jsx("button",{type:"button",onClick:at,"data-testid":"provider-modal-manual-model-add",className:"px-3 py-1.5 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Add"})]}),Le&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:Le})]}),P.length>0&&g&&(!v||_e==="connected")&&s.jsxs(s.Fragment,{children:[M.size>0&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",M.size,")"]}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),s.jsx("div",{className:"space-y-2",children:P.filter(we=>M.has(we.id)).map(we=>{var et;return s.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{onClick:()=>V(z===we.id?null:we.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:we.name??we.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((et=I[we.id])==null?void 0:et.contextWindow)??we.contextWindow).toLocaleString()," ctx"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[W.progress[we.id]==="probing"?s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):W.progress[we.id]==="done"?s.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):W.progress[we.id]==="error"?s.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):v?null:s.jsx("button",{onClick:Ye=>{Ye.stopPropagation(),hn(we.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),P.length>1&&s.jsx("button",{onClick:Ye=>{Ye.stopPropagation();const oe=new Set(M);oe.delete(we.id),te(oe),z===we.id&&V(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),s.jsx(pn,{className:`w-4 h-4 text-text-muted transition-transform ${z===we.id?"rotate-180":""}`})]})]}),z===we.id&&s.jsx(iG,{model:we,modelConfigs:I,autoConfigState:W,testResults:Z,onUpdateConfig:it,onRunAutoConfig:hn,onTestParams:Dn,onShowRaw:U})]},we.id)})})]}),P.length>1&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),M.size===0&&s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"This provider has many models available. Select the ones you want to use below."}),s.jsxs("div",{className:"relative mb-2",children:[s.jsx("input",{type:"text",value:se,onChange:we=>re(we.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),se&&s.jsx("button",{onClick:()=>re(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",Ve(se).length," of ",P.length," models"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{const we=new Set(M),et=Ve(se);for(const Ye of et)we.add(Ye.id);if(te(we),R(Ye=>{const oe={...Ye};for(const Pe of et)oe[Pe.id]={contextWindow:Pe.contextWindow,...oe[Pe.id]};return oe}),!v)for(const Ye of et)W.progress[Ye.id]!=="probing"&&W.progress[Ye.id]!=="done"&&hn(Ye.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),s.jsx("button",{onClick:()=>{const we=new Set(M),et=Ve(se);for(const Ye of et)we.delete(Ye.id);te(we)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),s.jsxs(dt,{className:"space-y-1 max-h-48 border border-border rounded-lg bg-bg-primary",children:[Ve(se).map(we=>{var Ye;const et=M.has(we.id);return s.jsxs("div",{role:"checkbox","aria-checked":et,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${et?"bg-accent-primary/5":""}`,onClick:()=>{if(et){const oe=new Set(M);oe.delete(we.id),te(oe)}else ge(we),v||hn(we.id)},onKeyDown:oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),oe.currentTarget.click())},children:[s.jsx("input",{type:"checkbox",checked:et,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),s.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:we.name??we.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Ye=I[we.id])==null?void 0:Ye.contextWindow)??we.contextWindow).toLocaleString()," ctx"]}),W.progress[we.id]==="probing"&&s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),W.progress[we.id]==="done"&&s.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),W.progress[we.id]==="error"&&s.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},we.id)}),Ve(se).length===0&&s.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",se,"”"]})]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[s.jsx("div",{children:c>1&&s.jsx("button",{onClick:()=>{c===2&&wn(),u(c-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:un,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),c===1?s.jsx("button",{onClick:()=>u(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"}):s.jsx("button",{onClick:nr,disabled:W.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:W.loading?"Configuring...":"Save Provider"})]})]})]}),$&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:we=>{we.target===we.currentTarget&&H(!1)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),s.jsx("button",{onClick:()=>H(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'reasoning_effort: "low"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",s.jsx("span",{className:"text-text-muted",children:"(override)"})]}),s.jsx("input",{type:"text",value:q,onChange:we=>X(we.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Field name the backend uses for reasoning/thinking content (e.g. reasoning, reasoning_content, thinking)."})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Y,onChange:we=>F(we.target.checked),className:"rounded border-border bg-bg-primary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"Send reasoning in messages"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:"When disabled, strips reasoning/thinking content from assistant messages sent to this provider"})]})]}),s.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:s.jsx("button",{onClick:()=>H(!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&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:we=>{we.target===we.currentTarget&&U(null)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),s.jsx("button",{onClick:()=>U(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx(dt,{horizontal:!0,children:s.jsx("pre",{className:"px-6 py-4 text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:J})})]})})]}):null}function Sk({activeProvider:e,shortModelName:t,agentOverrideActive:n,agentColor:r,agentName:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-accent-primary flex items-center gap-1",children:[n&&s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 ring-1 ring-border",style:{backgroundColor:r??"#6b7280"},title:`Model set by agent "${a??"unknown"}". Change it in Settings > Agents.`}),e?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"hidden sm:inline",children:[e.name," • "]}),t]}):t]}),s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${e!=null&&e.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:e!=null&&e.isLocal?"local":"api"})]})}function oG(){var Ye;const[,e]=Ln(),t=Re(oe=>oe.currentSession),n=Re(oe=>oe.setSessionProvider),[r,a]=j.useState(!1),[l,c]=j.useState([]),[u,d]=j.useState(null),h=j.useRef(null),[p,m]=j.useState(null),[g,x]=j.useState(!1),[w,C]=j.useState({}),[_,S]=j.useState(null),[v,b]=j.useState(null),[k,N]=j.useState(!1),E=j.useRef(null),[D,A]=j.useState(!1),O=j.useRef(new Set),P=en(oe=>oe.providers),G=en(oe=>oe.activeProviderId),z=en(oe=>oe.defaultModelSelection),V=en(oe=>oe.activating),$=en(oe=>oe.activateProvider),H=en(oe=>oe.refreshModel),q=en(oe=>oe.refreshProviderModels),X=en(oe=>oe.setDefaultModel),Y=en(oe=>oe.fetchConfig),F=hu();eu(F.modelSelector,()=>a(oe=>!oe));const I=(t==null?void 0:t.providerId)??null,R=(t==null?void 0:t.providerModel)??null,W=(z==null?void 0:z.split("/")[0])??null,B=(z==null?void 0:z.split("/").slice(1).join("/"))??null,Z=ut(oe=>oe.defaults),Q=ut(oe=>oe.userItems),J=ut(oe=>oe.modelOverrides),U=t==null?void 0:t.mode,M=U?Z.find(oe=>oe.id===U)??Q.find(oe=>oe.id===U):void 0,te=U?J[U]??void 0:void 0,se=te?te.split("/")[0]??null:null,re=te?te.split("/").slice(1).join("/")??null:null,le=U?Ja([...Z,...Q],U):void 0,ye=!!te,_e=se??I??W,Oe=re??R??B,Be=Oe?((Ye=Oe.split("/").pop())==null?void 0:Ye.replace(/-/g," "))??Oe:"No model",[ke,Ge]=j.useState(!1);j.useEffect(()=>{function oe(Pe){h.current&&!h.current.contains(Pe.target)&&(a(!1),c([]),O.current=new Set)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[]),j.useEffect(()=>()=>{E.current!==null&&window.clearTimeout(E.current)},[]),j.useEffect(()=>{r||(At(""),Sn(-1))},[r]),j.useEffect(()=>{var oe;r&&zt()&&((oe=nr.current)==null||oe.focus())},[r]),j.useEffect(()=>{if(r){const oe=P.map(Pe=>Pe.id);c(oe),P.filter(Pe=>!!Pe.authAdapter).forEach(Pe=>void Le(Pe.id)),oe.forEach(Pe=>{O.current.has(Pe)||(O.current.add(Pe),fe(Pe))})}},[r,P]),j.useEffect(()=>{if(!v)return;let oe=!1;const Pe=async()=>{const Dt=await Le(v.providerId);oe||Dt==="connected"&&(b(null),N(!1),A(!1),await Y(),O.current.delete(v.providerId),await fe(v.providerId))};Pe();const Ze=window.setInterval(()=>void Pe(),2e3);return()=>{oe=!0,window.clearInterval(Ze)}},[v]);const Je=P.find(oe=>oe.id===_e),ae=(Je==null?void 0:Je.status)==="disconnected",ue=(oe,Pe)=>t?t.providerId===oe&&t.providerModel===Pe:!1,Me=(oe,Pe)=>z?z===`${oe}/${Pe}`:!1,fe=async oe=>{d(oe);try{await q(oe)}catch{}finally{d(null)}},Fe=oe=>{l.includes(oe.id)?c(l.filter(Pe=>Pe!==oe.id)):(c([...l,oe.id]),fe(oe.id))},He=async oe=>{if(oe.id===G){Fe(oe);return}t?(n(oe.id,void 0),a(!1),c([])):await $(oe.id)&&(a(!1),c([]))},ie=oe=>{Fe(oe)},Se=async(oe,Pe)=>{oe.stopPropagation(),O.current.delete(Pe),await fe(Pe)},Le=async oe=>{const Pe=await xe(`/api/provider-auth/${oe}/status`);if(!Pe.ok)return"error";const Ze=await Pe.json();return C(Dt=>({...Dt,[oe]:Ze.state})),Ze.state},he=async(oe,Pe)=>{oe.stopPropagation(),S(Pe),C(Ze=>({...Ze,[Pe]:"pending"})),N(!1),A(!1);try{const Ze=await xe(`/api/provider-auth/${Pe}/login`,{method:"POST"});if(!Ze.ok)throw new Error("Unable to start provider sign-in");const Dt=await Ze.json();b({providerId:Pe,...Dt})}catch{C(Ze=>({...Ze,[Pe]:"error"}))}finally{S(null)}},me=async()=>{var oe;v!=null&&v.userCode&&(await((oe=navigator.clipboard)==null?void 0:oe.writeText(v.userCode)),E.current!==null&&window.clearTimeout(E.current),N(!1),requestAnimationFrame(()=>N(!0)),E.current=window.setTimeout(()=>{N(!1),E.current=null},1500))},We=()=>{v&&(window.open(v.directUrl??v.verificationUrl,"_blank","noopener,noreferrer"),A(!0))},Ue=()=>{b(null),N(!1),A(!1)},Qe=async(oe,Pe)=>{oe.stopPropagation(),S(Pe);try{if(!(await xe(`/api/provider-auth/${Pe}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");C(Dt=>({...Dt,[Pe]:"disconnected"})),await Y()}finally{S(null)}},it=(oe,Pe)=>{m({providerId:oe,model:Pe}),x(!0)},ge=p?P.find(oe=>oe.id===p.providerId):void 0,Ve=()=>{m(null),x(!1)},at=async oe=>{try{if(!(await xe(`/api/providers/${oe.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(qT(oe))})).ok)throw new Error("Failed to update provider");await en.getState().fetchConfig()}catch{}m(null),x(!1)},ht=async(oe,Pe)=>{if(U&&te&&te!==`${oe}/${Pe}`&&(xe(`/api/agents/${U}/model`,{method:"DELETE"}).catch(()=>{}),ut.setState(Dt=>{const rn={...Dt.modelOverrides};return delete rn[U],{modelOverrides:rn}})),t){Re.setState(Dt=>({currentSession:Dt.currentSession?{...Dt.currentSession,providerId:oe,providerModel:Pe}:null})),n(oe,Pe),c([]),a(!1),cu();return}await $(oe)&&(c([]),a(!1),cu())},Ht=async(oe,Pe,Ze)=>{oe.stopPropagation(),Ge(!0);try{await X(Pe,Ze)}catch{}finally{Ge(!1)}},{searchQuery:Vt,setSearchQuery:At,highlightedIndex:Bn,setHighlightedIndex:Sn,visibleGroups:hn,flatItems:Dn,handleSearchKeyDown:wn,highlightedRef:un,inputRef:nr}=ZN({providers:P,onSelect:ht,onEscape:()=>a(!1),extraItemCount:1}),we=Bn===Dn.length,et=oe=>{if(oe.key==="Enter"&&Bn===Dn.length){oe.preventDefault(),e("/onboarding"),a(!1);return}wn(oe)};return P.length===0?s.jsxs("button",{type:"button",onClick:()=>H(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:ae?"LLM server is offline. Click to retry.":Be??"Click to refresh model",children:[ae?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):s.jsx(Sk,{activeProvider:Je,shortModelName:Be,agentOverrideActive:ye,agentColor:le,agentName:M==null?void 0:M.name}),s.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):s.jsxs("div",{className:"relative",ref:h,children:[s.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:[ae?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):s.jsx(Sk,{activeProvider:Je,shortModelName:Be,agentOverrideActive:ye,agentColor:le,agentName:M==null?void 0:M.name}),s.jsx(pn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(hi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:nr,type:"text",value:Vt,onInput:oe=>{At(oe.currentTarget.value),Sn(-1)},onKeyDown:et,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsx(dt,{className:"flex-1 min-h-0",children:s.jsxs("div",{children:[hn.map(oe=>{const Pe=Vt.trim().length>0||l.includes(oe.provider.id);return s.jsxs("div",{children:[s.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${oe.provider.id===_e?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${V?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[s.jsxs("div",{onClick:()=>!V&&He(oe.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[s.jsx("span",{className:`text-sm font-medium truncate ${oe.provider.id===_e?"text-accent-primary":"text-text-primary"}`,children:oe.provider.name}),s.jsx("span",{className:"text-xs text-text-muted truncate",children:oe.provider.backend!=="unknown"&&Nj(oe.provider.backend)})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!oe.provider.authAdapter&&(w[oe.provider.id]==="connected"||oe.provider.credentialRef?s.jsx("button",{type:"button",onClick:Ze=>Qe(Ze,oe.provider.id),disabled:_===oe.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-success/40 text-accent-success hover:bg-accent-success/10 disabled:opacity-50",title:"Disconnect provider account",children:"Connected"}):s.jsx("button",{type:"button",onClick:Ze=>he(Ze,oe.provider.id),disabled:_===oe.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:_===oe.provider.id?"Starting…":w[oe.provider.id]==="error"||w[oe.provider.id]==="expired"?"Retry":"Connect"})),oe.provider.id===_e?s.jsx("span",{className:"text-accent-success",title:"Active provider",children:s.jsx(Rs,{className:"w-4 h-4"})}):s.jsx("span",{className:"w-4"}),s.jsx("button",{type:"button",onClick:Ze=>{Ze.stopPropagation(),Se(Ze,oe.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:s.jsx(wf,{className:`w-4 h-4 ${u===oe.provider.id?"animate-spin":""} ${oe.provider.id===G?"text-accent-primary":"text-text-muted"}`})}),s.jsx("button",{type:"button",onClick:Ze=>{Ze.stopPropagation(),ie(oe.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:s.jsx(pn,{className:`w-4 h-4 transition-transform ${Pe?"rotate-180":""} ${oe.provider.id===G?"text-accent-primary":"text-text-muted"}`})})]})]}),Pe&&s.jsx(dt,{className:"bg-bg-primary border-t border-border max-h-40",children:u===oe.provider.id?s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):oe.models.length>0?oe.models.map(Ze=>{const rn=Dn.findIndex(Ne=>Ne.providerId===oe.provider.id&&Ne.modelConfig.id===Ze.id)===Bn;return s.jsx("div",{ref:rn?un:void 0,children:s.jsx(QN,{providerId:oe.provider.id,modelConfig:Ze,isActive:ue(oe.provider.id,Ze.id),isDefault:Me(oe.provider.id,Ze.id),disabled:u==="activating",hasSession:!!t,settingDefault:ke,highlighted:rn,onModelClick:ht,onSetDefault:Ht,onEditModel:it})},`${oe.provider.id}/${Ze.id}`)}):s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},oe.provider.id)}),hn.length===0&&Vt.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})}),s.jsx("div",{className:`border-t border-border px-3 py-2 ${we?"bg-bg-tertiary":""} flex-shrink-0`,children:s.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),v&&s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 px-4",role:"dialog","aria-modal":"true","aria-labelledby":"provider-device-title",onMouseDown:oe=>{oe.target===oe.currentTarget&&Ue()},children:s.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),s.jsx("button",{type:"button",onClick:Ue,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"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:me,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"}),s.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:k?"Copied to clipboard":"Click the code to copy it"}),s.jsxs("div",{className:"mt-6 flex gap-3",children:[s.jsx("button",{type:"button",onClick:me,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:k?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:We,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"})]}),s.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."})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:v.instructions}),s.jsx("div",{className:"mt-6 flex gap-3",children:s.jsx("button",{type:"button",onClick:We,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&&g&&s.jsx(KT,{isOpen:!0,onClose:Ve,onSave:at,initialStep:2,editProvider:{id:p.providerId,name:(ge==null?void 0:ge.name)??"",url:(ge==null?void 0:ge.url)??"",backend:(ge==null?void 0:ge.backend)??"unknown",apiKey:ge==null?void 0:ge.apiKey,isLocal:ge==null?void 0:ge.isLocal,thinkingField:ge==null?void 0:ge.thinkingField,sendReasoningInMessages:ge==null?void 0:ge.sendReasoningInMessages,authAdapter:ge==null?void 0:ge.authAdapter,transportAdapter:ge==null?void 0:ge.transportAdapter,models:ge==null?void 0:ge.models},editModelId:p.model.id})]})}function lG(){const e=Qc(k=>k.servers),t=Qc(k=>k.fetchServers),n=Re(k=>k.currentSession),r=n==null?void 0:n.id,[a,l]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(new Set),[p,m]=j.useState(new Set),g=j.useRef(null),x=j.useCallback(async()=>{if(r)try{const k=await xe(`/api/sessions/${r}/mcp/overrides`);if(k.ok){const N=await k.json();m(new Set(N.disabledServers??[]))}}catch{}},[r]),w=j.useCallback(async()=>{await t(),await x()},[t,x]);j.useEffect(()=>{const k=()=>w();return window.addEventListener("mcp-servers-changed",k),()=>window.removeEventListener("mcp-servers-changed",k)},[w]),j.useEffect(()=>{x()},[x]),j.useEffect(()=>{a&&x()},[a,x]),Xf(g,()=>l(!1));const C=k=>p.has(k.name),_=e.filter(k=>k.status==="connected"&&!C(k)),S=_.length,v=_.reduce((k,N)=>k+N.estimatedTokens,0),b=async(k,N)=>{if(r){u(null),h(E=>new Set(E).add(k));try{const E=new Set(p);N?E.add(k):E.delete(k);const D=await xe(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(E)})});if(!D.ok){const A=await D.json().catch(()=>({}));throw new Error(A.error??"Toggle failed")}m(E),await t()}catch(E){u(E instanceof Error?E.message:String(E))}finally{h(E=>{const D=new Set(E);return D.delete(k),D})}}};return s.jsxs("div",{className:"relative",ref:g,children:[s.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:[s.jsx("span",{className:"text-sm text-accent-primary whitespace-nowrap",children:S>0?`● ${S} MCP (${Kh(v)})`:"MCP"}),s.jsx(pn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[s.jsx(dt,{className:"flex-1 min-h-0",children:e.length===0?s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No MCP servers configured"}):e.map(k=>{const N=C(k),E=d.has(k.name);return s.jsx("div",{children:s.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-bg-tertiary",children:[s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("span",{className:`text-sm ${Ib(N?"disabled":k.status)}`,children:Mb(N?"disabled":k.status)}),s.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:k.name})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted ml-3.5",children:[s.jsxs("span",{children:[k.tools.length," tools"]}),k.estimatedTokens>0&&s.jsxs("span",{children:[Kh(k.estimatedTokens)," tokens"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[E&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"..."}),s.jsx(ds,{enabled:!N,onClick:()=>b(k.name,!N)})]})]})},k.name)})}),s.jsx("div",{className:"border-t border-border px-3 py-2 flex-shrink-0",children:c?s.jsx("div",{className:"text-xs text-accent-error",children:c}):s.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," server(s) configured"]})})]})]})}function cG({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:l,errorMessage:c,setErrorMessage:u,scrollToBottom:d,sessionId:h,showHistory:p,history:m,selectedIndex:g,openHistory:x,closeHistory:w,navigateUp:C,navigateDown:_,selectCurrent:S,isAutoScrollActive:v,setAutoScroll:b,onOpenMessageSearch:k,onOpenCommandsModal:N,onOpenWorkflowsModal:E,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:A,onSendCommand:O,clearInput:P}){const G=j.useRef(null),z=j.useRef(null),V=j.useRef(0),$=j.useRef(0),H=j.useRef(null),q=j.useRef(null),X=bf(),Y=Re(he=>he.stopGeneration),F=Re(he=>he.cancelQueued),I=Re(he=>he.queuedMessages),R=Re(he=>he.restoredInput),W=Re(he=>he.clearRestoredInput),B=Re(he=>{var me;return(me=he.currentSession)==null?void 0:me.workdir}),Z=Re(he=>he.currentSession),Q=j.useRef(!1),J=j.useRef(!1),U=j.useRef(!1),[M,te]=j.useState([]),se=j.useRef(null),{sendMessage:re,launchWorkflow:le}=GT(b);j.useEffect(()=>{if(J.current)return;J.current=!0;const he=$t.getState();he.defaults.length===0&&he.userItems.length===0&&he.projectItems.length===0&&he.fetchWorkflows();const me=ln.getState();me.defaults.length===0&&me.userItems.length===0&&me.projectItems.length===0&&me.fetchCommands()},[]),j.useEffect(()=>{e||te([])},[e]),j.useEffect(()=>{var he;R!==null&&(t(R),W(),zt()&&((he=G.current)==null||he.focus()))},[R,t,W]);const ye=j.useCallback(()=>{const he=G.current;if(!he)return;const me=e.length>=V.current;V.current=e.length,me||(he.style.height="auto"),he.style.height=`${Math.min(200,he.scrollHeight)}px`},[e]);j.useEffect(()=>{if(!h)return;const he=`openfox:draft:${h}`,me=localStorage.getItem(he);me!==null&&t(me)},[h,t]),j.useEffect(()=>{var he;zt()&&((he=G.current)==null||he.focus()),ye()},[h,ye]),j.useEffect(()=>{if(!h)return;const he=`openfox:draft:${h}`,me=setTimeout(()=>{e?localStorage.setItem(he,e):localStorage.removeItem(he)},500);return()=>clearTimeout(me)},[h,e]),j.useEffect(()=>{ye()},[e,ye]),j.useEffect(()=>{const he=G.current;if(!he)return;const me=async We=>{var it;if(document.activeElement!==he)return;const Ue=(it=We.clipboardData)==null?void 0:it.items;if(!Ue)return;const Qe=[];for(const ge of Array.from(Ue)){let Ve=ge.getAsFile();if(Ve&&_7(Ve.type)){if(We.preventDefault(),!Ve.name){const at=v7(Ve.type);Ve=new File([Ve],`pasted-file.${at}`,{type:Ve.type})}await xy(Ve,at=>Qe.push(at),u)}}Qe.length>0&&r(ge=>[...ge,...Qe])};return he.addEventListener("paste",me),()=>he.removeEventListener("paste",me)},[r,u]);const _e=he=>{he.preventDefault(),!(!e.trim()&&n.length===0)&&fe()},Oe=he=>{var me,We;if(!((me=q.current)!=null&&me.handleKeyDown(he))&&!((We=H.current)!=null&&We.handleKeyDown(he))){if(p)switch(he.key){case"Enter":{he.preventDefault();const Ue=S();Ue&&(t(Ue),w());return}case"Escape":he.preventDefault(),w(),X&&Y();return;case"ArrowUp":he.preventDefault(),C();return;case"ArrowDown":he.preventDefault(),_();return}if(he.key==="ArrowUp"&&e.trim()===""&&!p){he.preventDefault(),x();return}he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),_e(he))}};async function Be(he,me,We){const Ue=[];for(const Qe of Array.from(he))await xy(Qe,it=>Ue.push(it),We);Ue.length>0&&me(Qe=>[...Qe,...Ue])}const ke=j.useCallback(async he=>{const me=he.target.files;!me||me.length===0||(u(null),await Be(me,r,u),z.current&&(z.current.value=""))},[r,u]),Ge=j.useCallback(he=>{var me;(me=he.dataTransfer.types)!=null&&me.includes("Files")&&(he.preventDefault(),he.stopPropagation(),l(!0))},[l]),Je=j.useCallback(he=>{he.preventDefault(),he.stopPropagation(),l(!1)},[l]),ae=j.useCallback(async he=>{he.preventDefault(),he.stopPropagation(),l(!1),u(null);const me=he.dataTransfer.files;!me||me.length===0||await Be(me,r,u)},[r,l,u]),ue=j.useCallback(he=>{r(n.filter(me=>me.id!==he))},[n,r]),Me=j.useCallback(()=>{var he;(he=z.current)==null||he.click()},[]),fe=()=>{if(U.current||!e.trim()&&n.length===0)return;if(U.current=!0,d==null||d(),e.trim().startsWith("/")){const me=Qa($t.getState()),We=ln.getState(),Ue=Qn(Qn(We.defaults,We.userItems),We.projectItems),Qe=FV(e,me,Ue);if(Qe!=null&&Qe.workflowId){const it=se.current,ge=it&&it.id===Qe.workflowId?it.scope:"auto";se.current=null;const Ve=py(me,Qe.workflowId,ge),at=((Ve==null?void 0:Ve.parameters)??[]).filter(ht=>ht.required&&!(ht.id in Qe.params));if(at.length>0){const ht=at.map(Ht=>Ht.label||Ht.id).join(", ");u(`Missing required parameter${at.length>1?"s":""}: ${ht}`),U.current=!1;return}le(void 0,void 0,Qe.workflowId,void 0,Qe.params,ge),P(),U.current=!1;return}if(Qe!=null&&Qe.commandId){We.fetchCommand(Qe.commandId).then(it=>{if(it){const ge=VT(it.prompt),Ve={};for(const[ht,Ht]of Object.entries(Qe.params)){const Vt=parseInt(ht,10),At=ge[Vt];At&&(Ve[At]=Ht)}let at=it.prompt;for(const[ht,Ht]of Object.entries(Ve))at=at.replaceAll(`{{${ht}}}`,Ht);O(at,it.metadata.agentMode),P()}U.current=!1});return}}re(e,n),P(),U.current=!1},Fe=j.useCallback((he,me)=>{const Ue=he.type==="directory"?"/":" ",{newText:Qe,newCursorPos:it}=Jh(e,$.current,me,`@${he.path}${Ue}`);t(Qe),$.current=it,Qh(G.current,it)},[e,t]),He=j.useCallback((he,me)=>{const{newText:We,newCursorPos:Ue}=Jh(e,$.current,me,`/${he.id} `);t(We),$.current=Ue,Qh(G.current,Ue),he.type==="workflow"&&(se.current={id:he.id,scope:he.scope}),te(rT(he))},[e,t]),ie=j.useCallback(he=>{const me=he.target.value;t(me),p&&w(),$.current=he.target.selectionStart;const We=se.current;if(We){const Ue=me.match(/^\/(\S+)/),Qe=Ue?Ue[1]:void 0;(!Qe||Qe!==We.id)&&(se.current=null)}M.length>0&&(!me.startsWith("/")||!me.includes(" "))&&te([]),!Q.current&&h&&me&&Z&&(Z.messageCount??0)===0&&(Q.current=!0,xe(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,p,w,h,Z,M]),Se=j.useCallback(he=>{$.current=he.target.selectionStart},[]),Le=j.useCallback(he=>{$.current=he.currentTarget.selectionStart},[]);return s.jsxs("div",{className:"relative",children:[X&&s.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:s.jsx(VV,{})}),s.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:[s.jsx(Gb,{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"}),s.jsxs("button",{type:"button",onClick:k,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[s.jsx(hi,{}),"Browse history"]})]}),s.jsx(GV,{}),s.jsxs("form",{onSubmit:_e,className:"p-2 md:p-4 bg-secondary rounded-lg",children:[s.jsx("input",{ref:z,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:ke,className:"hidden",multiple:!0}),c&&s.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:c}),n.length>0&&s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(he=>s.jsx(Bb,{attachment:he,onRemove:ue},he.id))}),p&&s.jsx(UV,{history:m,selectedIndex:g,onSelect:he=>{t(he),w()},onEscape:w,onNavigate:he=>{he==="up"?C():_()}}),s.jsx(XV,{messages:I,onCancel:F}),s.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:Ge,onDragLeave:Je,onDrop:ae,children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx("textarea",{id:FN,ref:G,value:e,onChange:ie,onKeyDown:Oe,onSelect:Se,onKeyUp:Le,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}),s.jsx(tT,{ref:H,text:e,cursorPos:$.current,workdir:B,onSelect:Fe}),s.jsx(eT,{ref:q,text:e,cursorPos:$.current,workflows:Qa($t.getState()),commands:(()=>{const he=ln.getState();return Qn(Qn(he.defaults,he.userItems),he.projectItems)})(),onSelect:He}),M.length>0&&(()=>{const he=e.match(/\/(\w+)\s+(.*)$/),We=(he?he[2].trim().split(/\s+/):[]).filter(Boolean).length,Ue=M[We];return Ue?s.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[Ue,"=?"]}):null})()]}),s.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[X&&s.jsxs("button",{type:"button",onClick:()=>Y(),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[s.jsx(qy,{}),"Abort"]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button",onClick:fe,disabled:!e.trim()&&n.length===0,"data-testid":"chat-send-button",className:"px-4 py-1.5 rounded-l bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"}),s.jsx(KV,{onSendCommand:O,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:A,onOpenCommandsManager:N,onOpenWorkflowsManager:E,onAttach:Me,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nG,{}),s.jsx(rG,{})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Lt(he=>he.settings)[Ee.FEATURES_PER_SESSION_MCP]==="true"&&s.jsx(lG,{}),s.jsx(oG,{})]})]})]})]})}const uG=4;function dG({projectId:e}){const[,t]=Ln(),n=It(w=>w.tasks),r=It(w=>w.activeProjectId),a=It(w=>w.loadBoard),l=It(w=>w.moveTask),c=It(w=>w.lastError),[u,d]=j.useState(!1),[h,p]=j.useState(null);j.useEffect(()=>{r!==e&&a(e)},[r,e,a]);const m=j.useMemo(()=>n.filter(w=>w.status==="todo"&&w.sessionIds.length===0).sort((w,C)=>w.position-C.position).slice(0,uG),[n]),g=j.useMemo(()=>n.filter(w=>w.status==="in_progress"&&w.runState==="running").length,[n]);if(m.length===0)return null;const x=async w=>{var _;p(null);const C=await l(e,w.id,"in_progress");C!=null&&C.sessionId?t(`/p/${e}/s/${C.sessionId}`):C!=null&&C.task&&C.task.status==="in_progress"&&C.task.runState==="queued"&&p({label:((_=w.prompt.split(`
320
+ `)[0])==null?void 0:_.slice(0,60))||"This task"})};return s.jsxs("div",{className:"mx-auto max-w-xl w-full",children:[s.jsxs("div",{className:"rounded-lg border border-border bg-bg-secondary/60 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-text-muted",children:[s.jsx(Ky,{className:"w-3.5 h-3.5"}),"Up next",g>0&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-xs font-medium normal-case tracking-normal text-emerald-400",title:`${g} task${g!==1?"s":""} currently running`,children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),g," running"]})]}),s.jsx(rt,{size:"sm",onClick:()=>d(!0),children:"Manage tasks"})]}),h&&s.jsx("div",{className:"mt-3 rounded-md border border-amber-400/40 bg-amber-400/10 p-2.5",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("p",{className:"text-xs text-text-primary",children:["“",h.label,"” is queued — it’ll start automatically when a slot frees."]}),s.jsx("button",{type:"button",onClick:()=>p(null),title:"Dismiss",className:"shrink-0 text-xs text-text-muted underline hover:text-text-primary transition-colors",children:"Dismiss"})]})}),s.jsx("ul",{className:"mt-3 space-y-2",children:m.map((w,C)=>s.jsxs("li",{className:"flex items-start justify-between gap-3 rounded-md border border-border bg-bg-secondary px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-text-primary font-medium leading-snug line-clamp-2 break-words whitespace-pre-wrap",children:w.prompt}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-text-muted",children:[w.attachments.length>0&&s.jsxs("span",{children:["📎 ",w.attachments.length]}),w.model&&s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary border border-border",children:w.model})]})]}),s.jsxs(rt,{variant:C===0?"primary":"secondary",size:"sm",onClick:()=>void x(w),className:"shrink-0 flex items-center gap-1",children:["Start ",s.jsx(vf,{className:"w-3 h-3"})]})]},w.id))}),c&&s.jsx("div",{className:"mt-3 text-sm text-accent-error",children:c})]}),s.jsx(Fb,{isOpen:u,onClose:()=>d(!1),projectId:e})]})}function wk({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[l,c]=j.useState({}),u=[...t].sort((p,m)=>(p.position??0)-(m.position??0)),d=()=>{var m;const p={};for(const g of u){const x=(m=l[g.id])==null?void 0:m.trim();x&&(p[g.id]=x)}n(p)},h=u.every(p=>{var m;return!p.required||(((m=l[p.id])==null?void 0:m.trim())??"")!==""});return s.jsxs(St,{isOpen:!0,onClose:r,title:`Run: ${e}`,size:"sm",closeOnEscape:!0,closeOnBackdropClick:!0,children:[s.jsx("div",{className:"space-y-3 py-2",children:u.map(p=>s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[p.label||p.id,p.required&&s.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),p.description&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:p.description}),s.jsx("input",{value:l[p.id]??"",onChange:m=>c(g=>({...g,[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===u[0])&&zt()})]},p.id))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border",children:[s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm text-text-muted hover:text-text-primary transition-colors",children:"Cancel"}),s.jsx("button",{onClick: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 Ck=9999,dh=j.forwardRef(function({trigger:t,children:n},r){const[a,l]=j.useState(!1),c=j.useRef(null),u=j.useRef(null),d=j.useRef(null),h=j.useCallback(()=>{l(!1)},[]);j.useImperativeHandle(r,()=>({close:h}),[h]);const p=j.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 j.useEffect(()=>{var w;if(!a){zt()&&((w=d.current)==null||w.focus()),d.current=null;return}const m=C=>{u.current&&!u.current.contains(C.target)&&c.current&&!c.current.contains(C.target)&&h()},g=C=>{C.key==="Escape"&&h()},x=()=>h();return document.addEventListener("mousedown",m),document.addEventListener("keydown",g),window.addEventListener("blur",x),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",g),window.removeEventListener("blur",x)}},[a,h]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:c,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&&mi.createPortal(s.jsx("div",{ref:u,role:"dialog","aria-modal":"true",className:"fixed bg-bg-secondary border border-border rounded-lg shadow-xl p-3 w-[320px] max-w-[calc(100vw-16px)] max-h-[60vh]",style:(()=>{if(!c.current)return{zIndex:Ck,top:0,left:0};const m=c.current.getBoundingClientRect(),g=320,x=8;let w=m.left;return w+g>window.innerWidth-x&&(w=m.right-g),w=Math.max(x,Math.min(w,window.innerWidth-g-x)),{zIndex:Ck,top:m.bottom+4,left:w}})(),children:s.jsx(dt,{className:"max-h-full",children:n})}),document.body)]})});function hG({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=fT.filter(r=>(t.get(r)??0)>0);return n.length===0?s.jsx("span",{className:"text-text-muted text-sm",children:"None"}):s.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:n.map(r=>s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(El,{status:r}),s.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function fG({visible:e}){const t=Re(M=>M.currentSession),n=Jn(M=>M.status),r=Jn(M=>M.config),a=Jn(M=>M.start),l=Re(M=>M.contextState),c=Re(M=>M.queueUpdate),u=Jn(M=>M.logs),{branch:d,diff:h}=Ub(),[p,m]=j.useState(!1),[g,x]=j.useState(!1),[w,C]=j.useState(!1),[_,S]=j.useState(null),[v,b]=j.useState(!1),[k,N]=j.useState(!1),E=j.useRef(null),D=j.useRef(null),A=j.useRef(null),O=j.useRef(null),P=Lt(M=>M.settings[Ee.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!t)return null;const G=mu(t.workspace??"")||"original",z=t.workspace??t.workdir,V=t.metadataEntries??{},$=V.criteria??[],H=["review_findings","todos"],q=H.filter(M=>{var te;return M in V&&(((te=V[M])==null?void 0:te.length)??0)>0}),X=Object.keys(V).filter(M=>M!=="criteria"&&!H.includes(M)).filter(M=>{var te;return(((te=V[M])==null?void 0:te.length)??0)>0}),Y=[...q,...X].reduce((M,te)=>{var se;return M+(((se=V[te])==null?void 0:se.length)??0)},0),F=[...q,...X].map(ol),I=h.files,R=I.reduce((M,te)=>M+te.additions,0),W=I.reduce((M,te)=>M+te.deletions,0),B=(n==null?void 0:n.state)??"off",Z=B==="running"||B==="warning",Q=r!==null,J=M=>{M.stopPropagation(),a()},U=M=>{M.stopPropagation(),n!=null&&n.url&&window.open(n.url,"_blank")};return s.jsxs("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:[s.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:items-center sm:justify-between gap-x-2 gap-y-1 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1 min-w-0 sm:shrink-0",children:[s.jsx(Qr,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:G}),s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx(Va,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:d??"-"}),I.length>0?s.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",R," -",W]}):s.jsx("span",{className:"shrink-0"}),s.jsx(dh,{ref:O,trigger:s.jsx(pn,{className:"w-3 h-3"}),children:s.jsx(TT,{workspaceName:G,branch:d,workdir:z,showEditorLink:P,sessionId:t.id,projectId:t.projectId,onEditWorkspace:()=>{var M;(M=O.current)==null||M.close(),b(!0)},onEditBranch:()=>{var M;(M=O.current)==null||M.close(),N(!0)}})})]}),s.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex-1 flex items-center sm:justify-center justify-self-end gap-1 min-w-0",children:[s.jsx(hG,{entries:$}),Y>0&&s.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:F.join(", "),children:["+",Y]}),s.jsx(dh,{ref:A,trigger:s.jsx(pn,{className:"w-3 h-3"}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var M;(M=A.current)==null||M.close(),S("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(ef,{entries:$,title:"Acceptance Criteria"})}),s.jsx(gT,{entries:$,sessionId:t.id})]}),[...q,...X].map(M=>{const te=V[M];return s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var se;(se=A.current)==null||se.close(),S(M)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(ef,{entries:te,title:ol(M)})}),s.jsx(mT,{entries:te})]},M)})]})})]}),s.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),s.jsx("div",{className:"col-span-2 border-t border-border sm:hidden -mx-4"}),s.jsx("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:l&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:l.currentTokens>=1e3?`${Math.round(l.currentTokens/1e3)}K`:l.currentTokens}),s.jsx(qb,{percent:Math.round(l.currentTokens/l.maxTokens*100),dangerZone:l.dangerZone,size:"sm"}),s.jsx(dh,{ref:D,trigger:s.jsx(pn,{className:"w-3 h-3"}),children:s.jsx(LT,{onUpdateSystemPrompt:()=>{var M;(M=D.current)==null||M.close(),C(!0)}})})]})}),s.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0 justify-self-end",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${B==="running"?"bg-accent-success":B==="warning"?"bg-accent-warning":B==="error"?"bg-accent-error":"bg-text-muted"}`}),Q?Z?s.jsx("button",{onClick:U,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Open dev server",children:s.jsx(Wy,{className:"w-3.5 h-3.5"})}):s.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:s.jsx(Sf,{className:"w-3.5 h-3.5"})}):s.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),s.jsx(dh,{ref:E,trigger:s.jsx(pn,{className:"w-3 h-3"}),children:s.jsx(vT,{workdir:z,compact:!0,onExpand:()=>m(!0),onConfigure:()=>{var M;(M=E.current)==null||M.close(),x(!0)}})})]})]}),p&&s.jsx(Wb,{title:"Dev Server Logs",logs:u,onClose:()=>m(!1)}),g&&s.jsx(xT,{isOpen:!0,onClose:()=>x(!1)}),_&&t&&s.jsx(pT,{isOpen:!0,onClose:()=>S(null),entries:V[_]??[],sessionId:t.id,metadataKey:_,title:ol(_)}),v&&s.jsx(ET,{isOpen:!0,onClose:()=>b(!1),projectId:t.projectId,sessionId:t.id,currentWorkspace:G,currentBranch:d}),k&&s.jsx(NT,{isOpen:!0,onClose:()=>N(!1),sessionId:t.id}),w&&l&&s.jsx(Kb,{isOpen:!0,onClose:()=>C(!1),isRunning:t.isRunning,onApply:()=>{t.isRunning?c():Bt.send("context.applyDynamic",{}),C(!1)}})]})}function mG(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function YT(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,c=1,u=null;const d=()=>{if(!u||u.size===0)return;const h=new Map;let p=0;for(const g of e)g.role!=="tool"&&g.contextWindowId===l&&(g.subAgentId&&!h.has(g.subAgentId)&&h.set(g.subAgentId,p),p++);const m=[...u.entries()].sort((g,x)=>(h.get(g[0])??0)-(h.get(x[0])??0));for(const[g,x]of m){const w=r.get(g);(w==null?void 0:w.type)==="subagent"&&w.messages.length===x.messages.length&&w.messages.every((_,S)=>_===x.messages[S])?a.push(w):a.push({type:"subagent",subAgentId:g,subAgentType:x.subAgentType,messages:x.messages})}u=null};for(let h=0;h<e.length;h++){const p=e[h];if(p.role!=="tool")if(p.contextWindowId&&l&&p.contextWindowId!==l&&(d(),c++,a.push({type:"context-divider",windowSequence:c})),l=p.contextWindowId,p.subAgentId&&p.subAgentType){u||(u=new Map);let m=u.get(p.subAgentId);m||(m={subAgentType:p.subAgentType,messages:[]},u.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 pG=10,gG=150;function xG(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 yG(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,pG).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:c7(r.timestamp),trimmedContent:Yh(r.content,gG),sessionId:r.sessionId,sessionName:r.sessionName}))}function bG(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(...xG(l));return yG(r)}function vG(e,t=[],n=null){const[r,a]=j.useState(0),[l,c]=j.useState(!1),u=j.useMemo(()=>bG(e,t,n),[e,t,n]),d=j.useCallback(()=>{u.length>0&&(a(u.length-1),c(!0))},[u.length]),h=j.useCallback(()=>{c(!1),a(0)},[]),p=j.useCallback(()=>{a(x=>u.length===0?x:x===0?u.length-1:x-1)},[u.length]),m=j.useCallback(()=>{a(x=>u.length===0?x:x===u.length-1?0:x+1)},[u.length]),g=j.useCallback(()=>{if(u.length===0||!l)return null;const x=u[r];return(x==null?void 0:x.content)??null},[u,r,l]);return{history:u,selectedIndex:r,showHistory:l,openHistory:d,closeHistory:h,navigateUp:p,navigateDown:m,selectCurrent:g}}j.memo(function({item:t}){const[n,r]=j.useState(!1);return t.type==="start"?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[s.jsx("span",{className:"animate-pulse",children:"●"}),s.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&s.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):s.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[s.jsx("span",{className:"text-accent-success",children:"✓"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),s.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&s.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(ar,{content:t.description})})]})]})});function _G({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r}={}){const a=e??!0,[l,c]=j.useState(""),[u,d]=j.useState([]),[h,p]=j.useState(!1),[m,g]=j.useState(null),[x,w]=j.useState(!1),[C,_]=j.useState(!1),[S,v]=j.useState(!1),[b,k]=j.useState(!1),[N,E]=j.useState(null),D=j.useRef(null),A=wu(D),O=Re(me=>me.currentSession),P=Re(me=>me.messages),G=Re(me=>me.hiddenCount),z=Re(me=>me.sessions),V=bf(),$=Re(me=>me.stopGeneration),H=n??P,{maxVisibleItems:q}=Ds(),X=ut(me=>me.defaults),Y=ut(me=>me.userItems),F=[...X,...Y].filter(me=>!me.subagent),{history:I,selectedIndex:R,showHistory:W,openHistory:B,closeHistory:Z,navigateUp:Q,navigateDown:J,selectCurrent:U}=vG(H,z,O==null?void 0:O.id);j.useEffect(()=>{const me=We=>{E(We.detail.stats)};return window.addEventListener("open-turn-stats",me),()=>window.removeEventListener("open-turn-stats",me)},[]);const M=O==null?void 0:O.workdir;j.useEffect(()=>{$t.getState().setWorkdir(M),M&&$t.getState().fetchWorkflows()},[M]),j.useEffect(()=>{$t.getState().fetchWorkflows()},[]),j.useEffect(()=>{const me=We=>{mG(We)&&(We.preventDefault(),k(!0))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[]);const te=j.useRef([]),{displayItems:se,hiddenCount:re}=j.useMemo(()=>{const me=YT(H,te.current);return te.current=me,q>0&&me.length>q?{displayItems:me.slice(-q),hiddenCount:me.length-q}:{displayItems:me,hiddenCount:0}},[H,q]),le=r??G??re,{isAutoScrollActive:ye,setAutoScroll:_e,handleScrollbarGesture:Oe}=Su(D,O,A),{sendMessage:Be,launchWorkflow:ke}=GT(_e);j.useEffect(()=>{const me=()=>_e(!0);return window.addEventListener(sf,me),()=>window.removeEventListener(sf,me)},[_e]);const[Ge,Je]=j.useState(null),[ae,ue]=j.useState(null),Me=j.useCallback((me,We,Ue,Qe="auto")=>{const it=Qa($t.getState()),ge=py(it,me,Qe);((ge==null?void 0:ge.parameters)??[]).filter(at=>at.position!==void 0||at.required).length>0?Je({id:me,name:(ge==null?void 0:ge.name)??me,subGroup:We,scope:Qe}):ke(void 0,void 0,me,We,Ue,Qe)},[ke]),fe=j.useCallback((me,We,Ue,Qe)=>{Me(me,We,Ue,Qe)},[Me]),Fe=j.useCallback(me=>{_e(!1);const We=document.querySelector(`[data-item-index="${me}"]`);We&&(We.hasAttribute("data-placeholder")?(window.dispatchEvent(new CustomEvent(by,{detail:{index:me}})),requestAnimationFrame(()=>requestAnimationFrame(()=>{var Ue;(Ue=document.querySelector(`[data-item-index="${me}"]`))==null||Ue.scrollIntoView({behavior:"smooth",block:"center"})}))):We.scrollIntoView({behavior:"smooth",block:"center"}))},[_e]);j.useEffect(()=>{const me=We=>{const Ue=S||x||C||b||N;We.key==="Escape"&&V&&!Ue&&$(),We.key==="ScrollLock"&&_e(!ye)};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[V,$,ye,S,x,C,b,N]);const He=hu();eu(He.quickAction,()=>{v(!0)}),eu(He.criteriaSidebar,()=>{t==null||t()}),i3(He.agentSwitching,F,me=>{Re.getState().switchMode(me)});const ie=(me,We)=>{Me(me,void 0,void 0,We),Le()},Se=(me,We,Ue)=>{Me(me,We,void 0,Ue),Le()},Le=()=>{c(""),d([]),O!=null&&O.id&&localStorage.removeItem(`openfox:draft:${O.id}`)},he=j.useCallback(async(me,We,Ue,Qe)=>{const it=VT(me);if(it.length>0)ue({prompt:me,paramKeys:it,agentMode:We,textareaContent:Ue,attachments:Qe});else{We&&(O==null?void 0:O.mode)!==We&&await Re.getState().switchMode(We);const ge=Ue&&Ue.trim()?`${Ue.trim()}
321
+
322
+ ${me}`:me;Be(ge,Qe!=null&&Qe.length?Qe:void 0,{messageKind:"command",isSystemGenerated:!0}),Le()}},[Be,Le,O]);return s.jsxs(s.Fragment,{children:[s.jsxs(a9,{criteriaSidebarOpen:a,onCriteriaSidebarToggle:t,messages:H,children:[s.jsx(fG,{visible:!a}),s.jsx(o9,{}),N&&s.jsx(l9,{stats:N,onClose:()=>E(null)}),s.jsx(yV,{}),s.jsx(gV,{displayItems:se,scrollContainerRef:D,highlightedMessageId:null,onLaunchWorkflow:fe,onScrollToTop:()=>_e(!1),hiddenCount:le,onScrollbarGesture:Oe,emptyState:H.length===0&&(O!=null&&O.projectId)?s.jsx(dG,{projectId:O.projectId}):void 0}),s.jsx(cG,{input:l,setInput:c,attachments:u,setAttachments:d,dragOver:h,setDragOver:p,errorMessage:m,setErrorMessage:g,scrollToBottom:()=>{var me,We;return(We=A())==null?void 0:We.scrollTo({top:((me=A())==null?void 0:me.scrollHeight)??0,behavior:"smooth"})},sessionId:O==null?void 0:O.id,showHistory:W,history:I,selectedIndex:R,openHistory:B,closeHistory:Z,navigateUp:Q,navigateDown:J,selectCurrent:U,isAutoScrollActive:ye,setAutoScroll:_e,onOpenMessageSearch:()=>k(!0),onOpenCommandsModal:()=>w(!0),onOpenWorkflowsModal:()=>_(!0),onSelectWorkflow:ie,onSelectWorkflowWithSubGroup:Se,onSendCommand:he,clearInput:Le}),s.jsx($T,{isOpen:x,onClose:()=>w(!1)}),s.jsx(FT,{isOpen:C,onClose:()=>_(!1),projectDir:O==null?void 0:O.workdir}),s.jsx(DV,{isOpen:S,onClose:()=>v(!1),onSearchMessages:()=>k(!0),isAutoScrollActive:ye,onToggleAutoScroll:_e,textareaContent:l,onCloseComplete:cu,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(me,We)=>{const Ue=await ln.getState().fetchCommand(me);Ue&&he(Ue.prompt,Ue.metadata.agentMode,We)},onSelectWorkflow:(me,We)=>{Me(me,void 0,void 0,We),Le()}}),Ge&&s.jsx(wk,{workflowName:Ge.name,parameters:(()=>{var We;const me=Qa($t.getState());return((We=py(me,Ge.id,Ge.scope))==null?void 0:We.parameters)??[]})(),onConfirm:me=>{ke(void 0,void 0,Ge.id,Ge.subGroup,me,Ge.scope),Je(null)},onCancel:()=>Je(null)}),ae&&s.jsx(wk,{workflowName:"Command",confirmLabel:"Launch command",parameters:ae.paramKeys.map((me,We)=>({id:me,label:me,position:We})),onConfirm:me=>{let We=ae.prompt;for(const[Ve,at]of Object.entries(me))We=We.replaceAll(`{{${Ve}}}`,at);const{agentMode:Ue,textareaContent:Qe,attachments:it}=ae;Ue&&(O==null?void 0:O.mode)!==Ue&&Re.getState().switchMode(Ue);const ge=Qe&&Qe.trim()?`${Qe.trim()}
323
+
324
+ ${We}`:We;Be(ge,it!=null&&it.length?it:void 0,{messageKind:"command",isSystemGenerated:!0}),Le(),ue(null)},onCancel:()=>ue(null)})]}),b&&s.jsx(HV,{isOpen:b,onClose:()=>{k(!1),cu(!0)},displayItems:se,onNavigate:Fe})]})}function SG(){var b;const[,e]=xl("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=j.useState(null),[a,l]=j.useState([]),[c,u]=j.useState(0),[d,h]=j.useState(!0),[p,m]=j.useState(null),g=async()=>{if(t){h(!0),m(null);try{const k=await xe(`/api/sessions/${t}?full=true`);if(!k.ok){m(`Failed to load session (${k.status})`),h(!1);return}const N=await k.json();r(N.session??null),l(N.messages??[]),u(N.hiddenCount??0)}catch(k){m(k instanceof Error?k.message:"Unknown error")}finally{h(!1)}}};j.useEffect(()=>{Lt.getState().getSettings([...Hy])},[]),j.useEffect(()=>{g()},[t]);const{showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S}=Ds(),v=j.useMemo(()=>YT(a),[a]);return d?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsx(ta,{})}):p?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx("div",{className:"text-red-400 text-sm",children:p}),s.jsx("button",{onClick:g,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):s.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((b=n==null?void 0:n.metadata)==null?void 0:b.title)??"Session"," — Read-only view"]}),s.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages",c>0?` (${c} older hidden)`:""]})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{onClick:g,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"})})]}),s.jsxs(dt,{className:"flex-1 print:overflow-visible",children:[s.jsx("div",{className:"pt-4",children:s.jsx(BT,{displayItems:v,showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S})}),s.jsx("div",{className:"h-8"})]})]})}function kk({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,l]=j.useState(""),c=j.useRef(null);j.useEffect(()=>{e&&(l(""),setTimeout(()=>{var d;zt()&&((d=c.current)==null||d.focus())},100))},[e]);const u=d=>{d.preventDefault(),a.trim()&&n(a)};return s.jsx(St,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:t?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),s.jsx(Ns,{ref:c,type:"password",value:a,onChange:d=>l(d.target.value),placeholder:"Enter password",autoFocus:zt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(rt,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(rt,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function wG({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return s.jsx("div",{className:"flex justify-center py-6",children:s.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,l)=>{const c=l+1,u=c<e,d=c===e;return s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{onClick:()=>r==null?void 0:r(c),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${u?"bg-accent-primary text-text-primary hover:opacity-80":d?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:u?"✓":c}),s.jsx("button",{onClick:()=>r==null?void 0:r(c),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&&s.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${u?"bg-accent-primary":"bg-border"}`})]},l)})})})}function CG({onNext:e}){const[t,n]=j.useState([]),[r,a]=j.useState([]),[l,c]=j.useState(!1),[u,d]=j.useState(null),[h,p]=j.useState(null),[m,g]=j.useState(null);j.useEffect(()=>{x()},[]);async function x(){try{const N=await xe("/api/providers");if(N.ok){const D=(await N.json()).providers.map(A=>({id:A.id,name:A.name,url:A.url,backend:A.backend,model:null,apiKey:A.apiKey,isLocal:A.isLocal,thinkingField:A.thinkingField,sendReasoningInMessages:A.sendReasoningInMessages,models:A.models}));n(D),a(D)}}catch{}}async function w(N){const E=N.id.startsWith("temp-"),D=r.some(P=>P.id===N.id),A=r.length===0&&u===null,O=qT(N);try{let P;if(E){const z=await xe("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!z.ok)throw new Error("Failed to create provider");const V=await z.json();P={...N,id:V.provider.id,model:null}}else{if(!(await xe(`/api/providers/${N.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).ok)throw new Error("Failed to update provider");P={...N,model:null}}const G=z=>z.some(V=>V.id===P.id)?z.map(V=>V.id===P.id?P:V):[...z,P];a(G),n(G),A&&!D&&e({providers:[P]})}catch{if(E){const P={...N,model:null};a(G=>[...G,P])}}}function C(){d(null),c(!0)}function _(N){d(N),c(!0)}function S(){c(!1),d(null)}function v(N){p(N),t.some(D=>D.id===N)?xe(`/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(E=>!E.id.startsWith("temp-"));e({providers:N})}const k=r.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),s.jsxs("div",{className:"space-y-4",children:[r.length>0?s.jsx("div",{className:"space-y-2",children:r.map(N=>s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:Nj(N.backend)}),s.jsx("span",{className:"text-text-primary font-medium",children:N.name}),s.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"})]}),s.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:N.url}),N.model&&s.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",N.model]})]}),s.jsx("div",{className:"flex items-center gap-1",children:m===N.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.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"}),s.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>_(N),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),s.jsx("button",{onClick:()=>g(N.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:s.jsx(fi,{})})]})})]},N.id))}):s.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:s.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),s.jsxs("button",{onClick:C,"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[s.jsx(es,{className:"w-4 h-4"}),"Add Provider"]}),s.jsx("button",{onClick:b,disabled:!k,"data-testid":"onboarding-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]}),s.jsx(KT,{isOpen:l,onClose:S,onSave:w,initialStep:1,editProvider:u??void 0})]})}function kG({onNext:e}){const[t,n]=j.useState(""),[r,a]=j.useState(!1);return j.useEffect(()=>{xe("/api/config").then(l=>l.json()).then(l=>{l.workdir?n(l.workdir):fetch(ms("/api/directories?path=")+encodeURIComponent("/home")).then(c=>c.json()).then(c=>{c.current&&n(c.current)}).catch(()=>{})}).catch(()=>{fetch(ms("/api/directories?path=")+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})})},[]),s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:t,onChange: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"}),s.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&s.jsx(Ef,{initialPath:t||void 0,onSelect:l=>{n(l),a(!1)},onClose:()=>a(!1)}),s.jsx("button",{onClick:()=>e({workdir:t}),disabled:!t,"data-testid":"onboarding-workdir-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function jG(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function EG(e){return j.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??jG(r.id)});return t},[e])}function NG({value:e,options:t,onChange:n,className:r}){return s.jsxs("select",{value:e,onChange:a=>n(a.target.value),className:r??"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"",children:"Manual configuration..."}),t.map(a=>s.jsxs("option",{value:`${a.providerId}/${a.modelId}`,children:[a.providerName," • ",a.modelName]},`${a.providerId}/${a.modelId}`))]})}function TG({backend:e,url:t,model:n,apiKey:r,onBackendChange:a,onUrlChange:l,onModelChange:c,onApiKeyChange:u}){return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),s.jsxs("select",{value:e,onChange:d=>a(d.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"ollama",children:"Ollama"}),s.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),s.jsx("input",{type:"text",value:t,onChange:d=>l(d.target.value),placeholder:e==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),s.jsx("input",{type:"text",value:n,onChange:d=>c(d.target.value),placeholder:e==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),e==="openai"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),s.jsx("input",{type:"password",value:r,onChange:d=>u(d.target.value),placeholder:"Leave empty for a local server that needs no auth",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]})}function AG(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 LG(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function DG({enabled:e,hasOptions:t,selectedRef:n,visionModelOptions:r,onProviderModelSelect:a,noOptionsMessage:l,children:c,...u}){return e?s.jsxs("div",{className:"space-y-4 pl-8",children:[t?s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model from your providers"}),s.jsx(NG,{value:n,options:r,onChange:a})]}):s.jsx("p",{className:"text-sm text-text-muted italic",children:l}),s.jsx(TG,{...u}),c]}):null}function RG({onNext:e}){const[t,n]=j.useState(!1),[r,a]=j.useState("http://localhost:11434"),[l,c]=j.useState("qwen3.5:0.8b"),[u,d]=j.useState(""),[h,p]=j.useState("ollama"),[m,g]=j.useState([]),[x,w]=j.useState(""),{copied:C,copy:_}=IN();j.useEffect(()=>{xe("/api/config").then(D=>D.json()).then(D=>{D.visionFallback&&(n(D.visionFallback.enabled),D.visionFallback.providerModelRef?w(D.visionFallback.providerModelRef):(a(D.visionFallback.url??"http://localhost:11434"),c(D.visionFallback.model??"qwen3.5:0.8b"),d(D.visionFallback.apiKey??""),D.visionFallback.backend&&p(D.visionFallback.backend))),D.providers&&g(D.providers)}).catch(()=>{})},[]);const S=EG(m),v=LG(w,a,c),b=AG(p,w,a,c);function k(D){if(D){e({});return}e(t&&x?{visionFallback:{enabled:t,providerModelRef:x,timeout:120}}:{visionFallback:{enabled:t,url:r,model:l,timeout:120,backend:h,providerModelRef:"",apiKey:h==="openai"?u:""}})}const N=S.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),s.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),s.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[s.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),s.jsx("button",{onClick:()=>_("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:C?s.jsx(Rs,{className:"w-4 h-4 text-accent-primary"}):s.jsx(U5,{className:"w-4 h-4"})})]}),s.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",s.jsx("strong",{children:"OpenAI"})," backend type."]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:D=>n(D.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),s.jsx(DG,{enabled:t,hasOptions:N,selectedRef:x,visionModelOptions:S,onProviderModelSelect:v,backend:h,url:r,model:l,apiKey:u,onBackendChange:b,onUrlChange:a,onModelChange:c,onApiKeyChange:d,noOptionsMessage:"No vision-capable models found in your providers. You can manually enter a model below."}),s.jsxs("div",{className:"flex items-center justify-between pt-4",children:[s.jsx("button",{onClick:()=>k(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),s.jsx("button",{onClick:()=>k(!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 OG({onComplete:e}){const[t,n]=j.useState(1),[r,a]=j.useState(!1),[l,c]=j.useState({});async function u(m){c(g=>({...g,providers:m.providers})),n(2)}async function d(m){c(g=>({...g,...m})),n(3)}async function h(m){a(!0);try{if(!(await xe("/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(g){console.error("Failed to save onboarding data:",g),a(!1)}}const p=m=>{n(m)};return s.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[s.jsx(_u,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),s.jsx(wG,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),s.jsx("div",{className:"max-w-xl mx-auto",children:r?s.jsxs("div",{className:"text-center",children:[s.jsx(es,{className:"w-6 h-6"}),s.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):s.jsxs(s.Fragment,{children:[t===1&&s.jsx(CG,{onNext:u}),t===2&&s.jsx(kG,{onNext:d}),t===3&&s.jsx(RG,{onNext:h})]})})]})}function IG({projectId:e}){var p;const[,t]=Ln(),n=Re(m=>m.sessionsWithPendingConfirmations),r=Re(m=>{var g;return(g=m.currentSession)==null?void 0:g.id}),a=Re(m=>m.crossSessionConfirmations),l=Re(m=>m.sessions),c=n.find(m=>m!==r);if(!c)return null;const u=l.find(m=>m.id===c),d=(u==null?void 0:u.title)??c.slice(0,6),h=((p=a[c])==null?void 0:p.length)??0;return s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 cursor-pointer hover:bg-amber-500/20 transition-colors",onClick:()=>t(e?`/p/${e}/s/${c}`:`/s/${c}`),role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&t(e?`/p/${e}/s/${c}`:`/s/${c}`)},children:[s.jsx(_f,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-amber-300 flex-1 truncate",children:[h," confirmation",h>1?"s":"",' pending in session "',d,'"']}),s.jsx("span",{className:"text-xs text-amber-400 font-medium flex-shrink-0",children:"View session →"})]})}const bx="openfox_updated_to",vx="update_pending";function MG(){const[e,t]=j.useState(!1),n=localStorage.getItem(bx),r=localStorage.getItem(vx);j.useEffect(()=>{if(!n||!r)return;const l=setTimeout(()=>{localStorage.removeItem(bx),localStorage.removeItem(vx),t(!0)},8e3);return()=>clearTimeout(l)},[n,r]);const a=()=>{localStorage.removeItem(bx),localStorage.removeItem(vx),t(!0)};return e||r!=="true"||!n?null:s.jsxs("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 bg-bg-secondary border border-border rounded-lg shadow-xl animate-slide-down",role:"status","aria-live":"polite",children:[s.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:s.jsx(Rs,{className:"w-3 h-3 text-accent-primary"})}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),s.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:s.jsx(Yy,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Kt.getState().loadUserPresets(),Kt.getState().applySavedTheme());function Qb(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function XT(){return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(ta,{})})}function PG({sidebarOpen:e,onSidebarToggle:t}){const[,n]=xl("/p/:projectId"),r=n==null?void 0:n.projectId,a=Re(d=>d.connectionStatus),l=Yt(d=>d.currentProject),c=Qb();return $5({canLoad:a==="connected"||c,projectId:r,currentProjectId:l==null?void 0:l.id}),!l||l.id!==r?s.jsx(XT,{}):s.jsxs(s.Fragment,{children:[s.jsx(uT,{projectId:r,isOpen:e,onClose:t}),s.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:s.jsx(aU,{})})]})}function BG({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=xl("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,c=a==null?void 0:a.sessionId,[,u]=Ln(),d=Re(C=>C.connectionStatus),h=Re(C=>C.currentSession),p=Re(C=>C.error),m=Re(C=>C.clearError),g=Yt(C=>C.currentProject),x=Qb();return z5({canLoad:d==="connected"||x,projectId:l,sessionId:c,currentProjectId:g==null?void 0:g.id,currentSessionId:h==null?void 0:h.id}),j.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),u(`/p/${l}`))},[p,l,m,u]),!g||g.id!==l?s.jsx(XT,{}):s.jsxs(s.Fragment,{children:[s.jsx(uT,{projectId:l,isOpen:e,onClose:t}),s.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[s.jsx(IG,{projectId:l}),s.jsx(_G,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function $G(){const e=en(r=>r.fetchConfig),[,t]=Ln();async function n(){await e(),t("/")}return s.jsx(dt,{className:"flex-1",children:s.jsx(OG,{onComplete:n})})}function zG(){const{connectionStatus:e}=R5(),t=en(I=>I.fetchConfig),n=en(I=>I.refreshProviderModels),r=en(I=>I.providers),a=en(I=>I.activeProviderId),[,l]=Ln(),c=Qb(),[u,d]=j.useState(!1);j.useEffect(()=>{(e==="connected"||c)&&t().then(()=>{d(!0),Lt.getState().getSettings([...Hy,Ee.DISPLAY_THEME,Ee.DISPLAY_USER_PRESETS,Ee.DISPLAY_CUSTOM_CSS,Ee.KEYBINDINGS,Ee.FEATURES_PER_SESSION_MCP]),Qc.getState().fetchServers()})},[e,c,t]),j.useEffect(()=>{u&&a&&n(a).then(()=>{const I=en.getState().defaultModelSelection;(I?I.split("/")[0]:null)!==a&&t()})},[u,a,n,t]);const h=Lt(I=>I.settings);j.useEffect(()=>{u&&r.length===0&&l("/onboarding")},[u,r.length]),j.useEffect(()=>{const{applyPreset:I,applyTokens:R,setFollowSystemTheme:W,initSystemThemeListener:B}=Kt.getState(),Z=h[Ee.DISPLAY_THEME],Q=h[Ee.DISPLAY_USER_PRESETS],J=h[Ee.DISPLAY_FOLLOW_SYSTEM_THEME];if(Q&&localStorage.setItem("openfox:userPresets",Q),Z){localStorage.setItem("openfox:theme",Z);try{const M=JSON.parse(Z);M.preset&&M.tokens?(I(M.preset),Kt.setState({basePreset:M.preset}),R(M.tokens)):M.preset?I(M.preset):M.tokens&&R(M.tokens)}catch{I("dark")}}else I("system");J!==void 0&&Kt.getState().followSystemTheme!==(J==="true")&&W(J==="true");const U=B();return()=>U()},[h[Ee.DISPLAY_THEME],h[Ee.DISPLAY_USER_PRESETS]]),j.useEffect(()=>{const I=h[Ee.DISPLAY_CUSTOM_CSS]??"";let R=document.getElementById("custom-css");R||(R=document.createElement("style"),R.id="custom-css",document.head.appendChild(R)),R.textContent=I},[h[Ee.DISPLAY_CUSTOM_CSS]]);const[p,m]=j.useState(!1);j.useEffect(()=>{const I=Lt.getState().settings[Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(I===void 0||I==="false")return;let R=!1;if(localStorage.getItem("update_pending")==="true"&&(R=!0,localStorage.removeItem("update_pending")),u){const B=en.getState().version,Z=localStorage.getItem("openfox_last_version");B&&Z&&B!==Z&&(R=!0),localStorage.setItem("openfox_last_version",B??"")}R&&m(!0)},[h[Ee.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],u]);const g=()=>{const I=localStorage.getItem("openfox:leftSidebar");return I!==null?I==="true":!0},x=()=>{const I=localStorage.getItem("openfox:rightSidebar");return I!==null?I==="true":!0},[w,C]=j.useState(g),[_,S]=j.useState(x),[v,b]=j.useState(!1),[k,N]=j.useState(!1),[E,D]=j.useState(!1),A=s5();j.useEffect(()=>{const I=()=>{D(window.innerWidth<768)};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]);const[O]=Ln(),P=/^\/p\/[^/]+$/.test(O),G=E?v:P?!0:w,z=E?k:_,V=()=>{E?b(!v):C(!w)},$=()=>{E?N(!k):S(!_)};j.useEffect(()=>{E||localStorage.setItem("openfox:leftSidebar",String(w))},[w,E]),j.useEffect(()=>{E||localStorage.setItem("openfox:rightSidebar",String(_))},[_,E]),j.useEffect(()=>{(e==="connected"||c)&&t()},[e,t,c]);const H=Re(I=>I.showPasswordModal),q=Re(I=>I.passwordModalRetry),X=Re(I=>I.submitPassword),Y=Re(I=>I.cancelPassword),[F]=xl("/p/:projectId/s/:sessionId/readonly");return!F&&e!=="connected"&&!H&&!c?s.jsxs(s.Fragment,{children:[s.jsx(kk,{isOpen:!0,isRetry:q,onSubmit:X,onCancel:Y}),s.jsx("div",{className:"h-screen flex items-center justify-center",children:s.jsx(h3,{text:"Connecting to server..."})})]}):F?s.jsx(SG,{}):s.jsxs(s.Fragment,{children:[s.jsx(kk,{isOpen:H,isRetry:q,onSubmit:X,onCancel:Y}),s.jsxs("div",{className:"flex flex-col",style:{height:E?`calc(${A.offsetTop}px + ${A.height}px)`:"100vh"},children:[s.jsx(eU,{}),s.jsx(q7,{onMenuClick:V,onCriteriaToggle:$}),s.jsx("div",{className:"flex-1 flex overflow-hidden",children:s.jsxs(FD,{children:[s.jsx(yc,{path:"/onboarding",children:s.jsx($G,{})}),s.jsx(yc,{path:"/p/:projectId/s/:sessionId",children:s.jsx(BG,{sidebarOpen:G,onSidebarToggle:V,rightSidebarOpen:z,onRightSidebarToggle:$})}),s.jsx(yc,{path:"/p/:projectId/new",children:s.jsx(iU,{})}),s.jsx(yc,{path:"/p/:projectId",children:s.jsx(PG,{sidebarOpen:G,onSidebarToggle:V})}),s.jsx(yc,{path:"/",children:s.jsx(sU,{})})]})})]}),s.jsx(MG,{}),s.jsx(BN,{isOpen:p,onClose:()=>m(!1)})]})}const hh=window.location.pathname.match(/\/p\/[^/]+\/s\/([0-9a-fA-F-]+)/);hh!=null&&hh[1]&&a5(hh[1]);_D.createRoot(document.getElementById("root")).render(s.jsx(cs.StrictMode,{children:s.jsx(Ok,{base:jj,children:s.jsx(zG,{})})}));