openfox 2.0.115 → 2.0.116

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 (95) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/CHANGELOG.md +22 -0
  3. package/dist/{ask-ZYPCJKZD.js → ask-UBIRH3SO.js} +2 -2
  4. package/dist/{auth-YY5PJYSC.js → auth-GTGIGX5X.js} +2 -2
  5. package/dist/{auto-config-T5GR2N6X.js → auto-config-AAUO4PKW.js} +2 -2
  6. package/dist/{backend-LVYHLGQJ.js → backend-67OLCS5O.js} +2 -2
  7. package/dist/{branch.api-XVTYACSH.js → branch.api-UMKSQMSA.js} +2 -2
  8. package/dist/changelog-FZUE6OSG.js +63 -0
  9. package/dist/{chat-handler-5SP265CR.js → chat-handler-Z6BEY66U.js} +17 -17
  10. package/dist/{chunk-OCBBAEMT.js → chunk-4E52GUXJ.js} +179 -137
  11. package/dist/{chunk-I7FY2LTR.js → chunk-4GHLULHB.js} +18 -2
  12. package/dist/{chunk-JFK4GKQD.js → chunk-4HV3PDEK.js} +58 -90
  13. package/dist/{chunk-TGLVWAFC.js → chunk-6XHDNSA3.js} +5 -5
  14. package/dist/{chunk-4H427UBV.js → chunk-AGXJ5O63.js} +2 -2
  15. package/dist/{chunk-OKVHMKE2.js → chunk-BH3BBUGB.js} +19 -17
  16. package/dist/{chunk-OCSTEGK7.js → chunk-EQ5CGNOT.js} +2 -2
  17. package/dist/{chunk-YX3OQBNX.js → chunk-EQ7DK2TG.js} +9 -5
  18. package/dist/{chunk-BVVCRIVM.js → chunk-GZTMCTUS.js} +3 -3
  19. package/dist/chunk-HNHSUQCN.js +7 -0
  20. package/dist/{chunk-3QQAIUZI.js → chunk-HYPXL7K5.js} +175 -30
  21. package/dist/{chunk-6RGACY4E.js → chunk-HZSKKJHQ.js} +4 -3
  22. package/dist/{chunk-VWEATA7R.js → chunk-KLQEL2DZ.js} +7 -1
  23. package/dist/{chunk-JGWHRYWG.js → chunk-MKWS7TQH.js} +2 -2
  24. package/dist/{chunk-37QLXLML.js → chunk-QJWTBVJO.js} +14 -14
  25. package/dist/{chunk-6KPJLELC.js → chunk-QQVPUZQB.js} +156 -20
  26. package/dist/{chunk-TFF5T3K3.js → chunk-SQLJRO3J.js} +3 -3
  27. package/dist/{chunk-ERNWAKUB.js → chunk-TGVDUK4N.js} +2 -2
  28. package/dist/{chunk-3NPLERPQ.js → chunk-U4HMAYAD.js} +9 -8
  29. package/dist/{chunk-V4IE7HJY.js → chunk-W7VIYHPQ.js} +2 -2
  30. package/dist/{chunk-BWVO5WFK.js → chunk-X3XKYGUN.js} +3 -3
  31. package/dist/{chunk-5WRI5ZAA.js → chunk-YLJ4XMA6.js} +6 -2
  32. package/dist/{chunk-X25Q6RAV.js → chunk-ZKLE2Q3I.js} +1 -1
  33. package/dist/cli/dev.js +3 -3
  34. package/dist/cli/index.js +3 -3
  35. package/dist/{client-KE7EDI2D.js → client-KCNTDTIR.js} +4 -4
  36. package/dist/{client-pure-66Z6FWS6.js → client-pure-B5DHEKQJ.js} +2 -2
  37. package/dist/command-defaults/mark-done.command.md +6 -6
  38. package/dist/{compactor-SKVC2VNL.js → compactor-LAXZLPPA.js} +7 -7
  39. package/dist/{config-EAB3V4QK.js → config-TUCHLIWD.js} +2 -2
  40. package/dist/{dynamic-context-QNB4ELLP.js → dynamic-context-YHWFFP53.js} +3 -3
  41. package/dist/{events-5PLO4QJU.js → events-IVPAMMR5.js} +4 -4
  42. package/dist/{folding-CJWYFUKD.js → folding-RTGU63BW.js} +2 -2
  43. package/dist/{http-client-KLODRQC2.js → http-client-IPUW2MSW.js} +2 -2
  44. package/dist/{inspect-proxy-K6QKEYDT.js → inspect-proxy-WPEDMCG7.js} +2 -2
  45. package/dist/{install-CPOPMCSE.js → install-VA2F6X6Z.js} +2 -2
  46. package/dist/{launch-EOXVWLOP.js → launch-PAVQAWGP.js} +17 -17
  47. package/dist/{manager-LZ3JQ443.js → manager-EMLSLMMT.js} +2 -2
  48. package/dist/{model-overrides-5UVW3KTE.js → model-overrides-7F2EOA4U.js} +2 -2
  49. package/dist/{oauth-provider-52YILVUJ.js → oauth-provider-DGBC2YM6.js} +2 -2
  50. package/dist/{oauth-store-XCFXV2VM.js → oauth-store-KECHUT54.js} +2 -2
  51. package/dist/{openFolder-HX7X356L.js → openFolder-XCMSU3OI.js} +2 -2
  52. package/dist/{orchestrator-ED3KFPXO.js → orchestrator-CS3KXLZE.js} +16 -16
  53. package/dist/package.json +5 -2
  54. package/dist/{path-security-B6EZC63L.js → path-security-JTCHWYG3.js} +7 -7
  55. package/dist/{paths-F27V3S4I.js → paths-BHR7CZ7I.js} +2 -2
  56. package/dist/{permissions-K6YEA2ZZ.js → permissions-UKR524ZB.js} +2 -2
  57. package/dist/{platform-6RPPBHKH.js → platform-ECDDYMAR.js} +2 -2
  58. package/dist/{processor-226ZOTRI.js → processor-RZD4JRDX.js} +16 -16
  59. package/dist/profiles-GYHXBWPV.js +10 -0
  60. package/dist/{project-creator-VBFE35NI.js → project-creator-PMQ65NKN.js} +2 -2
  61. package/dist/{projects-AXHZOBR2.js → projects-NDPNOV6D.js} +2 -2
  62. package/dist/{protocol-JdxRpPxM.d.ts → protocol-CfUkCYxF.d.ts} +11 -2
  63. package/dist/{protocol-RKSWKNXI.js → protocol-HYA5BYVN.js} +8 -4
  64. package/dist/{provider-DL4ZWQY7.js → provider-Q7J4UFTS.js} +7 -7
  65. package/dist/{provider-manager-6CLRMGDE.js → provider-manager-TMBO4DFG.js} +5 -5
  66. package/dist/{pwa-XPHP3PY2.js → pwa-2GRFSXD7.js} +3 -3
  67. package/dist/{registry-5XI5NDBF.js → registry-5QL3BOWN.js} +2 -2
  68. package/dist/{serve-DARV4NJG.js → serve-KR22J37W.js} +22 -22
  69. package/dist/server/index.d.ts +15 -2
  70. package/dist/server/index.js +21 -21
  71. package/dist/{server-LQJ7MBDS.js → server-ESKTIZL5.js} +20 -20
  72. package/dist/{service-4JKTGPRG.js → service-M7XJHAK4.js} +6 -6
  73. package/dist/{service-CXWJQFOZ.js → service-WKABQHKL.js} +2 -2
  74. package/dist/{session-overrides-AZKV6BRD.js → session-overrides-CWBKPHMF.js} +4 -4
  75. package/dist/{sessions-752IZIIK.js → sessions-I7ELDIIP.js} +5 -3
  76. package/dist/{settings-2AHDKCD7.js → settings-FGXQHKUH.js} +2 -2
  77. package/dist/shared/index.d.ts +1 -1
  78. package/dist/shared/index.js +2 -2
  79. package/dist/{store-SARB6V2N.js → store-JYPZ2RXB.js} +2 -2
  80. package/dist/{tasks-XJXHU623.js → tasks-X5H5HM4J.js} +6 -6
  81. package/dist/{tool-adapter-FEAHWU5C.js → tool-adapter-FJAFLDZA.js} +2 -2
  82. package/dist/{tools-QYYNFMGU.js → tools-KBS6X3EN.js} +14 -14
  83. package/dist/{update-2REP2WB6.js → update-TDS6LP5N.js} +4 -4
  84. package/dist/{update-server-LOOXIXDW.js → update-server-SVPV6ZJZ.js} +2 -2
  85. package/dist/{url-utils-SAJP7AEX.js → url-utils-C5BM7NF7.js} +2 -2
  86. package/dist/web/assets/index-ChtRS33s.js +324 -0
  87. package/dist/web/assets/{index-BmILAZrT.css → index-c43YT-4A.css} +1 -1
  88. package/dist/web/index.html +2 -2
  89. package/dist/web/sw.js +1 -1
  90. package/dist/workflow-defaults/default.workflow.json +2 -2
  91. package/dist/{workspace-RMZVTFJD.js → workspace-IQLLHMYR.js} +2 -2
  92. package/package.json +5 -2
  93. package/dist/chunk-5V3BF67X.js +0 -7
  94. package/dist/profiles-5J7F4BML.js +0 -10
  95. package/dist/web/assets/index-M7ToECa4.js +0 -324
@@ -0,0 +1,324 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-DA-rfuFy.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/angular-ts-BrjP3tb8.js","assets/scss-D5BDwBP9.js","assets/apl-CORt7UWP.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-HNnZUWAn.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-2xfisSek.js","assets/html-derivative-DlHx6ybY.js","assets/sql-CRqJ_cUM.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nBiQ_Alo.js","assets/coffee-Ch7k5sss.js","assets/cpp-UfJy6YNI.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-DGywbUpC.js","assets/shellscript-Yzrsuije.js","assets/edge-FbVlp4U3.js","assets/elixir-CkH2-t6x.js","assets/elm-DbKCFpqz.js","assets/erb-Dm6A9KJ5.js","assets/ruby-DyJCeAvU.js","assets/haml-D5jkg6IW.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-ByusRIyA.js","assets/glimmer-ts-BfAWNZQY.js","assets/hack-DbPARsA_.js","assets/handlebars-BpdQsYii.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-f2NsQr07.js","assets/jison-wvAkD_A8.js","assets/julia-D7OTSIA_.js","assets/r-Dspwwk_N.js","assets/just-CUsbIsdP.js","assets/perl-B9cMNwum.js","assets/latex-CaSxy8MP.js","assets/tex-idrVyKtj.js","assets/liquid-C0sCDyMI.js","assets/marko-DjSrsDqO.js","assets/less-B1dDrJ26.js","assets/mdc-DTYItulj.js","assets/nextflow-C-mBbutL.js","assets/nextflow-groovy-vE_lwT2v.js","assets/nginx-BpAMiNFr.js","assets/nim-BIad80T-.js","assets/php-Csjmro_R.js","assets/pug-DKIMFp6K.js","assets/qml-3beO22l8.js","assets/razor-BjBPvh-w.js","assets/csharp-DSvCPggb.js","assets/rst-CpCqk9r5.js","assets/cmake-D1j8_8rp.js","assets/sas-DEy46yEz.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-8wufbnw4.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-DI20mbqo.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-Cy7k_4gC.js","assets/templ-DhtptRzy.js","assets/go-C27-OAKa.js","assets/ts-tags-D351s5mN.js","assets/twig-CW1WmMYd.js","assets/vue-D2xRrEX4.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-BoDAl6tE.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js"])))=>i.map(i=>d[i]);
2
+ var QR=Object.defineProperty;var JR=Object.getPrototypeOf;var ZR=Reflect.get;var xw=e=>{throw TypeError(e)};var eD=(e,t,n)=>t in e?QR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Le=(e,t,n)=>eD(e,typeof t!="symbol"?t+"":t,n),Cg=(e,t,n)=>t.has(e)||xw("Cannot "+n);var cr=(e,t,n)=>(Cg(e,t,"read from private field"),n?n.call(e):t.get(e)),Da=(e,t,n)=>t.has(e)?xw("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),us=(e,t,n,r)=>(Cg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),kg=(e,t,n)=>(Cg(e,t,"access private method"),n);var yw=(e,t,n)=>ZR(JR(e),n,t);function tD(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function kf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jg={exports:{}},Lc={};/**
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 bw;function nD(){if(bw)return Lc;bw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var u in a)u!=="key"&&(o[u]=a[u])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:c,ref:a!==void 0?a:null,props:o}}return Lc.Fragment=t,Lc.jsx=n,Lc.jsxs=n,Lc}var vw;function rD(){return vw||(vw=1,jg.exports=nD()),jg.exports}var s=rD(),Eg={exports:{}},bt={};/**
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 _w;function sD(){if(_w)return bt;_w=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function x(D){return D===null||typeof D!="object"?null:(D=g&&D[g]||D["@@iterator"],typeof D=="function"?D:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,b={};function _(D,U,$){this.props=D,this.context=U,this.refs=b,this.updater=$||w}_.prototype.isReactComponent={},_.prototype.setState=function(D,U){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,U,"setState")},_.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function S(){}S.prototype=_.prototype;function v(D,U,$){this.props=D,this.context=U,this.refs=b,this.updater=$||w}var k=v.prototype=new S;k.constructor=v,C(k,_.prototype),k.isPureReactComponent=!0;var E=Array.isArray;function N(){}var L={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function O(D,U,$){var Q=$.ref;return{$$typeof:e,type:D,key:U,ref:Q!==void 0?Q:null,props:$}}function I(D,U){return O(D.type,U,D.props)}function F(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function B(D){var U={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function($){return U[$]})}var z=/\/+/g;function Y(D,U){return typeof D=="object"&&D!==null&&D.key!=null?B(""+D.key):U.toString(36)}function q(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(N,N):(D.status="pending",D.then(function(U){D.status==="pending"&&(D.status="fulfilled",D.value=U)},function(U){D.status==="pending"&&(D.status="rejected",D.reason=U)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function W(D,U,$,Q,K){var Z=typeof D;(Z==="undefined"||Z==="boolean")&&(D=null);var V=!1;if(D===null)V=!0;else switch(Z){case"bigint":case"string":case"number":V=!0;break;case"object":switch(D.$$typeof){case e:case t:V=!0;break;case m:return V=D._init,W(V(D._payload),U,$,Q,K)}}if(V)return K=K(D),V=Q===""?"."+Y(D,0):Q,E(K)?($="",V!=null&&($=V.replace(z,"$&/")+"/"),W(K,U,$,"",function(ne){return ne})):K!=null&&(F(K)&&(K=I(K,$+(K.key==null||D&&D.key===K.key?"":(""+K.key).replace(z,"$&/")+"/")+V)),U.push(K)),1;V=0;var M=Q===""?".":Q+":";if(E(D))for(var X=0;X<D.length;X++)Q=D[X],Z=M+Y(Q,X),V+=W(Q,U,$,Z,K);else if(X=x(D),typeof X=="function")for(D=X.call(D),X=0;!(Q=D.next()).done;)Q=Q.value,Z=M+Y(Q,X++),V+=W(Q,U,$,Z,K);else if(Z==="object"){if(typeof D.then=="function")return W(q(D),U,$,Q,K);throw U=String(D),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return V}function ee(D,U,$){if(D==null)return D;var Q=[],K=0;return W(D,Q,"","",function(Z){return U.call($,Z,K++)}),Q}function J(D){if(D._status===-1){var U=D._result;U=U(),U.then(function($){(D._status===0||D._status===-1)&&(D._status=1,D._result=$)},function($){(D._status===0||D._status===-1)&&(D._status=2,D._result=$)}),D._status===-1&&(D._status=0,D._result=U)}if(D._status===1)return D._result.default;throw D._result}var H=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},P={map:ee,forEach:function(D,U,$){ee(D,function(){U.apply(this,arguments)},$)},count:function(D){var U=0;return ee(D,function(){U++}),U},toArray:function(D){return ee(D,function(U){return U})||[]},only:function(D){if(!F(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return bt.Activity=f,bt.Children=P,bt.Component=_,bt.Fragment=n,bt.Profiler=a,bt.PureComponent=v,bt.StrictMode=r,bt.Suspense=d,bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,bt.__COMPILER_RUNTIME={__proto__:null,c:function(D){return L.H.useMemoCache(D)}},bt.cache=function(D){return function(){return D.apply(null,arguments)}},bt.cacheSignal=function(){return null},bt.cloneElement=function(D,U,$){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var Q=C({},D.props),K=D.key;if(U!=null)for(Z in U.key!==void 0&&(K=""+U.key),U)!A.call(U,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&U.ref===void 0||(Q[Z]=U[Z]);var Z=arguments.length-2;if(Z===1)Q.children=$;else if(1<Z){for(var V=Array(Z),M=0;M<Z;M++)V[M]=arguments[M+2];Q.children=V}return O(D.type,K,Q)},bt.createContext=function(D){return D={$$typeof:c,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:o,_context:D},D},bt.createElement=function(D,U,$){var Q,K={},Z=null;if(U!=null)for(Q in U.key!==void 0&&(Z=""+U.key),U)A.call(U,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(K[Q]=U[Q]);var V=arguments.length-2;if(V===1)K.children=$;else if(1<V){for(var M=Array(V),X=0;X<V;X++)M[X]=arguments[X+2];K.children=M}if(D&&D.defaultProps)for(Q in V=D.defaultProps,V)K[Q]===void 0&&(K[Q]=V[Q]);return O(D,Z,K)},bt.createRef=function(){return{current:null}},bt.forwardRef=function(D){return{$$typeof:u,render:D}},bt.isValidElement=F,bt.lazy=function(D){return{$$typeof:m,_payload:{_status:-1,_result:D},_init:J}},bt.memo=function(D,U){return{$$typeof:h,type:D,compare:U===void 0?null:U}},bt.startTransition=function(D){var U=L.T,$={};L.T=$;try{var Q=D(),K=L.S;K!==null&&K($,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(N,H)}catch(Z){H(Z)}finally{U!==null&&$.types!==null&&(U.types=$.types),L.T=U}},bt.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},bt.use=function(D){return L.H.use(D)},bt.useActionState=function(D,U,$){return L.H.useActionState(D,U,$)},bt.useCallback=function(D,U){return L.H.useCallback(D,U)},bt.useContext=function(D){return L.H.useContext(D)},bt.useDebugValue=function(){},bt.useDeferredValue=function(D,U){return L.H.useDeferredValue(D,U)},bt.useEffect=function(D,U){return L.H.useEffect(D,U)},bt.useEffectEvent=function(D){return L.H.useEffectEvent(D)},bt.useId=function(){return L.H.useId()},bt.useImperativeHandle=function(D,U,$){return L.H.useImperativeHandle(D,U,$)},bt.useInsertionEffect=function(D,U){return L.H.useInsertionEffect(D,U)},bt.useLayoutEffect=function(D,U){return L.H.useLayoutEffect(D,U)},bt.useMemo=function(D,U){return L.H.useMemo(D,U)},bt.useOptimistic=function(D,U){return L.H.useOptimistic(D,U)},bt.useReducer=function(D,U,$){return L.H.useReducer(D,U,$)},bt.useRef=function(D){return L.H.useRef(D)},bt.useState=function(D){return L.H.useState(D)},bt.useSyncExternalStore=function(D,U,$){return L.H.useSyncExternalStore(D,U,$)},bt.useTransition=function(){return L.H.useTransition()},bt.version="19.2.8",bt}var Sw;function jf(){return Sw||(Sw=1,Eg.exports=sD()),Eg.exports}var j=jf();const ps=kf(j),iD=tD({__proto__:null,default:ps},[j]);var Ng={exports:{}},Rc={},Tg={exports:{}},Ag={};/**
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 ww;function aD(){return ww||(ww=1,(function(e){function t(W,ee){var J=W.length;W.push(ee);e:for(;0<J;){var H=J-1>>>1,P=W[H];if(0<a(P,ee))W[H]=ee,W[J]=P,J=H;else break e}}function n(W){return W.length===0?null:W[0]}function r(W){if(W.length===0)return null;var ee=W[0],J=W.pop();if(J!==ee){W[0]=J;e:for(var H=0,P=W.length,D=P>>>1;H<D;){var U=2*(H+1)-1,$=W[U],Q=U+1,K=W[Q];if(0>a($,J))Q<P&&0>a(K,$)?(W[H]=K,W[Q]=J,H=Q):(W[H]=$,W[U]=J,H=U);else if(Q<P&&0>a(K,J))W[H]=K,W[Q]=J,H=Q;else break e}}return ee}function a(W,ee){var J=W.sortIndex-ee.sortIndex;return J!==0?J:W.id-ee.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var d=[],h=[],m=1,f=null,g=3,x=!1,w=!1,C=!1,b=!1,_=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;function k(W){for(var ee=n(h);ee!==null;){if(ee.callback===null)r(h);else if(ee.startTime<=W)r(h),ee.sortIndex=ee.expirationTime,t(d,ee);else break;ee=n(h)}}function E(W){if(C=!1,k(W),!w)if(n(d)!==null)w=!0,N||(N=!0,B());else{var ee=n(h);ee!==null&&q(E,ee.startTime-W)}}var N=!1,L=-1,A=5,O=-1;function I(){return b?!0:!(e.unstable_now()-O<A)}function F(){if(b=!1,N){var W=e.unstable_now();O=W;var ee=!0;try{e:{w=!1,C&&(C=!1,S(L),L=-1),x=!0;var J=g;try{t:{for(k(W),f=n(d);f!==null&&!(f.expirationTime>W&&I());){var H=f.callback;if(typeof H=="function"){f.callback=null,g=f.priorityLevel;var P=H(f.expirationTime<=W);if(W=e.unstable_now(),typeof P=="function"){f.callback=P,k(W),ee=!0;break t}f===n(d)&&r(d),k(W)}else r(d);f=n(d)}if(f!==null)ee=!0;else{var D=n(h);D!==null&&q(E,D.startTime-W),ee=!1}}break e}finally{f=null,g=J,x=!1}ee=void 0}}finally{ee?B():N=!1}}}var B;if(typeof v=="function")B=function(){v(F)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,Y=z.port2;z.port1.onmessage=F,B=function(){Y.postMessage(null)}}else B=function(){_(F,0)};function q(W,ee){L=_(function(){W(e.unstable_now())},ee)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(W){W.callback=null},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(W){switch(g){case 1:case 2:case 3:var ee=3;break;default:ee=g}var J=g;g=ee;try{return W()}finally{g=J}},e.unstable_requestPaint=function(){b=!0},e.unstable_runWithPriority=function(W,ee){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var J=g;g=W;try{return ee()}finally{g=J}},e.unstable_scheduleCallback=function(W,ee,J){var H=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?H+J:H):J=H,W){case 1:var P=-1;break;case 2:P=250;break;case 5:P=1073741823;break;case 4:P=1e4;break;default:P=5e3}return P=J+P,W={id:m++,callback:ee,priorityLevel:W,startTime:J,expirationTime:P,sortIndex:-1},J>H?(W.sortIndex=J,t(h,W),n(d)===null&&W===n(h)&&(C?(S(L),L=-1):C=!0,q(E,J-H))):(W.sortIndex=P,t(d,W),w||x||(w=!0,N||(N=!0,B()))),W},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(W){var ee=g;return function(){var J=g;g=ee;try{return W.apply(this,arguments)}finally{g=J}}}})(Ag)),Ag}var Cw;function oD(){return Cw||(Cw=1,Tg.exports=aD()),Tg.exports}var Lg={exports:{}},Zn={};/**
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 kw;function lD(){if(kw)return Zn;kw=1;var e=jf();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)h+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+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 o(d,h,m){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:f==null?null:""+f,children:d,containerInfo:h,implementation:m}}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 Zn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Zn.createPortal=function(d,h){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return o(d,h,null,m)},Zn.flushSync=function(d){var h=c.T,m=r.p;try{if(c.T=null,r.p=2,d)return d()}finally{c.T=h,r.p=m,r.d.f()}},Zn.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))},Zn.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},Zn.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var m=h.as,f=u(m,h.crossOrigin),g=typeof h.integrity=="string"?h.integrity:void 0,x=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;m==="style"?r.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:x}):m==="script"&&r.d.X(d,{crossOrigin:f,integrity:g,fetchPriority:x,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Zn.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var m=u(h.as,h.crossOrigin);r.d.M(d,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(d)},Zn.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var m=h.as,f=u(m,h.crossOrigin);r.d.L(d,m,{crossOrigin:f,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Zn.preloadModule=function(d,h){if(typeof d=="string")if(h){var m=u(h.as,h.crossOrigin);r.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(d)},Zn.requestFormReset=function(d){r.d.r(d)},Zn.unstable_batchedUpdates=function(d,h){return d(h)},Zn.useFormState=function(d,h,m){return c.H.useFormState(d,h,m)},Zn.useFormStatus=function(){return c.H.useHostTransitionStatus()},Zn.version="19.2.8",Zn}var jw;function rj(){if(jw)return Lg.exports;jw=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=lD(),Lg.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 Ew;function cD(){if(Ew)return Rc;Ew=1;var e=oD(),t=jf(),n=rj();function r(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function o(i){var l=i,p=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(p=l.return),i=l.return;while(i)}return l.tag===3?p:null}function c(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function u(i){if(i.tag===31){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function d(i){if(o(i)!==i)throw Error(r(188))}function h(i){var l=i.alternate;if(!l){if(l=o(i),l===null)throw Error(r(188));return l!==i?null:i}for(var p=i,y=l;;){var T=p.return;if(T===null)break;var R=T.alternate;if(R===null){if(y=T.return,y!==null){p=y;continue}break}if(T.child===R.child){for(R=T.child;R;){if(R===p)return d(T),i;if(R===y)return d(T),l;R=R.sibling}throw Error(r(188))}if(p.return!==y.return)p=T,y=R;else{for(var G=!1,te=T.child;te;){if(te===p){G=!0,p=T,y=R;break}if(te===y){G=!0,y=T,p=R;break}te=te.sibling}if(!G){for(te=R.child;te;){if(te===p){G=!0,p=R,y=T;break}if(te===y){G=!0,y=R,p=T;break}te=te.sibling}if(!G)throw Error(r(189))}}if(p.alternate!==y)throw Error(r(190))}if(p.tag!==3)throw Error(r(188));return p.stateNode.current===p?i:l}function m(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=m(i),l!==null)return l;i=i.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),v=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),I=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function B(i){return i===null||typeof i!="object"?null:(i=F&&i[F]||i["@@iterator"],typeof i=="function"?i:null)}var z=Symbol.for("react.client.reference");function Y(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===z?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case _:return"Profiler";case b:return"StrictMode";case E:return"Suspense";case N:return"SuspenseList";case O:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case v:return i.displayName||"Context";case S:return(i._context.displayName||"Context")+".Consumer";case k:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case L:return l=i.displayName||null,l!==null?l:Y(i.type)||"Memo";case A:l=i._payload,i=i._init;try{return Y(i(l))}catch{}}return null}var q=Array.isArray,W=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},H=[],P=-1;function D(i){return{current:i}}function U(i){0>P||(i.current=H[P],H[P]=null,P--)}function $(i,l){P++,H[P]=i.current,i.current=l}var Q=D(null),K=D(null),Z=D(null),V=D(null);function M(i,l){switch($(Z,l),$(K,i),$(Q,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?FS(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=FS(l),i=zS(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}U(Q),$(Q,i)}function X(){U(Q),U(K),U(Z)}function ne(i){i.memoizedState!==null&&$(V,i);var l=Q.current,p=zS(l,i.type);l!==p&&($(K,i),$(Q,p))}function re(i){K.current===i&&(U(Q),U(K)),V.current===i&&(U(V),Ec._currentValue=J)}var ie,ge;function ke(i){if(ie===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);ie=l&&l[1]||"",ge=-1<p.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+ie+i+ge}var Oe=!1;function Fe(i,l){if(!i||Oe)return"";Oe=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var y={DetermineComponentFrameRoot:function(){try{if(l){var $e=function(){throw Error()};if(Object.defineProperty($e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct($e,[])}catch(je){var Ce=je}Reflect.construct(i,[],$e)}else{try{$e.call()}catch(je){Ce=je}i.call($e.prototype)}}else{try{throw Error()}catch(je){Ce=je}($e=i())&&typeof $e.catch=="function"&&$e.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 R=y.DetermineComponentFrameRoot(),G=R[0],te=R[1];if(G&&te){var le=G.split(`
45
+ `),ve=te.split(`
46
+ `);for(T=y=0;y<le.length&&!le[y].includes("DetermineComponentFrameRoot");)y++;for(;T<ve.length&&!ve[T].includes("DetermineComponentFrameRoot");)T++;if(y===le.length||T===ve.length)for(y=le.length-1,T=ve.length-1;1<=y&&0<=T&&le[y]!==ve[T];)T--;for(;1<=y&&0<=T;y--,T--)if(le[y]!==ve[T]){if(y!==1||T!==1)do if(y--,T--,0>T||le[y]!==ve[T]){var Ie=`
47
+ `+le[y].replace(" at new "," at ");return i.displayName&&Ie.includes("<anonymous>")&&(Ie=Ie.replace("<anonymous>",i.displayName)),Ie}while(1<=y&&0<=T);break}}}finally{Oe=!1,Error.prepareStackTrace=p}return(p=i?i.displayName||i.name:"")?ke(p):""}function we(i,l){switch(i.tag){case 26:case 27:case 5:return ke(i.type);case 16:return ke("Lazy");case 13:return i.child!==l&&l!==null?ke("Suspense Fallback"):ke("Suspense");case 19:return ke("SuspenseList");case 0:case 15:return Fe(i.type,!1);case 11:return Fe(i.type.render,!1);case 1:return Fe(i.type,!0);case 31:return ke("Activity");default:return""}}function We(i){try{var l="",p=null;do l+=we(i,p),p=i,i=i.return;while(i);return l}catch(y){return`
48
+ Error generating stack: `+y.message+`
49
+ `+y.stack}}var Xe=Object.prototype.hasOwnProperty,_e=e.unstable_scheduleCallback,ye=e.unstable_cancelCallback,fe=e.unstable_shouldYield,oe=e.unstable_requestPaint,Me=e.unstable_now,He=e.unstable_getCurrentPriorityLevel,he=e.unstable_ImmediatePriority,Te=e.unstable_UserBlockingPriority,Qe=e.unstable_NormalPriority,me=e.unstable_LowPriority,ze=e.unstable_IdlePriority,at=e.log,Ze=e.unstable_setDisableYieldValue,et=null,ot=null;function ce(i){if(typeof at=="function"&&Ze(i),ot&&typeof ot.setStrictMode=="function")try{ot.setStrictMode(et,i)}catch{}}var ae=Math.clz32?Math.clz32:dt,Re=Math.log,Ve=Math.LN2;function dt(i){return i>>>=0,i===0?32:31-(Re(i)/Ve|0)|0}var vt=256,wt=262144,an=4194304;function on(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function fn(i,l,p){var y=i.pendingLanes;if(y===0)return 0;var T=0,R=i.suspendedLanes,G=i.pingedLanes;i=i.warmLanes;var te=y&134217727;return te!==0?(y=te&~R,y!==0?T=on(y):(G&=te,G!==0?T=on(G):p||(p=te&~i,p!==0&&(T=on(p))))):(te=y&~R,te!==0?T=on(te):G!==0?T=on(G):p||(p=y&~i,p!==0&&(T=on(p)))),T===0?0:l!==0&&l!==T&&(l&R)===0&&(R=T&-T,p=l&-l,R>=p||R===32&&(p&4194048)!==0)?l:T}function zn(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function bn(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function gn(){var i=an;return an<<=1,(an&62914560)===0&&(an=4194304),i}function hr(i){for(var l=[],p=0;31>p;p++)l.push(i);return l}function Se(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function tt(i,l,p,y,T,R){var G=i.pendingLanes;i.pendingLanes=p,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=p,i.entangledLanes&=p,i.errorRecoveryDisabledLanes&=p,i.shellSuspendCounter=0;var te=i.entanglements,le=i.expirationTimes,ve=i.hiddenUpdates;for(p=G&~p;0<p;){var Ie=31-ae(p),$e=1<<Ie;te[Ie]=0,le[Ie]=-1;var Ce=ve[Ie];if(Ce!==null)for(ve[Ie]=null,Ie=0;Ie<Ce.length;Ie++){var je=Ce[Ie];je!==null&&(je.lane&=-536870913)}p&=~$e}y!==0&&Ye(i,y,0),R!==0&&T===0&&i.tag!==0&&(i.suspendedLanes|=R&~(G&~l))}function Ye(i,l,p){i.pendingLanes|=l,i.suspendedLanes&=~l;var y=31-ae(l);i.entangledLanes|=l,i.entanglements[y]=i.entanglements[y]|1073741824|p&261930}function Ue(i,l){var p=i.entangledLanes|=l;for(i=i.entanglements;p;){var y=31-ae(p),T=1<<y;T&l|i[y]&l&&(i[y]|=l),p&=~T}}function ue(i,l){var p=l&-l;return p=(p&42)!==0?1:Ke(p),(p&(i.suspendedLanes|l))!==0?0:p}function Ke(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function mt(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Dt(){var i=ee.p;return i!==0?i:(i=window.event,i===void 0?32:uw(i.type))}function Ee(i,l){var p=ee.p;try{return ee.p=i,l()}finally{ee.p=p}}var Ae=Math.random().toString(36).slice(2),Be="__reactFiber$"+Ae,Je="__reactProps$"+Ae,nt="__reactContainer$"+Ae,gt="__reactEvents$"+Ae,kt="__reactListeners$"+Ae,Mn="__reactHandles$"+Ae,Cn="__reactResources$"+Ae,Nn="__reactMarker$"+Ae;function ho(i){delete i[Be],delete i[Je],delete i[gt],delete i[kt],delete i[Mn]}function fo(i){var l=i[Be];if(l)return l;for(var p=i.parentNode;p;){if(l=p[nt]||p[Be]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(i=KS(i);i!==null;){if(p=i[Be])return p;i=KS(i)}return l}i=p,p=i.parentNode}return null}function mo(i){if(i=i[Be]||i[nt]){var l=i.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return i}return null}function Ul(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i.stateNode;throw Error(r(33))}function po(i){var l=i[Cn];return l||(l=i[Cn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function Hn(i){i[Nn]=!0}var Nv=new Set,Tv={};function ga(i,l){go(i,l),go(i+"Capture",l)}function go(i,l){for(Tv[i]=l,i=0;i<l.length;i++)Nv.add(l[i])}var HA=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]*$"),Av={},Lv={};function UA(i){return Xe.call(Lv,i)?!0:Xe.call(Av,i)?!1:HA.test(i)?Lv[i]=!0:(Av[i]=!0,!1)}function $u(i,l,p){if(UA(l))if(p===null)i.removeAttribute(l);else{switch(typeof p){case"undefined":case"function":case"symbol":i.removeAttribute(l);return;case"boolean":var y=l.toLowerCase().slice(0,5);if(y!=="data-"&&y!=="aria-"){i.removeAttribute(l);return}}i.setAttribute(l,""+p)}}function Fu(i,l,p){if(p===null)i.removeAttribute(l);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(l);return}i.setAttribute(l,""+p)}}function Us(i,l,p,y){if(y===null)i.removeAttribute(p);else{switch(typeof y){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(p);return}i.setAttributeNS(l,p,""+y)}}function zr(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 l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function VA(i,l,p){var y=Object.getOwnPropertyDescriptor(i.constructor.prototype,l);if(!i.hasOwnProperty(l)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var T=y.get,R=y.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return T.call(this)},set:function(G){p=""+G,R.call(this,G)}}),Object.defineProperty(i,l,{enumerable:y.enumerable}),{getValue:function(){return p},setValue:function(G){p=""+G},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function xm(i){if(!i._valueTracker){var l=Rv(i)?"checked":"value";i._valueTracker=VA(i,l,""+i[l])}}function Dv(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var p=l.getValue(),y="";return i&&(y=Rv(i)?i.checked?"true":"false":i.value),i=y,i!==p?(l.setValue(i),!0):!1}function zu(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 WA=/[\n"\\]/g;function Hr(i){return i.replace(WA,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function ym(i,l,p,y,T,R,G,te){i.name="",G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"?i.type=G:i.removeAttribute("type"),l!=null?G==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+zr(l)):i.value!==""+zr(l)&&(i.value=""+zr(l)):G!=="submit"&&G!=="reset"||i.removeAttribute("value"),l!=null?bm(i,G,zr(l)):p!=null?bm(i,G,zr(p)):y!=null&&i.removeAttribute("value"),T==null&&R!=null&&(i.defaultChecked=!!R),T!=null&&(i.checked=T&&typeof T!="function"&&typeof T!="symbol"),te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"?i.name=""+zr(te):i.removeAttribute("name")}function Ov(i,l,p,y,T,R,G,te){if(R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(i.type=R),l!=null||p!=null){if(!(R!=="submit"&&R!=="reset"||l!=null)){xm(i);return}p=p!=null?""+zr(p):"",l=l!=null?""+zr(l):p,te||l===i.value||(i.value=l),i.defaultValue=l}y=y??T,y=typeof y!="function"&&typeof y!="symbol"&&!!y,i.checked=te?i.checked:!!y,i.defaultChecked=!!y,G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"&&(i.name=G),xm(i)}function bm(i,l,p){l==="number"&&zu(i.ownerDocument)===i||i.defaultValue===""+p||(i.defaultValue=""+p)}function xo(i,l,p,y){if(i=i.options,l){l={};for(var T=0;T<p.length;T++)l["$"+p[T]]=!0;for(p=0;p<i.length;p++)T=l.hasOwnProperty("$"+i[p].value),i[p].selected!==T&&(i[p].selected=T),T&&y&&(i[p].defaultSelected=!0)}else{for(p=""+zr(p),l=null,T=0;T<i.length;T++){if(i[T].value===p){i[T].selected=!0,y&&(i[T].defaultSelected=!0);return}l!==null||i[T].disabled||(l=i[T])}l!==null&&(l.selected=!0)}}function Iv(i,l,p){if(l!=null&&(l=""+zr(l),l!==i.value&&(i.value=l),p==null)){i.defaultValue!==l&&(i.defaultValue=l);return}i.defaultValue=p!=null?""+zr(p):""}function Mv(i,l,p,y){if(l==null){if(y!=null){if(p!=null)throw Error(r(92));if(q(y)){if(1<y.length)throw Error(r(93));y=y[0]}p=y}p==null&&(p=""),l=p}p=zr(l),i.defaultValue=p,y=i.textContent,y===p&&y!==""&&y!==null&&(i.value=y),xm(i)}function yo(i,l){if(l){var p=i.firstChild;if(p&&p===i.lastChild&&p.nodeType===3){p.nodeValue=l;return}}i.textContent=l}var GA=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 Pv(i,l,p){var y=l.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?y?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="":y?i.setProperty(l,p):typeof p!="number"||p===0||GA.has(l)?l==="float"?i.cssFloat=p:i[l]=(""+p).trim():i[l]=p+"px"}function Bv(i,l,p){if(l!=null&&typeof l!="object")throw Error(r(62));if(i=i.style,p!=null){for(var y in p)!p.hasOwnProperty(y)||l!=null&&l.hasOwnProperty(y)||(y.indexOf("--")===0?i.setProperty(y,""):y==="float"?i.cssFloat="":i[y]="");for(var T in l)y=l[T],l.hasOwnProperty(T)&&p[T]!==y&&Pv(i,T,y)}else for(var R in l)l.hasOwnProperty(R)&&Pv(i,R,l[R])}function vm(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 qA=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"]]),KA=/^[\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 Hu(i){return KA.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Vs(){}var _m=null;function Sm(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var bo=null,vo=null;function $v(i){var l=mo(i);if(l&&(i=l.stateNode)){var p=i[Je]||null;e:switch(i=l.stateNode,l.type){case"input":if(ym(i,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),l=p.name,p.type==="radio"&&l!=null){for(p=i;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+Hr(""+l)+'"][type="radio"]'),l=0;l<p.length;l++){var y=p[l];if(y!==i&&y.form===i.form){var T=y[Je]||null;if(!T)throw Error(r(90));ym(y,T.value,T.defaultValue,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name)}}for(l=0;l<p.length;l++)y=p[l],y.form===i.form&&Dv(y)}break e;case"textarea":Iv(i,p.value,p.defaultValue);break e;case"select":l=p.value,l!=null&&xo(i,!!p.multiple,l,!1)}}}var wm=!1;function Fv(i,l,p){if(wm)return i(l,p);wm=!0;try{var y=i(l);return y}finally{if(wm=!1,(bo!==null||vo!==null)&&(Td(),bo&&(l=bo,i=vo,vo=bo=null,$v(l),i)))for(l=0;l<i.length;l++)$v(i[l])}}function Vl(i,l){var p=i.stateNode;if(p===null)return null;var y=p[Je]||null;if(y===null)return null;p=y[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(i=i.type,y=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!y;break e;default:i=!1}if(i)return null;if(p&&typeof p!="function")throw Error(r(231,l,typeof p));return p}var Ws=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cm=!1;if(Ws)try{var Wl={};Object.defineProperty(Wl,"passive",{get:function(){Cm=!0}}),window.addEventListener("test",Wl,Wl),window.removeEventListener("test",Wl,Wl)}catch{Cm=!1}var ki=null,km=null,Uu=null;function zv(){if(Uu)return Uu;var i,l=km,p=l.length,y,T="value"in ki?ki.value:ki.textContent,R=T.length;for(i=0;i<p&&l[i]===T[i];i++);var G=p-i;for(y=1;y<=G&&l[p-y]===T[R-y];y++);return Uu=T.slice(i,1<y?1-y:void 0)}function Vu(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function Wu(){return!0}function Hv(){return!1}function fr(i){function l(p,y,T,R,G){this._reactName=p,this._targetInst=T,this.type=y,this.nativeEvent=R,this.target=G,this.currentTarget=null;for(var te in i)i.hasOwnProperty(te)&&(p=i[te],this[te]=p?p(R):R[te]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?Wu:Hv,this.isPropagationStopped=Hv,this}return f(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Wu)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Wu)},persist:function(){},isPersistent:Wu}),l}var xa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gu=fr(xa),Gl=f({},xa,{view:0,detail:0}),YA=fr(Gl),jm,Em,ql,qu=f({},Gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tm,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!==ql&&(ql&&i.type==="mousemove"?(jm=i.screenX-ql.screenX,Em=i.screenY-ql.screenY):Em=jm=0,ql=i),jm)},movementY:function(i){return"movementY"in i?i.movementY:Em}}),Uv=fr(qu),XA=f({},qu,{dataTransfer:0}),QA=fr(XA),JA=f({},Gl,{relatedTarget:0}),Nm=fr(JA),ZA=f({},xa,{animationName:0,elapsedTime:0,pseudoElement:0}),eL=fr(ZA),tL=f({},xa,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),nL=fr(tL),rL=f({},xa,{data:0}),Vv=fr(rL),sL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},iL={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"},aL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function oL(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=aL[i])?!!l[i]:!1}function Tm(){return oL}var lL=f({},Gl,{key:function(i){if(i.key){var l=sL[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=Vu(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?iL[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tm,charCode:function(i){return i.type==="keypress"?Vu(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Vu(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),cL=fr(lL),uL=f({},qu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wv=fr(uL),dL=f({},Gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tm}),hL=fr(dL),fL=f({},xa,{propertyName:0,elapsedTime:0,pseudoElement:0}),mL=fr(fL),pL=f({},qu,{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}),gL=fr(pL),xL=f({},xa,{newState:0,oldState:0}),yL=fr(xL),bL=[9,13,27,32],Am=Ws&&"CompositionEvent"in window,Kl=null;Ws&&"documentMode"in document&&(Kl=document.documentMode);var vL=Ws&&"TextEvent"in window&&!Kl,Gv=Ws&&(!Am||Kl&&8<Kl&&11>=Kl),qv=" ",Kv=!1;function Yv(i,l){switch(i){case"keyup":return bL.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xv(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var _o=!1;function _L(i,l){switch(i){case"compositionend":return Xv(l);case"keypress":return l.which!==32?null:(Kv=!0,qv);case"textInput":return i=l.data,i===qv&&Kv?null:i;default:return null}}function SL(i,l){if(_o)return i==="compositionend"||!Am&&Yv(i,l)?(i=zv(),Uu=km=ki=null,_o=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return Gv&&l.locale!=="ko"?null:l.data;default:return null}}var wL={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 Qv(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!wL[i.type]:l==="textarea"}function Jv(i,l,p,y){bo?vo?vo.push(y):vo=[y]:bo=y,l=Md(l,"onChange"),0<l.length&&(p=new Gu("onChange","change",null,p,y),i.push({event:p,listeners:l}))}var Yl=null,Xl=null;function CL(i){OS(i,0)}function Ku(i){var l=Ul(i);if(Dv(l))return i}function Zv(i,l){if(i==="change")return l}var e_=!1;if(Ws){var Lm;if(Ws){var Rm="oninput"in document;if(!Rm){var t_=document.createElement("div");t_.setAttribute("oninput","return;"),Rm=typeof t_.oninput=="function"}Lm=Rm}else Lm=!1;e_=Lm&&(!document.documentMode||9<document.documentMode)}function n_(){Yl&&(Yl.detachEvent("onpropertychange",r_),Xl=Yl=null)}function r_(i){if(i.propertyName==="value"&&Ku(Xl)){var l=[];Jv(l,Xl,i,Sm(i)),Fv(CL,l)}}function kL(i,l,p){i==="focusin"?(n_(),Yl=l,Xl=p,Yl.attachEvent("onpropertychange",r_)):i==="focusout"&&n_()}function jL(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ku(Xl)}function EL(i,l){if(i==="click")return Ku(l)}function NL(i,l){if(i==="input"||i==="change")return Ku(l)}function TL(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var jr=typeof Object.is=="function"?Object.is:TL;function Ql(i,l){if(jr(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var p=Object.keys(i),y=Object.keys(l);if(p.length!==y.length)return!1;for(y=0;y<p.length;y++){var T=p[y];if(!Xe.call(l,T)||!jr(i[T],l[T]))return!1}return!0}function s_(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function i_(i,l){var p=s_(i);i=0;for(var y;p;){if(p.nodeType===3){if(y=i+p.textContent.length,i<=l&&y>=l)return{node:p,offset:l-i};i=y}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=s_(p)}}function a_(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?a_(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function o_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=zu(i.document);l instanceof i.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)i=l.contentWindow;else break;l=zu(i.document)}return l}function Dm(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var AL=Ws&&"documentMode"in document&&11>=document.documentMode,So=null,Om=null,Jl=null,Im=!1;function l_(i,l,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Im||So==null||So!==zu(y)||(y=So,"selectionStart"in y&&Dm(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}),Jl&&Ql(Jl,y)||(Jl=y,y=Md(Om,"onSelect"),0<y.length&&(l=new Gu("onSelect","select",null,l,p),i.push({event:l,listeners:y}),l.target=So)))}function ya(i,l){var p={};return p[i.toLowerCase()]=l.toLowerCase(),p["Webkit"+i]="webkit"+l,p["Moz"+i]="moz"+l,p}var wo={animationend:ya("Animation","AnimationEnd"),animationiteration:ya("Animation","AnimationIteration"),animationstart:ya("Animation","AnimationStart"),transitionrun:ya("Transition","TransitionRun"),transitionstart:ya("Transition","TransitionStart"),transitioncancel:ya("Transition","TransitionCancel"),transitionend:ya("Transition","TransitionEnd")},Mm={},c_={};Ws&&(c_=document.createElement("div").style,"AnimationEvent"in window||(delete wo.animationend.animation,delete wo.animationiteration.animation,delete wo.animationstart.animation),"TransitionEvent"in window||delete wo.transitionend.transition);function ba(i){if(Mm[i])return Mm[i];if(!wo[i])return i;var l=wo[i],p;for(p in l)if(l.hasOwnProperty(p)&&p in c_)return Mm[i]=l[p];return i}var u_=ba("animationend"),d_=ba("animationiteration"),h_=ba("animationstart"),LL=ba("transitionrun"),RL=ba("transitionstart"),DL=ba("transitioncancel"),f_=ba("transitionend"),m_=new Map,Pm="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(" ");Pm.push("scrollEnd");function os(i,l){m_.set(i,l),ga(l,[i])}var Yu=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Ur=[],Co=0,Bm=0;function Xu(){for(var i=Co,l=Bm=Co=0;l<i;){var p=Ur[l];Ur[l++]=null;var y=Ur[l];Ur[l++]=null;var T=Ur[l];Ur[l++]=null;var R=Ur[l];if(Ur[l++]=null,y!==null&&T!==null){var G=y.pending;G===null?T.next=T:(T.next=G.next,G.next=T),y.pending=T}R!==0&&p_(p,T,R)}}function Qu(i,l,p,y){Ur[Co++]=i,Ur[Co++]=l,Ur[Co++]=p,Ur[Co++]=y,Bm|=y,i.lanes|=y,i=i.alternate,i!==null&&(i.lanes|=y)}function $m(i,l,p,y){return Qu(i,l,p,y),Ju(i)}function va(i,l){return Qu(i,null,null,l),Ju(i)}function p_(i,l,p){i.lanes|=p;var y=i.alternate;y!==null&&(y.lanes|=p);for(var T=!1,R=i.return;R!==null;)R.childLanes|=p,y=R.alternate,y!==null&&(y.childLanes|=p),R.tag===22&&(i=R.stateNode,i===null||i._visibility&1||(T=!0)),i=R,R=R.return;return i.tag===3?(R=i.stateNode,T&&l!==null&&(T=31-ae(p),i=R.hiddenUpdates,y=i[T],y===null?i[T]=[l]:y.push(l),l.lane=p|536870912),R):null}function Ju(i){if(50<vc)throw vc=0,Kp=null,Error(r(185));for(var l=i.return;l!==null;)i=l,l=i.return;return i.tag===3?i.stateNode:null}var ko={};function OL(i,l,p,y){this.tag=i,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Er(i,l,p,y){return new OL(i,l,p,y)}function Fm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Gs(i,l){var p=i.alternate;return p===null?(p=Er(i.tag,l,i.key,i.mode),p.elementType=i.elementType,p.type=i.type,p.stateNode=i.stateNode,p.alternate=i,i.alternate=p):(p.pendingProps=l,p.type=i.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=i.flags&65011712,p.childLanes=i.childLanes,p.lanes=i.lanes,p.child=i.child,p.memoizedProps=i.memoizedProps,p.memoizedState=i.memoizedState,p.updateQueue=i.updateQueue,l=i.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=i.sibling,p.index=i.index,p.ref=i.ref,p.refCleanup=i.refCleanup,p}function g_(i,l){i.flags&=65011714;var p=i.alternate;return p===null?(i.childLanes=0,i.lanes=l,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=p.childLanes,i.lanes=p.lanes,i.child=p.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=p.memoizedProps,i.memoizedState=p.memoizedState,i.updateQueue=p.updateQueue,i.type=p.type,l=p.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),i}function Zu(i,l,p,y,T,R){var G=0;if(y=i,typeof i=="function")Fm(i)&&(G=1);else if(typeof i=="string")G=$R(i,p,Q.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case O:return i=Er(31,p,l,T),i.elementType=O,i.lanes=R,i;case C:return _a(p.children,T,R,l);case b:G=8,T|=24;break;case _:return i=Er(12,p,l,T|2),i.elementType=_,i.lanes=R,i;case E:return i=Er(13,p,l,T),i.elementType=E,i.lanes=R,i;case N:return i=Er(19,p,l,T),i.elementType=N,i.lanes=R,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case v:G=10;break e;case S:G=9;break e;case k:G=11;break e;case L:G=14;break e;case A:G=16,y=null;break e}G=29,p=Error(r(130,i===null?"null":typeof i,"")),y=null}return l=Er(G,p,l,T),l.elementType=i,l.type=y,l.lanes=R,l}function _a(i,l,p,y){return i=Er(7,i,y,l),i.lanes=p,i}function zm(i,l,p){return i=Er(6,i,null,l),i.lanes=p,i}function x_(i){var l=Er(18,null,null,0);return l.stateNode=i,l}function Hm(i,l,p){return l=Er(4,i.children!==null?i.children:[],i.key,l),l.lanes=p,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}var y_=new WeakMap;function Vr(i,l){if(typeof i=="object"&&i!==null){var p=y_.get(i);return p!==void 0?p:(l={value:i,source:l,stack:We(l)},y_.set(i,l),l)}return{value:i,source:l,stack:We(l)}}var jo=[],Eo=0,ed=null,Zl=0,Wr=[],Gr=0,ji=null,ws=1,Cs="";function qs(i,l){jo[Eo++]=Zl,jo[Eo++]=ed,ed=i,Zl=l}function b_(i,l,p){Wr[Gr++]=ws,Wr[Gr++]=Cs,Wr[Gr++]=ji,ji=i;var y=ws;i=Cs;var T=32-ae(y)-1;y&=~(1<<T),p+=1;var R=32-ae(l)+T;if(30<R){var G=T-T%5;R=(y&(1<<G)-1).toString(32),y>>=G,T-=G,ws=1<<32-ae(l)+T|p<<T|y,Cs=R+i}else ws=1<<R|p<<T|y,Cs=i}function Um(i){i.return!==null&&(qs(i,1),b_(i,1,0))}function Vm(i){for(;i===ed;)ed=jo[--Eo],jo[Eo]=null,Zl=jo[--Eo],jo[Eo]=null;for(;i===ji;)ji=Wr[--Gr],Wr[Gr]=null,Cs=Wr[--Gr],Wr[Gr]=null,ws=Wr[--Gr],Wr[Gr]=null}function v_(i,l){Wr[Gr++]=ws,Wr[Gr++]=Cs,Wr[Gr++]=ji,ws=l.id,Cs=l.overflow,ji=i}var qn=null,ln=null,Rt=!1,Ei=null,qr=!1,Wm=Error(r(519));function Ni(i){var l=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ec(Vr(l,i)),Wm}function __(i){var l=i.stateNode,p=i.type,y=i.memoizedProps;switch(l[Be]=i,l[Je]=y,p){case"dialog":Nt("cancel",l),Nt("close",l);break;case"iframe":case"object":case"embed":Nt("load",l);break;case"video":case"audio":for(p=0;p<Sc.length;p++)Nt(Sc[p],l);break;case"source":Nt("error",l);break;case"img":case"image":case"link":Nt("error",l),Nt("load",l);break;case"details":Nt("toggle",l);break;case"input":Nt("invalid",l),Ov(l,y.value,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name,!0);break;case"select":Nt("invalid",l);break;case"textarea":Nt("invalid",l),Mv(l,y.value,y.defaultValue,y.children)}p=y.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||l.textContent===""+p||y.suppressHydrationWarning===!0||BS(l.textContent,p)?(y.popover!=null&&(Nt("beforetoggle",l),Nt("toggle",l)),y.onScroll!=null&&Nt("scroll",l),y.onScrollEnd!=null&&Nt("scrollend",l),y.onClick!=null&&(l.onclick=Vs),l=!0):l=!1,l||Ni(i,!0)}function S_(i){for(qn=i.return;qn;)switch(qn.tag){case 5:case 31:case 13:qr=!1;return;case 27:case 3:qr=!0;return;default:qn=qn.return}}function No(i){if(i!==qn)return!1;if(!Rt)return S_(i),Rt=!0,!1;var l=i.tag,p;if((p=l!==3&&l!==27)&&((p=l===5)&&(p=i.type,p=!(p!=="form"&&p!=="button")||cg(i.type,i.memoizedProps)),p=!p),p&&ln&&Ni(i),S_(i),l===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));ln=qS(i)}else if(l===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));ln=qS(i)}else l===27?(l=ln,Hi(i.type)?(i=mg,mg=null,ln=i):ln=l):ln=qn?Yr(i.stateNode.nextSibling):null;return!0}function Sa(){ln=qn=null,Rt=!1}function Gm(){var i=Ei;return i!==null&&(xr===null?xr=i:xr.push.apply(xr,i),Ei=null),i}function ec(i){Ei===null?Ei=[i]:Ei.push(i)}var qm=D(null),wa=null,Ks=null;function Ti(i,l,p){$(qm,l._currentValue),l._currentValue=p}function Ys(i){i._currentValue=qm.current,U(qm)}function Km(i,l,p){for(;i!==null;){var y=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,y!==null&&(y.childLanes|=l)):y!==null&&(y.childLanes&l)!==l&&(y.childLanes|=l),i===p)break;i=i.return}}function Ym(i,l,p,y){var T=i.child;for(T!==null&&(T.return=i);T!==null;){var R=T.dependencies;if(R!==null){var G=T.child;R=R.firstContext;e:for(;R!==null;){var te=R;R=T;for(var le=0;le<l.length;le++)if(te.context===l[le]){R.lanes|=p,te=R.alternate,te!==null&&(te.lanes|=p),Km(R.return,p,i),y||(G=null);break e}R=te.next}}else if(T.tag===18){if(G=T.return,G===null)throw Error(r(341));G.lanes|=p,R=G.alternate,R!==null&&(R.lanes|=p),Km(G,p,i),G=null}else G=T.child;if(G!==null)G.return=T;else for(G=T;G!==null;){if(G===i){G=null;break}if(T=G.sibling,T!==null){T.return=G.return,G=T;break}G=G.return}T=G}}function To(i,l,p,y){i=null;for(var T=l,R=!1;T!==null;){if(!R){if((T.flags&524288)!==0)R=!0;else if((T.flags&262144)!==0)break}if(T.tag===10){var G=T.alternate;if(G===null)throw Error(r(387));if(G=G.memoizedProps,G!==null){var te=T.type;jr(T.pendingProps.value,G.value)||(i!==null?i.push(te):i=[te])}}else if(T===V.current){if(G=T.alternate,G===null)throw Error(r(387));G.memoizedState.memoizedState!==T.memoizedState.memoizedState&&(i!==null?i.push(Ec):i=[Ec])}T=T.return}i!==null&&Ym(l,i,p,y),l.flags|=262144}function td(i){for(i=i.firstContext;i!==null;){if(!jr(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ca(i){wa=i,Ks=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Kn(i){return w_(wa,i)}function nd(i,l){return wa===null&&Ca(i),w_(i,l)}function w_(i,l){var p=l._currentValue;if(l={context:l,memoizedValue:p,next:null},Ks===null){if(i===null)throw Error(r(308));Ks=l,i.dependencies={lanes:0,firstContext:l},i.flags|=524288}else Ks=Ks.next=l;return p}var IL=typeof AbortController<"u"?AbortController:function(){var i=[],l=this.signal={aborted:!1,addEventListener:function(p,y){i.push(y)}};this.abort=function(){l.aborted=!0,i.forEach(function(p){return p()})}},ML=e.unstable_scheduleCallback,PL=e.unstable_NormalPriority,Tn={$$typeof:v,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Xm(){return{controller:new IL,data:new Map,refCount:0}}function tc(i){i.refCount--,i.refCount===0&&ML(PL,function(){i.controller.abort()})}var nc=null,Qm=0,Ao=0,Lo=null;function BL(i,l){if(nc===null){var p=nc=[];Qm=0,Ao=eg(),Lo={status:"pending",value:void 0,then:function(y){p.push(y)}}}return Qm++,l.then(C_,C_),l}function C_(){if(--Qm===0&&nc!==null){Lo!==null&&(Lo.status="fulfilled");var i=nc;nc=null,Ao=0,Lo=null;for(var l=0;l<i.length;l++)(0,i[l])()}}function $L(i,l){var p=[],y={status:"pending",value:null,reason:null,then:function(T){p.push(T)}};return i.then(function(){y.status="fulfilled",y.value=l;for(var T=0;T<p.length;T++)(0,p[T])(l)},function(T){for(y.status="rejected",y.reason=T,T=0;T<p.length;T++)(0,p[T])(void 0)}),y}var k_=W.S;W.S=function(i,l){lS=Me(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&BL(i,l),k_!==null&&k_(i,l)};var ka=D(null);function Jm(){var i=ka.current;return i!==null?i:Jt.pooledCache}function rd(i,l){l===null?$(ka,ka.current):$(ka,l.pool)}function j_(){var i=Jm();return i===null?null:{parent:Tn._currentValue,pool:i}}var Ro=Error(r(460)),Zm=Error(r(474)),sd=Error(r(542)),id={then:function(){}};function E_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function N_(i,l,p){switch(p=i[p],p===void 0?i.push(l):p!==l&&(l.then(Vs,Vs),l=p),l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,A_(i),i;default:if(typeof l.status=="string")l.then(Vs,Vs);else{if(i=Jt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=l,i.status="pending",i.then(function(y){if(l.status==="pending"){var T=l;T.status="fulfilled",T.value=y}},function(y){if(l.status==="pending"){var T=l;T.status="rejected",T.reason=y}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,A_(i),i}throw Ea=l,Ro}}function ja(i){try{var l=i._init;return l(i._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(Ea=p,Ro):p}}var Ea=null;function T_(){if(Ea===null)throw Error(r(459));var i=Ea;return Ea=null,i}function A_(i){if(i===Ro||i===sd)throw Error(r(483))}var Do=null,rc=0;function ad(i){var l=rc;return rc+=1,Do===null&&(Do=[]),N_(Do,i,l)}function sc(i,l){l=l.props.ref,i.ref=l!==void 0?l:null}function od(i,l){throw l.$$typeof===g?Error(r(525)):(i=Object.prototype.toString.call(l),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i)))}function L_(i){function l(pe,de){if(i){var be=pe.deletions;be===null?(pe.deletions=[de],pe.flags|=16):be.push(de)}}function p(pe,de){if(!i)return null;for(;de!==null;)l(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=Gs(pe,de),pe.index=0,pe.sibling=null,pe}function R(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 G(pe){return i&&pe.alternate===null&&(pe.flags|=67108866),pe}function te(pe,de,be,Pe){return de===null||de.tag!==6?(de=zm(be,pe.mode,Pe),de.return=pe,de):(de=T(de,be),de.return=pe,de)}function le(pe,de,be,Pe){var lt=be.type;return lt===C?Ie(pe,de,be.props.children,Pe,be.key):de!==null&&(de.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===A&&ja(lt)===de.type)?(de=T(de,be.props),sc(de,be),de.return=pe,de):(de=Zu(be.type,be.key,be.props,null,pe.mode,Pe),sc(de,be),de.return=pe,de)}function ve(pe,de,be,Pe){return de===null||de.tag!==4||de.stateNode.containerInfo!==be.containerInfo||de.stateNode.implementation!==be.implementation?(de=Hm(be,pe.mode,Pe),de.return=pe,de):(de=T(de,be.children||[]),de.return=pe,de)}function Ie(pe,de,be,Pe,lt){return de===null||de.tag!==7?(de=_a(be,pe.mode,Pe,lt),de.return=pe,de):(de=T(de,be),de.return=pe,de)}function $e(pe,de,be){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return de=zm(""+de,pe.mode,be),de.return=pe,de;if(typeof de=="object"&&de!==null){switch(de.$$typeof){case x:return be=Zu(de.type,de.key,de.props,null,pe.mode,be),sc(be,de),be.return=pe,be;case w:return de=Hm(de,pe.mode,be),de.return=pe,de;case A:return de=ja(de),$e(pe,de,be)}if(q(de)||B(de))return de=_a(de,pe.mode,be,null),de.return=pe,de;if(typeof de.then=="function")return $e(pe,ad(de),be);if(de.$$typeof===v)return $e(pe,nd(pe,de),be);od(pe,de)}return null}function Ce(pe,de,be,Pe){var lt=de!==null?de.key:null;if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return lt!==null?null:te(pe,de,""+be,Pe);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case x:return be.key===lt?le(pe,de,be,Pe):null;case w:return be.key===lt?ve(pe,de,be,Pe):null;case A:return be=ja(be),Ce(pe,de,be,Pe)}if(q(be)||B(be))return lt!==null?null:Ie(pe,de,be,Pe,null);if(typeof be.then=="function")return Ce(pe,de,ad(be),Pe);if(be.$$typeof===v)return Ce(pe,de,nd(pe,be),Pe);od(pe,be)}return null}function je(pe,de,be,Pe,lt){if(typeof Pe=="string"&&Pe!==""||typeof Pe=="number"||typeof Pe=="bigint")return pe=pe.get(be)||null,te(de,pe,""+Pe,lt);if(typeof Pe=="object"&&Pe!==null){switch(Pe.$$typeof){case x:return pe=pe.get(Pe.key===null?be:Pe.key)||null,le(de,pe,Pe,lt);case w:return pe=pe.get(Pe.key===null?be:Pe.key)||null,ve(de,pe,Pe,lt);case A:return Pe=ja(Pe),je(pe,de,be,Pe,lt)}if(q(Pe)||B(Pe))return pe=pe.get(be)||null,Ie(de,pe,Pe,lt,null);if(typeof Pe.then=="function")return je(pe,de,be,ad(Pe),lt);if(Pe.$$typeof===v)return je(pe,de,be,nd(de,Pe),lt);od(de,Pe)}return null}function rt(pe,de,be,Pe){for(var lt=null,Mt=null,it=de,Ct=de=0,Lt=null;it!==null&&Ct<be.length;Ct++){it.index>Ct?(Lt=it,it=null):Lt=it.sibling;var Pt=Ce(pe,it,be[Ct],Pe);if(Pt===null){it===null&&(it=Lt);break}i&&it&&Pt.alternate===null&&l(pe,it),de=R(Pt,de,Ct),Mt===null?lt=Pt:Mt.sibling=Pt,Mt=Pt,it=Lt}if(Ct===be.length)return p(pe,it),Rt&&qs(pe,Ct),lt;if(it===null){for(;Ct<be.length;Ct++)it=$e(pe,be[Ct],Pe),it!==null&&(de=R(it,de,Ct),Mt===null?lt=it:Mt.sibling=it,Mt=it);return Rt&&qs(pe,Ct),lt}for(it=y(it);Ct<be.length;Ct++)Lt=je(it,pe,Ct,be[Ct],Pe),Lt!==null&&(i&&Lt.alternate!==null&&it.delete(Lt.key===null?Ct:Lt.key),de=R(Lt,de,Ct),Mt===null?lt=Lt:Mt.sibling=Lt,Mt=Lt);return i&&it.forEach(function(qi){return l(pe,qi)}),Rt&&qs(pe,Ct),lt}function ht(pe,de,be,Pe){if(be==null)throw Error(r(151));for(var lt=null,Mt=null,it=de,Ct=de=0,Lt=null,Pt=be.next();it!==null&&!Pt.done;Ct++,Pt=be.next()){it.index>Ct?(Lt=it,it=null):Lt=it.sibling;var qi=Ce(pe,it,Pt.value,Pe);if(qi===null){it===null&&(it=Lt);break}i&&it&&qi.alternate===null&&l(pe,it),de=R(qi,de,Ct),Mt===null?lt=qi:Mt.sibling=qi,Mt=qi,it=Lt}if(Pt.done)return p(pe,it),Rt&&qs(pe,Ct),lt;if(it===null){for(;!Pt.done;Ct++,Pt=be.next())Pt=$e(pe,Pt.value,Pe),Pt!==null&&(de=R(Pt,de,Ct),Mt===null?lt=Pt:Mt.sibling=Pt,Mt=Pt);return Rt&&qs(pe,Ct),lt}for(it=y(it);!Pt.done;Ct++,Pt=be.next())Pt=je(it,pe,Ct,Pt.value,Pe),Pt!==null&&(i&&Pt.alternate!==null&&it.delete(Pt.key===null?Ct:Pt.key),de=R(Pt,de,Ct),Mt===null?lt=Pt:Mt.sibling=Pt,Mt=Pt);return i&&it.forEach(function(XR){return l(pe,XR)}),Rt&&qs(pe,Ct),lt}function Yt(pe,de,be,Pe){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 lt=be.key;de!==null;){if(de.key===lt){if(lt=be.type,lt===C){if(de.tag===7){p(pe,de.sibling),Pe=T(de,be.props.children),Pe.return=pe,pe=Pe;break e}}else if(de.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===A&&ja(lt)===de.type){p(pe,de.sibling),Pe=T(de,be.props),sc(Pe,be),Pe.return=pe,pe=Pe;break e}p(pe,de);break}else l(pe,de);de=de.sibling}be.type===C?(Pe=_a(be.props.children,pe.mode,Pe,be.key),Pe.return=pe,pe=Pe):(Pe=Zu(be.type,be.key,be.props,null,pe.mode,Pe),sc(Pe,be),Pe.return=pe,pe=Pe)}return G(pe);case w:e:{for(lt=be.key;de!==null;){if(de.key===lt)if(de.tag===4&&de.stateNode.containerInfo===be.containerInfo&&de.stateNode.implementation===be.implementation){p(pe,de.sibling),Pe=T(de,be.children||[]),Pe.return=pe,pe=Pe;break e}else{p(pe,de);break}else l(pe,de);de=de.sibling}Pe=Hm(be,pe.mode,Pe),Pe.return=pe,pe=Pe}return G(pe);case A:return be=ja(be),Yt(pe,de,be,Pe)}if(q(be))return rt(pe,de,be,Pe);if(B(be)){if(lt=B(be),typeof lt!="function")throw Error(r(150));return be=lt.call(be),ht(pe,de,be,Pe)}if(typeof be.then=="function")return Yt(pe,de,ad(be),Pe);if(be.$$typeof===v)return Yt(pe,de,nd(pe,be),Pe);od(pe,be)}return typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint"?(be=""+be,de!==null&&de.tag===6?(p(pe,de.sibling),Pe=T(de,be),Pe.return=pe,pe=Pe):(p(pe,de),Pe=zm(be,pe.mode,Pe),Pe.return=pe,pe=Pe),G(pe)):p(pe,de)}return function(pe,de,be,Pe){try{rc=0;var lt=Yt(pe,de,be,Pe);return Do=null,lt}catch(it){if(it===Ro||it===sd)throw it;var Mt=Er(29,it,null,pe.mode);return Mt.lanes=Pe,Mt.return=pe,Mt}finally{}}}var Na=L_(!0),R_=L_(!1),Ai=!1;function ep(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function tp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Li(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Ri(i,l,p){var y=i.updateQueue;if(y===null)return null;if(y=y.shared,(Ft&2)!==0){var T=y.pending;return T===null?l.next=l:(l.next=T.next,T.next=l),y.pending=l,l=Ju(i),p_(i,null,p),l}return Qu(i,y,l,p),Ju(i)}function ic(i,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194048)!==0)){var y=l.lanes;y&=i.pendingLanes,p|=y,l.lanes=p,Ue(i,p)}}function np(i,l){var p=i.updateQueue,y=i.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var T=null,R=null;if(p=p.firstBaseUpdate,p!==null){do{var G={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};R===null?T=R=G:R=R.next=G,p=p.next}while(p!==null);R===null?T=R=l:R=R.next=l}else T=R=l;p={baseState:y.baseState,firstBaseUpdate:T,lastBaseUpdate:R,shared:y.shared,callbacks:y.callbacks},i.updateQueue=p;return}i=p.lastBaseUpdate,i===null?p.firstBaseUpdate=l:i.next=l,p.lastBaseUpdate=l}var rp=!1;function ac(){if(rp){var i=Lo;if(i!==null)throw i}}function oc(i,l,p,y){rp=!1;var T=i.updateQueue;Ai=!1;var R=T.firstBaseUpdate,G=T.lastBaseUpdate,te=T.shared.pending;if(te!==null){T.shared.pending=null;var le=te,ve=le.next;le.next=null,G===null?R=ve:G.next=ve,G=le;var Ie=i.alternate;Ie!==null&&(Ie=Ie.updateQueue,te=Ie.lastBaseUpdate,te!==G&&(te===null?Ie.firstBaseUpdate=ve:te.next=ve,Ie.lastBaseUpdate=le))}if(R!==null){var $e=T.baseState;G=0,Ie=ve=le=null,te=R;do{var Ce=te.lane&-536870913,je=Ce!==te.lane;if(je?(At&Ce)===Ce:(y&Ce)===Ce){Ce!==0&&Ce===Ao&&(rp=!0),Ie!==null&&(Ie=Ie.next={lane:0,tag:te.tag,payload:te.payload,callback:null,next:null});e:{var rt=i,ht=te;Ce=l;var Yt=p;switch(ht.tag){case 1:if(rt=ht.payload,typeof rt=="function"){$e=rt.call(Yt,$e,Ce);break e}$e=rt;break e;case 3:rt.flags=rt.flags&-65537|128;case 0:if(rt=ht.payload,Ce=typeof rt=="function"?rt.call(Yt,$e,Ce):rt,Ce==null)break e;$e=f({},$e,Ce);break e;case 2:Ai=!0}}Ce=te.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:te.tag,payload:te.payload,callback:te.callback,next:null},Ie===null?(ve=Ie=je,le=$e):Ie=Ie.next=je,G|=Ce;if(te=te.next,te===null){if(te=T.shared.pending,te===null)break;je=te,te=je.next,je.next=null,T.lastBaseUpdate=je,T.shared.pending=null}}while(!0);Ie===null&&(le=$e),T.baseState=le,T.firstBaseUpdate=ve,T.lastBaseUpdate=Ie,R===null&&(T.shared.lanes=0),Pi|=G,i.lanes=G,i.memoizedState=$e}}function D_(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function O_(i,l){var p=i.callbacks;if(p!==null)for(i.callbacks=null,i=0;i<p.length;i++)D_(p[i],l)}var Oo=D(null),ld=D(0);function I_(i,l){i=si,$(ld,i),$(Oo,l),si=i|l.baseLanes}function sp(){$(ld,si),$(Oo,Oo.current)}function ip(){si=ld.current,U(Oo),U(ld)}var Nr=D(null),Kr=null;function Di(i){var l=i.alternate;$(kn,kn.current&1),$(Nr,i),Kr===null&&(l===null||Oo.current!==null||l.memoizedState!==null)&&(Kr=i)}function ap(i){$(kn,kn.current),$(Nr,i),Kr===null&&(Kr=i)}function M_(i){i.tag===22?($(kn,kn.current),$(Nr,i),Kr===null&&(Kr=i)):Oi()}function Oi(){$(kn,kn.current),$(Nr,Nr.current)}function Tr(i){U(Nr),Kr===i&&(Kr=null),U(kn)}var kn=D(0);function cd(i){for(var l=i;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||hg(p)||fg(p)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Xs=0,St=null,qt=null,An=null,ud=!1,Io=!1,Ta=!1,dd=0,lc=0,Mo=null,FL=0;function vn(){throw Error(r(321))}function op(i,l){if(l===null)return!1;for(var p=0;p<l.length&&p<i.length;p++)if(!jr(i[p],l[p]))return!1;return!0}function lp(i,l,p,y,T,R){return Xs=R,St=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,W.H=i===null||i.memoizedState===null?b0:wp,Ta=!1,R=p(y,T),Ta=!1,Io&&(R=B_(l,p,y,T)),P_(i),R}function P_(i){W.H=dc;var l=qt!==null&&qt.next!==null;if(Xs=0,An=qt=St=null,ud=!1,lc=0,Mo=null,l)throw Error(r(300));i===null||Ln||(i=i.dependencies,i!==null&&td(i)&&(Ln=!0))}function B_(i,l,p,y){St=i;var T=0;do{if(Io&&(Mo=null),lc=0,Io=!1,25<=T)throw Error(r(301));if(T+=1,An=qt=null,i.updateQueue!=null){var R=i.updateQueue;R.lastEffect=null,R.events=null,R.stores=null,R.memoCache!=null&&(R.memoCache.index=0)}W.H=v0,R=l(p,y)}while(Io);return R}function zL(){var i=W.H,l=i.useState()[0];return l=typeof l.then=="function"?cc(l):l,i=i.useState()[0],(qt!==null?qt.memoizedState:null)!==i&&(St.flags|=1024),l}function cp(){var i=dd!==0;return dd=0,i}function up(i,l,p){l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~p}function dp(i){if(ud){for(i=i.memoizedState;i!==null;){var l=i.queue;l!==null&&(l.pending=null),i=i.next}ud=!1}Xs=0,An=qt=St=null,Io=!1,lc=dd=0,Mo=null}function lr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return An===null?St.memoizedState=An=i:An=An.next=i,An}function jn(){if(qt===null){var i=St.alternate;i=i!==null?i.memoizedState:null}else i=qt.next;var l=An===null?St.memoizedState:An.next;if(l!==null)An=l,qt=i;else{if(i===null)throw St.alternate===null?Error(r(467)):Error(r(310));qt=i,i={memoizedState:qt.memoizedState,baseState:qt.baseState,baseQueue:qt.baseQueue,queue:qt.queue,next:null},An===null?St.memoizedState=An=i:An=An.next=i}return An}function hd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function cc(i){var l=lc;return lc+=1,Mo===null&&(Mo=[]),i=N_(Mo,i,l),l=St,(An===null?l.memoizedState:An.next)===null&&(l=l.alternate,W.H=l===null||l.memoizedState===null?b0:wp),i}function fd(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return cc(i);if(i.$$typeof===v)return Kn(i)}throw Error(r(438,String(i)))}function hp(i){var l=null,p=St.updateQueue;if(p!==null&&(l=p.memoCache),l==null){var y=St.alternate;y!==null&&(y=y.updateQueue,y!==null&&(y=y.memoCache,y!=null&&(l={data:y.data.map(function(T){return T.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),p===null&&(p=hd(),St.updateQueue=p),p.memoCache=l,p=l.data[l.index],p===void 0)for(p=l.data[l.index]=Array(i),y=0;y<i;y++)p[y]=I;return l.index++,p}function Qs(i,l){return typeof l=="function"?l(i):l}function md(i){var l=jn();return fp(l,qt,i)}function fp(i,l,p){var y=i.queue;if(y===null)throw Error(r(311));y.lastRenderedReducer=p;var T=i.baseQueue,R=y.pending;if(R!==null){if(T!==null){var G=T.next;T.next=R.next,R.next=G}l.baseQueue=T=R,y.pending=null}if(R=i.baseState,T===null)i.memoizedState=R;else{l=T.next;var te=G=null,le=null,ve=l,Ie=!1;do{var $e=ve.lane&-536870913;if($e!==ve.lane?(At&$e)===$e:(Xs&$e)===$e){var Ce=ve.revertLane;if(Ce===0)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null}),$e===Ao&&(Ie=!0);else if((Xs&Ce)===Ce){ve=ve.next,Ce===Ao&&(Ie=!0);continue}else $e={lane:0,revertLane:ve.revertLane,gesture:null,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null},le===null?(te=le=$e,G=R):le=le.next=$e,St.lanes|=Ce,Pi|=Ce;$e=ve.action,Ta&&p(R,$e),R=ve.hasEagerState?ve.eagerState:p(R,$e)}else Ce={lane:$e,revertLane:ve.revertLane,gesture:ve.gesture,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null},le===null?(te=le=Ce,G=R):le=le.next=Ce,St.lanes|=$e,Pi|=$e;ve=ve.next}while(ve!==null&&ve!==l);if(le===null?G=R:le.next=te,!jr(R,i.memoizedState)&&(Ln=!0,Ie&&(p=Lo,p!==null)))throw p;i.memoizedState=R,i.baseState=G,i.baseQueue=le,y.lastRenderedState=R}return T===null&&(y.lanes=0),[i.memoizedState,y.dispatch]}function mp(i){var l=jn(),p=l.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=i;var y=p.dispatch,T=p.pending,R=l.memoizedState;if(T!==null){p.pending=null;var G=T=T.next;do R=i(R,G.action),G=G.next;while(G!==T);jr(R,l.memoizedState)||(Ln=!0),l.memoizedState=R,l.baseQueue===null&&(l.baseState=R),p.lastRenderedState=R}return[R,y]}function $_(i,l,p){var y=St,T=jn(),R=Rt;if(R){if(p===void 0)throw Error(r(407));p=p()}else p=l();var G=!jr((qt||T).memoizedState,p);if(G&&(T.memoizedState=p,Ln=!0),T=T.queue,xp(H_.bind(null,y,T,i),[i]),T.getSnapshot!==l||G||An!==null&&An.memoizedState.tag&1){if(y.flags|=2048,Po(9,{destroy:void 0},z_.bind(null,y,T,p,l),null),Jt===null)throw Error(r(349));R||(Xs&127)!==0||F_(y,l,p)}return p}function F_(i,l,p){i.flags|=16384,i={getSnapshot:l,value:p},l=St.updateQueue,l===null?(l=hd(),St.updateQueue=l,l.stores=[i]):(p=l.stores,p===null?l.stores=[i]:p.push(i))}function z_(i,l,p,y){l.value=p,l.getSnapshot=y,U_(l)&&V_(i)}function H_(i,l,p){return p(function(){U_(l)&&V_(i)})}function U_(i){var l=i.getSnapshot;i=i.value;try{var p=l();return!jr(i,p)}catch{return!0}}function V_(i){var l=va(i,2);l!==null&&yr(l,i,2)}function pp(i){var l=lr();if(typeof i=="function"){var p=i;if(i=p(),Ta){ce(!0);try{p()}finally{ce(!1)}}}return l.memoizedState=l.baseState=i,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qs,lastRenderedState:i},l}function W_(i,l,p,y){return i.baseState=p,fp(i,qt,typeof y=="function"?y:Qs)}function HL(i,l,p,y,T){if(xd(i))throw Error(r(485));if(i=l.action,i!==null){var R={payload:T,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(G){R.listeners.push(G)}};W.T!==null?p(!0):R.isTransition=!1,y(R),p=l.pending,p===null?(R.next=l.pending=R,G_(l,R)):(R.next=p.next,l.pending=p.next=R)}}function G_(i,l){var p=l.action,y=l.payload,T=i.state;if(l.isTransition){var R=W.T,G={};W.T=G;try{var te=p(T,y),le=W.S;le!==null&&le(G,te),q_(i,l,te)}catch(ve){gp(i,l,ve)}finally{R!==null&&G.types!==null&&(R.types=G.types),W.T=R}}else try{R=p(T,y),q_(i,l,R)}catch(ve){gp(i,l,ve)}}function q_(i,l,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(y){K_(i,l,y)},function(y){return gp(i,l,y)}):K_(i,l,p)}function K_(i,l,p){l.status="fulfilled",l.value=p,Y_(l),i.state=p,l=i.pending,l!==null&&(p=l.next,p===l?i.pending=null:(p=p.next,l.next=p,G_(i,p)))}function gp(i,l,p){var y=i.pending;if(i.pending=null,y!==null){y=y.next;do l.status="rejected",l.reason=p,Y_(l),l=l.next;while(l!==y)}i.action=null}function Y_(i){i=i.listeners;for(var l=0;l<i.length;l++)(0,i[l])()}function X_(i,l){return l}function Q_(i,l){if(Rt){var p=Jt.formState;if(p!==null){e:{var y=St;if(Rt){if(ln){t:{for(var T=ln,R=qr;T.nodeType!==8;){if(!R){T=null;break t}if(T=Yr(T.nextSibling),T===null){T=null;break t}}R=T.data,T=R==="F!"||R==="F"?T:null}if(T){ln=Yr(T.nextSibling),y=T.data==="F!";break e}}Ni(y)}y=!1}y&&(l=p[0])}}return p=lr(),p.memoizedState=p.baseState=l,y={pending:null,lanes:0,dispatch:null,lastRenderedReducer:X_,lastRenderedState:l},p.queue=y,p=g0.bind(null,St,y),y.dispatch=p,y=pp(!1),R=Sp.bind(null,St,!1,y.queue),y=lr(),T={state:l,dispatch:null,action:i,pending:null},y.queue=T,p=HL.bind(null,St,T,R,p),T.dispatch=p,y.memoizedState=i,[l,p,!1]}function J_(i){var l=jn();return Z_(l,qt,i)}function Z_(i,l,p){if(l=fp(i,l,X_)[0],i=md(Qs)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var y=cc(l)}catch(G){throw G===Ro?sd:G}else y=l;l=jn();var T=l.queue,R=T.dispatch;return p!==l.memoizedState&&(St.flags|=2048,Po(9,{destroy:void 0},UL.bind(null,T,p),null)),[y,R,i]}function UL(i,l){i.action=l}function e0(i){var l=jn(),p=qt;if(p!==null)return Z_(l,p,i);jn(),l=l.memoizedState,p=jn();var y=p.queue.dispatch;return p.memoizedState=i,[l,y,!1]}function Po(i,l,p,y){return i={tag:i,create:p,deps:y,inst:l,next:null},l=St.updateQueue,l===null&&(l=hd(),St.updateQueue=l),p=l.lastEffect,p===null?l.lastEffect=i.next=i:(y=p.next,p.next=i,i.next=y,l.lastEffect=i),i}function t0(){return jn().memoizedState}function pd(i,l,p,y){var T=lr();St.flags|=i,T.memoizedState=Po(1|l,{destroy:void 0},p,y===void 0?null:y)}function gd(i,l,p,y){var T=jn();y=y===void 0?null:y;var R=T.memoizedState.inst;qt!==null&&y!==null&&op(y,qt.memoizedState.deps)?T.memoizedState=Po(l,R,p,y):(St.flags|=i,T.memoizedState=Po(1|l,R,p,y))}function n0(i,l){pd(8390656,8,i,l)}function xp(i,l){gd(2048,8,i,l)}function VL(i){St.flags|=4;var l=St.updateQueue;if(l===null)l=hd(),St.updateQueue=l,l.events=[i];else{var p=l.events;p===null?l.events=[i]:p.push(i)}}function r0(i){var l=jn().memoizedState;return VL({ref:l,nextImpl:i}),function(){if((Ft&2)!==0)throw Error(r(440));return l.impl.apply(void 0,arguments)}}function s0(i,l){return gd(4,2,i,l)}function i0(i,l){return gd(4,4,i,l)}function a0(i,l){if(typeof l=="function"){i=i();var p=l(i);return function(){typeof p=="function"?p():l(null)}}if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function o0(i,l,p){p=p!=null?p.concat([i]):null,gd(4,4,a0.bind(null,l,i),p)}function yp(){}function l0(i,l){var p=jn();l=l===void 0?null:l;var y=p.memoizedState;return l!==null&&op(l,y[1])?y[0]:(p.memoizedState=[i,l],i)}function c0(i,l){var p=jn();l=l===void 0?null:l;var y=p.memoizedState;if(l!==null&&op(l,y[1]))return y[0];if(y=i(),Ta){ce(!0);try{i()}finally{ce(!1)}}return p.memoizedState=[y,l],y}function bp(i,l,p){return p===void 0||(Xs&1073741824)!==0&&(At&261930)===0?i.memoizedState=l:(i.memoizedState=p,i=uS(),St.lanes|=i,Pi|=i,p)}function u0(i,l,p,y){return jr(p,l)?p:Oo.current!==null?(i=bp(i,p,y),jr(i,l)||(Ln=!0),i):(Xs&42)===0||(Xs&1073741824)!==0&&(At&261930)===0?(Ln=!0,i.memoizedState=p):(i=uS(),St.lanes|=i,Pi|=i,l)}function d0(i,l,p,y,T){var R=ee.p;ee.p=R!==0&&8>R?R:8;var G=W.T,te={};W.T=te,Sp(i,!1,l,p);try{var le=T(),ve=W.S;if(ve!==null&&ve(te,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var Ie=$L(le,y);uc(i,l,Ie,Rr(i))}else uc(i,l,y,Rr(i))}catch($e){uc(i,l,{then:function(){},status:"rejected",reason:$e},Rr())}finally{ee.p=R,G!==null&&te.types!==null&&(G.types=te.types),W.T=G}}function WL(){}function vp(i,l,p,y){if(i.tag!==5)throw Error(r(476));var T=h0(i).queue;d0(i,T,l,J,p===null?WL:function(){return f0(i),p(y)})}function h0(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qs,lastRenderedState:J},next:null};var p={};return l.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qs,lastRenderedState:p},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function f0(i){var l=h0(i);l.next===null&&(l=i.alternate.memoizedState),uc(i,l.next.queue,{},Rr())}function _p(){return Kn(Ec)}function m0(){return jn().memoizedState}function p0(){return jn().memoizedState}function GL(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var p=Rr();i=Li(p);var y=Ri(l,i,p);y!==null&&(yr(y,l,p),ic(y,l,p)),l={cache:Xm()},i.payload=l;return}l=l.return}}function qL(i,l,p){var y=Rr();p={lane:y,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},xd(i)?x0(l,p):(p=$m(i,l,p,y),p!==null&&(yr(p,i,y),y0(p,l,y)))}function g0(i,l,p){var y=Rr();uc(i,l,p,y)}function uc(i,l,p,y){var T={lane:y,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(xd(i))x0(l,T);else{var R=i.alternate;if(i.lanes===0&&(R===null||R.lanes===0)&&(R=l.lastRenderedReducer,R!==null))try{var G=l.lastRenderedState,te=R(G,p);if(T.hasEagerState=!0,T.eagerState=te,jr(te,G))return Qu(i,l,T,0),Jt===null&&Xu(),!1}catch{}finally{}if(p=$m(i,l,T,y),p!==null)return yr(p,i,y),y0(p,l,y),!0}return!1}function Sp(i,l,p,y){if(y={lane:2,revertLane:eg(),gesture:null,action:y,hasEagerState:!1,eagerState:null,next:null},xd(i)){if(l)throw Error(r(479))}else l=$m(i,p,y,2),l!==null&&yr(l,i,2)}function xd(i){var l=i.alternate;return i===St||l!==null&&l===St}function x0(i,l){Io=ud=!0;var p=i.pending;p===null?l.next=l:(l.next=p.next,p.next=l),i.pending=l}function y0(i,l,p){if((p&4194048)!==0){var y=l.lanes;y&=i.pendingLanes,p|=y,l.lanes=p,Ue(i,p)}}var dc={readContext:Kn,use:fd,useCallback:vn,useContext:vn,useEffect:vn,useImperativeHandle:vn,useLayoutEffect:vn,useInsertionEffect:vn,useMemo:vn,useReducer:vn,useRef:vn,useState:vn,useDebugValue:vn,useDeferredValue:vn,useTransition:vn,useSyncExternalStore:vn,useId:vn,useHostTransitionStatus:vn,useFormState:vn,useActionState:vn,useOptimistic:vn,useMemoCache:vn,useCacheRefresh:vn};dc.useEffectEvent=vn;var b0={readContext:Kn,use:fd,useCallback:function(i,l){return lr().memoizedState=[i,l===void 0?null:l],i},useContext:Kn,useEffect:n0,useImperativeHandle:function(i,l,p){p=p!=null?p.concat([i]):null,pd(4194308,4,a0.bind(null,l,i),p)},useLayoutEffect:function(i,l){return pd(4194308,4,i,l)},useInsertionEffect:function(i,l){pd(4,2,i,l)},useMemo:function(i,l){var p=lr();l=l===void 0?null:l;var y=i();if(Ta){ce(!0);try{i()}finally{ce(!1)}}return p.memoizedState=[y,l],y},useReducer:function(i,l,p){var y=lr();if(p!==void 0){var T=p(l);if(Ta){ce(!0);try{p(l)}finally{ce(!1)}}}else T=l;return y.memoizedState=y.baseState=T,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:T},y.queue=i,i=i.dispatch=qL.bind(null,St,i),[y.memoizedState,i]},useRef:function(i){var l=lr();return i={current:i},l.memoizedState=i},useState:function(i){i=pp(i);var l=i.queue,p=g0.bind(null,St,l);return l.dispatch=p,[i.memoizedState,p]},useDebugValue:yp,useDeferredValue:function(i,l){var p=lr();return bp(p,i,l)},useTransition:function(){var i=pp(!1);return i=d0.bind(null,St,i.queue,!0,!1),lr().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,p){var y=St,T=lr();if(Rt){if(p===void 0)throw Error(r(407));p=p()}else{if(p=l(),Jt===null)throw Error(r(349));(At&127)!==0||F_(y,l,p)}T.memoizedState=p;var R={value:p,getSnapshot:l};return T.queue=R,n0(H_.bind(null,y,R,i),[i]),y.flags|=2048,Po(9,{destroy:void 0},z_.bind(null,y,R,p,l),null),p},useId:function(){var i=lr(),l=Jt.identifierPrefix;if(Rt){var p=Cs,y=ws;p=(y&~(1<<32-ae(y)-1)).toString(32)+p,l="_"+l+"R_"+p,p=dd++,0<p&&(l+="H"+p.toString(32)),l+="_"}else p=FL++,l="_"+l+"r_"+p.toString(32)+"_";return i.memoizedState=l},useHostTransitionStatus:_p,useFormState:Q_,useActionState:Q_,useOptimistic:function(i){var l=lr();l.memoizedState=l.baseState=i;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=p,l=Sp.bind(null,St,!0,p),p.dispatch=l,[i,l]},useMemoCache:hp,useCacheRefresh:function(){return lr().memoizedState=GL.bind(null,St)},useEffectEvent:function(i){var l=lr(),p={impl:i};return l.memoizedState=p,function(){if((Ft&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}},wp={readContext:Kn,use:fd,useCallback:l0,useContext:Kn,useEffect:xp,useImperativeHandle:o0,useInsertionEffect:s0,useLayoutEffect:i0,useMemo:c0,useReducer:md,useRef:t0,useState:function(){return md(Qs)},useDebugValue:yp,useDeferredValue:function(i,l){var p=jn();return u0(p,qt.memoizedState,i,l)},useTransition:function(){var i=md(Qs)[0],l=jn().memoizedState;return[typeof i=="boolean"?i:cc(i),l]},useSyncExternalStore:$_,useId:m0,useHostTransitionStatus:_p,useFormState:J_,useActionState:J_,useOptimistic:function(i,l){var p=jn();return W_(p,qt,i,l)},useMemoCache:hp,useCacheRefresh:p0};wp.useEffectEvent=r0;var v0={readContext:Kn,use:fd,useCallback:l0,useContext:Kn,useEffect:xp,useImperativeHandle:o0,useInsertionEffect:s0,useLayoutEffect:i0,useMemo:c0,useReducer:mp,useRef:t0,useState:function(){return mp(Qs)},useDebugValue:yp,useDeferredValue:function(i,l){var p=jn();return qt===null?bp(p,i,l):u0(p,qt.memoizedState,i,l)},useTransition:function(){var i=mp(Qs)[0],l=jn().memoizedState;return[typeof i=="boolean"?i:cc(i),l]},useSyncExternalStore:$_,useId:m0,useHostTransitionStatus:_p,useFormState:e0,useActionState:e0,useOptimistic:function(i,l){var p=jn();return qt!==null?W_(p,qt,i,l):(p.baseState=i,[i,p.queue.dispatch])},useMemoCache:hp,useCacheRefresh:p0};v0.useEffectEvent=r0;function Cp(i,l,p,y){l=i.memoizedState,p=p(y,l),p=p==null?l:f({},l,p),i.memoizedState=p,i.lanes===0&&(i.updateQueue.baseState=p)}var kp={enqueueSetState:function(i,l,p){i=i._reactInternals;var y=Rr(),T=Li(y);T.payload=l,p!=null&&(T.callback=p),l=Ri(i,T,y),l!==null&&(yr(l,i,y),ic(l,i,y))},enqueueReplaceState:function(i,l,p){i=i._reactInternals;var y=Rr(),T=Li(y);T.tag=1,T.payload=l,p!=null&&(T.callback=p),l=Ri(i,T,y),l!==null&&(yr(l,i,y),ic(l,i,y))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var p=Rr(),y=Li(p);y.tag=2,l!=null&&(y.callback=l),l=Ri(i,y,p),l!==null&&(yr(l,i,p),ic(l,i,p))}};function _0(i,l,p,y,T,R,G){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(y,R,G):l.prototype&&l.prototype.isPureReactComponent?!Ql(p,y)||!Ql(T,R):!0}function S0(i,l,p,y){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,y),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,y),l.state!==i&&kp.enqueueReplaceState(l,l.state,null)}function Aa(i,l){var p=l;if("ref"in l){p={};for(var y in l)y!=="ref"&&(p[y]=l[y])}if(i=i.defaultProps){p===l&&(p=f({},p));for(var T in i)p[T]===void 0&&(p[T]=i[T])}return p}function w0(i){Yu(i)}function C0(i){console.error(i)}function k0(i){Yu(i)}function yd(i,l){try{var p=i.onUncaughtError;p(l.value,{componentStack:l.stack})}catch(y){setTimeout(function(){throw y})}}function j0(i,l,p){try{var y=i.onCaughtError;y(p.value,{componentStack:p.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function jp(i,l,p){return p=Li(p),p.tag=3,p.payload={element:null},p.callback=function(){yd(i,l)},p}function E0(i){return i=Li(i),i.tag=3,i}function N0(i,l,p,y){var T=p.type.getDerivedStateFromError;if(typeof T=="function"){var R=y.value;i.payload=function(){return T(R)},i.callback=function(){j0(l,p,y)}}var G=p.stateNode;G!==null&&typeof G.componentDidCatch=="function"&&(i.callback=function(){j0(l,p,y),typeof T!="function"&&(Bi===null?Bi=new Set([this]):Bi.add(this));var te=y.stack;this.componentDidCatch(y.value,{componentStack:te!==null?te:""})})}function KL(i,l,p,y,T){if(p.flags|=32768,y!==null&&typeof y=="object"&&typeof y.then=="function"){if(l=p.alternate,l!==null&&To(l,p,T,!0),p=Nr.current,p!==null){switch(p.tag){case 31:case 13:return Kr===null?Ad():p.alternate===null&&_n===0&&(_n=3),p.flags&=-257,p.flags|=65536,p.lanes=T,y===id?p.flags|=16384:(l=p.updateQueue,l===null?p.updateQueue=new Set([y]):l.add(y),Qp(i,y,T)),!1;case 22:return p.flags|=65536,y===id?p.flags|=16384:(l=p.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([y])},p.updateQueue=l):(p=l.retryQueue,p===null?l.retryQueue=new Set([y]):p.add(y)),Qp(i,y,T)),!1}throw Error(r(435,p.tag))}return Qp(i,y,T),Ad(),!1}if(Rt)return l=Nr.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=T,y!==Wm&&(i=Error(r(422),{cause:y}),ec(Vr(i,p)))):(y!==Wm&&(l=Error(r(423),{cause:y}),ec(Vr(l,p))),i=i.current.alternate,i.flags|=65536,T&=-T,i.lanes|=T,y=Vr(y,p),T=jp(i.stateNode,y,T),np(i,T),_n!==4&&(_n=2)),!1;var R=Error(r(520),{cause:y});if(R=Vr(R,p),bc===null?bc=[R]:bc.push(R),_n!==4&&(_n=2),l===null)return!0;y=Vr(y,p),p=l;do{switch(p.tag){case 3:return p.flags|=65536,i=T&-T,p.lanes|=i,i=jp(p.stateNode,y,i),np(p,i),!1;case 1:if(l=p.type,R=p.stateNode,(p.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&(Bi===null||!Bi.has(R))))return p.flags|=65536,T&=-T,p.lanes|=T,T=E0(T),N0(T,i,p,y),np(p,T),!1}p=p.return}while(p!==null);return!1}var Ep=Error(r(461)),Ln=!1;function Yn(i,l,p,y){l.child=i===null?R_(l,null,p,y):Na(l,i.child,p,y)}function T0(i,l,p,y,T){p=p.render;var R=l.ref;if("ref"in y){var G={};for(var te in y)te!=="ref"&&(G[te]=y[te])}else G=y;return Ca(l),y=lp(i,l,p,G,R,T),te=cp(),i!==null&&!Ln?(up(i,l,T),Js(i,l,T)):(Rt&&te&&Um(l),l.flags|=1,Yn(i,l,y,T),l.child)}function A0(i,l,p,y,T){if(i===null){var R=p.type;return typeof R=="function"&&!Fm(R)&&R.defaultProps===void 0&&p.compare===null?(l.tag=15,l.type=R,L0(i,l,R,y,T)):(i=Zu(p.type,null,y,l,l.mode,T),i.ref=l.ref,i.return=l,l.child=i)}if(R=i.child,!Ip(i,T)){var G=R.memoizedProps;if(p=p.compare,p=p!==null?p:Ql,p(G,y)&&i.ref===l.ref)return Js(i,l,T)}return l.flags|=1,i=Gs(R,y),i.ref=l.ref,i.return=l,l.child=i}function L0(i,l,p,y,T){if(i!==null){var R=i.memoizedProps;if(Ql(R,y)&&i.ref===l.ref)if(Ln=!1,l.pendingProps=y=R,Ip(i,T))(i.flags&131072)!==0&&(Ln=!0);else return l.lanes=i.lanes,Js(i,l,T)}return Np(i,l,p,y,T)}function R0(i,l,p,y){var T=y.children,R=i!==null?i.memoizedState:null;if(i===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),y.mode==="hidden"){if((l.flags&128)!==0){if(R=R!==null?R.baseLanes|p:p,i!==null){for(y=l.child=i.child,T=0;y!==null;)T=T|y.lanes|y.childLanes,y=y.sibling;y=T&~R}else y=0,l.child=null;return D0(i,l,R,p,y)}if((p&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},i!==null&&rd(l,R!==null?R.cachePool:null),R!==null?I_(l,R):sp(),M_(l);else return y=l.lanes=536870912,D0(i,l,R!==null?R.baseLanes|p:p,p,y)}else R!==null?(rd(l,R.cachePool),I_(l,R),Oi(),l.memoizedState=null):(i!==null&&rd(l,null),sp(),Oi());return Yn(i,l,T,p),l.child}function hc(i,l){return i!==null&&i.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function D0(i,l,p,y,T){var R=Jm();return R=R===null?null:{parent:Tn._currentValue,pool:R},l.memoizedState={baseLanes:p,cachePool:R},i!==null&&rd(l,null),sp(),M_(l),i!==null&&To(i,l,y,!0),l.childLanes=T,null}function bd(i,l){return l=_d({mode:l.mode,children:l.children},i.mode),l.ref=i.ref,i.child=l,l.return=i,l}function O0(i,l,p){return Na(l,i.child,null,p),i=bd(l,l.pendingProps),i.flags|=2,Tr(l),l.memoizedState=null,i}function YL(i,l,p){var y=l.pendingProps,T=(l.flags&128)!==0;if(l.flags&=-129,i===null){if(Rt){if(y.mode==="hidden")return i=bd(l,y),l.lanes=536870912,hc(null,i);if(ap(l),(i=ln)?(i=GS(i,qr),i=i!==null&&i.data==="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:ji!==null?{id:ws,overflow:Cs}:null,retryLane:536870912,hydrationErrors:null},p=x_(i),p.return=l,l.child=p,qn=l,ln=null)):i=null,i===null)throw Ni(l);return l.lanes=536870912,null}return bd(l,y)}var R=i.memoizedState;if(R!==null){var G=R.dehydrated;if(ap(l),T)if(l.flags&256)l.flags&=-257,l=O0(i,l,p);else if(l.memoizedState!==null)l.child=i.child,l.flags|=128,l=null;else throw Error(r(558));else if(Ln||To(i,l,p,!1),T=(p&i.childLanes)!==0,Ln||T){if(y=Jt,y!==null&&(G=ue(y,p),G!==0&&G!==R.retryLane))throw R.retryLane=G,va(i,G),yr(y,i,G),Ep;Ad(),l=O0(i,l,p)}else i=R.treeContext,ln=Yr(G.nextSibling),qn=l,Rt=!0,Ei=null,qr=!1,i!==null&&v_(l,i),l=bd(l,y),l.flags|=4096;return l}return i=Gs(i.child,{mode:y.mode,children:y.children}),i.ref=l.ref,l.child=i,i.return=l,i}function vd(i,l){var p=l.ref;if(p===null)i!==null&&i.ref!==null&&(l.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(r(284));(i===null||i.ref!==p)&&(l.flags|=4194816)}}function Np(i,l,p,y,T){return Ca(l),p=lp(i,l,p,y,void 0,T),y=cp(),i!==null&&!Ln?(up(i,l,T),Js(i,l,T)):(Rt&&y&&Um(l),l.flags|=1,Yn(i,l,p,T),l.child)}function I0(i,l,p,y,T,R){return Ca(l),l.updateQueue=null,p=B_(l,y,p,T),P_(i),y=cp(),i!==null&&!Ln?(up(i,l,R),Js(i,l,R)):(Rt&&y&&Um(l),l.flags|=1,Yn(i,l,p,R),l.child)}function M0(i,l,p,y,T){if(Ca(l),l.stateNode===null){var R=ko,G=p.contextType;typeof G=="object"&&G!==null&&(R=Kn(G)),R=new p(y,R),l.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,R.updater=kp,l.stateNode=R,R._reactInternals=l,R=l.stateNode,R.props=y,R.state=l.memoizedState,R.refs={},ep(l),G=p.contextType,R.context=typeof G=="object"&&G!==null?Kn(G):ko,R.state=l.memoizedState,G=p.getDerivedStateFromProps,typeof G=="function"&&(Cp(l,p,G,y),R.state=l.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(G=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),G!==R.state&&kp.enqueueReplaceState(R,R.state,null),oc(l,y,R,T),ac(),R.state=l.memoizedState),typeof R.componentDidMount=="function"&&(l.flags|=4194308),y=!0}else if(i===null){R=l.stateNode;var te=l.memoizedProps,le=Aa(p,te);R.props=le;var ve=R.context,Ie=p.contextType;G=ko,typeof Ie=="object"&&Ie!==null&&(G=Kn(Ie));var $e=p.getDerivedStateFromProps;Ie=typeof $e=="function"||typeof R.getSnapshotBeforeUpdate=="function",te=l.pendingProps!==te,Ie||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(te||ve!==G)&&S0(l,R,y,G),Ai=!1;var Ce=l.memoizedState;R.state=Ce,oc(l,y,R,T),ac(),ve=l.memoizedState,te||Ce!==ve||Ai?(typeof $e=="function"&&(Cp(l,p,$e,y),ve=l.memoizedState),(le=Ai||_0(l,p,le,y,Ce,ve,G))?(Ie||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(l.flags|=4194308)):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=y,l.memoizedState=ve),R.props=y,R.state=ve,R.context=G,y=le):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),y=!1)}else{R=l.stateNode,tp(i,l),G=l.memoizedProps,Ie=Aa(p,G),R.props=Ie,$e=l.pendingProps,Ce=R.context,ve=p.contextType,le=ko,typeof ve=="object"&&ve!==null&&(le=Kn(ve)),te=p.getDerivedStateFromProps,(ve=typeof te=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(G!==$e||Ce!==le)&&S0(l,R,y,le),Ai=!1,Ce=l.memoizedState,R.state=Ce,oc(l,y,R,T),ac();var je=l.memoizedState;G!==$e||Ce!==je||Ai||i!==null&&i.dependencies!==null&&td(i.dependencies)?(typeof te=="function"&&(Cp(l,p,te,y),je=l.memoizedState),(Ie=Ai||_0(l,p,Ie,y,Ce,je,le)||i!==null&&i.dependencies!==null&&td(i.dependencies))?(ve||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(y,je,le),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(y,je,le)),typeof R.componentDidUpdate=="function"&&(l.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof R.componentDidUpdate!="function"||G===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=1024),l.memoizedProps=y,l.memoizedState=je),R.props=y,R.state=je,R.context=le,y=Ie):(typeof R.componentDidUpdate!="function"||G===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&Ce===i.memoizedState||(l.flags|=1024),y=!1)}return R=y,vd(i,l),y=(l.flags&128)!==0,R||y?(R=l.stateNode,p=y&&typeof p.getDerivedStateFromError!="function"?null:R.render(),l.flags|=1,i!==null&&y?(l.child=Na(l,i.child,null,T),l.child=Na(l,null,p,T)):Yn(i,l,p,T),l.memoizedState=R.state,i=l.child):i=Js(i,l,T),i}function P0(i,l,p,y){return Sa(),l.flags|=256,Yn(i,l,p,y),l.child}var Tp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ap(i){return{baseLanes:i,cachePool:j_()}}function Lp(i,l,p){return i=i!==null?i.childLanes&~p:0,l&&(i|=Lr),i}function B0(i,l,p){var y=l.pendingProps,T=!1,R=(l.flags&128)!==0,G;if((G=R)||(G=i!==null&&i.memoizedState===null?!1:(kn.current&2)!==0),G&&(T=!0,l.flags&=-129),G=(l.flags&32)!==0,l.flags&=-33,i===null){if(Rt){if(T?Di(l):Oi(),(i=ln)?(i=GS(i,qr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:ji!==null?{id:ws,overflow:Cs}:null,retryLane:536870912,hydrationErrors:null},p=x_(i),p.return=l,l.child=p,qn=l,ln=null)):i=null,i===null)throw Ni(l);return fg(i)?l.lanes=32:l.lanes=536870912,null}var te=y.children;return y=y.fallback,T?(Oi(),T=l.mode,te=_d({mode:"hidden",children:te},T),y=_a(y,T,p,null),te.return=l,y.return=l,te.sibling=y,l.child=te,y=l.child,y.memoizedState=Ap(p),y.childLanes=Lp(i,G,p),l.memoizedState=Tp,hc(null,y)):(Di(l),Rp(l,te))}var le=i.memoizedState;if(le!==null&&(te=le.dehydrated,te!==null)){if(R)l.flags&256?(Di(l),l.flags&=-257,l=Dp(i,l,p)):l.memoizedState!==null?(Oi(),l.child=i.child,l.flags|=128,l=null):(Oi(),te=y.fallback,T=l.mode,y=_d({mode:"visible",children:y.children},T),te=_a(te,T,p,null),te.flags|=2,y.return=l,te.return=l,y.sibling=te,l.child=y,Na(l,i.child,null,p),y=l.child,y.memoizedState=Ap(p),y.childLanes=Lp(i,G,p),l.memoizedState=Tp,l=hc(null,y));else if(Di(l),fg(te)){if(G=te.nextSibling&&te.nextSibling.dataset,G)var ve=G.dgst;G=ve,y=Error(r(419)),y.stack="",y.digest=G,ec({value:y,source:null,stack:null}),l=Dp(i,l,p)}else if(Ln||To(i,l,p,!1),G=(p&i.childLanes)!==0,Ln||G){if(G=Jt,G!==null&&(y=ue(G,p),y!==0&&y!==le.retryLane))throw le.retryLane=y,va(i,y),yr(G,i,y),Ep;hg(te)||Ad(),l=Dp(i,l,p)}else hg(te)?(l.flags|=192,l.child=i.child,l=null):(i=le.treeContext,ln=Yr(te.nextSibling),qn=l,Rt=!0,Ei=null,qr=!1,i!==null&&v_(l,i),l=Rp(l,y.children),l.flags|=4096);return l}return T?(Oi(),te=y.fallback,T=l.mode,le=i.child,ve=le.sibling,y=Gs(le,{mode:"hidden",children:y.children}),y.subtreeFlags=le.subtreeFlags&65011712,ve!==null?te=Gs(ve,te):(te=_a(te,T,p,null),te.flags|=2),te.return=l,y.return=l,y.sibling=te,l.child=y,hc(null,y),y=l.child,te=i.child.memoizedState,te===null?te=Ap(p):(T=te.cachePool,T!==null?(le=Tn._currentValue,T=T.parent!==le?{parent:le,pool:le}:T):T=j_(),te={baseLanes:te.baseLanes|p,cachePool:T}),y.memoizedState=te,y.childLanes=Lp(i,G,p),l.memoizedState=Tp,hc(i.child,y)):(Di(l),p=i.child,i=p.sibling,p=Gs(p,{mode:"visible",children:y.children}),p.return=l,p.sibling=null,i!==null&&(G=l.deletions,G===null?(l.deletions=[i],l.flags|=16):G.push(i)),l.child=p,l.memoizedState=null,p)}function Rp(i,l){return l=_d({mode:"visible",children:l},i.mode),l.return=i,i.child=l}function _d(i,l){return i=Er(22,i,null,l),i.lanes=0,i}function Dp(i,l,p){return Na(l,i.child,null,p),i=Rp(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function $0(i,l,p){i.lanes|=l;var y=i.alternate;y!==null&&(y.lanes|=l),Km(i.return,l,p)}function Op(i,l,p,y,T,R){var G=i.memoizedState;G===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:T,treeForkCount:R}:(G.isBackwards=l,G.rendering=null,G.renderingStartTime=0,G.last=y,G.tail=p,G.tailMode=T,G.treeForkCount=R)}function F0(i,l,p){var y=l.pendingProps,T=y.revealOrder,R=y.tail;y=y.children;var G=kn.current,te=(G&2)!==0;if(te?(G=G&1|2,l.flags|=128):G&=1,$(kn,G),Yn(i,l,y,p),y=Rt?Zl:0,!te&&i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&$0(i,p,l);else if(i.tag===19)$0(i,p,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(T){case"forwards":for(p=l.child,T=null;p!==null;)i=p.alternate,i!==null&&cd(i)===null&&(T=p),p=p.sibling;p=T,p===null?(T=l.child,l.child=null):(T=p.sibling,p.sibling=null),Op(l,!1,T,p,R,y);break;case"backwards":case"unstable_legacy-backwards":for(p=null,T=l.child,l.child=null;T!==null;){if(i=T.alternate,i!==null&&cd(i)===null){l.child=T;break}i=T.sibling,T.sibling=p,p=T,T=i}Op(l,!0,p,null,R,y);break;case"together":Op(l,!1,null,null,void 0,y);break;default:l.memoizedState=null}return l.child}function Js(i,l,p){if(i!==null&&(l.dependencies=i.dependencies),Pi|=l.lanes,(p&l.childLanes)===0)if(i!==null){if(To(i,l,p,!1),(p&l.childLanes)===0)return null}else return null;if(i!==null&&l.child!==i.child)throw Error(r(153));if(l.child!==null){for(i=l.child,p=Gs(i,i.pendingProps),l.child=p,p.return=l;i.sibling!==null;)i=i.sibling,p=p.sibling=Gs(i,i.pendingProps),p.return=l;p.sibling=null}return l.child}function Ip(i,l){return(i.lanes&l)!==0?!0:(i=i.dependencies,!!(i!==null&&td(i)))}function XL(i,l,p){switch(l.tag){case 3:M(l,l.stateNode.containerInfo),Ti(l,Tn,i.memoizedState.cache),Sa();break;case 27:case 5:ne(l);break;case 4:M(l,l.stateNode.containerInfo);break;case 10:Ti(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,ap(l),null;break;case 13:var y=l.memoizedState;if(y!==null)return y.dehydrated!==null?(Di(l),l.flags|=128,null):(p&l.child.childLanes)!==0?B0(i,l,p):(Di(l),i=Js(i,l,p),i!==null?i.sibling:null);Di(l);break;case 19:var T=(i.flags&128)!==0;if(y=(p&l.childLanes)!==0,y||(To(i,l,p,!1),y=(p&l.childLanes)!==0),T){if(y)return F0(i,l,p);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),$(kn,kn.current),y)break;return null;case 22:return l.lanes=0,R0(i,l,p,l.pendingProps);case 24:Ti(l,Tn,i.memoizedState.cache)}return Js(i,l,p)}function z0(i,l,p){if(i!==null)if(i.memoizedProps!==l.pendingProps)Ln=!0;else{if(!Ip(i,p)&&(l.flags&128)===0)return Ln=!1,XL(i,l,p);Ln=(i.flags&131072)!==0}else Ln=!1,Rt&&(l.flags&1048576)!==0&&b_(l,Zl,l.index);switch(l.lanes=0,l.tag){case 16:e:{var y=l.pendingProps;if(i=ja(l.elementType),l.type=i,typeof i=="function")Fm(i)?(y=Aa(i,y),l.tag=1,l=M0(null,l,i,y,p)):(l.tag=0,l=Np(null,l,i,y,p));else{if(i!=null){var T=i.$$typeof;if(T===k){l.tag=11,l=T0(null,l,i,y,p);break e}else if(T===L){l.tag=14,l=A0(null,l,i,y,p);break e}}throw l=Y(i)||i,Error(r(306,l,""))}}return l;case 0:return Np(i,l,l.type,l.pendingProps,p);case 1:return y=l.type,T=Aa(y,l.pendingProps),M0(i,l,y,T,p);case 3:e:{if(M(l,l.stateNode.containerInfo),i===null)throw Error(r(387));y=l.pendingProps;var R=l.memoizedState;T=R.element,tp(i,l),oc(l,y,null,p);var G=l.memoizedState;if(y=G.cache,Ti(l,Tn,y),y!==R.cache&&Ym(l,[Tn],p,!0),ac(),y=G.element,R.isDehydrated)if(R={element:y,isDehydrated:!1,cache:G.cache},l.updateQueue.baseState=R,l.memoizedState=R,l.flags&256){l=P0(i,l,y,p);break e}else if(y!==T){T=Vr(Error(r(424)),l),ec(T),l=P0(i,l,y,p);break e}else{switch(i=l.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(ln=Yr(i.firstChild),qn=l,Rt=!0,Ei=null,qr=!0,p=R_(l,null,y,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(Sa(),y===T){l=Js(i,l,p);break e}Yn(i,l,y,p)}l=l.child}return l;case 26:return vd(i,l),i===null?(p=JS(l.type,null,l.pendingProps,null))?l.memoizedState=p:Rt||(p=l.type,i=l.pendingProps,y=Pd(Z.current).createElement(p),y[Be]=l,y[Je]=i,Xn(y,p,i),Hn(y),l.stateNode=y):l.memoizedState=JS(l.type,i.memoizedProps,l.pendingProps,i.memoizedState),null;case 27:return ne(l),i===null&&Rt&&(y=l.stateNode=YS(l.type,l.pendingProps,Z.current),qn=l,qr=!0,T=ln,Hi(l.type)?(mg=T,ln=Yr(y.firstChild)):ln=T),Yn(i,l,l.pendingProps.children,p),vd(i,l),i===null&&(l.flags|=4194304),l.child;case 5:return i===null&&Rt&&((T=y=ln)&&(y=jR(y,l.type,l.pendingProps,qr),y!==null?(l.stateNode=y,qn=l,ln=Yr(y.firstChild),qr=!1,T=!0):T=!1),T||Ni(l)),ne(l),T=l.type,R=l.pendingProps,G=i!==null?i.memoizedProps:null,y=R.children,cg(T,R)?y=null:G!==null&&cg(T,G)&&(l.flags|=32),l.memoizedState!==null&&(T=lp(i,l,zL,null,null,p),Ec._currentValue=T),vd(i,l),Yn(i,l,y,p),l.child;case 6:return i===null&&Rt&&((i=p=ln)&&(p=ER(p,l.pendingProps,qr),p!==null?(l.stateNode=p,qn=l,ln=null,i=!0):i=!1),i||Ni(l)),null;case 13:return B0(i,l,p);case 4:return M(l,l.stateNode.containerInfo),y=l.pendingProps,i===null?l.child=Na(l,null,y,p):Yn(i,l,y,p),l.child;case 11:return T0(i,l,l.type,l.pendingProps,p);case 7:return Yn(i,l,l.pendingProps,p),l.child;case 8:return Yn(i,l,l.pendingProps.children,p),l.child;case 12:return Yn(i,l,l.pendingProps.children,p),l.child;case 10:return y=l.pendingProps,Ti(l,l.type,y.value),Yn(i,l,y.children,p),l.child;case 9:return T=l.type._context,y=l.pendingProps.children,Ca(l),T=Kn(T),y=y(T),l.flags|=1,Yn(i,l,y,p),l.child;case 14:return A0(i,l,l.type,l.pendingProps,p);case 15:return L0(i,l,l.type,l.pendingProps,p);case 19:return F0(i,l,p);case 31:return YL(i,l,p);case 22:return R0(i,l,p,l.pendingProps);case 24:return Ca(l),y=Kn(Tn),i===null?(T=Jm(),T===null&&(T=Jt,R=Xm(),T.pooledCache=R,R.refCount++,R!==null&&(T.pooledCacheLanes|=p),T=R),l.memoizedState={parent:y,cache:T},ep(l),Ti(l,Tn,T)):((i.lanes&p)!==0&&(tp(i,l),oc(l,null,null,p),ac()),T=i.memoizedState,R=l.memoizedState,T.parent!==y?(T={parent:y,cache:y},l.memoizedState=T,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=T),Ti(l,Tn,y)):(y=R.cache,Ti(l,Tn,y),y!==T.cache&&Ym(l,[Tn],p,!0))),Yn(i,l,l.pendingProps.children,p),l.child;case 29:throw l.pendingProps}throw Error(r(156,l.tag))}function Zs(i){i.flags|=4}function Mp(i,l,p,y,T){if((l=(i.mode&32)!==0)&&(l=!1),l){if(i.flags|=16777216,(T&335544128)===T)if(i.stateNode.complete)i.flags|=8192;else if(mS())i.flags|=8192;else throw Ea=id,Zm}else i.flags&=-16777217}function H0(i,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!rw(l))if(mS())i.flags|=8192;else throw Ea=id,Zm}function Sd(i,l){l!==null&&(i.flags|=4),i.flags&16384&&(l=i.tag!==22?gn():536870912,i.lanes|=l,zo|=l)}function fc(i,l){if(!Rt)switch(i.tailMode){case"hidden":l=i.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?i.tail=null:p.sibling=null;break;case"collapsed":p=i.tail;for(var y=null;p!==null;)p.alternate!==null&&(y=p),p=p.sibling;y===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:y.sibling=null}}function cn(i){var l=i.alternate!==null&&i.alternate.child===i.child,p=0,y=0;if(l)for(var T=i.child;T!==null;)p|=T.lanes|T.childLanes,y|=T.subtreeFlags&65011712,y|=T.flags&65011712,T.return=i,T=T.sibling;else for(T=i.child;T!==null;)p|=T.lanes|T.childLanes,y|=T.subtreeFlags,y|=T.flags,T.return=i,T=T.sibling;return i.subtreeFlags|=y,i.childLanes=p,l}function QL(i,l,p){var y=l.pendingProps;switch(Vm(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return cn(l),null;case 1:return cn(l),null;case 3:return p=l.stateNode,y=null,i!==null&&(y=i.memoizedState.cache),l.memoizedState.cache!==y&&(l.flags|=2048),Ys(Tn),X(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(i===null||i.child===null)&&(No(l)?Zs(l):i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Gm())),cn(l),null;case 26:var T=l.type,R=l.memoizedState;return i===null?(Zs(l),R!==null?(cn(l),H0(l,R)):(cn(l),Mp(l,T,null,y,p))):R?R!==i.memoizedState?(Zs(l),cn(l),H0(l,R)):(cn(l),l.flags&=-16777217):(i=i.memoizedProps,i!==y&&Zs(l),cn(l),Mp(l,T,i,y,p)),null;case 27:if(re(l),p=Z.current,T=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&Zs(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return cn(l),null}i=Q.current,No(l)?__(l):(i=YS(T,y,p),l.stateNode=i,Zs(l))}return cn(l),null;case 5:if(re(l),T=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&Zs(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return cn(l),null}if(R=Q.current,No(l))__(l);else{var G=Pd(Z.current);switch(R){case 1:R=G.createElementNS("http://www.w3.org/2000/svg",T);break;case 2:R=G.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;default:switch(T){case"svg":R=G.createElementNS("http://www.w3.org/2000/svg",T);break;case"math":R=G.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;case"script":R=G.createElement("div"),R.innerHTML="<script><\/script>",R=R.removeChild(R.firstChild);break;case"select":R=typeof y.is=="string"?G.createElement("select",{is:y.is}):G.createElement("select"),y.multiple?R.multiple=!0:y.size&&(R.size=y.size);break;default:R=typeof y.is=="string"?G.createElement(T,{is:y.is}):G.createElement(T)}}R[Be]=l,R[Je]=y;e:for(G=l.child;G!==null;){if(G.tag===5||G.tag===6)R.appendChild(G.stateNode);else if(G.tag!==4&&G.tag!==27&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===l)break e;for(;G.sibling===null;){if(G.return===null||G.return===l)break e;G=G.return}G.sibling.return=G.return,G=G.sibling}l.stateNode=R;e:switch(Xn(R,T,y),T){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}y&&Zs(l)}}return cn(l),Mp(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,p),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==y&&Zs(l);else{if(typeof y!="string"&&l.stateNode===null)throw Error(r(166));if(i=Z.current,No(l)){if(i=l.stateNode,p=l.memoizedProps,y=null,T=qn,T!==null)switch(T.tag){case 27:case 5:y=T.memoizedProps}i[Be]=l,i=!!(i.nodeValue===p||y!==null&&y.suppressHydrationWarning===!0||BS(i.nodeValue,p)),i||Ni(l,!0)}else i=Pd(i).createTextNode(y),i[Be]=l,l.stateNode=i}return cn(l),null;case 31:if(p=l.memoizedState,i===null||i.memoizedState!==null){if(y=No(l),p!==null){if(i===null){if(!y)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Be]=l}else Sa(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;cn(l),i=!1}else p=Gm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=p),i=!0;if(!i)return l.flags&256?(Tr(l),l):(Tr(l),null);if((l.flags&128)!==0)throw Error(r(558))}return cn(l),null;case 13:if(y=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(T=No(l),y!==null&&y.dehydrated!==null){if(i===null){if(!T)throw Error(r(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(r(317));T[Be]=l}else Sa(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;cn(l),T=!1}else T=Gm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=T),T=!0;if(!T)return l.flags&256?(Tr(l),l):(Tr(l),null)}return Tr(l),(l.flags&128)!==0?(l.lanes=p,l):(p=y!==null,i=i!==null&&i.memoizedState!==null,p&&(y=l.child,T=null,y.alternate!==null&&y.alternate.memoizedState!==null&&y.alternate.memoizedState.cachePool!==null&&(T=y.alternate.memoizedState.cachePool.pool),R=null,y.memoizedState!==null&&y.memoizedState.cachePool!==null&&(R=y.memoizedState.cachePool.pool),R!==T&&(y.flags|=2048)),p!==i&&p&&(l.child.flags|=8192),Sd(l,l.updateQueue),cn(l),null);case 4:return X(),i===null&&sg(l.stateNode.containerInfo),cn(l),null;case 10:return Ys(l.type),cn(l),null;case 19:if(U(kn),y=l.memoizedState,y===null)return cn(l),null;if(T=(l.flags&128)!==0,R=y.rendering,R===null)if(T)fc(y,!1);else{if(_n!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(R=cd(i),R!==null){for(l.flags|=128,fc(y,!1),i=R.updateQueue,l.updateQueue=i,Sd(l,i),l.subtreeFlags=0,i=p,p=l.child;p!==null;)g_(p,i),p=p.sibling;return $(kn,kn.current&1|2),Rt&&qs(l,y.treeForkCount),l.child}i=i.sibling}y.tail!==null&&Me()>Ed&&(l.flags|=128,T=!0,fc(y,!1),l.lanes=4194304)}else{if(!T)if(i=cd(R),i!==null){if(l.flags|=128,T=!0,i=i.updateQueue,l.updateQueue=i,Sd(l,i),fc(y,!0),y.tail===null&&y.tailMode==="hidden"&&!R.alternate&&!Rt)return cn(l),null}else 2*Me()-y.renderingStartTime>Ed&&p!==536870912&&(l.flags|=128,T=!0,fc(y,!1),l.lanes=4194304);y.isBackwards?(R.sibling=l.child,l.child=R):(i=y.last,i!==null?i.sibling=R:l.child=R,y.last=R)}return y.tail!==null?(i=y.tail,y.rendering=i,y.tail=i.sibling,y.renderingStartTime=Me(),i.sibling=null,p=kn.current,$(kn,T?p&1|2:p&1),Rt&&qs(l,y.treeForkCount),i):(cn(l),null);case 22:case 23:return Tr(l),ip(),y=l.memoizedState!==null,i!==null?i.memoizedState!==null!==y&&(l.flags|=8192):y&&(l.flags|=8192),y?(p&536870912)!==0&&(l.flags&128)===0&&(cn(l),l.subtreeFlags&6&&(l.flags|=8192)):cn(l),p=l.updateQueue,p!==null&&Sd(l,p.retryQueue),p=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(p=i.memoizedState.cachePool.pool),y=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(y=l.memoizedState.cachePool.pool),y!==p&&(l.flags|=2048),i!==null&&U(ka),null;case 24:return p=null,i!==null&&(p=i.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),Ys(Tn),cn(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function JL(i,l){switch(Vm(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return Ys(Tn),X(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return re(l),null;case 31:if(l.memoizedState!==null){if(Tr(l),l.alternate===null)throw Error(r(340));Sa()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(Tr(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Sa()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return U(kn),null;case 4:return X(),null;case 10:return Ys(l.type),null;case 22:case 23:return Tr(l),ip(),i!==null&&U(ka),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return Ys(Tn),null;case 25:return null;default:return null}}function U0(i,l){switch(Vm(l),l.tag){case 3:Ys(Tn),X();break;case 26:case 27:case 5:re(l);break;case 4:X();break;case 31:l.memoizedState!==null&&Tr(l);break;case 13:Tr(l);break;case 19:U(kn);break;case 10:Ys(l.type);break;case 22:case 23:Tr(l),ip(),i!==null&&U(ka);break;case 24:Ys(Tn)}}function mc(i,l){try{var p=l.updateQueue,y=p!==null?p.lastEffect:null;if(y!==null){var T=y.next;p=T;do{if((p.tag&i)===i){y=void 0;var R=p.create,G=p.inst;y=R(),G.destroy=y}p=p.next}while(p!==T)}}catch(te){Gt(l,l.return,te)}}function Ii(i,l,p){try{var y=l.updateQueue,T=y!==null?y.lastEffect:null;if(T!==null){var R=T.next;y=R;do{if((y.tag&i)===i){var G=y.inst,te=G.destroy;if(te!==void 0){G.destroy=void 0,T=l;var le=p,ve=te;try{ve()}catch(Ie){Gt(T,le,Ie)}}}y=y.next}while(y!==R)}}catch(Ie){Gt(l,l.return,Ie)}}function V0(i){var l=i.updateQueue;if(l!==null){var p=i.stateNode;try{O_(l,p)}catch(y){Gt(i,i.return,y)}}}function W0(i,l,p){p.props=Aa(i.type,i.memoizedProps),p.state=i.memoizedState;try{p.componentWillUnmount()}catch(y){Gt(i,l,y)}}function pc(i,l){try{var p=i.ref;if(p!==null){switch(i.tag){case 26:case 27:case 5:var y=i.stateNode;break;case 30:y=i.stateNode;break;default:y=i.stateNode}typeof p=="function"?i.refCleanup=p(y):p.current=y}}catch(T){Gt(i,l,T)}}function ks(i,l){var p=i.ref,y=i.refCleanup;if(p!==null)if(typeof y=="function")try{y()}catch(T){Gt(i,l,T)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(T){Gt(i,l,T)}else p.current=null}function G0(i){var l=i.type,p=i.memoizedProps,y=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":p.autoFocus&&y.focus();break e;case"img":p.src?y.src=p.src:p.srcSet&&(y.srcset=p.srcSet)}}catch(T){Gt(i,i.return,T)}}function Pp(i,l,p){try{var y=i.stateNode;vR(y,i.type,p,l),y[Je]=l}catch(T){Gt(i,i.return,T)}}function q0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Hi(i.type)||i.tag===4}function Bp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||q0(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&&Hi(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 $p(i,l,p){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(i,l):(l=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,l.appendChild(i),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=Vs));else if(y!==4&&(y===27&&Hi(i.type)&&(p=i.stateNode,l=null),i=i.child,i!==null))for($p(i,l,p),i=i.sibling;i!==null;)$p(i,l,p),i=i.sibling}function wd(i,l,p){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?p.insertBefore(i,l):p.appendChild(i);else if(y!==4&&(y===27&&Hi(i.type)&&(p=i.stateNode),i=i.child,i!==null))for(wd(i,l,p),i=i.sibling;i!==null;)wd(i,l,p),i=i.sibling}function K0(i){var l=i.stateNode,p=i.memoizedProps;try{for(var y=i.type,T=l.attributes;T.length;)l.removeAttributeNode(T[0]);Xn(l,y,p),l[Be]=i,l[Je]=p}catch(R){Gt(i,i.return,R)}}var ei=!1,Rn=!1,Fp=!1,Y0=typeof WeakSet=="function"?WeakSet:Set,Un=null;function ZL(i,l){if(i=i.containerInfo,og=Vd,i=o_(i),Dm(i)){if("selectionStart"in i)var p={start:i.selectionStart,end:i.selectionEnd};else e:{p=(p=i.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var T=y.anchorOffset,R=y.focusNode;y=y.focusOffset;try{p.nodeType,R.nodeType}catch{p=null;break e}var G=0,te=-1,le=-1,ve=0,Ie=0,$e=i,Ce=null;t:for(;;){for(var je;$e!==p||T!==0&&$e.nodeType!==3||(te=G+T),$e!==R||y!==0&&$e.nodeType!==3||(le=G+y),$e.nodeType===3&&(G+=$e.nodeValue.length),(je=$e.firstChild)!==null;)Ce=$e,$e=je;for(;;){if($e===i)break t;if(Ce===p&&++ve===T&&(te=G),Ce===R&&++Ie===y&&(le=G),(je=$e.nextSibling)!==null)break;$e=Ce,Ce=$e.parentNode}$e=je}p=te===-1||le===-1?null:{start:te,end:le}}else p=null}p=p||{start:0,end:0}}else p=null;for(lg={focusedElem:i,selectionRange:p},Vd=!1,Un=l;Un!==null;)if(l=Un,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,Un=i;else for(;Un!==null;){switch(l=Un,R=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(p=0;p<i.length;p++)T=i[p],T.ref.impl=T.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&R!==null){i=void 0,p=l,T=R.memoizedProps,R=R.memoizedState,y=p.stateNode;try{var rt=Aa(p.type,T);i=y.getSnapshotBeforeUpdate(rt,R),y.__reactInternalSnapshotBeforeUpdate=i}catch(ht){Gt(p,p.return,ht)}}break;case 3:if((i&1024)!==0){if(i=l.stateNode.containerInfo,p=i.nodeType,p===9)dg(i);else if(p===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":dg(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=l.sibling,i!==null){i.return=l.return,Un=i;break}Un=l.return}}function X0(i,l,p){var y=p.flags;switch(p.tag){case 0:case 11:case 15:ni(i,p),y&4&&mc(5,p);break;case 1:if(ni(i,p),y&4)if(i=p.stateNode,l===null)try{i.componentDidMount()}catch(G){Gt(p,p.return,G)}else{var T=Aa(p.type,l.memoizedProps);l=l.memoizedState;try{i.componentDidUpdate(T,l,i.__reactInternalSnapshotBeforeUpdate)}catch(G){Gt(p,p.return,G)}}y&64&&V0(p),y&512&&pc(p,p.return);break;case 3:if(ni(i,p),y&64&&(i=p.updateQueue,i!==null)){if(l=null,p.child!==null)switch(p.child.tag){case 27:case 5:l=p.child.stateNode;break;case 1:l=p.child.stateNode}try{O_(i,l)}catch(G){Gt(p,p.return,G)}}break;case 27:l===null&&y&4&&K0(p);case 26:case 5:ni(i,p),l===null&&y&4&&G0(p),y&512&&pc(p,p.return);break;case 12:ni(i,p);break;case 31:ni(i,p),y&4&&Z0(i,p);break;case 13:ni(i,p),y&4&&eS(i,p),y&64&&(i=p.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(p=lR.bind(null,p),NR(i,p))));break;case 22:if(y=p.memoizedState!==null||ei,!y){l=l!==null&&l.memoizedState!==null||Rn,T=ei;var R=Rn;ei=y,(Rn=l)&&!R?ri(i,p,(p.subtreeFlags&8772)!==0):ni(i,p),ei=T,Rn=R}break;case 30:break;default:ni(i,p)}}function Q0(i){var l=i.alternate;l!==null&&(i.alternate=null,Q0(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&ho(l)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var mn=null,mr=!1;function ti(i,l,p){for(p=p.child;p!==null;)J0(i,l,p),p=p.sibling}function J0(i,l,p){if(ot&&typeof ot.onCommitFiberUnmount=="function")try{ot.onCommitFiberUnmount(et,p)}catch{}switch(p.tag){case 26:Rn||ks(p,l),ti(i,l,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:Rn||ks(p,l);var y=mn,T=mr;Hi(p.type)&&(mn=p.stateNode,mr=!1),ti(i,l,p),Cc(p.stateNode),mn=y,mr=T;break;case 5:Rn||ks(p,l);case 6:if(y=mn,T=mr,mn=null,ti(i,l,p),mn=y,mr=T,mn!==null)if(mr)try{(mn.nodeType===9?mn.body:mn.nodeName==="HTML"?mn.ownerDocument.body:mn).removeChild(p.stateNode)}catch(R){Gt(p,l,R)}else try{mn.removeChild(p.stateNode)}catch(R){Gt(p,l,R)}break;case 18:mn!==null&&(mr?(i=mn,VS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,p.stateNode),Yo(i)):VS(mn,p.stateNode));break;case 4:y=mn,T=mr,mn=p.stateNode.containerInfo,mr=!0,ti(i,l,p),mn=y,mr=T;break;case 0:case 11:case 14:case 15:Ii(2,p,l),Rn||Ii(4,p,l),ti(i,l,p);break;case 1:Rn||(ks(p,l),y=p.stateNode,typeof y.componentWillUnmount=="function"&&W0(p,l,y)),ti(i,l,p);break;case 21:ti(i,l,p);break;case 22:Rn=(y=Rn)||p.memoizedState!==null,ti(i,l,p),Rn=y;break;default:ti(i,l,p)}}function Z0(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Yo(i)}catch(p){Gt(l,l.return,p)}}}function eS(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Yo(i)}catch(p){Gt(l,l.return,p)}}function eR(i){switch(i.tag){case 31:case 13:case 19:var l=i.stateNode;return l===null&&(l=i.stateNode=new Y0),l;case 22:return i=i.stateNode,l=i._retryCache,l===null&&(l=i._retryCache=new Y0),l;default:throw Error(r(435,i.tag))}}function Cd(i,l){var p=eR(i);l.forEach(function(y){if(!p.has(y)){p.add(y);var T=cR.bind(null,i,y);y.then(T,T)}})}function pr(i,l){var p=l.deletions;if(p!==null)for(var y=0;y<p.length;y++){var T=p[y],R=i,G=l,te=G;e:for(;te!==null;){switch(te.tag){case 27:if(Hi(te.type)){mn=te.stateNode,mr=!1;break e}break;case 5:mn=te.stateNode,mr=!1;break e;case 3:case 4:mn=te.stateNode.containerInfo,mr=!0;break e}te=te.return}if(mn===null)throw Error(r(160));J0(R,G,T),mn=null,mr=!1,R=T.alternate,R!==null&&(R.return=null),T.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)tS(l,i),l=l.sibling}var ls=null;function tS(i,l){var p=i.alternate,y=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:pr(l,i),gr(i),y&4&&(Ii(3,i,i.return),mc(3,i),Ii(5,i,i.return));break;case 1:pr(l,i),gr(i),y&512&&(Rn||p===null||ks(p,p.return)),y&64&&ei&&(i=i.updateQueue,i!==null&&(y=i.callbacks,y!==null&&(p=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=p===null?y:p.concat(y))));break;case 26:var T=ls;if(pr(l,i),gr(i),y&512&&(Rn||p===null||ks(p,p.return)),y&4){var R=p!==null?p.memoizedState:null;if(y=i.memoizedState,p===null)if(y===null)if(i.stateNode===null){e:{y=i.type,p=i.memoizedProps,T=T.ownerDocument||T;t:switch(y){case"title":R=T.getElementsByTagName("title")[0],(!R||R[Nn]||R[Be]||R.namespaceURI==="http://www.w3.org/2000/svg"||R.hasAttribute("itemprop"))&&(R=T.createElement(y),T.head.insertBefore(R,T.querySelector("head > title"))),Xn(R,y,p),R[Be]=i,Hn(R),y=R;break e;case"link":var G=tw("link","href",T).get(y+(p.href||""));if(G){for(var te=0;te<G.length;te++)if(R=G[te],R.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&R.getAttribute("rel")===(p.rel==null?null:p.rel)&&R.getAttribute("title")===(p.title==null?null:p.title)&&R.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){G.splice(te,1);break t}}R=T.createElement(y),Xn(R,y,p),T.head.appendChild(R);break;case"meta":if(G=tw("meta","content",T).get(y+(p.content||""))){for(te=0;te<G.length;te++)if(R=G[te],R.getAttribute("content")===(p.content==null?null:""+p.content)&&R.getAttribute("name")===(p.name==null?null:p.name)&&R.getAttribute("property")===(p.property==null?null:p.property)&&R.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&R.getAttribute("charset")===(p.charSet==null?null:p.charSet)){G.splice(te,1);break t}}R=T.createElement(y),Xn(R,y,p),T.head.appendChild(R);break;default:throw Error(r(468,y))}R[Be]=i,Hn(R),y=R}i.stateNode=y}else nw(T,i.type,i.stateNode);else i.stateNode=ew(T,y,i.memoizedProps);else R!==y?(R===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):R.count--,y===null?nw(T,i.type,i.stateNode):ew(T,y,i.memoizedProps)):y===null&&i.stateNode!==null&&Pp(i,i.memoizedProps,p.memoizedProps)}break;case 27:pr(l,i),gr(i),y&512&&(Rn||p===null||ks(p,p.return)),p!==null&&y&4&&Pp(i,i.memoizedProps,p.memoizedProps);break;case 5:if(pr(l,i),gr(i),y&512&&(Rn||p===null||ks(p,p.return)),i.flags&32){T=i.stateNode;try{yo(T,"")}catch(rt){Gt(i,i.return,rt)}}y&4&&i.stateNode!=null&&(T=i.memoizedProps,Pp(i,T,p!==null?p.memoizedProps:T)),y&1024&&(Fp=!0);break;case 6:if(pr(l,i),gr(i),y&4){if(i.stateNode===null)throw Error(r(162));y=i.memoizedProps,p=i.stateNode;try{p.nodeValue=y}catch(rt){Gt(i,i.return,rt)}}break;case 3:if(Fd=null,T=ls,ls=Bd(l.containerInfo),pr(l,i),ls=T,gr(i),y&4&&p!==null&&p.memoizedState.isDehydrated)try{Yo(l.containerInfo)}catch(rt){Gt(i,i.return,rt)}Fp&&(Fp=!1,nS(i));break;case 4:y=ls,ls=Bd(i.stateNode.containerInfo),pr(l,i),gr(i),ls=y;break;case 12:pr(l,i),gr(i);break;case 31:pr(l,i),gr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,Cd(i,y)));break;case 13:pr(l,i),gr(i),i.child.flags&8192&&i.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(jd=Me()),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,Cd(i,y)));break;case 22:T=i.memoizedState!==null;var le=p!==null&&p.memoizedState!==null,ve=ei,Ie=Rn;if(ei=ve||T,Rn=Ie||le,pr(l,i),Rn=Ie,ei=ve,gr(i),y&8192)e:for(l=i.stateNode,l._visibility=T?l._visibility&-2:l._visibility|1,T&&(p===null||le||ei||Rn||La(i)),p=null,l=i;;){if(l.tag===5||l.tag===26){if(p===null){le=p=l;try{if(R=le.stateNode,T)G=R.style,typeof G.setProperty=="function"?G.setProperty("display","none","important"):G.display="none";else{te=le.stateNode;var $e=le.memoizedProps.style,Ce=$e!=null&&$e.hasOwnProperty("display")?$e.display:null;te.style.display=Ce==null||typeof Ce=="boolean"?"":(""+Ce).trim()}}catch(rt){Gt(le,le.return,rt)}}}else if(l.tag===6){if(p===null){le=l;try{le.stateNode.nodeValue=T?"":le.memoizedProps}catch(rt){Gt(le,le.return,rt)}}}else if(l.tag===18){if(p===null){le=l;try{var je=le.stateNode;T?WS(je,!0):WS(le.stateNode,!1)}catch(rt){Gt(le,le.return,rt)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===i)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break e;for(;l.sibling===null;){if(l.return===null||l.return===i)break e;p===l&&(p=null),l=l.return}p===l&&(p=null),l.sibling.return=l.return,l=l.sibling}y&4&&(y=i.updateQueue,y!==null&&(p=y.retryQueue,p!==null&&(y.retryQueue=null,Cd(i,p))));break;case 19:pr(l,i),gr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,Cd(i,y)));break;case 30:break;case 21:break;default:pr(l,i),gr(i)}}function gr(i){var l=i.flags;if(l&2){try{for(var p,y=i.return;y!==null;){if(q0(y)){p=y;break}y=y.return}if(p==null)throw Error(r(160));switch(p.tag){case 27:var T=p.stateNode,R=Bp(i);wd(i,R,T);break;case 5:var G=p.stateNode;p.flags&32&&(yo(G,""),p.flags&=-33);var te=Bp(i);wd(i,te,G);break;case 3:case 4:var le=p.stateNode.containerInfo,ve=Bp(i);$p(i,ve,le);break;default:throw Error(r(161))}}catch(Ie){Gt(i,i.return,Ie)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function nS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var l=i;nS(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),i=i.sibling}}function ni(i,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)X0(i,l.alternate,l),l=l.sibling}function La(i){for(i=i.child;i!==null;){var l=i;switch(l.tag){case 0:case 11:case 14:case 15:Ii(4,l,l.return),La(l);break;case 1:ks(l,l.return);var p=l.stateNode;typeof p.componentWillUnmount=="function"&&W0(l,l.return,p),La(l);break;case 27:Cc(l.stateNode);case 26:case 5:ks(l,l.return),La(l);break;case 22:l.memoizedState===null&&La(l);break;case 30:La(l);break;default:La(l)}i=i.sibling}}function ri(i,l,p){for(p=p&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var y=l.alternate,T=i,R=l,G=R.flags;switch(R.tag){case 0:case 11:case 15:ri(T,R,p),mc(4,R);break;case 1:if(ri(T,R,p),y=R,T=y.stateNode,typeof T.componentDidMount=="function")try{T.componentDidMount()}catch(ve){Gt(y,y.return,ve)}if(y=R,T=y.updateQueue,T!==null){var te=y.stateNode;try{var le=T.shared.hiddenCallbacks;if(le!==null)for(T.shared.hiddenCallbacks=null,T=0;T<le.length;T++)D_(le[T],te)}catch(ve){Gt(y,y.return,ve)}}p&&G&64&&V0(R),pc(R,R.return);break;case 27:K0(R);case 26:case 5:ri(T,R,p),p&&y===null&&G&4&&G0(R),pc(R,R.return);break;case 12:ri(T,R,p);break;case 31:ri(T,R,p),p&&G&4&&Z0(T,R);break;case 13:ri(T,R,p),p&&G&4&&eS(T,R);break;case 22:R.memoizedState===null&&ri(T,R,p),pc(R,R.return);break;case 30:break;default:ri(T,R,p)}l=l.sibling}}function zp(i,l){var p=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(p=i.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==p&&(i!=null&&i.refCount++,p!=null&&tc(p))}function Hp(i,l){i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&tc(i))}function cs(i,l,p,y){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)rS(i,l,p,y),l=l.sibling}function rS(i,l,p,y){var T=l.flags;switch(l.tag){case 0:case 11:case 15:cs(i,l,p,y),T&2048&&mc(9,l);break;case 1:cs(i,l,p,y);break;case 3:cs(i,l,p,y),T&2048&&(i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&tc(i)));break;case 12:if(T&2048){cs(i,l,p,y),i=l.stateNode;try{var R=l.memoizedProps,G=R.id,te=R.onPostCommit;typeof te=="function"&&te(G,l.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(le){Gt(l,l.return,le)}}else cs(i,l,p,y);break;case 31:cs(i,l,p,y);break;case 13:cs(i,l,p,y);break;case 23:break;case 22:R=l.stateNode,G=l.alternate,l.memoizedState!==null?R._visibility&2?cs(i,l,p,y):gc(i,l):R._visibility&2?cs(i,l,p,y):(R._visibility|=2,Bo(i,l,p,y,(l.subtreeFlags&10256)!==0||!1)),T&2048&&zp(G,l);break;case 24:cs(i,l,p,y),T&2048&&Hp(l.alternate,l);break;default:cs(i,l,p,y)}}function Bo(i,l,p,y,T){for(T=T&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var R=i,G=l,te=p,le=y,ve=G.flags;switch(G.tag){case 0:case 11:case 15:Bo(R,G,te,le,T),mc(8,G);break;case 23:break;case 22:var Ie=G.stateNode;G.memoizedState!==null?Ie._visibility&2?Bo(R,G,te,le,T):gc(R,G):(Ie._visibility|=2,Bo(R,G,te,le,T)),T&&ve&2048&&zp(G.alternate,G);break;case 24:Bo(R,G,te,le,T),T&&ve&2048&&Hp(G.alternate,G);break;default:Bo(R,G,te,le,T)}l=l.sibling}}function gc(i,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var p=i,y=l,T=y.flags;switch(y.tag){case 22:gc(p,y),T&2048&&zp(y.alternate,y);break;case 24:gc(p,y),T&2048&&Hp(y.alternate,y);break;default:gc(p,y)}l=l.sibling}}var xc=8192;function $o(i,l,p){if(i.subtreeFlags&xc)for(i=i.child;i!==null;)sS(i,l,p),i=i.sibling}function sS(i,l,p){switch(i.tag){case 26:$o(i,l,p),i.flags&xc&&i.memoizedState!==null&&FR(p,ls,i.memoizedState,i.memoizedProps);break;case 5:$o(i,l,p);break;case 3:case 4:var y=ls;ls=Bd(i.stateNode.containerInfo),$o(i,l,p),ls=y;break;case 22:i.memoizedState===null&&(y=i.alternate,y!==null&&y.memoizedState!==null?(y=xc,xc=16777216,$o(i,l,p),xc=y):$o(i,l,p));break;default:$o(i,l,p)}}function iS(i){var l=i.alternate;if(l!==null&&(i=l.child,i!==null)){l.child=null;do l=i.sibling,i.sibling=null,i=l;while(i!==null)}}function yc(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var p=0;p<l.length;p++){var y=l[p];Un=y,oS(y,i)}iS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)aS(i),i=i.sibling}function aS(i){switch(i.tag){case 0:case 11:case 15:yc(i),i.flags&2048&&Ii(9,i,i.return);break;case 3:yc(i);break;case 12:yc(i);break;case 22:var l=i.stateNode;i.memoizedState!==null&&l._visibility&2&&(i.return===null||i.return.tag!==13)?(l._visibility&=-3,kd(i)):yc(i);break;default:yc(i)}}function kd(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var p=0;p<l.length;p++){var y=l[p];Un=y,oS(y,i)}iS(i)}for(i=i.child;i!==null;){switch(l=i,l.tag){case 0:case 11:case 15:Ii(8,l,l.return),kd(l);break;case 22:p=l.stateNode,p._visibility&2&&(p._visibility&=-3,kd(l));break;default:kd(l)}i=i.sibling}}function oS(i,l){for(;Un!==null;){var p=Un;switch(p.tag){case 0:case 11:case 15:Ii(8,p,l);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var y=p.memoizedState.cachePool.pool;y!=null&&y.refCount++}break;case 24:tc(p.memoizedState.cache)}if(y=p.child,y!==null)y.return=p,Un=y;else e:for(p=i;Un!==null;){y=Un;var T=y.sibling,R=y.return;if(Q0(y),y===p){Un=null;break e}if(T!==null){T.return=R,Un=T;break e}Un=R}}}var tR={getCacheForType:function(i){var l=Kn(Tn),p=l.data.get(i);return p===void 0&&(p=i(),l.data.set(i,p)),p},cacheSignal:function(){return Kn(Tn).controller.signal}},nR=typeof WeakMap=="function"?WeakMap:Map,Ft=0,Jt=null,Et=null,At=0,Wt=0,Ar=null,Mi=!1,Fo=!1,Up=!1,si=0,_n=0,Pi=0,Ra=0,Vp=0,Lr=0,zo=0,bc=null,xr=null,Wp=!1,jd=0,lS=0,Ed=1/0,Nd=null,Bi=null,Pn=0,$i=null,Ho=null,ii=0,Gp=0,qp=null,cS=null,vc=0,Kp=null;function Rr(){return(Ft&2)!==0&&At!==0?At&-At:W.T!==null?eg():Dt()}function uS(){if(Lr===0)if((At&536870912)===0||Rt){var i=wt;wt<<=1,(wt&3932160)===0&&(wt=262144),Lr=i}else Lr=536870912;return i=Nr.current,i!==null&&(i.flags|=32),Lr}function yr(i,l,p){(i===Jt&&(Wt===2||Wt===9)||i.cancelPendingCommit!==null)&&(Uo(i,0),Fi(i,At,Lr,!1)),Se(i,p),((Ft&2)===0||i!==Jt)&&(i===Jt&&((Ft&2)===0&&(Ra|=p),_n===4&&Fi(i,At,Lr,!1)),js(i))}function dS(i,l,p){if((Ft&6)!==0)throw Error(r(327));var y=!p&&(l&127)===0&&(l&i.expiredLanes)===0||zn(i,l),T=y?iR(i,l):Xp(i,l,!0),R=y;do{if(T===0){Fo&&!y&&Fi(i,l,0,!1);break}else{if(p=i.current.alternate,R&&!rR(p)){T=Xp(i,l,!1),R=!1;continue}if(T===2){if(R=l,i.errorRecoveryDisabledLanes&R)var G=0;else G=i.pendingLanes&-536870913,G=G!==0?G:G&536870912?536870912:0;if(G!==0){l=G;e:{var te=i;T=bc;var le=te.current.memoizedState.isDehydrated;if(le&&(Uo(te,G).flags|=256),G=Xp(te,G,!1),G!==2){if(Up&&!le){te.errorRecoveryDisabledLanes|=R,Ra|=R,T=4;break e}R=xr,xr=T,R!==null&&(xr===null?xr=R:xr.push.apply(xr,R))}T=G}if(R=!1,T!==2)continue}}if(T===1){Uo(i,0),Fi(i,l,0,!0);break}e:{switch(y=i,R=T,R){case 0:case 1:throw Error(r(345));case 4:if((l&4194048)!==l)break;case 6:Fi(y,l,Lr,!Mi);break e;case 2:xr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((l&62914560)===l&&(T=jd+300-Me(),10<T)){if(Fi(y,l,Lr,!Mi),fn(y,0,!0)!==0)break e;ii=l,y.timeoutHandle=HS(hS.bind(null,y,p,xr,Nd,Wp,l,Lr,Ra,zo,Mi,R,"Throttled",-0,0),T);break e}hS(y,p,xr,Nd,Wp,l,Lr,Ra,zo,Mi,R,null,-0,0)}}break}while(!0);js(i)}function hS(i,l,p,y,T,R,G,te,le,ve,Ie,$e,Ce,je){if(i.timeoutHandle=-1,$e=l.subtreeFlags,$e&8192||($e&16785408)===16785408){$e={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vs},sS(l,R,$e);var rt=(R&62914560)===R?jd-Me():(R&4194048)===R?lS-Me():0;if(rt=zR($e,rt),rt!==null){ii=R,i.cancelPendingCommit=rt(vS.bind(null,i,l,R,p,y,T,G,te,le,Ie,$e,null,Ce,je)),Fi(i,R,G,!ve);return}}vS(i,l,R,p,y,T,G,te,le)}function rR(i){for(var l=i;;){var p=l.tag;if((p===0||p===11||p===15)&&l.flags&16384&&(p=l.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var y=0;y<p.length;y++){var T=p[y],R=T.getSnapshot;T=T.value;try{if(!jr(R(),T))return!1}catch{return!1}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Fi(i,l,p,y){l&=~Vp,l&=~Ra,i.suspendedLanes|=l,i.pingedLanes&=~l,y&&(i.warmLanes|=l),y=i.expirationTimes;for(var T=l;0<T;){var R=31-ae(T),G=1<<R;y[R]=-1,T&=~G}p!==0&&Ye(i,p,l)}function Td(){return(Ft&6)===0?(_c(0),!1):!0}function Yp(){if(Et!==null){if(Wt===0)var i=Et.return;else i=Et,Ks=wa=null,dp(i),Do=null,rc=0,i=Et;for(;i!==null;)U0(i.alternate,i),i=i.return;Et=null}}function Uo(i,l){var p=i.timeoutHandle;p!==-1&&(i.timeoutHandle=-1,wR(p)),p=i.cancelPendingCommit,p!==null&&(i.cancelPendingCommit=null,p()),ii=0,Yp(),Jt=i,Et=p=Gs(i.current,null),At=l,Wt=0,Ar=null,Mi=!1,Fo=zn(i,l),Up=!1,zo=Lr=Vp=Ra=Pi=_n=0,xr=bc=null,Wp=!1,(l&8)!==0&&(l|=l&32);var y=i.entangledLanes;if(y!==0)for(i=i.entanglements,y&=l;0<y;){var T=31-ae(y),R=1<<T;l|=i[T],y&=~R}return si=l,Xu(),p}function fS(i,l){St=null,W.H=dc,l===Ro||l===sd?(l=T_(),Wt=3):l===Zm?(l=T_(),Wt=4):Wt=l===Ep?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,Ar=l,Et===null&&(_n=1,yd(i,Vr(l,i.current)))}function mS(){var i=Nr.current;return i===null?!0:(At&4194048)===At?Kr===null:(At&62914560)===At||(At&536870912)!==0?i===Kr:!1}function pS(){var i=W.H;return W.H=dc,i===null?dc:i}function gS(){var i=W.A;return W.A=tR,i}function Ad(){_n=4,Mi||(At&4194048)!==At&&Nr.current!==null||(Fo=!0),(Pi&134217727)===0&&(Ra&134217727)===0||Jt===null||Fi(Jt,At,Lr,!1)}function Xp(i,l,p){var y=Ft;Ft|=2;var T=pS(),R=gS();(Jt!==i||At!==l)&&(Nd=null,Uo(i,l)),l=!1;var G=_n;e:do try{if(Wt!==0&&Et!==null){var te=Et,le=Ar;switch(Wt){case 8:Yp(),G=6;break e;case 3:case 2:case 9:case 6:Nr.current===null&&(l=!0);var ve=Wt;if(Wt=0,Ar=null,Vo(i,te,le,ve),p&&Fo){G=0;break e}break;default:ve=Wt,Wt=0,Ar=null,Vo(i,te,le,ve)}}sR(),G=_n;break}catch(Ie){fS(i,Ie)}while(!0);return l&&i.shellSuspendCounter++,Ks=wa=null,Ft=y,W.H=T,W.A=R,Et===null&&(Jt=null,At=0,Xu()),G}function sR(){for(;Et!==null;)xS(Et)}function iR(i,l){var p=Ft;Ft|=2;var y=pS(),T=gS();Jt!==i||At!==l?(Nd=null,Ed=Me()+500,Uo(i,l)):Fo=zn(i,l);e:do try{if(Wt!==0&&Et!==null){l=Et;var R=Ar;t:switch(Wt){case 1:Wt=0,Ar=null,Vo(i,l,R,1);break;case 2:case 9:if(E_(R)){Wt=0,Ar=null,yS(l);break}l=function(){Wt!==2&&Wt!==9||Jt!==i||(Wt=7),js(i)},R.then(l,l);break e;case 3:Wt=7;break e;case 4:Wt=5;break e;case 7:E_(R)?(Wt=0,Ar=null,yS(l)):(Wt=0,Ar=null,Vo(i,l,R,7));break;case 5:var G=null;switch(Et.tag){case 26:G=Et.memoizedState;case 5:case 27:var te=Et;if(G?rw(G):te.stateNode.complete){Wt=0,Ar=null;var le=te.sibling;if(le!==null)Et=le;else{var ve=te.return;ve!==null?(Et=ve,Ld(ve)):Et=null}break t}}Wt=0,Ar=null,Vo(i,l,R,5);break;case 6:Wt=0,Ar=null,Vo(i,l,R,6);break;case 8:Yp(),_n=6;break e;default:throw Error(r(462))}}aR();break}catch(Ie){fS(i,Ie)}while(!0);return Ks=wa=null,W.H=y,W.A=T,Ft=p,Et!==null?0:(Jt=null,At=0,Xu(),_n)}function aR(){for(;Et!==null&&!fe();)xS(Et)}function xS(i){var l=z0(i.alternate,i,si);i.memoizedProps=i.pendingProps,l===null?Ld(i):Et=l}function yS(i){var l=i,p=l.alternate;switch(l.tag){case 15:case 0:l=I0(p,l,l.pendingProps,l.type,void 0,At);break;case 11:l=I0(p,l,l.pendingProps,l.type.render,l.ref,At);break;case 5:dp(l);default:U0(p,l),l=Et=g_(l,si),l=z0(p,l,si)}i.memoizedProps=i.pendingProps,l===null?Ld(i):Et=l}function Vo(i,l,p,y){Ks=wa=null,dp(l),Do=null,rc=0;var T=l.return;try{if(KL(i,T,l,p,At)){_n=1,yd(i,Vr(p,i.current)),Et=null;return}}catch(R){if(T!==null)throw Et=T,R;_n=1,yd(i,Vr(p,i.current)),Et=null;return}l.flags&32768?(Rt||y===1?i=!0:Fo||(At&536870912)!==0?i=!1:(Mi=i=!0,(y===2||y===9||y===3||y===6)&&(y=Nr.current,y!==null&&y.tag===13&&(y.flags|=16384))),bS(l,i)):Ld(l)}function Ld(i){var l=i;do{if((l.flags&32768)!==0){bS(l,Mi);return}i=l.return;var p=QL(l.alternate,l,si);if(p!==null){Et=p;return}if(l=l.sibling,l!==null){Et=l;return}Et=l=i}while(l!==null);_n===0&&(_n=5)}function bS(i,l){do{var p=JL(i.alternate,i);if(p!==null){p.flags&=32767,Et=p;return}if(p=i.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!l&&(i=i.sibling,i!==null)){Et=i;return}Et=i=p}while(i!==null);_n=6,Et=null}function vS(i,l,p,y,T,R,G,te,le){i.cancelPendingCommit=null;do Rd();while(Pn!==0);if((Ft&6)!==0)throw Error(r(327));if(l!==null){if(l===i.current)throw Error(r(177));if(R=l.lanes|l.childLanes,R|=Bm,tt(i,p,R,G,te,le),i===Jt&&(Et=Jt=null,At=0),Ho=l,$i=i,ii=p,Gp=R,qp=T,cS=y,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,uR(Qe,function(){return kS(),null})):(i.callbackNode=null,i.callbackPriority=0),y=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||y){y=W.T,W.T=null,T=ee.p,ee.p=2,G=Ft,Ft|=4;try{ZL(i,l,p)}finally{Ft=G,ee.p=T,W.T=y}}Pn=1,_S(),SS(),wS()}}function _S(){if(Pn===1){Pn=0;var i=$i,l=Ho,p=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||p){p=W.T,W.T=null;var y=ee.p;ee.p=2;var T=Ft;Ft|=4;try{tS(l,i);var R=lg,G=o_(i.containerInfo),te=R.focusedElem,le=R.selectionRange;if(G!==te&&te&&te.ownerDocument&&a_(te.ownerDocument.documentElement,te)){if(le!==null&&Dm(te)){var ve=le.start,Ie=le.end;if(Ie===void 0&&(Ie=ve),"selectionStart"in te)te.selectionStart=ve,te.selectionEnd=Math.min(Ie,te.value.length);else{var $e=te.ownerDocument||document,Ce=$e&&$e.defaultView||window;if(Ce.getSelection){var je=Ce.getSelection(),rt=te.textContent.length,ht=Math.min(le.start,rt),Yt=le.end===void 0?ht:Math.min(le.end,rt);!je.extend&&ht>Yt&&(G=Yt,Yt=ht,ht=G);var pe=i_(te,ht),de=i_(te,Yt);if(pe&&de&&(je.rangeCount!==1||je.anchorNode!==pe.node||je.anchorOffset!==pe.offset||je.focusNode!==de.node||je.focusOffset!==de.offset)){var be=$e.createRange();be.setStart(pe.node,pe.offset),je.removeAllRanges(),ht>Yt?(je.addRange(be),je.extend(de.node,de.offset)):(be.setEnd(de.node,de.offset),je.addRange(be))}}}}for($e=[],je=te;je=je.parentNode;)je.nodeType===1&&$e.push({element:je,left:je.scrollLeft,top:je.scrollTop});for(typeof te.focus=="function"&&te.focus(),te=0;te<$e.length;te++){var Pe=$e[te];Pe.element.scrollLeft=Pe.left,Pe.element.scrollTop=Pe.top}}Vd=!!og,lg=og=null}finally{Ft=T,ee.p=y,W.T=p}}i.current=l,Pn=2}}function SS(){if(Pn===2){Pn=0;var i=$i,l=Ho,p=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||p){p=W.T,W.T=null;var y=ee.p;ee.p=2;var T=Ft;Ft|=4;try{X0(i,l.alternate,l)}finally{Ft=T,ee.p=y,W.T=p}}Pn=3}}function wS(){if(Pn===4||Pn===3){Pn=0,oe();var i=$i,l=Ho,p=ii,y=cS;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Pn=5:(Pn=0,Ho=$i=null,CS(i,i.pendingLanes));var T=i.pendingLanes;if(T===0&&(Bi=null),mt(p),l=l.stateNode,ot&&typeof ot.onCommitFiberRoot=="function")try{ot.onCommitFiberRoot(et,l,void 0,(l.current.flags&128)===128)}catch{}if(y!==null){l=W.T,T=ee.p,ee.p=2,W.T=null;try{for(var R=i.onRecoverableError,G=0;G<y.length;G++){var te=y[G];R(te.value,{componentStack:te.stack})}}finally{W.T=l,ee.p=T}}(ii&3)!==0&&Rd(),js(i),T=i.pendingLanes,(p&261930)!==0&&(T&42)!==0?i===Kp?vc++:(vc=0,Kp=i):vc=0,_c(0)}}function CS(i,l){(i.pooledCacheLanes&=l)===0&&(l=i.pooledCache,l!=null&&(i.pooledCache=null,tc(l)))}function Rd(){return _S(),SS(),wS(),kS()}function kS(){if(Pn!==5)return!1;var i=$i,l=Gp;Gp=0;var p=mt(ii),y=W.T,T=ee.p;try{ee.p=32>p?32:p,W.T=null,p=qp,qp=null;var R=$i,G=ii;if(Pn=0,Ho=$i=null,ii=0,(Ft&6)!==0)throw Error(r(331));var te=Ft;if(Ft|=4,aS(R.current),rS(R,R.current,G,p),Ft=te,_c(0,!1),ot&&typeof ot.onPostCommitFiberRoot=="function")try{ot.onPostCommitFiberRoot(et,R)}catch{}return!0}finally{ee.p=T,W.T=y,CS(i,l)}}function jS(i,l,p){l=Vr(p,l),l=jp(i.stateNode,l,2),i=Ri(i,l,2),i!==null&&(Se(i,2),js(i))}function Gt(i,l,p){if(i.tag===3)jS(i,i,p);else for(;l!==null;){if(l.tag===3){jS(l,i,p);break}else if(l.tag===1){var y=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Bi===null||!Bi.has(y))){i=Vr(p,i),p=E0(2),y=Ri(l,p,2),y!==null&&(N0(p,y,l,i),Se(y,2),js(y));break}}l=l.return}}function Qp(i,l,p){var y=i.pingCache;if(y===null){y=i.pingCache=new nR;var T=new Set;y.set(l,T)}else T=y.get(l),T===void 0&&(T=new Set,y.set(l,T));T.has(p)||(Up=!0,T.add(p),i=oR.bind(null,i,l,p),l.then(i,i))}function oR(i,l,p){var y=i.pingCache;y!==null&&y.delete(l),i.pingedLanes|=i.suspendedLanes&p,i.warmLanes&=~p,Jt===i&&(At&p)===p&&(_n===4||_n===3&&(At&62914560)===At&&300>Me()-jd?(Ft&2)===0&&Uo(i,0):Vp|=p,zo===At&&(zo=0)),js(i)}function ES(i,l){l===0&&(l=gn()),i=va(i,l),i!==null&&(Se(i,l),js(i))}function lR(i){var l=i.memoizedState,p=0;l!==null&&(p=l.retryLane),ES(i,p)}function cR(i,l){var p=0;switch(i.tag){case 31:case 13:var y=i.stateNode,T=i.memoizedState;T!==null&&(p=T.retryLane);break;case 19:y=i.stateNode;break;case 22:y=i.stateNode._retryCache;break;default:throw Error(r(314))}y!==null&&y.delete(l),ES(i,p)}function uR(i,l){return _e(i,l)}var Dd=null,Wo=null,Jp=!1,Od=!1,Zp=!1,zi=0;function js(i){i!==Wo&&i.next===null&&(Wo===null?Dd=Wo=i:Wo=Wo.next=i),Od=!0,Jp||(Jp=!0,hR())}function _c(i,l){if(!Zp&&Od){Zp=!0;do for(var p=!1,y=Dd;y!==null;){if(i!==0){var T=y.pendingLanes;if(T===0)var R=0;else{var G=y.suspendedLanes,te=y.pingedLanes;R=(1<<31-ae(42|i)+1)-1,R&=T&~(G&~te),R=R&201326741?R&201326741|1:R?R|2:0}R!==0&&(p=!0,LS(y,R))}else R=At,R=fn(y,y===Jt?R:0,y.cancelPendingCommit!==null||y.timeoutHandle!==-1),(R&3)===0||zn(y,R)||(p=!0,LS(y,R));y=y.next}while(p);Zp=!1}}function dR(){NS()}function NS(){Od=Jp=!1;var i=0;zi!==0&&SR()&&(i=zi);for(var l=Me(),p=null,y=Dd;y!==null;){var T=y.next,R=TS(y,l);R===0?(y.next=null,p===null?Dd=T:p.next=T,T===null&&(Wo=p)):(p=y,(i!==0||(R&3)!==0)&&(Od=!0)),y=T}Pn!==0&&Pn!==5||_c(i),zi!==0&&(zi=0)}function TS(i,l){for(var p=i.suspendedLanes,y=i.pingedLanes,T=i.expirationTimes,R=i.pendingLanes&-62914561;0<R;){var G=31-ae(R),te=1<<G,le=T[G];le===-1?((te&p)===0||(te&y)!==0)&&(T[G]=bn(te,l)):le<=l&&(i.expiredLanes|=te),R&=~te}if(l=Jt,p=At,p=fn(i,i===l?p:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y=i.callbackNode,p===0||i===l&&(Wt===2||Wt===9)||i.cancelPendingCommit!==null)return y!==null&&y!==null&&ye(y),i.callbackNode=null,i.callbackPriority=0;if((p&3)===0||zn(i,p)){if(l=p&-p,l===i.callbackPriority)return l;switch(y!==null&&ye(y),mt(p)){case 2:case 8:p=Te;break;case 32:p=Qe;break;case 268435456:p=ze;break;default:p=Qe}return y=AS.bind(null,i),p=_e(p,y),i.callbackPriority=l,i.callbackNode=p,l}return y!==null&&y!==null&&ye(y),i.callbackPriority=2,i.callbackNode=null,2}function AS(i,l){if(Pn!==0&&Pn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var p=i.callbackNode;if(Rd()&&i.callbackNode!==p)return null;var y=At;return y=fn(i,i===Jt?y:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y===0?null:(dS(i,y,l),TS(i,Me()),i.callbackNode!=null&&i.callbackNode===p?AS.bind(null,i):null)}function LS(i,l){if(Rd())return null;dS(i,l,!0)}function hR(){CR(function(){(Ft&6)!==0?_e(he,dR):NS()})}function eg(){if(zi===0){var i=Ao;i===0&&(i=vt,vt<<=1,(vt&261888)===0&&(vt=256)),zi=i}return zi}function RS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Hu(""+i)}function DS(i,l){var p=l.ownerDocument.createElement("input");return p.name=l.name,p.value=l.value,i.id&&p.setAttribute("form",i.id),l.parentNode.insertBefore(p,l),i=new FormData(i),p.parentNode.removeChild(p),i}function fR(i,l,p,y,T){if(l==="submit"&&p&&p.stateNode===T){var R=RS((T[Je]||null).action),G=y.submitter;G&&(l=(l=G[Je]||null)?RS(l.formAction):G.getAttribute("formAction"),l!==null&&(R=l,G=null));var te=new Gu("action","action",null,y,T);i.push({event:te,listeners:[{instance:null,listener:function(){if(y.defaultPrevented){if(zi!==0){var le=G?DS(T,G):new FormData(T);vp(p,{pending:!0,data:le,method:T.method,action:R},null,le)}}else typeof R=="function"&&(te.preventDefault(),le=G?DS(T,G):new FormData(T),vp(p,{pending:!0,data:le,method:T.method,action:R},R,le))},currentTarget:T}]})}}for(var tg=0;tg<Pm.length;tg++){var ng=Pm[tg],mR=ng.toLowerCase(),pR=ng[0].toUpperCase()+ng.slice(1);os(mR,"on"+pR)}os(u_,"onAnimationEnd"),os(d_,"onAnimationIteration"),os(h_,"onAnimationStart"),os("dblclick","onDoubleClick"),os("focusin","onFocus"),os("focusout","onBlur"),os(LL,"onTransitionRun"),os(RL,"onTransitionStart"),os(DL,"onTransitionCancel"),os(f_,"onTransitionEnd"),go("onMouseEnter",["mouseout","mouseover"]),go("onMouseLeave",["mouseout","mouseover"]),go("onPointerEnter",["pointerout","pointerover"]),go("onPointerLeave",["pointerout","pointerover"]),ga("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ga("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ga("onBeforeInput",["compositionend","keypress","textInput","paste"]),ga("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Sc="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(" "),gR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Sc));function OS(i,l){l=(l&4)!==0;for(var p=0;p<i.length;p++){var y=i[p],T=y.event;y=y.listeners;e:{var R=void 0;if(l)for(var G=y.length-1;0<=G;G--){var te=y[G],le=te.instance,ve=te.currentTarget;if(te=te.listener,le!==R&&T.isPropagationStopped())break e;R=te,T.currentTarget=ve;try{R(T)}catch(Ie){Yu(Ie)}T.currentTarget=null,R=le}else for(G=0;G<y.length;G++){if(te=y[G],le=te.instance,ve=te.currentTarget,te=te.listener,le!==R&&T.isPropagationStopped())break e;R=te,T.currentTarget=ve;try{R(T)}catch(Ie){Yu(Ie)}T.currentTarget=null,R=le}}}}function Nt(i,l){var p=l[gt];p===void 0&&(p=l[gt]=new Set);var y=i+"__bubble";p.has(y)||(IS(l,i,2,!1),p.add(y))}function rg(i,l,p){var y=0;l&&(y|=4),IS(p,i,y,l)}var Id="_reactListening"+Math.random().toString(36).slice(2);function sg(i){if(!i[Id]){i[Id]=!0,Nv.forEach(function(p){p!=="selectionchange"&&(gR.has(p)||rg(p,!1,i),rg(p,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[Id]||(l[Id]=!0,rg("selectionchange",!1,l))}}function IS(i,l,p,y){switch(uw(l)){case 2:var T=VR;break;case 8:T=WR;break;default:T=bg}p=T.bind(null,l,p,i),T=void 0,!Cm||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(T=!0),y?T!==void 0?i.addEventListener(l,p,{capture:!0,passive:T}):i.addEventListener(l,p,!0):T!==void 0?i.addEventListener(l,p,{passive:T}):i.addEventListener(l,p,!1)}function ig(i,l,p,y,T){var R=y;if((l&1)===0&&(l&2)===0&&y!==null)e:for(;;){if(y===null)return;var G=y.tag;if(G===3||G===4){var te=y.stateNode.containerInfo;if(te===T)break;if(G===4)for(G=y.return;G!==null;){var le=G.tag;if((le===3||le===4)&&G.stateNode.containerInfo===T)return;G=G.return}for(;te!==null;){if(G=fo(te),G===null)return;if(le=G.tag,le===5||le===6||le===26||le===27){y=R=G;continue e}te=te.parentNode}}y=y.return}Fv(function(){var ve=R,Ie=Sm(p),$e=[];e:{var Ce=m_.get(i);if(Ce!==void 0){var je=Gu,rt=i;switch(i){case"keypress":if(Vu(p)===0)break e;case"keydown":case"keyup":je=cL;break;case"focusin":rt="focus",je=Nm;break;case"focusout":rt="blur",je=Nm;break;case"beforeblur":case"afterblur":je=Nm;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=Uv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=QA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=hL;break;case u_:case d_:case h_:je=eL;break;case f_:je=mL;break;case"scroll":case"scrollend":je=YA;break;case"wheel":je=gL;break;case"copy":case"cut":case"paste":je=nL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Wv;break;case"toggle":case"beforetoggle":je=yL}var ht=(l&4)!==0,Yt=!ht&&(i==="scroll"||i==="scrollend"),pe=ht?Ce!==null?Ce+"Capture":null:Ce;ht=[];for(var de=ve,be;de!==null;){var Pe=de;if(be=Pe.stateNode,Pe=Pe.tag,Pe!==5&&Pe!==26&&Pe!==27||be===null||pe===null||(Pe=Vl(de,pe),Pe!=null&&ht.push(wc(de,Pe,be))),Yt)break;de=de.return}0<ht.length&&(Ce=new je(Ce,rt,null,p,Ie),$e.push({event:Ce,listeners:ht}))}}if((l&7)===0){e:{if(Ce=i==="mouseover"||i==="pointerover",je=i==="mouseout"||i==="pointerout",Ce&&p!==_m&&(rt=p.relatedTarget||p.fromElement)&&(fo(rt)||rt[nt]))break e;if((je||Ce)&&(Ce=Ie.window===Ie?Ie:(Ce=Ie.ownerDocument)?Ce.defaultView||Ce.parentWindow:window,je?(rt=p.relatedTarget||p.toElement,je=ve,rt=rt?fo(rt):null,rt!==null&&(Yt=o(rt),ht=rt.tag,rt!==Yt||ht!==5&&ht!==27&&ht!==6)&&(rt=null)):(je=null,rt=ve),je!==rt)){if(ht=Uv,Pe="onMouseLeave",pe="onMouseEnter",de="mouse",(i==="pointerout"||i==="pointerover")&&(ht=Wv,Pe="onPointerLeave",pe="onPointerEnter",de="pointer"),Yt=je==null?Ce:Ul(je),be=rt==null?Ce:Ul(rt),Ce=new ht(Pe,de+"leave",je,p,Ie),Ce.target=Yt,Ce.relatedTarget=be,Pe=null,fo(Ie)===ve&&(ht=new ht(pe,de+"enter",rt,p,Ie),ht.target=be,ht.relatedTarget=Yt,Pe=ht),Yt=Pe,je&&rt)t:{for(ht=xR,pe=je,de=rt,be=0,Pe=pe;Pe;Pe=ht(Pe))be++;Pe=0;for(var lt=de;lt;lt=ht(lt))Pe++;for(;0<be-Pe;)pe=ht(pe),be--;for(;0<Pe-be;)de=ht(de),Pe--;for(;be--;){if(pe===de||de!==null&&pe===de.alternate){ht=pe;break t}pe=ht(pe),de=ht(de)}ht=null}else ht=null;je!==null&&MS($e,Ce,je,ht,!1),rt!==null&&Yt!==null&&MS($e,Yt,rt,ht,!0)}}e:{if(Ce=ve?Ul(ve):window,je=Ce.nodeName&&Ce.nodeName.toLowerCase(),je==="select"||je==="input"&&Ce.type==="file")var Mt=Zv;else if(Qv(Ce))if(e_)Mt=NL;else{Mt=jL;var it=kL}else je=Ce.nodeName,!je||je.toLowerCase()!=="input"||Ce.type!=="checkbox"&&Ce.type!=="radio"?ve&&vm(ve.elementType)&&(Mt=Zv):Mt=EL;if(Mt&&(Mt=Mt(i,ve))){Jv($e,Mt,p,Ie);break e}it&&it(i,Ce,ve),i==="focusout"&&ve&&Ce.type==="number"&&ve.memoizedProps.value!=null&&bm(Ce,"number",Ce.value)}switch(it=ve?Ul(ve):window,i){case"focusin":(Qv(it)||it.contentEditable==="true")&&(So=it,Om=ve,Jl=null);break;case"focusout":Jl=Om=So=null;break;case"mousedown":Im=!0;break;case"contextmenu":case"mouseup":case"dragend":Im=!1,l_($e,p,Ie);break;case"selectionchange":if(AL)break;case"keydown":case"keyup":l_($e,p,Ie)}var Ct;if(Am)e:{switch(i){case"compositionstart":var Lt="onCompositionStart";break e;case"compositionend":Lt="onCompositionEnd";break e;case"compositionupdate":Lt="onCompositionUpdate";break e}Lt=void 0}else _o?Yv(i,p)&&(Lt="onCompositionEnd"):i==="keydown"&&p.keyCode===229&&(Lt="onCompositionStart");Lt&&(Gv&&p.locale!=="ko"&&(_o||Lt!=="onCompositionStart"?Lt==="onCompositionEnd"&&_o&&(Ct=zv()):(ki=Ie,km="value"in ki?ki.value:ki.textContent,_o=!0)),it=Md(ve,Lt),0<it.length&&(Lt=new Vv(Lt,i,null,p,Ie),$e.push({event:Lt,listeners:it}),Ct?Lt.data=Ct:(Ct=Xv(p),Ct!==null&&(Lt.data=Ct)))),(Ct=vL?_L(i,p):SL(i,p))&&(Lt=Md(ve,"onBeforeInput"),0<Lt.length&&(it=new Vv("onBeforeInput","beforeinput",null,p,Ie),$e.push({event:it,listeners:Lt}),it.data=Ct)),fR($e,i,ve,p,Ie)}OS($e,l)})}function wc(i,l,p){return{instance:i,listener:l,currentTarget:p}}function Md(i,l){for(var p=l+"Capture",y=[];i!==null;){var T=i,R=T.stateNode;if(T=T.tag,T!==5&&T!==26&&T!==27||R===null||(T=Vl(i,p),T!=null&&y.unshift(wc(i,T,R)),T=Vl(i,l),T!=null&&y.push(wc(i,T,R))),i.tag===3)return y;i=i.return}return[]}function xR(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function MS(i,l,p,y,T){for(var R=l._reactName,G=[];p!==null&&p!==y;){var te=p,le=te.alternate,ve=te.stateNode;if(te=te.tag,le!==null&&le===y)break;te!==5&&te!==26&&te!==27||ve===null||(le=ve,T?(ve=Vl(p,R),ve!=null&&G.unshift(wc(p,ve,le))):T||(ve=Vl(p,R),ve!=null&&G.push(wc(p,ve,le)))),p=p.return}G.length!==0&&i.push({event:l,listeners:G})}var yR=/\r\n?/g,bR=/\u0000|\uFFFD/g;function PS(i){return(typeof i=="string"?i:""+i).replace(yR,`
50
+ `).replace(bR,"")}function BS(i,l){return l=PS(l),PS(i)===l}function Kt(i,l,p,y,T,R){switch(p){case"children":typeof y=="string"?l==="body"||l==="textarea"&&y===""||yo(i,y):(typeof y=="number"||typeof y=="bigint")&&l!=="body"&&yo(i,""+y);break;case"className":Fu(i,"class",y);break;case"tabIndex":Fu(i,"tabindex",y);break;case"dir":case"role":case"viewBox":case"width":case"height":Fu(i,p,y);break;case"style":Bv(i,y,R);break;case"data":if(l!=="object"){Fu(i,"data",y);break}case"src":case"href":if(y===""&&(l!=="a"||p!=="href")){i.removeAttribute(p);break}if(y==null||typeof y=="function"||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(p);break}y=Hu(""+y),i.setAttribute(p,y);break;case"action":case"formAction":if(typeof y=="function"){i.setAttribute(p,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof R=="function"&&(p==="formAction"?(l!=="input"&&Kt(i,l,"name",T.name,T,null),Kt(i,l,"formEncType",T.formEncType,T,null),Kt(i,l,"formMethod",T.formMethod,T,null),Kt(i,l,"formTarget",T.formTarget,T,null)):(Kt(i,l,"encType",T.encType,T,null),Kt(i,l,"method",T.method,T,null),Kt(i,l,"target",T.target,T,null)));if(y==null||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(p);break}y=Hu(""+y),i.setAttribute(p,y);break;case"onClick":y!=null&&(i.onclick=Vs);break;case"onScroll":y!=null&&Nt("scroll",i);break;case"onScrollEnd":y!=null&&Nt("scrollend",i);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(p=y.__html,p!=null){if(T.children!=null)throw Error(r(60));i.innerHTML=p}}break;case"multiple":i.multiple=y&&typeof y!="function"&&typeof y!="symbol";break;case"muted":i.muted=y&&typeof y!="function"&&typeof y!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(y==null||typeof y=="function"||typeof y=="boolean"||typeof y=="symbol"){i.removeAttribute("xlink:href");break}p=Hu(""+y),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,""+y):i.removeAttribute(p);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":y&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,""):i.removeAttribute(p);break;case"capture":case"download":y===!0?i.setAttribute(p,""):y!==!1&&y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,y):i.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":y!=null&&typeof y!="function"&&typeof y!="symbol"&&!isNaN(y)&&1<=y?i.setAttribute(p,y):i.removeAttribute(p);break;case"rowSpan":case"start":y==null||typeof y=="function"||typeof y=="symbol"||isNaN(y)?i.removeAttribute(p):i.setAttribute(p,y);break;case"popover":Nt("beforetoggle",i),Nt("toggle",i),$u(i,"popover",y);break;case"xlinkActuate":Us(i,"http://www.w3.org/1999/xlink","xlink:actuate",y);break;case"xlinkArcrole":Us(i,"http://www.w3.org/1999/xlink","xlink:arcrole",y);break;case"xlinkRole":Us(i,"http://www.w3.org/1999/xlink","xlink:role",y);break;case"xlinkShow":Us(i,"http://www.w3.org/1999/xlink","xlink:show",y);break;case"xlinkTitle":Us(i,"http://www.w3.org/1999/xlink","xlink:title",y);break;case"xlinkType":Us(i,"http://www.w3.org/1999/xlink","xlink:type",y);break;case"xmlBase":Us(i,"http://www.w3.org/XML/1998/namespace","xml:base",y);break;case"xmlLang":Us(i,"http://www.w3.org/XML/1998/namespace","xml:lang",y);break;case"xmlSpace":Us(i,"http://www.w3.org/XML/1998/namespace","xml:space",y);break;case"is":$u(i,"is",y);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=qA.get(p)||p,$u(i,p,y))}}function ag(i,l,p,y,T,R){switch(p){case"style":Bv(i,y,R);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(p=y.__html,p!=null){if(T.children!=null)throw Error(r(60));i.innerHTML=p}}break;case"children":typeof y=="string"?yo(i,y):(typeof y=="number"||typeof y=="bigint")&&yo(i,""+y);break;case"onScroll":y!=null&&Nt("scroll",i);break;case"onScrollEnd":y!=null&&Nt("scrollend",i);break;case"onClick":y!=null&&(i.onclick=Vs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Tv.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(T=p.endsWith("Capture"),l=p.slice(2,T?p.length-7:void 0),R=i[Je]||null,R=R!=null?R[p]:null,typeof R=="function"&&i.removeEventListener(l,R,T),typeof y=="function")){typeof R!="function"&&R!==null&&(p in i?i[p]=null:i.hasAttribute(p)&&i.removeAttribute(p)),i.addEventListener(l,y,T);break e}p in i?i[p]=y:y===!0?i.setAttribute(p,""):$u(i,p,y)}}}function Xn(i,l,p){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Nt("error",i),Nt("load",i);var y=!1,T=!1,R;for(R in p)if(p.hasOwnProperty(R)){var G=p[R];if(G!=null)switch(R){case"src":y=!0;break;case"srcSet":T=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Kt(i,l,R,G,p,null)}}T&&Kt(i,l,"srcSet",p.srcSet,p,null),y&&Kt(i,l,"src",p.src,p,null);return;case"input":Nt("invalid",i);var te=R=G=T=null,le=null,ve=null;for(y in p)if(p.hasOwnProperty(y)){var Ie=p[y];if(Ie!=null)switch(y){case"name":T=Ie;break;case"type":G=Ie;break;case"checked":le=Ie;break;case"defaultChecked":ve=Ie;break;case"value":R=Ie;break;case"defaultValue":te=Ie;break;case"children":case"dangerouslySetInnerHTML":if(Ie!=null)throw Error(r(137,l));break;default:Kt(i,l,y,Ie,p,null)}}Ov(i,R,te,le,ve,G,T,!1);return;case"select":Nt("invalid",i),y=G=R=null;for(T in p)if(p.hasOwnProperty(T)&&(te=p[T],te!=null))switch(T){case"value":R=te;break;case"defaultValue":G=te;break;case"multiple":y=te;default:Kt(i,l,T,te,p,null)}l=R,p=G,i.multiple=!!y,l!=null?xo(i,!!y,l,!1):p!=null&&xo(i,!!y,p,!0);return;case"textarea":Nt("invalid",i),R=T=y=null;for(G in p)if(p.hasOwnProperty(G)&&(te=p[G],te!=null))switch(G){case"value":y=te;break;case"defaultValue":T=te;break;case"children":R=te;break;case"dangerouslySetInnerHTML":if(te!=null)throw Error(r(91));break;default:Kt(i,l,G,te,p,null)}Mv(i,y,T,R);return;case"option":for(le in p)if(p.hasOwnProperty(le)&&(y=p[le],y!=null))switch(le){case"selected":i.selected=y&&typeof y!="function"&&typeof y!="symbol";break;default:Kt(i,l,le,y,p,null)}return;case"dialog":Nt("beforetoggle",i),Nt("toggle",i),Nt("cancel",i),Nt("close",i);break;case"iframe":case"object":Nt("load",i);break;case"video":case"audio":for(y=0;y<Sc.length;y++)Nt(Sc[y],i);break;case"image":Nt("error",i),Nt("load",i);break;case"details":Nt("toggle",i);break;case"embed":case"source":case"link":Nt("error",i),Nt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ve in p)if(p.hasOwnProperty(ve)&&(y=p[ve],y!=null))switch(ve){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Kt(i,l,ve,y,p,null)}return;default:if(vm(l)){for(Ie in p)p.hasOwnProperty(Ie)&&(y=p[Ie],y!==void 0&&ag(i,l,Ie,y,p,void 0));return}}for(te in p)p.hasOwnProperty(te)&&(y=p[te],y!=null&&Kt(i,l,te,y,p,null))}function vR(i,l,p,y){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var T=null,R=null,G=null,te=null,le=null,ve=null,Ie=null;for(je in p){var $e=p[je];if(p.hasOwnProperty(je)&&$e!=null)switch(je){case"checked":break;case"value":break;case"defaultValue":le=$e;default:y.hasOwnProperty(je)||Kt(i,l,je,null,y,$e)}}for(var Ce in y){var je=y[Ce];if($e=p[Ce],y.hasOwnProperty(Ce)&&(je!=null||$e!=null))switch(Ce){case"type":R=je;break;case"name":T=je;break;case"checked":ve=je;break;case"defaultChecked":Ie=je;break;case"value":G=je;break;case"defaultValue":te=je;break;case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(r(137,l));break;default:je!==$e&&Kt(i,l,Ce,je,y,$e)}}ym(i,G,te,le,ve,Ie,R,T);return;case"select":je=G=te=Ce=null;for(R in p)if(le=p[R],p.hasOwnProperty(R)&&le!=null)switch(R){case"value":break;case"multiple":je=le;default:y.hasOwnProperty(R)||Kt(i,l,R,null,y,le)}for(T in y)if(R=y[T],le=p[T],y.hasOwnProperty(T)&&(R!=null||le!=null))switch(T){case"value":Ce=R;break;case"defaultValue":te=R;break;case"multiple":G=R;default:R!==le&&Kt(i,l,T,R,y,le)}l=te,p=G,y=je,Ce!=null?xo(i,!!p,Ce,!1):!!y!=!!p&&(l!=null?xo(i,!!p,l,!0):xo(i,!!p,p?[]:"",!1));return;case"textarea":je=Ce=null;for(te in p)if(T=p[te],p.hasOwnProperty(te)&&T!=null&&!y.hasOwnProperty(te))switch(te){case"value":break;case"children":break;default:Kt(i,l,te,null,y,T)}for(G in y)if(T=y[G],R=p[G],y.hasOwnProperty(G)&&(T!=null||R!=null))switch(G){case"value":Ce=T;break;case"defaultValue":je=T;break;case"children":break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:T!==R&&Kt(i,l,G,T,y,R)}Iv(i,Ce,je);return;case"option":for(var rt in p)if(Ce=p[rt],p.hasOwnProperty(rt)&&Ce!=null&&!y.hasOwnProperty(rt))switch(rt){case"selected":i.selected=!1;break;default:Kt(i,l,rt,null,y,Ce)}for(le in y)if(Ce=y[le],je=p[le],y.hasOwnProperty(le)&&Ce!==je&&(Ce!=null||je!=null))switch(le){case"selected":i.selected=Ce&&typeof Ce!="function"&&typeof Ce!="symbol";break;default:Kt(i,l,le,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 ht in p)Ce=p[ht],p.hasOwnProperty(ht)&&Ce!=null&&!y.hasOwnProperty(ht)&&Kt(i,l,ht,null,y,Ce);for(ve in y)if(Ce=y[ve],je=p[ve],y.hasOwnProperty(ve)&&Ce!==je&&(Ce!=null||je!=null))switch(ve){case"children":case"dangerouslySetInnerHTML":if(Ce!=null)throw Error(r(137,l));break;default:Kt(i,l,ve,Ce,y,je)}return;default:if(vm(l)){for(var Yt in p)Ce=p[Yt],p.hasOwnProperty(Yt)&&Ce!==void 0&&!y.hasOwnProperty(Yt)&&ag(i,l,Yt,void 0,y,Ce);for(Ie in y)Ce=y[Ie],je=p[Ie],!y.hasOwnProperty(Ie)||Ce===je||Ce===void 0&&je===void 0||ag(i,l,Ie,Ce,y,je);return}}for(var pe in p)Ce=p[pe],p.hasOwnProperty(pe)&&Ce!=null&&!y.hasOwnProperty(pe)&&Kt(i,l,pe,null,y,Ce);for($e in y)Ce=y[$e],je=p[$e],!y.hasOwnProperty($e)||Ce===je||Ce==null&&je==null||Kt(i,l,$e,Ce,y,je)}function $S(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function _R(){if(typeof performance.getEntriesByType=="function"){for(var i=0,l=0,p=performance.getEntriesByType("resource"),y=0;y<p.length;y++){var T=p[y],R=T.transferSize,G=T.initiatorType,te=T.duration;if(R&&te&&$S(G)){for(G=0,te=T.responseEnd,y+=1;y<p.length;y++){var le=p[y],ve=le.startTime;if(ve>te)break;var Ie=le.transferSize,$e=le.initiatorType;Ie&&$S($e)&&(le=le.responseEnd,G+=Ie*(le<te?1:(te-ve)/(le-ve)))}if(--y,l+=8*(R+G)/(T.duration/1e3),i++,10<i)break}}if(0<i)return l/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var og=null,lg=null;function Pd(i){return i.nodeType===9?i:i.ownerDocument}function FS(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 zS(i,l){if(i===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&l==="foreignObject"?0:i}function cg(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var ug=null;function SR(){var i=window.event;return i&&i.type==="popstate"?i===ug?!1:(ug=i,!0):(ug=null,!1)}var HS=typeof setTimeout=="function"?setTimeout:void 0,wR=typeof clearTimeout=="function"?clearTimeout:void 0,US=typeof Promise=="function"?Promise:void 0,CR=typeof queueMicrotask=="function"?queueMicrotask:typeof US<"u"?function(i){return US.resolve(null).then(i).catch(kR)}:HS;function kR(i){setTimeout(function(){throw i})}function Hi(i){return i==="head"}function VS(i,l){var p=l,y=0;do{var T=p.nextSibling;if(i.removeChild(p),T&&T.nodeType===8)if(p=T.data,p==="/$"||p==="/&"){if(y===0){i.removeChild(T),Yo(l);return}y--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")y++;else if(p==="html")Cc(i.ownerDocument.documentElement);else if(p==="head"){p=i.ownerDocument.head,Cc(p);for(var R=p.firstChild;R;){var G=R.nextSibling,te=R.nodeName;R[Nn]||te==="SCRIPT"||te==="STYLE"||te==="LINK"&&R.rel.toLowerCase()==="stylesheet"||p.removeChild(R),R=G}}else p==="body"&&Cc(i.ownerDocument.body);p=T}while(p);Yo(l)}function WS(i,l){var p=i;i=0;do{var y=p.nextSibling;if(p.nodeType===1?l?(p._stashedDisplay=p.style.display,p.style.display="none"):(p.style.display=p._stashedDisplay||"",p.getAttribute("style")===""&&p.removeAttribute("style")):p.nodeType===3&&(l?(p._stashedText=p.nodeValue,p.nodeValue=""):p.nodeValue=p._stashedText||""),y&&y.nodeType===8)if(p=y.data,p==="/$"){if(i===0)break;i--}else p!=="$"&&p!=="$?"&&p!=="$~"&&p!=="$!"||i++;p=y}while(p)}function dg(i){var l=i.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var p=l;switch(l=l.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":dg(p),ho(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}i.removeChild(p)}}function jR(i,l,p,y){for(;i.nodeType===1;){var T=p;if(i.nodeName.toLowerCase()!==l.toLowerCase()){if(!y&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(y){if(!i[Nn])switch(l){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(R=i.getAttribute("rel"),R==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(R!==T.rel||i.getAttribute("href")!==(T.href==null||T.href===""?null:T.href)||i.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin)||i.getAttribute("title")!==(T.title==null?null:T.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(R=i.getAttribute("src"),(R!==(T.src==null?null:T.src)||i.getAttribute("type")!==(T.type==null?null:T.type)||i.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin))&&R&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(l==="input"&&i.type==="hidden"){var R=T.name==null?null:""+T.name;if(T.type==="hidden"&&i.getAttribute("name")===R)return i}else return i;if(i=Yr(i.nextSibling),i===null)break}return null}function ER(i,l,p){if(l==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!p||(i=Yr(i.nextSibling),i===null))return null;return i}function GS(i,l){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!l||(i=Yr(i.nextSibling),i===null))return null;return i}function hg(i){return i.data==="$?"||i.data==="$~"}function fg(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function NR(i,l){var p=i.ownerDocument;if(i.data==="$~")i._reactRetry=l;else if(i.data!=="$?"||p.readyState!=="loading")l();else{var y=function(){l(),p.removeEventListener("DOMContentLoaded",y)};p.addEventListener("DOMContentLoaded",y),i._reactRetry=y}}function Yr(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return i}var mg=null;function qS(i){i=i.nextSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="/$"||p==="/&"){if(l===0)return Yr(i.nextSibling);l--}else p!=="$"&&p!=="$!"&&p!=="$?"&&p!=="$~"&&p!=="&"||l++}i=i.nextSibling}return null}function KS(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"){if(l===0)return i;l--}else p!=="/$"&&p!=="/&"||l++}i=i.previousSibling}return null}function YS(i,l,p){switch(l=Pd(p),i){case"html":if(i=l.documentElement,!i)throw Error(r(452));return i;case"head":if(i=l.head,!i)throw Error(r(453));return i;case"body":if(i=l.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function Cc(i){for(var l=i.attributes;l.length;)i.removeAttributeNode(l[0]);ho(i)}var Xr=new Map,XS=new Set;function Bd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var ai=ee.d;ee.d={f:TR,r:AR,D:LR,C:RR,L:DR,m:OR,X:MR,S:IR,M:PR};function TR(){var i=ai.f(),l=Td();return i||l}function AR(i){var l=mo(i);l!==null&&l.tag===5&&l.type==="form"?f0(l):ai.r(i)}var Go=typeof document>"u"?null:document;function QS(i,l,p){var y=Go;if(y&&typeof l=="string"&&l){var T=Hr(l);T='link[rel="'+i+'"][href="'+T+'"]',typeof p=="string"&&(T+='[crossorigin="'+p+'"]'),XS.has(T)||(XS.add(T),i={rel:i,crossOrigin:p,href:l},y.querySelector(T)===null&&(l=y.createElement("link"),Xn(l,"link",i),Hn(l),y.head.appendChild(l)))}}function LR(i){ai.D(i),QS("dns-prefetch",i,null)}function RR(i,l){ai.C(i,l),QS("preconnect",i,l)}function DR(i,l,p){ai.L(i,l,p);var y=Go;if(y&&i&&l){var T='link[rel="preload"][as="'+Hr(l)+'"]';l==="image"&&p&&p.imageSrcSet?(T+='[imagesrcset="'+Hr(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(T+='[imagesizes="'+Hr(p.imageSizes)+'"]')):T+='[href="'+Hr(i)+'"]';var R=T;switch(l){case"style":R=qo(i);break;case"script":R=Ko(i)}Xr.has(R)||(i=f({rel:"preload",href:l==="image"&&p&&p.imageSrcSet?void 0:i,as:l},p),Xr.set(R,i),y.querySelector(T)!==null||l==="style"&&y.querySelector(kc(R))||l==="script"&&y.querySelector(jc(R))||(l=y.createElement("link"),Xn(l,"link",i),Hn(l),y.head.appendChild(l)))}}function OR(i,l){ai.m(i,l);var p=Go;if(p&&i){var y=l&&typeof l.as=="string"?l.as:"script",T='link[rel="modulepreload"][as="'+Hr(y)+'"][href="'+Hr(i)+'"]',R=T;switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":R=Ko(i)}if(!Xr.has(R)&&(i=f({rel:"modulepreload",href:i},l),Xr.set(R,i),p.querySelector(T)===null)){switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(jc(R)))return}y=p.createElement("link"),Xn(y,"link",i),Hn(y),p.head.appendChild(y)}}}function IR(i,l,p){ai.S(i,l,p);var y=Go;if(y&&i){var T=po(y).hoistableStyles,R=qo(i);l=l||"default";var G=T.get(R);if(!G){var te={loading:0,preload:null};if(G=y.querySelector(kc(R)))te.loading=5;else{i=f({rel:"stylesheet",href:i,"data-precedence":l},p),(p=Xr.get(R))&&pg(i,p);var le=G=y.createElement("link");Hn(le),Xn(le,"link",i),le._p=new Promise(function(ve,Ie){le.onload=ve,le.onerror=Ie}),le.addEventListener("load",function(){te.loading|=1}),le.addEventListener("error",function(){te.loading|=2}),te.loading|=4,$d(G,l,y)}G={type:"stylesheet",instance:G,count:1,state:te},T.set(R,G)}}}function MR(i,l){ai.X(i,l);var p=Go;if(p&&i){var y=po(p).hoistableScripts,T=Ko(i),R=y.get(T);R||(R=p.querySelector(jc(T)),R||(i=f({src:i,async:!0},l),(l=Xr.get(T))&&gg(i,l),R=p.createElement("script"),Hn(R),Xn(R,"link",i),p.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},y.set(T,R))}}function PR(i,l){ai.M(i,l);var p=Go;if(p&&i){var y=po(p).hoistableScripts,T=Ko(i),R=y.get(T);R||(R=p.querySelector(jc(T)),R||(i=f({src:i,async:!0,type:"module"},l),(l=Xr.get(T))&&gg(i,l),R=p.createElement("script"),Hn(R),Xn(R,"link",i),p.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},y.set(T,R))}}function JS(i,l,p,y){var T=(T=Z.current)?Bd(T):null;if(!T)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(l=qo(p.href),p=po(T).hoistableStyles,y=p.get(l),y||(y={type:"style",instance:null,count:0,state:null},p.set(l,y)),y):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){i=qo(p.href);var R=po(T).hoistableStyles,G=R.get(i);if(G||(T=T.ownerDocument||T,G={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},R.set(i,G),(R=T.querySelector(kc(i)))&&!R._p&&(G.instance=R,G.state.loading=5),Xr.has(i)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Xr.set(i,p),R||BR(T,i,p,G.state))),l&&y===null)throw Error(r(528,""));return G}if(l&&y!==null)throw Error(r(529,""));return null;case"script":return l=p.async,p=p.src,typeof p=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=Ko(p),p=po(T).hoistableScripts,y=p.get(l),y||(y={type:"script",instance:null,count:0,state:null},p.set(l,y)),y):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function qo(i){return'href="'+Hr(i)+'"'}function kc(i){return'link[rel="stylesheet"]['+i+"]"}function ZS(i){return f({},i,{"data-precedence":i.precedence,precedence:null})}function BR(i,l,p,y){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?y.loading=1:(l=i.createElement("link"),y.preload=l,l.addEventListener("load",function(){return y.loading|=1}),l.addEventListener("error",function(){return y.loading|=2}),Xn(l,"link",p),Hn(l),i.head.appendChild(l))}function Ko(i){return'[src="'+Hr(i)+'"]'}function jc(i){return"script[async]"+i}function ew(i,l,p){if(l.count++,l.instance===null)switch(l.type){case"style":var y=i.querySelector('style[data-href~="'+Hr(p.href)+'"]');if(y)return l.instance=y,Hn(y),y;var T=f({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return y=(i.ownerDocument||i).createElement("style"),Hn(y),Xn(y,"style",T),$d(y,p.precedence,i),l.instance=y;case"stylesheet":T=qo(p.href);var R=i.querySelector(kc(T));if(R)return l.state.loading|=4,l.instance=R,Hn(R),R;y=ZS(p),(T=Xr.get(T))&&pg(y,T),R=(i.ownerDocument||i).createElement("link"),Hn(R);var G=R;return G._p=new Promise(function(te,le){G.onload=te,G.onerror=le}),Xn(R,"link",y),l.state.loading|=4,$d(R,p.precedence,i),l.instance=R;case"script":return R=Ko(p.src),(T=i.querySelector(jc(R)))?(l.instance=T,Hn(T),T):(y=p,(T=Xr.get(R))&&(y=f({},p),gg(y,T)),i=i.ownerDocument||i,T=i.createElement("script"),Hn(T),Xn(T,"link",y),i.head.appendChild(T),l.instance=T);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(y=l.instance,l.state.loading|=4,$d(y,p.precedence,i));return l.instance}function $d(i,l,p){for(var y=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),T=y.length?y[y.length-1]:null,R=T,G=0;G<y.length;G++){var te=y[G];if(te.dataset.precedence===l)R=te;else if(R!==T)break}R?R.parentNode.insertBefore(i,R.nextSibling):(l=p.nodeType===9?p.head:p,l.insertBefore(i,l.firstChild))}function pg(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.title==null&&(i.title=l.title)}function gg(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.integrity==null&&(i.integrity=l.integrity)}var Fd=null;function tw(i,l,p){if(Fd===null){var y=new Map,T=Fd=new Map;T.set(p,y)}else T=Fd,y=T.get(p),y||(y=new Map,T.set(p,y));if(y.has(i))return y;for(y.set(i,null),p=p.getElementsByTagName(i),T=0;T<p.length;T++){var R=p[T];if(!(R[Nn]||R[Be]||i==="link"&&R.getAttribute("rel")==="stylesheet")&&R.namespaceURI!=="http://www.w3.org/2000/svg"){var G=R.getAttribute(l)||"";G=i+G;var te=y.get(G);te?te.push(R):y.set(G,[R])}}return y}function nw(i,l,p){i=i.ownerDocument||i,i.head.insertBefore(p,l==="title"?i.querySelector("head > title"):null)}function $R(i,l,p){if(p===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return i=l.disabled,typeof l.precedence=="string"&&i==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function rw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function FR(i,l,p,y){if(p.type==="stylesheet"&&(typeof y.media!="string"||matchMedia(y.media).matches!==!1)&&(p.state.loading&4)===0){if(p.instance===null){var T=qo(y.href),R=l.querySelector(kc(T));if(R){l=R._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=zd.bind(i),l.then(i,i)),p.state.loading|=4,p.instance=R,Hn(R);return}R=l.ownerDocument||l,y=ZS(y),(T=Xr.get(T))&&pg(y,T),R=R.createElement("link"),Hn(R);var G=R;G._p=new Promise(function(te,le){G.onload=te,G.onerror=le}),Xn(R,"link",y),p.instance=R}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(p,l),(l=p.state.preload)&&(p.state.loading&3)===0&&(i.count++,p=zd.bind(i),l.addEventListener("load",p),l.addEventListener("error",p))}}var xg=0;function zR(i,l){return i.stylesheets&&i.count===0&&Ud(i,i.stylesheets),0<i.count||0<i.imgCount?function(p){var y=setTimeout(function(){if(i.stylesheets&&Ud(i,i.stylesheets),i.unsuspend){var R=i.unsuspend;i.unsuspend=null,R()}},6e4+l);0<i.imgBytes&&xg===0&&(xg=62500*_R());var T=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Ud(i,i.stylesheets),i.unsuspend)){var R=i.unsuspend;i.unsuspend=null,R()}},(i.imgBytes>xg?50:800)+l);return i.unsuspend=p,function(){i.unsuspend=null,clearTimeout(y),clearTimeout(T)}}:null}function zd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ud(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Hd=null;function Ud(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Hd=new Map,l.forEach(HR,i),Hd=null,zd.call(i))}function HR(i,l){if(!(l.state.loading&4)){var p=Hd.get(i);if(p)var y=p.get(null);else{p=new Map,Hd.set(i,p);for(var T=i.querySelectorAll("link[data-precedence],style[data-precedence]"),R=0;R<T.length;R++){var G=T[R];(G.nodeName==="LINK"||G.getAttribute("media")!=="not all")&&(p.set(G.dataset.precedence,G),y=G)}y&&p.set(null,y)}T=l.instance,G=T.getAttribute("data-precedence"),R=p.get(G)||y,R===y&&p.set(null,T),p.set(G,T),this.count++,y=zd.bind(this),T.addEventListener("load",y),T.addEventListener("error",y),R?R.parentNode.insertBefore(T,R.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(T,i.firstChild)),l.state.loading|=4}}var Ec={$$typeof:v,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function UR(i,l,p,y,T,R,G,te,le){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=hr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hr(0),this.hiddenUpdates=hr(null),this.identifierPrefix=y,this.onUncaughtError=T,this.onCaughtError=R,this.onRecoverableError=G,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=le,this.incompleteTransitions=new Map}function sw(i,l,p,y,T,R,G,te,le,ve,Ie,$e){return i=new UR(i,l,p,G,le,ve,Ie,$e,te),l=1,R===!0&&(l|=24),R=Er(3,null,null,l),i.current=R,R.stateNode=i,l=Xm(),l.refCount++,i.pooledCache=l,l.refCount++,R.memoizedState={element:y,isDehydrated:p,cache:l},ep(R),i}function iw(i){return i?(i=ko,i):ko}function aw(i,l,p,y,T,R){T=iw(T),y.context===null?y.context=T:y.pendingContext=T,y=Li(l),y.payload={element:p},R=R===void 0?null:R,R!==null&&(y.callback=R),p=Ri(i,y,l),p!==null&&(yr(p,i,l),ic(p,i,l))}function ow(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var p=i.retryLane;i.retryLane=p!==0&&p<l?p:l}}function yg(i,l){ow(i,l),(i=i.alternate)&&ow(i,l)}function lw(i){if(i.tag===13||i.tag===31){var l=va(i,67108864);l!==null&&yr(l,i,67108864),yg(i,67108864)}}function cw(i){if(i.tag===13||i.tag===31){var l=Rr();l=Ke(l);var p=va(i,l);p!==null&&yr(p,i,l),yg(i,l)}}var Vd=!0;function VR(i,l,p,y){var T=W.T;W.T=null;var R=ee.p;try{ee.p=2,bg(i,l,p,y)}finally{ee.p=R,W.T=T}}function WR(i,l,p,y){var T=W.T;W.T=null;var R=ee.p;try{ee.p=8,bg(i,l,p,y)}finally{ee.p=R,W.T=T}}function bg(i,l,p,y){if(Vd){var T=vg(y);if(T===null)ig(i,l,y,Wd,p),dw(i,y);else if(qR(T,i,l,p,y))y.stopPropagation();else if(dw(i,y),l&4&&-1<GR.indexOf(i)){for(;T!==null;){var R=mo(T);if(R!==null)switch(R.tag){case 3:if(R=R.stateNode,R.current.memoizedState.isDehydrated){var G=on(R.pendingLanes);if(G!==0){var te=R;for(te.pendingLanes|=2,te.entangledLanes|=2;G;){var le=1<<31-ae(G);te.entanglements[1]|=le,G&=~le}js(R),(Ft&6)===0&&(Ed=Me()+500,_c(0))}}break;case 31:case 13:te=va(R,2),te!==null&&yr(te,R,2),Td(),yg(R,2)}if(R=vg(y),R===null&&ig(i,l,y,Wd,p),R===T)break;T=R}T!==null&&y.stopPropagation()}else ig(i,l,y,null,p)}}function vg(i){return i=Sm(i),_g(i)}var Wd=null;function _g(i){if(Wd=null,i=fo(i),i!==null){var l=o(i);if(l===null)i=null;else{var p=l.tag;if(p===13){if(i=c(l),i!==null)return i;i=null}else if(p===31){if(i=u(l),i!==null)return i;i=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null)}}return Wd=i,null}function uw(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 he:return 2;case Te:return 8;case Qe:case me:return 32;case ze:return 268435456;default:return 32}default:return 32}}var Sg=!1,Ui=null,Vi=null,Wi=null,Nc=new Map,Tc=new Map,Gi=[],GR="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 dw(i,l){switch(i){case"focusin":case"focusout":Ui=null;break;case"dragenter":case"dragleave":Vi=null;break;case"mouseover":case"mouseout":Wi=null;break;case"pointerover":case"pointerout":Nc.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Tc.delete(l.pointerId)}}function Ac(i,l,p,y,T,R){return i===null||i.nativeEvent!==R?(i={blockedOn:l,domEventName:p,eventSystemFlags:y,nativeEvent:R,targetContainers:[T]},l!==null&&(l=mo(l),l!==null&&lw(l)),i):(i.eventSystemFlags|=y,l=i.targetContainers,T!==null&&l.indexOf(T)===-1&&l.push(T),i)}function qR(i,l,p,y,T){switch(l){case"focusin":return Ui=Ac(Ui,i,l,p,y,T),!0;case"dragenter":return Vi=Ac(Vi,i,l,p,y,T),!0;case"mouseover":return Wi=Ac(Wi,i,l,p,y,T),!0;case"pointerover":var R=T.pointerId;return Nc.set(R,Ac(Nc.get(R)||null,i,l,p,y,T)),!0;case"gotpointercapture":return R=T.pointerId,Tc.set(R,Ac(Tc.get(R)||null,i,l,p,y,T)),!0}return!1}function hw(i){var l=fo(i.target);if(l!==null){var p=o(l);if(p!==null){if(l=p.tag,l===13){if(l=c(p),l!==null){i.blockedOn=l,Ee(i.priority,function(){cw(p)});return}}else if(l===31){if(l=u(p),l!==null){i.blockedOn=l,Ee(i.priority,function(){cw(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){i.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Gd(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var p=vg(i.nativeEvent);if(p===null){p=i.nativeEvent;var y=new p.constructor(p.type,p);_m=y,p.target.dispatchEvent(y),_m=null}else return l=mo(p),l!==null&&lw(l),i.blockedOn=p,!1;l.shift()}return!0}function fw(i,l,p){Gd(i)&&p.delete(l)}function KR(){Sg=!1,Ui!==null&&Gd(Ui)&&(Ui=null),Vi!==null&&Gd(Vi)&&(Vi=null),Wi!==null&&Gd(Wi)&&(Wi=null),Nc.forEach(fw),Tc.forEach(fw)}function qd(i,l){i.blockedOn===l&&(i.blockedOn=null,Sg||(Sg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,KR)))}var Kd=null;function mw(i){Kd!==i&&(Kd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Kd===i&&(Kd=null);for(var l=0;l<i.length;l+=3){var p=i[l],y=i[l+1],T=i[l+2];if(typeof y!="function"){if(_g(y||p)===null)continue;break}var R=mo(p);R!==null&&(i.splice(l,3),l-=3,vp(R,{pending:!0,data:T,method:p.method,action:y},y,T))}}))}function Yo(i){function l(le){return qd(le,i)}Ui!==null&&qd(Ui,i),Vi!==null&&qd(Vi,i),Wi!==null&&qd(Wi,i),Nc.forEach(l),Tc.forEach(l);for(var p=0;p<Gi.length;p++){var y=Gi[p];y.blockedOn===i&&(y.blockedOn=null)}for(;0<Gi.length&&(p=Gi[0],p.blockedOn===null);)hw(p),p.blockedOn===null&&Gi.shift();if(p=(i.ownerDocument||i).$$reactFormReplay,p!=null)for(y=0;y<p.length;y+=3){var T=p[y],R=p[y+1],G=T[Je]||null;if(typeof R=="function")G||mw(p);else if(G){var te=null;if(R&&R.hasAttribute("formAction")){if(T=R,G=R[Je]||null)te=G.formAction;else if(_g(T)!==null)continue}else te=G.action;typeof te=="function"?p[y+1]=te:(p.splice(y,3),y-=3),mw(p)}}}function pw(){function i(R){R.canIntercept&&R.info==="react-transition"&&R.intercept({handler:function(){return new Promise(function(G){return T=G})},focusReset:"manual",scroll:"manual"})}function l(){T!==null&&(T(),T=null),y||setTimeout(p,20)}function p(){if(!y&&!navigation.transition){var R=navigation.currentEntry;R&&R.url!=null&&navigation.navigate(R.url,{state:R.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var y=!1,T=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(p,100),function(){y=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),T!==null&&(T(),T=null)}}}function wg(i){this._internalRoot=i}Yd.prototype.render=wg.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(r(409));var p=l.current,y=Rr();aw(p,y,i,l,null,null)},Yd.prototype.unmount=wg.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;aw(i.current,2,null,i,null,null),Td(),l[nt]=null}};function Yd(i){this._internalRoot=i}Yd.prototype.unstable_scheduleHydration=function(i){if(i){var l=Dt();i={blockedOn:null,target:i,priority:l};for(var p=0;p<Gi.length&&l!==0&&l<Gi[p].priority;p++);Gi.splice(p,0,i),p===0&&hw(i)}};var gw=t.version;if(gw!=="19.2.8")throw Error(r(527,gw,"19.2.8"));ee.findDOMNode=function(i){var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=h(l),i=i!==null?m(i):null,i=i===null?null:i.stateNode,i};var YR={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:W,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xd.isDisabled&&Xd.supportsFiber)try{et=Xd.inject(YR),ot=Xd}catch{}}return Rc.createRoot=function(i,l){if(!a(i))throw Error(r(299));var p=!1,y="",T=w0,R=C0,G=k0;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(y=l.identifierPrefix),l.onUncaughtError!==void 0&&(T=l.onUncaughtError),l.onCaughtError!==void 0&&(R=l.onCaughtError),l.onRecoverableError!==void 0&&(G=l.onRecoverableError)),l=sw(i,1,!1,null,null,p,y,null,T,R,G,pw),i[nt]=l.current,sg(i),new wg(l)},Rc.hydrateRoot=function(i,l,p){if(!a(i))throw Error(r(299));var y=!1,T="",R=w0,G=C0,te=k0,le=null;return p!=null&&(p.unstable_strictMode===!0&&(y=!0),p.identifierPrefix!==void 0&&(T=p.identifierPrefix),p.onUncaughtError!==void 0&&(R=p.onUncaughtError),p.onCaughtError!==void 0&&(G=p.onCaughtError),p.onRecoverableError!==void 0&&(te=p.onRecoverableError),p.formState!==void 0&&(le=p.formState)),l=sw(i,1,!0,l,p??null,y,T,le,R,G,te,pw),l.context=iw(null),p=l.current,y=Rr(),y=Ke(y),T=Li(y),T.callback=null,Ri(p,T,y),p=y,l.current.lanes=p,Se(l,p),js(l),i[nt]=l.current,sg(i),new Yd(l)},Rc.version="19.2.8",Rc}var Nw;function uD(){if(Nw)return Ng.exports;Nw=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(),Ng.exports=cD(),Ng.exports}var dD=uD();const hD=kf(dD);function fD(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,o,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),o=a.indexOf(".",1),c.push(a.substring(1,~r?r:~o?o:a.length)),u+=~r&&!~o?"(?:/([^/]+?))?":"/([^/]+?)",~o&&(u+=(~r?"?":"")+"\\"+a.substring(o))):u+="/"+a;return{keys:c,pattern:new RegExp("^"+u+(t?"(?=$|/)":"/?$"),"i")}}var Rg={exports:{}},Dg={};/**
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 Tw;function mD(){if(Tw)return Dg;Tw=1;var e=jf();function t(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(f,g){var x=g(),w=r({inst:{value:x,getSnapshot:g}}),C=w[0].inst,b=w[1];return o(function(){C.value=x,C.getSnapshot=g,d(C)&&b({inst:C})},[f,x,g]),a(function(){return d(C)&&b({inst:C}),f(function(){d(C)&&b({inst:C})})},[f]),c(x),x}function d(f){var g=f.getSnapshot;f=f.value;try{var x=g();return!n(f,x)}catch{return!0}}function h(f,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return Dg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Dg}var Aw;function pD(){return Aw||(Aw=1,Rg.exports=mD()),Rg.exports}var gD=pD();const xD=iD.useInsertionEffect,yD=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",bD=yD?j.useLayoutEffect:j.useEffect,vD=xD||bD,sj=e=>{const t=j.useRef([e,(...n)=>t[0](...n)]).current;return vD(()=>{t[0]=e}),t[1]},_D="popstate",Gy="pushState",qy="replaceState",SD="hashchange",Lw=[_D,Gy,qy,SD],wD=e=>{for(const t of Lw)addEventListener(t,e);return()=>{for(const t of Lw)removeEventListener(t,e)}},ij=(e,t)=>gD.useSyncExternalStore(wD,e,t),Rw=()=>location.search,CD=({ssrSearch:e}={})=>ij(Rw,e!=null?()=>e:Rw),Dw=()=>location.pathname,kD=({ssrPath:e}={})=>ij(Dw,e!=null?()=>e:Dw),jD=(e,{replace:t=!1,state:n=null}={})=>history[t?qy:Gy](n,"",e),ED=(e={})=>[kD(e),jD],Ow=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[Ow]>"u"){for(const e of[Gy,qy]){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,Ow,{value:!0})}const ND=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",aj=(e="")=>e==="/"?"":e,TD=(e,t)=>e[0]==="~"?e.slice(1):aj(t)+e,AD=(e="",t)=>ND(Iw(aj(e)),Iw(t)),Iw=e=>{try{return decodeURI(e)}catch{return e}},oj={hook:ED,searchHook:CD,parser:fD,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},lj=j.createContext(oj),Ll=()=>j.useContext(lj),cj={},uj=j.createContext(cj),LD=()=>j.useContext(uj),Ef=e=>{const[t,n]=e.hook(e);return[AD(e.base,t),sj((r,a)=>e.aroundNav(n,TD(r,e.base),a))]},wn=()=>Ef(Ll()),Ky=(e,t,n,r)=>{const{pattern:a,keys:o}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),c=a.exec(n)||[],[u,...d]=c;return u!==void 0?[!0,(()=>{const h=o!==!1?Object.fromEntries(o.map((f,g)=>[f,d[g]])):c.groups;let m={...d};return h&&Object.assign(m,h),m})(),...r?[u]:[]]:[!1,null]},Rl=e=>Ky(Ll().parser,e,wn()[0]),dj=({children:e,...t})=>{var m,f,g;const n=Ll(),r=t.hook?oj:n;let a=r;const[o,c=t.ssrSearch??""]=((m=t.ssrPath)==null?void 0:m.split("?"))??[];o&&(t.ssrSearch=c,t.ssrPath=o),t.hrefs=t.hrefs??((f=t.hook)==null?void 0:f.hrefs),t.searchHook=t.searchHook??((g=t.hook)==null?void 0:g.searchHook);let u=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(lj.Provider,{value:a,children:e})},Mw=({children:e,component:t},n)=>t?j.createElement(t,{params:n}):typeof e=="function"?e(n):e,RD=e=>{let t=j.useRef(cj);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,a])=>a!==n[r])?e:n},Xo=({path:e,nest:t,match:n,...r})=>{const a=Ll(),[o]=Ef(a),[c,u,d]=n??Ky(a.parser,e,o,t),h=RD({...LD(),...u});if(!c)return null;const m=d?j.createElement(dj,{base:d},Mw(r,h)):Mw(r,h);return j.createElement(uj.Provider,{value:h,children:m})},ir=j.forwardRef((e,t)=>{const n=Ll(),[r,a]=Ef(n),{to:o="",href:c=o,onClick:u,asChild:d,children:h,className:m,replace:f,state:g,transition:x,...w}=e,C=sj(_=>{_.ctrlKey||_.metaKey||_.altKey||_.shiftKey||_.button!==0||(u==null||u(_),_.defaultPrevented||(_.preventDefault(),a(c,e)))}),b=n.hrefs(c[0]==="~"?c.slice(1):n.base+c,n);return d&&j.isValidElement(h)?j.cloneElement(h,{onClick:C,href:b}):j.createElement("a",{...w,onClick:C,href:b,className:m!=null&&m.call?m(r===c):m,children:h,ref:t})}),hj=e=>Array.isArray(e)?e.flatMap(t=>hj(t&&t.type===j.Fragment?t.props.children:t)):[e],DD=({children:e,location:t})=>{const n=Ll(),[r]=Ef(n);for(const a of hj(e)){let o=0;if(j.isValidElement(a)&&(o=Ky(n.parser,a.props.path,t||r,a.props.nest))[0])return j.cloneElement(a,{match:o})}return null};/*!
59
+ * OverlayScrollbars
60
+ * Version: 2.16.0
61
+ *
62
+ * Copyright (c) Rene Haas | KingSora.
63
+ * https://github.com/KingSora
64
+ *
65
+ * Released under the MIT license.
66
+ */const Ir=(e,t)=>{const{o:n,i:r,u:a}=e;let o=n,c;const u=(m,f)=>{const g=o,x=m,w=f||(r?!r(g,x):g!==x);return(w||a)&&(o=x,c=g),[o,w,c]};return[t?m=>u(t(o,c),m):u,m=>[o,!!m,c]]},OD=typeof window<"u"&&typeof HTMLElement<"u"&&!!window.document,wr=OD?window:{},fj=Math.max,ID=Math.min,Hx=Math.round,ra=Math.abs,Pw=Math.sign,mj=wr.cancelAnimationFrame,Yy=wr.requestAnimationFrame,Xy=wr.setTimeout,pj=wr.clearTimeout,Nf=e=>typeof wr[e]<"u"?wr[e]:void 0,MD=Nf("MutationObserver"),Bw=Nf("IntersectionObserver"),hl=Nf("ResizeObserver"),Yc=Nf("ScrollTimeline"),Qy=e=>e===void 0,Tf=e=>e===null,oa=e=>typeof e=="number",Dl=e=>typeof e=="string",Af=e=>typeof e=="boolean",_s=e=>typeof e=="function",is=e=>Array.isArray(e),Hh=e=>typeof e=="object"&&!is(e)&&!Tf(e),Jy=e=>{const t=!!e&&e.length,n=oa(t)&&t>-1&&t%1==0;return is(e)||!_s(e)&&n?t>0&&Hh(e)?t-1 in e:!0:!1},au=e=>!!e&&e.constructor===Object,Uh=e=>e instanceof HTMLElement,Lf=e=>e instanceof Element;function Qt(e,t){if(Jy(e))for(let n=0;n<e.length&&t(e[n],n,e)!==!1;n++);else e&&Qt(Object.keys(e),(n=>t(e[n],n,e)));return e}const gj=(e,t)=>e.indexOf(t)>=0,wl=(e,t)=>e.concat(t),xn=(e,t,n)=>(!Dl(t)&&Jy(t)?Array.prototype.push.apply(e,t):e.push(t),e),ha=e=>Array.from(e||[]),Zy=e=>is(e)?e:!Dl(e)&&Jy(e)?ha(e):[e],Vh=e=>!!e&&!e.length,Wh=e=>ha(new Set(e)),Pr=(e,t,n)=>{Qt(e,a=>a?a.apply(void 0,t||[]):!0),n||(e.length=0)},xj="paddingTop",yj="paddingRight",bj="paddingLeft",vj="paddingBottom",_j="marginLeft",Sj="marginRight",wj="marginBottom",eb="overflowX",tb="overflowY",Rf="width",Df="height",mi="visible",hs="hidden",Qa="scroll",PD=e=>{const t=String(e||"");return t?t[0].toUpperCase()+t.slice(1):""},Of=(e,t,n,r)=>{if(e&&t){let a=!0;return Qt(n,(o=>{const c=e[o],u=t[o];c!==u&&(a=!1)})),a}return!1},Cj=(e,t)=>Of(e,t,["w","h"]),Ah=(e,t)=>Of(e,t,["x","y"]),BD=(e,t)=>Of(e,t,["t","r","b","l"]),pt=(e,...t)=>e.bind(0,...t),fl=e=>{let t;const n=e?Xy:Yy,r=e?pj:mj;return[a=>{r(t),t=n((()=>a()),_s(e)?e():e)},()=>r(t)]},$w=e=>{const t=_s(e)?e():e;if(oa(t)){const n=t?Xy:Yy,r=t?pj:mj;return a=>{const o=n((()=>a()),t);return()=>{r(o)}}}return t&&t._},kj=(e,t)=>{const{p:n,v:r,S:a,m:o}=t||{};let c,u,d,h;const m=function(C){u&&u(),c&&c(),h=u=c=d=void 0,e.apply(this,C)},f=w=>o&&d?o(d,w):w,g=()=>{u&&d&&m(f(d)||d)},x=function(){const C=ha(arguments),b=$w(n);if(b){const _=typeof a=="function"?a():a,S=$w(r),k=f(C)||C,E=m.bind(0,k);u&&u(),_&&!h?(E(),h=!0,u=b((()=>h=void 0))):(u=b(E),S&&!c&&(c=S(g))),d=k}else m(C)};return x.O=g,x},jj=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_r=e=>e?Object.keys(e):[],$t=(e,t,n,r,a,o,c)=>{const u=[t,n,r,a,o,c];return(typeof e!="object"||Tf(e))&&!_s(e)&&(e={}),Qt(u,(d=>{Qt(d,((h,m)=>{const f=d[m];if(e===f)return!0;const g=is(f);if(f&&au(f)){const x=e[m];let w=x;g&&!is(x)?w=[]:!g&&!au(x)&&(w={}),e[m]=$t(w,f)}else e[m]=g?f.slice():f}))})),e},Ej=(e,t)=>Qt($t({},e),((n,r,a)=>{n===void 0?delete a[r]:n&&au(n)&&(a[r]=Ej(n))})),nb=e=>!_r(e).length,ou=()=>{},Nj=(e,t,n)=>fj(e,ID(t,n)),Ja=e=>Wh((is(e)?e:(e||"").split(" ")).filter((t=>t))),rb=(e,t)=>e&&e.getAttribute(t),Fw=(e,t)=>e&&e.hasAttribute(t),di=(e,t,n)=>{Qt(Ja(t),(r=>{e&&e.setAttribute(r,String(n||""))}))},Ts=(e,t)=>{Qt(Ja(t),(n=>e&&e.removeAttribute(n)))},If=(e,t)=>{const n=Ja(rb(e,t)),r=pt(di,e,t),a=(o,c)=>{const u=new Set(n);return Qt(Ja(o),(d=>{u[c](d)})),ha(u).join(" ")};return{C:o=>r(a(o,"delete")),$:o=>r(a(o,"add")),H:o=>{const c=Ja(o);return c.reduce(((u,d)=>u&&n.includes(d)),c.length>0)}}},Tj=(e,t,n)=>(If(e,t).C(n),pt(sb,e,t,n)),sb=(e,t,n)=>(If(e,t).$(n),pt(Tj,e,t,n)),Gh=(e,t,n,r)=>(r?sb:Tj)(e,t,n),ib=(e,t,n)=>If(e,t).H(n),Aj=e=>If(e,"class"),Lj=(e,t)=>{Aj(e).C(t)},ab=(e,t)=>(Aj(e).$(t),pt(Lj,e,t)),Rj=(e,t)=>{const n=t?Lf(t)&&t:document;return n?ha(n.querySelectorAll(e)):[]},$D=(e,t)=>{const n=t?Lf(t)&&t:document;return n&&n.querySelector(e)},Ux=(e,t)=>Lf(e)&&e.matches(t),Dj=e=>Ux(e,"body"),Vx=e=>e?ha(e.childNodes):[],lu=e=>e&&e.parentElement,ml=(e,t)=>Lf(e)&&e.closest(t),Wx=e=>document.activeElement,FD=(e,t,n)=>{const r=ml(e,t),a=e&&$D(n,r),o=ml(a,t)===r;return r&&a?r===e||a===e||o&&ml(ml(e,n),t)!==r:!1},Cl=e=>{Qt(Zy(e),(t=>{const n=lu(t);t&&n&&n.removeChild(t)}))},Sr=(e,t)=>pt(Cl,e&&t&&Qt(Zy(t),(n=>{n&&e.appendChild(n)})));let Oj;const zD=()=>Oj,HD=e=>{Oj=e},xl=e=>{const t=document.createElement("div");return di(t,"class",e),t},Ij=e=>{const t=xl(),n=zD(),r=e.trim();return t.innerHTML=n?n.createHTML(r):r,Qt(Vx(t),(a=>Cl(a)))},zw=(e,t)=>e.getPropertyValue(t)||e[t]||"",Mj=e=>{const t=e||0;return isFinite(t)?t:0},Qd=e=>Mj(parseFloat(e||"")),Gx=e=>Math.round(e*1e4)/1e4,Pj=e=>`${Gx(Mj(e))}px`;function cu(e,t){e&&t&&Qt(t,((n,r)=>{try{const a=e.style,o=Tf(n)||Af(n)?"":oa(n)?Pj(n):n;r.indexOf("--")===0?a.setProperty(r,o):a[r]=o}catch{}}))}function Bs(e,t,n){const r=Dl(t);let a=r?"":{};if(e){const o=wr.getComputedStyle(e,n)||e.style;a=r?zw(o,t):ha(t).reduce(((c,u)=>(c[u]=zw(o,u),c)),a)}return a}const Hw=(e,t,n)=>{const r=t?`${t}-`:"",a=n?`-${n}`:"",o=`${r}top${a}`,c=`${r}right${a}`,u=`${r}bottom${a}`,d=`${r}left${a}`,h=Bs(e,[o,c,u,d]);return{t:Qd(h[o]),r:Qd(h[c]),b:Qd(h[u]),l:Qd(h[d])}},Og=(e,t)=>`translate${Hh(e)?`(${e.x},${e.y})`:`${t?"X":"Y"}(${e})`}`,UD=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length),VD={w:0,h:0},Mf=(e,t)=>t?{w:t[`${e}Width`],h:t[`${e}Height`]}:VD,WD=e=>Mf("inner",e||wr),yl=pt(Mf,"offset"),Bj=pt(Mf,"client"),qh=pt(Mf,"scroll"),ob=e=>{const t=parseFloat(Bs(e,Rf))||0,n=parseFloat(Bs(e,Df))||0;return{w:t-Hx(t),h:n-Hx(n)}},Ig=e=>e.getBoundingClientRect(),GD=e=>!!e&&UD(e),qx=e=>!!(e&&(e[Df]||e[Rf])),$j=(e,t)=>{const n=qx(e);return!qx(t)&&n},Uw=(e,t,n,r)=>{Qt(Ja(t),(a=>{e&&e.removeEventListener(a,n,r)}))},un=(e,t,n,r)=>{var a;const o=(a=r&&r.D)!=null?a:!0,c=r&&r.I||!1,u=r&&r.A||!1,d={passive:o,capture:c};return pt(Pr,Ja(t).map((h=>{const m=u?f=>{Uw(e,h,m,c),n&&n(f)}:n;return e&&e.addEventListener(h,m,d),pt(Uw,e,h,m,c)})))},Fj=e=>e.stopPropagation(),Kx=e=>e.preventDefault(),zj=e=>Fj(e)||Kx(e),Os=(e,t)=>{const{x:n,y:r}=oa(t)?{x:t,y:t}:t||{};oa(n)&&(e.scrollLeft=n),oa(r)&&(e.scrollTop=r)},Mr=e=>({x:e.scrollLeft,y:e.scrollTop}),Hj=()=>({T:{x:0,y:0},k:{x:0,y:0}}),qD=(e,t)=>{const{T:n,k:r}=e,{w:a,h:o}=t,c=(f,g,x)=>{let w=Pw(f)*x,C=Pw(g)*x;if(w===C){const b=ra(f),_=ra(g);C=b>_?0:C,w=b<_?0:w}return w=w===C?0:w,[w+0,C+0]},[u,d]=c(n.x,r.x,a),[h,m]=c(n.y,r.y,o);return{T:{x:u,y:h},k:{x:d,y:m}}},Mg=({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)}},Vw=({T:e,k:t},n)=>{const r=(a,o,c)=>Nj(0,1,(a-c)/(a-o)||0);return{x:r(e.x,t.x,n.x),y:r(e.y,t.y,n.y)}},Yx=e=>{e&&e.focus&&e.focus({preventScroll:!0,focusVisible:!1})},Ww=(e,t)=>{Qt(Zy(t),e)},Xx=e=>{const t=new Map,n=(o,c)=>{if(o){const u=t.get(o);Ww((d=>{u&&u[d?"delete":"clear"](d)}),c)}else t.forEach((u=>{u.clear()})),t.clear()},r=(o,c)=>{if(Dl(o)){const h=t.get(o)||new Set;return t.set(o,h),Ww((m=>{_s(m)&&h.add(m)}),c),pt(n,o,c)}Af(c)&&c&&n();const u=_r(o),d=[];return Qt(u,(h=>{const m=o[h];m&&xn(d,r(h,m))})),pt(Pr,d)},a=(o,c)=>{Qt(ha(t.get(o)),(u=>{c&&!Vh(c)?u.apply(0,c):u()}))};return r(e||{}),[r,n,a]},Uj={},Vj={},KD=e=>{Qt(e,(t=>Qt(t,((n,r)=>{Uj[r]=t[r]}))))},Wj=(e,t,n)=>_r(e).map((r=>{const{static:a,instance:o}=e[r],[c,u,d]=n||[],h=n?o:a;if(h){const m=n?h(c,u,t):h(t);return(d||Vj)[r]=m}})),YD=(e,t)=>e[t],Ol=e=>YD(Vj,e),XD="__osOptionsValidationPlugin",Il="data-overlayscrollbars",Lh="os-environment",Jd=`${Lh}-scrollbar-hidden`,Pg=`${Il}-initialize`,Rh="noClipping",Gw=`${Il}-body`,la=Il,QD="host",hi=`${Il}-viewport`,JD=eb,ZD=tb,e5="arrange",Gj="measuring",t5="scrolling",qj="scrollbarHidden",n5="noContent",Qx=`${Il}-padding`,qw=`${Il}-content`,lb="os-size-observer",r5=`${lb}-appear`,s5=`${lb}-listener`,i5="os-trinsic-observer",a5="os-theme-none",$r="os-scrollbar",o5=`${$r}-rtl`,l5=`${$r}-horizontal`,c5=`${$r}-vertical`,Kj=`${$r}-track`,cb=`${$r}-handle`,u5=`${$r}-visible`,d5=`${$r}-cornerless`,Kw=`${$r}-interaction`,Yw=`${$r}-unusable`,Jx=`${$r}-auto-hide`,h5=`${Jx}-hidden`,Xw=`${$r}-wheel`,f5=`${Kj}-interactive`,m5=`${cb}-interactive`,p5="__osSizeObserverPlugin",g5=(e,t)=>{const{M:n}=t,[r,a]=e("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,a]},pl=e=>e.indexOf(mi)===0,x5=e=>e.replace(`${mi}-`,""),Zx=(e,t)=>{if(e==="auto")return t?Qa:hs;const n=e||hs;return[hs,Qa,mi].includes(n)?n:hs},y5=(e,t)=>{const{overflowX:n,overflowY:r}=Bs(e,[eb,tb]);return{x:Zx(n,t.x),y:Zx(r,t.y)}},ub="__osScrollbarsHidingPlugin",b5="__osClickScrollPlugin",Qw=e=>JSON.stringify(e,((t,n)=>{if(_s(n))throw 0;return n})),Jw=(e,t)=>e?`${t}`.split(".").reduce(((n,r)=>n&&jj(n,r)?n[r]:void 0),e):void 0,v5=[0,33],Yj=[33,99],Xj=[222,666,!0],_5={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:{mutation:v5,resize:null,event:Yj,env:Xj},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"]}},Qj=(e,t)=>{const n={},r=wl(_r(t),_r(e));return Qt(r,(a=>{const o=e[a],c=t[a];if(Hh(o)&&Hh(c))$t(n[a]={},Qj(o,c)),nb(n[a])&&delete n[a];else if(jj(t,a)&&c!==o){let u=!0;if(is(o)||is(c))try{Qw(o)===Qw(c)&&(u=!1)}catch{}u&&(n[a]=c)}})),n},Bg=(e,t,n)=>r=>[Jw(e,r),n||Jw(t,r)!==void 0];let Jj;const S5=()=>Jj,w5=e=>{Jj=e};let $g;const C5=()=>{const e=(k,E,N)=>{Sr(document.body,k),Sr(document.body,k);const L=Bj(k),A=yl(k),O=ob(E);return N&&Cl(k),{x:A.h-L.h+O.h,y:A.w-L.w+O.w}},t=k=>{let E=!1;const N=ab(k,Jd);try{E=Bs(k,"scrollbar-width")==="none"||Bs(k,"display","::-webkit-scrollbar")==="none"}catch{}return N(),E},n=`.${Lh}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${Lh} div{width:200%;height:200%;margin:10px 0}.${Jd}{scrollbar-width:none!important}.${Jd}::-webkit-scrollbar,.${Jd}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`,a=Ij(`<div class="${Lh}"><div></div><style>${n}</style></div>`)[0],o=a.firstChild,c=a.lastChild,u=S5();u&&(c.nonce=u);const[d,,h]=Xx(),[m,f]=Ir({o:e(a,o),i:Ah},pt(e,a,o,!0)),[g]=f(),x=t(a),w={x:g.x===0,y:g.y===0},C={elements:{host:null,padding:!x,viewport:k=>x&&Dj(k)&&k,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},b=$t({},_5),_=pt($t,{},b),S=pt($t,{},C),v={U:g,M:w,P:x,J:!!Yc,G:pt(d,"r"),K:S,Z:k=>$t(C,k)&&S(),tt:_,nt:k=>$t(b,k)&&_(),ot:$t({},C),st:$t({},b)};if(Ts(a,"style"),Cl(a),un(wr,"resize",(()=>{h("r",[])})),_s(wr.matchMedia)&&!x&&(!w.x||!w.y)){const k=E=>{const N=wr.matchMedia(`(resolution: ${wr.devicePixelRatio}dppx)`);un(N,"change",(()=>{E(),k(E)}),{A:!0})};k((()=>{const[E,N]=m();$t(v.U,E),h("r",[N])}))}return v},$s=()=>($g||($g=C5()),$g),k5=(e,t,n)=>{let r=!1;const a=n?new WeakMap:!1,o=()=>{r=!0},c=u=>{if(a&&n){const d=n.map((h=>{const[m,f]=h||[];return[f&&m?(u||Rj)(m,e):[],f]}));Qt(d,(h=>Qt(h[0],(m=>{const f=h[1],g=a.get(m)||[];if(e.contains(m)&&f){const w=un(m,f,(C=>{r?(w(),a.delete(m)):t(C)}));a.set(m,xn(g,w))}else Pr(g),a.delete(m)}))))}};return c(),[o,c]},Zw=(e,t,n,r)=>{let a=!1;const{et:o,ct:c,rt:u,it:d,lt:h,ut:m}=r||{},[f,g]=k5(e,(()=>a&&n(!0)),u),x=o||[],w=c||[],C=wl(x,w),b=(S,v)=>{if(!Vh(v)){const k=h||ou,E=m||ou,N=[],L=[];let A=!1,O=!1;if(Qt(v,(I=>{const{attributeName:F,target:B,type:z,oldValue:Y,addedNodes:q,removedNodes:W}=I,ee=z==="attributes",J=z==="childList",H=e===B,P=ee&&F,D=P&&rb(B,F||""),U=Dl(D)?D:null,$=P&&Y!==U,Q=gj(w,F)&&$;if(t&&(J||!H)){const K=ee&&$,Z=K&&d&&Ux(B,d),M=(Z?!k(B,F,Y,U):!ee||K)&&!E(I,!!Z,e,r);Qt(q,(X=>xn(N,X))),Qt(W,(X=>xn(N,X))),O=O||M}!t&&H&&$&&!k(B,F,Y,U)&&(xn(L,F),A=A||Q)})),g((I=>Wh(N).reduce(((F,B)=>(xn(F,Rj(I,B)),Ux(B,I)?xn(F,B):F)),[]))),t)return!S&&O&&n(!1),[!1];if(!Vh(L)||A){const I=[Wh(L),A];return S||n.apply(0,I),I}}},_=new MD(pt(b,!1));return[()=>(_.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:C,subtree:t,childList:t,characterData:t}),a=!0,()=>{a&&(f(),_.disconnect(),a=!1)}),()=>{if(a)return b(!0,_.takeRecords())}]};let Oa=null;const Zj=(e,t,n)=>{const{ft:r}=n||{},a=Ol(p5),[o]=Ir({o:!1,u:!0});return()=>{const c=[],d=Ij(`<div class="${lb}"><div class="${s5}"></div></div>`)[0],h=d.firstChild,m=f=>{const g=is(f)&&!Vh(f);let x=!1,w=!1;if(g){const C=f[0],[b,,_]=o(C.contentRect),S=qx(b);w=$j(b,_),x=!w&&!S}else w=f===!0;x||t({_t:!0,ft:w})};if(hl){if(!Af(Oa)){const w=new hl(ou);w.observe(e,{get box(){Oa=!0}}),Oa=Oa||!1,w.disconnect()}const f=kj(m,{p:0,v:0}),g=w=>f(w),x=new hl(g);if(x.observe(Oa?e:h),xn(c,[()=>{x.disconnect()},!Oa&&Sr(e,d)]),Oa){const w=new hl(g);w.observe(e,{box:"border-box"}),xn(c,(()=>w.disconnect()))}}else if(a){const[f,g]=a(h,m,r);xn(c,wl([ab(d,r5),un(d,"animationstart",f),Sr(e,d)],g))}else return ou;return pt(Pr,c)}},j5=(e,t)=>{let n;const r=d=>d.h===0||d.isIntersecting||d.intersectionRatio>0,a=xl(i5),[o]=Ir({o:!1}),c=(d,h)=>{if(d){const m=o(r(d)),[,f]=m;return f&&!h&&t(m)&&[m]}},u=(d,h)=>c(h.pop(),d);return[()=>{const d=[];if(Bw)n=new Bw(pt(u,!1),{root:e}),n.observe(a),xn(d,(()=>{n.disconnect()}));else{const h=()=>{const m=yl(a);c(m)};xn(d,Zj(a,h)()),h()}return pt(Pr,xn(d,Sr(e,a)))},()=>n&&u(!0,n.takeRecords())]},E5=(e,t,n,r)=>{let a,o,c,u,d,h,m,f;const g=`[${la}]`,x=`[${hi}]`,w=["id","class","style","open","wrap","cols","rows"],{dt:C,vt:b,L:_,gt:S,ht:v,V:k,bt:E,yt:N,wt:L,St:A}=e,O=V=>Bs(V,"direction")==="rtl",I=()=>{let V,M,X;const ne=kj(r,{p:()=>V,v:()=>M,S:()=>X,m(ie,ge){const[ke]=ie,[Oe]=ge;return[wl(_r(ke),_r(Oe)).reduce(((Fe,we)=>(Fe[we]=ke[we]||Oe[we],Fe)),{})]}}),re=(ie,ge)=>{if(is(ge)){const[ke,Oe,Fe]=ge;V=ke,M=Oe,X=Fe}else oa(ge)?(V=ge,M=!1,X=!1):(V=!1,M=!1,X=!1);ne(ie)};return re.O=ne.O,re},F={Ot:!1,B:O(C)},B=$s(),z=Ol(ub),[Y]=Ir({i:Cj,o:{w:0,h:0}},(()=>{const V=z&&z.R(e,t,F,B,n).Y,X=!(E&&k)&&ib(b,la,Rh),ne=!k&&N(e5),re=ne&&Mr(S),ie=re&&A(),ge=L(Gj,X),ke=ne&&V&&V(),Oe=qh(_),Fe=ob(_);return ke&&ke(),Os(S,re),ie&&ie(),X&&ge(),{w:Oe.w+Fe.w,h:Oe.h+Fe.h}})),q=I(),W=V=>{const M=O(C);$t(V,{Ct:f!==M}),$t(F,{B:M}),f=M},ee=(V,M)=>{const[X,ne]=V,re={$t:ne};return $t(F,{Ot:X}),M||r(re),re},J=({_t:V,ft:M})=>{const X=M?r:q,ne={_t:V||M,ft:M};W(ne),X(ne,o)},H=(V,M)=>{const[,X]=Y(),ne={xt:X};return W(ne),X&&!M&&q(ne,V?c:a),ne},P=(V,M,X)=>{const ne={Ht:M};return W(ne),M&&!X&&q(ne,a),ne},[D,U]=v?j5(b,ee):[],$=!k&&Zj(b,J,{ft:!0}),[Q,K]=Zw(b,!1,P,{ct:w,et:w}),Z=k&&hl&&new hl((V=>{const M=V[V.length-1].contentRect;J({_t:!0,ft:$j(M,m)}),m=M}));return[()=>{Z&&Z.observe(b);const V=$&&$(),M=D&&D(),X=Q(),ne=B.G((re=>{const[,ie]=Y();q({Et:re,xt:ie,_t:E},u)}));return()=>{Z&&Z.disconnect(),V&&V(),M&&M(),h&&h(),X(),ne()}},({Dt:V,zt:M,It:X})=>{const ne={},[re]=V("update.ignoreMutation"),[ie,ge]=V("update.attributes"),[ke,Oe]=V("update.elementEvents"),[Fe,we]=V("update.debounce"),We=Oe||ge,Xe=M||X,_e=ye=>_s(re)&&!!re(ye);if(We){d&&d(),h&&h();const[ye,fe]=Zw(v||_,!0,H,{et:wl(w,ie||[]),rt:ke,it:g,ut:(oe,Me)=>{const{target:He,attributeName:he}=oe;return(!Me&&he&&!k?FD(He,g,x):!1)||!!ml(He,`.${$r}`)||_e(oe)}});h=ye(),d=fe}if(we&&(q.O(),is(Fe)||oa(Fe)?(a=Fe,o=!1,c=Yj,u=Xj):au(Fe)?(a=Fe.mutation,o=Fe.resize,c=Fe.event,u=Fe.env):(a=!1,o=!1,c=!1,u=!1)),Xe){const ye=K(),fe=U&&U(),oe=d&&d();ye&&$t(ne,P(ye[0],ye[1],Xe)),fe&&$t(ne,ee(fe[0],Xe)),oe&&$t(ne,H(oe[0],Xe))}return W(ne),ne},F]},eE=(e,t)=>_s(t)?t.apply(0,e):t,N5=(e,t,n,r)=>{const a=Qy(r)?n:r;return eE(e,a)||t.apply(0,e)},tE=(e,t,n,r)=>{const a=Qy(r)?n:r,o=eE(e,a);return!!o&&(Uh(o)?o:t.apply(0,e))},T5=(e,t)=>{const{nativeScrollbarsOverlaid:n,body:r}=t||{},{M:a,P:o,K:c}=$s(),{nativeScrollbarsOverlaid:u,body:d}=c().cancel,h=n??u,m=Qy(r)?d:r,f=(a.x||a.y)&&h,g=e&&(Tf(m)?!o:m);return!!f||!!g},A5=(e,t,n,r)=>{const a="--os-viewport-percent",o="--os-scroll-percent",c="--os-scroll-direction",{K:u}=$s(),{scrollbars:d}=u(),{slot:h}=d,{dt:m,vt:f,L:g,At:x,gt:w,bt:C,V:b}=t,{scrollbars:_}=x?{}:e,{slot:S}=_||{},v=[],k=[],E=[],N=tE([m,f,g],(()=>b&&C?m:f),h,S),L=D=>{if(Yc){let U=null,$=[];const Q=new Yc({source:w,axis:D}),K=()=>{U&&U.cancel(),U=null};return{Mt:V=>{const{Tt:M}=n,X=Mg(M)[D],ne=D==="x",re=[Og(0,ne),Og(`calc(-100% + 100cq${ne?"w":"h"})`,ne)],ie=X?re:re.reverse();return $[0]===ie[0]&&$[1]===ie[1]||($=ie,K(),U=V.kt.animate({clear:["left"],transform:ie},{timeline:Q})),K}}}},A={x:L("x"),y:L("y")},O=()=>{const{Rt:D,Vt:U}=n,$=(Q,K)=>Nj(0,1,Q/(Q+K)||0);return{x:$(U.x,D.x),y:$(U.y,D.y)}},I=(D,U,$)=>{const Q=$?ab:Lj;Qt(D,(K=>{Q(K.Lt,U)}))},F=(D,U)=>{Qt(D,($=>{const[Q,K]=U($);cu(Q,K)}))},B=(D,U,$)=>{const Q=Af($),K=Q?$:!0,Z=Q?!$:!0;K&&I(k,D,U),Z&&I(E,D,U)},z=()=>{const D=O(),U=$=>Q=>[Q.Lt,{[a]:Gx($)+""}];F(k,U(D.x)),F(E,U(D.y))},Y=()=>{if(!Yc){const{Tt:D}=n,U=Vw(D,Mr(w)),$=Q=>K=>[K.Lt,{[o]:Gx(Q)+""}];F(k,$(U.x)),F(E,$(U.y))}},q=()=>{const{Tt:D}=n,U=Mg(D),$=Q=>K=>[K.Lt,{[c]:Q?"0":"1"}];F(k,$(U.x)),F(E,$(U.y)),Yc&&(k.forEach(A.x.Mt),E.forEach(A.y.Mt))},W=()=>{if(b&&!C){const{Rt:D,Tt:U}=n,$=Mg(U),Q=Vw(U,Mr(w)),K=Z=>{const{Lt:V}=Z,M=lu(V)===g&&V,X=(ne,re,ie)=>{const ge=re*ne;return Pj(ie?ge:-ge)};return[M,M&&{transform:Og({x:X(Q.x,D.x,$.x),y:X(Q.y,D.y,$.y)})}]};F(k,K),F(E,K)}},ee=D=>{const U=D?"x":"y",Q=xl(`${$r} ${D?l5:c5}`),K=xl(Kj),Z=xl(cb),V={Lt:Q,Pt:K,kt:Z},M=A[U];return xn(D?k:E,V),xn(v,[Sr(Q,K),Sr(K,Z),pt(Cl,Q),M&&M.Mt(V),r(V,B,D)]),V},J=pt(ee,!0),H=pt(ee,!1),P=()=>(Sr(N,k[0].Lt),Sr(N,E[0].Lt),pt(Pr,v));return J(),H(),[{Ut:z,Nt:Y,qt:q,Bt:W,Ft:B,jt:{Xt:k,Yt:J,Wt:pt(F,k)},Jt:{Xt:E,Yt:H,Wt:pt(F,E)}},P]},L5=(e,t,n,r,a)=>(o,c,u)=>{const{vt:d,L:h,V:m,gt:f,Gt:g,St:x}=t,{Lt:w,Pt:C,kt:b}=o,[_,S]=fl(333),[v,k]=fl(444),E=A=>{_s(f.scrollBy)&&f.scrollBy({behavior:"smooth",left:A.x,top:A.y})},N=()=>{const A="pointerup pointercancel lostpointercapture",O=`client${u?"X":"Y"}`,I=u?Rf:Df,F=u?"left":"top",B=u?"w":"h",z=u?"x":"y",Y=[];return un(C,"pointerdown",r((q=>{const W=ml(q.target,`.${cb}`)===b,ee=W?b:C,J=e.scrollbars,H=J[W?"dragScroll":"clickScroll"],{button:P,isPrimary:D,pointerType:U}=q,{pointers:$}=J;if(P===0&&D&&H&&($||[]).includes(U)){Pr(Y),k();const K=!W&&(q.shiftKey||H==="instant"),Z=pt(Ig,b),V=pt(Ig,C),M=(He,he)=>(He||Z())[F]-(he||V())[F],X=Hx(Ig(f)[I])/yl(f)[B]||1,ne=Mr(f)[z],re=He=>{Os(f,{[z]:ne+He})},ie=He=>{const{Rt:he}=n,Te=yl(C)[B]-yl(b)[B],Qe=1/X*He/Te;re(Qe*he[z])},ge=q[O],ke=Z(),Oe=V(),Fe=ke[I],we=M(ke,Oe)+Fe/2,Xe=ge-Oe[F]-we,_e=W?0:Xe,ye=He=>{Pr(Me),ee.releasePointerCapture(He.pointerId)},fe=W||K,oe=x(),Me=[un(g,A,ye),un(g,"selectstart",(He=>Kx(He)),{D:!1}),un(C,A,ye),fe&&un(C,"pointermove",(He=>ie(_e+He[O]-ge))),fe&&(()=>{const He=Mr(f);oe();const he=Mr(f),Te={x:he.x-He.x,y:he.y-He.y};(ra(Te.x)>3||ra(Te.y)>3)&&(x(),Os(f,He),E(Te),v(oe))})];if(ee.setPointerCapture(q.pointerId),K)ie(Xe);else if(!W){const He=Ol(b5);if(He){const{Vt:he}=n,Te=He(re,ie,pt(M),Xe,he[z],H,!!u,(Qe=>{Qe?oe():xn(Me,oe)}));xn(Me,Te),xn(Y,pt(Te,!0))}}}})))};let L=!0;return pt(Pr,[un(b,"pointermove pointerleave",r(a)),un(w,"pointerenter",r((()=>{c(Kw,!0)}))),un(w,"pointerleave pointercancel",r((()=>{c(Kw,!1)}))),un(w,"wheel",r((A=>{const{deltaX:O,deltaY:I,deltaMode:F}=A;L&&F===0&&lu(w)===d&&E({x:O,y:I}),L=!1,c(Xw,!0),_((()=>{L=!0,c(Xw)})),Kx(A)})),{D:!1,I:!0}),!m&&un(w,"mousedown",r((()=>{const A=Wx();(Fw(A,hi)||Fw(A,la)||A===document.body)&&Xy(pt(Yx,h),25)}))),un(w,"pointerdown",(()=>{const A=un(g,"click",(I=>{O(),zj(I)}),{A:!0,I:!0,D:!1}),O=un(g,"pointerup pointercancel",(()=>{O(),setTimeout(A,150)}),{I:!0,D:!0})}),{I:!0,D:!0}),N(),S,k])},R5=(e,t,n,r,a,o,c)=>{let u,d,h,m,f,g=ou,x=0;const w=["mouse","pen"],C=Z=>V=>{n.Kt||Z(V)},b=Z=>w.includes(Z.pointerType),[_,S]=fl(),[v,k]=fl(100),[E,N]=fl(50),[L,A]=fl((()=>x)),[O,I]=A5(e,o,a,L5(t,o,a,C,(Z=>b(Z)&&P()))),{vt:F,Qt:B,bt:z}=o,{Ft:Y,Ut:q,Nt:W,qt:ee,Bt:J}=O,H=(Z,V)=>{A();const M=X=>{n.Kt||Y(h5,X)};if(Z)M();else{const X=h?!u:!0;x>0&&!V?L(pt(M,X)):M(X)}},P=()=>{(h?!u:!m)&&(H(!0),v((()=>{H(!1)})))},D=Z=>{b(Z)&&(u=!0,!n.Kt&&h&&H(!0))},U=Z=>{b(Z)&&(u=!1,!n.Kt&&h&&H(!1))},$=Z=>{Y(Jx,Z,!0),Y(Jx,Z,!1)},Q=[A,k,N,S,()=>g(),un(F,"pointerover",D,{A:!0}),un(F,"pointerenter",D),un(F,"pointerleave",U),un(F,"pointermove",C((Z=>{b(Z)&&d&&P()}))),un(B,"scroll",C((Z=>{_((()=>{W(),P()})),c(Z),J()})))],K=Ol(ub);return[()=>pt(Pr,xn(Q,I())),({Dt:Z,It:V,Zt:M,tn:X})=>{const{nn:ne,sn:re,en:ie,cn:ge}=X||{},{Ct:ke,ft:Oe}=M||{},{B:Fe}=r,{M:we,P:We}=$s(),{rn:Xe,j:_e}=a,[ye,fe]=Z("showNativeOverlaidScrollbars"),[oe,Me]=Z("scrollbars.theme"),[He,he]=Z("scrollbars.visibility"),[Te,Qe]=Z("scrollbars.autoHide"),[me,ze]=Z("scrollbars.autoHideSuspend"),[at]=Z("scrollbars.autoHideDelay"),[Ze,et]=Z("scrollbars.dragScroll"),[ot,ce]=Z("scrollbars.clickScroll"),[ae,Re]=Z("overflow"),Ve=Oe&&!V,dt=ne||re||ge||ke||V,vt=ie||he||Re,wt=ye&&we.x&&we.y,an=!We&&!K,on=wt||an,fn=(zn,bn,gn)=>{const hr=zn.includes(Qa)&&(He===mi||He==="auto"&&bn===Qa);return Y(u5,hr,gn),hr};if(x=at,(fe||an)&&Y(a5,on),Me&&(Y(f),Y(oe,!0),f=oe),(ze||Ve)&&($(!me),Ve&&me&&(_e.x||_e.y?(g(),E((()=>{g=un(B,Qa,C(pt($,!0)),{A:!0})}))):$(!0))),Qe&&(d=Te==="move",h=Te==="leave",m=Te==="never",H(m,!0)),et&&Y(m5,Ze),ce&&Y(f5,!!ot),vt){const zn=fn(ae.x,Xe.x,!0),bn=fn(ae.y,Xe.y,!1);Y(d5,!(zn&&bn))}dt&&(W(),q(),J(),ge&&ee(),Y(Yw,!_e.x,!0),Y(Yw,!_e.y,!1),Y(o5,Fe&&!z))},{},O]},D5=e=>{const t=$s(),{K:n,P:r}=t,{elements:a}=n(),{padding:o,viewport:c,content:u}=a,d=Uh(e),h=d?{}:e,{elements:m}=h,{padding:f,viewport:g,content:x}=m||{},w=d?e:h.target,C=Dj(w),b=w.ownerDocument,_=b.documentElement,S=()=>b.defaultView||wr,v=pt(N5,[w]),k=pt(tE,[w]),E=pt(xl,""),N=pt(v,E,c),L=pt(k,E,u),A=ke=>{const Oe=yl(ke),Fe=qh(ke),we=Bs(ke,eb),We=Bs(ke,tb);return Fe.w-Oe.w>0&&!pl(we)||Fe.h-Oe.h>0&&!pl(We)},O=N(g),I=O===w,F=I&&C,B=!I&&L(x),z=!I&&O===B,Y=F?_:O,q=F?Y:w,W=!I&&k(E,o,f),ee=!z&&B,J=[ee,Y,W,q].map((ke=>Uh(ke)&&!lu(ke)&&ke)),H=ke=>ke&&gj(J,ke),P=!H(Y)&&A(Y)?Y:w,D=F?_:Y,$={dt:w,vt:q,L:Y,ln:W,ht:ee,gt:D,Qt:F?b:Y,an:C?_:P,Gt:b,bt:C,At:d,V:I,un:S,yt:ke=>ib(Y,hi,ke),wt:(ke,Oe)=>Gh(Y,hi,ke,Oe),St:()=>Gh(D,hi,t5,!0)},{dt:Q,vt:K,ln:Z,L:V,ht:M}=$,X=[()=>{Ts(K,[la,Pg]),Ts(Q,Pg),C&&Ts(_,[Pg,la])}];let ne=Vx([M,V,Z,K,Q].find((ke=>ke&&!H(ke))));const re=F?Q:M||V,ie=pt(Pr,X);return[$,()=>{const ke=S(),Oe=Wx(),Fe=ye=>{Sr(lu(ye),Vx(ye)),Cl(ye)},we=ye=>un(ye,"focusin focusout focus blur",zj,{I:!0,D:!1}),We="tabindex",Xe=rb(V,We),_e=we(Oe);return di(K,la,I?"":QD),di(Z,Qx,""),di(V,hi,""),di(M,qw,""),I||(di(V,We,Xe||"-1"),C&&di(_,Gw,"")),Sr(re,ne),Sr(K,Z),Sr(Z||K,!I&&V),Sr(V,M),xn(X,[_e,()=>{const ye=Wx(),fe=H(V),oe=fe&&ye===V?Q:ye,Me=we(oe);Ts(Z,Qx),Ts(M,qw),Ts(V,hi),C&&Ts(_,Gw),Xe?di(V,We,Xe):Ts(V,We),H(M)&&Fe(M),fe&&Fe(V),H(Z)&&Fe(Z),Yx(oe),Me()}]),r&&!I&&(sb(V,hi,qj),xn(X,pt(Ts,V,hi))),Yx(!I&&C&&Oe===Q&&ke.top===ke?V:Oe),_e(),ne=0,ie},ie]},O5=({ht:e})=>({Zt:t,fn:n,It:r})=>{const{$t:a}=t||{},{Ot:o}=n;e&&(a||r)&&cu(e,{[Df]:o&&"100%"})},I5=({vt:e,ln:t,L:n,V:r},a)=>{const[o,c]=Ir({i:BD,o:Hw()},pt(Hw,e,"padding",""));return({Dt:u,Zt:d,fn:h,It:m})=>{let[f,g]=c(m);const{P:x}=$s(),{_t:w,xt:C,Ct:b}=d||{},{B:_}=h,[S,v]=u("paddingAbsolute");(w||g||(m||C))&&([f,g]=o(m));const E=!r&&(v||b||g);if(E){const N=!S||!t&&!x,L=f.r+f.l,A=f.t+f.b,O={[Sj]:N&&!_?-L:0,[wj]:N?-A:0,[_j]:N&&_?-L:0,top:N?-f.t:0,right:N?_?-f.r:"auto":0,left:N?_?"auto":-f.l:0,[Rf]:N&&`calc(100% + ${L}px)`},I={[xj]:N?f.t:0,[yj]:N?f.r:0,[vj]:N?f.b:0,[bj]:N?f.l:0};cu(t||n,O),cu(n,I),$t(a,{ln:f,_n:!N,F:t?I:$t({},O,I)})}return{dn:E}}},M5=(e,t)=>{const n=$s(),{vt:r,ln:a,L:o,V:c,Qt:u,gt:d,bt:h,wt:m,un:f}=e,{P:g}=n,x=h&&c,w=pt(fj,0),C={display:()=>!1,direction:Q=>Q!=="ltr",flexDirection:Q=>Q.endsWith("-reverse"),writingMode:Q=>Q!=="horizontal-tb"},b=_r(C),_={i:Cj,o:{w:0,h:0}},S={i:Ah,o:{}},v=Q=>{m(Gj,!x&&Q)},k=()=>Bs(o,b),E=(Q,K)=>{const Z=!_r(Q).length,V=K?!0:b.some((We=>{const Xe=Q[We];return Dl(Xe)&&C[We](Xe)}));if(Z||!V||!GD(o))return{T:{x:0,y:0},k:{x:1,y:1}};v(!0);const M=Mr(d),X=un(u,Qa,(We=>{const Xe=Mr(d);We.isTrusted&&Xe.x===M.x&&Xe.y===M.y&&Fj(We)}),{I:!0,A:!0}),ne=m(n5,!0);Os(d,{x:0,y:0}),ne();const re=Mr(d),ie=qh(d);Os(d,{x:ie.w,y:ie.h});const ge=Mr(d),ke={x:ge.x-re.x,y:ge.y-re.y};Os(d,{x:-ie.w,y:-ie.h});const Oe=Mr(d),Fe={x:Oe.x-re.x,y:Oe.y-re.y},we={x:ra(ke.x)>=ra(Fe.x)?ge.x:Oe.x,y:ra(ke.y)>=ra(Fe.y)?ge.y:Oe.y};return Os(d,M),Yy((()=>X())),{T:re,k:we}},N=(Q,K)=>{const Z=wr.devicePixelRatio%1!==0?1:0,V={w:w(Q.w-K.w),h:w(Q.h-K.h)};return{w:V.w>Z?V.w:0,h:V.h>Z?V.h:0}},L=(Q,K)=>{const Z=(V,M,X,ne)=>{const re=V===mi?hs:x5(V),ie=pl(V),ge=pl(X);return!M&&!ne?hs:ie&&ge?mi:ie?M&&ne?re:M?mi:hs:M?re:ge&&ne?mi:hs};return{x:Z(K.x,Q.x,K.y,Q.y),y:Z(K.y,Q.y,K.x,Q.x)}},A=Q=>{const K=V=>[mi,hs,Qa].map((M=>$(Zx(M),V))),Z=K(!0).concat(K()).join(" ");m(Z),m(_r(Q).map((V=>$(Q[V],V==="x"))).join(" "),!0)},[O,I]=Ir(_,pt(ob,o)),[F,B]=Ir(_,pt(qh,o)),[z,Y]=Ir(_),[q]=Ir(S),[W,ee]=Ir(_),[J]=Ir(S),[H]=Ir({i:(Q,K)=>Of(Q,K,Wh(wl(_r(Q),_r(K)))),o:{}}),[P,D]=Ir({i:(Q,K)=>Ah(Q.T,K.T)&&Ah(Q.k,K.k),o:Hj()}),U=Ol(ub),$=(Q,K)=>`${K?JD:ZD}${PD(Q)}`;return({Dt:Q,Zt:K,fn:Z,It:V},{dn:M})=>{const{_t:X,Ht:ne,xt:re,Ct:ie,ft:ge,Et:ke}=K||{},Oe=U&&U.R(e,t,Z,n,Q),{X:Fe,Y:we,W:We}=Oe||{},[Xe,_e]=g5(Q,n),[ye,fe]=Q("overflow"),oe=pl(ye.x),Me=pl(ye.y),He=X||M||re||ie||ke||_e;let he=I(V),Te=B(V),Qe=Y(V),me=ee(V);if(_e&&g&&m(qj,!Xe),He){ib(r,la,Rh)&&v(!0);const tt=we&&we(),[Ye]=he=O(V),[Ue]=Te=F(V),ue=Bj(o),Ke=x&&WD(f()),mt={w:w(Ue.w+Ye.w),h:w(Ue.h+Ye.h)},Dt={w:w((Ke?Ke.w:ue.w+w(ue.w-Ue.w))+Ye.w),h:w((Ke?Ke.h:ue.h+w(ue.h-Ue.h))+Ye.h)};tt&&tt(),me=W(Dt),Qe=z(N(mt,Dt),V)}const[ze,at]=me,[Ze,et]=Qe,[ot,ce]=Te,[ae,Re]=he,[Ve]=q({x:Ze.w>0,y:Ze.h>0}),dt=oe&&Me&&(Ve.x||Ve.y)||oe&&Ve.x&&!Ve.y||Me&&Ve.y&&!Ve.x,vt=M||ie||ke||Re||ce||at||et||fe||_e||He||ne&&x,[wt]=Q("update.flowDirectionStyles"),[an,on]=H(wt?wt(o)||{}:k(),V),fn=ie||ge||on||V,[zn,bn]=fn?P(E(an,!!wt),V):D();let gn=L(Ve,ye);v(!1),vt&&(A(gn),gn=y5(o,Ve),We&&Fe&&(Fe(gn,ot,ae),cu(o,We(gn))));const[hr,Se]=J(gn);return Gh(r,la,Rh,dt),Gh(a,Qx,Rh,dt),$t(t,{rn:hr,Vt:{x:ze.w,y:ze.h},Rt:{x:Ze.w,y:Ze.h},j:Ve,Tt:qD(zn,Ze)}),{en:Se,nn:at,sn:et,cn:bn||et}}},P5=e=>{const[t,n,r]=D5(e),a={ln:{t:0,r:0,b:0,l:0},_n:!1,F:{[Sj]:0,[wj]:0,[_j]:0,[xj]:0,[yj]:0,[vj]:0,[bj]:0},Vt:{x:0,y:0},Rt:{x:0,y:0},rn:{x:hs,y:hs},j:{x:!1,y:!1},Tt:Hj()},{dt:o,gt:c,V:u,St:d}=t,{P:h,M:m}=$s(),f=!h&&(m.x||m.y),g=[O5(t),I5(t,a),M5(t,a)];return[n,x=>{const w={},b=f&&Mr(c),_=b&&d();return Qt(g,(S=>{$t(w,S(x,w)||{})})),Os(c,b),_&&_(),u||Os(o,0),w},a,t,r]},B5=(e,t,n,r)=>{let a=!1;const o={Kt:!1,pn:!1},c=Bg(t,{}),[u,d,h,m,f]=P5(e),[g,x,w]=E5(m,h,c,(k=>{v({},k)})),[C,b,,_]=R5(e,t,o,w,h,m,r),S=k=>_r(k).some((E=>!!k[E])),v=(k,E)=>{const{Kt:N,pn:L}=o;if(L||N&&a)return!1;const{vn:A,It:O,zt:I}=k,F=A||{},B=!!O||!a,z={Dt:Bg(t,F,B),vn:F,It:B},Y=E||x($t({},z,{zt:I})),q=d($t({},z,{fn:w,Zt:Y}));b($t({},z,{Zt:Y,tn:q}));const W=S(Y),ee=S(q),J=W||ee||!nb(F)||B;return a=!0,J&&n(k,{Zt:Y,tn:q}),J};return[()=>{const{an:k,gt:E,St:N}=m,L=Mr(k),A=[g(),u(),C(),()=>{o.pn=!0}],O=N();return Os(E,L),O(),pt(Pr,A)},v,k=>{const E=o.Kt;o.Kt=k,!k&&E!==k&&v({It:!0,zt:!0})},()=>{b({Dt:Bg(t,{},!1),vn:{},It:!1})},()=>({gn:o,hn:w,bn:h}),{yn:m,wn:_},f]},db=new WeakMap,$5=(e,t)=>{db.set(e,t)},F5=e=>{db.delete(e)},nE=e=>db.get(e),gs=(e,t,n)=>{const{tt:r}=$s(),a=Uh(e),o=a?e:e.target,c=nE(o);if(t&&!c){const u=[],d={},h=B=>{const z=Ej(B),Y=Ol(XD);return Y?Y(z,!0):z},m=$t({},r(),h(t)),[f,g,x]=Xx(),[w,C,b]=Xx(n),_=(B,z)=>{b(B,z),x(B,z)},[S,v,k,E,N,L,A]=B5(e,m,(({vn:B,It:z},{Zt:Y,tn:q})=>{const{_t:W,Ct:ee,$t:J,xt:H,Ht:P,ft:D}=Y,{nn:U,sn:$,en:Q,cn:K}=q;_("updated",[F,{updateHints:{sizeChanged:!!W,directionChanged:!!ee,heightIntrinsicChanged:!!J,overflowEdgeChanged:!!U,overflowAmountChanged:!!$,overflowStyleChanged:!!Q,scrollCoordinatesChanged:!!K,contentMutation:!!H,hostMutation:!!P,appear:!!D},changedOptions:B||{},force:!!z}])}),(B=>_("scroll",[F,B]))),O=B=>{const{gn:z}=N(),{pn:Y}=z;Y||(F5(o),Pr(u),_("destroyed",[F,B]),g(),C())},F={options(B,z){if(B){const Y=z?r():{},q=Qj(m,$t(Y,h(B)));nb(q)||($t(m,q),v({vn:q}))}return $t({},m)},on:w,off:(B,z)=>{B&&z&&C(B,z)},state(){const{gn:B,hn:z,bn:Y}=N(),{pn:q,Kt:W}=B,{B:ee}=z,{Vt:J,Rt:H,rn:P,j:D,ln:U,_n:$,Tt:Q}=Y;return $t({},{overflowEdge:J,overflowAmount:H,overflowStyle:P,hasOverflow:D,scrollCoordinates:{start:Q.T,end:Q.k},padding:U,paddingAbsolute:$,directionRTL:ee,sleeping:W,destroyed:q})},elements(){const{dt:B,vt:z,ln:Y,L:q,ht:W,gt:ee,Qt:J}=L.yn,{jt:H,Jt:P}=L.wn,D=$=>{const{kt:Q,Pt:K,Lt:Z}=$;return{scrollbar:Z,track:K,handle:Q}},U=$=>{const{Xt:Q,Yt:K}=$,Z=D(Q[0]);return $t({},Z,{clone:()=>{const V=D(K());return E(),V}})};return $t({},{target:B,host:z,padding:Y||q,viewport:q,content:W||q,scrollOffsetElement:ee,scrollEventElement:J,scrollbarHorizontal:U(H),scrollbarVertical:U(P)})},update:B=>v({It:B,zt:!0}),destroy:pt(O,!1),sleep:k,plugin:B=>d[_r(B)[0]]};return xn(u,[A]),$5(o,F),Wj(Uj,gs,[F,f,d]),T5(L.yn.bt,!a&&e.cancel)?(O(!0),F):(xn(u,S()),_("initialized",[F]),F.update(),F)}return c};gs.plugin=e=>{const t=is(e),n=t?e:[e],r=n.map((a=>Wj(a,gs)[0]));return KD(n),t?r:r[0]};gs.valid=e=>{const t=e&&e.elements,n=_s(t)&&t();return au(n)&&!!nE(n.target)};gs.env=()=>{const{U:e,M:t,P:n,J:r,ot:a,st:o,K:c,Z:u,tt:d,nt:h}=$s();return $t({},{scrollbarsSize:e,scrollbarsOverlaid:t,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:a,staticDefaultOptions:o,getDefaultInitialization:c,setDefaultInitialization:u,getDefaultOptions:d,setDefaultOptions:h})};gs.nonce=w5;gs.trustedTypePolicy=HD;const z5=()=>{if(typeof window>"u"){const h=()=>{};return[h,h]}let e,t;const n=window,r=typeof n.requestIdleCallback=="function",a=n.requestAnimationFrame,o=n.cancelAnimationFrame,c=r?n.requestIdleCallback:a,u=r?n.cancelIdleCallback:o,d=()=>{u(e),o(t)};return[(h,m)=>{d(),e=c(r?()=>{d(),t=a(h)}:h,typeof m=="object"?m:{timeout:2233})},d]},H5=e=>{const{options:t,events:n,defer:r}=e||{},[a,o]=j.useMemo(z5,[]),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:m}=c;d.current=t,gs.valid(m)&&m.options(t||{},!0)},[t]),j.useEffect(()=>{const{current:m}=c;h.current=n,gs.valid(m)&&m.on(n||{},!0)},[n]),j.useEffect(()=>()=>{var m;o(),(m=c.current)==null||m.destroy()},[]),j.useMemo(()=>[m=>{const f=c.current;if(gs.valid(f))return;const g=u.current,x=d.current||{},w=h.current||{},C=()=>c.current=gs(m,x,w);g?a(C,g):C()},()=>c.current],[])},U5=(e,t)=>{const{element:n="div",options:r,events:a,defer:o,children:c,...u}=e,d=n,h=j.useRef(null),m=j.useRef(null),[f,g]=H5({options:r,events:a,defer:o});return j.useEffect(()=>{const{current:x}=h,{current:w}=m;if(!x)return;const C=x;return f(n==="body"?{target:C,cancel:{body:null}}:{target:C,elements:{viewport:w,content:w}}),()=>{var b;return(b=g())==null?void 0:b.destroy()}},[f,n]),j.useImperativeHandle(t,()=>({osInstance:g,getElement:()=>h.current}),[]),ps.createElement(d,{"data-overlayscrollbars-initialize":"",ref:h,...u},n==="body"?c:ps.createElement("div",{"data-overlayscrollbars-contents":"",ref:m},c))},V5=j.forwardRef(U5),ft=j.forwardRef(({options:e,horizontal:t,both:n,onScrollbarGesture:r,...a},o)=>{const c=t||n,u=j.useRef(r);u.current=r;const d=j.useRef(null),h=j.useMemo(()=>({initialized:f=>{var S;(S=d.current)==null||S.call(d);const g=f.elements().scrollbarVertical,x=()=>{const v=g.handle.getBoundingClientRect(),k=g.track.getBoundingClientRect();return v.height===0||k.height===0?null:Math.max(0,k.bottom-v.bottom)};let w=null;const C=()=>{var v;(v=u.current)==null||v.call(u,"up",x()),w==null||w()},b=v=>{var k;if(v.buttons===0){C();return}(k=u.current)==null||k.call(u,"move",x())},_=()=>{var v;(v=u.current)==null||v.call(u,"down",x()),w==null||w(),window.addEventListener("pointermove",b),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),w=()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C),w=null}};g.track.addEventListener("pointerdown",_),d.current=()=>{g.track.removeEventListener("pointerdown",_),w==null||w()}}}),[]);return j.useEffect(()=>()=>{var m;return(m=d.current)==null?void 0:m.call(d)},[]),s.jsx(V5,{ref:o,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})});ft.displayName="ScrollArea";const e1=e=>{let t;const n=new Set,r=(h,m)=>{const f=typeof h=="function"?h(t):h;if(!Object.is(f,t)){const g=t;t=m??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(x=>x(t,g))}},a=()=>t,u={setState:r,getState:a,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h))},d=t=e(r,a,u);return u},W5=(e=>e?e1(e):e1),G5=e=>e;function q5(e,t=G5){const n=ps.useSyncExternalStore(e.subscribe,ps.useCallback(()=>t(e.getState()),[e,t]),ps.useCallback(()=>t(e.getInitialState()),[e,t]));return ps.useDebugValue(n),n}const t1=e=>{const t=W5(e),n=r=>q5(t,r);return Object.assign(n,t),n},Jn=(e=>e?t1(e):t1);function K5(){if(typeof document>"u")return"";const e=Array.from(document.scripts).find(a=>{const o=new URL(a.src,window.location.href).pathname;return o.includes("/assets/")||o.endsWith("/src/main.tsx")});if(!e)return"";const t=new URL(e.src,window.location.href).pathname,n=t.includes("/assets/")?"/assets/":"/src/",r=t.indexOf(n);return r>0?t.slice(0,r):""}const rE=K5();function vs(e){return e.startsWith("/")?`${rE}${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(vs(e),{...t,headers:r})}async function n1(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 sE(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 Ne={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 Zd(e,t){return n=>({loading:{...n.loading,[e]:t}})}function r1(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const hb=[Ne.DISPLAY_SHOW_THINKING,Ne.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Ne.DISPLAY_SHOW_STATS,Ne.DISPLAY_SHOW_AGENT_DEFINITIONS,Ne.DISPLAY_SHOW_WORKFLOW_BARS,Ne.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Ne.DISPLAY_FOLLOW_SYSTEM_THEME,Ne.DISPLAY_SHOW_OPEN_IN_EDITOR,Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,Ne.DISPLAY_MAX_VISIBLE_ITEMS,Ne.DISPLAY_TERMINAL_FONT,Ne.DISPLAY_USE_NATIVE_SCROLLBARS,Ne.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,Ne.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,Ne.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,Ne.DISPLAY_FEED_VIRTUALIZATION];function Fs(){return{showThinking:It(e=>e.settings[Ne.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:It(e=>e.settings[Ne.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:It(e=>e.settings[Ne.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:It(e=>e.settings[Ne.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:It(e=>e.settings[Ne.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:It(e=>e.settings[Ne.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(It(e=>e.settings[Ne.DISPLAY_MAX_VISIBLE_ITEMS]??"300")),useNativeScrollbars:It(e=>e.settings[Ne.DISPLAY_USE_NATIVE_SCROLLBARS]??"false")==="true",useNativeScrollbarsCodeBlocks:It(e=>e.settings[Ne.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS]??"false")==="true",collapseLargeToolCalls:It(e=>e.settings[Ne.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS]??"false")==="true",deferCodeHighlightWhileStreaming:It(e=>e.settings[Ne.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING]??"false")==="true",feedVirtualization:It(e=>e.settings[Ne.DISPLAY_FEED_VIRTUALIZATION]??"false")==="true"}}const It=Jn(e=>({settings:{},loading:{},getSetting:async t=>{e(Zd(t,!0));try{const r=await(await xe(`/api/settings/${t}`)).json();return e(r1(t,r.value??"")),r.value}catch{return e(Zd(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(Zd(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(r1(t,a.value??""))}catch{e(Zd(t,!1))}}})),Dc=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:hb,SETTINGS_KEYS:Ne,useDisplaySettings:Fs,useSettingsStore:It},Symbol.toStringTag,{value:"Module"}));function Y5(){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 o=r.offsetTop,c=r.height,u=n.current-c>100;t({offsetTop:o,height:c,keyboardVisible:u})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}const s1=1e4,kl=new Map;function X5(){const e=Date.now();for(const[t,n]of kl)n.expiresAt<e&&kl.delete(t)}function Q5(e){if(kl.has(e))return;const t=localStorage.getItem("openfox_token"),n=fetch(vs(`/api/sessions/${e}`),{headers:t?{"x-session-token":t}:void 0}).then(async r=>r.ok?{ok:!0,data:await r.json()}:{ok:!1}).catch(()=>({ok:!1}));kl.set(e,{promise:n,expiresAt:Date.now()+s1}),setTimeout(X5,s1)}function J5(e){const t=kl.get(e);if(t&&(kl.delete(e),!(t.expiresAt<Date.now())))return t.promise}function Z5(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Dh(){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 e3{constructor(t){Le(this,"ws",null);Le(this,"handlers",new Set);Le(this,"statusHandler",null);Le(this,"baseUrl");Le(this,"isReconnecting",!1);Le(this,"connectingPromise",null);Le(this,"lastCloseCode",0);Le(this,"reconnectAttempts",0);Le(this,"manualReconnectScheduled",!1);Le(this,"pwaRecoveryAttempted",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,r;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,o)=>{try{const 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(),o(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,m,f;clearTimeout(u),this.lastCloseCode=d.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),o(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(u),console.error("WebSocket error:",d),this.connectingPromise=null,o(d)},this.ws.onmessage=d=>{try{const h=JSON.parse(d.data);Z5(h)&&this.handlers.forEach(m=>m(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(c){this.connectingPromise=null,o(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=Dh(),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 t3=window.location.protocol==="https:"?"wss:":"ws:";let ey=window.location.port;ey||(ey=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const n3=`${t3}//${window.location.hostname}:${ey}${vs("/ws")}`,Ht=new e3(n3),r3=3e4;function iE(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 Oc=null;const nn=Jn((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()=>Oc||(e({loading:!0,error:null}),Oc=(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{Oc=null}})(),Oc),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 o=await xe(`/api/providers/${n}/activate`,{method:"POST"});if(!o.ok){const u=await o.json();throw new Error(u.error??"Failed to activate provider")}const c=await o.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(o){return e({error:o instanceof Error?o.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,r)=>{const{providers:a}=t();try{const o=await xe("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!o.ok)return!1;const c=await o.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:o}=t();return e({providers:o.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()},r3);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(a=>a.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:a}=t(),o=r.find(u=>u.id===a);if(!o)return 2e5;const c=o.models.find(u=>u.id===n);return(c==null?void 0:c.contextWindow)??2e5}})),zt=Jn((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 o=await a.json();return await t().listProjects(),o.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 o=await xe(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)return null;const c=await o.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 o=await xe(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!o.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const c=await o.json();e({currentProject:c.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),da=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"}}},Pf=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 aE(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let eh=[];const Zc=Jn()((e,t)=>{function n(){if(eh.length===0)return;const a=eh;eh=[],e(o=>{const c={...o.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=aE(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(o=>({processes:[...o.processes,a]})),updateProcess:(a,o)=>e(c=>({processes:c.processes.map(u=>u.id===a?{...u,...o}:u)})),removeProcess:a=>e(o=>({processes:o.processes.filter(c=>c.id!==a),logs:Object.fromEntries(Object.entries(o.logs).filter(([c])=>c!==a))})),stopProcess:async(a,o)=>{try{(await xe(`/api/sessions/${o}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,o,c)=>{eh.push({processId:a,stream:o,content:c}),r()},setLogs:(a,o)=>e(c=>({logs:{...c.logs,[a]:o}})),clearLogs:a=>e(o=>({logs:{...o.logs,[a]:[]}})),handleMessage:(a,o)=>{switch(a){case"backgroundProcess.started":{const{processId:c,name:u,command:d,cwd:h,pid:m,status:f}=o;e(g=>({processes:[...g.processes,{id:c,sessionId:"",name:u,command:d,cwd:h,pid:m,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const c=o.processId,u=o.stream,d=o.content;t().appendLog(c,u,d);break}case"backgroundProcess.exited":{const c=o.processId,u=o.exitCode;e(d=>({processes:d.processes.map(h=>h.id===c?{...h,status:"exited",exitCode:u}:h)}));break}case"backgroundProcess.removed":{const c=o.processId;t().removeProcess(c);break}}}}}),oE="/split-view",ty="openfox:split",lE="openfox:split:layout";function s3(){return typeof window>"u"?!1:window.location.pathname===oE}function cE(){const[e]=wn();return e===oE}function i3(){return typeof localStorage>"u"?"columns":localStorage.getItem(lE)==="grid"?"grid":"columns"}function a3(e){typeof localStorage>"u"||localStorage.setItem(lE,e)}function o3(){if(typeof localStorage>"u")return null;const e=localStorage.getItem(ty);if(!e)return null;try{const t=JSON.parse(e);if(!Array.isArray(t.openSessionIds))return null;const n=t.openSessionIds.filter(Boolean),r=typeof t.focusedSessionId=="string"?t.focusedSessionId:null;return{openSessionIds:n,focusedSessionId:r}}catch{return null}}function l3(e){if(!(typeof localStorage>"u")){if(!e||e.openSessionIds.length===0){localStorage.removeItem(ty);return}localStorage.setItem(ty,JSON.stringify(e))}}const Bf="__default__",Kh=new Map,uu=new Set;let Za=null,gi=null,bl=null,fb=0;const i1=16;function c3(e){Za=e}function ol(e=Bf){let t=Kh.get(e);return t||(t={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]},Kh.set(e,t)),t}function u3(e=Bf){Kh.delete(e),uu.delete(e)}function d3(){gi!==null&&(bl==="raf"?cancelAnimationFrame(gi):clearTimeout(gi),gi=null,bl=null)}function Fg(){gi=null,bl=null,fb=Date.now();for(const e of uu)Za==null||Za(e);uu.clear()}function zg(e=Bf){if(uu.add(e),gi!==null)return;const t=Date.now()-fb;t>=i1?typeof document<"u"&&document.hidden?(gi=setTimeout(Fg,0),bl="timeout"):(gi=requestAnimationFrame(Fg),bl="raf"):(gi=setTimeout(Fg,i1-t),bl="timeout")}function sa(e=Bf){fb=0,d3(),uu.delete(e),Za==null||Za(e);const t=Kh.get(e);t&&(t.deltaContent.length>0||t.thinkingContent.length>0||t.toolOutput.length>0||(t.messageId=null,t.deltaContent="",t.thinkingContent="",t.toolOutput=[]))}let th=[];const tr=Jn()((e,t)=>{function n(){if(th.length===0)return;const a=th;th=[],e(o=>({logs:[...o.logs,...a]}))}const r=aE(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 o=t().workdir;if(o)try{const u=await(await xe(`/api/dev-server/config?workdir=${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:u.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const o=t().workdir;if(o)switch(a.type){case"devServer.output":{const c=a.payload;if(c.workdir!==o)return;th.push({stream:c.stream,content:c.content}),r();break}case"devServer.state":{const c=a.payload;if(c.workdir!==o)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}}}}}),a1={open:0,todo:0,inProgress:0,running:0,queued:0,done:0};function h3(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 Bt=Jn((e,t)=>({tasks:[],settings:{slotLimit:1,queuePaused:!1},counts:a1,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();h3(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(o=>({counts:a.counts??o.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 o=await a.json(),c=o==null?void 0:o.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)}),o=await a.json();return a.ok?(await t().loadBoard(n),o.task):(e({lastError:o.error??"Failed to create task"}),null)}catch{return e({lastError:"Failed to create task"}),null}},updateTask:async(n,r,a)=>{try{const o=await xe(`/api/projects/${n}/tasks/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await o.json();return o.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"}),o=await a.json();return a.ok?(await t().loadBoard(n),o.task):null}catch{return null}},moveTask:async(n,r,a,o)=>{try{const c=await xe(`/api/projects/${n}/tasks/${r}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({to:a,...o?{reason:o}:{}})}),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,o)=>{try{const c=await xe(`/api/projects/${n}/tasks/${r}/gate-values/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:o})}),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,o)=>{try{return!!(await xe(`/api/projects/${n}/tasks/${r}/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:a,index:o})})).ok}catch{return!1}},clearBoard:()=>{e({tasks:[],gates:[],settings:{slotLimit:1,queuePaused:!1},counts:a1,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}:{}}))}})),f3=[{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"}],m3=[{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"}],uE={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"},ia={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},dE={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},ny={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...ia},waiting_for_user:{...ia},phase_done:{...ia},phase_blocked:{...ia},new_message:{...dE}},agentOverrides:{}};function hE(e,t,n){var o;const r=e.events[t];if(!n)return r;const a=(o=e.agentOverrides[n])==null?void 0:o[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const Va=Jn((e,t)=>({settings:ny,loaded:!1,load:()=>{It.getState().getSetting(Ne.NOTIFICATION_SETTINGS);const r=It.subscribe(o=>{const c=o.settings[Ne.NOTIFICATION_SETTINGS];if(c!==void 0)try{const u=JSON.parse(c);e({settings:o1(u),loaded:!0})}catch{e({loaded:!0})}}),a=It.getState().settings[Ne.NOTIFICATION_SETTINGS];if(a)try{const o=JSON.parse(a);e({settings:o1(o),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Hg(n)},updateEvent:(n,r)=>{const a=t().settings,o={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:o}),Hg(o)},updateAgentOverride:(n,r,a)=>{var d;const o=t().settings,c={...o.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={...o,agentOverrides:c};e({settings:u}),Hg(u)}}));function Hg(e){It.getState().setSetting(Ne.NOTIFICATION_SETTINGS,JSON.stringify(e))}function o1(e){var t,n,r,a,o;return{soundEnabled:e.soundEnabled??ny.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??ny.browserNotificationEnabled,events:{complete:{...ia,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...ia,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...ia,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...ia,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...dE,...(o=e.events)==null?void 0:o.new_message}},agentOverrides:e.agentOverrides??{}}}const l1=new Map;function p3(e){let t=l1.get(e);return t||(t=new Audio(vs(e)),t.volume=.5,l1.set(e,t)),t}let fE=typeof Notification<"u"?Notification.permission:"denied";function g3(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(fE=e,e))}const x3={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},y3={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 b3(e){typeof Notification>"u"||fE==="granted"&&(document.hasFocus()||new Notification(x3[e],{body:y3[e],icon:vs("/fox.svg"),tag:`openfox-${e}`}))}function ju(e,t){const{settings:n}=Va.getState(),r=hE(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??uE[e],o=p3(a);o.currentTime=0,o.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&b3(e)}const v3=e=>ju("complete",e),_3=e=>ju("phase_done",e),S3=e=>ju("phase_blocked",e),Ug=e=>ju("waiting_for_user",e),w3=e=>ju("new_message",e),c1=new Map;function ll(e,t){var o;const n=t===((o=e.currentSession)==null?void 0:o.id)?e.currentSession:null,r=e.sessions.find(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 C3(e,t){if(e.type==="chat.done"){const n=e.payload,r=ll(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&v3(a),n.reason==="waiting_for_user"&&Ug(a);return}if(e.type==="chat.path_confirmation"){const n=ll(t,e.sessionId);Ug(n);return}if(e.type==="session.confirmation_pending"){const n=ll(t,e.sessionId);Ug(n);return}if(e.type==="task.completed"){const n=ll(t,e.sessionId);_3(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=c1.get(e.sessionId)??null;if(c1.set(e.sessionId,n.phase),r===n.phase)return;const a=ll(t,e.sessionId);n.phase==="blocked"&&S3(a)}}const du=Jn(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,o)=>a.name.localeCompare(o.name));e({servers:r})}catch{}}}));function hu(){return{session:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},queuedMessages:[],abortInProgress:!1,restoredInput:null,activeWorkflowExecution:null,gitStatus:null,error:null}}function ea(e){return{session:e.currentSession,messages:e.messages,hiddenCount:e.hiddenCount,currentTodos:e.currentTodos,contextState:e.contextState,subAgentContextStates:e.subAgentContextStates,pendingPathConfirmations:e.pendingPathConfirmations,pendingQuestions:e.pendingQuestions,visionFallbackByMessage:e.visionFallbackByMessage,queuedMessages:e.queuedMessages,abortInProgress:e.abortInProgress,restoredInput:e.restoredInput,activeWorkflowExecution:e.activeWorkflowExecution,gitStatus:e.gitStatus,error:e.error}}function xi(e){return{currentSession:e.session,messages:e.messages,hiddenCount:e.hiddenCount,currentTodos:e.currentTodos,contextState:e.contextState,subAgentContextStates:e.subAgentContextStates,pendingPathConfirmations:e.pendingPathConfirmations,pendingQuestions:e.pendingQuestions,visionFallbackByMessage:e.visionFallbackByMessage,queuedMessages:e.queuedMessages,abortInProgress:e.abortInProgress,restoredInput:e.restoredInput,activeWorkflowExecution:e.activeWorkflowExecution,gitStatus:e.gitStatus,error:e.error}}function Is(e){var t;return e.focusedSessionId??((t=e.currentSession)==null?void 0:t.id)??null}function vr(e,t){return t?Is(e)===t||e.panes[t]!==void 0:!1}function tn(e,t,n){const r=e.panes[t],a=Is(e)===t;if(!r){if(!a)return e;const u=n(ea(e));return{...e,panes:{...e.panes,[t]:u},...xi(u)}}const o=n(r),c={...e,panes:{...e.panes,[t]:o}};return a?{...c,...xi(o)}:c}function Oh(e,t,n){const r=Is(e)===t,a={...e,panes:{...e.panes,[t]:n}};return r?{...a,...xi(n)}:a}function ry(e,t,n){return tn(e,t,r=>r.session?{...r,session:n(r.session)}:r)}function u1(e,t){if(e.panes[t]===void 0&&e.openSessionIds.includes(t)===!1)return e;const n={...e.panes};delete n[t];const r=e.openSessionIds.filter(c=>c!==t);let a=e.focusedSessionId,o={};return e.focusedSessionId===t&&(a=r.length>0?r[r.length-1]:null,o=xi(a?n[a]??hu():hu())),{...e,panes:n,openSessionIds:r,focusedSessionId:a,...o}}const Vg=new Set;function k3(e,t){return e.includes(t)?e:[...e,t]}function d1(e,t){return e.filter(n=>n!==t)}function Sn(e,t){const n=t.sessionId;n&&e(r=>({unreadSessionIds:k3(r.unreadSessionIds,n)}))}function j3(e,t){const n=e.find(o=>o.id===t.id),r=t.messageCount??0,a=n?{...n,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning,isFavorite:!1,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length,messageCount:r};return n?e.map(o=>o.id===t.id?a:o):[a,...e]}function nh(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 E3(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,o=t.find(c=>c.id===r.id);return{...r,title:r.title??(o==null?void 0:o.title),mode:(a==null?void 0:a.mode)??(o==null?void 0:o.mode)??r.mode,phase:(a==null?void 0:a.phase)??(o==null?void 0:o.phase)??r.phase,isRunning:r.isRunning&&(o==null?void 0:o.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function h1(e,t,n,r){const a=e.sessionId;if(!a)return;const o=n(),c=vr(o,a);t(u=>{let d={...u,sessions:u.sessions.map(h=>h.id===a?r(h):h)};return c&&(d=ry(d,a,h=>{const m=r(h);return{...h,...m}})),d})}function Dn(e,t,n,r){if(!n)return!1;const a=t();return vr(a,n)?(e(o=>tn(o,n,r)),!0):!1}function f1(e,t,n){var o,c,u;const r=n();C3(e,r);const a=r.focusedSessionId??((o=r.currentSession)==null?void 0:o.id)??null;switch(e.type){case"session.state":{const d=e.payload,h=e.sessionId,m=n();if(!(e.id!==void 0||vr(m,h)||m.pendingSessionCreate===!0&&h!==void 0))break;const g=ol(h??"").messageId;sa(h??"");const x=n().pendingSessionCreate===!0,w=d.pendingConfirmations??[],C=d.session.id,b={...n().crossSessionConfirmations};delete b[C],t(_=>{const S=_.panes[C]??(Is(_)===C?ea(_):hu()),v=d.messages.map(N=>{const L=S.messages.find(z=>z.id===N.id);if(N.id===g&&L)return L;if(!L)return N;const A=L.content??"",O=N.content??"",I=L.thinkingContent??"",F=N.thinkingContent??"";if(A.length<=O.length&&I.length<=F.length)return N;const B={...N};return A.length>O.length&&(B.content=A),I.length>F.length&&(B.thinkingContent=I),B}),k={...S,session:d.session,messages:v,hiddenCount:d.hiddenCount??0,currentTodos:[],pendingPathConfirmations:w,pendingQuestions:d.pendingQuestions??[],activeWorkflowExecution:d.activeWorkflowExecution??null,queuedMessages:S.queuedMessages},E=Oh(_,C,k);return{...E,sessions:j3(E.sessions,d.session),unreadSessionIds:d1(E.unreadSessionIds,C),crossSessionConfirmations:b,sessionsWithPendingConfirmations:Object.keys(b),workflowRetry:null,...x?{pendingSessionCreate:C}:{}}});break}case"session.list":{const d=e.payload;t(h=>({sessions:E3(d.sessions,h.sessions,h.currentSession)}));break}case"session.created":{const d=e.payload;t(h=>({sessions:h.sessions.some(m=>m.id===d.session.id)?h.sessions.map(m=>m.id===d.session.id?{...m,...d.session}:m):[d.session,...h.sessions],searchSessions:null}));break}case"session.deleted":{const d=e.payload;t(h=>{const m={...h.panes};return delete m[d.sessionId],{panes:m,openSessionIds:h.openSessionIds.filter(f=>f!==d.sessionId),unreadSessionIds:d1(h.unreadSessionIds,d.sessionId),searchSessions:null}}),n().listSessions();break}case"session.deletedAll":{t({searchSessions:null}),n().listSessions();break}case"session.running":{const d=e.payload;h1(e,t,n,m=>({...m,isRunning:d.isRunning}));const h=e.sessionId;if(!h||!vr(n(),h))break;d.isRunning||t(m=>tn(m,h,f=>({...f,abortInProgress:!1,queuedMessages:[]}))),d.isRunning&&t(m=>tn(m,h,f=>({...f,restoredInput:null})));break}case"chat.message":{Dn(t,n,e.sessionId,d=>{const h=e.payload;if(d.messages.some(f=>f.id===h.message.id))return d;const m=h.message.role==="user";return{...d,messages:[...d.messages,h.message],session:d.session&&m?{...d.session,messageCount:(d.session.messageCount??0)+1}:d.session}})||(e.payload.message.role==="user"&&t(h=>({sessions:h.sessions.map(m=>m.id===e.sessionId?{...m,messageCount:m.messageCount+1}:m)})),Sn(t,e));break}case"chat.message_updated":{const d=e.payload,h=e.sessionId,m=n().panes[h??""],f=(m==null?void 0:m.messages.find(x=>x.id===d.messageId))??(((c=n().currentSession)==null?void 0:c.id)===h?n().messages.find(x=>x.id===d.messageId):void 0);d.updates.isStreaming===!1&&(f==null?void 0:f.isStreaming)===!0&&sa(h??""),Dn(t,n,h,x=>({...x,messages:x.messages.map(w=>{if(w.id!==d.messageId)return w;const C={...w,...d.updates},b=C.content??"",_=w.content??"";return _.length>b.length&&(C.content=_),C})}))||Sn(t,e);break}case"chat.delta":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>{if(d===a&&!Vg.has(h.messageId)){Vg.add(h.messageId);const g=h.subAgentType?"sub-agent":ll(n(),d);w3(g)}const f=ol(d??"");return f.messageId=h.messageId,f.deltaContent+=h.content,zg(d??""),m})||Sn(t,e);break}case"chat.thinking":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>{const f=ol(d??"");return f.messageId=h.messageId,f.thinkingContent+=h.content,zg(d??""),m})||Sn(t,e);break}case"chat.tool_preparing":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>{var b;const f=m.messages.find(_=>_.id===h.messageId);if(!f||((b=f.toolCalls)==null?void 0:b.find((_,S)=>S===h.index)))return m;const x=f.preparingToolCalls??[],w=x.findIndex(_=>_.index===h.index);let C;return w>=0?C=x.map((_,S)=>S===w?{..._,arguments:h.arguments}:_):C=[...x,{index:h.index,name:h.name,...h.arguments?{arguments:h.arguments}:{}}],{...m,messages:m.messages.map(_=>_.id===h.messageId?{..._,preparingToolCalls:C}:_)}})||Sn(t,e);break}case"chat.tool_call":{const d=e.sessionId,h=e.payload,m=f=>{var b;const g=(f.toolCalls??[]).length,x=(b=f.preparingToolCalls)==null?void 0:b.filter(_=>_.index!==g),w=ol(d??""),C=w.toolOutput.filter(_=>_.callId===h.callId);return C.length>0&&(w.toolOutput=w.toolOutput.filter(_=>_.callId!==h.callId)),{...f,toolCalls:[...f.toolCalls??[],{id:h.callId,name:h.tool,arguments:h.args,startedAt:Date.now(),...C.length>0?{streamingOutput:C.map(_=>({stream:_.stream,content:_.content,timestamp:Date.now()}))}:{}}],...x&&x.length>0?{preparingToolCalls:x}:{preparingToolCalls:void 0}}};Dn(t,n,d,f=>({...f,messages:f.messages.map(g=>g.id===h.messageId?m(g):g)}))||Sn(t,e);break}case"chat.tool_output":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>{const f=ol(d??"");return f.messageId=h.messageId,f.toolOutput.push({messageId:h.messageId,callId:h.callId,stream:h.stream,content:h.output}),zg(d??""),m})||Sn(t,e);break}case"chat.tool_result":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>({...m,messages:m.messages.map(f=>{var g;return f.id===h.messageId?{...f,toolCalls:(g=f.toolCalls)==null?void 0:g.map(x=>x.id===h.callId?{...x,result:h.result}:x)}:f})}))||Sn(t,e);break}case"chat.vision_fallback":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>{const f=`${h.messageId}-${h.attachmentId}`,g={...m.visionFallbackByMessage};return g[f]={type:h.type,attachmentId:h.attachmentId,filename:h.filename,description:h.description},{...m,visionFallbackByMessage:g}})||Sn(t,e);break}case"chat.todo":{const d=e.payload;Dn(t,n,e.sessionId,h=>({...h,currentTodos:d.todos}))||Sn(t,e);break}case"chat.progress":{vr(n(),e.sessionId)||Sn(t,e);break}case"chat.format_retry":{vr(n(),e.sessionId)||Sn(t,e);break}case"chat.done":{const d=e.sessionId,h=e.payload;if(!vr(n(),d)){Sn(t,e);break}sa(d??""),Vg.delete(h.messageId);const m=h.stats;t(f=>tn(f,d??"",g=>({...g,messages:g.messages.map(x=>x.id===h.messageId?{...x,isStreaming:!1,stats:m??x.stats,completeReason:h.reason,preparingToolCalls:void 0}:x),visionFallbackByMessage:{}}))),h.reason!=="error"&&t({workflowRetry:null});break}case"chat.message_removed":{const d=e.sessionId,h=e.payload,m=new Set(h.messageIds);Dn(t,n,d,f=>({...f,messages:f.messages.filter(g=>!m.has(g.id)),error:null}));break}case"chat.step_retry":{const d=e.sessionId,h=e.payload;if(!vr(n(),d)){Sn(t,e);break}Dn(t,n,d,m=>({...m,error:null})),t({workflowRetry:{stepName:h.stepName,attempt:h.attempt,retryInMs:h.retryInMs}});break}case"chat.error":{const d=e.sessionId,h=e.payload;if(!vr(n(),d)){Sn(t,e);break}sa(d??""),console.error("Chat error:",h.error,"recoverable:",h.recoverable),t(m=>tn(m,d??"",f=>({...f,error:{code:"CHAT_ERROR",message:h.error}})));break}case"chat.path_confirmation":{const d=e.sessionId,h=e.payload,m={callId:h.callId,tool:h.tool,paths:h.paths,workdir:h.workdir,reason:h.reason};Dn(t,n,d,f=>({...f,pendingPathConfirmations:nh(f.pendingPathConfirmations,m)}))||(Sn(t,e),d&&t(f=>({crossSessionConfirmations:{...f.crossSessionConfirmations,[d]:nh(f.crossSessionConfirmations[d]??[],m)},sessionsWithPendingConfirmations:f.sessionsWithPendingConfirmations.includes(d)?f.sessionsWithPendingConfirmations:[...f.sessionsWithPendingConfirmations,d]})));break}case"session.confirmation_pending":{const d=e.sessionId,h=e.payload,m={callId:h.callId,tool:h.tool,paths:h.paths,workdir:h.workdir,reason:h.reason};!Dn(t,n,d,f=>({...f,pendingPathConfirmations:nh(f.pendingPathConfirmations,m)}))&&d&&t(f=>({crossSessionConfirmations:{...f.crossSessionConfirmations,[d]:nh(f.crossSessionConfirmations[d]??[],m)},sessionsWithPendingConfirmations:f.sessionsWithPendingConfirmations.includes(d)?f.sessionsWithPendingConfirmations:[...f.sessionsWithPendingConfirmations,d]}));break}case"session.confirmation_resolved":{const d=e.sessionId,h=e.payload;d&&(t(m=>{const g=(m.crossSessionConfirmations[d]??[]).filter(w=>w.callId!==h.callId),x={...m.crossSessionConfirmations};return g.length===0?delete x[d]:x[d]=g,{crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x)}}),Dn(t,n,d,m=>({...m,pendingPathConfirmations:m.pendingPathConfirmations.filter(f=>f.callId!==h.callId)})));break}case"chat.ask_user":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>{const f={callId:h.callId,question:h.question,type:h.type??"text",options:h.options??void 0};return{...m,pendingQuestions:[...m.pendingQuestions.filter(g=>g.callId!==h.callId),f]}})||Sn(t,e);break}case"mode.changed":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>m.session?{...m,session:{...m.session,mode:h.mode}}:m)||Sn(t,e);break}case"phase.changed":{const d=e.payload;h1(e,t,n,h=>({...h,phase:d.phase}));break}case"workflow.execution_changed":{const d=e.sessionId,h=e.payload,m={...h.currentStepId?{currentStepId:h.currentStepId}:{},...h.currentStepName?{currentStepName:h.currentStepName}:{},...h.pendingChoices?{pendingChoices:h.pendingChoices}:{}};Dn(t,n,d,f=>{const g=f.activeWorkflowExecution;return g?{...f,activeWorkflowExecution:{...g,status:h.status,...m}}:{...f,activeWorkflowExecution:{id:h.executionId,sessionId:e.sessionId??"",workflowId:h.workflowId,workflowName:h.workflowName,...h.workflowColor?{workflowColor:h.workflowColor}:{},status:h.status,...m,stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}})||Sn(t,e),h.status!=="running"&&t({workflowRetry:null});break}case"criteria.updated":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>m.session?{...m,session:{...m.session,criteria:h.criteria}}:m)||Sn(t,e);break}case"metadata.updated":{const d=e.sessionId,h=e.payload;Dn(t,n,d,m=>m.session?{...m,session:{...m.session,metadataEntries:{...m.session.metadataEntries,[h.key]:h.entries}}}:m)||Sn(t,e);break}case"context.state":{const d=e.payload,h=e.sessionId,m=vr(n(),h);d.subAgentId?m&&h&&t(f=>tn(f,h,g=>({...g,subAgentContextStates:{...g.subAgentContextStates,[d.subAgentId]:d.context}}))):m&&h?t(f=>tn(f,h,g=>({...g,contextState:d.context}))):Sn(t,e);break}case"session.name_generated":{const d=e.payload,h=e.sessionId,m=n().focusedSessionId??((u=n().currentSession)==null?void 0:u.id);t(f=>{var x;const g=h&&((x=f.panes[h])!=null&&x.session)?tn(f,h,w=>({...w,session:{...w.session,metadata:{...w.session.metadata,title:d.name}}})):f;return{...g,sessions:g.sessions.map(w=>w.id===h?{...w,title:d.name}:w),currentSession:m===h&&g.currentSession?{...g.currentSession,metadata:{...g.currentSession.metadata,title:d.name}}:g.currentSession}});break}case"queue.state":{const d=e.payload,h=e.sessionId??Is(n());h&&vr(n(),h)?t(m=>tn(m,h,f=>({...f,queuedMessages:d.messages??[]}))):t({queuedMessages:d.messages??[]});break}case"mcp.servers.changed":{const d=e.payload;if(d!=null&&d.servers){const h=[...d.servers].sort((m,f)=>m.name.localeCompare(f.name));du.getState().setServers(h)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const d=e.payload,h=e.sessionId??Is(n());h&&vr(n(),h)?t(m=>tn(m,h,f=>({...f,gitStatus:{branch:d.branch,diff:d.diff}}))):t({gitStatus:{branch:d.branch,diff:d.diff}});break}case"devServer.output":case"devServer.state":{tr.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Zc.getState().handleMessage(e.type,e.payload);break}case"tasks.update":{Bt.getState().handleTasksUpdate(e.payload);break}case"error":{const d=e.payload;console.error("Server error:",d);const h=e.sessionId??Is(n());t(m=>h&&vr(m,h)?tn(m,h,f=>({...f,error:{code:d.code,message:d.message}})):{error:{code:d.code,message:d.message}});break}}}let Ic=!1,Es=null;const Wg=new Set,Qo=new Set,rh=new Map;let Mc=null;function N3(e,t,n){return e==null?void 0:e.map(r=>{const a=t.filter(o=>o.callId===r.id);return a.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...a.map(o=>({stream:o.stream,content:o.content,timestamp:Date.now()}))]})})}function m1(e,t){return e.includes(t)?e:[...e,t]}async function p1(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(u=>tn(u,e,d=>({...d,queuedMessages:c.queueState})))}catch(o){console.error("Error queueing message:",o)}}function g1(e,t){return e.map(n=>{const r=t.sessions.find(c=>c.id===n.id),a=t.panes[n.id],o=a==null?void 0:a.session;return{...n,title:n.title??(r==null?void 0:r.title),mode:(o==null?void 0:o.id)===n.id?o.mode:(r==null?void 0:r.mode)??n.mode,phase:(o==null?void 0:o.id)===n.id?o.phase:(r==null?void 0:r.phase)??n.phase,isRunning:n.isRunning&&(r==null?void 0:r.isRunning)!==!1,messageCount:n.messageCount,...n.recentUserPrompts!==void 0&&{recentUserPrompts:n.recentUserPrompts}}})}function Qn(e,t){var r;const n=e.panes[t];return n||(((r=e.currentSession)==null?void 0:r.id)===t?ea(e):null)}const De=Jn((e,t)=>{const n=()=>{const o=t();l3({openSessionIds:o.openSessionIds,focusedSessionId:o.focusedSessionId})};c3(o=>{const c=ol(o);if(!c.messageId)return;const u=c.deltaContent.length>0,d=c.thinkingContent.length>0,h=c.toolOutput.length>0;!u&&!d&&!h||e(m=>vr(m,o)?tn(m,o,f=>{const g=f.messages.find(C=>C.id===c.messageId);if(!g)return f;const x={...g};let w=!1;if(u&&(x.content=x.content+c.deltaContent,c.deltaContent="",w=!0),d&&(x.thinkingContent=(x.thinkingContent??"")+c.thinkingContent,c.thinkingContent="",w=!0),h){const C=new Set;x.toolCalls=N3(x.toolCalls,c.toolOutput,C);const b=c.toolOutput.filter(_=>!C.has(_.callId));c.toolOutput=b,w=!0}return w?{...f,messages:f.messages.map(C=>C.id===c.messageId?x:C)}:f}):m)});function r(o,c,u,d,h){return{workflowId:o.workflowId,resumeFrom:o.currentStepId,stepOutput:o.stepOutput,...o.params&&Object.keys(o.params).length>0?{params:o.params}:{},...o.subGroup?{subGroup:o.subGroup}:{},...h?{userChoice:h}:{},...c!=null&&c.trim()?{content:c}:{},...u&&u.length>0?{attachments:u}:{},...d?{messageKind:d}:{}}}async function a(o,c,u=!1){var d,h;if(!(!u&&Wg.has(o))){if(!u&&Qo.has(o)){c&&e(m=>{var g;const f=m.panes[o]??(((g=m.currentSession)==null?void 0:g.id)===o?ea(m):null);return f?{focusedSessionId:o,...xi(f),unreadSessionIds:m.unreadSessionIds.filter(x=>x!==o)}:m});return}Wg.add(o);try{const m=t(),f=Is(m),g=f!==null&&f!==o,x={...m.crossSessionConfirmations};if(g&&f){const k=((d=m.panes[f])==null?void 0:d.pendingPathConfirmations)??m.pendingPathConfirmations;k.length>0&&(x[f]=[...x[f]??[],...k])}e(k=>{const E=k.panes[o],N=E??(Is(k)===o?ea(k):hu()),L=c&&g&&!E;return{focusedSessionId:c?o:k.focusedSessionId,panes:{...k.panes,[o]:N},...c?xi(L?hu():N):{},unreadSessionIds:k.unreadSessionIds.filter(A=>A!==o),crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x),workflowRetry:null,pendingSessionCreate:!1}}),g&&f&&sa(f);const w=J5(o),C=w?w.then(async k=>{if(k.ok)return k.data;const E=await xe(`/api/sessions/${o}`);return E.ok?await E.json():null}):xe(`/api/sessions/${o}`).then(async k=>k.ok?await k.json():null),b=xe(`/api/sessions/${o}/background-processes`),_=await C;if(!_){((h=t().panes[o])==null?void 0:h.session)==null&&(e(k=>u1(k,o)),n());return}const S=_.messages??[],v={...t().crossSessionConfirmations};delete v[o],e(k=>{const N={...k.panes[o]??ea(k),session:_.session,messages:S,hiddenCount:_.hiddenCount??0,contextState:_.contextState??null,queuedMessages:_.queueState??[],pendingPathConfirmations:_.pendingConfirmations??[],pendingQuestions:_.pendingQuestions??[],activeWorkflowExecution:_.activeWorkflowExecution??null};return{...Oh(k,o,N),crossSessionConfirmations:v,sessionsWithPendingConfirmations:Object.keys(v)}}),Ht.send("session.load",{sessionId:o});try{const k=await b;if(k.ok){const E=await k.json();Zc.getState().setProcesses(E.processes??[])}}catch{}Qo.add(o)}catch{}finally{Wg.delete(o)}}}return{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],searchSessions:null,currentSession:null,unreadSessionIds:[],messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],crossSessionConfirmations:{},sessionsWithPendingConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,activeWorkflowExecution:null,workflowRetry:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,pendingUpdate:null,panes:{},openSessionIds:[],focusedSessionId:null,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let c=!1;try{c=(await(await xe("/api/auth")).json()).requiresAuth}catch{}if(c&&!Ht.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Ht.onStatusChange(u=>{var d,h;if(e({connectionStatus:u}),u==="connected"){if(s3())t().listHomeSessions();else{const f=(d=t().currentSession)==null?void 0:d.projectId;f&&t().listSessions(f)}zt.getState().listProjects();const m=t().focusedSessionId??((h=t().currentSession)==null?void 0:h.id);m&&t().loadSession(m)}else(u==="disconnected"||u==="reconnecting")&&Qo.clear()});try{await Ht.connect(),Ic||(Ic=!0,Es=Ht.subscribe(u=>{f1(u,e,t)}))}catch(u){console.error("Failed to connect:",u);const d=Ht.getLastCloseCode();if(!Ht.hasToken()&&(d===1006||d===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Es&&(Es(),Es=null),Ic=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Ht.disconnect(),Es&&(Es(),Es=null),Ic=!1,Qo.clear(),e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Ht.disconnect(),Es&&(Es(),Es=null),Ic=!1,Qo.clear(),e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async o=>{try{const c=await fetch(vs("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:o})});if(!c.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:u}=await c.json();Ht.setToken(u),e({showPasswordModal:!1}),t().connect();const{listProjects:d}=zt.getState(),{fetchConfig:h}=nn.getState();d(),h(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Ht.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(o,c)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const d=await xe("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:o,title:c})});if(!d.ok)return e({pendingSessionCreate:!1}),null;const h=await d.json();e({searchSessions:null});try{Ht.send("session.load",{sessionId:h.session.id})}catch{}return h.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async(o,c=!1)=>{await a(o,!0,c)},openPane:async(o,c={})=>{const u=c.focus??!1;e(d=>({openSessionIds:m1(d.openSessionIds,o)})),await a(o,u),u&&t().focusPane(o),n()},closePane:o=>{sa(o),u3(o),e(c=>u1(c,o)),n()},focusPane:o=>{e(c=>{var d;if(Is(c)===o)return c;const u=c.panes[o]??(((d=c.currentSession)==null?void 0:d.id)===o?ea(c):null);return u?{...c,focusedSessionId:o,openSessionIds:m1(c.openSessionIds,o),...xi(u)}:c}),n()},reorderPane:(o,c)=>{e(u=>{const d=u.openSessionIds.indexOf(o);if(d===-1)return u;const h=d+c;if(h<0||h>=u.openSessionIds.length)return u;const m=[...u.openSessionIds],[f,g]=[m[d],m[h]];return m[d]=g,m[h]=f,{...u,openSessionIds:m}}),n()},isPaneOpen:o=>{const c=t();return c.openSessionIds.includes(o)||c.panes[o]!==void 0},enterSplitView:async(o,c)=>{const u=o.filter(Boolean);if(u.length===0)return;t().listHomeSessions();const d=u.filter(m=>!t().panes[m]);await Promise.all(d.map(m=>t().openPane(m,{focus:!1})));const h=c&&u.includes(c)?c:u[0];e(m=>{const f=[...new Set([...m.openSessionIds,...u])],g=m.panes[h]??null;return{openSessionIds:f,focusedSessionId:h,...g?xi(g):{},unreadSessionIds:m.unreadSessionIds.filter(x=>x!==h)}}),n()},exitSplitView:()=>{n()},listSessions:async(o,c=20)=>{const u=o??"global";if(rh.has(u))return rh.get(u);const d=(async()=>{var h;try{const m=new URLSearchParams;m.set("limit",String(c)),o&&m.set("projectId",o);const g=await(await xe(`/api/sessions?${m.toString()}`)).json(),x=g.sessions??[];e(C=>({sessions:g1(x,C),sessionsHasMore:o?g.hasMore??!1:!0}));const w=g.pendingConfirmationsBySession;if(w){const C=t().focusedSessionId??((h=t().currentSession)==null?void 0:h.id),b={};for(const[_,S]of Object.entries(w))_!==C&&(b[_]=S);e({crossSessionConfirmations:b,sessionsWithPendingConfirmations:Object.keys(b)})}}catch{}finally{rh.delete(u)}})();return rh.set(u,d),d},listHomeSessions:async()=>{try{const o=await xe("/api/sessions/home");if(!o.ok)return;const c=await o.json();e(u=>({sessions:g1(c.sessions,u),sessionsHasMore:!1}))}catch{}},ensureFullSessionList:async()=>{if(!t().searchSessions)return Mc||(Mc=(async()=>{try{const u=(await(await xe("/api/sessions")).json()).sessions??[];e({searchSessions:u})}catch{}finally{Mc=null}})(),Mc)},loadMoreSessions:async o=>{const c=t();if(!(c.sessionsPaginationLoading||!c.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const u=new URLSearchParams;u.set("limit","20"),u.set("offset",String(c.sessions.length)),u.set("projectId",o);const h=await(await xe(`/api/sessions?${u.toString()}`)).json(),m=h.sessions??[];e(f=>({sessions:[...f.sessions,...m.map(g=>{const x=f.sessions.find(w=>w.id===g.id);return(x==null?void 0:x.isRunning)===!1?{...g,isRunning:!1}:g})],sessionsHasMore:h.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async o=>{var c;try{return(await xe(`/api/sessions/${o}`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),(t().focusedSessionId===o||((c=t().currentSession)==null?void 0:c.id)===o)&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(o,c)=>{try{return(await xe(`/api/sessions/${o}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:c})})).ok?(e({searchSessions:null}),await t().listSessions(),e(d=>{const h=d.panes[o];if(!h)return{};const m=h.session?{...h.session,metadata:{...h.session.metadata,title:c}}:h.session;return{...Oh(d,o,{...h,session:m})}}),!0):!1}catch{return!1}},toggleFavorite:async(o,c)=>{e(u=>({sessions:u.sessions.map(d=>d.id===o?{...d,isFavorite:c}:d)}));try{const u=await xe(`/api/sessions/${o}/favorite`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isFavorite:c})});return u.ok?(await t().listSessions(),!0):(console.warn("Failed to toggle favorite",{sessionId:o,isFavorite:c,status:u.status}),e(d=>({sessions:d.sessions.map(h=>h.id===o?{...h,isFavorite:!c}:h)})),!1)}catch(u){return console.error("Error toggling favorite:",u),e(d=>({sessions:d.sessions.map(h=>h.id===o?{...h,isFavorite:!c}:h)})),!1}},deleteAllSessions:async o=>{try{return(await xe(`/api/projects/${o}/sessions`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{var c;const o=t().focusedSessionId??((c=t().currentSession)==null?void 0:c.id);o&&sa(o),Qo.clear(),e(u=>{const d={...u.panes};return o&&delete d[o],{currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,focusedSessionId:null,panes:d,openSessionIds:u.openSessionIds.filter(h=>h!==o),unreadSessionIds:o?u.unreadSessionIds.filter(h=>h!==o):u.unreadSessionIds}})},sendMessage:async(o,c,u,d)=>{const h=Qn(t(),o);if(!(h!=null&&h.session))return;e(f=>tn(f,o,g=>({...g,error:null})));const m=h.activeWorkflowExecution;if(m&&m.status==="running"){Ht.send("runner.launch",r(m,c,u,d==null?void 0:d.messageKind));return}try{const f=c==null?void 0:c.trim(),g=u&&u.length>0,x={};f&&(x.content=c),g&&(x.attachments=u),d!=null&&d.messageKind&&(x.messageKind=d.messageKind);const C=await(await xe(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)})).json();C.queueState&&e(b=>tn(b,o,_=>({..._,queuedMessages:C.queueState})))}catch(f){console.error("Error sending message:",f)}},stopGeneration:async o=>{var c,u;if((c=Qn(t(),o))!=null&&c.session&&!((u=t().panes[o])!=null&&u.abortInProgress)){sa(o),e(d=>tn(d,o,h=>({...h,abortInProgress:!0})));try{const h=await(await xe(`/api/sessions/${o}/stop`,{method:"POST"})).json();if(h.queuedMessages&&h.queuedMessages.length>0){const m=h.queuedMessages.map(f=>f.content).join(`
67
+ `);e(f=>tn(f,o,g=>({...g,restoredInput:m})))}}catch(d){console.error("Error stopping generation:",d)}}},continueGeneration:async o=>{var c;if((c=Qn(t(),o))!=null&&c.session)try{await xe(`/api/sessions/${o}/continue`,{method:"POST"})}catch(u){console.error("Error continuing generation:",u)}},launchWorkflow:(o,c,u,d,h,m,f)=>{var x;if(!((x=Qn(t(),o))!=null&&x.session))return;const g={};c!=null&&c.trim()&&(g.content=c),u&&u.length>0&&(g.attachments=u),d&&(g.workflowId=d),h&&(g.subGroup=h),m&&(g.params=m),g.scope=f??"auto",Ht.send("runner.launch",g)},continueWorkflow:(o,c)=>{const u=Qn(t(),o),d=u==null?void 0:u.activeWorkflowExecution;!d||d.status!=="waiting"||Ht.send("runner.launch",r(d,void 0,void 0,void 0,c))},retryWorkflowStep:o=>{var d;const c=Qn(t(),o),u=c==null?void 0:c.activeWorkflowExecution;!u||!u.currentStepId||(d=c==null?void 0:c.session)!=null&&d.isRunning||(e({workflowRetry:null}),e(h=>tn(h,o,m=>({...m,error:null}))),Ht.send("runner.launch",r(u,void 0,void 0,void 0)))},exitWorkflow:o=>{var c;(c=Qn(t(),o))!=null&&c.session&&Ht.send("workflow.exit",{})},switchMode:async(o,c)=>{var u;if((u=Qn(t(),o))!=null&&u.session)try{const d=await xe(`/api/sessions/${o}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:c})});if(!d.ok){console.error("Failed to switch mode:",await d.json());return}const h=await d.json();h.session&&e(m=>ry(m,o,()=>h.session)),h.messages&&e(m=>tn(m,o,f=>({...f,messages:h.messages,hiddenCount:h.hiddenCount??0})))}catch(d){console.error("Error switching mode:",d)}},switchDangerLevel:async(o,c)=>{var u;if((u=Qn(t(),o))!=null&&u.session)try{const d=await xe(`/api/sessions/${o}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:c})});if(!d.ok){console.error("Failed to switch danger level:",await d.json());return}const h=await d.json();h.session&&e(m=>ry(m,o,()=>h.session))}catch(d){console.error("Error switching danger level:",d)}},editCriteria:async(o,c)=>{var u;if((u=Qn(t(),o))!=null&&u.session)try{const d=await xe(`/api/sessions/${o}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:c})});d.ok||console.error("Failed to update criteria:",await d.json())}catch(d){console.error("Error updating criteria:",d)}},compactContext:o=>{var c;(c=Qn(t(),o))!=null&&c.session&&Ht.send("context.compact",{})},setSessionProvider:async(o,c,u)=>{var d;try{if(!((d=Qn(t(),o))!=null&&d.session))return null;const h=await xe(`/api/sessions/${o}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:c,...u?{model:u}:{}})});if(!h.ok)return null;const m=await h.json();return e(f=>{const g=f.panes[o]??ea(f),x={...g,session:m.session,messages:m.messages??g.messages,hiddenCount:m.hiddenCount??g.hiddenCount,contextState:m.contextState??g.contextState};return Oh(f,o,x)}),m.session}catch{return null}},updateContextState:o=>{var u;const c=t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);c&&e(d=>tn(d,c,h=>({...h,contextState:o})))},updateSubAgentContextState:(o,c)=>{var d;const u=t().focusedSessionId??((d=t().currentSession)==null?void 0:d.id);u&&e(h=>tn(h,u,m=>({...m,subAgentContextStates:{...m.subAgentContextStates,[o]:c}})))},clearSubAgentContextState:o=>{var u;const c=t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);c&&e(d=>tn(d,c,h=>{const m={...h.subAgentContextStates};return delete m[o],{...h,subAgentContextStates:m}}))},confirmPath:async(o,c,u,d=!1)=>{var h;if((h=Qn(t(),o))!=null&&h.session)try{const m=await xe(`/api/sessions/${o}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:c,approved:u,alwaysAllow:d})});if(!m.ok){const f=await m.json().catch(()=>({}));console.error("Error confirming path:",f.error??`HTTP ${m.status}`)}}catch(m){console.error("Error confirming path:",m)}},answerQuestion:async(o,c,u,d)=>{var h;if((h=Qn(t(),o))!=null&&h.session){try{await xe(`/api/sessions/${o}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:c,answer:u,skip:d})})}catch(m){console.error("Error answering question:",m)}e(m=>tn(m,o,f=>({...f,pendingQuestions:f.pendingQuestions.filter(g=>g.callId!==c)})))}},queueAsap:async(o,c,u,d)=>{var h;(h=Qn(t(),o))!=null&&h.session&&await p1(o,c,u,d,e)},queueCompletion:async(o,c,u,d)=>{var h;(h=Qn(t(),o))!=null&&h.session&&await p1(o,c,u,d,e)},cancelQueued:async(o,c)=>{var u;if((u=Qn(t(),o))!=null&&u.session)try{const h=await(await xe(`/api/sessions/${o}/queue/${c}`,{method:"DELETE"})).json();h.queueState&&e(m=>tn(m,o,f=>({...f,queuedMessages:h.queueState})))}catch(d){console.error("Error canceling queued message:",d)}},clearError:()=>{var c;const o=t().focusedSessionId??((c=t().currentSession)==null?void 0:c.id);o&&e(u=>tn(u,o,d=>({...d,error:null})))},clearRestoredInput:o=>{var u;const c=o??t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);c&&e(d=>tn(d,c,h=>({...h,restoredInput:null})))},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:o=>{e({pendingUpdate:o})},triggerPendingUpdate:()=>{const o=t().pendingUpdate;o&&(e({pendingUpdate:null}),Ht.send("context.applyDynamic",{sessionId:o}))},handleServerMessage:o=>{f1(o,e,t)}}});function $f(e){return De(t=>{var n,r,a,o,c,u;return e?(n=t.panes)!=null&&n[e]?((o=(a=(r=t.panes)==null?void 0:r[e])==null?void 0:a.session)==null?void 0:o.isRunning)??!1:((c=t.currentSession)==null?void 0:c.id)===e?t.currentSession.isRunning??!1:!1:((u=t.currentSession)==null?void 0:u.isRunning)??!1})}function T3(e){return De(t=>{var n,r,a,o;return e?(n=t.panes)!=null&&n[e]?((a=(r=t.panes)==null?void 0:r[e])==null?void 0:a.queuedMessages)??[]:((o=t.currentSession)==null?void 0:o.id)===e?t.queuedMessages:[]:t.queuedMessages})}function A3(e){return De(t=>t.abortInProgress)}function L3(e){return De(t=>{var n,r,a,o;return e?(n=t.panes)!=null&&n[e]?((a=(r=t.panes)==null?void 0:r[e])==null?void 0:a.pendingQuestions)??[]:((o=t.currentSession)==null?void 0:o.id)===e?t.pendingQuestions:[]:t.pendingQuestions})}function R3(){const e=De(a=>a.connect),t=De(a=>a.connectionStatus),n=Va(a=>a.load),r=Rl("/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 D3="modulepreload",O3=function(e){return"/"+e},x1={},se=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=c(n.map(h=>{if(h=O3(h),h in x1)return;x1[h]=!0;const m=h.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${f}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":D3,m||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),m)return new Promise((x,w)=>{g.addEventListener("load",x),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(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"&&o(u.reason);return t().catch(o)})},I3=[{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"}],M3=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"}]'),mE={tokens:I3,presets:M3},pE=mE.tokens,ur=mE.presets;function y1(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function P3(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Xt=Jn((e,t)=>{const n=P3();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:y1(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:o}=t(),c=r();if(c)try{const u=JSON.parse(c);u.preset&&u.tokens?(a(u.preset),e({basePreset:u.preset}),o(u.tokens)):u.preset?a(u.preset):u.tokens&&o(u.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(ur.find(o=>o.id===r))if(r==="system"){const o=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:c,systemLightPreset:u,userPresets:d}=t(),h=o.matches?c:u,m=d.find(f=>f.id===h);e(m?{basePreset:"system",currentPreset:m.basePreset,customTokens:{...m.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:m.id}:{basePreset:"system",currentPreset:h,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0,activeUserPresetId:null}),t().applyTheme()}else e({currentPreset:r,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1,activeUserPresetId:null}),t().applyTheme()},startCustomizing:()=>{var o;const{currentPreset:r}=t(),a=((o=ur.find(c=>c.id===r))==null?void 0:o.tokens)??{};e({basePreset:r,customTokens:{...a},isCustom:!0,isCustomizing:!0})},setCustomToken:(r,a)=>{e(o=>({customTokens:{...o.customTokens,[r]:a}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:r}=t();t().saveTheme(JSON.stringify({tokens:r})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:r=>{e({customTokens:r,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var u,d;const{basePreset:r,customTokens:a,isCustom:o}=t();if(o&&r)return{...((u=ur.find(m=>m.id===r))==null?void 0:u.tokens)??{},...a};if(o)return{...pE.reduce((h,m)=>({...h,[m.key]:m.defaultValue}),{}),...a};const c=ur.find(h=>h.id===t().currentPreset);return(c==null?void 0:c.tokens)??((d=ur[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([o,c])=>{a.style.setProperty(`--${o}`,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 se(async()=>{const{useSettingsStore:o}=await Promise.resolve().then(()=>Dc);return{useSettingsStore:o}},void 0);await a.getState().setSetting(Ne.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),se(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Dc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_FOLLOW_SYSTEM_THEME,String(r))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const r=window.matchMedia("(prefers-color-scheme: dark)"),a=c=>{const{followSystemTheme:u,systemDarkPreset:d,systemLightPreset:h}=t();if(!u)return;const m=c?d:h;t().applyPreset(m),t().saveTheme(JSON.stringify({preset:m}))},o=c=>a(c.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0,systemDarkPreset:"dark",systemLightPreset:"light",activeUserPresetId:null})},addUserPreset:r=>{const{basePreset:a,customTokens:o,currentPreset:c}=t(),u=a||c,d=ur.find(f=>f.id===u),h={id:"custom-"+Date.now(),name:r,basePreset:u,mode:d==null?void 0:d.mode,tokens:{...o}},m=[...t().userPresets,h];e({userPresets:m}),t().saveUserPresets()},applyUserPreset:r=>{const a=t().userPresets[r];a&&(e({currentPreset:a.basePreset,basePreset:a.basePreset,customTokens:{...a.tokens},isCustom:!0,isCustomizing:!1,activeUserPresetId:a.id}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:a.basePreset,tokens:a.tokens})).catch(()=>{}))},deleteUserPreset:r=>{const a=t().userPresets.filter((o,c)=>c!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:y1()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),se(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>Dc);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(Ne.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),se(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Dc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset}))}),t().isSystem&&t().applyPreset("system")},setSystemLightPreset:r=>{e({systemLightPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r})),se(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Dc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r}))}),t().isSystem&&t().applyPreset("system")}}});function B3({canLoad:e,projectId:t,currentProjectId:n}){const r=zt(c=>c.loadProject),a=De(c=>c.listSessions),o=De(c=>c.clearSession);j.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),o())},[e,t,n,r,a,o])}function $3({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const o=De(h=>h.loadSession),c=zt(h=>h.loadProject),u=De(h=>h.listSessions),d=De(h=>h.pendingSessionCreate);j.useEffect(()=>{e&&t&&r!==t&&c(t)},[e,t,r,c]),j.useEffect(()=>{e&&n&&a!==n&&o(n),e&&t&&u(t)},[e,n,a,o,u,d,t])}function F3({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 Ff({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 gE({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 z3({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 eo({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 zs({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 fu({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"3.5",y:"4",width:"7",height:"16",rx:"1.5",strokeWidth:1.8}),s.jsx("rect",{x:"13.5",y:"4",width:"7",height:"16",rx:"1.5",strokeWidth:1.8})]})}function xE({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 yn(e){return s.jsx(xE,{direction:"down",...e})}function mb(e){return s.jsx(xE,{direction:"up",...e})}function H3({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function jl({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function pb({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 gb({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 xb({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 ss({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 U3({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 V3({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 W3({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 zf({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 G3({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 sy({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 yE({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 yb({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 Hf({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 as({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 q3({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 Uf({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 bE({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 K3({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 mu({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 Vf({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 bb({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 Y3({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 vb({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 vE({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 X3({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 Si({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 _i({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 Q3({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 iy({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 Ss({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 _b({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 J3({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 Z3({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 b1({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 ay(){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 v1(e,t){const n=Ht.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:ay(),type:e,payload:t}))}const fs=Jn((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 o=Ht.ws;if(o&&o.readyState===WebSocket.OPEN)for(const c of a)o.send(JSON.stringify({id:ay(),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 o=await a.json();e(u=>({sessions:[...u.sessions,o]}));const c=Ht.ws;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({id:ay(),type:"terminal.subscribe",payload:{sessionId:o.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{v1("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{v1("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(o=>o.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(a=>{const o=a.sessions.filter(c=>c.id!==r);return o.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:o}});break}}}}));Ht.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&fs.getState().handleMessage(e)});const bi=Jn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(vs(`/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"})}}}})),Ds={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 oy(e){if(!e)return structuredClone(Ds);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(Ds[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(Ds)}}function _1(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Sb(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 eO(e){return e.type==="double-press"}function _E(e){return e.type==="chord"}function tO(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 SE(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),o=t.modifiers.includes("shift");return tO(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===o}function Eu(){const e=It(t=>t.settings[Ne.KEYBINDINGS]);return oy(e)}function nO(e,t,n){const r=j.useRef(0),a=j.useRef(t);a.current=t,j.useEffect(()=>{if(!e)return;const o=e.threshold??300,c=u=>{if(u.key!==e.key)return;const d=e.key==="Control",h=e.key==="Shift",m=e.key==="Alt",f=e.key==="Meta";if(!d&&u.ctrlKey||!h&&u.shiftKey||!m&&u.altKey||!f&&u.metaKey)return;const g=Date.now();g-r.current<o?(u.preventDefault(),u.stopPropagation(),a.current(),r.current=0):r.current=g};return window.addEventListener("keydown",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 rO(e,t){const n=j.useRef(t);n.current=t,j.useEffect(()=>{if(!e)return;const r=a=>{SE(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function pu(e,t,n){nO(e&&eO(e)?e:void 0,t,n),rO(e&&_E(e)?e:void 0,t)}function sO(e,t,n){const r=j.useRef(n);r.current=n,j.useEffect(()=>{const a=o=>{for(let c=0;c<e.length;c++){const u=e[c];if(!u)continue;const d=t[c];if(d&&_E(u)&&SE(o,u)){o.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var wi=rj();const Wf=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})})}));Wf.displayName="IconButton";const iO="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",vi=j.forwardRef((e,t)=>s.jsx(Wf,{ref:t,icon:iO,title:"Edit",...e}));vi.displayName="EditButton";const aO="M6 18L18 6M6 6l12 12",wb=j.forwardRef((e,t)=>s.jsx(Wf,{ref:t,icon:aO,...e}));wb.displayName="CloseButton";const oO={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[90vh] flex-1"};function jt({label:e,title:t,headerRight:n,size:r="md",minHeight:a,children:o,footer:c,className:u,onClose:d,isOpen:h,closeOnBackdropClick:m=!0,closeOnEscape:f=!0,showCloseButton:g=!0,scrollable:x=!0}){const[w,C]=j.useState(!1),b=h!==void 0,_=b?h:w,S=j.useCallback(()=>{b||C(!0)},[b]),v=j.useCallback(()=>{b||C(!1),d==null||d()},[b,d]);j.useEffect(()=>{if(!_||!f)return;const E=N=>{if(N.key==="Escape"){const L=document.activeElement;if(L&&(L.tagName==="INPUT"||L.tagName==="TEXTAREA"))return;N.stopPropagation(),v()}};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[_,v,f]);const k=e&&(typeof e=="string"?s.jsx("button",{type:"button",onClick:S,className:u,children:e}):s.jsx("span",{onClick:S,className:u,style:{cursor:"pointer"},children:e}));return s.jsxs(s.Fragment,{children:[k,_&&(typeof document<"u"?wi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:m?v:void 0}),s.jsxs("div",{role:"dialog",className:`relative w-full ${oO[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(wb,{onClick:v,"aria-label":"Close"})]})]}),x?s.jsx(ft,{className:"p-4 flex-1 min-h-0",style:a?{minHeight:a}:void 0,children:o}):s.jsx("div",{className:"p-4 flex-1 min-h-0 overflow-hidden flex flex-col",style:a?{minHeight:a}:void 0,children:o}),c&&s.jsx("div",{className:"px-4 py-3 border-t border-border",children:c})]})]}),document.body):null)]})}function lO({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a,disabled:n,onChange:o=>{const c=o.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:m3.map(({url:o,label:c})=>s.jsx("option",{value:o,title:c,children:c.split(" ")[0]},o))}),s.jsx(yn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const S1=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function cO(){const e=Va(d=>d.settings),t=Va(d=>d.update),n=Va(d=>d.updateEvent),r=Va(d=>d.updateAgentOverride),a=Va(d=>d.load);j.useEffect(()=>{a()},[a]);const o=async()=>{await g3()==="granted"&&t({...e,browserNotificationEnabled:!0})},c=(d,h,m,f)=>{d==="general"?n(h,{[m]:f}):r(d,h,{[m]:f})},u=(d,h,m)=>{d==="general"?n(h,{customSoundUrl:m}):r(d,h,{customSoundUrl:m})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),s.jsx(w1,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),s.jsx(w1,{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"?o():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"}),S1.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:f3.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})}),S1.map(h=>{const m=hE(e,d.key,h.key==="general"?void 0:h.key),f=uE[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:m.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:m.browserNotification,onChange:g=>c(h.key,d.key,"browserNotification",g.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),m.soundEnabled&&e.soundEnabled&&s.jsx(lO,{value:m.customSoundUrl,defaultUrl:f,disabled:!e.soundEnabled,onChange:g=>u(h.key,d.key,g)})]})},h.key)})]},d.key))})]})})]})]})}function w1({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 st=j.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},o)=>{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:o,className:`${c} ${u[e]} ${d[t]} ${n}`,...a,children:r})});st.displayName="Button";async function C1(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 Ia(e,t){return t?`${e}?workdir=${encodeURIComponent(t)}`:e}const Vn=Jn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,workdir:null,setWorkdir:n=>{e({workdir:n})},fetchSkills:async n=>{const r=n??t().workdir;e({loading:!0});try{const o=await(await xe(Ia("/api/skills",r))).json();e({defaults:o.defaults??[],userItems:o.userItems??[],projectItems:o.projectItems??[],items:o.items??[],selectedDirectory:o.selectedDirectory??null,diagnostics:o.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await xe(Ia(`/api/skills/${n}/toggle`,t().workdir),{method:"POST"})).json();e(o=>({defaults:o.defaults.map(c=>c.id===n?{...c,enabled:a.enabled}:c),userItems:o.userItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c),projectItems:o.projectItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c),items:o.items.map(c=>c.id===n?{...c,enabled:a.enabled}:c)}))}catch{}},fetchSkill:async n=>{try{const r=await xe(Ia(`/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 da("POST",Ia("/api/skills",t().workdir),{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await da("PUT",Ia(`/api/skills/${n}`,t().workdir),r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await xe(Ia(`/api/skills/${n}`,t().workdir),{method:"DELETE"}),a=await r.json();return r.ok?(e(o=>({userItems:o.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)=>Pf(Ia(`/api/skills/${n}/duplicate`,t().workdir),()=>t().fetchSkills(),r),selectDirectory:async n=>C1("/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 C1("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function Nu(){const[e,t]=j.useState({id:null,type:null}),n=j.useCallback(o=>t({id:o,type:"delete"}),[]),r=j.useCallback(()=>t({id:null,type:null}),[]),a=j.useCallback((o,c)=>e.id===o&&e.type===c,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function Yh({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 Xh({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(Si,{})})}function gu({onClick:e}){return s.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:s.jsx(jl,{})})}function ns({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:o,mono:c}){return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,o&&s.jsx("span",{className:"text-text-muted ml-1",children:o})]}),s.jsx("input",{value:t,onChange:u=>n(u.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${c?"font-mono":""} ${a?"opacity-60":""}`})]})}function wE({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(st,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(st,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function vl({message:e}){return s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function Gf({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 CE({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(st,{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 kE({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 jE({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(st,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function Cb({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 EE({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:o="my-item",nameHint:c,readOnlyId:u=!1,readOnlyHint:d="(read-only)",onNameChange:h,onIdChange:m}){return s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(ns,{label:n,value:e,onChange:h,placeholder:a,hint:c}),s.jsx(ns,{label:r,value:t,onChange:m,readOnly:u,placeholder:o,hint:u?d:void 0,mono:!0})]})}function NE(e={}){const{initialData:t={}}=e,[n,r]=j.useState("list"),[a,o]=j.useState(null),[c,u]=j.useState(""),[d,h]=j.useState(!1),[m,f]=j.useState(t),g=j.useCallback(()=>{f(t),u(""),o(null)},[t]),x=j.useCallback(_=>{r(_),_==="list"&&g()},[g]),w=j.useCallback(_=>{f(S=>typeof _=="function"?_(S):_)},[]),C=j.useCallback((_,S={})=>{o(_),r("edit"),f({...S}),u("")},[]),b=j.useCallback(()=>{o(null),r("edit"),f(t),u("")},[t]);return{view:n,editingId:a,formError:c,saving:d,formData:m,setView:x,setEditingId:o,setFormError:u,setFormData:w,setSaving:h,resetForm:g,startEditing:C,startNew:b}}function El({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:o="Confirm",confirmVariant:c="primary",disabled:u=!1}){return s.jsx(jt,{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(st,{variant:"secondary",onClick:t,disabled:u,children:"Cancel"}),s.jsx(st,{variant:c,onClick:n,disabled:u,autoFocus:!0,children:o})]})]})})}const uO={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function fa({size:e="md",className:t=""}){return s.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${uO[e]} ${t}`})}function dO({text:e,...t}){return s.jsxs("div",{className:"text-center",children:[s.jsx(fa,{...t,className:"mx-auto mb-4"}),e&&s.jsx("div",{className:"text-text-secondary",children:e})]})}function Tu(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function hO(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 TE(e,t=28){if(e.length<=t)return e;const n=e.includes("\\")?"\\":"/",r=e.split(/[\\/]/).filter(Boolean);if(r.length<=2)return e;const a=r[0],o=r[r.length-1],c=r.slice(1,-1).join(n),u=t-a.length-o.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}${o}`}function Vt(){return typeof window>"u"||typeof window.matchMedia!="function"?!0:!window.matchMedia("(hover: none) and (pointer: coarse)").matches}const Ms=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}));Ms.displayName="Input";function qf({onSelect:e,onClose:t,initialPath:n}){const[r,a]=j.useState(null),[o,c]=j.useState(!0),[u,d]=j.useState(""),[h,m]=j.useState(-1),f=j.useRef(null),g=j.useRef(null),x=j.useCallback(async v=>{c(!0),d(""),m(-1);try{const k=v?`/api/directories?path=${encodeURIComponent(v)}`:"/api/directories",N=await(await xe(k)).json();a(N)}catch(k){console.error("Failed to load directories:",k)}finally{c(!1)}},[]);j.useEffect(()=>{x(n)},[n,x]);const w=hO((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(v=>u===""||v.name.toLowerCase().includes(u.toLowerCase())))??[],b=[...!u&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(v=>({type:"dir",path:v.path,name:v.name}))];j.useEffect(()=>{m(u?0:-1)},[u,C.length]),j.useEffect(()=>{if(h>=0&&g.current){const v=g.current.querySelector(`[data-index="${h}"]`);v==null||v.scrollIntoView({block:"nearest"})}},[h]);const _=v=>{var k;if(v.key==="ArrowDown")v.preventDefault(),m(E=>Math.min(E+1,b.length-1));else if(v.key==="ArrowUp")v.preventDefault(),m(E=>Math.max(E-1,0));else if(v.key==="Enter"){if(h<0||!b[h]||v.target instanceof HTMLElement&&v.target.dataset.select==="true")return;v.preventDefault(),v.shiftKey?x(b[h].path):e(b[h].path)}else v.key==="Escape"&&(d(""),Vt()&&((k=f.current)==null||k.focus()))},S=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(jt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:S,scrollable:!1,children:s.jsxs("div",{ref:g,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:_,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((v,k)=>s.jsxs("span",{className:"flex items-center shrink-0",children:[s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx("button",{onClick:()=>x(v.path),className:`px-1 ${k===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:v.name})]},v.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(_i,{})}),s.jsx(Ms,{autoFocus:Vt(),ref:f,value:u,onChange:v=>d(v.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),s.jsx(ft,{className:"flex-1",children:o?s.jsx("div",{className:"p-8 text-center",children:s.jsx(fa,{size:"sm"})}):b.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:b.map((v,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(v.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[v.type==="parent"?s.jsx(F3,{className:"w-5 h-5 text-text-muted shrink-0"}):s.jsx(ss,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"truncate",children:v.name}),v.type==="dir"&&s.jsx(yn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${k===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),v.type==="dir"&&s.jsx("button",{"data-select":"true",tabIndex:k===h?0:-1,onClick:E=>{E.stopPropagation(),e(v.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 ${v.name}`,children:"Select"})]},v.path))})})]})})}function AE(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 fO(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 AE(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function mO(e){return new Promise((t,n)=>e.file(t,n))}async function LE(e,t=""){const n=e.createReader(),r=[];for(;;){const o=await new Promise((c,u)=>n.readEntries(c,u));if(!o.length)break;r.push(...o)}return(await Promise.all(r.map(async o=>{const c=t?`${t}/${o.name}`:o.name;return o.isDirectory?LE(o,c):[{path:c,file:await mO(o)}]}))).flat()}async function pO(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 AE(n.name,await LE(n))}function gO({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,m]=j.useState(""),[f,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 b=k=>{g(k)},_=async()=>{if(!f||x)return;w(!0);const k=await t(f);if(k&&!k.success){m(k.error??"Cannot use selected folder."),w(!1);return}g(null),c(!1),w(!1)},S=async k=>{d(!0),m("");const E=await a(k);d(!1),E.success||m(E.error??"Failed to install skill package.")},v=async k=>{if(k.preventDefault(),!(!(e!=null&&e.available)||u))try{await S(await pO(k.dataTransfer))}catch(E){m(E instanceof Error?E.message:"Invalid skill folder.")}};return s.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),s.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(st,{variant:"secondary",onClick:()=>c(!0),children:"Change folder"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(st,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&s.jsx(st,{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:v,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 E;if((E=k.target.files)!=null&&E.length)try{S(fO(k.target.files))}catch(N){m(N instanceof Error?N.message:"Invalid skill folder.")}finally{k.target.value=""}}}),h&&s.jsx("p",{className:"mt-2 text-xs text-error",children:h}),o&&s.jsx(qf,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:b,onClose:()=>c(!1)}),s.jsx(El,{isOpen:f!==null,onClose:()=>g(null),onConfirm:_,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 xs({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 RE({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:o,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(vi,{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(xb,{})}),s.jsx(gu,{onClick:a}),!e&&r&&s.jsx(vi,{onClick:r}),!e&&o&&(t?s.jsx(Yh,{onConfirm:()=>{o==null||o()},onCancel:()=>c==null?void 0:c()}):s.jsx(Xh,{onClick:()=>o==null?void 0:o()})),u]})]})}function xO({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:m}){return s.jsxs(RE,{isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:m,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&s.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function k1({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:c,onToggle:u,readOnly:d=!1}){return s.jsx(xO,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:d?void 0:a,onDuplicate:o,onDelete:d?void 0:c,actions:s.jsx(xs,{enabled:e.enabled,onClick:u,label:`Activation for ${e.name}`})})}function yO({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return s.jsxs(jt,{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(st,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),s.jsx(st,{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 bO({isOpen:e}){const t=Vn(re=>re.defaults),n=Vn(re=>re.userItems),r=Vn(re=>re.projectItems),a=Vn(re=>re.items),o=Vn(re=>re.selectedDirectory),c=Vn(re=>re.diagnostics),u=Vn(re=>re.loading),d=Vn(re=>re.fetchSkills),h=Vn(re=>re.setWorkdir),m=Vn(re=>re.fetchSkill),f=Vn(re=>re.fetchDefaultContent),g=Vn(re=>re.createSkill),x=Vn(re=>re.updateSkill),w=Vn(re=>re.deleteSkill),C=Vn(re=>re.selectDirectory),b=Vn(re=>re.removeDirectory),_=Vn(re=>re.installSkill),S=Vn(re=>re.toggleSkill),v=De(re=>re.currentSession),[k,E]=j.useState(null),[N,L]=j.useState(!1),[A,O]=j.useState(""),{view:I,editingId:F,formError:B,saving:z,formData:Y,setView:q,setEditingId:W,setFormError:ee,setFormData:J,setSaving:H}=NE(),{clearConfirm:P}=Nu();j.useEffect(()=>{if(e){const re=(v==null?void 0:v.workdir)??null;h(re),d(re),q("list"),W(null),P()}},[e,d,h,P,v==null?void 0:v.workdir]);const D=(re,ie,ge,ke)=>{J({name:ke??re.metadata.name,id:ge??re.metadata.id,description:re.metadata.description??"",version:re.metadata.version??"1.0.0",prompt:re.prompt,isReadOnly:ie,destination:"user"})},U=async re=>{if(t.some(ge=>ge.id===re)){const ge=await f(re);if(!ge)return;D(ge,!0),W(re),ee(""),q("edit")}else{const ge=await m(re);if(!ge)return;D(ge,!0),W(re),ee(""),q("edit")}},$=async re=>{const ge=t.some(Oe=>Oe.id===re)?await f(re):await m(re);if(!ge)return;const ke=`${re}-copy-${Date.now()}`;D(ge,!1,ke,`${ge.metadata.name} (copy)`),W(null),ee(""),q("edit")},Q=()=>{J({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),q("edit")},K=async re=>{const ie=await m(re);ie&&(D(ie,!1),W(re),ee(""),q("edit"))},Z=async()=>{if(!k)return;L(!0),O("");const re=await w(k.id);if(L(!1),!re.success){O(re.error??"Failed to delete skill.");return}await d(),E(null),P()},V=async()=>{const re=F??Y.id;if(!re||!Y.name||!Y.prompt){ee("Name, ID, and prompt are required.");return}H(!0),ee("");const ie={metadata:{id:re,name:Y.name,description:Y.description,version:Y.version},prompt:Y.prompt},ge=F?await x(F,ie):await g(ie,Y.destination);if(H(!1),!ge.success){ee(ge.error??"Failed to save skill.");return}q("list")},M=re=>{J(ie=>({...ie,name:re})),F||J(ie=>({...ie,id:re.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},X=Y.isReadOnly;if(I==="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:X?Y.name:F?"Edit Skill":"New Skill"}),s.jsx("button",{onClick:()=>q("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),B&&s.jsx(vl,{message:B}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(EE,{name:Y.name,id:Y.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(ns,{label:"Description",value:Y.description,onChange:re=>J(ie=>({...ie,description:re})),placeholder:"What this skill does...",readOnly:X}),s.jsx(ns,{label:"Version",value:Y.version,onChange:re=>J(ie=>({...ie,version:re})),placeholder:"1.0.0",readOnly:X})]})]}),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:Y.prompt,onChange:re=>J(ie=>({...ie,prompt:re.target.value})),readOnly:X,placeholder:"The system prompt for this skill...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!F&&s.jsx(Gf,{value:Y.destination,onChange:re=>J(ie=>({...ie,destination:re}))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[s.jsx(st,{variant:"secondary",onClick:()=>q("list"),children:"Cancel"}),X?s.jsx(st,{variant:"primary",onClick:()=>{J(re=>({...re,name:re.name+" (copy)",id:`${F}-copy-${Date.now()}`,isReadOnly:!1})),W(null)},children:"Duplicate & Customize"}):s.jsx(st,{variant:"primary",onClick:V,disabled:z||!Y.name||!Y.id||!Y.prompt,children:z?"Saving...":"Save"})]})]});function ne({items:re}){return re.map(ie=>s.jsx(k1,{skill:ie,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>U(ie.id),onEdit:()=>K(ie.id),onDuplicate:()=>$(ie.id),onDelete:()=>{O(""),E(ie)},onToggle:()=>S(ie.id),readOnly:ie.readOnly},ie.id))}return s.jsxs("div",{children:[s.jsx(yO,{skill:k,deleting:N,error:A,onClose:()=>{N||E(null)},onConfirm:Z}),s.jsx(gO,{selectedDirectory:o,onSelect:C,onRemove:b,onRefresh:d,onInstall:_}),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,ie)=>s.jsx("p",{children:re},`${re}-${ie}`))}),s.jsx(jE,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:Q}),s.jsxs(Cb,{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(k1,{skill:re,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>U(re.id),onDuplicate:()=>$(re.id),onToggle:()=>S(re.id)},re.id))})]}),n.length>0&&s.jsx(kE,{children:s.jsx(ne,{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(ne,{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(ne,{items:r})})]})]})]})}function ma(){const e=It(a=>a.settings),t=It(a=>a.loading),n=It(a=>a.getSetting),r=It(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function vO({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=ma(),o=t[Ne.GLOBAL_INSTRUCTIONS]??"",c=n[Ne.GLOBAL_INSTRUCTIONS]??!1,[u,d]=j.useState(o),[h,m]=j.useState(!1),[f,g]=j.useState(!1);j.useEffect(()=>{e&&r(Ne.GLOBAL_INSTRUCTIONS)},[e,r]),j.useEffect(()=>{d(o),m(!1)},[o]);const x=async()=>{g(!0),await a(Ne.GLOBAL_INSTRUCTIONS,u),g(!1),m(!1)},w=()=>{d(o),m(!1)},C=c||f;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),s.jsx("textarea",{value:u,onChange:b=>{d(b.target.value),m(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(st,{variant:"secondary",onClick:w,disabled:!h,children:"Discard"}),s.jsx(st,{variant:"primary",onClick:x,disabled:!h||C,children:f?"Saving...":"Save"})]})]})}function _O(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 Ih(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 SO({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:o,onClose:c,onSave:u}){const[d,h]=j.useState(o),[m,f]=j.useState(r),[g,x]=j.useState(a);j.useEffect(()=>{h(o),f(r)},[o,r]);const w=(v,k)=>{const E=k.startsWith("#")?_O(k):k;h(N=>({...N,[v]:E}))},C=()=>{u(m.trim()||"Untitled",{...d},g)},b=pE.reduce((v,k)=>{const E=k.category;return v[E]||(v[E]=[]),v[E].push(k),v},{}),_={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},S=ur.find(v=>v.id===n);return s.jsx(jt,{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:m,onChange:v=>f(v.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),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:S==null?void 0:S.name})]}),Object.entries(b).map(([v,k])=>s.jsxs("div",{className:"space-y-3",children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:_[v]??v}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:k.map(E=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("label",{htmlFor:E.key,className:"text-xs text-text-muted",children:E.label}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"color",id:E.key,value:Ih(d[E.key]??E.defaultValue),onChange:N=>w(E.key,N.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),s.jsx("input",{type:"text",value:d[E.key]??E.defaultValue,onChange:N=>w(E.key,N.target.value),className:"flex-1 min-w-0 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},E.key))})]},v))]})})}function j1({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:o,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":Ih(e.tokens["color-bg-primary"]??"#000"),borderColor:Ih(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:Ih(e.tokens["color-text-primary"]??"#fff")}})}),s.jsx("span",{className:"text-xs",children:e.name})]}),a&&s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),a()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:s.jsx("span",{className:"text-xs",children:"✎"})}),o&&s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),o()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:s.jsx("span",{className:"text-xs",children:"✎"})}),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(Ss,{className:"w-3 h-3"})})]})}function wO(){const[e,t]=j.useState(null),n=Xt(B=>B.currentPreset),r=Xt(B=>B.isCustom),a=Xt(B=>B.basePreset),o=Xt(B=>B.isSystem),c=Xt(B=>B.systemDarkPreset),u=Xt(B=>B.systemLightPreset),d=Xt(B=>B.applyPreset),h=Xt(B=>B.applyUserPreset),m=Xt(B=>B.deleteUserPreset),f=Xt(B=>B.saveTheme),g=Xt(B=>B.setSystemDarkPreset),x=Xt(B=>B.setSystemLightPreset),w=Xt(B=>B.activeUserPresetId),C=Xt(B=>B.userPresets),b=ur.filter(B=>B.mode==="dark"),_=ur.filter(B=>B.mode==="light"),S=B=>{var z;if(o){const Y=C[B];if(!Y)return;const q=Y.mode??((z=ur.find(W=>W.id===Y.basePreset))==null?void 0:z.mode);q==="dark"?g(Y.id):q==="light"&&x(Y.id)}else h(B)},v=B=>{const z=ur.find(Y=>Y.id===B);z&&t({type:"new",presetIndex:C.length,basePresetId:B,presetName:z.name+" Copy",mode:z.mode??"dark",tokens:{...z.tokens}})},k=B=>{const z=C[B];if(!z)return;const Y=ur.find(W=>W.id===z.basePreset),q=Y?{...Y.tokens,...z.tokens}:z.tokens;t({type:"edit",presetIndex:B,basePresetId:z.basePreset,presetName:z.name,mode:z.mode??"dark",tokens:q})},E=(B,z,Y)=>{if(!e)return;const q=[...C];if(e.type==="new"){const W={id:"custom-"+Date.now(),name:B,basePreset:e.basePresetId,mode:Y,tokens:z};q.push(W);const ee=q.length-1;Xt.setState({userPresets:q}),Xt.getState().saveUserPresets(),Xt.getState().applyUserPreset(ee)}else{const W=q[e.presetIndex];W&&(q[e.presetIndex]={...W,name:B,mode:Y,tokens:z}),Xt.setState({userPresets:q}),Xt.getState().saveUserPresets(),Xt.getState().applyUserPreset(e.presetIndex)}t(null)},N=()=>{t(null)},L=(B,z)=>{B.stopPropagation(),m(z)},A=o?"system":r?a:n,O=()=>{o?(d(n),f(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),f(JSON.stringify({preset:"system"})).catch(()=>{}))},I=B=>{if(o){const z=ur.find(Y=>Y.id===B);(z==null?void 0:z.mode)==="dark"?g(B):(z==null?void 0:z.mode)==="light"&&x(B)}else d(B),f(JSON.stringify({preset:B})).catch(()=>{})},F=B=>{const z=ur.find(Y=>Y.id===B.basePreset);return z?{...z.tokens,...B.tokens}:B.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 ${o?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${o?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:B,mode:z})=>{const Y=z==="dark"?b:_,q=C.filter(W=>{var J;return(W.mode??((J=ur.find(H=>H.id===W.basePreset))==null?void 0:J.mode))===z});return s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:B}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[Y.map(W=>s.jsx(j1,{preset:W,isActive:W.id===A&&!r,isUnderlying:o&&(W.id===c||W.id===u),onClick:()=>I(W.id),onNewFrom:()=>v(W.id)},W.id)),q.map(W=>{const ee=C.indexOf(W),J=F(W);return s.jsx(j1,{preset:{id:W.id,name:W.name,tokens:J},isActive:w===W.id,isUnderlying:o&&(W.id===c||W.id===u),onClick:()=>S(ee),onEdit:()=>k(ee),onDelete:H=>L(H,ee)},W.id)})]})]},B)}),e&&s.jsx(SO,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,mode:e.mode,initialTokens:e.tokens,onClose:N,onSave:E})]})}const CO=["monospace","serif","sans-serif"],DE=["JetBrains Mono","Cascadia Mono","Menlo","Consolas","DejaVu Sans Mono","Liberation Mono"],Mh=`${DE.map(e=>`"${e}"`).join(", ")}, monospace`,kO=["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"],jO="mmmmmmmmmmlliWWWW@0Oo",EO="72px";let Pc;function NO(){if(Pc!==void 0)return Pc;try{Pc=document.createElement("canvas").getContext("2d")}catch{Pc=null}return Pc}function kb(e){const t=NO();if(!t)throw new Error("Canvas 2D context unavailable");return t.font=`${EO} ${e}`,t.measureText(jO).width}function OE(e,t=kb){const n=e.trim();if(!n)return!1;try{return CO.some(r=>{const a=t(r);return t(`"${n}", ${r}`)!==a})}catch{return!1}}function TO(e=kO,t=kb){const n=new Set;for(const r of e)OE(r,t)&&n.add(r);return[...n].sort((r,a)=>r.localeCompare(a))}function AO(e=DE,t=kb){return e.find(n=>OE(n,t))??""}function LO(e){const t=e.trim();return t?`"${t}", monospace`:""}function RO(e){var n;return(((n=e.split(",")[0])==null?void 0:n.trim())??"").replace(/^['"]|['"]$/g,"")}function DO(){return s.jsx(wO,{})}function OO(){const{settings:e,loading:t,getSetting:n,setSetting:r}=ma(),a=t[Ne.DISPLAY_SHOW_THINKING]??!1,o=e[Ne.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[c,u]=j.useState(o);j.useEffect(()=>{n(Ne.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),j.useEffect(()=>{u(o)},[o]);const d=()=>{const S=parseInt(c,10),v=isNaN(S)||S<0?0:Math.min(S,9999);u(String(v)),r(Ne.DISPLAY_MAX_VISIBLE_ITEMS,String(v))},h=[{key:Ne.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Ne.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Ne.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Ne.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Ne.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],m=[{key:Ne.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:Ne.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:Ne.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:Ne.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:Ne.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:Ne.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews",defaultValue:"true"}],f=[...h,...m],g=Object.fromEntries(h.map(S=>[S.key,e[S.key]??"true"])),x=Object.fromEntries(m.map(S=>[S.key,e[S.key]??S.defaultValue])),w={...g,...x},[C,b]=j.useState(()=>Object.fromEntries(f.map(S=>[S.key,w[S.key]==="true"])));j.useEffect(()=>{f.forEach(S=>n(S.key))},[n]),j.useEffect(()=>{b(Object.fromEntries(f.map(S=>[S.key,w[S.key]==="true"])))},[JSON.stringify(w)]);const _=async S=>{const v=String(!C[S]);b(k=>({...k,[S]:!k[S]})),await r(S,v)};return a?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(DO,{}),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(PO,{})]}),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(E1,{toggles:h,local:C,onToggle:_})]}),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(E1,{toggles:m,local:C,onToggle:_}),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:S=>{const v=S.target.value.replace(/[^0-9]/g,"");u(v)},onBlur:d,onKeyDown:S=>{S.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(MO,{})]})]})}const IO="~/project  git status ✓ ✗ → 0123 iIlL1 |─┤";function E1({toggles:e,local:t,onToggle:n}){return s.jsx("div",{className:"space-y-4",children:e.map(({key:r,label:a,description:o})=>s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:a}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:o})]}),s.jsx("button",{type:"button",onClick:()=>n(r),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${t[r]?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t[r]?"translate-x-6":"translate-x-1"}`})})]},r))})}function MO(){const{settings:e,getSetting:t,setSetting:n}=ma(),r=e[Ne.DISPLAY_TERMINAL_FONT]??Mh,[a,o]=j.useState(r),c=j.useMemo(()=>TO(),[]),u=j.useMemo(()=>AO(),[]);j.useEffect(()=>{t(Ne.DISPLAY_TERMINAL_FONT)},[t]),j.useEffect(()=>{o(r)},[r]);const h=r===Mh?u:RO(r),m=h!==""&&!c.includes(h),f=x=>{const w=x.target.value;w&&n(Ne.DISPLAY_TERMINAL_FONT,LO(w))},g=()=>{n(Ne.DISPLAY_TERMINAL_FONT,a.trim()||Mh)};return s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Only monospace fonts detected on this machine are listed. If your shell theme uses icons or powerline glyphs, pick a Nerd Font."}),s.jsxs("select",{value:m?"":h,onChange:f,className:"w-full px-2 py-1.5 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",children:[m&&s.jsx("option",{value:"",children:`Custom: ${h}`}),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(ft,{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:IO}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-text-muted mb-1",children:'Not listed? Enter a CSS font-family manually (e.g. "My Font", monospace)'}),s.jsx("input",{type:"text",value:a,onChange:x=>o(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&g()},className:"w-full px-2 py-1 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})]})]})}function PO(){const{settings:e,getSetting:t,setSetting:n}=ma(),r=e[Ne.DISPLAY_CUSTOM_CSS]??"",[a,o]=j.useState(r);j.useEffect(()=>{t(Ne.DISPLAY_CUSTOM_CSS)},[t]),j.useEffect(()=>{o(r)},[r]);const c=()=>{n(Ne.DISPLAY_CUSTOM_CSS,a)};return s.jsx("div",{className:"space-y-2",children:s.jsx("textarea",{value:a,onChange:u=>o(u.target.value),onBlur: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 ly(){const[e,t]=j.useState("Test"),[n,r]=j.useState(""),[a,o]=j.useState(!1),c=j.useCallback(async u=>{t("Testing..."),r(""),o(!1);try{const d=await u();d.success?(t("Success"),o(!0),setTimeout(()=>{t("Test"),o(!1)},3e3)):(r(d.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,a,c]}function BO(e){try{return new RegExp(e),!0}catch{return!1}}function $O({value:e,onChange:t}){const[n,r]=j.useState({}),a=(d,h)=>{const m=e.patterns.map((f,g)=>g===d?{...f,...h}:f);t({...e,patterns:m})},o=d=>{const h=e.patterns.filter((m,f)=>f!==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(m=>({...m,[d]:h.length>0&&!BO(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),m=isNaN(h)?10:Math.max(1,Math.min(100,h));t({...e,maxRetriesPerTurn:m})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?s.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[s.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),s.jsx("th",{className:"pb-2 pr-2",children:"Field"}),s.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),s.jsx("th",{className:"pb-2 pr-2",children:"Action"}),s.jsx("th",{className:"pb-2 w-8"})]})}),s.jsx("tbody",{children:e.patterns.map((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:m=>a(h,{field:m.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[s.jsx("option",{value:"content",children:"content"}),s.jsx("option",{value:"thinking",children:"thinking"}),s.jsx("option",{value:"both",children:"both"})]})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"text",value:d.pattern,onChange:m=>u(h,m.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),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:()=>o(h),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},h))})]}),s.jsx(st,{variant:"secondary",onClick:c,children:"Add Pattern"})]})}const IE="openfox_last_version",ME="openfox_previous_version";function jb(){return localStorage.getItem(IE)}function FO(){return localStorage.getItem(ME)}function PE(e){e&&localStorage.setItem(ME,e)}function zO(e){if(!e)return;const t=jb();t&&t!==e&&PE(t),localStorage.setItem(IE,e)}function HO(e,t){if(!e||!t)return!1;const n=e.split(".").map(Number),r=t.split(".").map(Number);if(n.length!==3||r.length!==3||n.some(a=>!Number.isInteger(a))||r.some(a=>!Number.isInteger(a)))return!1;for(let a=0;a<3;a++){const o=n[a],c=r[a];if(o!==c)return o>c}return!1}const N1=1e3,UO=3e4;function T1({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 BE({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=j.useState("ready"),[o,c]=j.useState(""),[u,d]=j.useState(n),[h,m]=j.useState(null),[f,g]=j.useState(null),[x,w]=j.useState(!1),[C,b]=j.useState(!1),[_,S]=j.useState(!1),v=j.useRef(!1),k=j.useRef(null),E=j.useRef(null),N=j.useRef(!0),L=j.useRef(n);L.current=n,j.useEffect(()=>{if(!e)return;let J=!1;return(async()=>{try{const P=await(await fetch(vs("/api/auto-update/check"))).json();if(J)return;b(!!P.isService),!L.current&&P.current&&P.latest&&d({current:P.current,latest:P.latest})}catch{J||b(!1)}})(),()=>{J=!0}},[e]),j.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const J=setInterval(()=>{c(H=>H.length>=3?"":H+".")},400);return()=>clearInterval(J)},[e,r]);const A=j.useCallback(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null),E.current=null},[]),O=j.useCallback(J=>{g(J),a("restartFailed")},[]),I=j.useCallback(J=>{v.current=J,S(J)},[]),F=j.useCallback(J=>{var P;const H=jb()??((P=L.current)==null?void 0:P.current)??null;H&&H!==J&&PE(H),localStorage.setItem("openfox_updated_to",J),localStorage.setItem("update_pending","true")},[]),B=j.useCallback(async J=>{a("restarting"),g(null),A();try{await xe("/api/auto-update/restart",{method:"POST"})}catch{}if(!N.current)return;E.current=Date.now();const H=async()=>{if(!N.current){A();return}const P=E.current;if(P!==null&&Date.now()-P>=UO){A(),O("OpenFox could not be reached after restart within 30 seconds. Please restart OpenFox manually.");return}try{const D=await fetch(vs("/api/auto-update/check?force=true"));if(!D.ok)throw new Error(`HTTP ${D.status}`);if((await D.json()).current===J){A(),F(J),window.location.reload();return}}catch{}if(!N.current){A();return}k.current=setTimeout(()=>{H()},N1)};k.current=setTimeout(()=>{H()},N1)},[A,O,F]),z=j.useCallback(async()=>{a("updating"),g(null);try{const H=await(await xe("/api/auto-update",{method:"POST"})).json();if(H.success){const P=H.version??"unknown";m(P),w(!!H.isService),v.current&&H.isService?B(P):a("complete")}else g(H.error??"Update failed"),a("failed")}catch(J){g(J instanceof Error?J.message:"Update request failed"),a("failed")}},[B]),Y=j.useCallback(()=>{const J=h??(u==null?void 0:u.latest)??null;if(!J){O("Installed version unknown; cannot verify restart.");return}B(J)},[h,u,O,B]);j.useEffect(()=>(N.current=!0,()=>{N.current=!1,A()}),[A]),j.useEffect(()=>{e&&(c(""),A(),a("ready"),m(null),g(null),w(!1),b(!1),I(!1))},[e,A,I]);const q=r!=="updating"&&r!=="restarting",W=J=>J,ee=r==="failed"?"Update Failed":r==="restarting"?"Restarting…":r==="complete"?"Update Complete":r==="restartFailed"?"Restart Not Confirmed":"New OpenFox version available";return s.jsxs(jt,{isOpen:e,onClose:q?t:void 0,title:ee,size:"md",closeOnBackdropClick:q,showCloseButton:q,children:[s.jsxs("div",{className:"flex flex-col gap-4",children:[u&&s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-text-muted",children:"Current version"}),s.jsx("span",{className:"text-text-primary font-mono",children:W(u.current)})]}),u&&s.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[s.jsx("span",{className:"text-text-muted",children:"Latest version"}),s.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:u.latest})]}),(r==="updating"||r==="restarting")&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),s.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",o]})]}),r==="complete"&&s.jsx("div",{className:"flex flex-col gap-3 mt-2",children:s.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h??(u==null?void 0:u.latest),".",x?' Click "Restart OpenFox now" to apply the update.':" Please restart OpenFox to use the new version."]})}),r==="failed"&&s.jsx(T1,{message:f,command:"openfox update",hint:"Run this command in your terminal to complete the update."}),r==="restartFailed"&&s.jsx(T1,{message:f,command:"openfox service restart",hint:"Run this command in your terminal to restart OpenFox."})]}),r==="ready"&&s.jsx("button",{onClick:z,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="ready"||r==="updating")&&C&&s.jsxs("label",{className:"flex items-center justify-center gap-2 text-xs text-text-muted cursor-pointer select-none mt-2",children:[s.jsx("input",{type:"checkbox",checked:_,onChange:J=>I(J.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:Y,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 hn({children:e,className:t="",horizontal:n=!1,style:r,scope:a="toolCalls"}){const{useNativeScrollbars:o,useNativeScrollbarsCodeBlocks:c}=Fs();if(a==="codeBlocks"?c:o){const d=n?"overflow-x-auto":"overflow-y-auto";return s.jsx("div",{className:`${d} ${t}`.trim(),style:r,children:e})}return s.jsx(ft,{horizontal:n,className:t,style:r,children:e})}function VO(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const WO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,qO={};function A1(e,t){return(qO.jsx?GO:WO).test(e)}const KO=/[ \t\n\f\r]/g;function YO(e){return typeof e=="object"?e.type==="text"?L1(e.value):!1:L1(e)}function L1(e){return e.replace(KO,"")===""}let Au=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Au.prototype.normal={};Au.prototype.property={};Au.prototype.space=void 0;function $E(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Au(n,r,t)}function cy(e){return e.toLowerCase()}let Cr=class{constructor(t,n){this.attribute=n,this.property=t}};Cr.prototype.attribute="";Cr.prototype.booleanish=!1;Cr.prototype.boolean=!1;Cr.prototype.commaOrSpaceSeparated=!1;Cr.prototype.commaSeparated=!1;Cr.prototype.defined=!1;Cr.prototype.mustUseProperty=!1;Cr.prototype.number=!1;Cr.prototype.overloadedBoolean=!1;Cr.prototype.property="";Cr.prototype.spaceSeparated=!1;Cr.prototype.space=void 0;let XO=0;const xt=co(),On=co(),uy=co(),Ge=co(),Zt=co(),to=co(),Dr=co();function co(){return 2**++XO}const dy=Object.freeze(Object.defineProperty({__proto__:null,boolean:xt,booleanish:On,commaOrSpaceSeparated:Dr,commaSeparated:to,number:Ge,overloadedBoolean:uy,spaceSeparated:Zt},Symbol.toStringTag,{value:"Module"})),Gg=Object.keys(dy);let Eb=class extends Cr{constructor(t,n,r,a){let o=-1;if(super(t,n),R1(this,"space",a),typeof r=="number")for(;++o<Gg.length;){const c=Gg[o];R1(this,Gg[o],(r&dy[c])===dy[c])}}};Eb.prototype.defined=!0;function R1(e,t,n){n&&(e[t]=n)}function Ml(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new Eb(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[cy(r)]=r,n[cy(o.attribute)]=r}return new Au(t,n,e.space)}const FE=Ml({properties:{ariaActiveDescendant:null,ariaAtomic:On,ariaAutoComplete:null,ariaBusy:On,ariaChecked:On,ariaColCount:Ge,ariaColIndex:Ge,ariaColSpan:Ge,ariaControls:Zt,ariaCurrent:null,ariaDescribedBy:Zt,ariaDetails:null,ariaDisabled:On,ariaDropEffect:Zt,ariaErrorMessage:null,ariaExpanded:On,ariaFlowTo:Zt,ariaGrabbed:On,ariaHasPopup:null,ariaHidden:On,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Zt,ariaLevel:Ge,ariaLive:null,ariaModal:On,ariaMultiLine:On,ariaMultiSelectable:On,ariaOrientation:null,ariaOwns:Zt,ariaPlaceholder:null,ariaPosInSet:Ge,ariaPressed:On,ariaReadOnly:On,ariaRelevant:null,ariaRequired:On,ariaRoleDescription:Zt,ariaRowCount:Ge,ariaRowIndex:Ge,ariaRowSpan:Ge,ariaSelected:On,ariaSetSize:Ge,ariaSort:null,ariaValueMax:Ge,ariaValueMin:Ge,ariaValueNow:Ge,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function zE(e,t){return t in e?e[t]:t}function HE(e,t){return zE(e,t.toLowerCase())}const QO=Ml({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:to,acceptCharset:Zt,accessKey:Zt,action:null,allow:null,allowFullScreen:xt,allowPaymentRequest:xt,allowUserMedia:xt,alpha:xt,alt:null,as:null,async:xt,autoCapitalize:null,autoComplete:Zt,autoFocus:xt,autoPlay:xt,blocking:Zt,capture:null,charSet:null,checked:xt,cite:null,className:Zt,closedBy:null,colorSpace:null,cols:Ge,colSpan:Ge,command:null,commandFor:null,content:null,contentEditable:On,controls:xt,controlsList:Zt,coords:Ge|to,crossOrigin:null,data:null,dateTime:null,decoding:null,default:xt,defer:xt,dir:null,dirName:null,disabled:xt,download:uy,draggable:On,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:xt,formTarget:null,headers:Zt,height:Ge,hidden:uy,high:Ge,href:null,hrefLang:null,htmlFor:Zt,httpEquiv:Zt,id:null,imageSizes:null,imageSrcSet:null,inert:xt,inputMode:null,integrity:null,is:null,isMap:xt,itemId:null,itemProp:Zt,itemRef:Zt,itemScope:xt,itemType:Zt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:xt,low:Ge,manifest:null,max:null,maxLength:Ge,media:null,method:null,min:null,minLength:Ge,multiple:xt,muted:xt,name:null,nonce:null,noModule:xt,noValidate:xt,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:xt,optimum:Ge,pattern:null,ping:Zt,placeholder:null,playsInline:xt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:xt,referrerPolicy:null,rel:Zt,required:xt,reversed:xt,rows:Ge,rowSpan:Ge,sandbox:Zt,scope:null,scoped:xt,seamless:xt,selected:xt,shadowRootClonable:xt,shadowRootCustomElementRegistry:xt,shadowRootDelegatesFocus:xt,shadowRootMode:null,shadowRootSerializable:xt,shape:null,size:Ge,sizes:null,slot:null,span:Ge,spellCheck:On,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ge,step:null,style:null,tabIndex:Ge,target:null,title:null,translate:null,type:null,typeMustMatch:xt,useMap:null,value:On,width:Ge,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Zt,axis:null,background:null,bgColor:null,border:Ge,borderColor:null,bottomMargin:Ge,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:xt,declare:xt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ge,leftMargin:Ge,link:null,longDesc:null,lowSrc:null,marginHeight:Ge,marginWidth:Ge,noResize:xt,noHref:xt,noShade:xt,noWrap:xt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ge,rules:null,scheme:null,scrolling:On,standby:null,summary:null,text:null,topMargin:Ge,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ge,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:xt,disablePictureInPicture:xt,disableRemotePlayback:xt,exportParts:to,part:Zt,prefix:null,property:null,results:Ge,security:null,unselectable:null},space:"html",transform:HE}),JO=Ml({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:Dr,accentHeight:Ge,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ge,amplitude:Ge,arabicForm:null,ascent:Ge,attributeName:null,attributeType:null,azimuth:Ge,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ge,by:null,calcMode:null,capHeight:Ge,className: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:Ge,diffuseConstant:Ge,direction:null,display:null,dur:null,divisor:Ge,dominantBaseline:null,download:xt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ge,enableBackground:null,end:null,event:null,exponent:Ge,externalResourcesRequired:null,fill:null,fillOpacity:Ge,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:to,g2:to,glyphName:to,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ge,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ge,horizOriginX:Ge,horizOriginY:Ge,id:null,ideographic:Ge,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ge,k:Ge,k1:Ge,k2:Ge,k3:Ge,k4:Ge,kernelMatrix:Dr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ge,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ge,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ge,overlineThickness:Ge,paintOrder:null,panose1:null,path:null,pathLength:Ge,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Zt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ge,pointsAtY:Ge,pointsAtZ:Ge,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Dr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Dr,rev:Dr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Dr,requiredFeatures:Dr,requiredFonts:Dr,requiredFormats:Dr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ge,specularExponent:Ge,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ge,strikethroughThickness:Ge,string:null,stroke:null,strokeDashArray:Dr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ge,strokeOpacity:Ge,strokeWidth:null,style:null,surfaceScale:Ge,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Dr,tabIndex:Ge,tableValues:null,target:null,targetX:Ge,targetY:Ge,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Dr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ge,underlineThickness:Ge,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ge,values:null,vAlphabetic:Ge,vMathematical:Ge,vectorEffect:null,vHanging:Ge,vIdeographic:Ge,version:null,vertAdvY:Ge,vertOriginX:Ge,vertOriginY:Ge,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ge,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:zE}),UE=Ml({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()}}),VE=Ml({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:HE}),WE=Ml({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),ZO={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"},eI=/[A-Z]/g,D1=/-[a-z]/g,tI=/^data[-\w.:]+$/i;function nI(e,t){const n=cy(t);let r=t,a=Cr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&tI.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(D1,sI);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!D1.test(o)){let c=o.replace(eI,rI);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Eb}return new a(r,t)}function rI(e){return"-"+e.toLowerCase()}function sI(e){return e.charAt(1).toUpperCase()}const iI=$E([FE,QO,UE,VE,WE],"html"),Nb=$E([FE,JO,UE,VE,WE],"svg");function aI(e){return e.join(" ").trim()}var Jo={},qg,O1;function oI(){if(O1)return qg;O1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
68
+ `,h="/",m="*",f="",g="comment",x="declaration";function w(b,_){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];_=_||{};var S=1,v=1;function k(Y){var q=Y.match(t);q&&(S+=q.length);var W=Y.lastIndexOf(d);v=~W?Y.length-W:v+Y.length}function E(){var Y={line:S,column:v};return function(q){return q.position=new N(Y),O(),q}}function N(Y){this.start=Y,this.end={line:S,column:v},this.source=_.source}N.prototype.content=b;function L(Y){var q=new Error(_.source+":"+S+":"+v+": "+Y);if(q.reason=Y,q.filename=_.source,q.line=S,q.column=v,q.source=b,!_.silent)throw q}function A(Y){var q=Y.exec(b);if(q){var W=q[0];return k(W),b=b.slice(W.length),q}}function O(){A(n)}function I(Y){var q;for(Y=Y||[];q=F();)q!==!1&&Y.push(q);return Y}function F(){var Y=E();if(!(h!=b.charAt(0)||m!=b.charAt(1))){for(var q=2;f!=b.charAt(q)&&(m!=b.charAt(q)||h!=b.charAt(q+1));)++q;if(q+=2,f===b.charAt(q-1))return L("End of comment missing");var W=b.slice(2,q-2);return v+=2,k(W),b=b.slice(q),v+=2,Y({type:g,comment:W})}}function B(){var Y=E(),q=A(r);if(q){if(F(),!A(a))return L("property missing ':'");var W=A(o),ee=Y({type:x,property:C(q[0].replace(e,f)),value:W?C(W[0].replace(e,f)):f});return A(c),ee}}function z(){var Y=[];I(Y);for(var q;q=B();)q!==!1&&(Y.push(q),I(Y));return Y}return O(),z()}function C(b){return b?b.replace(u,f):f}return qg=w,qg}var I1;function lI(){if(I1)return Jo;I1=1;var e=Jo&&Jo.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Jo,"__esModule",{value:!0}),Jo.default=n;const t=e(oI());function n(r,a){let o=null;if(!r||typeof r!="string")return o;const c=(0,t.default)(r),u=typeof a=="function";return c.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;u?a(h,m,d):m&&(o=o||{},o[h]=m)}),o}return Jo}var Bc={},M1;function cI(){if(M1)return Bc;M1=1,Object.defineProperty(Bc,"__esModule",{value:!0}),Bc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,m){return m.toUpperCase()},u=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),o(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(a,u):h=h.replace(r,u),h.replace(t,c))};return Bc.camelCase=d,Bc}var $c,P1;function uI(){if(P1)return $c;P1=1;var e=$c&&$c.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(lI()),n=cI();function r(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(u,d){u&&d&&(c[(0,n.camelCase)(u,o)]=d)}),c}return r.default=r,$c=r,$c}var dI=uI();const hI=kf(dI),GE=qE("end"),Tb=qE("start");function qE(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 fI(e){const t=Tb(e),n=GE(e);if(t&&n)return{start:t,end:n}}function eu(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?B1(e.position):"start"in e||"end"in e?B1(e):"line"in e||"column"in e?hy(e):""}function hy(e){return $1(e&&e.line)+":"+$1(e&&e.column)}function B1(e){return hy(e&&e.start)+"-"+hy(e&&e.end)}function $1(e){return e&&typeof e=="number"?e:1}class or extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?o.ruleId=r:(o.source=r.slice(0,d),o.ruleId=r.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=u?u.line:void 0,this.name=eu(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}or.prototype.file="";or.prototype.name="";or.prototype.reason="";or.prototype.message="";or.prototype.stack="";or.prototype.column=void 0;or.prototype.line=void 0;or.prototype.ancestors=void 0;or.prototype.cause=void 0;or.prototype.fatal=void 0;or.prototype.place=void 0;or.prototype.ruleId=void 0;or.prototype.source=void 0;const Ab={}.hasOwnProperty,mI=new Map,pI=/[A-Z]/g,gI=new Set(["table","tbody","thead","tfoot","tr"]),xI=new Set(["td","th"]),KE="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function yI(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=jI(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=kI(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"?Nb:iI,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=YE(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function YE(e,t,n){if(t.type==="element")return bI(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return vI(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return SI(e,t,n);if(t.type==="mdxjsEsm")return _I(e,t);if(t.type==="root")return wI(e,t,n);if(t.type==="text")return CI(e,t)}function bI(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=Nb,e.schema=a),e.ancestors.push(t);const o=QE(e,t.tagName,!1),c=EI(e,t);let u=Rb(e,t);return gI.has(t.tagName)&&(u=u.filter(function(d){return typeof d=="string"?!YO(d):!0})),XE(e,c,o,t),Lb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,o,c,n)}function vI(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)}xu(e,t.position)}function _I(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);xu(e,t.position)}function SI(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=Nb,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:QE(e,t.name,!0),c=NI(e,t),u=Rb(e,t);return XE(e,c,o,t),Lb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,o,c,n)}function wI(e,t,n){const r={};return Lb(r,Rb(e,t)),e.create(t,e.Fragment,r,n)}function CI(e,t){return t.value}function XE(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Lb(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function kI(e,t,n){return r;function r(a,o,c,u){const h=Array.isArray(c.children)?n:t;return u?h(o,c,u):h(o,c)}}function jI(e,t){return n;function n(r,a,o,c){const u=Array.isArray(o.children),d=Tb(r);return t(a,o,c,u,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function EI(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&Ab.call(t.properties,a)){const o=TI(e,a,t.properties[a]);if(o){const[c,u]=o;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&xI.has(t.tagName)?r=u:n[c]=u}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function NI(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const c=o.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else xu(e,t.position);else{const a=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const u=r.value.data.estree.body[0];u.type,o=e.evaluater.evaluateExpression(u.expression)}else xu(e,t.position);else o=r.value===null?!0:r.value;n[a]=o}return n}function Rb(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:mI;for(;++r<t.children.length;){const o=t.children[r];let c;if(e.passKeys){const d=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(d){const h=a.get(d)||0;c=d+"-"+h,a.set(d,h+1)}}const u=YE(e,o,c);u!==void 0&&n.push(u)}return n}function TI(e,t,n){const r=nI(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?VO(n):aI(n)),r.property==="style"){let a=typeof n=="object"?n:AI(e,String(n));return e.stylePropertyNameCase==="css"&&(a=LI(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?ZO[r.property]||r.property:r.attribute,n]}}function AI(e,t){try{return hI(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new or("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=KE+"#cannot-parse-style-attribute",a}}function QE(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,c;for(;++o<a.length;){const u=A1(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(o&&u.type==="Literal"),optional:!1}:u}r=c}else r=A1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return Ab.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);xu(e)}function xu(e,t){const n=new or("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=KE+"#cannot-handle-mdx-estrees-without-createevaluater",n}function LI(e){const t={};let n;for(n in e)Ab.call(e,n)&&(t[RI(n)]=e[n]);return t}function RI(e){let t=e.replace(pI,DI);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function DI(e){return"-"+e.toLowerCase()}const Kg={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"]},OI={};function Db(e,t){const n=OI,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return JE(e,r,a)}function JE(e,t,n){if(II(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 F1(e.children,t,n)}return Array.isArray(e)?F1(e,t,n):""}function F1(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=JE(e[a],t,n);return r.join("")}function II(e){return!!(e&&typeof e=="object")}const z1=document.createElement("i");function Ob(e){const t="&"+e+";";z1.innerHTML=t;const n=z1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Br(e,t,n,r){const a=e.length;let o=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);o<r.length;)c=r.slice(o,o+1e4),c.unshift(t,0),e.splice(...c),o+=1e4,t+=1e4}function Jr(e,t){return e.length>0?(Br(e,e.length,0,t),e):t}const H1={}.hasOwnProperty;function ZE(e){const t={};let n=-1;for(;++n<e.length;)MI(t,e[n]);return t}function MI(e,t){let n;for(n in t){const a=(H1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let c;if(o)for(c in o){H1.call(a,c)||(a[c]=[]);const u=o[c];PI(a[c],Array.isArray(u)?u:u?[u]:[])}}}function PI(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Br(e,0,0,r)}function e2(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 ys(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dr=pa(/[A-Za-z]/),ar=pa(/[\dA-Za-z]/),BI=pa(/[#-'*+\--9=?A-Z^-~]/);function Qh(e){return e!==null&&(e<32||e===127)}const fy=pa(/\d/),$I=pa(/[\dA-Fa-f]/),FI=pa(/[!-/:-@[-`{-~]/);function ut(e){return e!==null&&e<-2}function rn(e){return e!==null&&(e<0||e===32)}function Tt(e){return e===-2||e===-1||e===32}const Kf=pa(new RegExp("\\p{P}|\\p{S}","u")),io=pa(/\s/);function pa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Pl(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const o=e.charCodeAt(n);let c="";if(o===37&&ar(e.charCodeAt(n+1))&&ar(e.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(c=String.fromCharCode(o));else if(o>55295&&o<57344){const u=e.charCodeAt(n+1);o<56320&&u>56319&&u<57344?(c=String.fromCharCode(o,u),a=1):c="�"}else c=String.fromCharCode(o);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 Ot(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(d){return Tt(d)?(e.enter(n),u(d)):t(d)}function u(d){return Tt(d)&&o++<a?(e.consume(d),u):(e.exit(n),t(d))}}const zI={tokenize:HI};function HI(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"),Ot(e,t,"linePrefix")}function a(u){return e.enter("paragraph"),o(u)}function o(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 ut(u)?(e.consume(u),e.exit("chunkText"),o):(e.consume(u),c)}}const UI={tokenize:VI},U1={tokenize:WI};function VI(e){const t=this,n=[];let r=0,a,o,c;return u;function u(v){if(r<n.length){const k=n[r];return t.containerState=k[1],e.attempt(k[0].continuation,d,h)(v)}return h(v)}function d(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&S();const k=t.events.length;let E=k,N;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){N=t.events[E][1].end;break}_(r);let L=k;for(;L<t.events.length;)t.events[L][1].end={...N},L++;return Br(t.events,E+1,0,t.events.slice(k)),t.events.length=L,h(v)}return u(v)}function h(v){if(r===n.length){if(!a)return g(v);if(a.currentConstruct&&a.currentConstruct.concrete)return w(v);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(U1,m,f)(v)}function m(v){return a&&S(),_(r),g(v)}function f(v){return t.parser.lazy[t.now().line]=r!==n.length,c=t.now().offset,w(v)}function g(v){return t.containerState={},e.attempt(U1,x,w)(v)}function x(v){return r++,n.push([t.currentConstruct,t.containerState]),g(v)}function w(v){if(v===null){a&&S(),_(0),e.consume(v);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),C(v)}function C(v){if(v===null){b(e.exit("chunkFlow"),!0),_(0),e.consume(v);return}return ut(v)?(e.consume(v),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,u):(e.consume(v),C)}function b(v,k){const E=t.sliceStream(v);if(k&&E.push(null),v.previous=o,o&&(o.next=v),o=v,a.defineSkip(v.start),a.write(E),t.parser.lazy[v.start.line]){let N=a.events.length;for(;N--;)if(a.events[N][1].start.offset<c&&(!a.events[N][1].end||a.events[N][1].end.offset>c))return;const L=t.events.length;let A=L,O,I;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(O){I=t.events[A][1].end;break}O=!0}for(_(r),N=L;N<t.events.length;)t.events[N][1].end={...I},N++;Br(t.events,A+1,0,t.events.slice(L)),t.events.length=N}}function _(v){let k=n.length;for(;k-- >v;){const E=n[k];t.containerState=E[1],E[0].exit.call(t,e)}n.length=v}function S(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function WI(e,t,n){return Ot(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Nl(e){if(e===null||rn(e)||io(e))return 1;if(Kf(e))return 2}function Yf(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const my={name:"attention",resolveAll:GI,tokenize:qI};function GI(e,t){let n=-1,r,a,o,c,u,d,h,m;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;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 f={...e[r][1].end},g={...e[n][1].start};V1(f,-d),V1(g,d),c={type:d>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},u={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},o={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=Jr(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=Jr(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Jr(h,Yf(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=Jr(h,[["exit",o,t],["enter",u,t],["exit",u,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,h=Jr(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,Br(e,r-1,n-r+3,h),n=r+h.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function qI(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Nl(r);let o;return c;function c(d){return o=d,e.enter("attentionSequence"),u(d)}function u(d){if(d===o)return e.consume(d),u;const h=e.exit("attentionSequence"),m=Nl(d),f=!m||m===2&&a||n.includes(d),g=!a||a===2&&m||n.includes(r);return h._open=!!(o===42?f:f&&(a||!g)),h._close=!!(o===42?g:g&&(m||!f)),t(d)}}function V1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const KI={name:"autolink",tokenize:YI};function YI(e,t,n){let r=0;return a;function a(x){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(x){return dr(x)?(e.consume(x),c):x===64?n(x):h(x)}function c(x){return x===43||x===45||x===46||ar(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||ar(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||Qh(x)?n(x):(e.consume(x),d)}function h(x){return x===64?(e.consume(x),m):BI(x)?(e.consume(x),h):n(x)}function m(x){return ar(x)?f(x):n(x)}function f(x){return x===46?(e.consume(x),r=0,m):x===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):g(x)}function g(x){if((x===45||ar(x))&&r++<63){const w=x===45?g:f;return e.consume(x),w}return n(x)}}const Lu={partial:!0,tokenize:XI};function XI(e,t,n){return r;function r(o){return Tt(o)?Ot(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||ut(o)?t(o):n(o)}}const t2={continuation:{tokenize:JI},exit:ZI,name:"blockQuote",tokenize:QI};function QI(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"),o}return n(c)}function o(c){return Tt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function JI(e,t,n){const r=this;return a;function a(c){return Tt(c)?Ot(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(t2,t,n)(c)}}function ZI(e){e.exit("blockQuote")}const n2={name:"characterEscape",tokenize:eM};function eM(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return FI(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const r2={name:"characterReference",tokenize:tM};function tM(e,t,n){const r=this;let a=0,o,c;return u;function u(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),d}function d(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),o=31,c=ar,m(f))}function h(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=$I,m):(e.enter("characterReferenceValue"),o=7,c=fy,m(f))}function m(f){if(f===59&&a){const g=e.exit("characterReferenceValue");return c===ar&&!Ob(r.sliceSerialize(g))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(f)&&a++<o?(e.consume(f),m):n(f)}}const W1={partial:!0,tokenize:rM},G1={concrete:!0,name:"codeFenced",tokenize:nM};function nM(e,t,n){const r=this,a={partial:!0,tokenize:E};let o=0,c=0,u;return d;function d(N){return h(N)}function h(N){const L=r.events[r.events.length-1];return o=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,u=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(N)}function m(N){return N===u?(c++,e.consume(N),m):c<3?n(N):(e.exit("codeFencedFenceSequence"),Tt(N)?Ot(e,f,"whitespace")(N):f(N))}function f(N){return N===null||ut(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(W1,C,k)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(N))}function g(N){return N===null||ut(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(N)):Tt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ot(e,x,"whitespace")(N)):N===96&&N===u?n(N):(e.consume(N),g)}function x(N){return N===null||ut(N)?f(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(N))}function w(N){return N===null||ut(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(N)):N===96&&N===u?n(N):(e.consume(N),w)}function C(N){return e.attempt(a,k,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),_}function _(N){return o>0&&Tt(N)?Ot(e,S,"linePrefix",o+1)(N):S(N)}function S(N){return N===null||ut(N)?e.check(W1,C,k)(N):(e.enter("codeFlowValue"),v(N))}function v(N){return N===null||ut(N)?(e.exit("codeFlowValue"),S(N)):(e.consume(N),v)}function k(N){return e.exit("codeFenced"),t(N)}function E(N,L,A){let O=0;return I;function I(q){return N.enter("lineEnding"),N.consume(q),N.exit("lineEnding"),F}function F(q){return N.enter("codeFencedFence"),Tt(q)?Ot(N,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):B(q)}function B(q){return q===u?(N.enter("codeFencedFenceSequence"),z(q)):A(q)}function z(q){return q===u?(O++,N.consume(q),z):O>=c?(N.exit("codeFencedFenceSequence"),Tt(q)?Ot(N,Y,"whitespace")(q):Y(q)):A(q)}function Y(q){return q===null||ut(q)?(N.exit("codeFencedFence"),L(q)):A(q)}}}function rM(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"),o)}function o(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}const Yg={name:"codeIndented",tokenize:iM},sM={partial:!0,tokenize:aM};function iM(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),Ot(e,o,"linePrefix",5)(h)}function o(h){const m=r.events[r.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?d(h):ut(h)?e.attempt(sM,c,d)(h):(e.enter("codeFlowValue"),u(h))}function u(h){return h===null||ut(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),u)}function d(h){return e.exit("codeIndented"),t(h)}}function aM(e,t,n){const r=this;return a;function a(c){return r.parser.lazy[r.now().line]?n(c):ut(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ot(e,o,"linePrefix",5)(c)}function o(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):ut(c)?a(c):n(c)}}const oM={name:"codeText",previous:cM,resolve:lM,tokenize:uM};function lM(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 cM(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function uM(e,t,n){let r=0,a,o;return c;function c(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),r++,u):(e.exit("codeTextSequence"),d(f))}function d(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),d):f===96?(o=e.enter("codeTextSequence"),a=0,m(f)):ut(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(f))}function h(f){return f===null||f===32||f===96||ut(f)?(e.exit("codeTextData"),d(f)):(e.consume(f),h)}function m(f){return f===96?(e.consume(f),a++,m):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",h(f))}}class dM{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&Fc(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Fc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Fc(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);Fc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Fc(this.left,n.reverse())}}}function Fc(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 s2(e){const t={};let n=-1,r,a,o,c,u,d,h;const m=new dM(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(r=m.get(n),n&&r[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,o=0,o<d.length&&d[o][1].type==="lineEndingBlank"&&(o+=2),o<d.length&&d[o][1].type==="content"))for(;++o<d.length&&d[o][1].type!=="content";)d[o][1].type==="chunkText"&&(d[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,hM(m,n)),n=t[n],h=!0);else if(r[1]._container){for(o=n,a=void 0;o--;)if(c=m.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(m.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=o);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(r[1].end={...m.get(a)[1].start},u=m.slice(a,n),u.unshift(r),m.splice(a,n-a+1,u))}}return Br(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!h}function hM(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const o=[];let c=n._tokenizer;c||(c=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,d=[],h={};let m,f,g=-1,x=n,w=0,C=0;const b=[C];for(;x;){for(;e.get(++a)[1]!==x;);o.push(a),x._tokenizer||(m=r.sliceStream(x),x.next||m.push(null),f&&c.defineSkip(x.start),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(m),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),f=x,x=x.next}for(x=n;++g<u.length;)u[g][0]==="exit"&&u[g-1][0]==="enter"&&u[g][1].type===u[g-1][1].type&&u[g][1].start.line!==u[g][1].end.line&&(C=g+1,b.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):b.pop(),g=b.length;g--;){const _=u.slice(b[g],b[g+1]),S=o.pop();d.push([S,S+_.length-1]),e.splice(S,2,_)}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 fM={resolve:pM,tokenize:gM},mM={partial:!0,tokenize:xM};function pM(e){return s2(e),e}function gM(e,t){let n;return r;function r(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(u)}function a(u){return u===null?o(u):ut(u)?e.check(mM,c,o)(u):(e.consume(u),a)}function o(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 xM(e,t,n){const r=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ot(e,o,"linePrefix")}function o(c){if(c===null||ut(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 i2(e,t,n,r,a,o,c,u,d){const h=d||Number.POSITIVE_INFINITY;let m=0;return f;function f(_){return _===60?(e.enter(r),e.enter(a),e.enter(o),e.consume(_),e.exit(o),g):_===null||_===32||_===41||Qh(_)?n(_):(e.enter(r),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),C(_))}function g(_){return _===62?(e.enter(o),e.consume(_),e.exit(o),e.exit(a),e.exit(r),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),x(_))}function x(_){return _===62?(e.exit("chunkString"),e.exit(u),g(_)):_===null||_===60||ut(_)?n(_):(e.consume(_),_===92?w:x)}function w(_){return _===60||_===62||_===92?(e.consume(_),x):x(_)}function C(_){return!m&&(_===null||_===41||rn(_))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(r),t(_)):m<h&&_===40?(e.consume(_),m++,C):_===41?(e.consume(_),m--,C):_===null||_===32||_===40||Qh(_)?n(_):(e.consume(_),_===92?b:C)}function b(_){return _===40||_===41||_===92?(e.consume(_),C):C(_)}}function a2(e,t,n,r,a,o){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(o),m}function m(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(o),e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):ut(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),f(x))}function f(x){return x===null||x===91||x===93||ut(x)||u++>999?(e.exit("chunkString"),m(x)):(e.consume(x),d||(d=!Tt(x)),x===92?g:f)}function g(x){return x===91||x===92||x===93?(e.consume(x),u++,f):f(x)}}function o2(e,t,n,r,a,o){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(o),h(g))}function h(g){return g===c?(e.exit(o),d(c)):g===null?n(g):ut(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Ot(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===c||g===null||ut(g)?(e.exit("chunkString"),h(g)):(e.consume(g),g===92?f:m)}function f(g){return g===c||g===92?(e.consume(g),m):m(g)}}function tu(e,t){let n;return r;function r(a){return ut(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Tt(a)?Ot(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const yM={name:"definition",tokenize:vM},bM={partial:!0,tokenize:_M};function vM(e,t,n){const r=this;let a;return o;function o(x){return e.enter("definition"),c(x)}function c(x){return a2.call(r,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function u(x){return a=ys(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 rn(x)?tu(e,h)(x):h(x)}function h(x){return i2(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function m(x){return e.attempt(bM,f,f)(x)}function f(x){return Tt(x)?Ot(e,g,"whitespace")(x):g(x)}function g(x){return x===null||ut(x)?(e.exit("definition"),r.parser.defined.push(a),t(x)):n(x)}}function _M(e,t,n){return r;function r(u){return rn(u)?tu(e,a)(u):n(u)}function a(u){return o2(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return Tt(u)?Ot(e,c,"whitespace")(u):c(u)}function c(u){return u===null||ut(u)?t(u):n(u)}}const SM={name:"hardBreakEscape",tokenize:wM};function wM(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ut(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const CM={name:"headingAtx",resolve:kM,tokenize:jM};function kM(e,t){let n=e.length-2,r=3,a,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Br(e,r,n-r+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function jM(e,t,n){let r=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),c(m)}function c(m){return m===35&&r++<6?(e.consume(m),c):m===null||rn(m)?(e.exit("atxHeadingSequence"),u(m)):n(m)}function u(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||ut(m)?(e.exit("atxHeading"),t(m)):Tt(m)?Ot(e,u,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),u(m))}function h(m){return m===null||m===35||rn(m)?(e.exit("atxHeadingText"),u(m)):(e.consume(m),h)}}const EM=["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"],q1=["pre","script","style","textarea"],NM={concrete:!0,name:"htmlFlow",resolveTo:LM,tokenize:RM},TM={partial:!0,tokenize:OM},AM={partial:!0,tokenize:DM};function LM(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 RM(e,t,n){const r=this;let a,o,c,u,d;return h;function h($){return m($)}function m($){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume($),f}function f($){return $===33?(e.consume($),g):$===47?(e.consume($),o=!0,C):$===63?(e.consume($),a=3,r.interrupt?t:P):dr($)?(e.consume($),c=String.fromCharCode($),b):n($)}function g($){return $===45?(e.consume($),a=2,x):$===91?(e.consume($),a=5,u=0,w):dr($)?(e.consume($),a=4,r.interrupt?t:P):n($)}function x($){return $===45?(e.consume($),r.interrupt?t:P):n($)}function w($){const Q="CDATA[";return $===Q.charCodeAt(u++)?(e.consume($),u===Q.length?r.interrupt?t:B:w):n($)}function C($){return dr($)?(e.consume($),c=String.fromCharCode($),b):n($)}function b($){if($===null||$===47||$===62||rn($)){const Q=$===47,K=c.toLowerCase();return!Q&&!o&&q1.includes(K)?(a=1,r.interrupt?t($):B($)):EM.includes(c.toLowerCase())?(a=6,Q?(e.consume($),_):r.interrupt?t($):B($)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n($):o?S($):v($))}return $===45||ar($)?(e.consume($),c+=String.fromCharCode($),b):n($)}function _($){return $===62?(e.consume($),r.interrupt?t:B):n($)}function S($){return Tt($)?(e.consume($),S):I($)}function v($){return $===47?(e.consume($),I):$===58||$===95||dr($)?(e.consume($),k):Tt($)?(e.consume($),v):I($)}function k($){return $===45||$===46||$===58||$===95||ar($)?(e.consume($),k):E($)}function E($){return $===61?(e.consume($),N):Tt($)?(e.consume($),E):v($)}function N($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),d=$,L):Tt($)?(e.consume($),N):A($)}function L($){return $===d?(e.consume($),d=null,O):$===null||ut($)?n($):(e.consume($),L)}function A($){return $===null||$===34||$===39||$===47||$===60||$===61||$===62||$===96||rn($)?E($):(e.consume($),A)}function O($){return $===47||$===62||Tt($)?v($):n($)}function I($){return $===62?(e.consume($),F):n($)}function F($){return $===null||ut($)?B($):Tt($)?(e.consume($),F):n($)}function B($){return $===45&&a===2?(e.consume($),W):$===60&&a===1?(e.consume($),ee):$===62&&a===4?(e.consume($),D):$===63&&a===3?(e.consume($),P):$===93&&a===5?(e.consume($),H):ut($)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(TM,U,z)($)):$===null||ut($)?(e.exit("htmlFlowData"),z($)):(e.consume($),B)}function z($){return e.check(AM,Y,U)($)}function Y($){return e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),q}function q($){return $===null||ut($)?z($):(e.enter("htmlFlowData"),B($))}function W($){return $===45?(e.consume($),P):B($)}function ee($){return $===47?(e.consume($),c="",J):B($)}function J($){if($===62){const Q=c.toLowerCase();return q1.includes(Q)?(e.consume($),D):B($)}return dr($)&&c.length<8?(e.consume($),c+=String.fromCharCode($),J):B($)}function H($){return $===93?(e.consume($),P):B($)}function P($){return $===62?(e.consume($),D):$===45&&a===2?(e.consume($),P):B($)}function D($){return $===null||ut($)?(e.exit("htmlFlowData"),U($)):(e.consume($),D)}function U($){return e.exit("htmlFlow"),t($)}}function DM(e,t,n){const r=this;return a;function a(c){return ut(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}function OM(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Lu,t,n)}}const IM={name:"htmlText",tokenize:MM};function MM(e,t,n){const r=this;let a,o,c;return u;function u(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),d}function d(P){return P===33?(e.consume(P),h):P===47?(e.consume(P),E):P===63?(e.consume(P),v):dr(P)?(e.consume(P),A):n(P)}function h(P){return P===45?(e.consume(P),m):P===91?(e.consume(P),o=0,w):dr(P)?(e.consume(P),S):n(P)}function m(P){return P===45?(e.consume(P),x):n(P)}function f(P){return P===null?n(P):P===45?(e.consume(P),g):ut(P)?(c=f,ee(P)):(e.consume(P),f)}function g(P){return P===45?(e.consume(P),x):f(P)}function x(P){return P===62?W(P):P===45?g(P):f(P)}function w(P){const D="CDATA[";return P===D.charCodeAt(o++)?(e.consume(P),o===D.length?C:w):n(P)}function C(P){return P===null?n(P):P===93?(e.consume(P),b):ut(P)?(c=C,ee(P)):(e.consume(P),C)}function b(P){return P===93?(e.consume(P),_):C(P)}function _(P){return P===62?W(P):P===93?(e.consume(P),_):C(P)}function S(P){return P===null||P===62?W(P):ut(P)?(c=S,ee(P)):(e.consume(P),S)}function v(P){return P===null?n(P):P===63?(e.consume(P),k):ut(P)?(c=v,ee(P)):(e.consume(P),v)}function k(P){return P===62?W(P):v(P)}function E(P){return dr(P)?(e.consume(P),N):n(P)}function N(P){return P===45||ar(P)?(e.consume(P),N):L(P)}function L(P){return ut(P)?(c=L,ee(P)):Tt(P)?(e.consume(P),L):W(P)}function A(P){return P===45||ar(P)?(e.consume(P),A):P===47||P===62||rn(P)?O(P):n(P)}function O(P){return P===47?(e.consume(P),W):P===58||P===95||dr(P)?(e.consume(P),I):ut(P)?(c=O,ee(P)):Tt(P)?(e.consume(P),O):W(P)}function I(P){return P===45||P===46||P===58||P===95||ar(P)?(e.consume(P),I):F(P)}function F(P){return P===61?(e.consume(P),B):ut(P)?(c=F,ee(P)):Tt(P)?(e.consume(P),F):O(P)}function B(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),a=P,z):ut(P)?(c=B,ee(P)):Tt(P)?(e.consume(P),B):(e.consume(P),Y)}function z(P){return P===a?(e.consume(P),a=void 0,q):P===null?n(P):ut(P)?(c=z,ee(P)):(e.consume(P),z)}function Y(P){return P===null||P===34||P===39||P===60||P===61||P===96?n(P):P===47||P===62||rn(P)?O(P):(e.consume(P),Y)}function q(P){return P===47||P===62||rn(P)?O(P):n(P)}function W(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):n(P)}function ee(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),J}function J(P){return Tt(P)?Ot(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):H(P)}function H(P){return e.enter("htmlTextData"),c(P)}}const Ib={name:"labelEnd",resolveAll:FM,resolveTo:zM,tokenize:HM},PM={tokenize:UM},BM={tokenize:VM},$M={tokenize:WM};function FM(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&&Br(e,0,e.length,n),e}function zM(e,t){let n=e.length,r=0,a,o,c,u;for(;n--;)if(a=e[n][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(c=n);const d={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[o][1].start},end:{...e[c][1].end}},m={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",d,t],["enter",h,t]],u=Jr(u,e.slice(o+1,o+r+3)),u=Jr(u,[["enter",m,t]]),u=Jr(u,Yf(t.parser.constructs.insideSpan.null,e.slice(o+r+4,c-3),t)),u=Jr(u,[["exit",m,t],e[c-2],e[c-1],["exit",h,t]]),u=Jr(u,e.slice(c+1)),u=Jr(u,[["exit",d,t]]),Br(e,o,e.length,u),e}function HM(e,t,n){const r=this;let a=r.events.length,o,c;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){o=r.events[a][1];break}return u;function u(g){return o?o._inactive?f(g):(c=r.parser.defined.includes(ys(r.sliceSerialize({start:o.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(PM,m,c?m:f)(g):g===91?e.attempt(BM,m,c?h:f)(g):c?m(g):f(g)}function h(g){return e.attempt($M,m,f)(g)}function m(g){return t(g)}function f(g){return o._balanced=!0,n(g)}}function UM(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),a}function a(f){return rn(f)?tu(e,o)(f):o(f)}function o(f){return f===41?m(f):i2(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function c(f){return rn(f)?tu(e,d)(f):m(f)}function u(f){return n(f)}function d(f){return f===34||f===39||f===40?o2(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):m(f)}function h(f){return rn(f)?tu(e,m)(f):m(f)}function m(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function VM(e,t,n){const r=this;return a;function a(u){return a2.call(r,e,o,c,"reference","referenceMarker","referenceString")(u)}function o(u){return r.parser.defined.includes(ys(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function WM(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),a}function a(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const GM={name:"labelStartImage",resolveAll:Ib.resolveAll,tokenize:qM};function qM(e,t,n){const r=this;return a;function a(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),o}function o(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const KM={name:"labelStartLink",resolveAll:Ib.resolveAll,tokenize:YM};function YM(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"),o}function o(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const Xg={name:"lineEnding",tokenize:XM};function XM(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ot(e,t,"linePrefix")}}const Ph={name:"thematicBreak",tokenize:QM};function QM(e,t,n){let r=0,a;return o;function o(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||ut(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===a?(e.consume(h),r++,d):(e.exit("thematicBreakSequence"),Tt(h)?Ot(e,u,"whitespace")(h):u(h))}}const br={continuation:{tokenize:t4},exit:r4,name:"list",tokenize:e4},JM={partial:!0,tokenize:s4},ZM={partial:!0,tokenize:n4};function e4(e,t,n){const r=this,a=r.events[r.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,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:fy(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(Ph,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 fy(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(Lu,r.interrupt?n:m,e.attempt(JM,g,f))}function m(x){return r.containerState.initialBlankLine=!0,o++,g(x)}function f(x){return Tt(x)?(e.enter("listItemPrefixWhitespace"),e.consume(x),e.exit("listItemPrefixWhitespace"),g):n(x)}function g(x){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(x)}}function t4(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Lu,a,o);function a(u){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ot(e,t,"listItemIndent",r.containerState.size+1)(u)}function o(u){return r.containerState.furtherBlankLines||!Tt(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(ZM,t,c)(u))}function c(u){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ot(e,e.attempt(br,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function n4(e,t,n){const r=this;return Ot(e,a,"listItemIndent",r.containerState.size+1);function a(o){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(o):n(o)}}function r4(e){e.exit(this.containerState.type)}function s4(e,t,n){const r=this;return Ot(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=r.events[r.events.length-1];return!Tt(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const K1={name:"setextUnderline",resolveTo:i4,tokenize:a4};function i4(e,t){let n=e.length,r,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=c,e.push(["exit",c,t]),e}function a4(e,t,n){const r=this;let a;return o;function o(h){let m=r.events.length,f;for(;m--;)if(r.events[m][1].type!=="lineEnding"&&r.events[m][1].type!=="linePrefix"&&r.events[m][1].type!=="content"){f=r.events[m][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),a=h,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"),Tt(h)?Ot(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||ut(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const o4={tokenize:l4};function l4(e){const t=this,n=e.attempt(Lu,r,e.attempt(this.parser.constructs.flowInitial,a,Ot(e,e.attempt(this.parser.constructs.flow,a,e.attempt(fM,a)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const c4={resolveAll:c2()},u4=l2("string"),d4=l2("text");function l2(e){return{resolveAll:c2(e==="text"?h4:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],o=n.attempt(a,c,u);return c;function c(m){return h(m)?o(m):u(m)}function u(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),d}function d(m){return h(m)?(n.exit("data"),o(m)):(n.consume(m),d)}function h(m){if(m===null)return!0;const f=a[m];let g=-1;if(f)for(;++g<f.length;){const x=f[g];if(!x.previous||x.previous.call(r,r.previous))return!0}return!1}}}function c2(e){return t;function t(n,r){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,r):n}}function h4(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let o=a.length,c=-1,u=0,d;for(;o--;){const h=a[o];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){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const h={type:n===e.length||d||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:r.start._bufferIndex+c,_index:r.start._index+o,line:r.end.line,column:r.end.column-u,offset:r.end.offset-u},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const f4={42:br,43:br,45:br,48:br,49:br,50:br,51:br,52:br,53:br,54:br,55:br,56:br,57:br,62:t2},m4={91:yM},p4={[-2]:Yg,[-1]:Yg,32:Yg},g4={35:CM,42:Ph,45:[K1,Ph],60:NM,61:K1,95:Ph,96:G1,126:G1},x4={38:r2,92:n2},y4={[-5]:Xg,[-4]:Xg,[-3]:Xg,33:GM,38:r2,42:my,60:[KI,IM],91:KM,92:[SM,n2],93:Ib,95:my,96:oM},b4={null:[my,c4]},v4={null:[42,95]},_4={null:[]},S4=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:v4,contentInitial:m4,disable:_4,document:f4,flow:g4,flowInitial:p4,insideSpan:b4,string:x4,text:y4},Symbol.toStringTag,{value:"Module"}));function w4(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],u=[];const d={attempt:L(E),check:L(N),consume:S,enter:v,exit:k,interrupt:L(N,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:x,write:f};let m=t.tokenize.call(h,d);return t.resolveAll&&o.push(t),h;function f(F){return c=Jr(c,F),b(),c[c.length-1]!==null?[]:(A(t,0),h.events=Yf(o,h.events,h),h.events)}function g(F,B){return k4(x(F),B)}function x(F){return C4(c,F)}function w(){const{_bufferIndex:F,_index:B,line:z,column:Y,offset:q}=r;return{_bufferIndex:F,_index:B,line:z,column:Y,offset:q}}function C(F){a[F.line]=F.column,I()}function b(){let F;for(;r._index<c.length;){const B=c[r._index];if(typeof B=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<B.length;)_(B.charCodeAt(r._bufferIndex));else _(B)}}function _(F){m=m(F)}function S(F){ut(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,I()):F!==-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=F}function v(F,B){const z=B||{};return z.type=F,z.start=w(),h.events.push(["enter",z,h]),u.push(z),z}function k(F){const B=u.pop();return B.end=w(),h.events.push(["exit",B,h]),B}function E(F,B){A(F,B.from)}function N(F,B){B.restore()}function L(F,B){return z;function z(Y,q,W){let ee,J,H,P;return Array.isArray(Y)?U(Y):"tokenize"in Y?U([Y]):D(Y);function D(Z){return V;function V(M){const X=M!==null&&Z[M],ne=M!==null&&Z.null,re=[...Array.isArray(X)?X:X?[X]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return U(re)(M)}}function U(Z){return ee=Z,J=0,Z.length===0?W:$(Z[J])}function $(Z){return V;function V(M){return P=O(),H=Z,Z.partial||(h.currentConstruct=Z),Z.name&&h.parser.constructs.disable.null.includes(Z.name)?K():Z.tokenize.call(B?Object.assign(Object.create(h),B):h,d,Q,K)(M)}}function Q(Z){return F(H,P),q}function K(Z){return P.restore(),++J<ee.length?$(ee[J]):W}}}function A(F,B){F.resolveAll&&!o.includes(F)&&o.push(F),F.resolve&&Br(h.events,B,h.events.length-B,F.resolve(h.events.slice(B),h)),F.resolveTo&&(h.events=F.resolveTo(h.events,h))}function O(){const F=w(),B=h.previous,z=h.currentConstruct,Y=h.events.length,q=Array.from(u);return{from:Y,restore:W};function W(){r=F,h.previous=B,h.currentConstruct=z,h.events.length=Y,u=q,I()}}function I(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function C4(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let c;if(n===a)c=[e[n].slice(r,o)];else{if(c=e.slice(n,a),r>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(r):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function k4(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const o=e[n];let c;if(typeof o=="string")c=o;else switch(o){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(o)}a=o===-2,r.push(c)}return r.join("")}function j4(e){const r={constructs:ZE([S4,...(e||{}).extensions||[]]),content:a(zI),defined:[],document:a(UI),flow:a(o4),lazy:{},string:a(u4),text:a(d4)};return r;function a(o){return c;function c(u){return w4(r,o,u)}}}function E4(e){for(;!s2(e););return e}const Y1=/[\0\t\n\r]/g;function N4(){let e=1,t="",n=!0,r;return a;function a(o,c,u){const d=[];let h,m,f,g,x;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(Y1.lastIndex=f,h=Y1.exec(o),g=h&&h.index!==void 0?h.index:o.length,x=o.charCodeAt(g),!h){t=o.slice(f);break}if(x===10&&f===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),f<g&&(d.push(o.slice(f,g)),e+=g-f),x){case 0:{d.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,d.push(-2);e++<m;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}f=g+1}return u&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const T4=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function A4(e){return e.replace(T4,L4)}function L4(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),o=a===120||a===88;return e2(n.slice(o?2:1),o?16:10)}return Ob(n)||e}const u2={}.hasOwnProperty;function R4(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),D4(n)(E4(j4(n).document().write(N4()(e,t,!0))))}function D4(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Xe),autolinkProtocol:O,autolinkEmail:O,atxHeading:o(Oe),blockQuote:o(ne),characterEscape:O,characterReference:O,codeFenced:o(re),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(re,c),codeText:o(ie,c),codeTextData:O,data:O,codeFlowValue:O,definition:o(ge),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(ke),hardBreakEscape:o(Fe),hardBreakTrailing:o(Fe),htmlFlow:o(we,c),htmlFlowData:O,htmlText:o(we,c),htmlTextData:O,image:o(We),label:c,link:o(Xe),listItem:o(ye),listItemValue:g,listOrdered:o(_e,f),listUnordered:o(_e),paragraph:o(fe),reference:$,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(Oe),strong:o(oe),thematicBreak:o(He)},exit:{atxHeading:d(),atxHeadingSequence:E,autolink:d(),autolinkEmail:X,autolinkProtocol:M,blockQuote:d(),characterEscapeValue:I,characterReferenceMarkerHexadecimal:K,characterReferenceMarkerNumeric:K,characterReferenceValue:Z,characterReference:V,codeFenced:d(b),codeFencedFence:C,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:I,codeIndented:d(_),codeText:d(q),codeTextData:I,data:I,definition:d(),definitionDestinationString:k,definitionLabelString:S,definitionTitleString:v,emphasis:d(),hardBreakEscape:d(B),hardBreakTrailing:d(B),htmlFlow:d(z),htmlFlowData:I,htmlText:d(Y),htmlTextData:I,image:d(ee),label:H,labelText:J,lineEnding:F,link:d(W),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:Q,resourceDestinationString:P,resourceTitleString:D,resource:U,setextHeading:d(A),setextHeadingLineSequence:L,setextHeadingText:N,strong:d(),thematicBreak:d()}};d2(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(he){let Te={type:"root",children:[]};const Qe={stack:[Te],tokenStack:[],config:t,enter:u,exit:h,buffer:c,resume:m,data:n},me=[];let ze=-1;for(;++ze<he.length;)if(he[ze][1].type==="listOrdered"||he[ze][1].type==="listUnordered")if(he[ze][0]==="enter")me.push(ze);else{const at=me.pop();ze=a(he,at,ze)}for(ze=-1;++ze<he.length;){const at=t[he[ze][0]];u2.call(at,he[ze][1].type)&&at[he[ze][1].type].call(Object.assign({sliceSerialize:he[ze][2].sliceSerialize},Qe),he[ze][1])}if(Qe.tokenStack.length>0){const at=Qe.tokenStack[Qe.tokenStack.length-1];(at[1]||X1).call(Qe,void 0,at[0])}for(Te.position={start:Ki(he.length>0?he[0][1].start:{line:1,column:1,offset:0}),end:Ki(he.length>0?he[he.length-2][1].end:{line:1,column:1,offset:0})},ze=-1;++ze<t.transforms.length;)Te=t.transforms[ze](Te)||Te;return Te}function a(he,Te,Qe){let me=Te-1,ze=-1,at=!1,Ze,et,ot,ce;for(;++me<=Qe;){const ae=he[me];switch(ae[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ae[0]==="enter"?ze++:ze--,ce=void 0;break}case"lineEndingBlank":{ae[0]==="enter"&&(Ze&&!ce&&!ze&&!ot&&(ot=me),ce=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ce=void 0}if(!ze&&ae[0]==="enter"&&ae[1].type==="listItemPrefix"||ze===-1&&ae[0]==="exit"&&(ae[1].type==="listUnordered"||ae[1].type==="listOrdered")){if(Ze){let Re=me;for(et=void 0;Re--;){const Ve=he[Re];if(Ve[1].type==="lineEnding"||Ve[1].type==="lineEndingBlank"){if(Ve[0]==="exit")continue;et&&(he[et][1].type="lineEndingBlank",at=!0),Ve[1].type="lineEnding",et=Re}else if(!(Ve[1].type==="linePrefix"||Ve[1].type==="blockQuotePrefix"||Ve[1].type==="blockQuotePrefixWhitespace"||Ve[1].type==="blockQuoteMarker"||Ve[1].type==="listItemIndent"))break}ot&&(!et||ot<et)&&(Ze._spread=!0),Ze.end=Object.assign({},et?he[et][1].start:ae[1].end),he.splice(et||me,0,["exit",Ze,ae[2]]),me++,Qe++}if(ae[1].type==="listItemPrefix"){const Re={type:"listItem",_spread:!1,start:Object.assign({},ae[1].start),end:void 0};Ze=Re,he.splice(me,0,["enter",Re,ae[2]]),me++,Qe++,ot=void 0,ce=!0}}}return he[Te][1]._spread=at,Qe}function o(he,Te){return Qe;function Qe(me){u.call(this,he(me),me),Te&&Te.call(this,me)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(he,Te,Qe){this.stack[this.stack.length-1].children.push(he),this.stack.push(he),this.tokenStack.push([Te,Qe||void 0]),he.position={start:Ki(Te.start),end:void 0}}function d(he){return Te;function Te(Qe){he&&he.call(this,Qe),h.call(this,Qe)}}function h(he,Te){const Qe=this.stack.pop(),me=this.tokenStack.pop();if(me)me[0].type!==he.type&&(Te?Te.call(this,he,me[0]):(me[1]||X1).call(this,he,me[0]));else throw new Error("Cannot close `"+he.type+"` ("+eu({start:he.start,end:he.end})+"): it’s not open");Qe.position.end=Ki(he.end)}function m(){return Db(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function g(he){if(this.data.expectingFirstListItemValue){const Te=this.stack[this.stack.length-2];Te.start=Number.parseInt(this.sliceSerialize(he),10),this.data.expectingFirstListItemValue=void 0}}function x(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.lang=he}function w(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.meta=he}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.value=he.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.value=he.replace(/(\r?\n|\r)$/g,"")}function S(he){const Te=this.resume(),Qe=this.stack[this.stack.length-1];Qe.label=Te,Qe.identifier=ys(this.sliceSerialize(he)).toLowerCase()}function v(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.title=he}function k(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.url=he}function E(he){const Te=this.stack[this.stack.length-1];if(!Te.depth){const Qe=this.sliceSerialize(he).length;Te.depth=Qe}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function L(he){const Te=this.stack[this.stack.length-1];Te.depth=this.sliceSerialize(he).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function O(he){const Qe=this.stack[this.stack.length-1].children;let me=Qe[Qe.length-1];(!me||me.type!=="text")&&(me=Me(),me.position={start:Ki(he.start),end:void 0},Qe.push(me)),this.stack.push(me)}function I(he){const Te=this.stack.pop();Te.value+=this.sliceSerialize(he),Te.position.end=Ki(he.end)}function F(he){const Te=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Qe=Te.children[Te.children.length-1];Qe.position.end=Ki(he.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Te.type)&&(O.call(this,he),I.call(this,he))}function B(){this.data.atHardBreak=!0}function z(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.value=he}function Y(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.value=he}function q(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.value=he}function W(){const he=this.stack[this.stack.length-1];if(this.data.inReference){const Te=this.data.referenceType||"shortcut";he.type+="Reference",he.referenceType=Te,delete he.url,delete he.title}else delete he.identifier,delete he.label;this.data.referenceType=void 0}function ee(){const he=this.stack[this.stack.length-1];if(this.data.inReference){const Te=this.data.referenceType||"shortcut";he.type+="Reference",he.referenceType=Te,delete he.url,delete he.title}else delete he.identifier,delete he.label;this.data.referenceType=void 0}function J(he){const Te=this.sliceSerialize(he),Qe=this.stack[this.stack.length-2];Qe.label=A4(Te),Qe.identifier=ys(Te).toLowerCase()}function H(){const he=this.stack[this.stack.length-1],Te=this.resume(),Qe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Qe.type==="link"){const me=he.children;Qe.children=me}else Qe.alt=Te}function P(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.url=he}function D(){const he=this.resume(),Te=this.stack[this.stack.length-1];Te.title=he}function U(){this.data.inReference=void 0}function $(){this.data.referenceType="collapsed"}function Q(he){const Te=this.resume(),Qe=this.stack[this.stack.length-1];Qe.label=Te,Qe.identifier=ys(this.sliceSerialize(he)).toLowerCase(),this.data.referenceType="full"}function K(he){this.data.characterReferenceType=he.type}function Z(he){const Te=this.sliceSerialize(he),Qe=this.data.characterReferenceType;let me;Qe?(me=e2(Te,Qe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):me=Ob(Te);const ze=this.stack[this.stack.length-1];ze.value+=me}function V(he){const Te=this.stack.pop();Te.position.end=Ki(he.end)}function M(he){I.call(this,he);const Te=this.stack[this.stack.length-1];Te.url=this.sliceSerialize(he)}function X(he){I.call(this,he);const Te=this.stack[this.stack.length-1];Te.url="mailto:"+this.sliceSerialize(he)}function ne(){return{type:"blockquote",children:[]}}function re(){return{type:"code",lang:null,meta:null,value:""}}function ie(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ke(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function Fe(){return{type:"break"}}function we(){return{type:"html",value:""}}function We(){return{type:"image",title:null,url:"",alt:null}}function Xe(){return{type:"link",title:null,url:"",children:[]}}function _e(he){return{type:"list",ordered:he.type==="listOrdered",start:null,spread:he._spread,children:[]}}function ye(he){return{type:"listItem",spread:he._spread,checked:null,children:[]}}function fe(){return{type:"paragraph",children:[]}}function oe(){return{type:"strong",children:[]}}function Me(){return{type:"text",value:""}}function He(){return{type:"thematicBreak"}}}function Ki(e){return{line:e.line,column:e.column,offset:e.offset}}function d2(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?d2(e,r):O4(e,r)}}function O4(e,t){let n;for(n in t)if(u2.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 X1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+eu({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+eu({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+eu({start:t.start,end:t.end})+") is still open")}function I4(e){const t=this;t.parser=n;function n(r){return R4(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function M4(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 P4(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
71
+ `}]}function B4(e,t){const n=t.value?t.value+`
72
+ `:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function $4(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function F4(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function z4(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=Pl(r.toLowerCase()),o=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=o+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 H4(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 U4(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function h2(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=r:a.push({type:"text",value:r}),a}function V4(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return h2(e,t);const a={src:Pl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function W4(e,t){const n={src:Pl(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 G4(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 q4(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return h2(e,t);const a={href:Pl(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function K4(e,t){const n={href:Pl(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 Y4(e,t,n){const r=e.all(t),a=n?X4(n):f2(t),o={},c=[];if(typeof t.checked=="boolean"){const m=r[0];let f;m&&m.type==="element"&&m.tagName==="p"?f=m:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const m=r[u];(a||u!==0||m.type!=="element"||m.tagName!=="p")&&c.push({type:"text",value:`
73
+ `}),m.type==="element"&&m.tagName==="p"&&!a?c.push(...m.children):c.push(m)}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:o,children:c};return e.patch(t,h),e.applyData(t,h)}function X4(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=f2(n[r])}return t}function f2(e){const t=e.spread;return t??e.children.length>1}function Q4(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 o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function J4(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Z4(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function eP(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function tP(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=GE(t.children[t.children.length-1]);u&&d&&(c.position={start:u,end:d}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function nP(e,t,n){const r=n?n.children:void 0,o=(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 f=t.children[d],g={},x=c?c[d]:void 0;x&&(g.align=x);let w={type:"element",tagName:o,properties:g,children:[]};f&&(w.children=e.all(f),e.patch(f,w),w=e.applyData(f,w)),h.push(w)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,m),e.applyData(t,m)}function rP(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Q1=9,J1=32;function sP(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const o=[];for(;r;)o.push(Z1(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return o.push(Z1(t.slice(a),a>0,!1)),o.join("")}function Z1(e,t,n){let r=0,a=e.length;if(t){let o=e.codePointAt(r);for(;o===Q1||o===J1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(a-1);for(;o===Q1||o===J1;)a--,o=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function iP(e,t){const n={type:"text",value:sP(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function aP(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const oP={blockquote:M4,break:P4,code:B4,delete:$4,emphasis:F4,footnoteReference:z4,heading:H4,html:U4,imageReference:V4,image:W4,inlineCode:G4,linkReference:q4,link:K4,listItem:Y4,list:Q4,paragraph:J4,root:Z4,strong:eP,table:tP,tableCell:rP,tableRow:nP,text:iP,thematicBreak:aP,toml:sh,yaml:sh,definition:sh,footnoteDefinition:sh};function sh(){}const m2=-1,Xf=0,nu=1,Jh=2,Mb=3,Pb=4,Bb=5,$b=6,p2=7,g2=8,x2=typeof self=="object"?self:globalThis,eC=(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 x2[e](t)},lP=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),r=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Xf:case m2:return n(c,a);case nu:{const u=n([],a);for(const d of c)u.push(r(d));return u}case Jh:{const u=n({},a);for(const[d,h]of c)u[r(d)]=r(h);return u}case Mb:return n(new Date(c),a);case Pb:{const{source:u,flags:d}=c;return n(new RegExp(u,d),a)}case Bb:{const u=n(new Map,a);for(const[d,h]of c)u.set(r(d),r(h));return u}case $b:{const u=n(new Set,a);for(const d of c)u.add(r(d));return u}case p2:{const{name:u,message:d}=c;return n(typeof x2[u]=="function"?eC(u,d):new Error(d),a)}case g2: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(eC(o,c),a)};return r},tC=e=>lP(new Map,e)(0),Ua="",{toString:cP}={},{keys:uP}=Object,zc=e=>{const t=typeof e;if(t!=="object"||!e)return[Xf,t];const n=cP.call(e).slice(8,-1);switch(n){case"Array":return[nu,Ua];case"Object":return[Jh,Ua];case"Date":return[Mb,Ua];case"RegExp":return[Pb,Ua];case"Map":return[Bb,Ua];case"Set":return[$b,Ua];case"DataView":return[nu,n]}return n.includes("Array")?[nu,n]:e instanceof Error?[p2,e.name||"Error"]:[Jh,n]},ih=([e,t])=>e===Xf&&(t==="function"||t==="symbol"),dP=(e,t,n,r)=>{const a=(c,u)=>{const d=r.push(c)-1;return n.set(u,d),d},o=c=>{if(n.has(c))return n.get(c);let[u,d]=zc(c);switch(u){case Xf:{let m=c;switch(d){case"bigint":u=g2,m=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);m=null;break;case"undefined":return a([m2],c)}return a([u,m],c)}case nu:{if(d){let g=c;return d==="DataView"?g=new Uint8Array(c.buffer):d==="ArrayBuffer"&&(g=new Uint8Array(c)),a([d,[...g]],c)}const m=[],f=a([u,m],c);for(const g of c)m.push(o(g));return f}case Jh:{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 o(c.toJSON());const m=[],f=a([u,m],c);for(const g of uP(c))(e||!ih(zc(c[g])))&&m.push([o(g),o(c[g])]);return f}case Mb:return a([u,isNaN(c.getTime())?Ua:c.toISOString()],c);case Pb:{const{source:m,flags:f}=c;return a([u,{source:m,flags:f}],c)}case Bb:{const m=[],f=a([u,m],c);for(const[g,x]of c)(e||!(ih(zc(g))||ih(zc(x))))&&m.push([o(g),o(x)]);return f}case $b:{const m=[],f=a([u,m],c);for(const g of c)(e||!ih(zc(g)))&&m.push(o(g));return f}}const{message:h}=c;return a([u,{name:d,message:h}],c)};return o},nC=(e,{json:t,lossy:n}={})=>{const r=[];return dP(!(t||n),!!t,new Map,r)(e),r},Zh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?tC(nC(e,t)):structuredClone(e):(e,t)=>tC(nC(e,t));function hP(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 fP(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function mP(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||hP,r=e.options.footnoteBackLabel||fP,a=e.options.footnoteLabel||"Footnotes",o=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 m=e.all(h),f=String(h.identifier).toUpperCase(),g=Pl(f.toLowerCase());let x=0;const w=[],C=e.footnoteCounts.get(f);for(;C!==void 0&&++x<=C;){w.length>0&&w.push({type:"text",value:" "});let S=typeof n=="string"?n:n(d,x);typeof S=="string"&&(S={type:"text",value:S}),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(S)?S:[S]})}const b=m[m.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const S=b.children[b.children.length-1];S&&S.type==="text"?S.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...w)}else m.push(...w);const _={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(m,!0)};e.patch(h,_),u.push(_)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Zh(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 Qf=(function(e){if(e==null)return yP;if(typeof e=="function")return Jf(e);if(typeof e=="object")return Array.isArray(e)?pP(e):gP(e);if(typeof e=="string")return xP(e);throw new Error("Expected function, string, or object as test")});function pP(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Qf(e[n]);return Jf(r);function r(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function gP(e){const t=e;return Jf(n);function n(r){const a=r;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function xP(e){return Jf(t);function t(n){return n&&n.type===e}}function Jf(e){return t;function t(n,r,a){return!!(bP(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function yP(){return!0}function bP(e){return e!==null&&typeof e=="object"&&"type"in e}const y2=[],vP=!0,py=!1,_P="skip";function b2(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const o=Qf(a),c=r?-1:1;u(e,void 0,[])();function u(d,h,m){const f=d&&typeof d=="object"?d:{};if(typeof f.type=="string"){const x=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(x?"<"+x+">":""))+")"})}return g;function g(){let x=y2,w,C,b;if((!t||o(d,h,m[m.length-1]||void 0))&&(x=SP(n(d,m)),x[0]===py))return x;if("children"in d&&d.children){const _=d;if(_.children&&x[0]!==_P)for(C=(r?_.children.length:-1)+c,b=m.concat(_);C>-1&&C<_.children.length;){const S=_.children[C];if(w=u(S,C,b)(),w[0]===py)return w;C=typeof w[1]=="number"?w[1]:C+c}}return x}}}function SP(e){return Array.isArray(e)?e:typeof e=="number"?[vP,e]:e==null?y2:[e]}function Fb(e,t,n,r){let a,o,c;typeof t=="function"&&typeof n!="function"?(o=void 0,c=t,a=n):(o=t,c=n,a=r),b2(e,o,u,a);function u(d,h){const m=h[h.length-1],f=m?m.children.indexOf(d):void 0;return c(d,f,m)}}const gy={}.hasOwnProperty,wP={};function CP(e,t){const n=t||wP,r=new Map,a=new Map,o=new Map,c={...oP,...n.handlers},u={all:h,applyData:jP,definitionById:r,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:d,options:n,patch:kP,wrap:NP};return Fb(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const f=m.type==="definition"?r:a,g=String(m.identifier).toUpperCase();f.has(g)||f.set(g,m)}}),u;function d(m,f){const g=m.type,x=u.handlers[g];if(gy.call(u.handlers,g)&&x)return x(u,m,f);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in m){const{children:C,...b}=m,_=Zh(b);return _.children=u.all(m),_}return Zh(m)}return(u.options.unknownHandler||EP)(u,m,f)}function h(m){const f=[];if("children"in m){const g=m.children;let x=-1;for(;++x<g.length;){const w=u.one(g[x],m);if(w){if(x&&g[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=rC(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=rC(C.value))}Array.isArray(w)?f.push(...w):f.push(w)}}}return f}}function kP(e,t){e.position&&(t.position=fI(e))}function jP(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const c="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:c}}n.type==="element"&&o&&Object.assign(n.properties,Zh(o)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function EP(e,t){const n=t.data||{},r="value"in t&&!(gy.call(n,"hProperties")||gy.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 NP(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 rC(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function sC(e,t){const n=CP(e,t),r=n.one(e,void 0),a=mP(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
80
+ `},a),o}function TP(e,t){return e&&"run"in e?async function(n,r){const a=sC(n,{file:r,...t});await e.run(a,r)}:function(n,r){return sC(n,{file:r,...e||t})}}function iC(e){if(e)throw e}var Qg,aC;function AP(){if(aC)return Qg;aC=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),f=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!f)return!1;var g;for(g in h);return typeof g>"u"||e.call(h,g)},c=function(h,m){n&&m.name==="__proto__"?n(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},u=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(r)return r(h,m).value}else return;return h[m]};return Qg=function d(){var h,m,f,g,x,w,C=arguments[0],b=1,_=arguments.length,S=!1;for(typeof C=="boolean"&&(S=C,C=arguments[1]||{},b=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});b<_;++b)if(h=arguments[b],h!=null)for(m in h)f=u(C,m),g=u(h,m),C!==g&&(S&&g&&(o(g)||(x=a(g)))?(x?(x=!1,w=f&&a(f)?f:[]):w=f&&o(f)?f:{},c(C,{name:m,newValue:d(S,w,g)})):typeof g<"u"&&c(C,{name:m,newValue:g}));return C},Qg}var LP=AP();const Jg=kf(LP);function xy(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 RP(){const e=[],t={run:n,use:r};return t;function n(...a){let o=-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 m=e[++o];let f=-1;if(d){c(d);return}for(;++f<a.length;)(h[f]===null||h[f]===void 0)&&(h[f]=a[f]);a=h,m?DP(m,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 DP(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 m=h;if(u&&n)throw m;return a(m)}u||(d&&d.then&&typeof d.then=="function"?d.then(o,a):d instanceof Error?a(d):o(d))}function a(c,...u){n||(n=!0,t(c,...u))}function o(c){a(null,c)}}const Rs={basename:OP,dirname:IP,extname:MP,join:PP,sep:"/"};function OP(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ru(e);let n=0,r=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else r<0&&(o=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let c=-1,u=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!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 IP(e){if(Ru(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 MP(e){Ru(e);let t=e.length,n=-1,r=0,a=-1,o=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:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function PP(...e){let t=-1,n;for(;++t<e.length;)Ru(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":BP(n)}function BP(e){Ru(e);const t=e.codePointAt(0)===47;let n=$P(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function $P(e,t){let n="",r=0,a=-1,o=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||o===1))if(a!==c-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(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,o=0;continue}}else if(n.length>0){n="",r=0,a=c,o=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,o=0}else u===46&&o>-1?o++:o=-1}return n}function Ru(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const FP={cwd:zP};function zP(){return"/"}function yy(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function HP(e){if(typeof e=="string")e=new URL(e);else if(!yy(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 UP(e)}function UP(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 Zg=["history","path","basename","stem","extname","dirname"];class v2{constructor(t){let n;t?yy(t)?n={path:t}:typeof t=="string"||VP(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":FP.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Zg.length;){const o=Zg[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let a;for(a in n)Zg.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Rs.basename(this.path):void 0}set basename(t){tx(t,"basename"),ex(t,"basename"),this.path=Rs.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Rs.dirname(this.path):void 0}set dirname(t){oC(this.basename,"dirname"),this.path=Rs.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Rs.extname(this.path):void 0}set extname(t){if(ex(t,"extname"),oC(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=Rs.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){yy(t)&&(t=HP(t)),tx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Rs.basename(this.path,this.extname):void 0}set stem(t){tx(t,"stem"),ex(t,"stem"),this.path=Rs.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 or(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 ex(e,t){if(e&&e.includes(Rs.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Rs.sep+"`")}function tx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function oC(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function VP(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const WP=(function(e){const r=this.constructor.prototype,a=r[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),GP={}.hasOwnProperty;class zb extends WP{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=RP()}copy(){const t=new zb;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Jg(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(sx("data",this.frozen),this.namespace[t]=n,this):GP.call(this.namespace,t)&&this.namespace[t]||void 0:t?(sx("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=ah(t),r=this.parser||this.Parser;return nx("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),nx("process",this.parser||this.Parser),rx("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,c){const u=ah(t),d=r.parse(u);r.run(d,u,function(m,f,g){if(m||!f||!g)return h(m);const x=f,w=r.stringify(x,g);YP(w)?g.value=w:g.result=w,h(m,g)});function h(m,f){m||!f?c(m):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),nx("processSync",this.parser||this.Parser),rx("processSync",this.compiler||this.Compiler),this.process(t,a),cC("processSync","process",n),r;function a(o,c){n=!0,iC(o),r=c}}run(t,n,r){lC(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(c,u){const d=ah(n);a.run(t,d,h);function h(m,f,g){const x=f||t;m?u(m):c?c(x):r(void 0,x,g)}}}runSync(t,n){let r=!1,a;return this.run(t,n,o),cC("runSync","run",r),a;function o(c,u){iC(c),a=u,r=!0}}stringify(t,n){this.freeze();const r=ah(n),a=this.compiler||this.Compiler;return rx("stringify",a),lC(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(sx("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 o(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...f]=h;d(m,f)}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=Jg(!0,a.settings,h.settings))}function u(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const f=h[m];o(f)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,m){let f=-1,g=-1;for(;++f<r.length;)if(r[f][0]===h){g=f;break}if(g===-1)r.push([h,...m]);else if(m.length>0){let[x,...w]=m;const C=r[g][1];xy(C)&&xy(x)&&(x=Jg(!0,C,x)),r[g]=[h,x,...w]}}}}const qP=new zb().freeze();function nx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function rx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function sx(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 lC(e){if(!xy(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function cC(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ah(e){return KP(e)?e:new v2(e)}function KP(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function YP(e){return typeof e=="string"||XP(e)}function XP(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const QP="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",uC=[],dC={allowDangerousHtml:!0},JP=/^(https?|ircs?|mailto|xmpp)$/i,ZP=[{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 e6(e){const t=t6(e),n=n6(e);return r6(t.runSync(t.parse(n),n),e)}function t6(e){const t=e.rehypePlugins||uC,n=e.remarkPlugins||uC,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dC}:dC;return qP().use(I4).use(n).use(TP,r).use(t)}function n6(e){const t=e.children||"",n=new v2;return typeof t=="string"&&(n.value=t),n}function r6(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,u=t.unwrapDisallowed,d=t.urlTransform||s6;for(const m of ZP)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+QP+m.id,void 0);return Fb(e,h),yI(e,{Fragment:s.Fragment,components:a,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function h(m,f,g){if(m.type==="raw"&&g&&typeof f=="number")return c?g.children.splice(f,1):g.children[f]={type:"text",value:m.value},f;if(m.type==="element"){let x;for(x in Kg)if(Object.hasOwn(Kg,x)&&Object.hasOwn(m.properties,x)){const w=m.properties[x],C=Kg[x];(C===null||C.includes(m.tagName))&&(m.properties[x]=d(String(w||""),x,m))}}if(m.type==="element"){let x=n?!n.includes(m.tagName):o?o.includes(m.tagName):!1;if(!x&&r&&typeof f=="number"&&(x=!r(m,f,g)),x&&g&&typeof f=="number")return u&&m.children?g.children.splice(f,1,...m.children):g.children.splice(f,1),f}}}function s6(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||JP.test(e.slice(0,t))?e:""}function hC(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 i6(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function a6(e,t,n){const a=Qf((n||{}).ignore||[]),o=o6(t);let c=-1;for(;++c<o.length;)b2(e,"text",u);function u(h,m){let f=-1,g;for(;++f<m.length;){const x=m[f],w=g?g.children:void 0;if(a(x,w?w.indexOf(x):void 0,g))return;g=x}if(g)return d(h,m)}function d(h,m){const f=m[m.length-1],g=o[c][0],x=o[c][1];let w=0;const b=f.children.indexOf(h);let _=!1,S=[];g.lastIndex=0;let v=g.exec(h.value);for(;v;){const k=v.index,E={index:v.index,input:v.input,stack:[...m,h]};let N=x(...v,E);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?g.lastIndex=k+1:(w!==k&&S.push({type:"text",value:h.value.slice(w,k)}),Array.isArray(N)?S.push(...N):N&&S.push(N),w=k+v[0].length,_=!0),!g.global)break;v=g.exec(h.value)}return _?(w<h.value.length&&S.push({type:"text",value:h.value.slice(w)}),f.children.splice(b,1,...S)):S=[h],b+S.length}}function o6(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([l6(a[0]),c6(a[1])])}return t}function l6(e){return typeof e=="string"?new RegExp(i6(e),"g"):e}function c6(e){return typeof e=="function"?e:function(){return e}}const ix="phrasing",ax=["autolink","link","image","label"];function u6(){return{transforms:[x6],enter:{literalAutolink:h6,literalAutolinkEmail:ox,literalAutolinkHttp:ox,literalAutolinkWww:ox},exit:{literalAutolink:g6,literalAutolinkEmail:p6,literalAutolinkHttp:f6,literalAutolinkWww:m6}}}function d6(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ix,notInConstruct:ax},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ix,notInConstruct:ax},{character:":",before:"[ps]",after:"\\/",inConstruct:ix,notInConstruct:ax}]}}function h6(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ox(e){this.config.enter.autolinkProtocol.call(this,e)}function f6(e){this.config.exit.autolinkProtocol.call(this,e)}function m6(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 p6(e){this.config.exit.autolinkEmail.call(this,e)}function g6(e){this.exit(e)}function x6(e){a6(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,y6],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),b6]],{ignore:["link","linkReference"]})}function y6(e,t,n,r,a){let o="";if(!_2(a)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!v6(n)))return!1;const c=_6(n+r);if(!c[0])return!1;const u={type:"link",title:null,url:o+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[u,{type:"text",value:c[1]}]:u}function b6(e,t,n,r){return!_2(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function v6(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 _6(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=hC(e,"(");let o=hC(e,")");for(;r!==-1&&a>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function _2(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||io(n)||Kf(n))&&(!t||n!==47)}S2.peek=A6;function S6(){this.buffer()}function w6(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function C6(){this.buffer()}function k6(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function j6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ys(this.sliceSerialize(e)).toLowerCase(),n.label=t}function E6(e){this.exit(e)}function N6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ys(this.sliceSerialize(e)).toLowerCase(),n.label=t}function T6(e){this.exit(e)}function A6(){return"["}function S2(e,t,n,r){const a=n.createTracker(r);let o=a.move("[^");const c=n.enter("footnoteReference"),u=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),u(),c(),o+=a.move("]"),o}function L6(){return{enter:{gfmFootnoteCallString:S6,gfmFootnoteCall:w6,gfmFootnoteDefinitionLabelString:C6,gfmFootnoteDefinition:k6},exit:{gfmFootnoteCallString:j6,gfmFootnoteCall:E6,gfmFootnoteDefinitionLabelString:N6,gfmFootnoteDefinition:T6}}}function R6(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:S2},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,o,c){const u=o.createTracker(c);let d=u.move("[^");const h=o.enter("footnoteDefinition"),m=o.enter("label");return d+=u.move(o.safe(o.associationId(r),{before:d,after:"]"})),m(),d+=u.move("]:"),r.children&&r.children.length>0&&(u.shift(4),d+=u.move((t?`
81
+ `:" ")+o.indentLines(o.containerFlow(r,u.current()),t?w2:D6))),h(),d}}function D6(e,t,n){return t===0?e:w2(e,t,n)}function w2(e,t,n){return(n?"":" ")+e}const O6=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];C2.peek=$6;function I6(){return{canContainEols:["delete"],enter:{strikethrough:P6},exit:{strikethrough:B6}}}function M6(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:O6}],handlers:{delete:C2}}}function P6(e){this.enter({type:"delete",children:[]},e)}function B6(e){this.exit(e)}function C2(e,t,n,r){const a=n.createTracker(r),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function $6(){return"~"}function F6(e){return e.length}function z6(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||F6,o=[],c=[],u=[],d=[];let h=0,m=-1;for(;++m<e.length;){const C=[],b=[];let _=-1;for(e[m].length>h&&(h=e[m].length);++_<e[m].length;){const S=H6(e[m][_]);if(n.alignDelimiters!==!1){const v=a(S);b[_]=v,(d[_]===void 0||v>d[_])&&(d[_]=v)}C.push(S)}c[m]=C,u[m]=b}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<h;)o[f]=fC(r[f]);else{const C=fC(r);for(;++f<h;)o[f]=C}f=-1;const g=[],x=[];for(;++f<h;){const C=o[f];let b="",_="";C===99?(b=":",_=":"):C===108?b=":":C===114&&(_=":");let S=n.alignDelimiters===!1?1:Math.max(1,d[f]-b.length-_.length);const v=b+"-".repeat(S)+_;n.alignDelimiters!==!1&&(S=b.length+S+_.length,S>d[f]&&(d[f]=S),x[f]=S),g[f]=v}c.splice(1,0,g),u.splice(1,0,x),m=-1;const w=[];for(;++m<c.length;){const C=c[m],b=u[m];f=-1;const _=[];for(;++f<h;){const S=C[f]||"";let v="",k="";if(n.alignDelimiters!==!1){const E=d[f]-(b[f]||0),N=o[f];N===114?v=" ".repeat(E):N===99?E%2?(v=" ".repeat(E/2+.5),k=" ".repeat(E/2-.5)):(v=" ".repeat(E/2),k=v):k=" ".repeat(E)}n.delimiterStart!==!1&&!f&&_.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&S==="")&&(n.delimiterStart!==!1||f)&&_.push(" "),n.alignDelimiters!==!1&&_.push(v),_.push(S),n.alignDelimiters!==!1&&_.push(k),n.padding!==!1&&_.push(" "),(n.delimiterEnd!==!1||f!==h-1)&&_.push("|")}w.push(n.delimiterEnd===!1?_.join("").replace(/ +$/,""):_.join(""))}return w.join(`
82
+ `)}function H6(e){return e==null?"":String(e)}function fC(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 U6(e,t,n,r){const a=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),V6);return a(),c}function V6(e,t,n){return">"+(n?"":" ")+e}function W6(e,t){return mC(e,t.inConstruct,!0)&&!mC(e,t.notInConstruct,!1)}function mC(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 pC(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
83
+ `&&W6(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
84
+ `}function G6(e,t){const n=String(e);let r=n.indexOf(t),a=r,o=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++o>c&&(c=o):o=1,a=r+t.length,r=n.indexOf(t,a);return c}function q6(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 K6(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 Y6(e,t,n,r){const a=K6(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(q6(e,n)){const f=n.enter("codeIndented"),g=n.indentLines(o,X6);return f(),g}const u=n.createTracker(r),d=a.repeat(Math.max(G6(o,a)+1,3)),h=n.enter("codeFenced");let m=u.move(d);if(e.lang){const f=n.enter(`codeFencedLang${c}`);m+=u.move(n.safe(e.lang,{before:m,after:" ",encode:["`"],...u.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${c}`);m+=u.move(" "),m+=u.move(n.safe(e.meta,{before:m,after:`
85
+ `,encode:["`"],...u.current()})),f()}return m+=u.move(`
86
+ `),o&&(m+=u.move(o+`
87
+ `)),m+=u.move(d),h(),m}function X6(e,t,n){return(n?"":" ")+e}function Hb(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 Q6(e,t,n,r){const a=Hb(n),o=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${o}`),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 J6(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 yu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ef(e,t,n){const r=Nl(e),a=Nl(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}}k2.peek=Z6;function k2(e,t,n,r){const a=J6(n),o=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),m=ef(r.before.charCodeAt(r.before.length-1),h,a);m.inside&&(d=yu(h)+d.slice(1));const f=d.charCodeAt(d.length-1),g=ef(r.after.charCodeAt(0),f,a);g.inside&&(d=d.slice(0,-1)+yu(f));const x=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},u+d+x}function Z6(e,t,n){return n.options.emphasis||"*"}function eB(e,t){let n=!1;return Fb(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,py}),!!((!e.depth||e.depth<3)&&Db(e)&&(t.options.setext||n))}function tB(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(eB(e,n)){const m=n.enter("headingSetext"),f=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:`
89
+ `,after:`
90
+ `});return f(),m(),g+`
91
+ `+(a===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
92
+ `))+1))}const c="#".repeat(a),u=n.enter("headingAtx"),d=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
93
+ `,...o.current()});return/^[\t ]/.test(h)&&(h=yu(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),d(),u(),h}j2.peek=nB;function j2(e){return e.value||""}function nB(){return"<"}E2.peek=rB;function E2(e,t,n,r){const a=Hb(n),o=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${o}`),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 rB(){return"!"}N2.peek=sB;function N2(e,t,n,r){const a=e.referenceType,o=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 m=n.stack;n.stack=[],c=n.enter("reference");const f=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=m,o(),a==="full"||!h||h!==f?d+=u.move(f+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function sB(){return"!"}T2.peek=iB;function T2(e,t,n){let r=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const c=n.unsafe[o],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 iB(){return"`"}function A2(e,t){const n=Db(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))}L2.peek=aB;function L2(e,t,n,r){const a=Hb(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(r);let u,d;if(A2(e,n)){const m=n.stack;n.stack=[],u=n.enter("autolink");let f=c.move("<");return f+=c.move(n.containerPhrasing(e,{before:f,after:">",...c.current()})),f+=c.move(">"),u(),n.stack=m,f}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${o}`),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 aB(e,t,n){return A2(e,n)?"<":"["}R2.peek=oB;function R2(e,t,n,r){const a=e.referenceType,o=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 m=n.stack;n.stack=[],c=n.enter("reference");const f=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=m,o(),a==="full"||!h||h!==f?d+=u.move(f+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function oB(){return"["}function Ub(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 lB(e){const t=Ub(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 cB(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 D2(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 uB(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?cB(n):Ub(n);const u=e.ordered?c==="."?")":".":lB(n);let d=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&m&&(!m.children||!m.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),D2(n)===c&&m){let f=-1;for(;++f<e.children.length;){const g=e.children[f];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(c=u),n.bulletCurrent=c;const h=n.containerFlow(e,r);return n.bulletLastUsed=c,n.bulletCurrent=o,a(),h}function dB(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 hB(e,t,n,r){const a=dB(n);let o=n.bulletCurrent||Ub(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.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(o+" ".repeat(c-o.length)),u.shift(c);const d=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,u.current()),m);return d(),h;function m(f,g,x){return g?(x?"":" ".repeat(c))+f:(x?o:o+" ".repeat(c-o.length))+f}}function fB(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,r);return o(),a(),c}const mB=Qf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function pB(e,t,n,r){return(e.children.some(function(c){return mB(c)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function gB(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}O2.peek=xB;function O2(e,t,n,r){const a=gB(n),o=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),m=ef(r.before.charCodeAt(r.before.length-1),h,a);m.inside&&(d=yu(h)+d.slice(1));const f=d.charCodeAt(d.length-1),g=ef(r.after.charCodeAt(0),f,a);g.inside&&(d=d.slice(0,-1)+yu(f));const x=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},u+d+x}function xB(e,t,n){return n.options.strong||"*"}function yB(e,t,n,r){return n.safe(e.value,r)}function bB(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 vB(e,t,n){const r=(D2(n)+(n.options.ruleSpaces?" ":"")).repeat(bB(n));return n.options.ruleSpaces?r.slice(0,-1):r}const I2={blockquote:U6,break:pC,code:Y6,definition:Q6,emphasis:k2,hardBreak:pC,heading:tB,html:j2,image:E2,imageReference:N2,inlineCode:T2,link:L2,linkReference:R2,list:uB,listItem:hB,paragraph:fB,root:pB,strong:O2,text:yB,thematicBreak:vB};function _B(){return{enter:{table:SB,tableData:gC,tableHeader:gC,tableRow:CB},exit:{codeText:kB,table:wB,tableData:lx,tableHeader:lx,tableRow:lx}}}function SB(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 wB(e){this.exit(e),this.data.inTable=void 0}function CB(e){this.enter({type:"tableRow",children:[]},e)}function lx(e){this.exit(e)}function gC(e){this.enter({type:"tableCell",children:[]},e)}function kB(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,jB));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function jB(e,t){return t==="|"?t:e}function EB(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
94
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:c,tableCell:d,tableRow:u}};function c(x,w,C,b){return h(m(x,C,b),x.align)}function u(x,w,C,b){const _=f(x,C,b),S=h([_]);return S.slice(0,S.indexOf(`
95
+ `))}function d(x,w,C,b){const _=C.enter("tableCell"),S=C.enter("phrasing"),v=C.containerPhrasing(x,{...b,before:o,after:o});return S(),_(),v}function h(x,w){return z6(x,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function m(x,w,C){const b=x.children;let _=-1;const S=[],v=w.enter("table");for(;++_<b.length;)S[_]=f(b[_],w,C);return v(),S}function f(x,w,C){const b=x.children;let _=-1;const S=[],v=w.enter("tableRow");for(;++_<b.length;)S[_]=d(b[_],x,w,C);return v(),S}function g(x,w,C){let b=I2.inlineCode(x,w,C);return C.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function NB(){return{exit:{taskListCheckValueChecked:xC,taskListCheckValueUnchecked:xC,paragraph:AB}}}function TB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:LB}}}function xC(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function AB(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let o=-1,c;for(;++o<a.length;){const u=a[o];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 LB(e,t,n,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);o&&u.move(c);let d=I2.listItem(e,t,n,{...r,...u.current()});return o&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(m){return m+c}}function RB(){return[u6(),L6(),I6(),_B(),NB()]}function DB(e){return{extensions:[d6(),R6(e),M6(),EB(e),TB()]}}const OB={tokenize:FB,partial:!0},M2={tokenize:zB,partial:!0},P2={tokenize:HB,partial:!0},B2={tokenize:UB,partial:!0},IB={tokenize:VB,partial:!0},$2={name:"wwwAutolink",tokenize:BB,previous:z2},F2={name:"protocolAutolink",tokenize:$B,previous:H2},Ci={name:"emailAutolink",tokenize:PB,previous:U2},Hs={};function MB(){return{text:Hs}}let Ma=48;for(;Ma<123;)Hs[Ma]=Ci,Ma++,Ma===58?Ma=65:Ma===91&&(Ma=97);Hs[43]=Ci;Hs[45]=Ci;Hs[46]=Ci;Hs[95]=Ci;Hs[72]=[Ci,F2];Hs[104]=[Ci,F2];Hs[87]=[Ci,$2];Hs[119]=[Ci,$2];function PB(e,t,n){const r=this;let a,o;return c;function c(f){return!by(f)||!U2.call(r,r.previous)||Vb(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(f))}function u(f){return by(f)?(e.consume(f),u):f===64?(e.consume(f),d):n(f)}function d(f){return f===46?e.check(IB,m,h)(f):f===45||f===95||ar(f)?(o=!0,e.consume(f),d):m(f)}function h(f){return e.consume(f),a=!0,d}function m(f){return o&&a&&dr(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function BB(e,t,n){const r=this;return a;function a(c){return c!==87&&c!==119||!z2.call(r,r.previous)||Vb(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(OB,e.attempt(M2,e.attempt(P2,o),n),n)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function $B(e,t,n){const r=this;let a="",o=!1;return c;function c(f){return(f===72||f===104)&&H2.call(r,r.previous)&&!Vb(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(f),e.consume(f),u):n(f)}function u(f){if(dr(f)&&a.length<5)return a+=String.fromCodePoint(f),e.consume(f),u;if(f===58){const g=a.toLowerCase();if(g==="http"||g==="https")return e.consume(f),d}return n(f)}function d(f){return f===47?(e.consume(f),o?h:(o=!0,d)):n(f)}function h(f){return f===null||Qh(f)||rn(f)||io(f)||Kf(f)?n(f):e.attempt(M2,e.attempt(P2,m),n)(f)}function m(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function FB(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),o):n(c)}function o(c){return c===null?n(c):t(c)}}function zB(e,t,n){let r,a,o;return c;function c(h){return h===46||h===95?e.check(B2,d,u)(h):h===null||rn(h)||io(h)||h!==45&&Kf(h)?d(h):(o=!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||!o?n(h):t(h)}}function HB(e,t){let n=0,r=0;return a;function a(c){return c===40?(n++,e.consume(c),a):c===41&&r<n?o(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(B2,t,o)(c):c===null||rn(c)||io(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&r++,e.consume(c),a}}function UB(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),o):u===93?(e.consume(u),a):u===60||u===null||rn(u)||io(u)?t(u):n(u)}function a(u){return u===null||u===40||u===91||rn(u)||io(u)?t(u):r(u)}function o(u){return dr(u)?c(u):n(u)}function c(u){return u===59?(e.consume(u),r):dr(u)?(e.consume(u),c):n(u)}}function VB(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return ar(o)?n(o):t(o)}}function z2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||rn(e)}function H2(e){return!dr(e)}function U2(e){return!(e===47||by(e))}function by(e){return e===43||e===45||e===46||e===95||ar(e)}function Vb(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 WB={tokenize:ZB,partial:!0};function GB(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:XB,continuation:{tokenize:QB},exit:JB}},text:{91:{name:"gfmFootnoteCall",tokenize:YB},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:qB,resolveTo:KB}}}}function qB(e,t,n){const r=this;let a=r.events.length;const o=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=ys(r.sliceSerialize({start:c.end,end:r.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function KB(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...u),e}function YB(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,c;return u;function u(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),d}function d(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(f){if(o>999||f===93&&!c||f===null||f===91||rn(f))return n(f);if(f===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(ys(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return rn(f)||(c=!0),o++,e.consume(f),f===92?m:h}function m(f){return f===91||f===92||f===93?(e.consume(f),o++,h):h(f)}}function XB(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,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",m):n(w)}function m(w){if(c>999||w===93&&!u||w===null||w===91||rn(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return o=ys(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return rn(w)||(u=!0),c++,e.consume(w),w===92?f:m}function f(w){return w===91||w===92||w===93?(e.consume(w),c++,m):m(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ot(e,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return t(w)}}function QB(e,t,n){return e.check(Lu,t,e.attempt(WB,t,n))}function JB(e){e.exit("gfmFootnoteDefinition")}function ZB(e,t,n){const r=this;return Ot(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=r.events[r.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function e8(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(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 m={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[d][1].end)},f={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[d][1].start)},g=[["enter",m,u],["enter",c[h][1],u],["exit",c[h][1],u],["enter",f,u]],x=u.parser.constructs.insideSpan.null;x&&Br(g,g.length,0,Yf(x,c.slice(h+1,d),u)),Br(g,g.length,0,[["exit",f,u],["enter",c[d][1],u],["exit",c[d][1],u],["exit",m,u]]),Br(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 o(c,u,d){const h=this.previous,m=this.events;let f=0;return g;function g(w){return h===126&&m[m.length-1][1].type!=="characterEscape"?d(w):(c.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const C=Nl(h);if(w===126)return f>1?d(w):(c.consume(w),f++,x);if(f<2&&!n)return d(w);const b=c.exit("strikethroughSequenceTemporary"),_=Nl(w);return b._open=!_||_===2&&!!C,b._close=!C||C===2&&!!_,u(w)}}}class t8{constructor(){this.map=[]}add(t,n,r){n8(this,t,n,r)}consume(t){if(this.map.sort(function(o,c){return o[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 o of a)t.push(o);a=r.pop()}this.map.length=0}}function n8(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 r8(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function s8(){return{flow:{null:{name:"table",tokenize:i8,resolveAll:a8}}}}function i8(e,t,n){const r=this;let a=0,o=0,c;return u;function u(I){let F=r.events.length-1;for(;F>-1;){const Y=r.events[F][1].type;if(Y==="lineEnding"||Y==="linePrefix")F--;else break}const B=F>-1?r.events[F][1].type:null,z=B==="tableHead"||B==="tableRow"?N:d;return z===N&&r.parser.lazy[r.now().line]?n(I):z(I)}function d(I){return e.enter("tableHead"),e.enter("tableRow"),h(I)}function h(I){return I===124||(c=!0,o+=1),m(I)}function m(I){return I===null?n(I):ut(I)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),x):n(I):Tt(I)?Ot(e,m,"whitespace")(I):(o+=1,c&&(c=!1,a+=1),I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),c=!0,m):(e.enter("data"),f(I)))}function f(I){return I===null||I===124||rn(I)?(e.exit("data"),m(I)):(e.consume(I),I===92?g:f)}function g(I){return I===92||I===124?(e.consume(I),f):f(I)}function x(I){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(I):(e.enter("tableDelimiterRow"),c=!1,Tt(I)?Ot(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):w(I))}function w(I){return I===45||I===58?b(I):I===124?(c=!0,e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),C):E(I)}function C(I){return Tt(I)?Ot(e,b,"whitespace")(I):b(I)}function b(I){return I===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),_):I===45?(o+=1,_(I)):I===null||ut(I)?k(I):E(I)}function _(I){return I===45?(e.enter("tableDelimiterFiller"),S(I)):E(I)}function S(I){return I===45?(e.consume(I),S):I===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(I))}function v(I){return Tt(I)?Ot(e,k,"whitespace")(I):k(I)}function k(I){return I===124?w(I):I===null||ut(I)?!c||a!==o?E(I):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(I)):E(I)}function E(I){return n(I)}function N(I){return e.enter("tableRow"),L(I)}function L(I){return I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),L):I===null||ut(I)?(e.exit("tableRow"),t(I)):Tt(I)?Ot(e,L,"whitespace")(I):(e.enter("data"),A(I))}function A(I){return I===null||I===124||rn(I)?(e.exit("data"),L(I)):(e.consume(I),I===92?O:A)}function O(I){return I===92||I===124?(e.consume(I),A):A(I)}}function a8(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,h,m,f;const g=new t8;for(;++n<e.length;){const x=e[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(u=!1,d!==0&&(yC(g,t,d,h,m),m=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,f=void 0,o=[0,0,0,0],c=[0,n+1,0,0],u&&(u=!1,m={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",m,t]])),a=w.type==="tableDelimiterRow"?2:m?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],f=oh(g,t,o,a,void 0,f),o=[0,0,0,0]),c[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(c[0]=c[1],f=oh(g,t,o,a,void 0,f)),o=c,c=[o[1],n,0,0])):w.type==="tableHead"?(u=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,o[1]!==0?(c[0]=c[1],f=oh(g,t,o,a,n,f)):c[1]!==0&&(f=oh(g,t,c,a,n,f)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=n)}for(d!==0&&yC(g,t,d,h,m),g.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=r8(t.events,n))}return e}function oh(e,t,n,r,a,o){const c=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(o.end=Object.assign({},cl(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const d=cl(t.events,n[1]);if(o={type:c,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const h=cl(t.events,n[2]),m=cl(t.events,n[3]),f={type:u,start:Object.assign({},h),end:Object.assign({},m)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const g=t.events[n[2]],x=t.events[n[3]];if(g[1].end=Object.assign({},x[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return a!==void 0&&(o.end=Object.assign({},cl(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function yC(e,t,n,r,a){const o=[],c=cl(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),r.end=Object.assign({},c),o.push(["exit",r,t]),e.add(n+1,0,o)}function cl(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const o8={name:"tasklistCheck",tokenize:c8};function l8(){return{text:{91:o8}}}function c8(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"),o)}function o(d){return rn(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 ut(d)?t(d):Tt(d)?e.check({tokenize:u8},t,n)(d):n(d)}}function u8(e,t,n){return Ot(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function d8(e){return ZE([MB(),GB(),e8(e),s8(),l8()])}const h8={};function f8(e){const t=this,n=e||h8,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),c=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(d8(n)),o.push(RB()),c.push(DB(n))}var vy=Object.defineProperty,m8=Object.getOwnPropertyDescriptor,p8=Object.getOwnPropertyNames,g8=Object.prototype.hasOwnProperty,Wb=(e,t)=>{let n={};for(var r in e)vy(n,r,{get:e[r],enumerable:!0});return vy(n,Symbol.toStringTag,{value:"Module"}),n},x8=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=p8(t),o=0,c=a.length,u;o<c;o++)u=a[o],!g8.call(e,u)&&u!==n&&vy(e,u,{get:(d=>t[d]).bind(null,u),enumerable:!(r=m8(t,u))||r.enumerable});return e},V2=(e,t,n)=>(x8(e,t,"default"),n);const Zf=[{id:"abap",name:"ABAP",import:(()=>se(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>se(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>se(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>se(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>se(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>se(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>se(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>se(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>se(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>se(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>se(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>se(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>se(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>se(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>se(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>se(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>se(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>se(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>se(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>se(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>se(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>se(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>se(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>se(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>se(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>se(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>se(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>se(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>se(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>se(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>se(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>se(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>se(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>se(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>se(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>se(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>se(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>se(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>se(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>se(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>se(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>se(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>se(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>se(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>se(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>se(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>se(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>se(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>se(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>se(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>se(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>se(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>se(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>se(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>se(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>se(()=>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:(()=>se(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>se(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>se(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>se(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>se(()=>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:(()=>se(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>se(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>se(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>se(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>se(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>se(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>se(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>se(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>se(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>se(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>se(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>se(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>se(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>se(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>se(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>se(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>se(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>se(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>se(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>se(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>se(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>se(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>se(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>se(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>se(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>se(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>se(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>se(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>se(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>se(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>se(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>se(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>se(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>se(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>se(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>se(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>se(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>se(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>se(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>se(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>se(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>se(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>se(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>se(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>se(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>se(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>se(()=>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:(()=>se(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>se(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>se(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>se(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>se(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>se(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>se(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>se(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>se(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>se(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>se(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>se(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>se(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>se(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>se(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>se(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>se(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>se(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>se(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>se(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>se(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>se(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>se(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>se(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>se(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>se(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>se(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>se(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>se(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>se(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>se(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>se(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>se(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>se(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>se(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>se(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>se(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>se(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>se(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>se(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>se(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>se(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>se(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>se(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>se(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>se(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>se(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>se(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>se(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>se(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>se(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>se(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>se(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>se(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>se(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>se(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>se(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>se(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>se(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>se(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>se(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>se(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>se(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>se(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>se(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>se(()=>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:(()=>se(()=>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:(()=>se(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>se(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>se(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>se(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>se(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>se(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>se(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>se(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>se(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>se(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>se(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>se(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>se(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>se(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>se(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>se(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>se(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>se(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>se(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>se(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>se(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>se(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>se(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>se(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>se(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>se(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>se(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>se(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>se(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>se(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>se(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>se(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>se(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>se(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>se(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>se(()=>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:(()=>se(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>se(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>se(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>se(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>se(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>se(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>se(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>se(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>se(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>se(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>se(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>se(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>se(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>se(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>se(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>se(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>se(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>se(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>se(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>se(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>se(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>se(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>se(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>se(()=>import("./zig-VOosw3JB.js"),[]))}],Gb=Object.fromEntries(Zf.map(e=>[e.id,e.import])),qb=Object.fromEntries(Zf.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),em={...Gb,...qb},Kb=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>se(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>se(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>se(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>se(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>se(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>se(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>se(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>se(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>se(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>se(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>se(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>se(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>se(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>se(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>se(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>se(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>se(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>se(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>se(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>se(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>se(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>se(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>se(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>se(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>se(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>se(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>se(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>se(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>se(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>se(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>se(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>se(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>se(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>se(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>se(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>se(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>se(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>se(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>se(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>se(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>se(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>se(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>se(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>se(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>se(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>se(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>se(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>se(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>se(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>se(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>se(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>se(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>se(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>se(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>se(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>se(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>se(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>se(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>se(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>se(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>se(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>se(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>se(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>se(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>se(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],Yb=Object.fromEntries(Kb.map(e=>[e.id,e.import]));var Xb=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function y8(){return 2147483648}function b8(){return typeof performance<"u"?performance.now():Date.now()}const v8=(e,t)=>e+(t-e%t)%t;async function _8(e){let t,n;const r={};function a(x){n=x,r.HEAPU8=new Uint8Array(x),r.HEAPU32=new Uint32Array(x)}function o(x,w,C){r.HEAPU8.copyWithin(x,w,w+C)}function 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=y8();if(x>C)return!1;for(let b=1;b<=4;b*=2){let _=w*(1+.2/b);_=Math.min(_,x+100663296);const S=Math.min(C,v8(Math.max(x,_),65536));if(c(S))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(x,w,C=1024){const b=w+C;let _=w;for(;x[_]&&!(_>=b);)++_;if(_-w>16&&x.buffer&&d)return d.decode(x.subarray(w,_));let S="";for(;w<_;){let v=x[w++];if(!(v&128)){S+=String.fromCharCode(v);continue}const k=x[w++]&63;if((v&224)===192){S+=String.fromCharCode((v&31)<<6|k);continue}const E=x[w++]&63;if((v&240)===224?v=(v&15)<<12|k<<6|E:v=(v&7)<<18|k<<12|E<<6|x[w++]&63,v<65536)S+=String.fromCharCode(v);else{const N=v-65536;S+=String.fromCharCode(55296|N>>10,56320|N&1023)}}return S}function m(x,w){return x?h(r.HEAPU8,x,w):""}const f={emscripten_get_now:b8,emscripten_memcpy_big:o,emscripten_resize_heap:u,fd_write:()=>0};async function g(){const w=await e({env:f,wasi_snapshot_preview1:f});t=w.memory,a(t.buffer),Object.assign(r,w),r.UTF8ToString=m}return await g(),r}var S8=Object.defineProperty,w8=(e,t,n)=>t in e?S8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bn=(e,t,n)=>w8(e,typeof t!="symbol"?t+"":t,n);let Wn=null;function C8(e){throw new Xb(e.UTF8ToString(e.getLastOnigError()))}class tm{constructor(t){Bn(this,"utf16Length"),Bn(this,"utf8Length"),Bn(this,"utf16Value"),Bn(this,"utf8Value"),Bn(this,"utf16OffsetToUtf8"),Bn(this,"utf8OffsetToUtf16");const n=t.length,r=tm._utf8ByteLength(t),a=r!==n,o=a?new Uint32Array(n+1):null;a&&(o[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 m=t.charCodeAt(h);let f=m,g=!1;if(m>=55296&&m<=56319&&h+1<n){const x=t.charCodeAt(h+1);x>=56320&&x<=57343&&(f=(m-55296<<10)+65536|x-56320,g=!0)}a&&(o[h]=d,g&&(o[h+1]=d),f<=127?c[d+0]=h:f<=2047?(c[d+0]=h,c[d+1]=h):f<=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)),f<=127?u[d++]=f:f<=2047?(u[d++]=192|(f&1984)>>>6,u[d++]=128|(f&63)>>>0):f<=65535?(u[d++]=224|(f&61440)>>>12,u[d++]=128|(f&4032)>>>6,u[d++]=128|(f&63)>>>0):(u[d++]=240|(f&1835008)>>>18,u[d++]=128|(f&258048)>>>12,u[d++]=128|(f&4032)>>>6,u[d++]=128|(f&63)>>>0),g&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=u,this.utf16OffsetToUtf8=o,this.utf8OffsetToUtf16=c}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const o=t.charCodeAt(r);let c=o,u=!1;if(o>=55296&&o<=56319&&r+1<a){const d=t.charCodeAt(r+1);d>=56320&&d<=57343&&(c=(o-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 nm=class As{constructor(t){if(Bn(this,"id",++As.LAST_ID),Bn(this,"_onigBinding"),Bn(this,"content"),Bn(this,"utf16Length"),Bn(this,"utf8Length"),Bn(this,"utf16OffsetToUtf8"),Bn(this,"utf8OffsetToUtf16"),Bn(this,"ptr"),!Wn)throw new Xb("Must invoke loadWasm first.");this._onigBinding=Wn,this.content=t;const n=new tm(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!As._sharedPtrInUse?(As._sharedPtr||(As._sharedPtr=Wn.omalloc(1e4)),As._sharedPtrInUse=!0,Wn.HEAPU8.set(n.utf8Value,As._sharedPtr),this.ptr=As._sharedPtr):this.ptr=n.createString(Wn)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===As._sharedPtr?As._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Bn(nm,"LAST_ID",0);Bn(nm,"_sharedPtr",0);Bn(nm,"_sharedPtrInUse",!1);let W2=nm;class k8{constructor(t){if(Bn(this,"_onigBinding"),Bn(this,"_ptr"),!Wn)throw new Xb("Must invoke loadWasm first.");const n=[],r=[];for(let u=0,d=t.length;u<d;u++){const h=new tm(t[u]);n[u]=h.createString(Wn),r[u]=h.utf8Length}const a=Wn.omalloc(4*t.length);Wn.HEAPU32.set(n,a/4);const o=Wn.omalloc(4*t.length);Wn.HEAPU32.set(r,o/4);const c=Wn.createOnigScanner(a,o,t.length);for(let u=0,d=t.length;u<d;u++)Wn.ofree(n[u]);Wn.ofree(o),Wn.ofree(a),c===0&&C8(Wn),this._onigBinding=Wn,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 W2(t);const o=this._findNextMatchSync(t,n,!1,a);return t.dispose(),o}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,r,a){const o=this._onigBinding,c=o.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(c===0)return null;const u=o.HEAPU32;let d=c/4;const h=u[d++],m=u[d++],f=[];for(let g=0;g<m;g++){const x=t.convertUtf8OffsetToUtf16(u[d++]),w=t.convertUtf8OffsetToUtf16(u[d++]);f[g]={start:x,end:w,length:w-x}}return{index:h,captureIndices:f}}}function j8(e){return typeof e.instantiator=="function"}function E8(e){return typeof e.default=="function"}function N8(e){return typeof e.data<"u"}function T8(e){return typeof Response<"u"&&e instanceof Response}function A8(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 lh;function Qb(e){if(lh)return lh;async function t(){Wn=await _8(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),j8(r)?r=await r.instantiator(n):E8(r)?r=await r.default(n):(N8(r)&&(r=r.data),T8(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await L8(r)(n):r=await R8(r)(n):A8(r)?r=await cx(r)(n):r instanceof WebAssembly.Module?r=await cx(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await cx(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return lh=t(),lh}function cx(e){return t=>WebAssembly.instantiate(e,t)}function L8(e){return t=>WebAssembly.instantiateStreaming(e,t)}function R8(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let G2;function D8(e){G2=e}function O8(){return G2}async function q2(e){return e&&await Qb(e),{createScanner(t){return new k8(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new W2(t)}}}const I8=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:q2,getDefaultWasmLoader:O8,loadWasm:Qb,setDefaultWasmLoader:D8},Symbol.toStringTag,{value:"Module"}));var K2=Wb({});V2(K2,I8);var sn=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function M8(e){return Jb(e)}function Jb(e){return Array.isArray(e)?P8(e):e instanceof RegExp?e:typeof e=="object"?B8(e):e}function P8(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Jb(e[n]);return t}function B8(e){let t={};for(let n in e)t[n]=Jb(e[n]);return t}function Y2(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function X2(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?X2(e.substring(0,e.length-1)):e.substr(~t+1)}var ux=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ch=class{static hasCaptures(e){return e===null?!1:(ux.lastIndex=0,ux.test(e))}static replaceCaptures(e,t,n){return e.replace(ux,(r,a,o,c)=>{let u=n[parseInt(a||o,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 Q2(e,t){return e<t?-1:e>t?1:0}function J2(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let a=0;a<n;a++){let o=Q2(e[a],t[a]);if(o!==0)return o}return 0}return n-r}function bC(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 Z2(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var eN=class{constructor(e){Le(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}},tf=class{constructor(e,t,n){Le(this,"_cachedMatchRoot",new eN(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(z8(e),t)}static createFromParsedTheme(e,t){return U8(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=>$8(e.parent,a.parentScopes));return r?new tN(r.fontStyle,r.foreground,r.background):null}},dx=class Bh{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Bh(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Bh(n,t[r]);return n}push(t){return new Bh(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 $8(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&&!F8(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function F8(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var tN=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function z8(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let a=0,o=t.length;a<o;a++){let c=t[a];if(!c.settings)continue;let u;if(typeof c.scope=="string"){let f=c.scope;f=f.replace(/^[,]+/,""),f=f.replace(/[,]+$/,""),u=f.split(",")}else Array.isArray(c.scope)?u=c.scope:u=[""];let d=-1;if(typeof c.settings.fontStyle=="string"){d=0;let f=c.settings.fontStyle.split(" ");for(let g=0,x=f.length;g<x;g++)switch(f[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"&&bC(c.settings.foreground)&&(h=c.settings.foreground);let m=null;typeof c.settings.background=="string"&&bC(c.settings.background)&&(m=c.settings.background);for(let f=0,g=u.length;f<g;f++){let w=u[f].trim().split(" "),C=w[w.length-1],b=null;w.length>1&&(b=w.slice(0,w.length-1),b.reverse()),n[r++]=new H8(C,b,a,d,h,m)}}return n}var H8=class{constructor(e,t,n,r,a,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=a,this.background=o}},sr=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(sr||{});function U8(e,t){e.sort((d,h)=>{let m=Q2(d.scope,h.scope);return m!==0||(m=J2(d.parentScopes,h.parentScopes),m!==0)?m: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 o=new V8(t),c=new tN(n,o.getId(r),o.getId(a)),u=new G8(new _y(0,null,-1,0,0),[]);for(let d=0,h=e.length;d<h;d++){let m=e[d];u.insert(0,m.scope,m.parentScopes,m.fontStyle,o.getId(m.foreground),o.getId(m.background))}return new tf(o,c,u)}var V8=class{constructor(e){Le(this,"_isFrozen");Le(this,"_lastColorId");Le(this,"_id2color");Le(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)}},W8=Object.freeze([]),_y=class nN{constructor(t,n,r,a,o){Le(this,"scopeDepth");Le(this,"parentScopes");Le(this,"fontStyle");Le(this,"foreground");Le(this,"background");this.scopeDepth=t,this.parentScopes=n||W8,this.fontStyle=r,this.foreground=a,this.background=o}clone(){return new nN(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)}},G8=class Sy{constructor(t,n=[],r={}){Le(this,"_rulesWithParentScopes");this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,a=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[a]===">"&&a++,!(r>=t.parentScopes.length||a>=n.parentScopes.length);){const o=n.parentScopes[a].length-t.parentScopes[r].length;if(o!==0)return o;r++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),a,o;if(r===-1?(a=t,o=""):(a=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(a))return this._children[a].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Sy._cmpBySpecificity),n}insert(t,n,r,a,o,c){if(n===""){this._doInsertHere(t,r,a,o,c);return}let u=n.indexOf("."),d,h;u===-1?(d=n,h=""):(d=n.substring(0,u),h=n.substring(u+1));let m;this._children.hasOwnProperty(d)?m=this._children[d]:(m=new Sy(this._mainRule.clone(),_y.cloneArr(this._rulesWithParentScopes)),this._children[d]=m),m.insert(t+1,h,r,a,o,c)}_doInsertHere(t,n,r,a,o){if(n===null){this._mainRule.acceptOverwrite(t,r,a,o);return}for(let c=0,u=this._rulesWithParentScopes.length;c<u;c++){let d=this._rulesWithParentScopes[c];if(J2(d.parentScopes,n)===0){d.acceptOverwrite(t,r,a,o);return}}r===-1&&(r=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new _y(t,n,r,a,o))}},no=class Qr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Qr.getLanguageId(t),r=Qr.getTokenType(t),a=Qr.getFontStyle(t),o=Qr.getForeground(t),c=Qr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:a,foreground:o,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,o,c,u){let d=Qr.getLanguageId(t),h=Qr.getTokenType(t),m=Qr.containsBalancedBrackets(t)?1:0,f=Qr.getFontStyle(t),g=Qr.getForeground(t),x=Qr.getBackground(t);return n!==0&&(d=n),r!==8&&(h=r),a!==null&&(m=a?1:0),o!==-1&&(f=o),c!==0&&(g=c),u!==0&&(x=u),(d<<0|h<<8|m<<10|f<<11|g<<15|x<<24)>>>0}};function nf(e,t){const n=[],r=q8(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 o(){if(a==="-"){a=r.next();const d=o();return h=>!!d&&!d(h)}if(a==="("){a=r.next();const d=u();return a===")"&&(a=r.next()),d}if(vC(a)){const d=[];do d.push(a),a=r.next();while(vC(a));return h=>t(d,h)}return null}function c(){const d=[];let h=o();for(;h;)d.push(h),h=o();return m=>d.every(f=>f(m))}function u(){const d=[];let h=c();for(;h&&(d.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=c()}return m=>d.some(f=>f(m))}}function vC(e){return!!e&&!!e.match(/[\w\.:]+/)}function q8(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 rN(e){typeof e.dispose=="function"&&e.dispose()}var bu=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},K8=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Y8=class{constructor(){Le(this,"_references",[]);Le(this,"_seenReferenceKeys",new Set);Le(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))}},X8=class{constructor(e,t){Le(this,"seenFullScopeRequests",new Set);Le(this,"seenPartialScopeRequests",new Set);Le(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new bu(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new Y8;for(const n of e)Q8(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof bu){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 Q8(e,t,n,r){const a=n.lookup(e.scopeName);if(!a){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const o=n.lookup(t);e instanceof bu?$h({baseGrammar:o,selfGrammar:a},r):wy(e.ruleName,{baseGrammar:o,selfGrammar:a,repository:a.repository},r);const c=n.injections(e.scopeName);if(c)for(const u of c)r.add(new bu(u))}function wy(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];rf([r],t,n)}}function $h(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&rf(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&rf(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function rf(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?Y2({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&rf(r.patterns,{...t,repository:a},n);const o=r.include;if(!o)continue;const c=sN(o);switch(c.kind){case 0:$h({...t,selfGrammar:t.baseGrammar},n);break;case 1:$h(t,n);break;case 2:wy(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?wy(c.ruleName,d,n):$h(d,n)}else c.kind===4?n.add(new K8(c.scopeName,c.ruleName)):n.add(new bu(c.scopeName));break}}}var J8=class{constructor(){Le(this,"kind",0)}},Z8=class{constructor(){Le(this,"kind",1)}},e$=class{constructor(e){Le(this,"kind",2);this.ruleName=e}},t$=class{constructor(e){Le(this,"kind",3);this.scopeName=e}},n$=class{constructor(e,t){Le(this,"kind",4);this.scopeName=e,this.ruleName=t}};function sN(e){if(e==="$base")return new J8;if(e==="$self")return new Z8;const t=e.indexOf("#");if(t===-1)return new t$(e);if(t===0)return new e$(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new n$(n,r)}}var r$=/\\(\d+)/,_C=/\\(\d+)/g,s$=-1,iN=-2;var Du=class{constructor(e,t,n,r){Le(this,"$location");Le(this,"id");Le(this,"_nameIsCapturing");Le(this,"_name");Le(this,"_contentNameIsCapturing");Le(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=ch.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=ch.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${X2(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:ch.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ch.replaceCaptures(this._contentName,e,t)}},i$=class extends Du{constructor(t,n,r,a,o){super(t,n,r,a);Le(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=o}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,a){throw new Error("Not supported!")}},a$=class extends Du{constructor(t,n,r,a,o){super(t,n,r,null);Le(this,"_match");Le(this,"captures");Le(this,"_cachedCompiledPatterns");this._match=new vu(a,this.id),this.captures=o,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new _u,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},SC=class extends Du{constructor(t,n,r,a,o){super(t,n,r,a);Le(this,"hasMissingPatterns");Le(this,"patterns");Le(this,"_cachedCompiledPatterns");this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new _u,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Cy=class extends Du{constructor(t,n,r,a,o,c,u,d,h,m){super(t,n,r,a);Le(this,"_begin");Le(this,"beginCaptures");Le(this,"_end");Le(this,"endHasBackReferences");Le(this,"endCaptures");Le(this,"applyEndPatternLast");Le(this,"hasMissingPatterns");Le(this,"patterns");Le(this,"_cachedCompiledPatterns");this._begin=new vu(o,this.id),this.beginCaptures=c,this._end=new vu(u||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=h||!1,this.patterns=m.patterns,this.hasMissingPatterns=m.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new _u;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}},sf=class extends Du{constructor(t,n,r,a,o,c,u,d,h){super(t,n,r,a);Le(this,"_begin");Le(this,"beginCaptures");Le(this,"whileCaptures");Le(this,"_while");Le(this,"whileHasBackReferences");Le(this,"hasMissingPatterns");Le(this,"patterns");Le(this,"_cachedCompiledPatterns");Le(this,"_cachedCompiledWhilePatterns");this._begin=new vu(o,this.id),this.beginCaptures=c,this.whileCaptures=d,this._while=new vu(u,iN),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 _u;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 _u,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},aN=class er{static createCaptureRule(t,n,r,a,o){return t.registerRule(c=>new i$(n,c,r,a,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new a$(t.$vscodeTextmateLocation,t.id,t.name,t.match,er._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Y2({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new SC(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,er._compilePatterns(o,n,r))}return t.while?new sf(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,er._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,er._compileCaptures(t.whileCaptures||t.captures,n,r),er._compilePatterns(t.patterns,n,r)):new Cy(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,er._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,er._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,er._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let a=[];if(t){let o=0;for(const c in t){if(c==="$vscodeTextmateLocation")continue;const u=parseInt(c,10);u>o&&(o=u)}for(let c=0;c<=o;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=er.getCompiledRuleId(t[c],n,r)),a[u]=er.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 o=0,c=t.length;o<c;o++){const u=t[o];let d=-1;if(u.include){const h=sN(u.include);switch(h.kind){case 0:case 1:d=er.getCompiledRuleId(r[u.include],n,r);break;case 2:let m=r[h.ruleName];m&&(d=er.getCompiledRuleId(m,n,r));break;case 3:case 4:const f=h.scopeName,g=h.kind===4?h.ruleName:null,x=n.getExternalGrammar(f,r);if(x)if(g){let w=x.repository[g];w&&(d=er.getCompiledRuleId(w,n,x.repository))}else d=er.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else d=er.getCompiledRuleId(u,n,r);if(d!==-1){const h=n.getRule(d);let m=!1;if((h instanceof SC||h instanceof Cy||h instanceof sf)&&h.hasMissingPatterns&&h.patterns.length===0&&(m=!0),m)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},vu=class oN{constructor(t,n){Le(this,"source");Le(this,"ruleId");Le(this,"hasAnchor");Le(this,"hasBackReferences");Le(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,o=[],c=!1;for(let u=0;u<r;u++)if(t.charAt(u)==="\\"&&u+1<r){const h=t.charAt(u+1);h==="z"?(o.push(t.substring(a,u)),o.push("$(?!\\n)(?<!\\n)"),a=u+2):(h==="A"||h==="G")&&(c=!0),u++}this.hasAnchor=c,a===0?this.source=t:(o.push(t.substring(a,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=r$.test(this.source):this.hasBackReferences=!1}clone(){return new oN(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 _C.lastIndex=0,this.source.replace(_C,(a,o)=>Z2(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],a=[],o,c,u,d;for(o=0,c=this.source.length;o<c;o++)u=this.source.charAt(o),t[o]=u,n[o]=u,r[o]=u,a[o]=u,u==="\\"&&o+1<c&&(d=this.source.charAt(o+1),d==="A"?(t[o+1]="￿",n[o+1]="￿",r[o+1]="A",a[o+1]="A"):d==="G"?(t[o+1]="￿",n[o+1]="G",r[o+1]="￿",a[o+1]="G"):(t[o+1]=d,n[o+1]=d,r[o+1]=d,a[o+1]=d),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:a.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},_u=class{constructor(){Le(this,"_items");Le(this,"_hasAnchors");Le(this,"_cached");Le(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 wC(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 wC(e,r,this._items.map(a=>a.ruleId))}},wC=class{constructor(e,t,n){Le(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}},hx=class{constructor(e,t){this.languageId=e,this.tokenType=t}},pi,o$=(pi=class{constructor(t,n){Le(this,"_defaultAttributes");Le(this,"_embeddedLanguagesMatcher");Le(this,"_getBasicScopeAttributes",new eN(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new hx(n,r)}));this._defaultAttributes=new hx(t,8),this._embeddedLanguagesMatcher=new l$(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?pi._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(pi.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!")}},Le(pi,"_NULL_SCOPE_METADATA",new hx(0,0)),Le(pi,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),pi),l$=class{constructor(e){Le(this,"values");Le(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>Z2(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])}},CC=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function lN(e,t,n,r,a,o,c,u){const d=t.content.length;let h=!1,m=-1;if(c){const x=c$(e,t,n,r,a,o);a=x.stack,r=x.linePos,n=x.isFirstLine,m=x.anchorPosition}const f=Date.now();for(;!h;){if(u!==0&&Date.now()-f>u)return new CC(a,!0);g()}return new CC(a,!1);function g(){const x=u$(e,t,n,r,a,m);if(!x){o.produce(a,d),h=!0;return}const w=x.captureIndices,C=x.matchedRuleId,b=w&&w.length>0?w[0].end>r:!1;if(C===s$){const _=a.getRule(e);o.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),Xc(e,t,n,a,o,_.endCaptures,w),o.produce(a,w[0].end);const S=a;if(a=a.parent,m=S.getAnchorPos(),!b&&S.getEnterPos()===r){a=S,o.produce(a,d),h=!0;return}}else{const _=e.getRule(C);o.produce(a,w[0].start);const S=a,v=_.getName(t.content,w),k=a.contentNameScopesList.pushAttributed(v,e);if(a=a.push(C,r,m,w[0].end===d,null,k,k),_ instanceof Cy){const E=_;Xc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),m=w[0].end;const N=E.getContentName(t.content,w),L=k.pushAttributed(N,e);if(a=a.withContentNameScopesList(L),E.endHasBackReferences&&(a=a.withEndRule(E.getEndWithResolvedBackReferences(t.content,w))),!b&&S.hasSameRuleAs(a)){a=a.pop(),o.produce(a,d),h=!0;return}}else if(_ instanceof sf){const E=_;Xc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),m=w[0].end;const N=E.getContentName(t.content,w),L=k.pushAttributed(N,e);if(a=a.withContentNameScopesList(L),E.whileHasBackReferences&&(a=a.withEndRule(E.getWhileWithResolvedBackReferences(t.content,w))),!b&&S.hasSameRuleAs(a)){a=a.pop(),o.produce(a,d),h=!0;return}}else if(Xc(e,t,n,a,o,_.captures,w),o.produce(a,w[0].end),a=a.pop(),!b){a=a.safePop(),o.produce(a,d),h=!0;return}}w[0].end>r&&(r=w[0].end,n=!1)}}function c$(e,t,n,r,a,o){let c=a.beginRuleCapturedEOL?0:-1;const u=[];for(let d=a;d;d=d.pop()){const h=d.getRule(e);h instanceof sf&&u.push({rule:h,stack:d})}for(let d=u.pop();d;d=u.pop()){const{ruleScanner:h,findOptions:m}=f$(d.rule,e,d.stack.endRule,n,r===c),f=h.findNextMatchSync(t,r,m);if(f){if(f.ruleId!==iN){a=d.stack.pop();break}f.captureIndices&&f.captureIndices.length&&(o.produce(d.stack,f.captureIndices[0].start),Xc(e,t,n,d.stack,o,d.rule.whileCaptures,f.captureIndices),o.produce(d.stack,f.captureIndices[0].end),c=f.captureIndices[0].end,f.captureIndices[0].end>r&&(r=f.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:c,isFirstLine:n}}function u$(e,t,n,r,a,o){const c=d$(e,t,n,r,a,o),u=e.getInjections();if(u.length===0)return c;const d=h$(u,e,t,n,r,a,o);if(!d)return c;if(!c)return d;const h=c.captureIndices[0].start,m=d.captureIndices[0].start;return m<h||d.priorityMatch&&m===h?d:c}function d$(e,t,n,r,a,o){const c=a.getRule(e),{ruleScanner:u,findOptions:d}=cN(c,e,a.endRule,n,r===o),h=u.findNextMatchSync(t,r,d);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function h$(e,t,n,r,a,o,c){let u=Number.MAX_VALUE,d=null,h,m=0;const f=o.contentNameScopesList.getScopeNames();for(let g=0,x=e.length;g<x;g++){const w=e[g];if(!w.matcher(f))continue;const C=t.getRule(w.ruleId),{ruleScanner:b,findOptions:_}=cN(C,t,null,r,a===c),S=b.findNextMatchSync(n,a,_);if(!S)continue;const v=S.captureIndices[0].start;if(!(v>=u)&&(u=v,d=S.captureIndices,h=S.ruleId,m=w.priority,u===a))break}return d?{priorityMatch:m===-1,captureIndices:d,matchedRuleId:h}:null}function cN(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function f$(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function Xc(e,t,n,r,a,o,c){if(o.length===0)return;const u=t.content,d=Math.min(o.length,c.length),h=[],m=c[0].end;for(let f=0;f<d;f++){const g=o[f];if(g===null)continue;const x=c[f];if(x.length===0)continue;if(x.start>m)break;for(;h.length>0&&h[h.length-1].endPos<=x.start;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?a.produceFromScopes(h[h.length-1].scopes,x.start):a.produce(r,x.start),g.retokenizeCapturedWithRuleId){const C=g.getName(u,c),b=r.contentNameScopesList.pushAttributed(C,e),_=g.getContentName(u,c),S=b.pushAttributed(_,e),v=r.push(g.retokenizeCapturedWithRuleId,x.start,-1,!1,null,b,S),k=e.createOnigString(u.substring(0,x.end));lN(e,k,n&&x.start===0,x.start,v,a,!1,0),rN(k);continue}const w=g.getName(u,c);if(w!==null){const b=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);h.push(new m$(b,x.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var m$=class{constructor(e,t){Le(this,"scopes");Le(this,"endPos");this.scopes=e,this.endPos=t}};function p$(e,t,n,r,a,o,c,u){return new x$(e,t,n,r,a,o,c,u)}function kC(e,t,n,r,a){const o=nf(t,af),c=aN.getCompiledRuleId(n,r,a.repository);for(const u of o)e.push({debugSelector:t,matcher:u.matcher,ruleId:c,grammar:a,priority:u.priority})}function af(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(g$(t[a],r))return n=a+1,!0;return!1})}function g$(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 x$=class{constructor(e,t,n,r,a,o,c,u){Le(this,"_rootId");Le(this,"_lastRuleId");Le(this,"_ruleId2desc");Le(this,"_includedGrammars");Le(this,"_grammarRepository");Le(this,"_grammar");Le(this,"_injections");Le(this,"_basicScopeAttributesProvider");Le(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=u,this._basicScopeAttributesProvider=new o$(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=c,this._grammar=jC(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const h=nf(d,af);for(const m of h)this._tokenTypeMatchers.push({matcher:m.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)kC(t,c,a[c],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(c=>{const u=this.getExternalGrammar(c);if(u){const d=u.injectionSelector;d&&kC(t,d,u,this,u)}})}return t.sort((a,o)=>a.priority-o.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=jC(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=aN.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===ky.NULL){a=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),m=this.themeProvider.getDefaults(),f=no.set(0,h.languageId,h.tokenType,null,m.fontStyle,m.foregroundId,m.backgroundId),g=this.getRule(this._rootId).getName(null,null);let x;g?x=ru.createRootAndLookUpScopeName(g,f,this):x=ru.createRoot("unknown",f),t=new ky(null,this._rootId,-1,-1,!1,null,x,x)}else a=!1,t.reset();e=e+`
97
+ `;const o=this.createOnigString(e),c=o.content.length,u=new b$(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=lN(this,o,a,0,t,u,!0,r);return rN(o),{lineLength:c,lineTokens:u,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function jC(e,t){return e=M8(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 ru=class Ls{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,a=(t==null?void 0:t.scopePath)??null;for(const o of n)a=dx.push(a,o.scopeNames),r=new Ls(r,a,o.encodedTokenAttributes);return r}static createRoot(t,n){return new Ls(null,new dx(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),o=new dx(null,t),c=r.themeProvider.themeMatch(o),u=Ls.mergeAttributes(n,a,c);return new Ls(null,o,u)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ls.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let a=-1,o=0,c=0;return r!==null&&(a=r.fontStyle,o=r.foregroundId,c=r.backgroundId),no.set(t,n.languageId,n.tokenType,null,a,o,c)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Ls._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const o of r)a=Ls._pushAttributed(a,o,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),o=t.scopePath.push(n),c=r.themeProvider.themeMatch(o),u=Ls.mergeAttributes(t.tokenAttributes,a,c);return new Ls(t,o,u)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((a=r.parent)==null?void 0:a.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},es,ky=(es=class{constructor(t,n,r,a,o,c,u,d){Le(this,"_stackElementBrand");Le(this,"_enterPos");Le(this,"_anchorPos");Le(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=o,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:es._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?ru.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(){es._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,o,c,u){return new es(this,t,n,r,a,o,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 es(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=ru.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new es(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,ru.fromExtension(r,n.contentNameScopesList))}},Le(es,"NULL",new es(null,0,0,0,!1,null,null,null)),es),y$=class{constructor(e,t){Le(this,"balancedBracketScopes");Le(this,"unbalancedBracketScopes");Le(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):nf(n,af).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>nf(n,af).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}},b$=class{constructor(e,t,n,r){Le(this,"_emitBinaryTokens");Le(this,"_lineText");Le(this,"_tokens");Le(this,"_binaryTokens");Le(this,"_lastTokenEndIndex");Le(this,"_tokenTypeOverrides");this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var r;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let a=(e==null?void 0:e.tokenAttributes)??0,o=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const c=(e==null?void 0:e.getScopeNames())??[];for(const u of this._tokenTypeOverrides)u.matcher(c)&&(a=no.set(a,0,u.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(c))}if(o&&(a=no.set(a,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===a){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(a),this._lastTokenEndIndex=t;return}const n=(e==null?void 0:e.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,a=this._binaryTokens.length;r<a;r++)n[r]=this._binaryTokens[r];return n}},v$=class{constructor(e,t){Le(this,"_grammars",new Map);Le(this,"_rawGrammars",new Map);Le(this,"_injectionGrammars",new Map);Le(this,"_theme");this._onigLib=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,a){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,p$(e,o,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},_$=class{constructor(t){Le(this,"_options");Le(this,"_syncRegistry");Le(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new v$(tf.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(tf.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 y$(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,o){const c=new X8(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,o)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,a=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,a)}_grammarForScopeName(t,n=0,r=null,a=null,o=null){return this._syncRegistry.grammarForScopeName(t,n,r,a,o)}},jy=ky.NULL;function of(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[a,o]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof o=="string"?n[a]=o:a===r&&Object.assign(n,o);return n}function ca(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function S$(e){return Array.isArray(e)?e:[e]}async function uN(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function rm(e){return!e||["plaintext","txt","text","plain"].includes(e)}function dN(e){return e==="ansi"||rm(e)}function sm(e){return e==="none"}function hN(e){return sm(e)}const w$=/(\r?\n)/g;function im(e,t=!1){var o;if(e.length===0)return[["",0]];const n=e.split(w$);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+=((o=n[c+1])==null?void 0:o.length)||0}return a}const EC={light:"#333333",dark:"#bbbbbb"},NC={light:"#fffffe",dark:"#1e1e1e"},TC="__shiki_resolved";function Zb(e){var u,d,h,m,f;if(e!=null&&e[TC])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&&((m=t==null?void 0:t.colors)!=null&&m["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?EC.light:EC.dark),n||(n=t.type==="light"?NC.light:NC.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let a=0;const o=new Map;function c(g){var w;if(o.has(g))return o.get(g);a+=1;const x=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${x}`]?c(g):(o.set(g,x),x)}t.settings=t.settings.map(g=>{var b,_;const x=((b=g.settings)==null?void 0:b.foreground)&&!g.settings.foreground.startsWith("#"),w=((_=g.settings)==null?void 0:_.background)&&!g.settings.background.startsWith("#");if(!x&&!w)return g;const C={...g,settings:{...g.settings}};if(x){const S=c(g.settings.foreground);t.colorReplacements[S]=g.settings.foreground,C.settings.foreground=S}if(w){const S=c(g.settings.background);t.colorReplacements[S]=g.settings.background,C.settings.background=S}return C});for(const g of Object.keys(t.colors||{}))if((g==="editor.foreground"||g==="editor.background"||g.startsWith("terminal.ansi"))&&!((f=t.colors[g])!=null&&f.startsWith("#"))){const x=c(t.colors[g]);t.colorReplacements[x]=t.colors[g],t.colors[g]=x}return Object.defineProperty(t,TC,{enumerable:!1,writable:!1,value:!0}),t}async function fN(e){return[...new Set((await Promise.all(e.filter(t=>!dN(t)).map(async t=>await uN(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function mN(e){return(await Promise.all(e.map(async t=>hN(t)?null:Zb(await uN(t))))).filter(t=>!!t)}function pN(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 sn(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var C$=class extends _${constructor(t,n,r,a={}){super(t);Le(this,"_resolver");Le(this,"_themes");Le(this,"_langs");Le(this,"_alias");Le(this,"_resolvedThemes",new Map);Le(this,"_resolvedGrammars",new Map);Le(this,"_langMap",new Map);Le(this,"_langGraph",new Map);Le(this,"_textmateThemeCache",new WeakMap);Le(this,"_loadedThemesCache",null);Le(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=a,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Zb(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=tf.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=pN(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var o,c,u,d;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(h=>{var m;return(m=h.embeddedLangsLazy)==null?void 0:m.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(c=(o=this._syncRegistry)==null?void 0:o._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,o])=>!o);if(r.length){const a=n.filter(([o,c])=>{var u;return c?(u=c.embeddedLanguages||c.embeddedLangs)==null?void 0:u.some(d=>r.map(([h])=>h).includes(d)):!1}).filter(o=>!r.includes(o));throw new sn(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${a.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[a,o]of n)this._resolver.addLanguage(o);for(const[a,o]of n)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const n=t.embeddedLanguages??t.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}},k$=class{constructor(e,t){Le(this,"_langs",new Map);Le(this,"_scopeToLang",new Map);Le(this,"_injections",new Map);Le(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 Hc=0;function j$(e){Hc+=1,e.warnings!==!1&&Hc>=10&&Hc%10===0&&console.warn(`[Shiki] ${Hc} 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 sn("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Zb),a=new C$(new k$(e.engine,n),r,n,e.langAlias);let o;function c(S){return pN(S,e.langAlias)}function u(S){b();const v=a.getGrammar(typeof S=="string"?S:S.name);if(!v)throw new sn(`Language \`${S}\` not found, you may need to load it first`);return v}function d(S){if(S==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};b();const v=a.getTheme(S);if(!v)throw new sn(`Theme \`${S}\` not found, you may need to load it first`);return v}function h(S){b();const v=d(S);return o!==S&&(a.setTheme(v),o=S),{theme:v,colorMap:a.getColorMap()}}function m(){return b(),a.getLoadedThemes()}function f(){return b(),a.getLoadedLanguages()}function g(...S){b(),a.loadLanguages(S.flat(1))}async function x(...S){return g(await fN(S))}function w(...S){b();for(const v of S.flat(1))a.loadTheme(v)}async function C(...S){return b(),w(await mN(S))}function b(){if(t)throw new sn("Shiki instance has been disposed")}function _(){t||(t=!0,a.dispose(),Hc-=1)}return{setTheme:h,getTheme:d,getLanguage:u,getLoadedThemes:m,getLoadedLanguages:f,resolveLangAlias:c,loadLanguage:x,loadLanguageSync:g,loadTheme:C,loadThemeSync:w,dispose:_,[Symbol.dispose]:_}}async function E$(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([mN(e.themes||[]),fN(e.langs||[]),e.engine]);return j$({...e,themes:t,langs:n,engine:r})}const gN=new WeakMap;function am(e,t){gN.set(e,t)}function Su(e){return gN.get(e)}var om=class xN{constructor(...t){Le(this,"_stacks",{});Le(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 xN(Object.fromEntries(S$(n).map(r=>[r,jy])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return N$(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function N$(e){const t=[],n=new Set;function r(a){var c;if(n.has(a))return;n.add(a);const o=(c=a==null?void 0:a.nameScopesList)==null?void 0:c.scopeName;o&&t.push(o),a.parent&&r(a.parent)}return r(e),t}function T$(e,t){if(!(e instanceof om))throw new sn("Invalid grammar state");return e.getInternalStack(t)}const A$=/,/,L$=/ /;function yN(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(rm(e.resolveLangAlias(n.lang||"text"))||sm(r))return im(t).map(u=>[{content:u[0],offset:u[1]}]);const{theme:a,colorMap:o}=e.setTheme(r),c=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==c.name)throw new sn(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${c.name}"`);if(!n.grammarState.themes.includes(a.name))throw new sn(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return D$(t,c,a,o,n)}function R$(...e){if(e.length===2)return Su(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:o=t.getLoadedThemes()[0]}=r;if(rm(a)||sm(o))throw new sn("Plain language does not have grammar state");if(a==="ansi")throw new sn("ANSI language does not have grammar state");const{theme:c,colorMap:u}=t.setTheme(o),d=t.getLanguage(a);return new om(ev(n,d,c,u,r).stateStack,d.name,c.name)}function D$(e,t,n,r,a){const o=ev(e,t,n,r,a),c=new om(o.stateStack,t.name,n.name);return am(o.tokens,c),o.tokens}function ev(e,t,n,r,a){const o=of(n,a),{tokenizeMaxLineLength:c=0,tokenizeTimeLimit:u=500,includeExplanation:d=!1}=a,h=im(e);let m=a.grammarState?T$(a.grammarState,n.name)??jy:a.grammarContextCode!=null?ev(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:jy,f=[];const g=[];for(let x=0,w=h.length;x<w;x++){const[C,b]=h[x];if(C===""){f=[],g.push([]);continue}if(c>0&&C.length>=c){f=[],g.push([{content:C,offset:b,color:"",fontStyle:0}]);continue}let _,S,v;d&&d!=="tokenType"&&(_=t.tokenizeLine(C,m,u),S=_.tokens,v=0);const k=t.tokenizeLine2(C,m,u),E=k.tokens.length/2;for(let N=0;N<E;N++){const L=k.tokens[2*N],A=N+1<E?k.tokens[2*N+2]:C.length;if(L===A)continue;const O=k.tokens[2*N+1],I=ca(r[no.getForeground(O)],o),F=no.getFontStyle(O),B={content:C.substring(L,A),offset:b+L,color:I,fontStyle:F};if(d==="tokenType")B.type=no.getTokenType(O);else if(d){const z=[];if(d!=="scopeName")for(const q of n.settings){let W;switch(typeof q.scope){case"string":W=q.scope.split(A$).map(ee=>ee.trim());break;case"object":W=q.scope;break;default:continue}z.push({settings:q,selectors:W.map(ee=>ee.split(L$))})}B.explanation=[];let Y=0;for(;L+Y<A;){const q=S[v],W=C.substring(q.startIndex,q.endIndex);Y+=W.length,B.explanation.push({content:W,scopes:d==="scopeName"?O$(q.scopes):I$(z,q.scopes)}),v+=1}}f.push(B)}g.push(f),f=[],m=k.ruleStack}return{tokens:g,stateStack:m}}function O$(e){return e.map(t=>({scopeName:t}))}function I$(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const o=t[r];n[r]={scopeName:o,themeMatches:P$(e,o,t.slice(0,r))}}return n}function AC(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function M$(e,t,n){if(!AC(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)AC(e[r],n[a])&&(r-=1),a-=1;return r===-1}function P$(e,t,n){const r=[];for(const{selectors:a,settings:o}of e)for(const c of a)if(M$(c,t,n)){r.push(o);break}return r}function bN(e,t,n,r=yN){const a=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),o=a.map(h=>{const m=r(e,t,{...n,theme:h.theme});return{tokens:m,state:Su(m),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),c=B$(...o.map(h=>h.tokens)),u=c[0].map((h,m)=>h.map((f,g)=>{const x={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=f.explanation),c.forEach((w,C)=>{const{content:b,explanation:_,offset:S,...v}=w[m][g];x.variants[a[C].color]=v}),x})),d=o[0].state?new om(Object.fromEntries(o.map(h=>{var m;return[h.theme,(m=h.state)==null?void 0:m.getInternalStack(h.theme)]})),o[0].state.lang):void 0;return d&&am(u,d),u}function B$(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const a=e.map(d=>d[r]),o=t.map(()=>[]);t.forEach((d,h)=>d.push(o[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 m=u[h];m.content.length===d?(o[h].push(m),c[h]+=1,u[h]=a[h][c[h]]):(o[h].push({...m,content:m.content.slice(0,d)}),u[h]={...m,content:m.content.slice(d),offset:m.offset+d})}}}return t}const $$=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Ou{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ou.prototype.normal={};Ou.prototype.property={};Ou.prototype.space=void 0;function vN(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ou(n,r,t)}function Ey(e){return e.toLowerCase()}class kr{constructor(t,n){this.attribute=n,this.property=t}}kr.prototype.attribute="";kr.prototype.booleanish=!1;kr.prototype.boolean=!1;kr.prototype.commaOrSpaceSeparated=!1;kr.prototype.commaSeparated=!1;kr.prototype.defined=!1;kr.prototype.mustUseProperty=!1;kr.prototype.number=!1;kr.prototype.overloadedBoolean=!1;kr.prototype.property="";kr.prototype.spaceSeparated=!1;kr.prototype.space=void 0;let F$=0;const yt=uo(),In=uo(),Ny=uo(),qe=uo(),en=uo(),ro=uo(),Or=uo();function uo(){return 2**++F$}const Ty=Object.freeze(Object.defineProperty({__proto__:null,boolean:yt,booleanish:In,commaOrSpaceSeparated:Or,commaSeparated:ro,number:qe,overloadedBoolean:Ny,spaceSeparated:en},Symbol.toStringTag,{value:"Module"})),fx=Object.keys(Ty);class tv extends kr{constructor(t,n,r,a){let o=-1;if(super(t,n),LC(this,"space",a),typeof r=="number")for(;++o<fx.length;){const c=fx[o];LC(this,fx[o],(r&Ty[c])===Ty[c])}}}tv.prototype.defined=!0;function LC(e,t,n){n&&(e[t]=n)}function Bl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new tv(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Ey(r)]=r,n[Ey(o.attribute)]=r}return new Ou(t,n,e.space)}const _N=Bl({properties:{ariaActiveDescendant:null,ariaAtomic:In,ariaAutoComplete:null,ariaBusy:In,ariaChecked:In,ariaColCount:qe,ariaColIndex:qe,ariaColSpan:qe,ariaControls:en,ariaCurrent:null,ariaDescribedBy:en,ariaDetails:null,ariaDisabled:In,ariaDropEffect:en,ariaErrorMessage:null,ariaExpanded:In,ariaFlowTo:en,ariaGrabbed:In,ariaHasPopup:null,ariaHidden:In,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:en,ariaLevel:qe,ariaLive:null,ariaModal:In,ariaMultiLine:In,ariaMultiSelectable:In,ariaOrientation:null,ariaOwns:en,ariaPlaceholder:null,ariaPosInSet:qe,ariaPressed:In,ariaReadOnly:In,ariaRelevant:null,ariaRequired:In,ariaRoleDescription:en,ariaRowCount:qe,ariaRowIndex:qe,ariaRowSpan:qe,ariaSelected:In,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 SN(e,t){return t in e?e[t]:t}function wN(e,t){return SN(e,t.toLowerCase())}const z$=Bl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ro,acceptCharset:en,accessKey:en,action:null,allow:null,allowFullScreen:yt,allowPaymentRequest:yt,allowUserMedia:yt,alpha:yt,alt:null,as:null,async:yt,autoCapitalize:null,autoComplete:en,autoFocus:yt,autoPlay:yt,blocking:en,capture:null,charSet:null,checked:yt,cite:null,className:en,closedBy:null,colorSpace:null,cols:qe,colSpan:qe,command:null,commandFor:null,content:null,contentEditable:In,controls:yt,controlsList:en,coords:qe|ro,crossOrigin:null,data:null,dateTime:null,decoding:null,default:yt,defer:yt,dir:null,dirName:null,disabled:yt,download:Ny,draggable:In,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:yt,formTarget:null,headers:en,height:qe,hidden:Ny,high:qe,href:null,hrefLang:null,htmlFor:en,httpEquiv:en,id:null,imageSizes:null,imageSrcSet:null,inert:yt,inputMode:null,integrity:null,is:null,isMap:yt,itemId:null,itemProp:en,itemRef:en,itemScope:yt,itemType:en,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:yt,low:qe,manifest:null,max:null,maxLength:qe,media:null,method:null,min:null,minLength:qe,multiple:yt,muted:yt,name:null,nonce:null,noModule:yt,noValidate:yt,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:yt,optimum:qe,pattern:null,ping:en,placeholder:null,playsInline:yt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:yt,referrerPolicy:null,rel:en,required:yt,reversed:yt,rows:qe,rowSpan:qe,sandbox:en,scope:null,scoped:yt,seamless:yt,selected:yt,shadowRootClonable:yt,shadowRootCustomElementRegistry:yt,shadowRootDelegatesFocus:yt,shadowRootMode:null,shadowRootSerializable:yt,shape:null,size:qe,sizes:null,slot:null,span:qe,spellCheck:In,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:yt,useMap:null,value:In,width:qe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:en,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:yt,declare:yt,event:null,face:null,frame:null,frameBorder:null,hSpace:qe,leftMargin:qe,link:null,longDesc:null,lowSrc:null,marginHeight:qe,marginWidth:qe,noResize:yt,noHref:yt,noShade:yt,noWrap:yt,object:null,profile:null,prompt:null,rev:null,rightMargin:qe,rules:null,scheme:null,scrolling:In,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:yt,disablePictureInPicture:yt,disableRemotePlayback:yt,exportParts:ro,part:en,prefix:null,property:null,results:qe,security:null,unselectable:null},space:"html",transform:wN}),H$=Bl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Or,accentHeight: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:en,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:yt,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:ro,g2:ro,glyphName:ro,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:Or,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:en,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:qe,pointsAtY:qe,pointsAtZ:qe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Or,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Or,rev:Or,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Or,requiredFeatures:Or,requiredFonts:Or,requiredFormats:Or,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant: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:Or,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:Or,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:Or,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:SN}),CN=Bl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),kN=Bl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wN}),jN=Bl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),U$=/[A-Z]/g,RC=/-[a-z]/g,V$=/^data[-\w.:]+$/i;function W$(e,t){const n=Ey(t);let r=t,a=kr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&V$.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(RC,q$);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!RC.test(o)){let c=o.replace(U$,G$);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=tv}return new a(r,t)}function G$(e){return"-"+e.toLowerCase()}function q$(e){return e.charAt(1).toUpperCase()}const K$=vN([_N,z$,CN,kN,jN],"html"),EN=vN([_N,H$,CN,kN,jN],"svg"),DC={}.hasOwnProperty;function Y$(e,t){const n=t||{};function r(a,...o){let c=r.invalid;const u=r.handlers;if(a&&DC.call(a,e)){const d=String(a[e]);c=DC.call(u,d)?u[d]:r.unknown}if(c)return c.call(this,a,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const X$=/["&'<>`]/g,Q$=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,J$=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Z$=/[|\\{}()[\]^$+*?.]/g,OC=new WeakMap;function eF(e,t){if(e=e.replace(t.subset?tF(t.subset):X$,r),t.subset||t.escapeOnly)return e;return e.replace(Q$,n).replace(J$,r);function n(a,o,c){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,c.charCodeAt(o+2),t)}function r(a,o,c){return t.format(a.charCodeAt(0),c.charCodeAt(o+1),t)}}function tF(e){let t=OC.get(e);return t||(t=nF(e),OC.set(e,t)),t}function nF(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(Z$,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const rF=/[\dA-Fa-f]/;function sF(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!rF.test(String.fromCharCode(t))?r:r+";"}const iF=/\d/;function aF(e,t,n){const r="&#"+String(e);return n&&t&&!iF.test(String.fromCharCode(t))?r:r+";"}const oF=["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"],mx={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:"€"},lF=["cent","copy","divide","gt","lt","not","para","times"],NN={}.hasOwnProperty,Ay={};let uh;for(uh in mx)NN.call(mx,uh)&&(Ay[mx[uh]]=uh);const cF=/[^\dA-Za-z]/;function uF(e,t,n,r){const a=String.fromCharCode(e);if(NN.call(Ay,a)){const o=Ay[a],c="&"+o;return n&&oF.includes(o)&&!lF.includes(o)&&(!r||t&&t!==61&&cF.test(String.fromCharCode(t)))?c:c+";"}return""}function dF(e,t,n){let r=sF(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=uF(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const o=aF(e,t,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function _l(e,t){return eF(e,Object.assign({format:dF},t))}const hF=/^>|^->|<!--|-->|--!>|<!-$/g,fF=[">"],mF=["<",">"];function pF(e,t,n,r){return r.settings.bogusComments?"<?"+_l(e.value,Object.assign({},r.settings.characterReferences,{subset:fF}))+">":"<!--"+e.value.replace(hF,a)+"-->";function a(o){return _l(o,Object.assign({},r.settings.characterReferences,{subset:mF}))}}function gF(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function IC(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 xF(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function yF(e){return e.join(" ").trim()}const bF=/[ \t\n\f\r]/g;function nv(e){return typeof e=="object"?e.type==="text"?MC(e.value):!1:MC(e)}function MC(e){return e.replace(bF,"")===""}const Fn=AN(1),TN=AN(-1),vF=[];function AN(e){return t;function t(n,r,a){const o=n?n.children:vF;let c=(r||0)+e,u=o[c];if(!a)for(;u&&nv(u);)c+=e,u=o[c];return u}}const _F={}.hasOwnProperty;function LN(e){return t;function t(n,r,a){return _F.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const rv=LN({body:wF,caption:px,colgroup:px,dd:EF,dt:jF,head:px,html:SF,li:kF,optgroup:NF,option:TF,p:CF,rp:PC,rt:PC,tbody:LF,td:BC,tfoot:RF,th:BC,thead:AF,tr:DF});function px(e,t,n){const r=Fn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&nv(r.value.charAt(0)))}function SF(e,t,n){const r=Fn(n,t);return!r||r.type!=="comment"}function wF(e,t,n){const r=Fn(n,t);return!r||r.type!=="comment"}function CF(e,t,n){const r=Fn(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 kF(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function jF(e,t,n){const r=Fn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function EF(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function PC(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function NF(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function TF(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function AF(e,t,n){const r=Fn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function LF(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function RF(e,t,n){return!Fn(n,t)}function DF(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function BC(e,t,n){const r=Fn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const OF=LN({body:PF,colgroup:BF,head:MF,html:IF,tbody:$F});function IF(e){const t=Fn(e,-1);return!t||t.type!=="comment"}function MF(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 PF(e){const t=Fn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&nv(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function BF(e,t,n){const r=TN(n,t),a=Fn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&rv(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function $F(e,t,n){const r=TN(n,t),a=Fn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&rv(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const dh={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 FF(e,t,n,r){const a=r.schema,o=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=EN);const h=zF(r,e.properties),m=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,m&&(c=!1),(h||!o||!OF(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(m),!c&&(!o||!rv(e,t,n))&&u.push("</"+e.tagName+">"),u.join("")}function zF(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const o=HF(e,a,t[a]);o&&n.push(o)}}for(;++r<n.length;){const o=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function HF(e,t,n){const r=W$(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=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=_l(r.attribute,Object.assign({},e.settings.characterReferences,{subset:dh.name[a][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?xF:yF)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(u=_l(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:dh.unquoted[a][o]}))),u!==n&&(e.settings.quoteSmart&&IC(n,c)>IC(n,e.alternative)&&(c=e.alternative),u=c+_l(n,Object.assign({},e.settings.characterReferences,{subset:(c==="'"?dh.single:dh.double)[a][o],attribute:!0}))+c),d+(u&&"="+u))}const UF=["<","&"];function RN(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:_l(e.value,Object.assign({},r.settings.characterReferences,{subset:UF}))}function VF(e,t,n,r){return r.settings.allowDangerousHtml?e.value:RN(e,t,n,r)}function WF(e,t,n,r){return r.all(e)}const GF=Y$("type",{invalid:qF,unknown:KF,handlers:{comment:pF,doctype:gF,element:FF,raw:VF,root:WF,text:RN}});function qF(e){throw new Error("Expected node, not `"+e+"`")}function KF(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const YF={},XF={},QF=[];function JF(e,t){const n=t||YF,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:ZF,all:ez,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||$$,characterReferences:n.characterReferences||XF,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?EN:K$,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function ZF(e,t,n){return GF(e,t,n,this)}function ez(e){const t=[],n=e&&e.children||QF;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const $C=/\s+/g;function DN(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($C)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split($C);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const tz=/:?lang=["']([^"']+)["']/g,nz=/(?:```|~~~)([\w-]+)/g,rz=/\\begin\{([\w-]+)\}/g,sz=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function iz(e){const t=im(e,!0).map(([a])=>a);function n(a){if(a===e.length)return{line:t.length-1,character:t.at(-1).length};let o=a,c=0;for(const u of t){if(o<u.length)break;o-=u.length,c++}return{line:c,character:o}}function r(a,o){let c=0;for(let u=0;u<a;u++)c+=t[u].length;return c+=o,c}return{lines:t,indexToPos:n,posToIndex:r}}function az(e,t,n){const r=new Set;for(const o of e.matchAll(tz)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(nz)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(rz)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(sz)){const c=o[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(o=>o&&a[o])}const oz=["color","background-color"];function lz(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 cz(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,a)=>r-a);return n.length?e.map(r=>r.flatMap(a=>{const o=n.filter(c=>a.offset<c&&c<a.offset+a.content.length).map(c=>c-a.offset).sort((c,u)=>c-u);return o.length?lz(a,o):a})):e}function uz(e,t,n,r,a="css-vars"){const o={content:e.content,explanation:e.explanation,offset:e.offset},c=t.map(m=>lf(e.variants[m])),u=new Set(c.flatMap(m=>Object.keys(m))),d={},h=(m,f)=>{const g=f==="color"?"":f==="background-color"?"-bg":`-${f}`;return n+t[m]+(f==="color"?"":g)};return c.forEach((m,f)=>{for(const g of u){const x=m[g]||"inherit";if(f===0&&r&&oz.includes(g))if(r==="light-dark()"&&c.length>1){const w=t.findIndex(b=>b==="light"),C=t.findIndex(b=>b==="dark");if(w===-1||C===-1)throw new sn('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(f,g)]=x)}else d[g]=x;else a==="css-vars"&&(d[h(f,g)]=x)}}),o.htmlStyle=d,o}function lf(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&sr.Italic&&(t["font-style"]="italic"),e.fontStyle&sr.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&sr.Underline&&n.push("underline"),e.fontStyle&sr.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Ly(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function dz(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let o=function(u){if(typeof u=="number"){if(u<0||u>n.source.length)throw new sn(`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 sn(`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 sn(`Invalid decoration position ${JSON.stringify(u)}. Line ${u.line} length: ${d.length}`);return{...u,character:h,offset:a.posToIndex(u.line,h)}}};var r=o;const a=iz(n.source),c=(n.options.decorations||[]).map(u=>({...u,start:o(u.start),end:o(u.end)}));hz(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 cz(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var m;if(!((m=this.options.decorations)!=null&&m.length))return;const r=t(this),a=[...n.children].filter(f=>f.type==="element"&&f.tagName==="span");if(a.length!==r.converter.lines.length)throw new sn(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(f,g,x,w){const C=a[f];let b="",_=-1,S=-1;if(g===0&&(_=0),x===0&&(S=0),x===Number.POSITIVE_INFINITY&&(S=C.children.length),_===-1||S===-1)for(let k=0;k<C.children.length;k++)b+=ON(C.children[k]),_===-1&&b.length===g&&(_=k+1),S===-1&&b.length===x&&(S=k+1);if(_===-1)throw new sn(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(S===-1)throw new sn(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const v=C.children.slice(_,S);if(!w.alwaysWrap&&v.length===C.children.length)u(C,w,"line");else if(!w.alwaysWrap&&v.length===1&&v[0].type==="element")u(v[0],w,"token");else{const k={type:"element",tagName:"span",properties:{},children:v};u(k,w,"wrapper"),C.children.splice(_,v.length,k)}}function c(f,g){a[f]=u(a[f],g,"line")}function u(f,g,x){var b;const w=g.properties||{},C=g.transform||(_=>_);return f.tagName=g.tagName||"span",f.properties={...f.properties,...w,class:f.properties.class},(b=g.properties)!=null&&b.class&&DN(f,g.properties.class),f=C(f,x)||f,f}const d=[],h=r.decorations.sort((f,g)=>g.start.offset-f.start.offset||f.end.offset-g.end.offset);for(const f of h){const{start:g,end:x}=f;if(g.line===x.line)o(g.line,g.character,x.character,f);else if(g.line<x.line){o(g.line,g.character,Number.POSITIVE_INFINITY,f);for(let w=g.line+1;w<x.line;w++)d.unshift(()=>c(w,f));o(x.line,0,x.character,f)}}d.forEach(f=>f())}}}function hz(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new sn(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const a=e[r],o=n.start.offset<=a.start.offset&&a.start.offset<n.end.offset,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(o||c||u||d){if(o&&c||u&&d||u&&n.start.offset===n.end.offset||c&&a.start.offset===a.end.offset)continue;throw new sn(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function ON(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(ON).join(""):""}const fz=[dz()];function cf(e){const t=mz(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...fz]}function mz(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 Ga=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],gx={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function pz(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 FC(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 gz(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)gx[r]&&t.push({type:"setDecoration",value:gx[r]});else if(r<=29){const a=gx[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:Ga[r-30]}});else if(r===38){const a=FC(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:Ga[r-40]}});else if(r===48){const a=FC(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:Ga[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Ga[r-100+8]}})}return t}function xz(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let o=0;do{const c=pz(r,o),u=c.sequence?r.substring(o,c.startPosition):r.substring(o);if(u.length>0&&a.push({value:u,foreground:e,background:t,decorations:new Set(n)}),c.sequence){const d=gz(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)}o=c.position}while(o<r.length);return a}}}var yz={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 bz(e=yz){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<Ga.length;h++)r.push(t(Ga[h]));let u=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let m=0;m<6;m++)for(let f=0;f<6;f++)r.push(n([u[h],u[m],u[f]]));let d=8;for(let h=0;h<24;h++,d+=10)r.push(n([d,d,d]));return r}function o(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 o(u.index)}}return{value:c}}const vz=/#([0-9a-f]{3,8})/i,_z=/var\((--[\w-]+-ansi-[\w-]+)\)/,Sz={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 wz(e,t,n){const r=of(e,n),a=im(t),o=bz(Object.fromEntries(Ga.map(u=>{var h;const d=`terminal.ansi${u[0].toUpperCase()}${u.substring(1)}`;return[u,((h=e.colors)==null?void 0:h[d])||Sz[u]]}))),c=xz();return a.map(u=>c.parse(u[0]).map(d=>{let h,m;d.decorations.has("reverse")?(h=d.background?o.value(d.background):e.bg,m=d.foreground?o.value(d.foreground):e.fg):(h=d.foreground?o.value(d.foreground):e.fg,m=d.background?o.value(d.background):void 0),h=ca(h,r),m=ca(m,r),d.decorations.has("dim")&&(h=Cz(h));let f=sr.None;return d.decorations.has("bold")&&(f|=sr.Bold),d.decorations.has("italic")&&(f|=sr.Italic),d.decorations.has("underline")&&(f|=sr.Underline),d.decorations.has("strikethrough")&&(f|=sr.Strikethrough),{content:d.value,offset:u[1],color:h,bgColor:m,fontStyle:f}}))}function Cz(e){const t=e.match(vz);if(t){const r=t[1];if(r.length===8){const a=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${a}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const a=r[0],o=r[1],c=r[2],u=r[3];return`#${a}${a}${o}${o}${c}${c}${Math.round(Number.parseInt(`${u}${u}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],o=r[1],c=r[2];return`#${a}${a}${o}${o}${c}${c}80`}}}const n=e.match(_z);return n?`var(${n[1]}-dim)`:e}function Ry(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!rm(r)&&!sm(a)&&r==="ansi"){const{theme:o}=e.setTheme(a);return wz(o,t,n)}return yN(e,t,n)}function uf(e,t,n){let r,a,o,c,u,d;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:m="--shiki-",colorsRendering:f="css-vars"}=n,g=Object.entries(n.themes).filter(_=>_[1]).map(_=>({color:_[0],theme:_[1]})).sort((_,S)=>_.color===h?-1:S.color===h?1:0);if(g.length===0)throw new sn("`themes` option must not be empty");const x=bN(e,t,n,Ry);if(d=Su(x),h&&h!=="light-dark()"&&!g.some(_=>_.color===h))throw new sn(`\`themes\` option must contain the defaultColor key \`${h}\``);const w=g.map(_=>e.getTheme(_.theme)),C=g.map(_=>_.color);o=x.map(_=>_.map(S=>uz(S,C,m,h,f))),d&&am(o,d);const b=g.map(_=>of(_.theme,n));a=zC(g,w,b,m,h,"fg",f),r=zC(g,w,b,m,h,"bg",f),c=`shiki-themes ${w.map(_=>_.name).join(" ")}`,u=h?void 0:[a,r].join(";")}else if("theme"in n){const h=of(n.theme,n);o=Ry(e,t,n);const m=e.getTheme(n.theme);r=ca(m.bg,h),a=ca(m.fg,h),c=m.name,d=Su(o)}else throw new sn("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:a,bg:r,themeName:c,rootStyle:u,grammarState:d}}function zC(e,t,n,r,a,o,c){return e.map((u,d)=>{const h=ca(t[d][o],n[d])||"inherit",m=`${r+u.color}${o==="bg"?"-bg":""}:${h}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const f=e.findIndex(x=>x.color==="light"),g=e.findIndex(x=>x.color==="dark");if(f===-1||g===-1)throw new sn('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${ca(t[f][o],n[f])||"inherit"}, ${ca(t[g][o],n[g])||"inherit"});${m}`}return h}return c==="css-vars"?m:null}).filter(u=>!!u).join(";")}const IN=/^\s+$/,kz=/^(\s*)(.*?)(\s*)$/;function df(e,t,n,r={meta:{},options:n,codeToHast:(a,o)=>df(e,a,o),codeToTokens:(a,o)=>uf(e,a,o)}){var w,C;let a=t;for(const b of cf(n))a=((w=b.preprocess)==null?void 0:w.call(r,a,n))||a;let{tokens:o,fg:c,bg:u,themeName:d,rootStyle:h,grammarState:m}=uf(e,a,n);const{mergeWhitespaces:f=!0,mergeSameStyleTokens:g=!1}=n;f===!0?o=Ez(o):f==="never"&&(o=Nz(o)),g&&(o=Tz(o));const x={...r,get source(){return a}};for(const b of cf(n))o=((C=b.tokens)==null?void 0:C.call(x,o))||o;return jz(o,{...n,fg:c,bg:u,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},x,m)}function jz(e,t,n,r=Su(e)){var C,b,_,S;const a=cf(t),o=[],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[v,k]of Object.entries(t.meta||{}))v.startsWith("_")||(h[v]=k);let m={type:"element",tagName:"pre",properties:h,children:[],data:t.data},f={type:"element",tagName:"code",properties:{},children:o};const g=[],x={...n,structure:u,addClassToHast:DN,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return c},get pre(){return m},get code(){return f},get lines(){return g}};if(e.forEach((v,k)=>{var L,A;k&&(u==="inline"?c.children.push({type:"element",tagName:"br",properties:{},children:[]}):u==="classic"&&o.push({type:"text",value:`
106
+ `}));let E={type:"element",tagName:"span",properties:{class:"line"},children:[]},N=0;for(const O of v){let I={type:"element",tagName:"span",properties:{...O.htmlAttrs},children:[{type:"text",value:O.content}]};const F=Ly(O.htmlStyle||lf(O));F&&(I.properties.style=F);for(const B of a)I=((L=B==null?void 0:B.span)==null?void 0:L.call(x,I,k+1,N,E,O))||I;u==="inline"?c.children.push(I):u==="classic"&&E.children.push(I),N+=O.content.length}if(u==="classic"){for(const O of a)E=((A=O==null?void 0:O.line)==null?void 0:A.call(x,E,k+1))||E;g.push(E),o.push(E)}else u==="inline"&&g.push(E)}),u==="classic"){for(const v of a)f=((C=v==null?void 0:v.code)==null?void 0:C.call(x,f))||f;m.children.push(f);for(const v of a)m=((b=v==null?void 0:v.pre)==null?void 0:b.call(x,m))||m;c.children.push(m)}else if(u==="inline"){const v=[];let k={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const N of c.children)N.type==="element"&&N.tagName==="br"?(v.push(k),k={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(N.type==="element"||N.type==="text")&&k.children.push(N);v.push(k);let E={type:"element",tagName:"code",properties:{},children:v};for(const N of a)E=((_=N==null?void 0:N.code)==null?void 0:_.call(x,E))||E;c.children=[];for(let N=0;N<E.children.length;N++){N>0&&c.children.push({type:"element",tagName:"br",properties:{},children:[]});const L=E.children[N];L.type==="element"&&c.children.push(...L.children)}}let w=c;for(const v of a)w=((S=v==null?void 0:v.root)==null?void 0:S.call(x,w))||w;return r&&am(w,r),w}function Ez(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((o,c)=>{const u=!(o.fontStyle&&(o.fontStyle&sr.Underline||o.fontStyle&sr.Strikethrough));u&&IN.test(o.content)&&t[c+1]?(a===void 0&&(a=o.offset),r+=o.content):r?(u?n.push({...o,offset:a,content:r+o.content}):n.push({content:r,offset:a},o),a=void 0,r=""):n.push(o)}),n})}function Nz(e){return e.map(t=>t.flatMap(n=>{if(IN.test(n.content))return n;const r=n.content.match(kz);if(!r)return n;const[,a,o,c]=r;if(!a&&!c)return n;const u=[{...n,offset:n.offset+a.length,content:o}];return a&&u.unshift({content:a,offset:n.offset}),c&&u.push({content:c,offset:n.offset+a.length+o.length}),u}))}function Tz(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const a=n.at(-1),o=Ly(a.htmlStyle||lf(a)),c=Ly(r.htmlStyle||lf(r)),u=a.fontStyle&&(a.fontStyle&sr.Underline||a.fontStyle&sr.Strikethrough),d=r.fontStyle&&(r.fontStyle&sr.Underline||r.fontStyle&sr.Strikethrough);!u&&!d&&o===c?a.content+=r.content:n.push({...r})}return n})}const Az=JF;function Lz(e,t,n){var o;const r={meta:{},options:n,codeToHast:(c,u)=>df(e,c,u),codeToTokens:(c,u)=>uf(e,c,u)};let a=Az(df(e,t,n,r));for(const c of cf(n))a=((o=c.postprocess)==null?void 0:o.call(r,a,n))||a;return a}async function Rz(e){const t=await E$(e);return{getLastGrammarState:(...n)=>R$(t,...n),codeToTokensBase:(n,r)=>Ry(t,n,r),codeToTokensWithThemes:(n,r)=>bN(t,n,r),codeToTokens:(n,r)=>uf(t,n,r),codeToHast:(n,r)=>df(t,n,r),codeToHtml:(n,r)=>Lz(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Dz(e){const t=e.langs,n=e.themes,r=e.engine;async function a(o){function c(f){var g;if(typeof f=="string"){if(f=((g=o.langAlias)==null?void 0:g[f])||f,dN(f))return[];const x=t[f];if(!x)throw new sn(`Language \`${f}\` is not included in this bundle. You may want to load it from external source.`);return x}return f}function u(f){if(hN(f))return"none";if(typeof f=="string"){const g=n[f];if(!g)throw new sn(`Theme \`${f}\` is not included in this bundle. You may want to load it from external source.`);return g}return f}const d=(o.themes??[]).map(f=>u(f)),h=(o.langs??[]).map(f=>c(f)),m=await Rz({engine:o.engine??r(),...o,themes:d,langs:h});return{...m,loadLanguage(...f){return m.loadLanguage(...f.map(c))},loadTheme(...f){return m.loadTheme(...f.map(u))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function Oz(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 Iz(e,t){const n=Oz(e);async function r(a,o){var d;const c=await n({langs:[o.lang],themes:"theme"in o?[o.theme]:Object.values(o.themes)}),u=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,a,o.lang,c));return u&&await c.loadLanguage(...u),c}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,o){return(await r(a,o)).codeToHtml(a,o)},async codeToHast(a,o){return(await r(a,o)).codeToHast(a,o)},async codeToTokens(a,o){return(await r(a,o)).codeToTokens(a,o)},async codeToTokensBase(a,o){return(await r(a,o)).codeToTokensBase(a,o)},async codeToTokensWithThemes(a,o){return(await r(a,o)).codeToTokensWithThemes(a,o)},async getLastGrammarState(a,o){return(await n({langs:[o.lang],themes:[o.theme]})).getLastGrammarState(a,o)}}}var Mz=Wb({bundledLanguages:()=>em,bundledLanguagesAlias:()=>qb,bundledLanguagesBase:()=>Gb,bundledLanguagesInfo:()=>Zf,bundledThemes:()=>Yb,bundledThemesInfo:()=>Kb,codeToHast:()=>PN,codeToHtml:()=>MN,codeToTokens:()=>BN,codeToTokensBase:()=>$N,codeToTokensWithThemes:()=>FN,createHighlighter:()=>lm,getLastGrammarState:()=>HN,getSingletonHighlighter:()=>zN});const lm=Dz({langs:em,themes:Yb,engine:()=>(0,K2.createOnigurumaEngine)(se(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:MN,codeToHast:PN,codeToTokens:BN,codeToTokensBase:$N,codeToTokensWithThemes:FN,getSingletonHighlighter:zN,getLastGrammarState:HN}=Iz(lm,{guessEmbeddedLanguages:az}),HC=4294967295;var Pz=class{constructor(e,t={}){Le(this,"patterns");Le(this,"options");Le(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:a}=t;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(o=>{if(typeof o!="string")return o;const c=r==null?void 0:r.get(o);if(c){if(c instanceof RegExp)return c;if(n)return null;throw c}try{const u=a(o);return r==null||r.set(o,u),u}catch(u){if(r==null||r.set(o,u),n)return null;throw u}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function o(c,u,d=0){return{index:c,captureIndices:u.indices.map(h=>h==null?{start:HC,end:HC,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 o(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 o(u,d,h)}return null}};function $l(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Bz(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const sv=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Gn=String.raw;function Fl(e,t){if(e==null)throw new Error(t??"Value expected");return e}const UN=Gn`\[\^?`,VN=`c.? | C(?:-.?)?|${Gn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Gn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Gn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Gn`o\{[^\}]*\}?`}|${Gn`\d{1,3}`}`,iv=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,hh=new RegExp(Gn`
107
+ \\ (?:
108
+ ${VN}
109
+ | [gk]<[^>]*>?
110
+ | [gk]'[^']*'?
111
+ | .
112
+ )
113
+ | \( (?:
114
+ \? (?:
115
+ [:=!>({]
116
+ | <[=!]
117
+ | <[^>]*>
118
+ | '[^']*'
119
+ | ~\|?
120
+ | #(?:[^)\\]|\\.?)*
121
+ | [^:)]*[:)]
122
+ )?
123
+ | \*[^\)]*\)?
124
+ )?
125
+ | (?:${iv.source})+
126
+ | ${UN}
127
+ | .
128
+ `.replace(/\s+/g,""),"gsu"),xx=new RegExp(Gn`
129
+ \\ (?:
130
+ ${VN}
131
+ | .
132
+ )
133
+ | \[:(?:\^?\p{Alpha}+|\^):\]
134
+ | ${UN}
135
+ | &&
136
+ | .
137
+ `.replace(/\s+/g,""),"gsu");function $z(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=sH(n.flags),a=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(f){a.push(f)},replaceCurrentModX(f){a[a.length-1]=f},singleline:n.rules.singleline};let c=[],u;for(hh.lastIndex=0;u=hh.exec(e);){const f=Fz(o,e,u[0],hh.lastIndex);f.tokens?c.push(...f.tokens):f.token&&c.push(f.token),f.lastIndex!==void 0&&(hh.lastIndex=f.lastIndex)}const d=[];let h=0;c.filter(f=>f.type==="GroupOpen").forEach(f=>{f.kind==="capturing"?f.number=++h:f.raw==="("&&d.push(f)}),h||d.forEach((f,g)=>{f.kind="capturing",f.number=g+1});const m=h||d.length;return{tokens:c.map(f=>f.type==="EscapedNumber"?aH(f,m):f).flat(),flags:r}}function Fz(e,t,n,r){const[a,o]=n;if(n==="["||n==="[^"){const c=zz(t,n,r);return{tokens:c.tokens,lastIndex:c.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(o))return{token:UC(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Qz(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:GN(n)}}if(o==="K")return{token:qN("keep",n)};if(o==="N"||o==="R")return{token:qa("newline",n,{negate:o==="N"})};if(o==="O")return{token:qa("any",n)};if(o==="X")return{token:qa("text_segment",n)};const c=WN(n,{inCharClass:!1});return Array.isArray(c)?{tokens:c}:{token:c}}if(a==="("){if(o==="*")return{token:tH(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:eH(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:ul("group",n)};if(n==="(?>")return{token:ul("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:ul(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:ul("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:ul("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Kz(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:qa("dot",n)};if(n==="^"||n==="$"){const c=e.singleline?{"^":Gn`\A`,$:Gn`\Z`}[n]:n;return{token:UC(c,n)}}return n==="|"?{token:Uz(n)}:iv.test(n)?{tokens:oH(n)}:{token:yi($l(n),n)}}function zz(e,t,n){const r=[VC(t[1]==="^",t)];let a=1,o;for(xx.lastIndex=n;o=xx.exec(e);){const c=o[0];if(c[0]==="["&&c[1]!==":")a++,r.push(VC(c[1]==="^",c));else if(c==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(yi(93,c));else if(a--,r.push(Vz(c)),!a)break}else{const u=Hz(c);Array.isArray(u)?r.push(...u):r.push(u)}}return{tokens:r,lastIndex:xx.lastIndex||e.length}}function Hz(e){if(e[0]==="\\")return WN(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!sv.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return qa("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Wz(e):e==="&&"?Gz(e):yi($l(e),e)}function WN(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return Zz(e);if("dDhHsSwW".includes(n))return nH(e);if(e.startsWith(Gn`\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 rH(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)),o=new TextEncoder;return[...a].map(c=>{const u=[...o.encode(c)].map(d=>`\\x${d.toString(16)}`).join("");return yi($l(c),u)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return yi(iH(e),e);if(WC.has(n))return yi(WC.get(n),e);if(/\d/.test(n))return qz(t,e);if(e==="\\")throw new Error(Gn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return yi(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Uz(e){return{type:"Alternator",raw:e}}function UC(e,t){return{type:"Assertion",kind:e,raw:t}}function GN(e){return{type:"Backreference",raw:e}}function yi(e,t){return{type:"Character",value:e,raw:t}}function Vz(e){return{type:"CharacterClassClose",raw:e}}function Wz(e){return{type:"CharacterClassHyphen",raw:e}}function Gz(e){return{type:"CharacterClassIntersector",raw:e}}function VC(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function qa(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function qN(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Fl(n.flags),raw:t}}function qz(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Kz(e){return{type:"GroupClose",raw:e}}function ul(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function Yz(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Xz(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Qz(e){return{type:"Subroutine",raw:e}}const Jz=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),WC=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Zz(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 yi($l(t.toUpperCase())-64,e)}function eH(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const a=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),o=qC(n),c=qC(r),u={};if(o&&(u.enable=o),c&&(u.disable=c),e.endsWith(")"))return t.replaceCurrentModX(a),qN("flags",e,{flags:u});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,ul("group",e,{...(o||c)&&{flags:u}});throw new Error(`Unexpected flag modifier "${e}"`)}function tH(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:a}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const o=a?a.split(",").filter(m=>m!=="").map(m=>/^[+-]?\d+$/.test(m)?+m:m):[],[c,u,d]=o,h=Jz.has(n)?n.toLowerCase():"custom";switch(h){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof c=="string")throw new Error(`Named callout argument must be a number "${c}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);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(o.length===2&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${u}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${c}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);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 Yz(h,r??null,(a==null?void 0:a.split(","))??null,e)}function GC(e){let t=null,n,r;if(e[0]==="{"){const{minStr:a,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,c=1e5;if(+a>c||o&&+o>c)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+a,r=o===void 0?+a:o===""?1/0:+o,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return Xz(t,n,r,e)}function nH(e){const t=e[1].toLowerCase();return qa({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function rH(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return qa("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function qC(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 sH(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 iH(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 aH(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[GN(n)];const o=[],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(Gn`Octal encoded byte above 177 unsupported "${n}"`)}else h=$l(d);o.push(yi(h,(u===0?"\\":"")+d))}return o}function oH(e){const t=[],n=new RegExp(iv,"gy");let r;for(;r=n.exec(e);){const a=r[0];if(a[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(o){const{min:c,max:u}=o.groups;if(+c>+u&&a.endsWith("?")){n.lastIndex--,t.push(GC(a.slice(0,-1)));continue}}}t.push(GC(a))}return t}function KN(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function lH(e){return cH.has(e.type)}const cH=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function YN(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=$z(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(g,x)=>{const w=r.tokens[o.nextIndex];switch(o.parent=g,o.nextIndex++,w.type){case"Alternator":return ao();case"Assertion":return uH(w);case"Backreference":return dH(w,o);case"Character":return cm(w.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return hH(w,o,x);case"CharacterClassOpen":return fH(w,o,x);case"CharacterSet":return mH(w,o);case"Directive":return vH(w.kind,{flags:w.flags});case"GroupOpen":return pH(w,o,x);case"NamedCallout":return SH(w.kind,w.tag,w.arguments);case"Quantifier":return gH(w,o);case"Subroutine":return xH(w,o);default:throw new Error(`Unexpected token type "${w.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},c=CH(_H(r.flags));let u=c.body[0];for(;o.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:m,subroutines:f}=o;if(h&&m.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:g}of f)if(typeof g=="number"){if(g>d.length)throw new Error("Subroutine uses a group number that's not defined");g&&(d[g-1].isSubroutined=!0)}else if(m.has(g)){if(m.get(g).length>1)throw new Error(Gn`Subroutine uses a duplicate group name "\g<${g}>"`);m.get(g)[0].isSubroutined=!0}else throw new Error(Gn`Subroutine uses a group name that's not defined "\g<${g}>"`);return c}function uH({kind:e}){return Dy(Fl({"^":"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===Gn`\B`||e===Gn`\Y`})}function dH({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),a=(o,c=!1)=>{const u=t.capturingGroups.length;let d=!1;if(o>u)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Oy(c?u+1-o:o,{orphan:d})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return a(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return Oy(r)}return a(+r)}function hH(e,t,n){const{tokens:r,walk:a}=t,o=t.parent,c=o.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(o,{...n,isCheckingRangeEnd:!0});if(c.type==="Character"&&d.type==="Character")return o.body.pop(),bH(c,d);throw new Error("Invalid character class range")}return cm($l("-"))}function fH({negate:e},t,n){const{tokens:r,walk:a}=t,o=[Fh()],c=r[t.nextIndex];let u=XC(c);for(;u.type!=="CharacterClassClose";){if(u.type==="CharacterClassIntersector")o.push(Fh()),t.nextIndex++;else{const h=o.at(-1);h.body.push(a(h,n))}u=XC(r[t.nextIndex],c)}const d=Fh({negate:e});return o.length===1?d.body=o[0].body:(d.kind="intersection",d.body=o.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,d}function mH({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:c}=r;if(e==="property"){const u=um(n);if(sv.has(u)&&!(c!=null&&c.has(u)))e="posix",n=u;else return dl(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:c})}return e==="posix"?wH(n,{negate:t}):Iy(e,{negate:t})}function pH(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:o,skipLookbehindValidation:c,walk:u}=t,d=kH(e),h=d.type==="AbsenceFunction",m=YC(d),f=m&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&Bz(o,d.name,[]).push(d)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let g=QC(r[t.nextIndex]);for(;g.type!=="GroupClose";){if(g.type==="Alternator")d.body.push(ao()),t.nextIndex++;else{const x=d.body.at(-1),w=u(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||m,isInNegLookbehind:n.isInNegLookbehind||f});if(x.body.push(w),(m||n.isInLookbehind)&&!c){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(KC(w)||w.type==="CapturingGroup")throw new Error(C)}else if(KC(w)||YC(w)&&w.negate)throw new Error(C)}}g=QC(r[t.nextIndex])}return t.nextIndex++,d}function gH({kind:e,min:t,max:n},r){const a=r.parent,o=a.body.at(-1);if(!o||!lH(o))throw new Error("Quantifier requires a repeatable token");const c=QN(e,t,n,o);return a.body.pop(),c}function xH({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let a=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(o){const u=+o.groups.num,d=n.length;if(t.hasNumberedRef=!0,a={"":u,"+":d+u,"-":d+1-u}[o.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const c=JN(a);return r.push(c),c}function yH(e,t){return{type:"AbsenceFunction",kind:e,body:Iu(t==null?void 0:t.body)}}function ao(e){return{type:"Alternative",body:ZN(e==null?void 0:e.body)}}function Dy(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function Oy(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function XN(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!jH(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:Iu(t==null?void 0:t.body)}}function cm(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 Fh(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:ZN(e==null?void 0:e.body)}}function bH(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Iy(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 vH(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Fl(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function _H(e){return{type:"Flags",...e}}function ms(e){const t=e==null?void 0:e.atomic,n=e==null?void 0:e.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:Iu(e==null?void 0:e.body)}}function Wa(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Iu(e==null?void 0:e.body)}}function SH(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function wH(e,t){const n=!!(t!=null&&t.negate);if(!sv.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function QN(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 CH(e,t){return{type:"Regex",body:Iu(t==null?void 0:t.body),flags:e}}function JN(e){return{type:"Subroutine",ref:e}}function dl(e,t){var a;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(a=n.unicodePropertyMap)==null?void 0:a.get(um(e));if(!r){if(n.normalizeUnknownPropertyNames)r=EH(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Gn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function kH({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return yH("repeater");case"atomic":return ms({atomic:!0});case"capturing":return XN(a,{name:n});case"group":return ms({flags:e});case"lookahead":case"lookbehind":return Wa({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function Iu(e){if(e===void 0)e=[ao()];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 ZN(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 KC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function YC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function jH(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function EH(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 um(e){return e.replace(/[- _]+/g,"").toLowerCase()}function XC(e,t){const n=t;return Fl(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function QC(e){return Fl(e,"Unclosed group")}function su(e,t,n=null){function r(o,c){for(let u=0;u<o.length;u++){const d=a(o[u],c,u,o);u=Math.max(-1,u+d)}}function a(o,c=null,u=null,d=null){var _,S;let h=0,m=!1;const f={node:o,parent:c,key:u,container:d,root:e,remove(){fh(d).splice(Math.max(0,Zo(u)+h),1),h--,m=!0},removeAllNextSiblings(){return fh(d).splice(Zo(u)+1)},removeAllPrevSiblings(){const v=Zo(u)+h;return h-=v,fh(d).splice(0,Math.max(0,v))},replaceWith(v,k={}){const E=!!k.traverse;d?d[Math.max(0,Zo(u)+h)]=v:Fl(c,"Can't replace root node")[u]=v,E&&a(v,c,u,d),m=!0},replaceWithMultiple(v,k={}){const E=!!k.traverse;if(fh(d).splice(Math.max(0,Zo(u)+h),1,...v),h+=v.length-1,E){let N=0;for(let L=0;L<v.length;L++)N+=a(v[L],c,Zo(u)+L+N,d)}m=!0},skip(){m=!0}},{type:g}=o,x=t["*"],w=t[g],C=typeof x=="function"?x:x==null?void 0:x.enter,b=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(f,n),b==null||b(f,n),!m)switch(g){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(o.min,o,"min"),a(o.max,o,"max");break;case"Quantifier":a(o.body,o,"body");break;case"Regex":r(o.body,o),a(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${g}"`)}return(_=w==null?void 0:w.exit)==null||_.call(w,f,n),(S=x==null?void 0:x.exit)==null||S.call(x,f,n),h}return a(e),e}function fh(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Zo(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const NH=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function TH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function AH(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const rs=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function av(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let c=0,u="";for(const d of e.matchAll(a)){const{0:h,groups:{$skip:m}}=d;if(!m&&(!r||r===rs.DEFAULT==!c)){n instanceof Function?u+=n(d,{context:c?rs.CHAR_CLASS:rs.DEFAULT,negated:o[o.length-1]}):u+=n;continue}h[0]==="["?(c++,o.push(h[1]==="^")):h==="]"&&c&&(c--,o.pop()),u+=h}return u}function eT(e,t,n,r){av(e,t,n,r)}function LH(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=n;let o=0,c;for(;c=a.exec(e);){const{0:u,groups:{$skip:d}}=c;if(!d&&(!r||r===rs.DEFAULT==!o))return c;u==="["?o++:u==="]"&&o&&o--,a.lastIndex==c.index&&a.lastIndex++}return null}function mh(e,t,n){return!!LH(e,t,0,n)}function RH(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,a=0,o=1,c;for(;c=n.exec(e);){const[u]=c;if(u==="[")a++;else if(a)u==="]"&&a--;else if(u==="(")o++;else if(u===")"&&(o--,!o)){r=c.index;break}}return e.slice(t,r)}const JC=new RegExp(String.raw`(?<noncapturingStart>${NH})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function DH(e,t){const n=(t==null?void 0:t.hiddenCaptures)??[];let r=(t==null?void 0:t.captureTransfers)??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const a="(?>",o="(?:(?=(",c=[0],u=[];let d=0,h=0,m=NaN,f;do{f=!1;let g=0,x=0,w=!1,C;for(JC.lastIndex=Number.isNaN(m)?0:m+o.length;C=JC.exec(e);){const{0:b,index:_,groups:{capturingStart:S,noncapturingStart:v}}=C;if(b==="[")g++;else if(g)b==="]"&&g--;else if(b===a&&!w)m=_,w=!0;else if(w&&v)x++;else if(S)w?x++:(d++,c.push(d+h));else if(b===")"&&w){if(!x){h++;const k=d+h;if(e=`${e.slice(0,m)}${o}${e.slice(m+a.length,_)}))<$$${k}>)${e.slice(_+1)}`,f=!0,u.push(k),TH(n,k),r.size){const E=new Map;r.forEach((N,L)=>{E.set(L>=k?L+1:L,N.map(A=>A>=k?A+1:A))}),r=E}break}x--}}}while(f);return n.push(...u),e=av(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}`},rs.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const tT=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,yx=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>${tT})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
152
+ | \\?.
153
+ `.replace(/\s+/g,""),"gsu");function OH(e){if(!new RegExp(`${tT}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",o=0,c;for(yx.lastIndex=0;c=yx.exec(e);){const{0:u,index:d,groups:{qBase:h,qMod:m,invalidQ:f}}=c;if(u==="[")o||(r=d),o++;else if(u==="]")o?o--:r=null;else if(!o)if(m==="+"&&a&&!a.startsWith("(")){if(f)throw new Error(`Invalid quantifier "${u}"`);let g=-1;if(/^\{\d+\}$/.test(h))e=AH(e,d+h.length,m,"");else{if(a===")"||a==="]"){const x=a===")"?n:r;if(x===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,x)}(?>${e.slice(x,d)}${h})${e.slice(d+u.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${h})${e.slice(d+u.length)}`;g+=4}yx.lastIndex+=g}else u[0]==="("?t.push(d):u===")"&&(n=t.length?t.pop():null);a=u}return{pattern:e}}const ts=String.raw,IH=ts`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,My=ts`\(\?R=(?<rDepth>[^\)]+)\)|${IH}`,dm=ts`\(\?<(?![=!])(?<captureName>[^>]+)>`,nT=ts`${dm}|(?<unnamed>\()(?!\?)`,Pa=new RegExp(ts`${dm}|${My}|\(\?|\\?.`,"gsu"),bx="Cannot use multiple overlapping recursions";function MH(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(My,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&mh(e,ts`\(\?\(DEFINE\)`,rs.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],c=mh(e,ts`\\[1-9]`,rs.DEFAULT),u=new Map,d=[];let h=!1,m=0,f=0,g;for(Pa.lastIndex=0;g=Pa.exec(e);){const{0:x,groups:{captureName:w,rDepth:C,gRNameOrNum:b,gRDepth:_}}=g;if(x==="[")m++;else if(m)x==="]"&&m--;else if(C){if(ZC(C),h)throw new Error(bx);if(c)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const S=e.slice(0,g.index),v=e.slice(Pa.lastIndex);if(mh(v,My,rs.DEFAULT))throw new Error(bx);const k=+C-1;e=ek(S,v,k,!1,n,o,f),a=nk(a,S,k,o.length,0,f);break}else if(b){ZC(_);let S=!1;for(const B of d)if(B.name===b||B.num===+b){if(S=!0,B.hasRecursedWithin)throw new Error(bx);break}if(!S)throw new Error(ts`Recursive \g cannot be used outside the referenced group "${r==="external"?b:ts`\g<${b}&R=${_}>`}"`);const v=u.get(b),k=RH(e,v);if(c&&mh(k,ts`${dm}|\((?!\?)`,rs.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const E=e.slice(v,g.index),N=k.slice(E.length+x.length),L=o.length,A=+_-1,O=ek(E,N,A,!0,n,o,f);a=nk(a,E,A,o.length-L,L,f);const I=e.slice(0,v),F=e.slice(v+k.length);e=`${I}${O}${F}`,Pa.lastIndex+=O.length-x.length-E.length-N.length,d.forEach(B=>B.hasRecursedWithin=!0),h=!0}else if(w)f++,u.set(String(f),Pa.lastIndex),u.set(w,Pa.lastIndex),d.push({num:f,name:w});else if(x[0]==="("){const S=x==="(";S&&(f++,u.set(String(f),Pa.lastIndex)),d.push(S?{num:f}:{})}else x===")"&&d.pop()}return n.push(...o),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function ZC(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 ek(e,t,n,r,a,o,c){const u=new Set;r&&eT(e+t,dm,({groups:{captureName:h}})=>{u.add(h)},rs.DEFAULT);const d=[n,r?u:null,a,o,c];return`${e}${tk(`(?:${e}`,"forward",...d)}(?:)${tk(`${t})`,"backward",...d)}${t}`}function tk(e,t,n,r,a,o,c){const d=m=>t==="forward"?m+2:n-m+2-1;let h="";for(let m=0;m<n;m++){const f=d(m);h+=av(e,ts`${nT}|\\k<(?<backref>[^>]+)>`,({0:g,groups:{captureName:x,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return g;const b=`_$${f}`;if(w||x){const _=c+o.length+1;return o.push(_),PH(a,_),w?g:`(?<${x}${b}>`}return ts`\k<${C}${b}>`},rs.DEFAULT)}return h}function PH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function nk(e,t,n,r,a,o){if(e.size&&r){let c=0;eT(t,nT,()=>c++,rs.DEFAULT);const u=o-c+a,d=new Map;return e.forEach((h,m)=>{const f=(r-c*n)/n,g=c*n,x=m>u+c?m+r:m,w=[];for(const C of h)if(C<=u)w.push(C);else if(C>u+c+f)w.push(C+r);else if(C<=u+c)for(let b=0;b<=n;b++)w.push(C+c*b);else for(let b=0;b<=n;b++)w.push(C+g+f*b);d.set(x,w)}),d}return e}var $n=String.fromCodePoint,_t=String.raw,bs={},hm=globalThis.RegExp;bs.flagGroups=(()=>{try{new hm("(?i:)")}catch{return!1}return!0})();bs.unicodeSets=(()=>{try{new hm("[[]]","v")}catch{return!1}return!0})();bs.bugFlagVLiteralHyphenIsRange=bs.unicodeSets?(()=>{try{new hm(_t`[\d\-a]`,"v")}catch{return!0}return!1})():!1;bs.bugNestedClassIgnoresNegation=bs.unicodeSets&&new hm("[[^a]]","v").test("a");function hf(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 wu(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Py(e,t){return rk[e]>=rk[t]}function BH(e,t){if(e==null)throw new Error(t??"Value expected");return e}var rk={ES2025:2025,ES2024:2024,ES2018:2018},$H={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function rT(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!$H[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=bs.flagGroups?"ES2025":bs.unicodeSets?"ES2024":"ES2018"),t}var FH="[ -\r ]",zH=new Set([$n(304),$n(305)]),oi=_t`[\p{L}\p{M}\p{N}\p{Pc}]`;function sT(e){if(zH.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=VH.get(n),o=HH.get(n),c=UH.get(n);return[...r].length===1&&t.add(r),c&&t.add(c),a&&t.add(a),t.add(n),o&&t.add(o),[...t]}var ov=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=>[um(e),e])),HH=new Map([["s",$n(383)],[$n(383),"s"]]),UH=new Map([[$n(223),$n(7838)],[$n(107),$n(8490)],[$n(229),$n(8491)],[$n(969),$n(8486)]]),VH=new Map([Qi(453),Qi(456),Qi(459),Qi(498),...vx(8072,8079),...vx(8088,8095),...vx(8104,8111),Qi(8124),Qi(8140),Qi(8188)]),WH=new Map([["alnum",_t`[\p{Alpha}\p{Nd}]`],["alpha",_t`\p{Alpha}`],["ascii",_t`\p{ASCII}`],["blank",_t`[\p{Zs}\t]`],["cntrl",_t`\p{Cc}`],["digit",_t`\p{Nd}`],["graph",_t`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",_t`\p{Lower}`],["print",_t`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",_t`[\p{P}\p{S}]`],["space",_t`\p{space}`],["upper",_t`\p{Upper}`],["word",_t`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",_t`\p{AHex}`]]);function GH(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Qi(e){const t=$n(e);return[t.toLowerCase(),t]}function vx(e,t){return GH(e,t).map(n=>Qi(n))}var iT=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function qH(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};aT(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Py(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};su(e,KH,r);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};su(e,YH,o);const c={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return su(e,XH,c),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var KH={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const o=ms();o.body[0].body.push(Wa({negate:!0,body:r}),dl("Any"));const c=ms();c.body[0].body.push(QN("greedy",0,1/0,o)),n(En(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(o=>o.kind==="flags");for(let o=n+1;o<t.body.length;o++){const c=t.body[o];wu(r,c,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=lT(t.get(e));if(r){const a=ms({flags:r});a.body[0].body=e.body,e.body=[En(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:o,replaceWith:c},u){const{kind:d,negate:h}=e,{asciiWordBoundaries:m,avoidSubclass:f,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(En(Wa({body:[ao({body:[Dy("string_end")]}),ao({body:[cm(10)]})]}),t));else if(d==="line_start")c(En(li(_t`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(g.has(e))a.flags.sticky=!0,o();else{const w=r[n-1];if(w&&n7(w))c(En(Wa({negate:!0}),t));else{if(f)throw new Error(_t`Uses "\G" in a way that requires a subclass`);c(Ji(Dy("string_start"),t)),u.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")c(En(li(_t`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!x&&!m){const w=`(?:(?<=${oi})(?!${oi})|(?<!${oi})(?=${oi}))`,C=`(?:(?<=${oi})(?=${oi})|(?<!${oi})(?!${oi}))`;c(En(li(h?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Sx(n)&&(n=_x(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Sx(r)&&(r=_x(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=Fh({body:[e]});n(En(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:o,spaceIsAscii:c,wordIsAscii:u}){const{kind:d,negate:h,value:m}=e;if(o&&(d==="digit"||m==="digit")){n(Ji(Iy("digit",{negate:h}),t));return}if(c&&(d==="space"||m==="space")){n(En(wx(li(FH),h),t));return}if(u&&(d==="word"||m==="word")){n(Ji(Iy("word",{negate:h}),t));return}if(d==="any")n(Ji(dl("Any"),t));else if(d==="digit")n(Ji(dl("Nd",{negate:h}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(_t`Use of "\X" requires non-strict accuracy`);const f="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",g=_t`\p{RI}{2}|${f}(?:\u200D${f})*`;n(En(li(_t`(?>\r\n|${a?_t`\p{RGI_Emoji}`:g}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Ji(dl("AHex",{negate:h}),t));else if(d==="newline")n(En(li(h?`[^
244
+ ]`:`(?>\r
245
+ ?|[
246
+ \v\f…\u2028\u2029])`),t));else if(d==="posix")if(!a&&(m==="graph"||m==="print")){if(r==="strict")throw new Error(`POSIX class "${m}" requires min target ES2024 or non-strict accuracy`);let f={graph:"!-~",print:" -~"}[m];h&&(f=`\0-${$n(f.codePointAt(0)-1)}${$n(f.codePointAt(2)+1)}-􏿿`),n(En(li(`[${f}]`),t))}else n(En(wx(li(WH.get(m)),h),t));else if(d==="property")ov.has(um(m))||(e.key="sc");else if(d==="space")n(Ji(dl("space",{negate:h}),t));else if(d==="word")n(En(wx(li(oi),h),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:a,removeAllPrevSiblings:o,removeAllNextSiblings:c}){const{kind:u,flags:d}=e;if(u==="flags")if(!d.enable&&!d.disable)r();else{const h=ms({flags:d});h.body[0].body=c(),a(En(h,t),{traverse:!0})}else if(u==="keep"){const h=n.body[0],f=n.body.length===1&&KN(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==f||f.body.length>1)throw new Error(_t`Uses "\K" in a way that's unsupported`);const g=Wa({behind:!0});g.body[0].body=o(),a(En(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(En(Wa({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=ms();t.body[0].body.push(e.body),e.body=En(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,a=!1;for(const o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const c=uT(o.body);c?(r=!0,Array.isArray(c)?n.push(...c):n.push(c)):a=!0}r&&!a&&n.forEach(o=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(_t`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Sx(n)&&(n=_x(n,t),e.ref=n)}},YH={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:a}=e;r||n.set(e,[...t.get(a).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:a,groupsByName:o,multiplexCapturesToLeftByRef:c,openRefs:u,reffedNodesByReferencer:d}){const h=a.get(e);if(h&&u.has(e.number)){const f=Ji(sk(e.number),t);d.set(f,u.get(e.number)),n(f);return}u.set(e.number,e),c.set(e.number,[]),e.name&&wu(c,e.name,[]);const m=c.get(e.name??e.number);for(let f=0;f<m.length;f++){const g=m[f];if(h===g.node||h&&h===g.origin||e===g.origin){m.splice(f,1);break}}if(c.get(e.number).push({node:e,origin:h}),e.name&&c.get(e.name).push({node:e,origin:h}),e.name){const f=wu(o,e.name,new Map);let g=!1;if(h)g=!0;else for(const x of f.values())if(!x.hasDuplicateNameToRemove){g=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:g})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=hf(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:a,ref:o}=e;if(a){let m=t;for(;(m=m.parent)&&!(m.type==="CapturingGroup"&&(m.name===o||m.number===o)););r.reffedNodesByReferencer.set(e,m);return}const c=r.subroutineRefMap.get(o),u=o===0,d=u?sk(0):oT(c,r.groupOriginByCopy,null);let h=d;if(!u){const m=lT(ZH(c,g=>g.type==="Group"&&!!g.flags)),f=m?hf(r.globalFlags,m):r.globalFlags;QH(f,r.currentFlags)||(h=ms({flags:e7(f)}),h.body[0].body.push(d))}n(En(h,t),{traverse:!u})}},XH={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const o=r.reffedNodesByReferencer.get(e).filter(c=>JH(c,e));if(!o.length)n(En(Wa({negate:!0}),t));else if(o.length>1){const c=ms({atomic:!0,body:o.reverse().map(u=>ao({body:[Oy(u.number)]}))});n(En(c,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const a=XN();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function aT(e){su(e,{"*"({node:t,parent:n}){t.parent=n}})}function QH(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function JH(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=cT(n.parent);for(const a of r){if(a===n)break;if(a===e||dT(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function oT(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))o==="parent"?a.parent=Array.isArray(n)?r:n:c&&typeof c=="object"?a[o]=oT(c,t,a,n):(o==="type"&&c==="CapturingGroup"&&t.set(a,t.get(e)??e),a[o]=c);return a}function sk(e){const t=JN(e);return t.isRecursive=!0,t}function ZH(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function _x(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 lT(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var o,c;(o=r.enable)!=null&&o[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 e7({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 cT(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function uT(e){const t=e.find(n=>n.kind==="search_start"||r7(n,{negate:!1})||!t7(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=uT(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function dT(e,t){const n=cT(e)??[];for(const r of n)if(r===t||dT(r,t))return!0;return!1}function t7({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function n7(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function r7(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&KN(e.body[0],{type:"Assertion",kind:"search_start"})}function Sx(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function li(e,t){const r=YN(e,{...t,unicodePropertyMap:ov}).body;return r.length>1||r[0].body.length>1?ms({body:r}):r[0].body[0]}function wx(e,t){return e.negate=t,e}function Ji(e,t){return e.parent=t,e}function En(e,t){return aT(e),e.parent=t,e}function s7(e,t){const n=rT(t),r=Py(n.target,"ES2024"),a=Py(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let c=null,u=null;if(!a){const x=[e.flags.ignoreCase];su(e,i7,{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 m={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:o,useAppliedIgnoreCase:!!(!a&&c&&u),useFlagMods:a,useFlagV:r,verbose:n.verbose};function f(x){return m.lastNode=h,h=x,BH(a7[x.type],`Unexpected node type "${x.type}"`)(x,m,f)}const g={pattern:e.body.map(f).join("|"),flags:f(e.flags),options:{...e.options}};return r||(delete g.options.force.v,g.options.disable.v=!0,g.options.unicodeSetsPlugin=null),g._captureTransfers=new Map,g._hiddenCaptures=[],m.captureMap.forEach((x,w)=>{x.hidden&&g._hiddenCaptures.push(w),x.transferTo&&wu(g._captureTransfers,x.transferTo,[]).push(w)}),g}var i7={"*":{enter({node:e},t){if(ak(e)){const n=t.getCurrentModI();t.pushModI(e.flags?hf({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){ak(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){lv($n(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),hT(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&iT.has(e.value)&&t.setHasCasedChar()}},a7={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?_t`\B`:_t`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:a,number:o}=e,c={ignoreCase:t.currentFlags.ignoreCase},u=t.originMap.get(e);return u&&(c.hidden=!0,o>u.number&&(c.transferTo=u.number)),t.captureMap.set(o,c),`(${a?`?<${a}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=$n(e),r=el(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&lv(n)){const a=sT(n);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:a,parent:o}=e;let{body:c}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");bs.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&c.some(ok)&&(c=[cm(45),...c.filter(h=>!ok(h))]);const u=()=>`[${a?"^":""}${c.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||bs.bugNestedClassIgnoresNegation)&&!a){const m=c.filter(f=>f.type==="CharacterClass"&&f.kind==="union"&&f.negate);if(m.length){const f=ms(),g=f.body[0];return f.parent=o,g.parent=f,c=c.filter(x=>!m.includes(x)),e.body=c,c.length?(e.parent=g,g.body.push(e)):f.body.pop(),m.forEach(x=>{const w=ao({body:[x]});x.parent=w,w.parent=f,f.body.push(w)}),n(f)}}t.inCharClass=!0;const h=u();return t.inCharClass=!1,h}const d=c[0];if(r==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(bs.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&c.length===1&&d.type!=="CharacterClassRange"))return c.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return u()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=el(n,a),c=el(r,a),u=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=hT(e);d7(d).forEach(m=>{u.add(Array.isArray(m)?`${el(m[0],a)}-${el(m[1],a)}`:el(m,a))})}return`${o}-${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?".":"[^]":_t`[^\n]`;if(e==="digit")return t?_t`\D`:_t`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&iT.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?_t`\P`:_t`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?_t`\W`:_t`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},a,o){const c=a.currentFlags;n&&(a.currentFlags=hf(c,n));const u=t.map(o).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?u:`(?${h7(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)+f7(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})`:_t`\g<${t}&R=${r}>`}},o7=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),l7=new Set(["-","\\","]","^","["]),c7=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),ik=new Map([[9,_t`\t`],[10,_t`\n`],[11,_t`\v`],[12,_t`\f`],[13,_t`\r`],[8232,_t`\u2028`],[8233,_t`\u2029`],[65279,_t`\uFEFF`]]),u7=new RegExp("^\\p{Cased}$","u");function lv(e){return u7.test(e)}function hT(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,a=e.max.value,o=[];if(r<65&&(a===65535||a>=131071)||r===65536&&a>=131071)return o;for(let c=r;c<=a;c++){const u=$n(c);if(!lv(u))continue;const d=sT(u).filter(h=>{const m=h.codePointAt(0);return m<r||m>a});if(d.length&&(o.push(...d),n))break}return o}function el(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(ik.has(e))return ik.get(e);if(e<32||e>126&&e<160||e>262143||t&&m7(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?c7:l7:o7,o=$n(e);return(a.has(o)?"\\":"")+o}function d7(e){const t=e.map(a=>a.codePointAt(0)).sort((a,o)=>a-o),n=[];let r=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?r??(r=t[a]):r===null?n.push(t[a]):(n.push([r,t[a]]),r=null);return n}function h7(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:a,disable:o}=t;r=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(o?"-":"")+(o!=null&&o.ignoreCase?"i":"")+(o!=null&&o.dotAll?"s":"")}return`${r}:`}function f7({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 ak({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function m7(e){return e>47&&e<58}function ok({type:e,value:t}){return e==="Character"&&t===45}var ta,fi,Ya,na,Xa,ku,By,ua,p7=(ua=class extends RegExp{constructor(n,r,a){var t=(...Kq)=>(super(...Kq),Da(this,ku),Da(this,ta,new Map),Da(this,fi,null),Da(this,Ya),Da(this,na,null),Da(this,Xa,null),Le(this,"rawOptions",{}),this);const o=!!(a!=null&&a.lazyCompile);if(n instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const c=n;t(c,r),us(this,Ya,c.source),c instanceof ua&&(us(this,ta,cr(c,ta)),us(this,na,cr(c,na)),us(this,Xa,cr(c,Xa)),this.rawOptions=c.rawOptions)}else{const c={hiddenCaptures:[],strategy:null,transfers:[],...a};t(o?"":n,r),us(this,Ya,n),us(this,ta,x7(c.hiddenCaptures,c.transfers)),us(this,Xa,c.strategy),this.rawOptions=a??{}}o||us(this,fi,this)}get source(){return cr(this,Ya)||"(?:)"}exec(n){if(!cr(this,fi)){const{lazyCompile:o,...c}=this.rawOptions;us(this,fi,new ua(cr(this,Ya),this.flags,c))}const r=this.global||this.sticky,a=this.lastIndex;if(cr(this,Xa)==="clip_search"&&r&&a){this.lastIndex=0;const o=kg(this,ku,By).call(this,n.slice(a));return o&&(g7(o,a,n,this.hasIndices),this.lastIndex+=a),o}return kg(this,ku,By).call(this,n)}},ta=new WeakMap,fi=new WeakMap,Ya=new WeakMap,na=new WeakMap,Xa=new WeakMap,ku=new WeakSet,By=function(n){cr(this,fi).lastIndex=this.lastIndex;const r=yw(ua.prototype,this,"exec").call(cr(this,fi),n);if(this.lastIndex=cr(this,fi).lastIndex,!r||!cr(this,ta).size)return r;const a=[...r];r.length=1;let o;this.hasIndices&&(o=[...r.indices],r.indices.length=1);const c=[0];for(let u=1;u<a.length;u++){const{hidden:d,transferTo:h}=cr(this,ta).get(u)??{};if(d?c.push(null):(c.push(r.length),r.push(a[u]),this.hasIndices&&r.indices.push(o[u])),h&&a[u]!==void 0){const m=c[h];if(!m)throw new Error(`Invalid capture transfer to "${m}"`);if(r[m]=a[u],this.hasIndices&&(r.indices[m]=o[u]),r.groups){cr(this,na)||us(this,na,y7(this.source));const f=cr(this,na).get(h);f&&(r.groups[f]=a[u],this.hasIndices&&(r.indices.groups[f]=o[u]))}}}return r},ua);function g7(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 o=a.groups;o&&Object.keys(o).forEach(c=>{const u=o[c];u&&(o[c]=[u[0]+t,u[1]+t])})}}function x7(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,a]of t)for(const o of a)wu(n,o,{}).transferTo=r;return n}function y7(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,o;for(;o=t.exec(e);){const{0:c,groups:{capture:u,name:d}}=o;c==="["?r++:r?c==="]"&&r--:u&&(a++,d&&n.set(a,d))}return n}function b7(e,t){const n=v7(e,t);return n.options?new p7(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function v7(e,t){const n=rT(t),r=YN(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:ov}),a=qH(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=s7(a,n),c=MH(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),u=OH(c.pattern),d=DH(u.pattern,{captureTransfers:c.captureTransfers,hiddenCaptures:c.hiddenCaptures}),h={pattern:d.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const m=d.hiddenCaptures.sort((w,C)=>w-C),f=Array.from(d.captureTransfers),g=a._strategy,x=h.pattern.length>=n.lazyCompileLength;(m.length||f.length||g||x)&&(h.options={...m.length&&{hiddenCaptures:m},...f.length&&{transfers:f},...g&&{strategy:g},...x&&{lazyCompile:x}})}return h}function fT(e,t){return b7(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function _7(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>fT(n,{target:t.target})),{createScanner(n){return new Pz(n,t)},createString(n){return{content:n}}}}V2(Wb({bundledLanguages:()=>em,bundledLanguagesAlias:()=>qb,bundledLanguagesBase:()=>Gb,bundledLanguagesInfo:()=>Zf,bundledThemes:()=>Yb,bundledThemesInfo:()=>Kb,codeToHast:()=>PN,codeToHtml:()=>MN,codeToTokens:()=>BN,codeToTokensBase:()=>$N,codeToTokensWithThemes:()=>FN,createHighlighter:()=>lm,createJavaScriptRegexEngine:()=>_7,createOnigurumaEngine:()=>q2,defaultJavaScriptRegexConstructor:()=>fT,getLastGrammarState:()=>HN,getSingletonHighlighter:()=>zN,loadWasm:()=>Qb}),Mz);let Cx=null;const iu=new Set,ph=new Map,lk=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],S7=["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"],kx={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 w7(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function mT(){return Cx||(Cx=lm({themes:S7,langs:lk}).then(e=>(lk.forEach(t=>iu.add(t)),e))),Cx}async function C7(e){if(iu.has(e))return;if(ph.has(e))return ph.get(e);const t=(async()=>{const n=await mT(),r=em[e];if(r){await n.loadLanguage(r),iu.add(e);return}try{const a=await se(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),iu.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();ph.set(e,t),await t,ph.delete(e)}const Uc=new Map,k7=50;function j7(e,t,n){return`${e}|${t}|${n}`}async function pT(e,t,n="github-dark-default"){t!=="text"&&!iu.has(t)&&await C7(t);const r=j7(e,t,n),a=Uc.get(r);if(a)return a;const c=(await mT()).codeToHtml(e,{lang:t,theme:n,transformers:[w7()]});if(Uc.size>=k7){const u=Uc.keys().next().value;u&&Uc.delete(u)}return Uc.set(r,c),c}const E7={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 fm(e){var a;if(!e)return"text";const t=Tu(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?E7[r]??"text":"text"}function gT(){const e=Xt(r=>r.currentPreset),t=Xt(r=>r.isCustom),n=Xt(r=>r.basePreset);return N7(e,t,n)}function N7(e,t,n){return t?n&&n!=="system"&&kx[n]?kx[n]??"github-dark-default":"github-dark-default":kx[e]??"github-dark-default"}function xT(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 o=document.createElement("textarea");o.value=a,o.style.position="fixed",o.style.left="-9999px",document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}n(!0),setTimeout(()=>n(!1),e)}catch(o){console.error("Failed to copy:",o)}},[e]);return{copied:t,copy:r}}const T7=5e3,Qc=new Map,A7=100,L7=20*1024*1024;let R7=L7,jx=0;function D7(e,t){for(Qc.set(e,t),jx+=e.length;Qc.size>A7||jx>R7;){const n=Qc.keys().next().value;if(n===void 0)break;Qc.delete(n),jx-=n.length}return t}const O7=j.memo(function({language:t,codeString:n,showSyntaxHighlighting:r,deferHighlight:a}){const{copied:o,copy:c}=xT(),[u,d]=j.useState(null),h=gT(),m=j.useRef(n),f=t==="text"||n.length>T7;return j.useEffect(()=>{!r||a||f||(m.current=n,pT(n,t,h).then(g=>{m.current===n&&d(g)}))},[n,t,h,r,a,f]),s.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[s.jsxs("div",{className:"absolute bottom-0 right-0 flex items-center gap-2 px-2 py-1 text-xs text-text-muted/70 bg-bg-tertiary/60 rounded-tl rounded-tr z-10",children:[s.jsx("span",{children:t}),s.jsx("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),c(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:o?s.jsx(zs,{}):s.jsx(jl,{})})]}),r&&u?s.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):s.jsx(hn,{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 I7(e,t,n){const r=e?"text-text-muted":"text-text-heading",a=e?"text-text-secondary":"text-text-bold";return{code({className:o,children:c,...u}){const d=/language-(\w+)/.exec(o||"");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 m=(d==null?void 0:d[1])||"text",f=String(c).replace(/\n$/,"");return s.jsx(O7,{language:m,codeString:f,showSyntaxHighlighting:t,deferHighlight:n})},p({children:o}){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:o})},ul({children:o}){return s.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:o})},ol({children:o}){return s.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:o})},li({children:o}){const c=e?"text-text-muted":"text-text-primary";return s.jsx("li",{className:`${c} text-sm list-item`,children:o})},h1({children:o}){return s.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:o})},h2({children:o}){return s.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:o})},h3({children:o}){return s.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:o})},h4({children:o}){return s.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:o})},strong({children:o}){return s.jsx("strong",{className:`font-bold ${a}`,children:o})},em({children:o}){return s.jsx("em",{className:e?"italic text-text-secondary":"italic",children:o})},a({href:o,children:c}){return s.jsx("a",{href:o,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:c})},blockquote({children:o}){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:o})},table({children:o}){return s.jsx(hn,{horizontal:!0,className:"my-1.5",scope:"codeBlocks",children:s.jsx("table",{className:"min-w-full border border-border",children:o})})},th({children:o}){return s.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:o})},td({children:o}){return s.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:o})},hr(){return s.jsx("hr",{className:"border-border my-2"})},input({checked:o,...c}){return s.jsx("input",{type:"checkbox",checked:o,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...c})}}}const nr=j.memo(function({content:t,className:n="",muted:r=!1,isStreaming:a=!1}){const{showSyntaxHighlighting:o,deferCodeHighlightWhileStreaming:c}=Fs(),u=j.useMemo(()=>a&&c&&bT(t)%2===1,[a,c,t]),d=j.useMemo(()=>I7(r,o,u),[r,o,u]),h=j.useMemo(()=>{const m=M7(t);if(!B7(m)){if(!m.trim())return null;const f=r?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${f} mb-1.5 last:mb-0 leading-tight break-words whitespace-pre-line`,children:P7(m)})}return a?yT(m,d):$7(m,d,r,o)},[t,a,d,r,o]);return s.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:h})});function M7(e){let t=F7(e);return t=z7(t),t.trimEnd()}function P7(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 B7(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 yT(e,t){return s.jsx(e6,{remarkPlugins:[f8],components:t,children:e})}function $7(e,t,n,r){const a=`${n?"m":"n"}|${r?"h":"p"}|${e}`,o=Qc.get(a);if(o!==void 0)return o;const c=yT(e,t);return D7(a,c)}function F7(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 bT(e){var t;return((t=e.match(/```/g))==null?void 0:t.length)??0}function z7(e){if(bT(e)%2===1){const n=e.lastIndexOf("```");return e.slice(n+3).includes(`
248
+ `),e+"\n```"}return e}function vT({isOpen:e,onClose:t,since:n}){const[r,a]=j.useState(null),[o,c]=j.useState(!1),{settings:u,getSetting:d,setSetting:h}=ma(),m=u[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";j.useEffect(()=>{e&&d(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,d]),j.useEffect(()=>{if(!e)return;c(!0);const g=n?`/api/changelog?since=${encodeURIComponent(n)}`:"/api/changelog";xe(g).then(x=>x.json()).then(x=>{a(x.content)}).catch(()=>{a(`# Changelog
249
+
250
+ Failed to load changelog.`)}).finally(()=>c(!1))},[e,n]);const f=j.useCallback(()=>{const g=m?"false":"true";h(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,g)},[m,h]);return s.jsx(jt,{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(xs,{enabled:m,onClick:f}),s.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:s.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:o?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):s.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:s.jsx(nr,{content:r??""})})})})}const H7="#6b7280";function oo(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??H7}const tl=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,ct=Jn(e=>{const t=async n=>{e({loading:!0});try{const a=await(await xe(tl("/api/agents",n))).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],modelOverrides:a.modelOverrides??{},loading:!1})}catch{e({loading:!1})}};return{defaults:[],userItems:[],projectItems:[],modelOverrides:{},loading:!1,fetchAgents:t,fetchAgent:async(n,r)=>{try{const a=await xe(tl(`/api/agents/${n}`,r));return a.ok?await a.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,a)=>{const o=await da("POST",tl("/api/agents",a),{...n,destination:r});return o.success&&await t(a),o},updateAgent:async(n,r,a)=>{const o=await da("PUT",tl(`/api/agents/${n}`,a),r);return o.success&&await t(a),o},deleteAgent:async(n,r)=>{try{const a=await xe(tl(`/api/agents/${n}`,r),{method:"DELETE"}),o=await a.json();return a.ok?(e(c=>({userItems:c.userItems.filter(u=>u.id!==n),projectItems:c.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r,a)=>Pf(tl(`/api/agents/${n}/duplicate`,a),()=>t(a),r)}});function U7({onClose:e}){const[,t]=wn(),{settings:n,getSetting:r,setSetting:a}=ma(),o=n[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",c=n[Ne.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",u=n[Ne.CACHE_WARMING]==="true",[d,h]=j.useState({openInEditor:o,dynamicPrompt:c,cacheWarming:u}),[m,f]=j.useState({patterns:[],maxRetriesPerTurn:10}),[g,x]=j.useState(""),[w,C]=j.useState(""),[b,_]=j.useState(!1),[S,v,k,E]=ly(),[N,L]=j.useState(!1),[A,O]=j.useState(!1),I=nn(M=>M.version),F=bi(M=>M.status),B=bi(M=>M.latest),z=bi(M=>M.check),Y=I&&B?{current:I,latest:B}:null,[q,W]=j.useState(!1),ee=ct(M=>M.defaults),J=ct(M=>M.userItems),H=ct(M=>M.fetchAgents),P=[...ee,...J].filter(M=>!M.subagent);j.useEffect(()=>{h({openInEditor:o,dynamicPrompt:c,cacheWarming:u})},[o,c,u]),j.useEffect(()=>{r(Ne.DISPLAY_SHOW_OPEN_IN_EDITOR),r(Ne.LLM_DYNAMIC_SYSTEM_PROMPT),r(Ne.CACHE_WARMING),r(Ne.RETRY_PATTERNS),r(Ne.PROXY_URL)},[r]),j.useEffect(()=>{const M=n[Ne.RETRY_PATTERNS];if(M)try{f(JSON.parse(M))}catch{}},[n]),j.useEffect(()=>{const M=n[Ne.PROXY_URL];M!==void 0&&x(M)},[n]),j.useEffect(()=>{H().catch(()=>{})},[H]),j.useEffect(()=>{r(Ne.DEFAULT_AGENT)},[r]),j.useEffect(()=>{const M=n[Ne.DEFAULT_AGENT];M!==void 0&&(C(M),_(!0))},[n]);const D=j.useCallback(M=>{f(M),a(Ne.RETRY_PATTERNS,JSON.stringify(M))},[a]),U=M=>{x(M),a(Ne.PROXY_URL,M)};function $(){E(async()=>(await xe("/api/proxy/test",{method:"POST"})).json())}const Q=()=>{const M=!d.openInEditor;h(X=>({...X,openInEditor:M})),a(Ne.DISPLAY_SHOW_OPEN_IN_EDITOR,String(M))},K=()=>{const M=!d.dynamicPrompt;h(X=>({...X,dynamicPrompt:M})),a(Ne.LLM_DYNAMIC_SYSTEM_PROMPT,String(M))},Z=()=>{const M=!d.cacheWarming;h(X=>({...X,cacheWarming:M})),a(Ne.CACHE_WARMING,String(M))};function V(){e(),t("/onboarding")}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[F==="available"&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:I?s.jsxs(s.Fragment,{children:["Current version: ",s.jsxs("span",{className:"font-mono",children:["v",I]})]}):"Check for a new OpenFox version."}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(st,{variant:"secondary",onClick:()=>{W(!0),z()},disabled:F==="checking",children:F==="checking"?"Checking…":"Check for Updates"}),q&&F==="upToDate"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),F==="error"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),F==="available"&&s.jsxs("button",{onClick:()=>L(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",B," →"]})]})]}),s.jsx(BE,{isOpen:N,onClose:()=>L(!1),versionInfo:Y}),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(xs,{enabled:(n[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const X=(n[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,X)}})]})]}),s.jsx(vT,{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:b?w:"",onChange:M=>{const X=M.target.value;C(X),a(Ne.DEFAULT_AGENT,X)},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:[!b&&s.jsx("option",{value:"",children:"Loading…"}),b&&s.jsx("option",{value:"",children:"System default (planner)"}),P.map(M=>s.jsx("option",{value:M.id,children:M.name},M.id))]}),P.length===0&&b&&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(st,{variant:"secondary",onClick:V,children:"Launch Onboarding"})]}),s.jsx("hr",{className:"border-border"}),s.jsx("div",{children:s.jsx(Ex,{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:Q})}),s.jsx("hr",{className:"border-border"}),s.jsx(Ex,{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:Z,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(Ms,{type:"text",value:g,onChange:M=>U(M.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),s.jsx(st,{variant:"secondary",onClick:$,style:k?{color:"rgb(63, 185, 80)"}:void 0,children:S})]}),v&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:v}),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($O,{value:m,onChange:D})]}),s.jsx("hr",{className:"border-border"}),s.jsx(Ex,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:K,boldTitle:!0})]})}function Ex({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(xs,{enabled:n,onClick:r})})]})}function V7(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function W7({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:o,onClear:c,onReset:u,onCancelRecording:d}){const h=j.useRef(null),m=j.useRef(0),f=j.useRef("");return j.useEffect(()=>{if(!r)return;const g=new Set(["Control","Shift","Alt","Meta"]);let x=[];const w=b=>{if(b.preventDefault(),b.stopPropagation(),b.key==="Escape"){d();return}if(g.has(b.key)){const v=Date.now();if(b.key===f.current&&v-m.current<400){o({type:"double-press",key:b.key,threshold:300});return}m.current=v,f.current=b.key,b.ctrlKey&&!x.includes("ctrl")&&x.push("ctrl"),b.metaKey&&!x.includes("meta")&&x.push("meta"),b.altKey&&!x.includes("alt")&&x.push("alt"),b.shiftKey&&!x.includes("shift")&&x.push("shift");return}if(x.length>0||b.ctrlKey||b.metaKey||b.altKey||b.shiftKey){const v=[...x];b.ctrlKey&&!v.includes("ctrl")&&v.push("ctrl"),b.metaKey&&!v.includes("meta")&&v.push("meta"),b.altKey&&!v.includes("alt")&&v.push("alt"),b.shiftKey&&!v.includes("shift")&&v.push("shift"),o({type:"chord",key:_1(b),modifiers:v});return}const _=Date.now(),S=_1(b);if(S===f.current&&_-m.current<400){o({type:"double-press",key:S,threshold:300});return}m.current=_,f.current=S},C=b=>{b.key==="Control"&&(x=x.filter(_=>_!=="ctrl")),b.key==="Shift"&&(x=x.filter(_=>_!=="shift")),b.key==="Alt"&&(x=x.filter(_=>_!=="alt")),b.key==="Meta"&&(x=x.filter(_=>_!=="meta"))};return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",C,!0)}},[r,o,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?Sb(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(_b,{className:"w-3.5 h-3.5"})}),!V7(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(Uf,{className:"w-3.5 h-3.5"})})]})})]})}function G7(){const{settings:e,loading:t,setSetting:n}=ma(),r=e[Ne.KEYBINDINGS],a=t[Ne.KEYBINDINGS]??!1,o=oy(r),[c,u]=j.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:o.terminalToggle,defaultBinding:Ds.terminalToggle},{id:"quickAction",label:"Quick Action",binding:o.quickAction,defaultBinding:Ds.quickAction},{id:"modelSelector",label:"Select Model",binding:o.modelSelector,defaultBinding:Ds.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:o.sessionSearch,defaultBinding:Ds.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:o.criteriaSidebar,defaultBinding:Ds.criteriaSidebar},...o.agentSwitching.map((x,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:x,defaultBinding:Ds.agentSwitching[w]??null}))],h=x=>{u(x)},m=j.useCallback((x,w)=>{const C=oy(r);if(x.startsWith("agentSwitching.")){const b=parseInt(x.split(".")[1],10);C.agentSwitching[b]=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(Ne.KEYBINDINGS,JSON.stringify(C))},[r,n]),f=j.useCallback(x=>{c&&(u(null),m(c,x))},[c,m]),g=()=>{n(Ne.KEYBINDINGS,JSON.stringify(Ds))};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(W7,{label:x.label,binding:x.binding,defaultBinding:x.defaultBinding,isRecording:c===x.id,onStartRecording:()=>h(x.id),onBindingRecorded:f,onClear:()=>m(x.id,null),onReset:()=>m(x.id,x.defaultBinding),onCancelRecording:()=>u(null)},x.id))})]})}function cv(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 uv(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function ff(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function _T({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:o,onToolToggle:c,statusDot:u,statusColor:d,actions:h,authPanel:m}){var w;const[f,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:["(",o.length," tools)"]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[ff(e.estimatedTokens)," tokens"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xs,{enabled:r,onClick:a}),h,s.jsx("span",{className:"text-xs text-text-muted",children:t?"▲":"▼"})]})]}),t&&s.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[e.config.command&&s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[e.config.command," ",((w=e.config.args)==null?void 0:w.join(" "))??""]}),e.config.url&&s.jsx("div",{className:"text-xs text-text-muted font-mono",children:e.config.url}),m,o.length===0?s.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):s.jsx("div",{className:"space-y-1",children:o.map(C=>s.jsxs("div",{className:"py-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[s.jsx("span",{className:"text-xs text-text-primary font-mono",children:C.name}),C.description&&C.description.length>80?s.jsxs("button",{onClick:()=>{const b=C.name;g(_=>{const S=new Set(_);return S.has(b)?S.delete(b):S.add(b),S})},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(yn,{rotate:f.has(C.name)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):C.description?s.jsx("span",{className:"text-xs text-text-muted ml-2",children:C.description}):null]}),s.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:ff(C.estimatedTokens)}),s.jsx(xs,{enabled:C.enabled,onClick:()=>c(C.name)})]}),C.description&&C.description.length>80&&f.has(C.name)&&s.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:C.description})]},C.name))})]})]},x)}function ck(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 uk({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(ns,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),s.jsx(ns,{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(ns,{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(ns,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}const Nx="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 q7({serverName:e,onChanged:t}){const[n,r]=j.useState(!1),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(""),m=`/api/mcp/servers/${encodeURIComponent(e)}/oauth`,f=async b=>{r(!0),h("");try{await b()}catch(_){h(_ instanceof Error?_.message:String(_))}finally{r(!1)}},g=async(b,_)=>{const S=await xe(b,{method:"POST",headers:{"Content-Type":"application/json"},..._!==void 0?{body:JSON.stringify(_)}:{}}),v=await S.json();if(!S.ok)throw new Error(v.error??"Request failed");return v},x=()=>f(async()=>{const b=await g(`${m}/start`);if(b.status!=="redirect"){t();return}o(b.redirectUri??""),window.open(b.authorizationUrl,"_blank","noopener,noreferrer")}),w=()=>f(async()=>{await g(`${m}/complete`,{response:c}),u(""),o(""),t()}),C=()=>f(async()=>{if(!(await xe(m,{method:"DELETE"})).ok)throw new Error("Could not clear the stored credentials");t()});return s.jsxs("div",{className:"space-y-1.5 py-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:x,disabled:n,className:Nx,children:"Authorize"}),s.jsx("button",{onClick:C,disabled:n,className:Nx,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:b=>u(b.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:Nx,children:"Finish"})]})]}),d&&s.jsx("div",{className:"text-xs text-accent-error",children:d})]})}function Tx(e,t,n,r=250){const a=j.useRef(!0);j.useEffect(()=>{if(a.current){a.current=!1;return}const o=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(o)},[e,t,r,n])}function dk({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(st,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),s.jsx(st,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function K7(){const{settings:e,getSetting:t,setSetting:n}=ma(),[r,a]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState(""),[h,m]=j.useState("");Tx(o,Ne.SEARCH_TAVILY_API_KEY,n),Tx(u,Ne.SEARCH_SEARXNG_URL,n),Tx(h,Ne.SEARCH_SEARXNG_API_KEY,n);const[f,g,x,w]=ly(),[C,b,_,S]=ly();j.useEffect(()=>{t(Ne.SEARCH_ENGINE),t(Ne.SEARCH_TAVILY_API_KEY),t(Ne.SEARCH_SEARXNG_URL),t(Ne.SEARCH_SEARXNG_API_KEY),t(Ne.TOOLS_USE_RTK),t(Ne.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),j.useEffect(()=>{e[Ne.SEARCH_ENGINE]!==void 0&&(a(e[Ne.SEARCH_ENGINE]??""),c(e[Ne.SEARCH_TAVILY_API_KEY]??""),d(e[Ne.SEARCH_SEARXNG_URL]??""),m(e[Ne.SEARCH_SEARXNG_API_KEY]??""))},[e]);function v(oe){a(oe),n(Ne.SEARCH_ENGINE,oe)}function k(){w(async()=>(await xe("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:o||void 0})})).json())}function E(){S(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[N,L]=j.useState("checking");j.useEffect(()=>{xe("/api/tools/rtk-check").then(oe=>oe.json()).then(oe=>L(oe.available?"available":"unavailable")).catch(()=>L("unavailable"))},[]);const[A,O]=j.useState([]);j.useEffect(()=>{t(Ne.TOOLS_SHELL),xe("/api/tools/shells").then(oe=>oe.json()).then(oe=>O(oe.shells??[])).catch(()=>O([]))},[t]);const I=e[Ne.TOOLS_SHELL]||"cmd",[F,B]=j.useState([]),[z,Y]=j.useState(!0),[q,W]=j.useState(!1),[ee,J]=j.useState(null),[H,P]=j.useState(new Set),[D,U]=j.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""}),[$,Q]=j.useState(""),[K,Z]=j.useState(""),[V,M]=j.useState(!1),{requestDelete:X,clearConfirm:ne,isConfirming:re}=Nu(),ie=j.useCallback(async()=>{try{const He=((await(await xe("/api/mcp/servers")).json()).servers??[]).sort((he,Te)=>he.name.localeCompare(Te.name));B(He)}catch{}Y(!1)},[]);j.useEffect(()=>{ie()},[ie]),j.useEffect(()=>{const oe=()=>ie();return window.addEventListener("mcp-servers-changed",oe),()=>window.removeEventListener("mcp-servers-changed",oe)},[ie]);const ge=oe=>{P(Me=>{const He=new Set(Me);return He.has(oe)?(He.delete(oe),He):(He.add(oe),He)})};function ke(){if(D.transport==="stdio"&&!D.command)return"Command is required for stdio transport";if(D.transport==="http"&&!D.url)return"URL is required for HTTP transport";if(D.timeout){const oe=parseFloat(D.timeout);if(isNaN(oe)||oe<=0)return"Timeout must be a positive number"}return null}function Oe(oe){const Me=oe?{name:D.name,transport:D.transport}:{transport:D.transport};if(D.transport==="stdio"?(Me.command=D.command,Me.args=D.args?D.args.split(" ").filter(Boolean):[],Me.env=ck(D.env)):(Me.url=D.url,Me.headers=ck(D.headers),Me.oauth=D.oauth),D.timeout){const He=parseFloat(D.timeout);!isNaN(He)&&He>0&&(Me.timeout=He)}return Me}const Fe={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""},we=async()=>{if(Q(""),!D.name){Q("Name is required");return}const oe=ke();if(oe){Q(oe);return}M(!0);try{const Me=Oe(!0),He=await xe("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Me)});if(!He.ok){const he=await He.json();throw new Error(he.error??"Failed to add server")}W(!1),U(Fe),await ie()}catch(Me){Q(Me instanceof Error?Me.message:String(Me))}finally{M(!1)}},We=oe=>{var Me;U({name:oe.name,transport:oe.config.transport,command:oe.config.command??"",args:((Me=oe.config.args)==null?void 0:Me.join(" "))??"",env:oe.config.env?Object.entries(oe.config.env).map(([He,he])=>`${He}=${he}`).join(`
252
+ `):"",url:oe.config.url??"",headers:oe.config.headers?Object.entries(oe.config.headers).map(([He,he])=>`${He}=${he}`).join(`
253
+ `):"",oauth:oe.config.oauth??!1,timeout:oe.config.timeout!==void 0?String(oe.config.timeout):""}),Q(""),J(oe.name)},Xe=async()=>{Q("");const oe=ke();if(oe){Q(oe);return}M(!0);try{const Me=Oe(!1),He=await xe(`/api/mcp/servers/${encodeURIComponent(ee)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Me)});if(!He.ok){const he=await He.json();throw new Error(he.error??"Failed to update server")}J(null),U(Fe),await ie()}catch(Me){Q(Me instanceof Error?Me.message:String(Me))}finally{M(!1)}},_e=async oe=>{try{const Me=await xe(`/api/mcp/servers/${encodeURIComponent(oe)}`,{method:"DELETE"});if(!Me.ok){const He=await Me.json().catch(()=>({}));throw new Error(He.error??"Failed to remove server")}ne(),Z(""),await ie()}catch(Me){Z(Me instanceof Error?Me.message:String(Me))}},ye=async(oe,Me,He)=>{try{const he=await xe(`/api/mcp/servers/${encodeURIComponent(oe)}/tools/${encodeURIComponent(Me)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})});if(!he.ok){const Te=await he.json().catch(()=>({}));throw new Error(Te.error??"Failed to toggle tool")}Z(""),await ie()}catch(he){Z(he instanceof Error?he.message:String(he))}},fe=async(oe,Me)=>{try{const He=await xe(`/api/mcp/servers/${encodeURIComponent(oe)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:Me})});if(!He.ok){const he=await He.json().catch(()=>({}));throw new Error(he.error??"Failed to toggle server")}Z(""),await ie()}catch(He){Z(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(oe=>s.jsx("button",{onClick:()=>v(oe),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===oe?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:oe||"Off"},oe))})]}),r==="tavily"&&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(Ms,{type:"password",value:o,onChange:oe=>c(oe.target.value),placeholder:"tvly-...",className:"flex-1"}),s.jsx(st,{variant:"secondary",onClick:k,style:x?{color:"rgb(63, 185, 80)"}:void 0,children:f})]}),g&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:g}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",s.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),s.jsx(Ms,{type:"url",value:u,onChange:oe=>d(oe.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(Ms,{type:"password",value:h,onChange:oe=>m(oe.target.value),placeholder:"Optional API key",className:"w-full"})]}),s.jsx(st,{variant:"secondary",onClick:E,style:_?{color:"rgb(63, 185, 80)"}:void 0,children:C}),b&&s.jsx("p",{className:"text-xs text-red-500",children:b})]})]})]}),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(oe=>s.jsxs("button",{onClick:()=>n(Ne.TOOLS_SHELL,oe.id),disabled:!oe.available,title:oe.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${I===oe.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":oe.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[oe.label,!oe.available&&" (not found)"]},oe.id))}),s.jsx("p",{className:"text-xs text-text-muted mt-2",children:"Applies to new commands and newly opened terminals. Running terminals keep their current shell."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",s.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),N==="checking"&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),N==="available"&&s.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),N==="unavailable"&&s.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),s.jsx(xs,{enabled:e[Ne.TOOLS_USE_RTK]==="true",onClick:()=>n(Ne.TOOLS_USE_RTK,e[Ne.TOOLS_USE_RTK]==="true"?"false":"true")})]}),A.length>0&&e[Ne.TOOLS_USE_RTK]==="true"&&I!=="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(xs,{enabled:e[Ne.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(Ne.CONFIRM_ON_WORKSPACE_ACTIONS,e[Ne.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(st,{variant:"primary",size:"sm",onClick:()=>W(!0),children:"+ Add Server"})]}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Show per-conversation MCP toggle in chat bar"})}),s.jsx(xs,{enabled:e[Ne.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(Ne.FEATURES_PER_SESSION_MCP,e[Ne.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),K&&s.jsx(vl,{message:K}),s.jsx(Cb,{loading:z,hasItems:F.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:F.map(oe=>{const Me=H.has(oe.name)?re(oe.name,"delete")?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:he=>{he.stopPropagation(),_e(oe.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),s.jsx("button",{onClick:he=>{he.stopPropagation(),ne()},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:he=>{he.stopPropagation(),We(oe)},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:he=>{he.stopPropagation(),X(oe.name)},className:"px-2 py-1 rounded text-xs font-medium text-accent-error/80 hover:text-accent-error hover:bg-accent-error/10 transition-colors",children:"Remove"})]}):null,He=oe.status==="error"&&oe.error?s.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:oe.error,children:oe.error}):null;return s.jsx(_T,{server:oe,expanded:H.has(oe.name),onToggleExpand:ge,serverToggleEnabled:!oe.config.disabled,onServerToggle:()=>fe(oe.name,!oe.config.disabled),tools:oe.tools,onToolToggle:he=>{var Te;return ye(oe.name,he,!((Te=oe.tools.find(Qe=>Qe.name===he))!=null&&Te.enabled))},statusDot:uv(oe.status),statusColor:cv(oe.status),authPanel:oe.config.oauth?s.jsx(q7,{serverName:oe.name,onChanged:ie}):null,actions:s.jsxs(s.Fragment,{children:[He,Me]})},oe.name)})}),q&&s.jsx(jt,{isOpen:q,onClose:()=>{W(!1),Q("")},title:"Add MCP Server",size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(ns,{label:"Name",value:D.name,onChange:oe=>U({...D,name:oe}),placeholder:"e.g. filesystem"}),s.jsx(uk,{formData:D,onChange:U}),$&&s.jsx(vl,{message:$}),s.jsx(dk,{saving:V,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{W(!1),Q(""),M(!1),U(Fe)},onSave:we})]})}),ee!==null&&s.jsx(jt,{isOpen:!0,onClose:()=>{J(null),Q("")},title:`Edit MCP Server: ${ee}`,size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(uk,{formData:D,onChange:U}),$&&s.jsx(vl,{message:$}),s.jsx(dk,{saving:V,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{J(null),Q(""),M(!1),U(Fe)},onSave:Xe})]})})]})]})}const ST="openfox_user_plugins";function Y7(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function Ax(e){const t=Y7(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 gh(){try{return JSON.parse(localStorage.getItem(ST)??"[]")}catch{return[]}}function hk(e){localStorage.setItem(ST,JSON.stringify(e))}function X7({onAdd:e}){const[t,n]=j.useState(""),[r,a]=j.useState(""),[o,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(st,{type:"submit",variant:"primary",size:"sm",children:o?"Added":"Add"})]})}function Q7({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[o,c]=j.useState(t?"installed":"idle"),[u,d]=j.useState(!1),[h,m]=j.useState(""),[f,g]=j.useState(n),[x,w]=j.useState(!1),[C,b]=j.useState(!1);j.useEffect(()=>{g(n)},[n]);const _=j.useCallback(async()=>{const I=await xe("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),F=await I.json();if(I.ok)c("installed"),e.latestVersion&&g(e.latestVersion),F.loaded||m(F.loadError??"Plugin installed but failed to load");else throw new Error(F.error??"Install failed")},[e.githubUrl,e.name]),S=async()=>{c("installing"),m("");try{await _()}catch(I){c("error"),m(I instanceof Error?I.message:"Connection error")}},v=()=>{w(!0)},k=async()=>{b(!0);try{(await xe(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(c("idle"),r(e.name))}catch{}b(!1),w(!1)},E=async()=>{d(!0),m("");try{await _()}catch(I){m(I instanceof Error?I.message:"Update failed")}d(!1)},N=f??n,L=e.latestVersion&&N&&N!=="unknown"&&e.latestVersion!==N,A=o==="installing"?"Installing…":u?"Updating…":o==="installed"?"Installed ✓":"Install",O=o==="installing"||o==="installed"||u;return s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&s.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?s.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?s.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,N&&N!=="unknown"&&s.jsxs("span",{className:"text-text-muted",children:["installed: v",N]})]}),o==="error"&&h&&s.jsx("p",{className:"text-xs text-accent-error mt-1",children:h})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[s.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&s.jsx(st,{variant:o==="installed"?"secondary":"primary",size:"sm",onClick:S,disabled:O,children:A}),L&&s.jsx(st,{variant:"primary",size:"sm",onClick:E,children:"Update"}),o==="installed"&&s.jsx(st,{variant:"danger",size:"sm",onClick:v,children:"Remove"})]}),o==="installed"&&s.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),s.jsx(El,{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 J7(){const[e,t]=j.useState([]),[n,r]=j.useState([]),[a,o]=j.useState({}),[c,u]=j.useState(!0),[d,h]=j.useState(""),[m,f]=j.useState("");j.useEffect(()=>{let _=!1;Promise.all([xe("/api/plugins/registry").then(v=>{if(!v.ok)throw new Error(`HTTP ${v.status}`);return v.json()}),xe("/api/plugins/installed").then(v=>v.ok?v.json():{installed:[]})]).then(([v,k])=>{if(_)return;const E={},N=k.installed;for(const F of N)E[F.name]=F.version;o(E);const L=v.plugins.map(F=>({...F,latestVersion:null,versionLoading:!0}));t(L),L.forEach(F=>{Ax(F.githubUrl).then(B=>{_||t(z=>z.map(Y=>Y.name===F.name?{...Y,latestVersion:B,versionLoading:!1}:Y))})});const A=new Set(L.map(F=>F.name)),O=gh(),I=[];for(const F of N)!A.has(F.name)&&!O.some(B=>B.name===F.name)&&I.push({name:F.name,displayName:F.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});I.length>0&&r(F=>[...F,...I])}).catch(v=>{_||h(v instanceof Error?v.message:"Failed to load plugins")}).finally(()=>{_||u(!1)});const S=gh();return S.length>0&&(r(S.map(v=>({...v,latestVersion:null,versionLoading:!0}))),S.forEach(v=>{Ax(v.githubUrl).then(k=>{_||r(E=>E.map(N=>N.name===v.name?{...N,latestVersion:k,versionLoading:!1}:N))})})),()=>{_=!0}},[]);const g=async _=>{try{_?await xe(`/api/plugins/${_}/open-folder`):await xe("/api/plugins/open-folder")}catch{}},x=j.useCallback(_=>{o(k=>{const E={...k};return delete E[_],E});const S=gh(),v=S.filter(k=>k.name!==_);v.length!==S.length&&hk(v),r(k=>k.filter(E=>E.name!==_))},[]),w=j.useCallback(_=>{if(new Set(e.map(k=>k.name)).has(_.name)){f(`"${_.displayName}" is already listed in the registry and won't be added again.`);return}const v=gh();hk([...v,_]),r(k=>[...k,{..._,latestVersion:null,versionLoading:!0}]),Ax(_.githubUrl).then(k=>{r(E=>E.map(N=>N.name===_.name?{...N,latestVersion:k,versionLoading:!1}:N))})},[e]),C=new Set,b=[...e,...n].filter(_=>C.has(_.name)?!1:(C.add(_.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]}),m&&s.jsxs("div",{className:"text-sm text-accent-warning bg-accent-warning/10 border border-accent-warning/30 rounded-lg p-3 flex justify-between items-center",children:[s.jsx("span",{children:m}),s.jsx("button",{onClick:()=>f(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),s.jsx(X7,{onAdd:w})]}),b.length===0&&!d&&s.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),b.map(_=>s.jsx(Q7,{plugin:_,initiallyInstalled:_.name in a,installedVersion:a[_.name]??null,onRemove:x,onOpenFolder:g},_.name))]})}function Z7({isOpen:e,onClose:t}){const[n,r]=j.useState("instructions"),a=bi(c=>c.status==="available"),o=()=>{try{Ht.send("context.checkDynamic",{})}catch{}t()};return s.jsx(jt,{isOpen:e,onClose:o,title:"Settings",size:"xl",scrollable:!1,children:s.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full min-h-0 -m-4",children:[s.jsxs(ft,{horizontal:!0,options:{scrollbars:{visibility:"hidden"}},className:"flex border-b border-border mb-4 flex-shrink-0 px-4 pt-4",children:[s.jsx(Yi,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),s.jsx(Yi,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),s.jsx(Yi,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),s.jsx(Yi,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),s.jsx(Yi,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),s.jsx(Yi,{label:"Display",active:n==="display",onClick:()=>r("display")}),s.jsx(Yi,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),s.jsx(Yi,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),s.jsxs(ft,{className:"flex-1 min-h-0 px-4 pb-4",children:[n==="instructions"&&s.jsx(vO,{isOpen:e}),n==="skills"&&s.jsx(bO,{isOpen:e}),n==="plugins"&&s.jsx(J7,{}),n==="notifications"&&s.jsx(cO,{}),n==="display"&&s.jsx(OO,{}),n==="keybindings"&&s.jsx(G7,{}),n==="tools"&&s.jsx(K7,{}),n==="advanced"&&s.jsx(U7,{onClose:t})]})]})})}function Yi({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 Lx={exports:{}},fk;function eU(){return fk||(fk=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(c,u,d){var h=this&&this.__decorate||function(S,v,k,E){var N,L=arguments.length,A=L<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,v,k,E);else for(var O=S.length-1;O>=0;O--)(N=S[O])&&(A=(L<3?N(A):L>3?N(v,k,A):N(v,k))||A);return L>3&&A&&Object.defineProperty(v,k,A),A},m=this&&this.__param||function(S,v){return function(k,E){v(k,E,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.AccessibilityManager=void 0;const f=d(9042),g=d(9924),x=d(844),w=d(4725),C=d(2585),b=d(3656);let _=u.AccessibilityManager=class extends x.Disposable{constructor(S,v,k,E){super(),this._terminal=S,this._coreBrowserService=k,this._renderService=E,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new g.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
254
+ `)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,b.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(S){for(let v=0;v<S;v++)this._handleChar(" ")}_handleChar(S){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==S&&(this._charsToAnnounce+=S):this._charsToAnnounce+=S,S===`
255
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=f.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(S){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(S)||this._charsToConsume.push(S)}_refreshRows(S,v){this._liveRegionDebouncer.refresh(S,v,this._terminal.rows)}_renderRows(S,v){const k=this._terminal.buffer,E=k.lines.length.toString();for(let N=S;N<=v;N++){const L=k.lines.get(k.ydisp+N),A=[],O=(L==null?void 0:L.translateToString(!0,void 0,void 0,A))||"",I=(k.ydisp+N+1).toString(),F=this._rowElements[N];F&&(O.length===0?(F.innerText=" ",this._rowColumns.set(F,[0,1])):(F.textContent=O,this._rowColumns.set(F,A)),F.setAttribute("aria-posinset",I),F.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(S,v){const k=S.target,E=this._rowElements[v===0?1:this._rowElements.length-2];if(k.getAttribute("aria-posinset")===(v===0?"1":`${this._terminal.buffer.lines.length}`)||S.relatedTarget!==E)return;let N,L;if(v===0?(N=k,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(N=this._rowElements.shift(),L=k,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),v===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(v===0?-1:1),this._rowElements[v===0?1:this._rowElements.length-2].focus(),S.preventDefault(),S.stopImmediatePropagation()}_handleSelectionChange(){var O;if(this._rowElements.length===0)return;const S=document.getSelection();if(!S)return;if(S.isCollapsed)return void(this._rowContainer.contains(S.anchorNode)&&this._terminal.clearSelection());if(!S.anchorNode||!S.focusNode)return void console.error("anchorNode and/or focusNode are null");let v={node:S.anchorNode,offset:S.anchorOffset},k={node:S.focusNode,offset:S.focusOffset};if((v.node.compareDocumentPosition(k.node)&Node.DOCUMENT_POSITION_PRECEDING||v.node===k.node&&v.offset>k.offset)&&([v,k]=[k,v]),v.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(v={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(v.node))return;const E=this._rowElements.slice(-1)[0];if(k.node.compareDocumentPosition(E)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(k={node:E,offset:((O=E.textContent)==null?void 0:O.length)??0}),!this._rowContainer.contains(k.node))return;const N=({node:I,offset:F})=>{const B=I instanceof Text?I.parentNode:I;let z=parseInt(B==null?void 0:B.getAttribute("aria-posinset"),10)-1;if(isNaN(z))return console.warn("row is invalid. Race condition?"),null;const Y=this._rowColumns.get(B);if(!Y)return console.warn("columns is null. Race condition?"),null;let q=F<Y.length?Y[F]:Y.slice(-1)[0]+1;return q>=this._terminal.cols&&(++z,q=0),{row:z,column:q}},L=N(v),A=N(k);if(L&&A){if(L.row>A.row||L.row===A.row&&L.column>=A.column)throw new Error("invalid range");this._terminal.select(L.column,L.row,(A.row-L.row)*this._terminal.cols-L.column+A.column)}}_handleResize(S){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let v=this._rowContainer.children.length;v<this._terminal.rows;v++)this._rowElements[v]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[v]);for(;this._rowElements.length>S;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const S=this._coreBrowserService.mainDocument.createElement("div");return S.setAttribute("role","listitem"),S.tabIndex=-1,this._refreshRowDimensions(S),S}_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 S=0;S<this._terminal.rows;S++)this._refreshRowDimensions(this._rowElements[S])}}_refreshRowDimensions(S){S.style.height=`${this._renderService.dimensions.css.cell.height}px`}};u.AccessibilityManager=_=h([m(1,C.IInstantiationService),m(2,w.ICoreBrowserService),m(3,w.IRenderService)],_)},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 m(g,x,w,C){g=h(g=d(g),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(g,!0),x.value=""}function f(g,x,w){const C=w.getBoundingClientRect(),b=g.clientX-C.left-10,_=g.clientY-C.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${b}px`,x.style.top=`${_}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&&m(g.clipboardData.getData("text/plain"),x,w,C)},u.paste=m,u.moveTextAreaUnderMouseCursor=f,u.rightClickHandler=function(g,x,w,C,b){f(g,x,w),b&&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(m,f,g){this._css.set(m,f,g)}getCss(m,f){return this._css.get(m,f)}setColor(m,f,g){this._color.set(m,f,g)}getColor(m,f){return this._color.get(m,f)}clear(){this._color.clear(),this._css.clear()}}},3656:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.addDisposableDomListener=void 0,u.addDisposableDomListener=function(d,h,m,f){d.addEventListener(h,m,f);let g=!1;return{dispose:()=>{g||(g=!0,d.removeEventListener(h,m,f))}}}},3551:function(c,u,d){var h=this&&this.__decorate||function(_,S,v,k){var E,N=arguments.length,L=N<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,v):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,S,v,k);else for(var A=_.length-1;A>=0;A--)(E=_[A])&&(L=(N<3?E(L):N>3?E(S,v,L):E(S,v))||L);return N>3&&L&&Object.defineProperty(S,v,L),L},m=this&&this.__param||function(_,S){return function(v,k){S(v,k,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Linkifier=void 0;const f=d(3656),g=d(8460),x=d(844),w=d(2585),C=d(4725);let b=u.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(_,S,v,k,E){super(),this._element=_,this._mouseService=S,this._renderService=v,this._bufferService=k,this._linkProviderService=E,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,f.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,f.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,f.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,f.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(_){this._lastMouseEvent=_;const S=this._positionFromMouseEvent(_,this._element,this._mouseService);if(!S)return;this._isMouseOut=!1;const v=_.composedPath();for(let k=0;k<v.length;k++){const E=v[k];if(E.classList.contains("xterm"))break;if(E.classList.contains("xterm-hover"))return}this._lastBufferCell&&S.x===this._lastBufferCell.x&&S.y===this._lastBufferCell.y||(this._handleHover(S),this._lastBufferCell=S)}_handleHover(_){if(this._activeLine!==_.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(_,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,_)||(this._clearCurrentLink(),this._askForLink(_,!0))}_askForLink(_,S){var k,E;this._activeProviderReplies&&S||((k=this._activeProviderReplies)==null||k.forEach((N=>{N==null||N.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=_.y);let v=!1;for(const[N,L]of this._linkProviderService.linkProviders.entries())S?(E=this._activeProviderReplies)!=null&&E.get(N)&&(v=this._checkLinkProviderResult(N,_,v)):L.provideLinks(_.y,(A=>{var I,F;if(this._isMouseOut)return;const O=A==null?void 0:A.map((B=>({link:B})));(I=this._activeProviderReplies)==null||I.set(N,O),v=this._checkLinkProviderResult(N,_,v),((F=this._activeProviderReplies)==null?void 0:F.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(_.y,this._activeProviderReplies)}))}_removeIntersectingLinks(_,S){const v=new Set;for(let k=0;k<S.size;k++){const E=S.get(k);if(E)for(let N=0;N<E.length;N++){const L=E[N],A=L.link.range.start.y<_?0:L.link.range.start.x,O=L.link.range.end.y>_?this._bufferService.cols:L.link.range.end.x;for(let I=A;I<=O;I++){if(v.has(I)){E.splice(N--,1);break}v.add(I)}}}}_checkLinkProviderResult(_,S,v){var N;if(!this._activeProviderReplies)return v;const k=this._activeProviderReplies.get(_);let E=!1;for(let L=0;L<_;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(E=!0);if(!E&&k){const L=k.find((A=>this._linkAtPosition(A.link,S)));L&&(v=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!v)for(let L=0;L<this._activeProviderReplies.size;L++){const A=(N=this._activeProviderReplies.get(L))==null?void 0:N.find((O=>this._linkAtPosition(O.link,S)));if(A){v=!0,this._handleNewLink(A);break}}return v}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(_){if(!this._currentLink)return;const S=this._positionFromMouseEvent(_,this._element,this._mouseService);S&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,S)&&this._currentLink.link.activate(_,this._currentLink.link.text)}_clearCurrentLink(_,S){this._currentLink&&this._lastMouseEvent&&(!_||!S||this._currentLink.link.range.start.y>=_&&this._currentLink.link.range.end.y<=S)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(_){if(!this._lastMouseEvent)return;const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._linkAtPosition(_.link,S)&&(this._currentLink=_,this._currentLink.state={decorations:{underline:_.link.decorations===void 0||_.link.decorations.underline,pointerCursor:_.link.decorations===void 0||_.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,_.link,this._lastMouseEvent),_.link.decorations={},Object.defineProperties(_.link.decorations,{pointerCursor:{get:()=>{var v,k;return(k=(v=this._currentLink)==null?void 0:v.state)==null?void 0:k.decorations.pointerCursor},set:v=>{var k;(k=this._currentLink)!=null&&k.state&&this._currentLink.state.decorations.pointerCursor!==v&&(this._currentLink.state.decorations.pointerCursor=v,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",v))}},underline:{get:()=>{var v,k;return(k=(v=this._currentLink)==null?void 0:v.state)==null?void 0:k.decorations.underline},set:v=>{var k,E,N;(k=this._currentLink)!=null&&k.state&&((N=(E=this._currentLink)==null?void 0:E.state)==null?void 0:N.decorations.underline)!==v&&(this._currentLink.state.decorations.underline=v,this._currentLink.state.isHovered&&this._fireUnderlineEvent(_.link,v))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((v=>{if(!this._currentLink)return;const k=v.start===0?0:v.start+1+this._bufferService.buffer.ydisp,E=this._bufferService.buffer.ydisp+1+v.end;if(this._currentLink.link.range.start.y>=k&&this._currentLink.link.range.end.y<=E&&(this._clearCurrentLink(k,E),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(_,S,v){var k;(k=this._currentLink)!=null&&k.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(S,!0),this._currentLink.state.decorations.pointerCursor&&_.classList.add("xterm-cursor-pointer")),S.hover&&S.hover(v,S.text)}_fireUnderlineEvent(_,S){const v=_.range,k=this._bufferService.buffer.ydisp,E=this._createLinkUnderlineEvent(v.start.x-1,v.start.y-k-1,v.end.x,v.end.y-k-1,void 0);(S?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(E)}_linkLeave(_,S,v){var k;(k=this._currentLink)!=null&&k.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(S,!1),this._currentLink.state.decorations.pointerCursor&&_.classList.remove("xterm-cursor-pointer")),S.leave&&S.leave(v,S.text)}_linkAtPosition(_,S){const v=_.range.start.y*this._bufferService.cols+_.range.start.x,k=_.range.end.y*this._bufferService.cols+_.range.end.x,E=S.y*this._bufferService.cols+S.x;return v<=E&&E<=k}_positionFromMouseEvent(_,S,v){const k=v.getCoords(_,S,this._bufferService.cols,this._bufferService.rows);if(k)return{x:k[0],y:k[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(_,S,v,k,E){return{x1:_,y1:S,x2:v,y2:k,cols:this._bufferService.cols,fg:E}}};u.Linkifier=b=h([m(1,C.IMouseService),m(2,C.IRenderService),m(3,w.IBufferService),m(4,C.ILinkProviderService)],b)},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,b,_,S){var v,k=arguments.length,E=k<3?b:S===null?S=Object.getOwnPropertyDescriptor(b,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,b,_,S);else for(var N=C.length-1;N>=0;N--)(v=C[N])&&(E=(k<3?v(E):k>3?v(b,_,E):v(b,_))||E);return k>3&&E&&Object.defineProperty(b,_,E),E},m=this&&this.__param||function(C,b){return function(_,S){b(_,S,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkProvider=void 0;const f=d(511),g=d(2585);let x=u.OscLinkProvider=class{constructor(C,b,_){this._bufferService=C,this._optionsService=b,this._oscLinkService=_}provideLinks(C,b){var O;const _=this._bufferService.buffer.lines.get(C-1);if(!_)return void b(void 0);const S=[],v=this._optionsService.rawOptions.linkHandler,k=new f.CellData,E=_.getTrimmedLength();let N=-1,L=-1,A=!1;for(let I=0;I<E;I++)if(L!==-1||_.hasContent(I)){if(_.loadCell(I,k),k.hasExtendedAttrs()&&k.extended.urlId){if(L===-1){L=I,N=k.extended.urlId;continue}A=k.extended.urlId!==N}else L!==-1&&(A=!0);if(A||L!==-1&&I===E-1){const F=(O=this._oscLinkService.getLinkData(N))==null?void 0:O.uri;if(F){const B={start:{x:L+1,y:C},end:{x:I+(A||I!==E-1?0:1),y:C}};let z=!1;if(!(v!=null&&v.allowNonHttpProtocols))try{const Y=new URL(F);["http:","https:"].includes(Y.protocol)||(z=!0)}catch{z=!0}z||S.push({text:F,range:B,activate:(Y,q)=>v?v.activate(Y,q,B):w(0,q),hover:(Y,q)=>{var W;return(W=v==null?void 0:v.hover)==null?void 0:W.call(v,Y,q,B)},leave:(Y,q)=>{var W;return(W=v==null?void 0:v.leave)==null?void 0:W.call(v,Y,q,B)}})}A=!1,k.hasExtendedAttrs()&&k.extended.urlId?(L=I,N=k.extended.urlId):(L=-1,N=-1)}}b(S)}};function w(C,b){if(confirm(`Do you want to navigate to ${b}?
256
+
257
+ WARNING: This link could potentially be dangerous`)){const _=window.open();if(_){try{_.opener=null}catch{}_.location.href=b}else console.warn("Opening link blocked as opener could not be cleared")}}u.OscLinkProvider=x=h([m(0,g.IBufferService),m(1,g.IOptionsService),m(2,g.IOscLinkService)],x)},6193:(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,m){this._rowCount=m,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),m=d(3656),f=d(3551),g=d(9042),x=d(3730),w=d(1680),C=d(3107),b=d(5744),_=d(2950),S=d(1296),v=d(428),k=d(4269),E=d(5114),N=d(8934),L=d(3230),A=d(9312),O=d(4725),I=d(6731),F=d(8055),B=d(8969),z=d(8460),Y=d(844),q=d(6114),W=d(8437),ee=d(2584),J=d(7399),H=d(5941),P=d(9074),D=d(2585),U=d(5435),$=d(4567),Q=d(779);class K extends B.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(V={}){super(V),this.browser=q,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new Y.MutableDisposable),this._onCursorMove=this.register(new z.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new z.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new z.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new z.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new z.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new z.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new z.EventEmitter),this._onBlur=this.register(new z.EventEmitter),this._onA11yCharEmitter=this.register(new z.EventEmitter),this._onA11yTabEmitter=this.register(new z.EventEmitter),this._onWillOpen=this.register(new z.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(D.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Q.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,X)=>this.refresh(M,X)))),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,z.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,z.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,z.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,z.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((M=>this._afterResize(M.cols,M.rows)))),this.register((0,Y.toDisposable)((()=>{var M,X;this._customKeyEventHandler=void 0,(X=(M=this.element)==null?void 0:M.parentNode)==null||X.removeChild(this.element)})))}_handleColorEvent(V){if(this._themeService)for(const M of V){let X,ne="";switch(M.index){case 256:X="foreground",ne="10";break;case 257:X="background",ne="11";break;case 258:X="cursor",ne="12";break;default:X="ansi",ne="4;"+M.index}switch(M.type){case 0:const re=F.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[M.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${ee.C0.ESC}]${ne};${(0,H.toRgbString)(re)}${ee.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((ie=>ie.ansi[M.index]=F.channels.toColor(...M.color)));else{const ie=X;this._themeService.modifyColors((ge=>ge[ie]=F.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(V){V?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(V){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ee.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var V;return(V=this.textarea)==null?void 0:V.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ee.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const V=this.buffer.ybase+this.buffer.y,M=this.buffer.lines.get(V);if(!M)return;const X=Math.min(this.buffer.x,this.cols-1),ne=this._renderService.dimensions.css.cell.height,re=M.getWidth(X),ie=this._renderService.dimensions.css.cell.width*re,ge=this.buffer.y*this._renderService.dimensions.css.cell.height,ke=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ke+"px",this.textarea.style.top=ge+"px",this.textarea.style.width=ie+"px",this.textarea.style.height=ne+"px",this.textarea.style.lineHeight=ne+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,m.addDisposableDomListener)(this.element,"copy",(M=>{this.hasSelection()&&(0,h.copyHandler)(M,this._selectionService)})));const V=M=>(0,h.handlePasteEvent)(M,this.textarea,this.coreService,this.optionsService);this.register((0,m.addDisposableDomListener)(this.textarea,"paste",V)),this.register((0,m.addDisposableDomListener)(this.element,"paste",V)),q.isFirefox?this.register((0,m.addDisposableDomListener)(this.element,"mousedown",(M=>{M.button===2&&(0,h.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,m.addDisposableDomListener)(this.element,"contextmenu",(M=>{(0,h.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),q.isLinux&&this.register((0,m.addDisposableDomListener)(this.element,"auxclick",(M=>{M.button===1&&(0,h.moveTextAreaUnderMouseCursor)(M,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,m.addDisposableDomListener)(this.textarea,"keyup",(V=>this._keyUp(V)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keydown",(V=>this._keyDown(V)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keypress",(V=>this._keyPress(V)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionupdate",(V=>this._compositionHelper.compositionupdate(V)))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,m.addDisposableDomListener)(this.textarea,"input",(V=>this._inputEvent(V)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(V){var X;if(!V)throw new Error("Terminal requires a parent element.");if(V.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((X=this.element)==null?void 0:X.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=V.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"),V.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,m.addDisposableDomListener)(this.screenElement,"mousemove",(ne=>this.updateCursorStyle(ne)))),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),q.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(E.CoreBrowserService,this.textarea,V.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(O.ICoreBrowserService,this._coreBrowserService),this.register((0,m.addDisposableDomListener)(this.textarea,"focus",(ne=>this._handleTextAreaFocus(ne)))),this.register((0,m.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(v.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(O.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(I.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(L.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(O.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((ne=>this._onRender.fire(ne)))),this.onResize((ne=>this._renderService.resize(ne.cols,ne.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(_.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(N.MouseService),this._instantiationService.setService(O.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(f.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((ne=>this.scrollLines(ne.amount,ne.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((ne=>this.scrollLines(ne.amount,ne.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((ne=>this._renderService.handleSelectionChanged(ne.start,ne.end,ne.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((ne=>{this.textarea.value=ne,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((ne=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,m.addDisposableDomListener)(this.element,"mousedown",(ne=>this._selectionService.handleMouseDown(ne)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(ne=>this._handleScreenReaderModeOptionChange(ne)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(b.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(ne=>{!this._overviewRulerRenderer&&ne&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(b.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(S.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const V=this,M=this.element;function X(ie){const ge=V._mouseService.getMouseReportCoords(ie,V.screenElement);if(!ge)return!1;let ke,Oe;switch(ie.overrideType||ie.type){case"mousemove":Oe=32,ie.buttons===void 0?(ke=3,ie.button!==void 0&&(ke=ie.button<3?ie.button:3)):ke=1&ie.buttons?0:4&ie.buttons?1:2&ie.buttons?2:3;break;case"mouseup":Oe=0,ke=ie.button<3?ie.button:3;break;case"mousedown":Oe=1,ke=ie.button<3?ie.button:3;break;case"wheel":if(V._customWheelEventHandler&&V._customWheelEventHandler(ie)===!1||V.viewport.getLinesScrolled(ie)===0)return!1;Oe=ie.deltaY<0?0:1,ke=4;break;default:return!1}return!(Oe===void 0||ke===void 0||ke>4)&&V.coreMouseService.triggerMouseEvent({col:ge.col,row:ge.row,x:ge.x,y:ge.y,button:ke,action:Oe,ctrl:ie.ctrlKey,alt:ie.altKey,shift:ie.shiftKey})}const ne={mouseup:null,wheel:null,mousedrag:null,mousemove:null},re={mouseup:ie=>(X(ie),ie.buttons||(this._document.removeEventListener("mouseup",ne.mouseup),ne.mousedrag&&this._document.removeEventListener("mousemove",ne.mousedrag)),this.cancel(ie)),wheel:ie=>(X(ie),this.cancel(ie,!0)),mousedrag:ie=>{ie.buttons&&X(ie)},mousemove:ie=>{ie.buttons||X(ie)}};this.register(this.coreMouseService.onProtocolChange((ie=>{ie?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ie)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&ie?ne.mousemove||(M.addEventListener("mousemove",re.mousemove),ne.mousemove=re.mousemove):(M.removeEventListener("mousemove",ne.mousemove),ne.mousemove=null),16&ie?ne.wheel||(M.addEventListener("wheel",re.wheel,{passive:!1}),ne.wheel=re.wheel):(M.removeEventListener("wheel",ne.wheel),ne.wheel=null),2&ie?ne.mouseup||(ne.mouseup=re.mouseup):(this._document.removeEventListener("mouseup",ne.mouseup),ne.mouseup=null),4&ie?ne.mousedrag||(ne.mousedrag=re.mousedrag):(this._document.removeEventListener("mousemove",ne.mousedrag),ne.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,m.addDisposableDomListener)(M,"mousedown",(ie=>{if(ie.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ie))return X(ie),ne.mouseup&&this._document.addEventListener("mouseup",ne.mouseup),ne.mousedrag&&this._document.addEventListener("mousemove",ne.mousedrag),this.cancel(ie)}))),this.register((0,m.addDisposableDomListener)(M,"wheel",(ie=>{if(!ne.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(ie)===!1)return!1;if(!this.buffer.hasScrollback){const ge=this.viewport.getLinesScrolled(ie);if(ge===0)return;const ke=ee.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ie.deltaY<0?"A":"B");let Oe="";for(let Fe=0;Fe<Math.abs(ge);Fe++)Oe+=ke;return this.coreService.triggerDataEvent(Oe,!0),this.cancel(ie,!0)}return this.viewport.handleWheel(ie)?this.cancel(ie):void 0}}),{passive:!1})),this.register((0,m.addDisposableDomListener)(M,"touchstart",(ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ie),this.cancel(ie)}),{passive:!0})),this.register((0,m.addDisposableDomListener)(M,"touchmove",(ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ie)?void 0:this.cancel(ie)}),{passive:!1}))}refresh(V,M){var X;(X=this._renderService)==null||X.refreshRows(V,M)}updateCursorStyle(V){var M;(M=this._selectionService)!=null&&M.shouldColumnSelect(V)?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(V,M,X=0){var ne;X===1?(super.scrollLines(V,M,X),this.refresh(0,this.rows-1)):(ne=this.viewport)==null||ne.scrollLines(V)}paste(V){(0,h.paste)(V,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(V){this._customKeyEventHandler=V}attachCustomWheelEventHandler(V){this._customWheelEventHandler=V}registerLinkProvider(V){return this._linkProviderService.registerLinkProvider(V)}registerCharacterJoiner(V){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const M=this._characterJoinerService.register(V);return this.refresh(0,this.rows-1),M}deregisterCharacterJoiner(V){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(V)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(V){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+V)}registerDecoration(V){return this._decorationService.registerDecoration(V)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(V,M,X){this._selectionService.setSelection(V,M,X)}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 V;(V=this._selectionService)==null||V.clearSelection()}selectAll(){var V;(V=this._selectionService)==null||V.selectAll()}selectLines(V,M){var X;(X=this._selectionService)==null||X.selectLines(V,M)}_keyDown(V){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(V)===!1)return!1;const M=this.browser.isMac&&this.options.macOptionIsMeta&&V.altKey;if(!M&&!this._compositionHelper.keydown(V))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;M||V.key!=="Dead"&&V.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,J.evaluateKeyboardEvent)(V,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(V),X.type===3||X.type===2){const ne=this.rows-1;return this.scrollLines(X.type===2?-ne:ne),this.cancel(V,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,V)||(X.cancel&&this.cancel(V,!0),!X.key||!!(V.key&&!V.ctrlKey&&!V.altKey&&!V.metaKey&&V.key.length===1&&V.key.charCodeAt(0)>=65&&V.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==ee.C0.ETX&&X.key!==ee.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:V}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||V.altKey||V.ctrlKey?this.cancel(V,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(V,M){const X=V.isMac&&!this.options.macOptionIsMeta&&M.altKey&&!M.ctrlKey&&!M.metaKey||V.isWindows&&M.altKey&&M.ctrlKey&&!M.metaKey||V.isWindows&&M.getModifierState("AltGraph");return M.type==="keypress"?X:X&&(!M.keyCode||M.keyCode>47)}_keyUp(V){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(V)===!1||((function(M){return M.keyCode===16||M.keyCode===17||M.keyCode===18})(V)||this.focus(),this.updateCursorStyle(V),this._keyPressHandled=!1)}_keyPress(V){let M;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(V)===!1)return!1;if(this.cancel(V),V.charCode)M=V.charCode;else if(V.which===null||V.which===void 0)M=V.keyCode;else{if(V.which===0||V.charCode===0)return!1;M=V.which}return!(!M||(V.altKey||V.ctrlKey||V.metaKey)&&!this._isThirdLevelShift(this.browser,V)||(M=String.fromCharCode(M),this._onKey.fire({key:M,domEvent:V}),this._showCursor(),this.coreService.triggerDataEvent(M,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(V){if(V.data&&V.inputType==="insertText"&&(!V.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const M=V.data;return this.coreService.triggerDataEvent(M,!0),this.cancel(V),!0}return!1}resize(V,M){V!==this.cols||M!==this.rows?super.resize(V,M):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(V,M){var X,ne;(X=this._charSizeService)==null||X.measure(),(ne=this.viewport)==null||ne.syncScrollArea(!0)}clear(){var V;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(W.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(V=this.viewport)==null||V.reset(),this.refresh(0,this.rows-1)}}reset(){var M,X;this.options.rows=this.rows,this.options.cols=this.cols;const V=this._customKeyEventHandler;this._setup(),super.reset(),(M=this._selectionService)==null||M.reset(),this._decorationService.reset(),(X=this.viewport)==null||X.reset(),this._customKeyEventHandler=V,this.refresh(0,this.rows-1)}clearTextureAtlas(){var V;(V=this._renderService)==null||V.clearTextureAtlas()}_reportFocus(){var V;(V=this.element)!=null&&V.classList.contains("focus")?this.coreService.triggerDataEvent(ee.C0.ESC+"[I"):this.coreService.triggerDataEvent(ee.C0.ESC+"[O")}_reportWindowsOptions(V){if(this._renderService)switch(V){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const M=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ee.C0.ESC}[4;${X};${M}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const ne=this._renderService.dimensions.css.cell.width.toFixed(0),re=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ee.C0.ESC}[6;${re};${ne}t`)}}cancel(V,M){if(this.options.cancelEvents||M)return V.preventDefault(),V.stopPropagation(),!1}}u.Terminal=K},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,m){this._rowCount=m,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 f=Date.now();if(f-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=f,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=f-this._lastRefreshMs,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const 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,k){var E,N=arguments.length,L=N<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,v):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,S,v,k);else for(var A=_.length-1;A>=0;A--)(E=_[A])&&(L=(N<3?E(L):N>3?E(S,v,L):E(S,v))||L);return N>3&&L&&Object.defineProperty(S,v,L),L},m=this&&this.__param||function(_,S){return function(v,k){S(v,k,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Viewport=void 0;const f=d(3656),g=d(4725),x=d(8460),w=d(844),C=d(2585);let b=u.Viewport=class extends w.Disposable{constructor(_,S,v,k,E,N,L,A){super(),this._viewportElement=_,this._scrollArea=S,this._bufferService=v,this._optionsService=k,this._charSizeService=E,this._renderService=N,this._coreBrowserService=L,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((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(_){this._viewportElement.style.backgroundColor=_.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(_){if(_)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 S=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==S&&(this._lastRecordedBufferHeight=S,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const _=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==_&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=_),this._refreshAnimationFrame=null}syncScrollArea(_=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(_);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(_)}_handleScroll(_){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 S=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:S,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const _=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(_*(this._smoothScrollState.target-this._smoothScrollState.origin)),_<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(_,S){const v=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(S<0&&this._viewportElement.scrollTop!==0||S>0&&v<this._lastRecordedBufferHeight)||(_.cancelable&&_.preventDefault(),!1)}handleWheel(_){const S=this._getPixelsScrolled(_);return S!==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+S:this._smoothScrollState.target+=S,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=S,this._bubbleScroll(_,S))}scrollLines(_){if(_!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const S=_*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+S,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:_,suppressScrollEvent:!1})}_getPixelsScrolled(_){if(_.deltaY===0||_.shiftKey)return 0;let S=this._applyScrollModifier(_.deltaY,_);return _.deltaMode===WheelEvent.DOM_DELTA_LINE?S*=this._currentRowHeight:_.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(S*=this._currentRowHeight*this._bufferService.rows),S}getBufferElements(_,S){var A;let v,k="";const E=[],N=S??this._bufferService.buffer.lines.length,L=this._bufferService.buffer.lines;for(let O=_;O<N;O++){const I=L.get(O);if(!I)continue;const F=(A=L.get(O+1))==null?void 0:A.isWrapped;if(k+=I.translateToString(!F),!F||O===L.length-1){const B=document.createElement("div");B.textContent=k,E.push(B),k.length>0&&(v=B),k=""}}return{bufferElements:E,cursorElement:v}}getLinesScrolled(_){if(_.deltaY===0||_.shiftKey)return 0;let S=this._applyScrollModifier(_.deltaY,_);return _.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(S/=this._currentRowHeight+0,this._wheelPartialScroll+=S,S=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):_.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(S*=this._bufferService.rows),S}_applyScrollModifier(_,S){const v=this._optionsService.rawOptions.fastScrollModifier;return v==="alt"&&S.altKey||v==="ctrl"&&S.ctrlKey||v==="shift"&&S.shiftKey?_*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:_*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(_){this._lastTouchY=_.touches[0].pageY}handleTouchMove(_){const S=this._lastTouchY-_.touches[0].pageY;return this._lastTouchY=_.touches[0].pageY,S!==0&&(this._viewportElement.scrollTop+=S,this._bubbleScroll(_,S))}};u.Viewport=b=h([m(2,C.IBufferService),m(3,C.IOptionsService),m(4,g.ICharSizeService),m(5,g.IRenderService),m(6,g.ICoreBrowserService),m(7,g.IThemeService)],b)},3107:function(c,u,d){var h=this&&this.__decorate||function(C,b,_,S){var v,k=arguments.length,E=k<3?b:S===null?S=Object.getOwnPropertyDescriptor(b,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,b,_,S);else for(var N=C.length-1;N>=0;N--)(v=C[N])&&(E=(k<3?v(E):k>3?v(b,_,E):v(b,_))||E);return k>3&&E&&Object.defineProperty(b,_,E),E},m=this&&this.__param||function(C,b){return function(_,S){b(_,S,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferDecorationRenderer=void 0;const f=d(4725),g=d(844),x=d(2585);let w=u.BufferDecorationRenderer=class extends g.Disposable{constructor(C,b,_,S,v){super(),this._screenElement=C,this._bufferService=b,this._coreBrowserService=_,this._decorationService=S,this._renderService=v,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 S;const b=this._coreBrowserService.mainDocument.createElement("div");b.classList.add("xterm-decoration"),b.classList.toggle("xterm-decoration-top-layer",((S=C==null?void 0:C.options)==null?void 0:S.layer)==="top"),b.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,b.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",b.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",b.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const _=C.options.x??0;return _&&_>this._bufferService.cols&&(b.style.display="none"),this._refreshXPosition(C,b),b}_refreshStyle(C){const b=C.marker.line-this._bufferService.buffers.active.ydisp;if(b<0||b>=this._bufferService.rows)C.element&&(C.element.style.display="none",C.onRenderEmitter.fire(C.element));else{let _=this._decorationElements.get(C);_||(_=this._createElement(C),C.element=_,this._decorationElements.set(C,_),this._container.appendChild(_),C.onDispose((()=>{this._decorationElements.delete(C),_.remove()}))),_.style.top=b*this._renderService.dimensions.css.cell.height+"px",_.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(_)}}_refreshXPosition(C,b=C.element){if(!b)return;const _=C.options.x??0;(C.options.anchor||"left")==="right"?b.style.right=_?_*this._renderService.dimensions.css.cell.width+"px":"":b.style.left=_?_*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var b;(b=this._decorationElements.get(C))==null||b.remove(),this._decorationElements.delete(C),C.dispose()}};u.BufferDecorationRenderer=w=h([m(1,x.IBufferService),m(2,f.ICoreBrowserService),m(3,x.IDecorationService),m(4,f.IRenderService)],w)},5871:(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,m){return h>=d.startBufferLine-this._linePadding[m||"full"]&&h<=d.endBufferLine+this._linePadding[m||"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(v,k,E,N){var L,A=arguments.length,O=A<3?k:N===null?N=Object.getOwnPropertyDescriptor(k,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,k,E,N);else for(var I=v.length-1;I>=0;I--)(L=v[I])&&(O=(A<3?L(O):A>3?L(k,E,O):L(k,E))||O);return A>3&&O&&Object.defineProperty(k,E,O),O},m=this&&this.__param||function(v,k){return function(E,N){k(E,N,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OverviewRulerRenderer=void 0;const f=d(5871),g=d(4725),x=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},b={full:0,left:0,center:0,right:0},_={full:0,left:0,center:0,right:0};let S=u.OverviewRulerRenderer=class extends x.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(v,k,E,N,L,A,O){var F;super(),this._viewportElement=v,this._screenElement=k,this._bufferService=E,this._decorationService=N,this._renderService=L,this._optionsService=A,this._coreBrowserService=O,this._colorZoneStore=new f.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(F=this._viewportElement.parentElement)==null||F.insertBefore(this._canvas,this._viewportElement);const I=this._canvas.getContext("2d");if(!I)throw new Error("Ctx cannot be null");this._ctx=I,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,x.toDisposable)((()=>{var B;(B=this._canvas)==null||B.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 v=Math.floor(this._canvas.width/3),k=Math.ceil(this._canvas.width/3);b.full=this._canvas.width,b.left=v,b.center=k,b.right=v,this._refreshDrawHeightConstants(),_.full=0,_.left=0,_.center=b.left,_.right=b.left+b.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const v=this._canvas.height/this._bufferService.buffer.lines.length,k=Math.round(Math.max(Math.min(v,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 v=this._colorZoneStore.zones;for(const k of v)k.position!=="full"&&this._renderColorZone(k);for(const k of v)k.position==="full"&&this._renderColorZone(k);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(v){this._ctx.fillStyle=v.color,this._ctx.fillRect(_[v.position||"full"],Math.round((this._canvas.height-1)*(v.startBufferLine/this._bufferService.buffers.active.lines.length)-C[v.position||"full"]/2),b[v.position||"full"],Math.round((this._canvas.height-1)*((v.endBufferLine-v.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[v.position||"full"]))}_queueRefresh(v,k){this._shouldUpdateDimensions=v||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=S=h([m(2,w.IBufferService),m(3,w.IDecorationService),m(4,g.IRenderService),m(5,w.IOptionsService),m(6,g.ICoreBrowserService)],S)},2950:function(c,u,d){var h=this&&this.__decorate||function(C,b,_,S){var v,k=arguments.length,E=k<3?b:S===null?S=Object.getOwnPropertyDescriptor(b,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,b,_,S);else for(var N=C.length-1;N>=0;N--)(v=C[N])&&(E=(k<3?v(E):k>3?v(b,_,E):v(b,_))||E);return k>3&&E&&Object.defineProperty(b,_,E),E},m=this&&this.__param||function(C,b){return function(_,S){b(_,S,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CompositionHelper=void 0;const f=d(4725),g=d(2585),x=d(2584);let w=u.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,b,_,S,v,k){this._textarea=C,this._compositionView=b,this._bufferService=_,this._optionsService=S,this._coreService=v,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 b={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let _;this._isSendingComposition=!1,b.start+=this._dataAlreadySent.length,_=this._isComposing?this._textarea.value.substring(b.start,b.end):this._textarea.value.substring(b.start),_.length>0&&this._coreService.triggerDataEvent(_,!0)}}),0)}else{this._isSendingComposition=!1;const b=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(b,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const b=this._textarea.value,_=b.replace(C,"");this._dataAlreadySent=_,b.length>C.length?this._coreService.triggerDataEvent(_,!0):b.length<C.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):b.length===C.length&&b!==C&&this._coreService.triggerDataEvent(b,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const b=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),_=this._renderService.dimensions.css.cell.height,S=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,v=b*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=v+"px",this._compositionView.style.top=S+"px",this._compositionView.style.height=_+"px",this._compositionView.style.lineHeight=_+"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=v+"px",this._textarea.style.top=S+"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([m(2,g.IBufferService),m(3,g.IOptionsService),m(4,g.ICoreService),m(5,f.IRenderService)],w)},9806:(c,u)=>{function d(h,m,f){const g=f.getBoundingClientRect(),x=h.getComputedStyle(f),w=parseInt(x.getPropertyValue("padding-left")),C=parseInt(x.getPropertyValue("padding-top"));return[m.clientX-g.left-w,m.clientY-g.top-C]}Object.defineProperty(u,"__esModule",{value:!0}),u.getCoords=u.getCoordsRelativeToElement=void 0,u.getCoordsRelativeToElement=d,u.getCoords=function(h,m,f,g,x,w,C,b,_){if(!w)return;const S=d(h,m,f);return S?(S[0]=Math.ceil((S[0]+(_?C/2:0))/C),S[1]=Math.ceil(S[1]/b),S[0]=Math.min(Math.max(S[0],1),g+(_?1:0)),S[1]=Math.min(Math.max(S[1],1),x),S):void 0}},9504:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.moveToCellSequence=void 0;const h=d(2584);function m(b,_,S,v){const k=b-f(b,S),E=_-f(_,S),N=Math.abs(k-E)-(function(L,A,O){let I=0;const F=L-f(L,O),B=A-f(A,O);for(let z=0;z<Math.abs(F-B);z++){const Y=g(L,A)==="A"?-1:1,q=O.buffer.lines.get(F+Y*z);q!=null&&q.isWrapped&&I++}return I})(b,_,S);return C(N,w(g(b,_),v))}function f(b,_){let S=0,v=_.buffer.lines.get(b),k=v==null?void 0:v.isWrapped;for(;k&&b>=0&&b<_.rows;)S++,v=_.buffer.lines.get(--b),k=v==null?void 0:v.isWrapped;return S}function g(b,_){return b>_?"A":"B"}function x(b,_,S,v,k,E){let N=b,L=_,A="";for(;N!==S||L!==v;)N+=k?1:-1,k&&N>E.cols-1?(A+=E.buffer.translateBufferLineToString(L,!1,b,N),N=0,b=0,L++):!k&&N<0&&(A+=E.buffer.translateBufferLineToString(L,!1,0,b+1),N=E.cols-1,b=N,L--);return A+E.buffer.translateBufferLineToString(L,!1,b,N)}function w(b,_){const S=_?"O":"[";return h.C0.ESC+S+b}function C(b,_){b=Math.floor(b);let S="";for(let v=0;v<b;v++)S+=_;return S}u.moveToCellSequence=function(b,_,S,v){const k=S.buffer.x,E=S.buffer.y;if(!S.buffer.hasScrollback)return(function(A,O,I,F,B,z){return m(O,F,B,z).length===0?"":C(x(A,O,A,O-f(O,B),!1,B).length,w("D",z))})(k,E,0,_,S,v)+m(E,_,S,v)+(function(A,O,I,F,B,z){let Y;Y=m(O,F,B,z).length>0?F-f(F,B):O;const q=F,W=(function(ee,J,H,P,D,U){let $;return $=m(H,P,D,U).length>0?P-f(P,D):J,ee<H&&$<=P||ee>=H&&$<P?"C":"D"})(A,O,I,F,B,z);return C(x(A,Y,I,q,W==="C",B).length,w(W,z))})(k,E,b,_,S,v);let N;if(E===_)return N=k>b?"D":"C",C(Math.abs(k-b),w(N,v));N=E>_?"D":"C";const L=Math.abs(E-_);return C((function(A,O){return O.cols-A})(E>_?b:k,S)+(L-1)*S.cols+1+((E>_?k:b)-1),w(N,v))}},1296:function(c,u,d){var h=this&&this.__decorate||function(z,Y,q,W){var ee,J=arguments.length,H=J<3?Y:W===null?W=Object.getOwnPropertyDescriptor(Y,q):W;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(z,Y,q,W);else for(var P=z.length-1;P>=0;P--)(ee=z[P])&&(H=(J<3?ee(H):J>3?ee(Y,q,H):ee(Y,q))||H);return J>3&&H&&Object.defineProperty(Y,q,H),H},m=this&&this.__param||function(z,Y){return function(q,W){Y(q,W,z)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRenderer=void 0;const f=d(3787),g=d(2550),x=d(2223),w=d(6171),C=d(6052),b=d(4725),_=d(8055),S=d(8460),v=d(844),k=d(2585),E="xterm-dom-renderer-owner-",N="xterm-rows",L="xterm-fg-",A="xterm-bg-",O="xterm-focus",I="xterm-selection";let F=1,B=u.DomRenderer=class extends v.Disposable{constructor(z,Y,q,W,ee,J,H,P,D,U,$,Q,K){super(),this._terminal=z,this._document=Y,this._element=q,this._screenElement=W,this._viewportElement=ee,this._helperContainer=J,this._linkifier2=H,this._charSizeService=D,this._optionsService=U,this._bufferService=$,this._coreBrowserService=Q,this._themeService=K,this._terminalClass=F++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new S.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(N),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(I),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((Z=>this._injectCss(Z)))),this._injectCss(this._themeService.colors),this._rowFactory=P.createInstance(f.DomRendererRowFactory,document),this._element.classList.add(E+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((Z=>this._handleLinkHover(Z)))),this.register(this._linkifier2.onHideLinkUnderline((Z=>this._handleLinkLeave(Z)))),this.register((0,v.toDisposable)((()=>{this._element.classList.remove(E+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const z=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*z,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*z),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/z),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/z),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const q of this._rowElements)q.style.width=`${this.dimensions.css.canvas.width}px`,q.style.height=`${this.dimensions.css.cell.height}px`,q.style.lineHeight=`${this.dimensions.css.cell.height}px`,q.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const Y=`${this._terminalSelector} .${N} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=Y,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(z){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let Y=`${this._terminalSelector} .${N} { color: ${z.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;Y+=`${this._terminalSelector} .${N} .xterm-dim { color: ${_.color.multiplyOpacity(z.foreground,.5).css};}`,Y+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;const q=`blink_underline_${this._terminalClass}`,W=`blink_bar_${this._terminalClass}`,ee=`blink_block_${this._terminalClass}`;Y+=`@keyframes ${q} { 50% { border-bottom-style: hidden; }}`,Y+=`@keyframes ${W} { 50% { box-shadow: none; }}`,Y+=`@keyframes ${ee} { 0% { background-color: ${z.cursor.css}; color: ${z.cursorAccent.css}; } 50% { background-color: inherit; color: ${z.cursor.css}; }}`,Y+=`${this._terminalSelector} .${N}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${q} 1s step-end infinite;}${this._terminalSelector} .${N}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${W} 1s step-end infinite;}${this._terminalSelector} .${N}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${ee} 1s step-end infinite;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block { background-color: ${z.cursor.css}; color: ${z.cursorAccent.css};}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${z.cursor.css} !important; color: ${z.cursorAccent.css} !important;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${z.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${z.cursor.css} inset;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${z.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,Y+=`${this._terminalSelector} .${I} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${I} div { position: absolute; background-color: ${z.selectionBackgroundOpaque.css};}${this._terminalSelector} .${I} div { position: absolute; background-color: ${z.selectionInactiveBackgroundOpaque.css};}`;for(const[J,H]of z.ansi.entries())Y+=`${this._terminalSelector} .${L}${J} { color: ${H.css}; }${this._terminalSelector} .${L}${J}.xterm-dim { color: ${_.color.multiplyOpacity(H,.5).css}; }${this._terminalSelector} .${A}${J} { background-color: ${H.css}; }`;Y+=`${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR} { color: ${_.color.opaque(z.background).css}; }${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${_.color.multiplyOpacity(_.color.opaque(z.background),.5).css}; }${this._terminalSelector} .${A}${x.INVERTED_DEFAULT_COLOR} { background-color: ${z.foreground.css}; }`,this._themeStyleElement.textContent=Y}_setDefaultSpacing(){const z=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${z}px`,this._rowFactory.defaultSpacing=z}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(z,Y){for(let q=this._rowElements.length;q<=Y;q++){const W=this._document.createElement("div");this._rowContainer.appendChild(W),this._rowElements.push(W)}for(;this._rowElements.length>Y;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(z,Y){this._refreshRowElements(z,Y),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(z,Y,q){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(z,Y,q),this.renderRows(0,this._bufferService.rows-1),!z||!Y)return;this._selectionRenderModel.update(this._terminal,z,Y,q);const W=this._selectionRenderModel.viewportStartRow,ee=this._selectionRenderModel.viewportEndRow,J=this._selectionRenderModel.viewportCappedStartRow,H=this._selectionRenderModel.viewportCappedEndRow;if(J>=this._bufferService.rows||H<0)return;const P=this._document.createDocumentFragment();if(q){const D=z[0]>Y[0];P.appendChild(this._createSelectionElement(J,D?Y[0]:z[0],D?z[0]:Y[0],H-J+1))}else{const D=W===J?z[0]:0,U=J===ee?Y[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(J,D,U));const $=H-J-1;if(P.appendChild(this._createSelectionElement(J+1,0,this._bufferService.cols,$)),J!==H){const Q=ee===H?Y[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(H,0,Q))}}this._selectionContainer.appendChild(P)}_createSelectionElement(z,Y,q,W=1){const ee=this._document.createElement("div"),J=Y*this.dimensions.css.cell.width;let H=this.dimensions.css.cell.width*(q-Y);return J+H>this.dimensions.css.canvas.width&&(H=this.dimensions.css.canvas.width-J),ee.style.height=W*this.dimensions.css.cell.height+"px",ee.style.top=z*this.dimensions.css.cell.height+"px",ee.style.left=`${J}px`,ee.style.width=`${H}px`,ee}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const z of this._rowElements)z.replaceChildren()}renderRows(z,Y){const q=this._bufferService.buffer,W=q.ybase+q.y,ee=Math.min(q.x,this._bufferService.cols-1),J=this._optionsService.rawOptions.cursorBlink,H=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let D=z;D<=Y;D++){const U=D+q.ydisp,$=this._rowElements[D],Q=q.lines.get(U);if(!$||!Q)break;$.replaceChildren(...this._rowFactory.createRow(Q,U,U===W,H,P,ee,J,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${E}${this._terminalClass}`}_handleLinkHover(z){this._setCellUnderline(z.x1,z.x2,z.y1,z.y2,z.cols,!0)}_handleLinkLeave(z){this._setCellUnderline(z.x1,z.x2,z.y1,z.y2,z.cols,!1)}_setCellUnderline(z,Y,q,W,ee,J){q<0&&(z=0),W<0&&(Y=0);const H=this._bufferService.rows-1;q=Math.max(Math.min(q,H),0),W=Math.max(Math.min(W,H),0),ee=Math.min(ee,this._bufferService.cols);const P=this._bufferService.buffer,D=P.ybase+P.y,U=Math.min(P.x,ee-1),$=this._optionsService.rawOptions.cursorBlink,Q=this._optionsService.rawOptions.cursorStyle,K=this._optionsService.rawOptions.cursorInactiveStyle;for(let Z=q;Z<=W;++Z){const V=Z+P.ydisp,M=this._rowElements[Z],X=P.lines.get(V);if(!M||!X)break;M.replaceChildren(...this._rowFactory.createRow(X,V,V===D,Q,K,U,$,this.dimensions.css.cell.width,this._widthCache,J?Z===q?z:0:-1,J?(Z===W?Y:ee)-1:-1))}}};u.DomRenderer=B=h([m(7,k.IInstantiationService),m(8,b.ICharSizeService),m(9,k.IOptionsService),m(10,k.IBufferService),m(11,b.ICoreBrowserService),m(12,b.IThemeService)],B)},3787:function(c,u,d){var h=this&&this.__decorate||function(N,L,A,O){var I,F=arguments.length,B=F<3?L:O===null?O=Object.getOwnPropertyDescriptor(L,A):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(N,L,A,O);else for(var z=N.length-1;z>=0;z--)(I=N[z])&&(B=(F<3?I(B):F>3?I(L,A,B):I(L,A))||B);return F>3&&B&&Object.defineProperty(L,A,B),B},m=this&&this.__param||function(N,L){return function(A,O){L(A,O,N)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRendererRowFactory=void 0;const f=d(2223),g=d(643),x=d(511),w=d(2585),C=d(8055),b=d(4725),_=d(4269),S=d(6171),v=d(3734);let k=u.DomRendererRowFactory=class{constructor(N,L,A,O,I,F,B){this._document=N,this._characterJoinerService=L,this._optionsService=A,this._coreBrowserService=O,this._coreService=I,this._decorationService=F,this._themeService=B,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(N,L,A){this._selectionStart=N,this._selectionEnd=L,this._columnSelectMode=A}createRow(N,L,A,O,I,F,B,z,Y,q,W){const ee=[],J=this._characterJoinerService.getJoinedCharacters(L),H=this._themeService.colors;let P,D=N.getNoBgTrimmedLength();A&&D<F+1&&(D=F+1);let U=0,$="",Q=0,K=0,Z=0,V=!1,M=0,X=!1,ne=0;const re=[],ie=q!==-1&&W!==-1;for(let ge=0;ge<D;ge++){N.loadCell(ge,this._workCell);let ke=this._workCell.getWidth();if(ke===0)continue;let Oe=!1,Fe=ge,we=this._workCell;if(J.length>0&&ge===J[0][0]){Oe=!0;const Ze=J.shift();we=new _.JoinedCellData(this._workCell,N.translateToString(!0,Ze[0],Ze[1]),Ze[1]-Ze[0]),Fe=Ze[1]-1,ke=we.getWidth()}const We=this._isCellInSelection(ge,L),Xe=A&&ge===F,_e=ie&&ge>=q&&ge<=W;let ye=!1;this._decorationService.forEachDecorationAtCell(ge,L,void 0,(Ze=>{ye=!0}));let fe=we.getChars()||g.WHITESPACE_CELL_CHAR;if(fe===" "&&(we.isUnderline()||we.isOverline())&&(fe=" "),ne=ke*z-Y.get(fe,we.isBold(),we.isItalic()),P){if(U&&(We&&X||!We&&!X&&we.bg===Q)&&(We&&X&&H.selectionForeground||we.fg===K)&&we.extended.ext===Z&&_e===V&&ne===M&&!Xe&&!Oe&&!ye){we.isInvisible()?$+=g.WHITESPACE_CELL_CHAR:$+=fe,U++;continue}U&&(P.textContent=$),P=this._document.createElement("span"),U=0,$=""}else P=this._document.createElement("span");if(Q=we.bg,K=we.fg,Z=we.extended.ext,V=_e,M=ne,X=We,Oe&&F>=ge&&F<=Fe&&(F=ge),!this._coreService.isCursorHidden&&Xe&&this._coreService.isCursorInitialized){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)B&&re.push("xterm-cursor-blink"),re.push(O==="bar"?"xterm-cursor-bar":O==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(I)switch(I){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(we.isBold()&&re.push("xterm-bold"),we.isItalic()&&re.push("xterm-italic"),we.isDim()&&re.push("xterm-dim"),$=we.isInvisible()?g.WHITESPACE_CELL_CHAR:we.getChars()||g.WHITESPACE_CELL_CHAR,we.isUnderline()&&(re.push(`xterm-underline-${we.extended.underlineStyle}`),$===" "&&($=" "),!we.isUnderlineColorDefault()))if(we.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${v.AttributeData.toColorRGB(we.getUnderlineColor()).join(",")})`;else{let Ze=we.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&we.isBold()&&Ze<8&&(Ze+=8),P.style.textDecorationColor=H.ansi[Ze].css}we.isOverline()&&(re.push("xterm-overline"),$===" "&&($=" ")),we.isStrikethrough()&&re.push("xterm-strikethrough"),_e&&(P.style.textDecoration="underline");let oe=we.getFgColor(),Me=we.getFgColorMode(),He=we.getBgColor(),he=we.getBgColorMode();const Te=!!we.isInverse();if(Te){const Ze=oe;oe=He,He=Ze;const et=Me;Me=he,he=et}let Qe,me,ze,at=!1;switch(this._decorationService.forEachDecorationAtCell(ge,L,void 0,(Ze=>{Ze.options.layer!=="top"&&at||(Ze.backgroundColorRGB&&(he=50331648,He=Ze.backgroundColorRGB.rgba>>8&16777215,Qe=Ze.backgroundColorRGB),Ze.foregroundColorRGB&&(Me=50331648,oe=Ze.foregroundColorRGB.rgba>>8&16777215,me=Ze.foregroundColorRGB),at=Ze.options.layer==="top")})),!at&&We&&(Qe=this._coreBrowserService.isFocused?H.selectionBackgroundOpaque:H.selectionInactiveBackgroundOpaque,He=Qe.rgba>>8&16777215,he=50331648,at=!0,H.selectionForeground&&(Me=50331648,oe=H.selectionForeground.rgba>>8&16777215,me=H.selectionForeground)),at&&re.push("xterm-decoration-top"),he){case 16777216:case 33554432:ze=H.ansi[He],re.push(`xterm-bg-${He}`);break;case 50331648:ze=C.channels.toColor(He>>16,He>>8&255,255&He),this._addStyle(P,`background-color:#${E((He>>>0).toString(16),"0",6)}`);break;default:Te?(ze=H.foreground,re.push(`xterm-bg-${f.INVERTED_DEFAULT_COLOR}`)):ze=H.background}switch(Qe||we.isDim()&&(Qe=C.color.multiplyOpacity(ze,.5)),Me){case 16777216:case 33554432:we.isBold()&&oe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(oe+=8),this._applyMinimumContrast(P,ze,H.ansi[oe],we,Qe,void 0)||re.push(`xterm-fg-${oe}`);break;case 50331648:const Ze=C.channels.toColor(oe>>16&255,oe>>8&255,255&oe);this._applyMinimumContrast(P,ze,Ze,we,Qe,me)||this._addStyle(P,`color:#${E(oe.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,ze,H.foreground,we,Qe,me)||Te&&re.push(`xterm-fg-${f.INVERTED_DEFAULT_COLOR}`)}re.length&&(P.className=re.join(" "),re.length=0),Xe||Oe||ye?P.textContent=$:U++,ne!==this.defaultSpacing&&(P.style.letterSpacing=`${ne}px`),ee.push(P),ge=Fe}return P&&U&&(P.textContent=$),ee}_applyMinimumContrast(N,L,A,O,I,F){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,S.treatGlyphAsBackgroundColor)(O.getCode()))return!1;const B=this._getContrastCache(O);let z;if(I||F||(z=B.getColor(L.rgba,A.rgba)),z===void 0){const Y=this._optionsService.rawOptions.minimumContrastRatio/(O.isDim()?2:1);z=C.color.ensureContrastRatio(I||L,F||A,Y),B.setColor((I||L).rgba,(F||A).rgba,z??null)}return!!z&&(this._addStyle(N,`color:${z.css}`),!0)}_getContrastCache(N){return N.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(N,L){N.setAttribute("style",`${N.getAttribute("style")||""}${L};`)}_isCellInSelection(N,L){const A=this._selectionStart,O=this._selectionEnd;return!(!A||!O)&&(this._columnSelectMode?A[0]<=O[0]?N>=A[0]&&L>=A[1]&&N<O[0]&&L<=O[1]:N<A[0]&&L>=A[1]&&N>=O[0]&&L<=O[1]:L>A[1]&&L<O[1]||A[1]===O[1]&&L===A[1]&&N>=A[0]&&N<O[0]||A[1]<O[1]&&L===O[1]&&N<O[0]||A[1]<O[1]&&L===A[1]&&N>=A[0])}};function E(N,L,A){for(;N.length<A;)N=L+N;return N}u.DomRendererRowFactory=k=h([m(1,b.ICharacterJoinerService),m(2,w.IOptionsService),m(3,b.ICoreBrowserService),m(4,w.ICoreService),m(5,w.IDecorationService),m(6,b.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 m=d.createElement("span");m.classList.add("xterm-char-measure-element");const f=d.createElement("span");f.classList.add("xterm-char-measure-element"),f.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=[m,f,g,x],this._container.appendChild(m),this._container.appendChild(f),this._container.appendChild(g),this._container.appendChild(x),h.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(d,h,m,f){d===this._font&&h===this._fontSize&&m===this._weight&&f===this._weightBold||(this._font=d,this._fontSize=h,this._weight=m,this._weightBold=f,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${m}`,this._measureElements[1].style.fontWeight=`${f}`,this._measureElements[2].style.fontWeight=`${m}`,this._measureElements[3].style.fontWeight=`${f}`,this.clear())}get(d,h,m){let f=0;if(!h&&!m&&d.length===1&&(f=d.charCodeAt(0))<256){if(this._flat[f]!==-9999)return this._flat[f];const w=this._measure(d,0);return w>0&&(this._flat[f]=w),w}let g=d;h&&(g+="B"),m&&(g+="I");let x=this._holey.get(g);if(x===void 0){let w=0;h&&(w|=1),m&&(w|=2),x=this._measure(d,w),x>0&&this._holey.set(g,x)}return x}_measure(d,h){const m=this._measureElements[h];return m.textContent=d.repeat(32),m.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(m){return 57508<=m&&m<=57558}function h(m){return m>=128512&&m<=128591||m>=127744&&m<=128511||m>=128640&&m<=128767||m>=9728&&m<=9983||m>=9984&&m<=10175||m>=65024&&m<=65039||m>=129280&&m<=129535||m>=127462&&m<=127487}Object.defineProperty(u,"__esModule",{value:!0}),u.computeNextVariantOffset=u.createRenderDimensions=u.treatGlyphAsBackgroundColor=u.allowRescaling=u.isEmoji=u.isRestrictedPowerlineGlyph=u.isPowerlineGlyph=u.throwIfFalsy=void 0,u.throwIfFalsy=function(m){if(!m)throw new Error("value must not be falsy");return m},u.isPowerlineGlyph=d,u.isRestrictedPowerlineGlyph=function(m){return 57520<=m&&m<=57527},u.isEmoji=h,u.allowRescaling=function(m,f,g,x){return f===1&&g>Math.ceil(1.5*x)&&m!==void 0&&m>255&&!h(m)&&!d(m)&&!(function(w){return 57344<=w&&w<=63743})(m)},u.treatGlyphAsBackgroundColor=function(m){return d(m)||(function(f){return 9472<=f&&f<=9631})(m)},u.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},u.computeNextVariantOffset=function(m,f,g=0){return(m-(2*Math.round(f)-g))%(2*Math.round(f))}},6052:(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(m,f,g,x=!1){if(this.selectionStart=f,this.selectionEnd=g,!f||!g||f[0]===g[0]&&f[1]===g[1])return void this.clear();const w=m.buffers.active.ydisp,C=f[1]-w,b=g[1]-w,_=Math.max(C,0),S=Math.min(b,m.rows-1);_>=m.rows||S<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=x,this.viewportStartRow=C,this.viewportEndRow=b,this.viewportCappedStartRow=_,this.viewportCappedEndRow=S,this.startCol=f[0],this.endCol=g[0])}isCellSelected(m,f,g){return!!this.hasSelection&&(g-=m.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?f>=this.startCol&&g>=this.viewportCappedStartRow&&f<this.endCol&&g<=this.viewportCappedEndRow:f<this.startCol&&g>=this.viewportCappedStartRow&&f>=this.endCol&&g<=this.viewportCappedEndRow:g>this.viewportStartRow&&g<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&g===this.viewportStartRow&&f>=this.startCol&&f<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportEndRow&&f<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportStartRow&&f>=this.startCol)}}u.createSelectionRenderModel=function(){return new 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(S,v,k,E){var N,L=arguments.length,A=L<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,v,k,E);else for(var O=S.length-1;O>=0;O--)(N=S[O])&&(A=(L<3?N(A):L>3?N(v,k,A):N(v,k))||A);return L>3&&A&&Object.defineProperty(v,k,A),A},m=this&&this.__param||function(S,v){return function(k,E){v(k,E,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharSizeService=void 0;const f=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(S,v,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 _(this._optionsService))}catch{this._measureStrategy=this.register(new b(S,v,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const S=this._measureStrategy.measure();S.width===this.width&&S.height===this.height||(this.width=S.width,this.height=S.height,this._onCharSizeChange.fire())}};u.CharSizeService=w=h([m(2,f.IOptionsService)],w);class C extends x.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(v,k){v!==void 0&&v>0&&k!==void 0&&k>0&&(this._result.width=v,this._result.height=k)}}class b extends C{constructor(v,k,E){super(),this._document=v,this._parentElement=k,this._optionsService=E,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class _ extends C{constructor(v){super(),this._optionsService=v,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 v=this._ctx.measureText("W");return this._validateAndSet(v.width,v.fontBoundingBoxAscent+v.fontBoundingBoxDescent),this._result}}},4269:function(c,u,d){var h=this&&this.__decorate||function(_,S,v,k){var E,N=arguments.length,L=N<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,v):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,S,v,k);else for(var A=_.length-1;A>=0;A--)(E=_[A])&&(L=(N<3?E(L):N>3?E(S,v,L):E(S,v))||L);return N>3&&L&&Object.defineProperty(S,v,L),L},m=this&&this.__param||function(_,S){return function(v,k){S(v,k,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharacterJoinerService=u.JoinedCellData=void 0;const f=d(3734),g=d(643),x=d(511),w=d(2585);class C extends f.AttributeData{constructor(S,v,k){super(),this.content=0,this.combinedData="",this.fg=S.fg,this.bg=S.bg,this.combinedData=v,this._width=k}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(S){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}u.JoinedCellData=C;let b=u.CharacterJoinerService=class wT{constructor(S){this._bufferService=S,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(S){const v={id:this._nextCharacterJoinerId++,handler:S};return this._characterJoiners.push(v),v.id}deregister(S){for(let v=0;v<this._characterJoiners.length;v++)if(this._characterJoiners[v].id===S)return this._characterJoiners.splice(v,1),!0;return!1}getJoinedCharacters(S){if(this._characterJoiners.length===0)return[];const v=this._bufferService.buffer.lines.get(S);if(!v||v.length===0)return[];const k=[],E=v.translateToString(!0);let N=0,L=0,A=0,O=v.getFg(0),I=v.getBg(0);for(let F=0;F<v.getTrimmedLength();F++)if(v.loadCell(F,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==O||this._workCell.bg!==I){if(F-N>1){const B=this._getJoinedRanges(E,A,L,v,N);for(let z=0;z<B.length;z++)k.push(B[z])}N=F,A=L,O=this._workCell.fg,I=this._workCell.bg}L+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-N>1){const F=this._getJoinedRanges(E,A,L,v,N);for(let B=0;B<F.length;B++)k.push(F[B])}return k}_getJoinedRanges(S,v,k,E,N){const L=S.substring(v,k);let A=[];try{A=this._characterJoiners[0].handler(L)}catch(O){console.error(O)}for(let O=1;O<this._characterJoiners.length;O++)try{const I=this._characterJoiners[O].handler(L);for(let F=0;F<I.length;F++)wT._mergeRanges(A,I[F])}catch(I){console.error(I)}return this._stringRangesToCellRanges(A,E,N),A}_stringRangesToCellRanges(S,v,k){let E=0,N=!1,L=0,A=S[E];if(A){for(let O=k;O<this._bufferService.cols;O++){const I=v.getWidth(O),F=v.getString(O).length||g.WHITESPACE_CELL_CHAR.length;if(I!==0){if(!N&&A[0]<=L&&(A[0]=O,N=!0),A[1]<=L){if(A[1]=O,A=S[++E],!A)break;A[0]<=L?(A[0]=O,N=!0):N=!1}L+=F}}A&&(A[1]=this._bufferService.cols)}}static _mergeRanges(S,v){let k=!1;for(let E=0;E<S.length;E++){const N=S[E];if(k){if(v[1]<=N[0])return S[E-1][1]=v[1],S;if(v[1]<=N[1])return S[E-1][1]=Math.max(v[1],N[1]),S.splice(E,1),S;S.splice(E,1),E--}else{if(v[1]<=N[0])return S.splice(E,0,v),S;if(v[1]<=N[1])return N[0]=Math.min(v[0],N[0]),S;v[0]<N[1]&&(N[0]=Math.min(v[0],N[0]),k=!0)}}return k?S[S.length-1][1]=v[1]:S.push(v),S}};u.CharacterJoinerService=b=h([m(0,w.IBufferService)],b)},5114:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreBrowserService=void 0;const h=d(844),m=d(8460),f=d(3656);class g extends h.Disposable{constructor(C,b,_){super(),this._textarea=C,this._window=b,this.mainDocument=_,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new x(this._window),this._onDprChange=this.register(new m.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new m.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((S=>this._screenDprMonitor.setWindow(S)))),this.register((0,m.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}u.CoreBrowserService=g;class x extends h.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new m.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,h.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,f.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.LinkProviderService=void 0;const h=d(844);class m extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(g){return this.linkProviders.push(g),{dispose:()=>{const x=this.linkProviders.indexOf(g);x!==-1&&this.linkProviders.splice(x,1)}}}}u.LinkProviderService=m},8934:function(c,u,d){var h=this&&this.__decorate||function(w,C,b,_){var S,v=arguments.length,k=v<3?C:_===null?_=Object.getOwnPropertyDescriptor(C,b):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(w,C,b,_);else for(var E=w.length-1;E>=0;E--)(S=w[E])&&(k=(v<3?S(k):v>3?S(C,b,k):S(C,b))||k);return v>3&&k&&Object.defineProperty(C,b,k),k},m=this&&this.__param||function(w,C){return function(b,_){C(b,_,w)}};Object.defineProperty(u,"__esModule",{value:!0}),u.MouseService=void 0;const f=d(4725),g=d(9806);let x=u.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,b,_,S){return(0,g.getCoords)(window,w,C,b,_,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,S)}getMouseReportCoords(w,C){const b=(0,g.getCoordsRelativeToElement)(window,w,C);if(this._charSizeService.hasValidSize)return b[0]=Math.min(Math.max(b[0],0),this._renderService.dimensions.css.canvas.width-1),b[1]=Math.min(Math.max(b[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(b[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(b[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(b[0]),y:Math.floor(b[1])}}};u.MouseService=x=h([m(0,f.IRenderService),m(1,f.ICharSizeService)],x)},3230:function(c,u,d){var h=this&&this.__decorate||function(S,v,k,E){var N,L=arguments.length,A=L<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,v,k,E);else for(var O=S.length-1;O>=0;O--)(N=S[O])&&(A=(L<3?N(A):L>3?N(v,k,A):N(v,k))||A);return L>3&&A&&Object.defineProperty(v,k,A),A},m=this&&this.__param||function(S,v){return function(k,E){v(k,E,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.RenderService=void 0;const f=d(6193),g=d(4725),x=d(8460),w=d(844),C=d(7226),b=d(2585);let _=u.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(S,v,k,E,N,L,A,O){super(),this._rowCount=S,this._charSizeService=E,this._renderer=this.register(new w.MutableDisposable),this._pausedResizeTask=new C.DebouncedIdleTask,this._observerDisposable=this.register(new w.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new f.RenderDebouncer(((I,F)=>this._renderRows(I,F)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(L.onResize((()=>this._fullRefresh()))),this.register(L.buffers.onBufferActivate((()=>{var I;return(I=this._renderer.value)==null?void 0:I.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(N.onDecorationRegistered((()=>this._fullRefresh()))),this.register(N.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(L.cols,L.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(L.buffer.y,L.buffer.y,!0)))),this.register(O.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,v),this.register(A.onWindowChange((I=>this._registerIntersectionObserver(I,v))))}_registerIntersectionObserver(S,v){if("IntersectionObserver"in S){const k=new S.IntersectionObserver((E=>this._handleIntersectionChange(E[E.length-1])),{threshold:0});k.observe(v),this._observerDisposable.value=(0,w.toDisposable)((()=>k.disconnect()))}}_handleIntersectionChange(S){this._isPaused=S.isIntersecting===void 0?S.intersectionRatio===0:!S.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(S,v,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(S,v,this._rowCount))}_renderRows(S,v){this._renderer.value&&(S=Math.min(S,this._rowCount-1),v=Math.min(v,this._rowCount-1),this._renderer.value.renderRows(S,v),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:S,end:v}),this._onRender.fire({start:S,end:v}),this._isNextRenderRedrawOnly=!0)}resize(S,v){this._rowCount=v,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(S){this._renderer.value=S,this._renderer.value&&(this._renderer.value.onRequestRedraw((v=>this.refreshRows(v.start,v.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(S){return this._renderDebouncer.addRefreshCallback(S)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var S,v;this._renderer.value&&((v=(S=this._renderer.value).clearTextureAtlas)==null||v.call(S),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(S,v){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var k;return(k=this._renderer.value)==null?void 0:k.handleResize(S,v)})):this._renderer.value.handleResize(S,v),this._fullRefresh())}handleCharSizeChanged(){var S;(S=this._renderer.value)==null||S.handleCharSizeChanged()}handleBlur(){var S;(S=this._renderer.value)==null||S.handleBlur()}handleFocus(){var S;(S=this._renderer.value)==null||S.handleFocus()}handleSelectionChanged(S,v,k){var E;this._selectionState.start=S,this._selectionState.end=v,this._selectionState.columnSelectMode=k,(E=this._renderer.value)==null||E.handleSelectionChanged(S,v,k)}handleCursorMove(){var S;(S=this._renderer.value)==null||S.handleCursorMove()}clear(){var S;(S=this._renderer.value)==null||S.clear()}};u.RenderService=_=h([m(2,b.IOptionsService),m(3,g.ICharSizeService),m(4,b.IDecorationService),m(5,b.IBufferService),m(6,g.ICoreBrowserService),m(7,g.IThemeService)],_)},9312:function(c,u,d){var h=this&&this.__decorate||function(A,O,I,F){var B,z=arguments.length,Y=z<3?O:F===null?F=Object.getOwnPropertyDescriptor(O,I):F;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(A,O,I,F);else for(var q=A.length-1;q>=0;q--)(B=A[q])&&(Y=(z<3?B(Y):z>3?B(O,I,Y):B(O,I))||Y);return z>3&&Y&&Object.defineProperty(O,I,Y),Y},m=this&&this.__param||function(A,O){return function(I,F){O(I,F,A)}};Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionService=void 0;const f=d(9806),g=d(9504),x=d(456),w=d(4725),C=d(8460),b=d(844),_=d(6114),S=d(4841),v=d(511),k=d(2585),E=" ",N=new RegExp(E,"g");let L=u.SelectionService=class extends b.Disposable{constructor(A,O,I,F,B,z,Y,q,W){super(),this._element=A,this._screenElement=O,this._linkifier=I,this._bufferService=F,this._coreService=B,this._mouseService=z,this._optionsService=Y,this._renderService=q,this._coreBrowserService=W,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new v.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new C.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new C.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=ee=>this._handleMouseMove(ee),this._mouseUpListener=ee=>this._handleMouseUp(ee),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((ee=>this._handleTrim(ee))),this.register(this._bufferService.buffers.onBufferActivate((ee=>this._handleBufferActivate(ee)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,b.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 I=this._bufferService.buffer,F=[];if(this._activeSelectionMode===3){if(A[0]===O[0])return"";const B=A[0]<O[0]?A[0]:O[0],z=A[0]<O[0]?O[0]:A[0];for(let Y=A[1];Y<=O[1];Y++){const q=I.translateBufferLineToString(Y,!0,B,z);F.push(q)}}else{const B=A[1]===O[1]?O[0]:void 0;F.push(I.translateBufferLineToString(A[1],!0,A[0],B));for(let z=A[1]+1;z<=O[1]-1;z++){const Y=I.lines.get(z),q=I.translateBufferLineToString(z,!0);Y!=null&&Y.isWrapped?F[F.length-1]+=q:F.push(q)}if(A[1]!==O[1]){const z=I.lines.get(O[1]),Y=I.translateBufferLineToString(O[1],!0,0,O[0]);z&&z.isWrapped?F[F.length-1]+=Y:F.push(Y)}}return F.map((B=>B.replace(N," "))).join(_.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()))),_.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),I=this._model.finalSelectionStart,F=this._model.finalSelectionEnd;return!!(I&&F&&O)&&this._areCoordsInSelection(O,I,F)}isCellInSelection(A,O){const I=this._model.finalSelectionStart,F=this._model.finalSelectionEnd;return!(!I||!F)&&this._areCoordsInSelection([A,O],I,F)}_areCoordsInSelection(A,O,I){return A[1]>O[1]&&A[1]<I[1]||O[1]===I[1]&&A[1]===O[1]&&A[0]>=O[0]&&A[0]<I[0]||O[1]<I[1]&&A[1]===I[1]&&A[0]<I[0]||O[1]<I[1]&&A[1]===O[1]&&A[0]>=O[0]}_selectWordAtCursor(A,O){var B,z;const I=(z=(B=this._linkifier.currentLink)==null?void 0:B.link)==null?void 0:z.range;if(I)return this._model.selectionStart=[I.start.x-1,I.start.y-1],this._model.selectionStartLength=(0,S.getRangeLength)(I,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const F=this._getMouseBufferCoords(A);return!!F&&(this._selectWordAt(F,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,f.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const I=this._renderService.dimensions.css.canvas.height;return O>=0&&O<=I?0:(O>I&&(O-=I),O=Math.min(Math.max(O,-50),50),O/=50,O/Math.abs(O)+Math.round(14*O))}shouldForceSelection(A){return _.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&&!(_.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 I=this._bufferService.buffer;if(this._model.selectionEnd[1]<I.lines.length){const F=I.lines.get(this._model.selectionEnd[1]);F&&F.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}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 I=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(I&&I[0]!==void 0&&I[1]!==void 0){const F=(0,g.moveToCellSequence)(I[0]-1,I[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(F,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd,I=!(!A||!O||A[0]===O[0]&&A[1]===O[1]);I?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,I)):this._oldHasSelection&&this._fireOnSelectionChange(A,O,I)}_fireOnSelectionChange(A,O,I){this._oldSelectionStart=A,this._oldSelectionEnd=O,this._oldHasSelection=I,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((O=>this._handleTrim(O)))}_convertViewportColToCharacterIndex(A,O){let I=O;for(let F=0;O>=F;F++){const B=A.loadCell(F,this._workCell).getChars().length;this._workCell.getWidth()===0?I--:B>1&&O!==F&&(I+=B-1)}return I}setSelection(A,O,I){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,O],this._model.selectionStartLength=I,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,O,I=!0,F=!0){if(A[0]>=this._bufferService.cols)return;const B=this._bufferService.buffer,z=B.lines.get(A[1]);if(!z)return;const Y=B.translateBufferLineToString(A[1],!1);let q=this._convertViewportColToCharacterIndex(z,A[0]),W=q;const ee=A[0]-q;let J=0,H=0,P=0,D=0;if(Y.charAt(q)===" "){for(;q>0&&Y.charAt(q-1)===" ";)q--;for(;W<Y.length&&Y.charAt(W+1)===" ";)W++}else{let Q=A[0],K=A[0];z.getWidth(Q)===0&&(J++,Q--),z.getWidth(K)===2&&(H++,K++);const Z=z.getString(K).length;for(Z>1&&(D+=Z-1,W+=Z-1);Q>0&&q>0&&!this._isCharWordSeparator(z.loadCell(Q-1,this._workCell));){z.loadCell(Q-1,this._workCell);const V=this._workCell.getChars().length;this._workCell.getWidth()===0?(J++,Q--):V>1&&(P+=V-1,q-=V-1),q--,Q--}for(;K<z.length&&W+1<Y.length&&!this._isCharWordSeparator(z.loadCell(K+1,this._workCell));){z.loadCell(K+1,this._workCell);const V=this._workCell.getChars().length;this._workCell.getWidth()===2?(H++,K++):V>1&&(D+=V-1,W+=V-1),W++,K++}}W++;let U=q+ee-J+P,$=Math.min(this._bufferService.cols,W-q+J+H-P-D);if(O||Y.slice(q,W).trim()!==""){if(I&&U===0&&z.getCodePoint(0)!==32){const Q=B.lines.get(A[1]-1);if(Q&&z.isWrapped&&Q.getCodePoint(this._bufferService.cols-1)!==32){const K=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(K){const Z=this._bufferService.cols-K.start;U-=Z,$+=Z}}}if(F&&U+$===this._bufferService.cols&&z.getCodePoint(this._bufferService.cols-1)!==32){const Q=B.lines.get(A[1]+1);if(Q!=null&&Q.isWrapped&&Q.getCodePoint(0)!==32){const K=this._getWordAt([0,A[1]+1],!1,!1,!0);K&&($+=K.length)}}return{start:U,length:$}}}_selectWordAt(A,O){const I=this._getWordAt(A,O);if(I){for(;I.start<0;)I.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[I.start,A[1]],this._model.selectionStartLength=I.length}}_selectToWordAt(A){const O=this._getWordAt(A,!0);if(O){let I=A[1];for(;O.start<0;)O.start+=this._bufferService.cols,I--;if(!this._model.areSelectionValuesReversed())for(;O.start+O.length>this._bufferService.cols;)O.length-=this._bufferService.cols,I++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?O.start:O.start+O.length,I]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const O=this._bufferService.buffer.getWrappedRangeForLine(A),I={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,S.getRangeLength)(I,this._bufferService.cols)}};u.SelectionService=L=h([m(3,k.IBufferService),m(4,k.ICoreService),m(5,w.IMouseService),m(6,k.IOptionsService),m(7,w.IRenderService),m(8,w.ICoreBrowserService)],L)},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(L,A,O,I){var F,B=arguments.length,z=B<3?A:I===null?I=Object.getOwnPropertyDescriptor(A,O):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(L,A,O,I);else for(var Y=L.length-1;Y>=0;Y--)(F=L[Y])&&(z=(B<3?F(z):B>3?F(A,O,z):F(A,O))||z);return B>3&&z&&Object.defineProperty(A,O,z),z},m=this&&this.__param||function(L,A){return function(O,I){A(O,I,L)}};Object.defineProperty(u,"__esModule",{value:!0}),u.ThemeService=u.DEFAULT_ANSI_COLORS=void 0;const f=d(7239),g=d(8055),x=d(8460),w=d(844),C=d(2585),b=g.css.toColor("#ffffff"),_=g.css.toColor("#000000"),S=g.css.toColor("#ffffff"),v=g.css.toColor("#000000"),k={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};u.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const L=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],A=[0,95,135,175,215,255];for(let O=0;O<216;O++){const I=A[O/36%6|0],F=A[O/6%6|0],B=A[O%6];L.push({css:g.channels.toCss(I,F,B),rgba:g.channels.toRgba(I,F,B)})}for(let O=0;O<24;O++){const I=8+10*O;L.push({css:g.channels.toCss(I,I,I),rgba:g.channels.toRgba(I,I,I)})}return L})());let E=u.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(L){super(),this._optionsService=L,this._contrastCache=new f.ColorContrastCache,this._halfContrastCache=new f.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:b,background:_,cursor:S,cursorAccent:v,selectionForeground:void 0,selectionBackgroundTransparent:k,selectionBackgroundOpaque:g.color.blend(_,k),selectionInactiveBackgroundTransparent:k,selectionInactiveBackgroundOpaque:g.color.blend(_,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(L={}){const A=this._colors;if(A.foreground=N(L.foreground,b),A.background=N(L.background,_),A.cursor=N(L.cursor,S),A.cursorAccent=N(L.cursorAccent,v),A.selectionBackgroundTransparent=N(L.selectionBackground,k),A.selectionBackgroundOpaque=g.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=N(L.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=g.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=L.selectionForeground?N(L.selectionForeground,g.NULL_COLOR):void 0,A.selectionForeground===g.NULL_COLOR&&(A.selectionForeground=void 0),g.color.isOpaque(A.selectionBackgroundTransparent)&&(A.selectionBackgroundTransparent=g.color.opacity(A.selectionBackgroundTransparent,.3)),g.color.isOpaque(A.selectionInactiveBackgroundTransparent)&&(A.selectionInactiveBackgroundTransparent=g.color.opacity(A.selectionInactiveBackgroundTransparent,.3)),A.ansi=u.DEFAULT_ANSI_COLORS.slice(),A.ansi[0]=N(L.black,u.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=N(L.red,u.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=N(L.green,u.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=N(L.yellow,u.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=N(L.blue,u.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=N(L.magenta,u.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=N(L.cyan,u.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=N(L.white,u.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=N(L.brightBlack,u.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=N(L.brightRed,u.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=N(L.brightGreen,u.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=N(L.brightYellow,u.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=N(L.brightBlue,u.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=N(L.brightMagenta,u.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=N(L.brightCyan,u.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=N(L.brightWhite,u.DEFAULT_ANSI_COLORS[15]),L.extendedAnsi){const O=Math.min(A.ansi.length-16,L.extendedAnsi.length);for(let I=0;I<O;I++)A.ansi[I+16]=N(L.extendedAnsi[I],u.DEFAULT_ANSI_COLORS[I+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(L){this._restoreColor(L),this._onChangeColors.fire(this.colors)}_restoreColor(L){if(L!==void 0)switch(L){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[L]=this._restoreColors.ansi[L]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}modifyColors(L){L(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function N(L,A){if(L!==void 0)try{return g.css.toColor(L)}catch{}return A}u.ThemeService=E=h([m(0,C.IOptionsService)],E)},6349:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CircularList=void 0;const h=d(8460),m=d(844);class f extends m.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(x){if(this._maxLength===x)return;const w=new Array(x);for(let C=0;C<Math.min(x,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,w,...C){if(w){for(let b=x;b<this._length-w;b++)this._array[this._getCyclicIndex(b)]=this._array[this._getCyclicIndex(b+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let b=this._length-1;b>=x;b--)this._array[this._getCyclicIndex(b+C.length)]=this._array[this._getCyclicIndex(b)];for(let b=0;b<C.length;b++)this._array[this._getCyclicIndex(x+b)]=C[b];if(C.length&&this.onInsertEmitter.fire({index:x,amount:C.length}),this._length+C.length>this._maxLength){const b=this._length+C.length-this._maxLength;this._startIndex+=b,this._length=this._maxLength,this.onTrimEmitter.fire(b)}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 _=w-1;_>=0;_--)this.set(x+_+C,this.get(x+_));const b=x+w+C-this._length;if(b>0)for(this._length+=b;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let b=0;b<w;b++)this.set(x+b+C,this.get(x+b))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}u.CircularList=f},1439:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.clone=void 0,u.clone=function d(h,m=5){if(typeof h!="object")return h;const f=Array.isArray(h)?[]:{};for(const g in h)f[g]=m<=1?h[g]:h[g]&&d(h[g],m-1);return f}},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,m=0,f=0;var g,x,w,C,b;function _(v){const k=v.toString(16);return k.length<2?"0"+k:k}function S(v,k){return v<k?(k+.05)/(v+.05):(v+.05)/(k+.05)}u.NULL_COLOR={css:"#00000000",rgba:0},(function(v){v.toCss=function(k,E,N,L){return L!==void 0?`#${_(k)}${_(E)}${_(N)}${_(L)}`:`#${_(k)}${_(E)}${_(N)}`},v.toRgba=function(k,E,N,L=255){return(k<<24|E<<16|N<<8|L)>>>0},v.toColor=function(k,E,N,L){return{css:v.toCss(k,E,N,L),rgba:v.toRgba(k,E,N,L)}}})(g||(u.channels=g={})),(function(v){function k(E,N){return f=Math.round(255*N),[d,h,m]=b.toChannels(E.rgba),{css:g.toCss(d,h,m,f),rgba:g.toRgba(d,h,m,f)}}v.blend=function(E,N){if(f=(255&N.rgba)/255,f===1)return{css:N.css,rgba:N.rgba};const L=N.rgba>>24&255,A=N.rgba>>16&255,O=N.rgba>>8&255,I=E.rgba>>24&255,F=E.rgba>>16&255,B=E.rgba>>8&255;return d=I+Math.round((L-I)*f),h=F+Math.round((A-F)*f),m=B+Math.round((O-B)*f),{css:g.toCss(d,h,m),rgba:g.toRgba(d,h,m)}},v.isOpaque=function(E){return(255&E.rgba)==255},v.ensureContrastRatio=function(E,N,L){const A=b.ensureContrastRatio(E.rgba,N.rgba,L);if(A)return g.toColor(A>>24&255,A>>16&255,A>>8&255)},v.opaque=function(E){const N=(255|E.rgba)>>>0;return[d,h,m]=b.toChannels(N),{css:g.toCss(d,h,m),rgba:N}},v.opacity=k,v.multiplyOpacity=function(E,N){return f=255&E.rgba,k(E,f*N/255)},v.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(x||(u.color=x={})),(function(v){let k,E;try{const N=document.createElement("canvas");N.width=1,N.height=1;const L=N.getContext("2d",{willReadFrequently:!0});L&&(k=L,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}catch{}v.toColor=function(N){if(N.match(/#[\da-f]{3,8}/i))switch(N.length){case 4:return d=parseInt(N.slice(1,2).repeat(2),16),h=parseInt(N.slice(2,3).repeat(2),16),m=parseInt(N.slice(3,4).repeat(2),16),g.toColor(d,h,m);case 5:return d=parseInt(N.slice(1,2).repeat(2),16),h=parseInt(N.slice(2,3).repeat(2),16),m=parseInt(N.slice(3,4).repeat(2),16),f=parseInt(N.slice(4,5).repeat(2),16),g.toColor(d,h,m,f);case 7:return{css:N,rgba:(parseInt(N.slice(1),16)<<8|255)>>>0};case 9:return{css:N,rgba:parseInt(N.slice(1),16)>>>0}}const L=N.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(L)return d=parseInt(L[1]),h=parseInt(L[2]),m=parseInt(L[3]),f=Math.round(255*(L[5]===void 0?1:parseFloat(L[5]))),g.toColor(d,h,m,f);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=N,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,h,m,f]=k.getImageData(0,0,1,1).data,f!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:g.toRgba(d,h,m,f),css:N}}})(w||(u.css=w={})),(function(v){function k(E,N,L){const A=E/255,O=N/255,I=L/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*(I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4))}v.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},v.relativeLuminance2=k})(C||(u.rgb=C={})),(function(v){function k(N,L,A){const O=N>>24&255,I=N>>16&255,F=N>>8&255;let B=L>>24&255,z=L>>16&255,Y=L>>8&255,q=S(C.relativeLuminance2(B,z,Y),C.relativeLuminance2(O,I,F));for(;q<A&&(B>0||z>0||Y>0);)B-=Math.max(0,Math.ceil(.1*B)),z-=Math.max(0,Math.ceil(.1*z)),Y-=Math.max(0,Math.ceil(.1*Y)),q=S(C.relativeLuminance2(B,z,Y),C.relativeLuminance2(O,I,F));return(B<<24|z<<16|Y<<8|255)>>>0}function E(N,L,A){const O=N>>24&255,I=N>>16&255,F=N>>8&255;let B=L>>24&255,z=L>>16&255,Y=L>>8&255,q=S(C.relativeLuminance2(B,z,Y),C.relativeLuminance2(O,I,F));for(;q<A&&(B<255||z<255||Y<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),z=Math.min(255,z+Math.ceil(.1*(255-z))),Y=Math.min(255,Y+Math.ceil(.1*(255-Y))),q=S(C.relativeLuminance2(B,z,Y),C.relativeLuminance2(O,I,F));return(B<<24|z<<16|Y<<8|255)>>>0}v.blend=function(N,L){if(f=(255&L)/255,f===1)return L;const A=L>>24&255,O=L>>16&255,I=L>>8&255,F=N>>24&255,B=N>>16&255,z=N>>8&255;return d=F+Math.round((A-F)*f),h=B+Math.round((O-B)*f),m=z+Math.round((I-z)*f),g.toRgba(d,h,m)},v.ensureContrastRatio=function(N,L,A){const O=C.relativeLuminance(N>>8),I=C.relativeLuminance(L>>8);if(S(O,I)<A){if(I<O){const z=k(N,L,A),Y=S(O,C.relativeLuminance(z>>8));if(Y<A){const q=E(N,L,A);return Y>S(O,C.relativeLuminance(q>>8))?z:q}return z}const F=E(N,L,A),B=S(O,C.relativeLuminance(F>>8));if(B<A){const z=k(N,L,A);return B>S(O,C.relativeLuminance(z>>8))?F:z}return F}},v.reduceLuminance=k,v.increaseLuminance=E,v.toChannels=function(N){return[N>>24&255,N>>16&255,N>>8&255,255&N]}})(b||(u.rgba=b={})),u.toPaddedHex=_,u.contrastRatio=S},8969:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreTerminal=void 0;const h=d(844),m=d(2585),f=d(4348),g=d(7866),x=d(744),w=d(7302),C=d(6975),b=d(8460),_=d(1753),S=d(1480),v=d(7994),k=d(9282),E=d(5435),N=d(5981),L=d(2660);let A=!1;class O extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new b.EventEmitter),this._onScroll.event((F=>{var B;(B=this._onScrollApi)==null||B.fire(F.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(F){for(const B in F)this.optionsService.options[B]=F[B]}constructor(F){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new b.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new b.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new b.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new b.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new b.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new b.EventEmitter),this._instantiationService=new f.InstantiationService,this.optionsService=this.register(new w.OptionsService(F)),this._instantiationService.setService(m.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(m.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(m.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(m.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(_.CoreMouseService)),this._instantiationService.setService(m.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(S.UnicodeService)),this._instantiationService.setService(m.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(v.CharsetService),this._instantiationService.setService(m.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(L.OscLinkService),this._instantiationService.setService(m.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new E.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,b.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,b.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,b.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,b.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((B=>{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((B=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new N.WriteBuffer(((B,z)=>this._inputHandler.parse(B,z)))),this.register((0,b.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(F,B){this._writeBuffer.write(F,B)}writeSync(F,B){this._logService.logLevel<=m.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(F,B)}input(F,B=!0){this.coreService.triggerDataEvent(F,B)}resize(F,B){isNaN(F)||isNaN(B)||(F=Math.max(F,x.MINIMUM_COLS),B=Math.max(B,x.MINIMUM_ROWS),this._bufferService.resize(F,B))}scroll(F,B=!1){this._bufferService.scroll(F,B)}scrollLines(F,B,z){this._bufferService.scrollLines(F,B,z)}scrollPages(F){this.scrollLines(F*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(F){const B=F-this._bufferService.buffer.ydisp;B!==0&&this.scrollLines(B)}registerEscHandler(F,B){return this._inputHandler.registerEscHandler(F,B)}registerDcsHandler(F,B){return this._inputHandler.registerDcsHandler(F,B)}registerCsiHandler(F,B){return this._inputHandler.registerCsiHandler(F,B)}registerOscHandler(F,B){return this._inputHandler.registerOscHandler(F,B)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let F=!1;const B=this.optionsService.rawOptions.windowsPty;B&&B.buildNumber!==void 0&&B.buildNumber!==void 0?F=B.backend==="conpty"&&B.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(F=!0),F?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const F=[];F.push(this.onLineFeed(k.updateWindowsModeWrappedState.bind(null,this._bufferService))),F.push(this.registerCsiHandler({final:"H"},(()=>((0,k.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const B of F)B.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 m=[];for(let f=0;f<this._listeners.length;f++)m.push(this._listeners[f]);for(let f=0;f<m.length;f++)m[f].call(void 0,d,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},u.forwardEvent=function(d,h){return d((m=>h.fire(m)))},u.runAndSubscribe=function(d,h){return h(void 0),d((m=>h(m)))}},5435:function(c,u,d){var h=this&&this.__decorate||function(J,H,P,D){var U,$=arguments.length,Q=$<3?H:D===null?D=Object.getOwnPropertyDescriptor(H,P):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Q=Reflect.decorate(J,H,P,D);else for(var K=J.length-1;K>=0;K--)(U=J[K])&&(Q=($<3?U(Q):$>3?U(H,P,Q):U(H,P))||Q);return $>3&&Q&&Object.defineProperty(H,P,Q),Q},m=this&&this.__param||function(J,H){return function(P,D){H(P,D,J)}};Object.defineProperty(u,"__esModule",{value:!0}),u.InputHandler=u.WindowsOptionsReportType=void 0;const f=d(2584),g=d(7116),x=d(2015),w=d(844),C=d(482),b=d(8437),_=d(8460),S=d(643),v=d(511),k=d(3734),E=d(2585),N=d(1480),L=d(6242),A=d(6351),O=d(5941),I={"(":0,")":1,"*":2,"+":3,"-":1,".":2},F=131072;function B(J,H){if(J>24)return H.setWinLines||!1;switch(J){case 1:return!!H.restoreWin;case 2:return!!H.minimizeWin;case 3:return!!H.setWinPosition;case 4:return!!H.setWinSizePixels;case 5:return!!H.raiseWin;case 6:return!!H.lowerWin;case 7:return!!H.refreshWin;case 8:return!!H.setWinSizeChars;case 9:return!!H.maximizeWin;case 10:return!!H.fullscreenWin;case 11:return!!H.getWinState;case 13:return!!H.getWinPosition;case 14:return!!H.getWinSizePixels;case 15:return!!H.getScreenSizePixels;case 16:return!!H.getCellSizePixels;case 18:return!!H.getWinSizeChars;case 19:return!!H.getScreenSizeChars;case 20:return!!H.getIconTitle;case 21:return!!H.getWinTitle;case 22:return!!H.pushTitle;case 23:return!!H.popTitle;case 24:return!!H.setWinLines}return!1}var z;(function(J){J[J.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",J[J.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(z||(u.WindowsOptionsReportType=z={}));let Y=0;class q extends w.Disposable{getAttrData(){return this._curAttrData}constructor(H,P,D,U,$,Q,K,Z,V=new x.EscapeSequenceParser){super(),this._bufferService=H,this._charsetService=P,this._coreService=D,this._logService=U,this._optionsService=$,this._oscLinkService=Q,this._coreMouseService=K,this._unicodeService=Z,this._parser=V,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new v.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=b.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=b.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new _.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new _.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new _.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new _.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new _.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new _.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new _.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new _.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new _.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new _.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new _.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new _.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new _.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new W(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((M=>this._activeBuffer=M.activeBuffer))),this._parser.setCsiHandlerFallback(((M,X)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(M),params:X.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,X,ne)=>{this._logService.debug("Unknown OSC code: ",{identifier:M,action:X,data:ne})})),this._parser.setDcsHandlerFallback(((M,X,ne)=>{X==="HOOK"&&(ne=ne.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(M),action:X,payload:ne})})),this._parser.setPrintHandler(((M,X,ne)=>this.print(M,X,ne))),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(f.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(f.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(f.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(f.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(f.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(f.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(f.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(f.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(f.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new L.OscHandler((M=>(this.setTitle(M),this.setIconName(M),!0)))),this._parser.registerOscHandler(1,new L.OscHandler((M=>this.setIconName(M)))),this._parser.registerOscHandler(2,new L.OscHandler((M=>this.setTitle(M)))),this._parser.registerOscHandler(4,new L.OscHandler((M=>this.setOrReportIndexedColor(M)))),this._parser.registerOscHandler(8,new L.OscHandler((M=>this.setHyperlink(M)))),this._parser.registerOscHandler(10,new L.OscHandler((M=>this.setOrReportFgColor(M)))),this._parser.registerOscHandler(11,new L.OscHandler((M=>this.setOrReportBgColor(M)))),this._parser.registerOscHandler(12,new L.OscHandler((M=>this.setOrReportCursorColor(M)))),this._parser.registerOscHandler(104,new L.OscHandler((M=>this.restoreIndexedColor(M)))),this._parser.registerOscHandler(110,new L.OscHandler((M=>this.restoreFgColor(M)))),this._parser.registerOscHandler(111,new L.OscHandler((M=>this.restoreBgColor(M)))),this._parser.registerOscHandler(112,new L.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,X)=>this.requestStatusString(M,X))))}_preserveStack(H,P,D,U){this._parseStack.paused=!0,this._parseStack.cursorStartX=H,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=D,this._parseStack.position=U}_logSlowResolvingAsync(H){this._logService.logLevel<=E.LogLevelEnum.WARN&&Promise.race([H,new Promise(((P,D)=>setTimeout((()=>D("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(H,P){let D,U=this._activeBuffer.x,$=this._activeBuffer.y,Q=0;const K=this._parseStack.paused;if(K){if(D=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(D),D;U=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,H.length>F&&(Q=this._parseStack.position+F)}if(this._logService.logLevel<=E.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof H=="string"?` "${H}"`:` "${Array.prototype.map.call(H,(M=>String.fromCharCode(M))).join("")}"`),typeof H=="string"?H.split("").map((M=>M.charCodeAt(0))):H),this._parseBuffer.length<H.length&&this._parseBuffer.length<F&&(this._parseBuffer=new Uint32Array(Math.min(H.length,F))),K||this._dirtyRowTracker.clearRange(),H.length>F)for(let M=Q;M<H.length;M+=F){const X=M+F<H.length?M+F:H.length,ne=typeof H=="string"?this._stringDecoder.decode(H.substring(M,X),this._parseBuffer):this._utf8Decoder.decode(H.subarray(M,X),this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,ne))return this._preserveStack(U,$,ne,M),this._logSlowResolvingAsync(D),D}else if(!K){const M=typeof H=="string"?this._stringDecoder.decode(H,this._parseBuffer):this._utf8Decoder.decode(H,this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,M))return this._preserveStack(U,$,M,0),this._logSlowResolvingAsync(D),D}this._activeBuffer.x===U&&this._activeBuffer.y===$||this._onCursorMove.fire();const Z=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),V=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);V<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(V,this._bufferService.rows-1),Math.min(Z,this._bufferService.rows-1))}print(H,P,D){let U,$;const Q=this._charsetService.charset,K=this._optionsService.rawOptions.screenReaderMode,Z=this._bufferService.cols,V=this._coreService.decPrivateModes.wraparound,M=this._coreService.modes.insertMode,X=this._curAttrData;let ne=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&D-P>0&&ne.getWidth(this._activeBuffer.x-1)===2&&ne.setCellFromCodepoint(this._activeBuffer.x-1,0,1,X);let re=this._parser.precedingJoinState;for(let ie=P;ie<D;++ie){if(U=H[ie],U<127&&Q){const Fe=Q[String.fromCharCode(U)];Fe&&(U=Fe.charCodeAt(0))}const ge=this._unicodeService.charProperties(U,re);$=N.UnicodeService.extractWidth(ge);const ke=N.UnicodeService.extractShouldJoin(ge),Oe=ke?N.UnicodeService.extractWidth(re):0;if(re=ge,K&&this._onA11yChar.fire((0,C.stringFromCodePoint)(U)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+$-Oe>Z){if(V){const Fe=ne;let we=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),ne=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Oe>0&&ne instanceof b.BufferLine&&ne.copyCellsFrom(Fe,we,0,Oe,!1);we<Z;)Fe.setCellFromCodepoint(we++,0,1,X)}else if(this._activeBuffer.x=Z-1,$===2)continue}if(ke&&this._activeBuffer.x){const Fe=ne.getWidth(this._activeBuffer.x-1)?1:2;ne.addCodepointToCell(this._activeBuffer.x-Fe,U,$);for(let we=$-Oe;--we>=0;)ne.setCellFromCodepoint(this._activeBuffer.x++,0,0,X)}else if(M&&(ne.insertCells(this._activeBuffer.x,$-Oe,this._activeBuffer.getNullCell(X)),ne.getWidth(Z-1)===2&&ne.setCellFromCodepoint(Z-1,S.NULL_CELL_CODE,S.NULL_CELL_WIDTH,X)),ne.setCellFromCodepoint(this._activeBuffer.x++,U,$,X),$>0)for(;--$;)ne.setCellFromCodepoint(this._activeBuffer.x++,0,0,X)}this._parser.precedingJoinState=re,this._activeBuffer.x<Z&&D-P>0&&ne.getWidth(this._activeBuffer.x)===0&&!ne.hasContent(this._activeBuffer.x)&&ne.setCellFromCodepoint(this._activeBuffer.x,0,1,X),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(H,P){return H.final!=="t"||H.prefix||H.intermediates?this._parser.registerCsiHandler(H,P):this._parser.registerCsiHandler(H,(D=>!B(D.params[0],this._optionsService.rawOptions.windowOptions)||P(D)))}registerDcsHandler(H,P){return this._parser.registerDcsHandler(H,new A.DcsHandler(P))}registerEscHandler(H,P){return this._parser.registerEscHandler(H,P)}registerOscHandler(H,P){return this._parser.registerOscHandler(H,new L.OscHandler(P))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var H;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&H.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const H=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-H),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(H=this._bufferService.cols-1){this._activeBuffer.x=Math.min(H,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(H,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=H,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=H,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(H,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+H,this._activeBuffer.y+P)}cursorUp(H){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,H.params[0]||1)):this._moveCursor(0,-(H.params[0]||1)),!0}cursorDown(H){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,H.params[0]||1)):this._moveCursor(0,H.params[0]||1),!0}cursorForward(H){return this._moveCursor(H.params[0]||1,0),!0}cursorBackward(H){return this._moveCursor(-(H.params[0]||1),0),!0}cursorNextLine(H){return this.cursorDown(H),this._activeBuffer.x=0,!0}cursorPrecedingLine(H){return this.cursorUp(H),this._activeBuffer.x=0,!0}cursorCharAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(H){return this._setCursor(H.length>=2?(H.params[1]||1)-1:0,(H.params[0]||1)-1),!0}charPosAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(H){return this._moveCursor(H.params[0]||1,0),!0}linePosAbsolute(H){return this._setCursor(this._activeBuffer.x,(H.params[0]||1)-1),!0}vPositionRelative(H){return this._moveCursor(0,H.params[0]||1),!0}hVPosition(H){return this.cursorPosition(H),!0}tabClear(H){const P=H.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=H.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=H.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(H){const P=H.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(H,P,D,U=!1,$=!1){const Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);Q.replaceCells(P,D,this._activeBuffer.getNullCell(this._eraseAttrData()),$),U&&(Q.isWrapped=!1)}_resetBufferLine(H,P=!1){const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);D&&(D.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+H),D.isWrapped=!1)}eraseInDisplay(H,P=!1){let D;switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);D<this._bufferService.rows;D++)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(D);break;case 1:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(D+1).isWrapped=!1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(D=this._bufferService.rows,this._dirtyRowTracker.markDirty(D-1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 3:const U=this._activeBuffer.lines.length-this._bufferService.rows;U>0&&(this._activeBuffer.lines.trimStart(U),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-U,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-U,0),this._onScroll.fire(0))}return!0}eraseInLine(H,P=!1){switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(H){this._restrictCursor();let P=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y,U=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-U+1;for(;P--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(D,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(H){this._restrictCursor();let P=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y;let U;for(U=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-U;P--;)this._activeBuffer.lines.splice(D,1),this._activeBuffer.lines.splice(U,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(H){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(H){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(H){let P=H.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(H){let P=H.params[0]||1;for(;P--;)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(b.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(H){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(H.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(H){const P=this._parser.precedingJoinState;if(!P)return!0;const D=H.params[0]||1,U=N.UnicodeService.extractWidth(P),$=this._activeBuffer.x-U,Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString($),K=new Uint32Array(Q.length*D);let Z=0;for(let M=0;M<Q.length;){const X=Q.codePointAt(M)||0;K[Z++]=X,M+=X>65535?2:1}let V=Z;for(let M=1;M<D;++M)K.copyWithin(V,0,Z),V+=Z;return this.print(K,0,V),!0}sendDeviceAttributesPrimary(H){return H.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(f.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(f.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(H){return H.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(f.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(f.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(H.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(f.C0.ESC+"[>83;40003;0c")),!0}_is(H){return(this._optionsService.rawOptions.termName+"").indexOf(H)===0}setMode(H){for(let P=0;P<H.length;P++)switch(H.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(H){for(let P=0;P<H.length;P++)switch(H.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(H){for(let P=0;P<H.length;P++)switch(H.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(H){for(let P=0;P<H.length;P++)switch(H.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),H.params[P]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(H,P){const D=this._coreService.decPrivateModes,{activeProtocol:U,activeEncoding:$}=this._coreMouseService,Q=this._coreService,{buffers:K,cols:Z}=this._bufferService,{active:V,alt:M}=K,X=this._optionsService.rawOptions,ne=ke=>ke?1:2,re=H.params[0];return ie=re,ge=P?re===2?4:re===4?ne(Q.modes.insertMode):re===12?3:re===20?ne(X.convertEol):0:re===1?ne(D.applicationCursorKeys):re===3?X.windowOptions.setWinLines?Z===80?2:Z===132?1:0:0:re===6?ne(D.origin):re===7?ne(D.wraparound):re===8?3:re===9?ne(U==="X10"):re===12?ne(X.cursorBlink):re===25?ne(!Q.isCursorHidden):re===45?ne(D.reverseWraparound):re===66?ne(D.applicationKeypad):re===67?4:re===1e3?ne(U==="VT200"):re===1002?ne(U==="DRAG"):re===1003?ne(U==="ANY"):re===1004?ne(D.sendFocus):re===1005?4:re===1006?ne($==="SGR"):re===1015?4:re===1016?ne($==="SGR_PIXELS"):re===1048?1:re===47||re===1047||re===1049?ne(V===M):re===2004?ne(D.bracketedPasteMode):0,Q.triggerDataEvent(`${f.C0.ESC}[${P?"":"?"}${ie};${ge}$y`),!0;var ie,ge}_updateAttrColor(H,P,D,U,$){return P===2?(H|=50331648,H&=-16777216,H|=k.AttributeData.fromColorRGB([D,U,$])):P===5&&(H&=-50331904,H|=33554432|255&D),H}_extractColor(H,P,D){const U=[0,0,-1,0,0,0];let $=0,Q=0;do{if(U[Q+$]=H.params[P+Q],H.hasSubParams(P+Q)){const K=H.getSubParams(P+Q);let Z=0;do U[1]===5&&($=1),U[Q+Z+1+$]=K[Z];while(++Z<K.length&&Z+Q+1+$<U.length);break}if(U[1]===5&&Q+$>=2||U[1]===2&&Q+$>=5)break;U[1]&&($=1)}while(++Q+P<H.length&&Q+$<U.length);for(let K=2;K<U.length;++K)U[K]===-1&&(U[K]=0);switch(U[0]){case 38:D.fg=this._updateAttrColor(D.fg,U[1],U[3],U[4],U[5]);break;case 48:D.bg=this._updateAttrColor(D.bg,U[1],U[3],U[4],U[5]);break;case 58:D.extended=D.extended.clone(),D.extended.underlineColor=this._updateAttrColor(D.extended.underlineColor,U[1],U[3],U[4],U[5])}return Q}_processUnderline(H,P){P.extended=P.extended.clone(),(!~H||H>5)&&(H=1),P.extended.underlineStyle=H,P.fg|=268435456,H===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(H){H.fg=b.DEFAULT_ATTR_DATA.fg,H.bg=b.DEFAULT_ATTR_DATA.bg,H.extended=H.extended.clone(),H.extended.underlineStyle=0,H.extended.underlineColor&=-67108864,H.updateExtended()}charAttributes(H){if(H.length===1&&H.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=H.length;let D;const U=this._curAttrData;for(let $=0;$<P;$++)D=H.params[$],D>=30&&D<=37?(U.fg&=-50331904,U.fg|=16777216|D-30):D>=40&&D<=47?(U.bg&=-50331904,U.bg|=16777216|D-40):D>=90&&D<=97?(U.fg&=-50331904,U.fg|=16777224|D-90):D>=100&&D<=107?(U.bg&=-50331904,U.bg|=16777224|D-100):D===0?this._processSGR0(U):D===1?U.fg|=134217728:D===3?U.bg|=67108864:D===4?(U.fg|=268435456,this._processUnderline(H.hasSubParams($)?H.getSubParams($)[0]:1,U)):D===5?U.fg|=536870912:D===7?U.fg|=67108864:D===8?U.fg|=1073741824:D===9?U.fg|=2147483648:D===2?U.bg|=134217728:D===21?this._processUnderline(2,U):D===22?(U.fg&=-134217729,U.bg&=-134217729):D===23?U.bg&=-67108865:D===24?(U.fg&=-268435457,this._processUnderline(0,U)):D===25?U.fg&=-536870913:D===27?U.fg&=-67108865:D===28?U.fg&=-1073741825:D===29?U.fg&=2147483647:D===39?(U.fg&=-67108864,U.fg|=16777215&b.DEFAULT_ATTR_DATA.fg):D===49?(U.bg&=-67108864,U.bg|=16777215&b.DEFAULT_ATTR_DATA.bg):D===38||D===48||D===58?$+=this._extractColor(H,$,U):D===53?U.bg|=1073741824:D===55?U.bg&=-1073741825:D===59?(U.extended=U.extended.clone(),U.extended.underlineColor=-1,U.updateExtended()):D===100?(U.fg&=-67108864,U.fg|=16777215&b.DEFAULT_ATTR_DATA.fg,U.bg&=-67108864,U.bg|=16777215&b.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",D);return!0}deviceStatus(H){switch(H.params[0]){case 5:this._coreService.triggerDataEvent(`${f.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${f.C0.ESC}[${P};${D}R`)}return!0}deviceStatusPrivate(H){if(H.params[0]===6){const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${f.C0.ESC}[?${P};${D}R`)}return!0}softReset(H){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=b.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(H){const P=H.params[0]||1;switch(P){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 D=P%2==1;return this._optionsService.options.cursorBlink=D,!0}setScrollRegion(H){const P=H.params[0]||1;let D;return(H.length<2||(D=H.params[1])>this._bufferService.rows||D===0)&&(D=this._bufferService.rows),D>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=D-1,this._setCursor(0,0)),!0}windowOptions(H){if(!B(H.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=H.length>1?H.params[1]:0;switch(H.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(z.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(z.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${f.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(H){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(H){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(H){return this._windowTitle=H,this._onTitleChange.fire(H),!0}setIconName(H){return this._iconName=H,!0}setOrReportIndexedColor(H){const P=[],D=H.split(";");for(;D.length>1;){const U=D.shift(),$=D.shift();if(/^\d+$/.exec(U)){const Q=parseInt(U);if(ee(Q))if($==="?")P.push({type:0,index:Q});else{const K=(0,O.parseColor)($);K&&P.push({type:1,index:Q,color:K})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(H){const P=H.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(H,P){this._getCurrentLinkId()&&this._finishHyperlink();const D=H.split(":");let U;const $=D.findIndex((Q=>Q.startsWith("id=")));return $!==-1&&(U=D[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:U,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(H,P){const D=H.split(";");for(let U=0;U<D.length&&!(P>=this._specialColors.length);++U,++P)if(D[U]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const $=(0,O.parseColor)(D[U]);$&&this._onColor.fire([{type:1,index:this._specialColors[P],color:$}])}return!0}setOrReportFgColor(H){return this._setOrReportSpecialColor(H,0)}setOrReportBgColor(H){return this._setOrReportSpecialColor(H,1)}setOrReportCursorColor(H){return this._setOrReportSpecialColor(H,2)}restoreIndexedColor(H){if(!H)return this._onColor.fire([{type:2}]),!0;const P=[],D=H.split(";");for(let U=0;U<D.length;++U)if(/^\d+$/.exec(D[U])){const $=parseInt(D[U]);ee($)&&P.push({type:2,index:$})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(H){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(H){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(H){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(H){return H.length!==2?(this.selectDefaultCharset(),!0):(H[0]==="/"||this._charsetService.setgCharset(I[H[0]],g.CHARSETS[H[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const H=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,H,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=b.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=b.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(H){return this._charsetService.setgLevel(H),!0}screenAlignmentPattern(){const H=new v.CellData;H.content=4194373,H.fg=this._curAttrData.fg,H.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const D=this._activeBuffer.ybase+this._activeBuffer.y+P,U=this._activeBuffer.lines.get(D);U&&(U.fill(H),U.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(H,P){const D=this._bufferService.buffer,U=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${f.C0.ESC}${$}${f.C0.ESC}\\`),!0))(H==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:H==='"p'?'P1$r61;1"p':H==="r"?`P1$r${D.scrollTop+1};${D.scrollBottom+1}r`:H==="m"?"P1$r0m":H===" q"?`P1$r${{block:2,underline:4,bar:6}[U.cursorStyle]-(U.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(H,P){this._dirtyRowTracker.markRangeDirty(H,P)}}u.InputHandler=q;let W=class{constructor(J){this._bufferService=J,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(J){J<this.start?this.start=J:J>this.end&&(this.end=J)}markRangeDirty(J,H){J>H&&(Y=J,J=H,H=Y),J<this.start&&(this.start=J),H>this.end&&(this.end=H)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function ee(J){return 0<=J&&J<256}W=h([m(0,E.IBufferService)],W)},844:(c,u)=>{function d(h){for(const m of h)m.dispose();h.length=0}Object.defineProperty(u,"__esModule",{value:!0}),u.getDisposeArrayDisposable=u.disposeArray=u.toDisposable=u.MutableDisposable=u.Disposable=void 0,u.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const m=this._disposables.indexOf(h);m!==-1&&this._disposables.splice(m,1)}},u.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){var m;this._isDisposed||h===this._value||((m=this._value)==null||m.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){var h;this._isDisposed=!0,(h=this._value)==null||h.dispose(),this._value=void 0}},u.toDisposable=function(h){return{dispose:h}},u.disposeArray=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(m,f,g){this._data[m]||(this._data[m]={}),this._data[m][f]=g}get(m,f){return this._data[m]?this._data[m][f]:void 0}clear(){this._data={}}}u.TwoKeyMap=d,u.FourKeyMap=class{constructor(){this._data=new d}set(h,m,f,g,x){this._data.get(h,m)||this._data.set(h,m,new d),this._data.get(h,m).set(f,g,x)}get(h,m,f,g){var x;return(x=this._data.get(h,m))==null?void 0:x.get(f,g)}clear(){this._data.clear()}}},6114:(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 m=d.match(/Version\/(\d+)/);return m===null||m.length<2?0:parseInt(m[1])},u.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h),u.isIpad=h==="iPad",u.isIphone=h==="iPhone",u.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),u.isLinux=h.indexOf("Linux")>=0,u.isChromeOS=/\bCrOS\b/.test(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 m=this._getKey(h);if(m===void 0||(d=this._search(m),d===-1)||this._getKey(this._array[d])!==m)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])===m);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,m){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do m(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===h)}values(){return[...this._array].values()}_search(h){let m=0,f=this._array.length-1;for(;f>=m;){let g=m+f>>1;const x=this._getKey(this._array[g]);if(x>h)f=g-1;else{if(!(x<h)){for(;g>0&&this._getKey(this._array[g-1])===h;)g--;return g}m=g+1}}return m}}},7226:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DebouncedIdleTask=u.IdleTaskQueue=u.PriorityTaskQueue=void 0;const h=d(6114);class m{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let w=0,C=0,b=x.timeRemaining(),_=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),_=x.timeRemaining(),1.5*C>_)return b-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(b-w))}ms`),void this._start();b=_}this.clear()}}class f extends m{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}u.PriorityTaskQueue=f,u.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends m{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:f,u.DebouncedIdleTask=class{constructor(){this._queue=new u.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.updateWindowsModeWrappedState=void 0;const h=d(643);u.updateWindowsModeWrappedState=function(m){const f=m.buffer.lines.get(m.buffer.ybase+m.buffer.y-1),g=f==null?void 0:f.get(m.cols-1),x=m.buffer.lines.get(m.buffer.ybase+m.buffer.y);x&&g&&(x.isWrapped=g[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&g[h.CHAR_DATA_CODE_INDEX]!==h.WHITESPACE_CELL_CODE)}},3734:(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(f){return[f>>>16&255,f>>>8&255,255&f]}static fromColorRGB(f){return(255&f[0])<<16|(255&f[1])<<8|255&f[2]}clone(){const f=new d;return f.fg=this.fg,f.bg=this.bg,f.extended=this.extended.clone(),f}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}u.AttributeData=d;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(f){this._ext=f}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(f){this._ext&=-469762049,this._ext|=f<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(f){this._ext&=-67108864,this._ext|=67108863&f}get urlId(){return this._urlId}set urlId(f){this._urlId=f}get underlineVariantOffset(){const f=(3758096384&this._ext)>>29;return f<0?4294967288^f:f}set underlineVariantOffset(f){this._ext&=536870911,this._ext|=f<<29&3758096384}constructor(f=0,g=0){this._ext=0,this._urlId=0,this._ext=f,this._urlId=g}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}u.ExtendedAttrs=h},9092:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Buffer=u.MAX_BUFFER_SIZE=void 0;const h=d(6349),m=d(7226),f=d(3734),g=d(8437),x=d(4634),w=d(511),C=d(643),b=d(4863),_=d(7116);u.MAX_BUFFER_SIZE=4294967295,u.Buffer=class{constructor(S,v,k){this._hasScrollback=S,this._optionsService=v,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=_.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new m.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(S){return S?(this._nullCell.fg=S.fg,this._nullCell.bg=S.bg,this._nullCell.extended=S.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new f.ExtendedAttrs),this._nullCell}getWhitespaceCell(S){return S?(this._whitespaceCell.fg=S.fg,this._whitespaceCell.bg=S.bg,this._whitespaceCell.extended=S.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new f.ExtendedAttrs),this._whitespaceCell}getBlankLine(S,v){return new g.BufferLine(this._bufferService.cols,this.getNullCell(S),v)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const S=this.ybase+this.y-this.ydisp;return S>=0&&S<this._rows}_getCorrectBufferLength(S){if(!this._hasScrollback)return S;const v=S+this._optionsService.rawOptions.scrollback;return v>u.MAX_BUFFER_SIZE?u.MAX_BUFFER_SIZE:v}fillViewportRows(S){if(this.lines.length===0){S===void 0&&(S=g.DEFAULT_ATTR_DATA);let v=this._rows;for(;v--;)this.lines.push(this.getBlankLine(S))}}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(S,v){const k=this.getNullCell(g.DEFAULT_ATTR_DATA);let E=0;const N=this._getCorrectBufferLength(v);if(N>this.lines.maxLength&&(this.lines.maxLength=N),this.lines.length>0){if(this._cols<S)for(let A=0;A<this.lines.length;A++)E+=+this.lines.get(A).resize(S,k);let L=0;if(this._rows<v)for(let A=this._rows;A<v;A++)this.lines.length<v+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(S,k)):this.ybase>0&&this.lines.length<=this.ybase+this.y+L+1?(this.ybase--,L++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(S,k)));else for(let A=this._rows;A>v;A--)this.lines.length>v+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(N<this.lines.maxLength){const A=this.lines.length-N;A>0&&(this.lines.trimStart(A),this.ybase=Math.max(this.ybase-A,0),this.ydisp=Math.max(this.ydisp-A,0),this.savedY=Math.max(this.savedY-A,0)),this.lines.maxLength=N}this.x=Math.min(this.x,S-1),this.y=Math.min(this.y,v-1),L&&(this.y+=L),this.savedX=Math.min(this.savedX,S-1),this.scrollTop=0}if(this.scrollBottom=v-1,this._isReflowEnabled&&(this._reflow(S,v),this._cols>S))for(let L=0;L<this.lines.length;L++)E+=+this.lines.get(L).resize(S,k);this._cols=S,this._rows=v,this._memoryCleanupQueue.clear(),E>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let S=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,S=!1);let v=0;for(;this._memoryCleanupPosition<this.lines.length;)if(v+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),v>100)return!0;return S}get _isReflowEnabled(){const S=this._optionsService.rawOptions.windowsPty;return S&&S.buildNumber?this._hasScrollback&&S.backend==="conpty"&&S.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(S,v){this._cols!==S&&(S>this._cols?this._reflowLarger(S,v):this._reflowSmaller(S,v))}_reflowLarger(S,v){const k=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,S,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(k.length>0){const E=(0,x.reflowLargerCreateNewLayout)(this.lines,k);(0,x.reflowLargerApplyNewLayout)(this.lines,E.layout),this._reflowLargerAdjustViewport(S,v,E.countRemoved)}}_reflowLargerAdjustViewport(S,v,k){const E=this.getNullCell(g.DEFAULT_ATTR_DATA);let N=k;for(;N-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<v&&this.lines.push(new g.BufferLine(S,E))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-k,0)}_reflowSmaller(S,v){const k=this.getNullCell(g.DEFAULT_ATTR_DATA),E=[];let N=0;for(let L=this.lines.length-1;L>=0;L--){let A=this.lines.get(L);if(!A||!A.isWrapped&&A.getTrimmedLength()<=S)continue;const O=[A];for(;A.isWrapped&&L>0;)A=this.lines.get(--L),O.unshift(A);const I=this.ybase+this.y;if(I>=L&&I<L+O.length)continue;const F=O[O.length-1].getTrimmedLength(),B=(0,x.reflowSmallerGetNewLineLengths)(O,this._cols,S),z=B.length-O.length;let Y;Y=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+z):Math.max(0,this.lines.length-this.lines.maxLength+z);const q=[];for(let D=0;D<z;D++){const U=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);q.push(U)}q.length>0&&(E.push({start:L+O.length+N,newLines:q}),N+=q.length),O.push(...q);let W=B.length-1,ee=B[W];ee===0&&(W--,ee=B[W]);let J=O.length-z-1,H=F;for(;J>=0;){const D=Math.min(H,ee);if(O[W]===void 0)break;if(O[W].copyCellsFrom(O[J],H-D,ee-D,D,!0),ee-=D,ee===0&&(W--,ee=B[W]),H-=D,H===0){J--;const U=Math.max(J,0);H=(0,x.getWrappedLineTrimmedLength)(O,U,this._cols)}}for(let D=0;D<O.length;D++)B[D]<S&&O[D].setCell(B[D],k);let P=z-Y;for(;P-- >0;)this.ybase===0?this.y<v-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+N)-v&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+z,this.ybase+v-1)}if(E.length>0){const L=[],A=[];for(let W=0;W<this.lines.length;W++)A.push(this.lines.get(W));const O=this.lines.length;let I=O-1,F=0,B=E[F];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+N);let z=0;for(let W=Math.min(this.lines.maxLength-1,O+N-1);W>=0;W--)if(B&&B.start>I+z){for(let ee=B.newLines.length-1;ee>=0;ee--)this.lines.set(W--,B.newLines[ee]);W++,L.push({index:I+1,amount:B.newLines.length}),z+=B.newLines.length,B=E[++F]}else this.lines.set(W,A[I--]);let Y=0;for(let W=L.length-1;W>=0;W--)L[W].index+=Y,this.lines.onInsertEmitter.fire(L[W]),Y+=L[W].amount;const q=Math.max(0,O+N-this.lines.maxLength);q>0&&this.lines.onTrimEmitter.fire(q)}}translateBufferLineToString(S,v,k=0,E){const N=this.lines.get(S);return N?N.translateToString(v,k,E):""}getWrappedRangeForLine(S){let v=S,k=S;for(;v>0&&this.lines.get(v).isWrapped;)v--;for(;k+1<this.lines.length&&this.lines.get(k+1).isWrapped;)k++;return{first:v,last:k}}setupTabStops(S){for(S!=null?this.tabs[S]||(S=this.prevStop(S)):(this.tabs={},S=0);S<this._cols;S+=this._optionsService.rawOptions.tabStopWidth)this.tabs[S]=!0}prevStop(S){for(S==null&&(S=this.x);!this.tabs[--S]&&S>0;);return S>=this._cols?this._cols-1:S<0?0:S}nextStop(S){for(S==null&&(S=this.x);!this.tabs[++S]&&S<this._cols;);return S>=this._cols?this._cols-1:S<0?0:S}clearMarkers(S){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].line===S&&(this.markers[v].dispose(),this.markers.splice(v--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let S=0;S<this.markers.length;S++)this.markers[S].dispose(),this.markers.splice(S--,1);this._isClearing=!1}addMarker(S){const v=new b.Marker(S);return this.markers.push(v),v.register(this.lines.onTrim((k=>{v.line-=k,v.line<0&&v.dispose()}))),v.register(this.lines.onInsert((k=>{v.line>=k.index&&(v.line+=k.amount)}))),v.register(this.lines.onDelete((k=>{v.line>=k.index&&v.line<k.index+k.amount&&v.dispose(),v.line>k.index&&(v.line-=k.amount)}))),v.register(v.onDispose((()=>this._removeMarker(v)))),v}_removeMarker(S){this._isClearing||this.markers.splice(this.markers.indexOf(S),1)}}},8437:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLine=u.DEFAULT_ATTR_DATA=void 0;const h=d(3734),m=d(511),f=d(643),g=d(482);u.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let x=0;class w{constructor(b,_,S=!1){this.isWrapped=S,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*b);const v=_||m.CellData.fromCharData([0,f.NULL_CELL_CHAR,f.NULL_CELL_WIDTH,f.NULL_CELL_CODE]);for(let k=0;k<b;++k)this.setCell(k,v);this.length=b}get(b){const _=this._data[3*b+0],S=2097151&_;return[this._data[3*b+1],2097152&_?this._combined[b]:S?(0,g.stringFromCodePoint)(S):"",_>>22,2097152&_?this._combined[b].charCodeAt(this._combined[b].length-1):S]}set(b,_){this._data[3*b+1]=_[f.CHAR_DATA_ATTR_INDEX],_[f.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[b]=_[1],this._data[3*b+0]=2097152|b|_[f.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*b+0]=_[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[f.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(b){return this._data[3*b+0]>>22}hasWidth(b){return 12582912&this._data[3*b+0]}getFg(b){return this._data[3*b+1]}getBg(b){return this._data[3*b+2]}hasContent(b){return 4194303&this._data[3*b+0]}getCodePoint(b){const _=this._data[3*b+0];return 2097152&_?this._combined[b].charCodeAt(this._combined[b].length-1):2097151&_}isCombined(b){return 2097152&this._data[3*b+0]}getString(b){const _=this._data[3*b+0];return 2097152&_?this._combined[b]:2097151&_?(0,g.stringFromCodePoint)(2097151&_):""}isProtected(b){return 536870912&this._data[3*b+2]}loadCell(b,_){return x=3*b,_.content=this._data[x+0],_.fg=this._data[x+1],_.bg=this._data[x+2],2097152&_.content&&(_.combinedData=this._combined[b]),268435456&_.bg&&(_.extended=this._extendedAttrs[b]),_}setCell(b,_){2097152&_.content&&(this._combined[b]=_.combinedData),268435456&_.bg&&(this._extendedAttrs[b]=_.extended),this._data[3*b+0]=_.content,this._data[3*b+1]=_.fg,this._data[3*b+2]=_.bg}setCellFromCodepoint(b,_,S,v){268435456&v.bg&&(this._extendedAttrs[b]=v.extended),this._data[3*b+0]=_|S<<22,this._data[3*b+1]=v.fg,this._data[3*b+2]=v.bg}addCodepointToCell(b,_,S){let v=this._data[3*b+0];2097152&v?this._combined[b]+=(0,g.stringFromCodePoint)(_):2097151&v?(this._combined[b]=(0,g.stringFromCodePoint)(2097151&v)+(0,g.stringFromCodePoint)(_),v&=-2097152,v|=2097152):v=_|4194304,S&&(v&=-12582913,v|=S<<22),this._data[3*b+0]=v}insertCells(b,_,S){if((b%=this.length)&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,S),_<this.length-b){const v=new m.CellData;for(let k=this.length-b-_-1;k>=0;--k)this.setCell(b+_+k,this.loadCell(b+k,v));for(let k=0;k<_;++k)this.setCell(b+k,S)}else for(let v=b;v<this.length;++v)this.setCell(v,S);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,S)}deleteCells(b,_,S){if(b%=this.length,_<this.length-b){const v=new m.CellData;for(let k=0;k<this.length-b-_;++k)this.setCell(b+k,this.loadCell(b+_+k,v));for(let k=this.length-_;k<this.length;++k)this.setCell(k,S)}else for(let v=b;v<this.length;++v)this.setCell(v,S);b&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,S),this.getWidth(b)!==0||this.hasContent(b)||this.setCellFromCodepoint(b,0,1,S)}replaceCells(b,_,S,v=!1){if(v)for(b&&this.getWidth(b-1)===2&&!this.isProtected(b-1)&&this.setCellFromCodepoint(b-1,0,1,S),_<this.length&&this.getWidth(_-1)===2&&!this.isProtected(_)&&this.setCellFromCodepoint(_,0,1,S);b<_&&b<this.length;)this.isProtected(b)||this.setCell(b,S),b++;else for(b&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,S),_<this.length&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_,0,1,S);b<_&&b<this.length;)this.setCell(b++,S)}resize(b,_){if(b===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const S=3*b;if(b>this.length){if(this._data.buffer.byteLength>=4*S)this._data=new Uint32Array(this._data.buffer,0,S);else{const v=new Uint32Array(S);v.set(this._data),this._data=v}for(let v=this.length;v<b;++v)this.setCell(v,_)}else{this._data=this._data.subarray(0,S);const v=Object.keys(this._combined);for(let E=0;E<v.length;E++){const N=parseInt(v[E],10);N>=b&&delete this._combined[N]}const k=Object.keys(this._extendedAttrs);for(let E=0;E<k.length;E++){const N=parseInt(k[E],10);N>=b&&delete this._extendedAttrs[N]}}return this.length=b,4*S*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const b=new Uint32Array(this._data.length);return b.set(this._data),this._data=b,1}return 0}fill(b,_=!1){if(_)for(let S=0;S<this.length;++S)this.isProtected(S)||this.setCell(S,b);else{this._combined={},this._extendedAttrs={};for(let S=0;S<this.length;++S)this.setCell(S,b)}}copyFrom(b){this.length!==b.length?this._data=new Uint32Array(b._data):this._data.set(b._data),this.length=b.length,this._combined={};for(const _ in b._combined)this._combined[_]=b._combined[_];this._extendedAttrs={};for(const _ in b._extendedAttrs)this._extendedAttrs[_]=b._extendedAttrs[_];this.isWrapped=b.isWrapped}clone(){const b=new w(0);b._data=new Uint32Array(this._data),b.length=this.length;for(const _ in this._combined)b._combined[_]=this._combined[_];for(const _ in this._extendedAttrs)b._extendedAttrs[_]=this._extendedAttrs[_];return b.isWrapped=this.isWrapped,b}getTrimmedLength(){for(let b=this.length-1;b>=0;--b)if(4194303&this._data[3*b+0])return b+(this._data[3*b+0]>>22);return 0}getNoBgTrimmedLength(){for(let b=this.length-1;b>=0;--b)if(4194303&this._data[3*b+0]||50331648&this._data[3*b+2])return b+(this._data[3*b+0]>>22);return 0}copyCellsFrom(b,_,S,v,k){const E=b._data;if(k)for(let L=v-1;L>=0;L--){for(let A=0;A<3;A++)this._data[3*(S+L)+A]=E[3*(_+L)+A];268435456&E[3*(_+L)+2]&&(this._extendedAttrs[S+L]=b._extendedAttrs[_+L])}else for(let L=0;L<v;L++){for(let A=0;A<3;A++)this._data[3*(S+L)+A]=E[3*(_+L)+A];268435456&E[3*(_+L)+2]&&(this._extendedAttrs[S+L]=b._extendedAttrs[_+L])}const N=Object.keys(b._combined);for(let L=0;L<N.length;L++){const A=parseInt(N[L],10);A>=_&&(this._combined[A-_+S]=b._combined[A])}}translateToString(b,_,S,v){_=_??0,S=S??this.length,b&&(S=Math.min(S,this.getTrimmedLength())),v&&(v.length=0);let k="";for(;_<S;){const E=this._data[3*_+0],N=2097151&E,L=2097152&E?this._combined[_]:N?(0,g.stringFromCodePoint)(N):f.WHITESPACE_CELL_CHAR;if(k+=L,v)for(let A=0;A<L.length;++A)v.push(_);_+=E>>22||1}return v&&v.push(_),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,m,f){if(m===h.length-1)return h[m].getTrimmedLength();const g=!h[m].hasContent(f-1)&&h[m].getWidth(f-1)===1,x=h[m+1].getWidth(0)===2;return g&&x?f-1:f}Object.defineProperty(u,"__esModule",{value:!0}),u.getWrappedLineTrimmedLength=u.reflowSmallerGetNewLineLengths=u.reflowLargerApplyNewLayout=u.reflowLargerCreateNewLayout=u.reflowLargerGetLinesToRemove=void 0,u.reflowLargerGetLinesToRemove=function(h,m,f,g,x){const w=[];for(let C=0;C<h.length-1;C++){let b=C,_=h.get(++b);if(!_.isWrapped)continue;const S=[h.get(C)];for(;b<h.length&&_.isWrapped;)S.push(_),_=h.get(++b);if(g>=C&&g<b){C+=S.length-1;continue}let v=0,k=d(S,v,m),E=1,N=0;for(;E<S.length;){const A=d(S,E,m),O=A-N,I=f-k,F=Math.min(O,I);S[v].copyCellsFrom(S[E],N,k,F,!1),k+=F,k===f&&(v++,k=0),N+=F,N===A&&(E++,N=0),k===0&&v!==0&&S[v-1].getWidth(f-1)===2&&(S[v].copyCellsFrom(S[v-1],f-1,k++,1,!1),S[v-1].setCell(f-1,x))}S[v].replaceCells(k,f,x);let L=0;for(let A=S.length-1;A>0&&(A>v||S[A].getTrimmedLength()===0);A--)L++;L>0&&(w.push(C+S.length-L),w.push(L)),C+=S.length-1}return w},u.reflowLargerCreateNewLayout=function(h,m){const f=[];let g=0,x=m[g],w=0;for(let C=0;C<h.length;C++)if(x===C){const b=m[++g];h.onDeleteEmitter.fire({index:C-w,amount:b}),C+=b-1,w+=b,x=m[++g]}else f.push(C);return{layout:f,countRemoved:w}},u.reflowLargerApplyNewLayout=function(h,m){const f=[];for(let g=0;g<m.length;g++)f.push(h.get(m[g]));for(let g=0;g<f.length;g++)h.set(g,f[g]);h.length=m.length},u.reflowSmallerGetNewLineLengths=function(h,m,f){const g=[],x=h.map(((_,S)=>d(h,S,m))).reduce(((_,S)=>_+S));let w=0,C=0,b=0;for(;b<x;){if(x-b<f){g.push(x-b);break}w+=f;const _=d(h,C,m);w>_&&(w-=_,C++);const S=h[C].getWidth(w-1)===2;S&&w--;const v=S?f-1:f;g.push(v),b+=v}return g},u.getWrappedLineTrimmedLength=d},5295:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferSet=void 0;const h=d(8460),m=d(844),f=d(9092);class g extends m.Disposable{constructor(w,C){super(),this._optionsService=w,this._bufferService=C,this._onBufferActivate=this.register(new h.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new f.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new f.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}u.BufferSet=g},511:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CellData=void 0;const h=d(482),m=d(643),f=d(3734);class g extends f.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new f.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new g;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[m.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[m.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[m.CHAR_DATA_CHAR_INDEX].length===2){const b=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=b&&b<=56319){const _=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=_&&_<=57343?this.content=1024*(b-55296)+_-56320+65536|w[m.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[m.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[m.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[m.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}u.CellData=g},643:(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),m=d(844);class f{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=f._nextId++,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,m.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}u.Marker=f,f._nextId=1},7116:(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,m;Object.defineProperty(u,"__esModule",{value:!0}),u.C1_ESCAPED=u.C1=u.C0=void 0,(function(f){f.NUL="\0",f.SOH="",f.STX="",f.ETX="",f.EOT="",f.ENQ="",f.ACK="",f.BEL="\x07",f.BS="\b",f.HT=" ",f.LF=`
260
+ `,f.VT="\v",f.FF="\f",f.CR="\r",f.SO="",f.SI="",f.DLE="",f.DC1="",f.DC2="",f.DC3="",f.DC4="",f.NAK="",f.SYN="",f.ETB="",f.CAN="",f.EM="",f.SUB="",f.ESC="\x1B",f.FS="",f.GS="",f.RS="",f.US="",f.SP=" ",f.DEL=""})(d||(u.C0=d={})),(function(f){f.PAD="€",f.HOP="",f.BPH="‚",f.NBH="ƒ",f.IND="„",f.NEL="…",f.SSA="†",f.ESA="‡",f.HTS="ˆ",f.HTJ="‰",f.VTS="Š",f.PLD="‹",f.PLU="Œ",f.RI="",f.SS2="Ž",f.SS3="",f.DCS="",f.PU1="‘",f.PU2="’",f.STS="“",f.CCH="”",f.MW="•",f.SPA="–",f.EPA="—",f.SOS="˜",f.SGCI="™",f.SCI="š",f.CSI="›",f.ST="œ",f.OSC="",f.PM="ž",f.APC="Ÿ"})(h||(u.C1=h={})),(function(f){f.ST=`${d.ESC}\\`})(m||(u.C1_ESCAPED=m={}))},7399:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.evaluateKeyboardEvent=void 0;const h=d(2584),m={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};u.evaluateKeyboardEvent=function(f,g,x,w){const C={type:0,cancel:!1,key:void 0},b=(f.shiftKey?1:0)|(f.altKey?2:0)|(f.ctrlKey?4:0)|(f.metaKey?8:0);switch(f.keyCode){case 0:f.key==="UIKeyInputUpArrow"?C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A":f.key==="UIKeyInputLeftArrow"?C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D":f.key==="UIKeyInputRightArrow"?C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C":f.key==="UIKeyInputDownArrow"&&(C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:C.key=f.ctrlKey?"\b":h.C0.DEL,f.altKey&&(C.key=h.C0.ESC+C.key);break;case 9:if(f.shiftKey){C.key=h.C0.ESC+"[Z";break}C.key=h.C0.HT,C.cancel=!0;break;case 13:C.key=f.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,C.cancel=!0;break;case 27:C.key=h.C0.ESC,f.altKey&&(C.key=h.C0.ESC+h.C0.ESC),C.cancel=!0;break;case 37:if(f.metaKey)break;b?(C.key=h.C0.ESC+"[1;"+(b+1)+"D",C.key===h.C0.ESC+"[1;3D"&&(C.key=h.C0.ESC+(x?"b":"[1;5D"))):C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(f.metaKey)break;b?(C.key=h.C0.ESC+"[1;"+(b+1)+"C",C.key===h.C0.ESC+"[1;3C"&&(C.key=h.C0.ESC+(x?"f":"[1;5C"))):C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(f.metaKey)break;b?(C.key=h.C0.ESC+"[1;"+(b+1)+"A",x||C.key!==h.C0.ESC+"[1;3A"||(C.key=h.C0.ESC+"[1;5A")):C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(f.metaKey)break;b?(C.key=h.C0.ESC+"[1;"+(b+1)+"B",x||C.key!==h.C0.ESC+"[1;3B"||(C.key=h.C0.ESC+"[1;5B")):C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:f.shiftKey||f.ctrlKey||(C.key=h.C0.ESC+"[2~");break;case 46:C.key=b?h.C0.ESC+"[3;"+(b+1)+"~":h.C0.ESC+"[3~";break;case 36:C.key=b?h.C0.ESC+"[1;"+(b+1)+"H":g?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:C.key=b?h.C0.ESC+"[1;"+(b+1)+"F":g?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:f.shiftKey?C.type=2:f.ctrlKey?C.key=h.C0.ESC+"[5;"+(b+1)+"~":C.key=h.C0.ESC+"[5~";break;case 34:f.shiftKey?C.type=3:f.ctrlKey?C.key=h.C0.ESC+"[6;"+(b+1)+"~":C.key=h.C0.ESC+"[6~";break;case 112:C.key=b?h.C0.ESC+"[1;"+(b+1)+"P":h.C0.ESC+"OP";break;case 113:C.key=b?h.C0.ESC+"[1;"+(b+1)+"Q":h.C0.ESC+"OQ";break;case 114:C.key=b?h.C0.ESC+"[1;"+(b+1)+"R":h.C0.ESC+"OR";break;case 115:C.key=b?h.C0.ESC+"[1;"+(b+1)+"S":h.C0.ESC+"OS";break;case 116:C.key=b?h.C0.ESC+"[15;"+(b+1)+"~":h.C0.ESC+"[15~";break;case 117:C.key=b?h.C0.ESC+"[17;"+(b+1)+"~":h.C0.ESC+"[17~";break;case 118:C.key=b?h.C0.ESC+"[18;"+(b+1)+"~":h.C0.ESC+"[18~";break;case 119:C.key=b?h.C0.ESC+"[19;"+(b+1)+"~":h.C0.ESC+"[19~";break;case 120:C.key=b?h.C0.ESC+"[20;"+(b+1)+"~":h.C0.ESC+"[20~";break;case 121:C.key=b?h.C0.ESC+"[21;"+(b+1)+"~":h.C0.ESC+"[21~";break;case 122:C.key=b?h.C0.ESC+"[23;"+(b+1)+"~":h.C0.ESC+"[23~";break;case 123:C.key=b?h.C0.ESC+"[24;"+(b+1)+"~":h.C0.ESC+"[24~";break;default:if(!f.ctrlKey||f.shiftKey||f.altKey||f.metaKey)if(x&&!w||!f.altKey||f.metaKey)!x||f.altKey||f.ctrlKey||f.shiftKey||!f.metaKey?f.key&&!f.ctrlKey&&!f.altKey&&!f.metaKey&&f.keyCode>=48&&f.key.length===1?C.key=f.key:f.key&&f.ctrlKey&&(f.key==="_"&&(C.key=h.C0.US),f.key==="@"&&(C.key=h.C0.NUL)):f.keyCode===65&&(C.type=1);else{const _=m[f.keyCode],S=_==null?void 0:_[f.shiftKey?1:0];if(S)C.key=h.C0.ESC+S;else if(f.keyCode>=65&&f.keyCode<=90){const v=f.ctrlKey?f.keyCode-64:f.keyCode+32;let k=String.fromCharCode(v);f.shiftKey&&(k=k.toUpperCase()),C.key=h.C0.ESC+k}else if(f.keyCode===32)C.key=h.C0.ESC+(f.ctrlKey?h.C0.NUL:" ");else if(f.key==="Dead"&&f.code.startsWith("Key")){let v=f.code.slice(3,4);f.shiftKey||(v=v.toLowerCase()),C.key=h.C0.ESC+v,C.cancel=!0}}else f.keyCode>=65&&f.keyCode<=90?C.key=String.fromCharCode(f.keyCode-64):f.keyCode===32?C.key=h.C0.NUL:f.keyCode>=51&&f.keyCode<=55?C.key=String.fromCharCode(f.keyCode-51+27):f.keyCode===56?C.key=h.C0.DEL:f.keyCode===219?C.key=h.C0.ESC:f.keyCode===220?C.key=h.C0.FS:f.keyCode===221&&(C.key=h.C0.GS)}return C}},482:(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,m=d.length){let f="";for(let g=h;g<m;++g){let x=d[g];x>65535?(x-=65536,f+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):f+=String.fromCharCode(x)}return f},u.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,h){const m=d.length;if(!m)return 0;let f=0,g=0;if(this._interim){const x=d.charCodeAt(g++);56320<=x&&x<=57343?h[f++]=1024*(this._interim-55296)+x-56320+65536:(h[f++]=this._interim,h[f++]=x),this._interim=0}for(let x=g;x<m;++x){const w=d.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=m)return this._interim=w,f;const C=d.charCodeAt(x);56320<=C&&C<=57343?h[f++]=1024*(w-55296)+C-56320+65536:(h[f++]=w,h[f++]=C)}else w!==65279&&(h[f++]=w)}return f}},u.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,h){const m=d.length;if(!m)return 0;let f,g,x,w,C=0,b=0,_=0;if(this.interim[0]){let k=!1,E=this.interim[0];E&=(224&E)==192?31:(240&E)==224?15:7;let N,L=0;for(;(N=63&this.interim[++L])&&L<4;)E<<=6,E|=N;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=A-L;for(;_<O;){if(_>=m)return 0;if(N=d[_++],(192&N)!=128){_--,k=!0;break}this.interim[L++]=N,E<<=6,E|=63&N}k||(A===2?E<128?_--:h[C++]=E:A===3?E<2048||E>=55296&&E<=57343||E===65279||(h[C++]=E):E<65536||E>1114111||(h[C++]=E)),this.interim.fill(0)}const S=m-4;let v=_;for(;v<m;){for(;!(!(v<S)||128&(f=d[v])||128&(g=d[v+1])||128&(x=d[v+2])||128&(w=d[v+3]));)h[C++]=f,h[C++]=g,h[C++]=x,h[C++]=w,v+=4;if(f=d[v++],f<128)h[C++]=f;else if((224&f)==192){if(v>=m)return this.interim[0]=f,C;if(g=d[v++],(192&g)!=128){v--;continue}if(b=(31&f)<<6|63&g,b<128){v--;continue}h[C++]=b}else if((240&f)==224){if(v>=m)return this.interim[0]=f,C;if(g=d[v++],(192&g)!=128){v--;continue}if(v>=m)return this.interim[0]=f,this.interim[1]=g,C;if(x=d[v++],(192&x)!=128){v--;continue}if(b=(15&f)<<12|(63&g)<<6|63&x,b<2048||b>=55296&&b<=57343||b===65279)continue;h[C++]=b}else if((248&f)==240){if(v>=m)return this.interim[0]=f,C;if(g=d[v++],(192&g)!=128){v--;continue}if(v>=m)return this.interim[0]=f,this.interim[1]=g,C;if(x=d[v++],(192&x)!=128){v--;continue}if(v>=m)return this.interim[0]=f,this.interim[1]=g,this.interim[2]=x,C;if(w=d[v++],(192&w)!=128){v--;continue}if(b=(7&f)<<18|(63&g)<<12|(63&x)<<6|63&w,b<65536||b>1114111)continue;h[C++]=b}}return C}}},225:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeV6=void 0;const h=d(1480),m=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],f=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let g;u.UnicodeV6=class{constructor(){if(this.version="6",!g){g=new Uint8Array(65536),g.fill(1),g[0]=0,g.fill(0,1,32),g.fill(0,127,160),g.fill(2,4352,4448),g[9001]=2,g[9002]=2,g.fill(2,11904,42192),g[12351]=1,g.fill(2,44032,55204),g.fill(2,63744,64256),g.fill(2,65040,65050),g.fill(2,65072,65136),g.fill(2,65280,65377),g.fill(2,65504,65511);for(let x=0;x<m.length;++x)g.fill(0,m[x][0],m[x][1]+1)}}wcwidth(x){return x<32?0:x<127?1:x<65536?g[x]:(function(w,C){let b,_=0,S=C.length-1;if(w<C[0][0]||w>C[S][1])return!1;for(;S>=_;)if(b=_+S>>1,w>C[b][1])_=b+1;else{if(!(w<C[b][0]))return!0;S=b-1}return!1})(x,f)?0:x>=131072&&x<=196605||x>=196608&&x<=262141?2:1}charProperties(x,w){let C=this.wcwidth(x),b=C===0&&w!==0;if(b){const _=h.UnicodeService.extractWidth(w);_===0?b=!1:_>C&&(C=_)}return h.UnicodeService.createPropertyValue(0,C,b)}}},5981:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WriteBuffer=void 0;const h=d(8460),m=d(844);class f extends m.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const b=this._callbacks.shift();b&&b()}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 b=this._writeBuffer[this._bufferOffset],_=this._action(b,w);if(_){const v=k=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,k))):this._innerWrite(C,k);return void _.catch((k=>(queueMicrotask((()=>{throw k})),Promise.resolve(!1)))).then(v)}const S=this._callbacks[this._bufferOffset];if(S&&S(),this._bufferOffset++,this._pendingData-=b.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}u.WriteBuffer=f},5941:(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 m(f,g){const x=f.toString(16),w=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}u.parseColor=function(f){if(!f)return;let g=f.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const x=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 b=parseInt(g.slice(x*C,x*C+x),16);w[C]=x===1?b<<4:x===2?b:x===3?b>>4:b>>8}return w}},u.toRgbString=function(f,g=16){const[x,w,C]=f;return`rgb:${m(x,g)}/${m(w,g)}/${m(C,g)}`}},5770:(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),m=d(8742),f=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 b=this._handlers[w];return b.push(C),{dispose:()=>{const _=b.indexOf(C);_!==-1&&b.splice(_,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 b=this._active.length-1;b>=0;b--)this._active[b].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,b){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(w,C,b);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(w,C,b))}unhook(w,C=!0){if(this._active.length){let b=!1,_=this._active.length-1,S=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,b=C,S=this._stack.fallThrough,this._stack.paused=!1),!S&&b===!1){for(;_>=0&&(b=this._active[_].unhook(w),b!==!0);_--)if(b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,b;_--}for(;_>=0;_--)if(b=this._active[_].unhook(!1),b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,b}else this._handlerFb(this._ident,"UNHOOK",w);this._active=g,this._ident=0}};const x=new m.Params;x.addParam(0),u.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=x,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():x,this._data="",this._hitLimit=!1}put(w,C,b){this._hitLimit||(this._data+=(0,h.utf32ToString)(w,C,b),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((b=>(this._params=x,this._data="",this._hitLimit=!1,b)));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),m=d(8742),f=d(6242),g=d(6351);class x{constructor(_){this.table=new Uint8Array(_)}setDefault(_,S){this.table.fill(_<<4|S)}add(_,S,v,k){this.table[S<<8|_]=v<<4|k}addMany(_,S,v,k){for(let E=0;E<_.length;E++)this.table[S<<8|_[E]]=v<<4|k}}u.TransitionTable=x;const w=160;u.VT500_TRANSITION_TABLE=(function(){const b=new x(4095),_=Array.apply(null,Array(256)).map(((L,A)=>A)),S=(L,A)=>_.slice(L,A),v=S(32,127),k=S(0,24);k.push(25),k.push.apply(k,S(28,32));const E=S(0,14);let N;for(N in b.setDefault(1,0),b.addMany(v,0,2,0),E)b.addMany([24,26,153,154],N,3,0),b.addMany(S(128,144),N,3,0),b.addMany(S(144,152),N,3,0),b.add(156,N,0,0),b.add(27,N,11,1),b.add(157,N,4,8),b.addMany([152,158,159],N,0,7),b.add(155,N,11,3),b.add(144,N,11,9);return b.addMany(k,0,3,0),b.addMany(k,1,3,1),b.add(127,1,0,1),b.addMany(k,8,0,8),b.addMany(k,3,3,3),b.add(127,3,0,3),b.addMany(k,4,3,4),b.add(127,4,0,4),b.addMany(k,6,3,6),b.addMany(k,5,3,5),b.add(127,5,0,5),b.addMany(k,2,3,2),b.add(127,2,0,2),b.add(93,1,4,8),b.addMany(v,8,5,8),b.add(127,8,5,8),b.addMany([156,27,24,26,7],8,6,0),b.addMany(S(28,32),8,0,8),b.addMany([88,94,95],1,0,7),b.addMany(v,7,0,7),b.addMany(k,7,0,7),b.add(156,7,0,0),b.add(127,7,0,7),b.add(91,1,11,3),b.addMany(S(64,127),3,7,0),b.addMany(S(48,60),3,8,4),b.addMany([60,61,62,63],3,9,4),b.addMany(S(48,60),4,8,4),b.addMany(S(64,127),4,7,0),b.addMany([60,61,62,63],4,0,6),b.addMany(S(32,64),6,0,6),b.add(127,6,0,6),b.addMany(S(64,127),6,0,0),b.addMany(S(32,48),3,9,5),b.addMany(S(32,48),5,9,5),b.addMany(S(48,64),5,0,6),b.addMany(S(64,127),5,7,0),b.addMany(S(32,48),4,9,5),b.addMany(S(32,48),1,9,2),b.addMany(S(32,48),2,9,2),b.addMany(S(48,127),2,10,0),b.addMany(S(48,80),1,10,0),b.addMany(S(81,88),1,10,0),b.addMany([89,90,92],1,10,0),b.addMany(S(96,127),1,10,0),b.add(80,1,11,9),b.addMany(k,9,0,9),b.add(127,9,0,9),b.addMany(S(28,32),9,0,9),b.addMany(S(32,48),9,9,12),b.addMany(S(48,60),9,8,10),b.addMany([60,61,62,63],9,9,10),b.addMany(k,11,0,11),b.addMany(S(32,128),11,0,11),b.addMany(S(28,32),11,0,11),b.addMany(k,10,0,10),b.add(127,10,0,10),b.addMany(S(28,32),10,0,10),b.addMany(S(48,60),10,8,10),b.addMany([60,61,62,63],10,0,11),b.addMany(S(32,48),10,9,12),b.addMany(k,12,0,12),b.add(127,12,0,12),b.addMany(S(28,32),12,0,12),b.addMany(S(32,48),12,9,12),b.addMany(S(48,64),12,0,11),b.addMany(S(64,127),12,12,13),b.addMany(S(64,127),10,12,13),b.addMany(S(64,127),9,12,13),b.addMany(k,13,13,13),b.addMany(v,13,13,13),b.add(127,13,0,13),b.addMany([27,156,24,26],13,14,0),b.add(w,0,2,0),b.add(w,8,5,8),b.add(w,6,0,6),b.add(w,11,0,11),b.add(w,13,13,13),b})();class C extends h.Disposable{constructor(_=u.VT500_TRANSITION_TABLE){super(),this._transitions=_,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new m.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(S,v,k)=>{},this._executeHandlerFb=S=>{},this._csiHandlerFb=(S,v)=>{},this._escHandlerFb=S=>{},this._errorHandlerFb=S=>S,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new f.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(_,S=[64,126]){let v=0;if(_.prefix){if(_.prefix.length>1)throw new Error("only one byte as prefix supported");if(v=_.prefix.charCodeAt(0),v&&60>v||v>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(_.intermediates){if(_.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let E=0;E<_.intermediates.length;++E){const N=_.intermediates.charCodeAt(E);if(32>N||N>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");v<<=8,v|=N}}if(_.final.length!==1)throw new Error("final must be a single byte");const k=_.final.charCodeAt(0);if(S[0]>k||k>S[1])throw new Error(`final must be in range ${S[0]} .. ${S[1]}`);return v<<=8,v|=k,v}identToString(_){const S=[];for(;_;)S.push(String.fromCharCode(255&_)),_>>=8;return S.reverse().join("")}setPrintHandler(_){this._printHandler=_}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(_,S){const v=this._identifier(_,[48,126]);this._escHandlers[v]===void 0&&(this._escHandlers[v]=[]);const k=this._escHandlers[v];return k.push(S),{dispose:()=>{const E=k.indexOf(S);E!==-1&&k.splice(E,1)}}}clearEscHandler(_){this._escHandlers[this._identifier(_,[48,126])]&&delete this._escHandlers[this._identifier(_,[48,126])]}setEscHandlerFallback(_){this._escHandlerFb=_}setExecuteHandler(_,S){this._executeHandlers[_.charCodeAt(0)]=S}clearExecuteHandler(_){this._executeHandlers[_.charCodeAt(0)]&&delete this._executeHandlers[_.charCodeAt(0)]}setExecuteHandlerFallback(_){this._executeHandlerFb=_}registerCsiHandler(_,S){const v=this._identifier(_);this._csiHandlers[v]===void 0&&(this._csiHandlers[v]=[]);const k=this._csiHandlers[v];return k.push(S),{dispose:()=>{const E=k.indexOf(S);E!==-1&&k.splice(E,1)}}}clearCsiHandler(_){this._csiHandlers[this._identifier(_)]&&delete this._csiHandlers[this._identifier(_)]}setCsiHandlerFallback(_){this._csiHandlerFb=_}registerDcsHandler(_,S){return this._dcsParser.registerHandler(this._identifier(_),S)}clearDcsHandler(_){this._dcsParser.clearHandler(this._identifier(_))}setDcsHandlerFallback(_){this._dcsParser.setHandlerFallback(_)}registerOscHandler(_,S){return this._oscParser.registerHandler(_,S)}clearOscHandler(_){this._oscParser.clearHandler(_)}setOscHandlerFallback(_){this._oscParser.setHandlerFallback(_)}setErrorHandler(_){this._errorHandler=_}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,k,E){this._parseStack.state=_,this._parseStack.handlers=S,this._parseStack.handlerPos=v,this._parseStack.transition=k,this._parseStack.chunkPos=E}parse(_,S,v){let k,E=0,N=0,L=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,L=this._parseStack.chunkPos+1;else{if(v===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(v===!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(v===!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(E=_[this._parseStack.chunkPos],k=this._dcsParser.unhook(E!==24&&E!==26,v),k)return k;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(E=_[this._parseStack.chunkPos],k=this._oscParser.end(E!==24&&E!==26,v),k)return k;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,L=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let A=L;A<S;++A){switch(E=_[A],N=this._transitions.table[this.currentState<<8|(E<160?E:w)],N>>4){case 2:for(let z=A+1;;++z){if(z>=S||(E=_[z])<32||E>126&&E<w){this._printHandler(_,A,z),A=z-1;break}if(++z>=S||(E=_[z])<32||E>126&&E<w){this._printHandler(_,A,z),A=z-1;break}if(++z>=S||(E=_[z])<32||E>126&&E<w){this._printHandler(_,A,z),A=z-1;break}if(++z>=S||(E=_[z])<32||E>126&&E<w){this._printHandler(_,A,z),A=z-1;break}}break;case 3:this._executeHandlers[E]?this._executeHandlers[E]():this._executeHandlerFb(E),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:A,code:E,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const O=this._csiHandlers[this._collect<<8|E];let I=O?O.length-1:-1;for(;I>=0&&(k=O[I](this._params),k!==!0);I--)if(k instanceof Promise)return this._preserveStack(3,O,I,N,A),k;I<0&&this._csiHandlerFb(this._collect<<8|E,this._params),this.precedingJoinState=0;break;case 8:do switch(E){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(E-48)}while(++A<S&&(E=_[A])>47&&E<60);A--;break;case 9:this._collect<<=8,this._collect|=E;break;case 10:const F=this._escHandlers[this._collect<<8|E];let B=F?F.length-1:-1;for(;B>=0&&(k=F[B](),k!==!0);B--)if(k instanceof Promise)return this._preserveStack(4,F,B,N,A),k;B<0&&this._escHandlerFb(this._collect<<8|E),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|E,this._params);break;case 13:for(let z=A+1;;++z)if(z>=S||(E=_[z])===24||E===26||E===27||E>127&&E<w){this._dcsParser.put(_,A,z),A=z-1;break}break;case 14:if(k=this._dcsParser.unhook(E!==24&&E!==26),k)return this._preserveStack(6,[],0,N,A),k;E===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let z=A+1;;z++)if(z>=S||(E=_[z])<32||E>127&&E<w){this._oscParser.put(_,A,z),A=z-1;break}break;case 6:if(k=this._oscParser.end(E!==24&&E!==26),k)return this._preserveStack(5,[],0,N,A),k;E===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&N}}}u.EscapeSequenceParser=C},6242:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OscHandler=u.OscParser=void 0;const h=d(5770),m=d(482),f=[];u.OscParser=class{constructor(){this._state=0,this._active=f,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const w=this._handlers[g];return w.push(x),{dispose:()=>{const C=w.indexOf(x);C!==-1&&w.splice(C,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=f,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||f,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,x,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(g,x,w);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(g,x,w))}start(){this.reset(),this._state=1}put(g,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const C=g[x++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-x>0&&this._put(g,x,w)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,b=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=x,b=this._stack.fallThrough,this._stack.paused=!1),!b&&w===!1){for(;C>=0&&(w=this._active[C].end(g),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",g);this._active=f,this._id=-1,this._state=0}}},u.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,x,w){this._hitLimit||(this._data+=(0,m.utf32ToString)(g,x,w),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,x}}},8742:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Params=void 0;const d=2147483647;class h{static fromArray(f){const g=new h;if(!f.length)return g;for(let x=Array.isArray(f[0])?1:0;x<f.length;++x){const w=f[x];if(Array.isArray(w))for(let C=0;C<w.length;++C)g.addSubParam(w[C]);else g.addParam(w)}return g}constructor(f=32,g=32){if(this.maxLength=f,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(f),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(f),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const f=new h(this.maxLength,this.maxSubParamsLength);return f.params.set(this.params),f.length=this.length,f._subParams.set(this._subParams),f._subParamsLength=this._subParamsLength,f._subParamsIdx.set(this._subParamsIdx),f._rejectDigits=this._rejectDigits,f._rejectSubDigits=this._rejectSubDigits,f._digitIsSub=this._digitIsSub,f}toArray(){const f=[];for(let g=0;g<this.length;++g){f.push(this.params[g]);const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&f.push(Array.prototype.slice.call(this._subParams,x,w))}return f}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(f){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(f<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=f>d?d:f}}addSubParam(f){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(f<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=f>d?d:f,this._subParamsIdx[this.length-1]++}}hasSubParams(f){return(255&this._subParamsIdx[f])-(this._subParamsIdx[f]>>8)>0}getSubParams(f){const g=this._subParamsIdx[f]>>8,x=255&this._subParamsIdx[f];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const f={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&(f[g]=this._subParams.slice(x,w))}return f}addDigit(f){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[g-1];x[g-1]=~w?Math.min(10*w+f,d):f}}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 m={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(m),h.dispose=()=>this._wrappedAddonDispose(m),h.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let h=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===d){h=m;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),m=d(511);u.BufferApiView=class{constructor(f,g){this._buffer=f,this.type=g}init(f){return this._buffer=f,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(f){const g=this._buffer.lines.get(f);if(g)return new h.BufferLineApiView(g)}getNullCell(){return new m.CellData}}},3785:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLineApiView=void 0;const h=d(511);u.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,f){if(!(m<0||m>=this._line.length))return f?(this._line.loadCell(m,f),f):this._line.loadCell(m,new h.CellData)}translateToString(m,f,g){return this._line.translateToString(m,f,g)}}},8285:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferNamespaceApi=void 0;const h=d(8771),m=d(8460),f=d(844);class g extends f.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new m.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}u.BufferNamespaceApi=g},7975:(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,(m=>h(m.toArray())))}addCsiHandler(d,h){return this.registerCsiHandler(d,h)}registerDcsHandler(d,h){return this._core.registerDcsHandler(d,((m,f)=>h(m,f.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(b,_,S,v){var k,E=arguments.length,N=E<3?_:v===null?v=Object.getOwnPropertyDescriptor(_,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,_,S,v);else for(var L=b.length-1;L>=0;L--)(k=b[L])&&(N=(E<3?k(N):E>3?k(_,S,N):k(_,S))||N);return E>3&&N&&Object.defineProperty(_,S,N),N},m=this&&this.__param||function(b,_){return function(S,v){_(S,v,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferService=u.MINIMUM_ROWS=u.MINIMUM_COLS=void 0;const f=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(b){super(),this.isUserScrolling=!1,this._onResize=this.register(new f.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new f.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(b.rawOptions.cols||0,u.MINIMUM_COLS),this.rows=Math.max(b.rawOptions.rows||0,u.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(b,this))}resize(b,_){this.cols=b,this.rows=_,this.buffers.resize(b,_),this._onResize.fire({cols:b,rows:_})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(b,_=!1){const S=this.buffer;let v;v=this._cachedBlankLine,v&&v.length===this.cols&&v.getFg(0)===b.fg&&v.getBg(0)===b.bg||(v=S.getBlankLine(b,_),this._cachedBlankLine=v),v.isWrapped=_;const k=S.ybase+S.scrollTop,E=S.ybase+S.scrollBottom;if(S.scrollTop===0){const N=S.lines.isFull;E===S.lines.length-1?N?S.lines.recycle().copyFrom(v):S.lines.push(v.clone()):S.lines.splice(E+1,0,v.clone()),N?this.isUserScrolling&&(S.ydisp=Math.max(S.ydisp-1,0)):(S.ybase++,this.isUserScrolling||S.ydisp++)}else{const N=E-k+1;S.lines.shiftElements(k+1,N-1,-1),S.lines.set(E,v.clone())}this.isUserScrolling||(S.ydisp=S.ybase),this._onScroll.fire(S.ydisp)}scrollLines(b,_,S){const v=this.buffer;if(b<0){if(v.ydisp===0)return;this.isUserScrolling=!0}else b+v.ydisp>=v.ybase&&(this.isUserScrolling=!1);const k=v.ydisp;v.ydisp=Math.max(Math.min(v.ydisp+b,v.ybase),0),k!==v.ydisp&&(_||this._onScroll.fire(v.ydisp))}};u.BufferService=C=h([m(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(v,k,E,N){var L,A=arguments.length,O=A<3?k:N===null?N=Object.getOwnPropertyDescriptor(k,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,k,E,N);else for(var I=v.length-1;I>=0;I--)(L=v[I])&&(O=(A<3?L(O):A>3?L(k,E,O):L(k,E))||O);return A>3&&O&&Object.defineProperty(k,E,O),O},m=this&&this.__param||function(v,k){return function(E,N){k(E,N,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreMouseService=void 0;const f=d(2585),g=d(8460),x=d(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:v=>v.button!==4&&v.action===1&&(v.ctrl=!1,v.alt=!1,v.shift=!1,!0)},VT200:{events:19,restrict:v=>v.action!==32},DRAG:{events:23,restrict:v=>v.action!==32||v.button!==3},ANY:{events:31,restrict:v=>!0}};function C(v,k){let E=(v.ctrl?16:0)|(v.shift?4:0)|(v.alt?8:0);return v.button===4?(E|=64,E|=v.action):(E|=3&v.button,4&v.button&&(E|=64),8&v.button&&(E|=128),v.action===32?E|=32:v.action!==0||k||(E|=3)),E}const b=String.fromCharCode,_={DEFAULT:v=>{const k=[C(v,!1)+32,v.col+32,v.row+32];return k[0]>255||k[1]>255||k[2]>255?"":`\x1B[M${b(k[0])}${b(k[1])}${b(k[2])}`},SGR:v=>{const k=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${C(v,!0)};${v.col};${v.row}${k}`},SGR_PIXELS:v=>{const k=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${C(v,!0)};${v.x};${v.y}${k}`}};let S=u.CoreMouseService=class extends x.Disposable{constructor(v,k){super(),this._bufferService=v,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 E of Object.keys(w))this.addProtocol(E,w[E]);for(const E of Object.keys(_))this.addEncoding(E,_[E]);this.reset()}addProtocol(v,k){this._protocols[v]=k}addEncoding(v,k){this._encodings[v]=k}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(v){if(!this._protocols[v])throw new Error(`unknown protocol "${v}"`);this._activeProtocol=v,this._onProtocolChange.fire(this._protocols[v].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(v){if(!this._encodings[v])throw new Error(`unknown encoding "${v}"`);this._activeEncoding=v}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(v){if(v.col<0||v.col>=this._bufferService.cols||v.row<0||v.row>=this._bufferService.rows||v.button===4&&v.action===32||v.button===3&&v.action!==32||v.button!==4&&(v.action===2||v.action===3)||(v.col++,v.row++,v.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,v,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(v))return!1;const k=this._encodings[this._activeEncoding](v);return k&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(k):this._coreService.triggerDataEvent(k,!0)),this._lastEvent=v,!0}explainEvents(v){return{down:!!(1&v),up:!!(2&v),drag:!!(4&v),move:!!(8&v),wheel:!!(16&v)}}_equalEvents(v,k,E){if(E){if(v.x!==k.x||v.y!==k.y)return!1}else if(v.col!==k.col||v.row!==k.row)return!1;return v.button===k.button&&v.action===k.action&&v.ctrl===k.ctrl&&v.alt===k.alt&&v.shift===k.shift}};u.CoreMouseService=S=h([m(0,f.IBufferService),m(1,f.ICoreService)],S)},6975:function(c,u,d){var h=this&&this.__decorate||function(S,v,k,E){var N,L=arguments.length,A=L<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,v,k,E);else for(var O=S.length-1;O>=0;O--)(N=S[O])&&(A=(L<3?N(A):L>3?N(v,k,A):N(v,k))||A);return L>3&&A&&Object.defineProperty(v,k,A),A},m=this&&this.__param||function(S,v){return function(k,E){v(k,E,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreService=void 0;const f=d(1439),g=d(8460),x=d(844),w=d(2585),C=Object.freeze({insertMode:!1}),b=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let _=u.CoreService=class extends x.Disposable{constructor(S,v,k){super(),this._bufferService=S,this._logService=v,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,f.clone)(C),this.decPrivateModes=(0,f.clone)(b)}reset(){this.modes=(0,f.clone)(C),this.decPrivateModes=(0,f.clone)(b)}triggerDataEvent(S,v=!1){if(this._optionsService.rawOptions.disableStdin)return;const k=this._bufferService.buffer;v&&this._optionsService.rawOptions.scrollOnUserInput&&k.ybase!==k.ydisp&&this._onRequestScrollToBottom.fire(),v&&this._onUserInput.fire(),this._logService.debug(`sending data "${S}"`,(()=>S.split("").map((E=>E.charCodeAt(0))))),this._onData.fire(S)}triggerBinaryEvent(S){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${S}"`,(()=>S.split("").map((v=>v.charCodeAt(0))))),this._onBinary.fire(S))}};u.CoreService=_=h([m(0,w.IBufferService),m(1,w.ILogService),m(2,w.IOptionsService)],_)},9074:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DecorationService=void 0;const h=d(8055),m=d(8460),f=d(844),g=d(6106);let x=0,w=0;class C extends f.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((S=>S==null?void 0:S.marker.line)),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,f.toDisposable)((()=>this.reset())))}registerDecoration(S){if(S.marker.isDisposed)return;const v=new b(S);if(v){const k=v.marker.onDispose((()=>v.dispose()));v.onDispose((()=>{v&&(this._decorations.delete(v)&&this._onDecorationRemoved.fire(v),k.dispose())})),this._decorations.insert(v),this._onDecorationRegistered.fire(v)}return v}reset(){for(const S of this._decorations.values())S.dispose();this._decorations.clear()}*getDecorationsAtCell(S,v,k){let E=0,N=0;for(const L of this._decorations.getKeyIterator(v))E=L.options.x??0,N=E+(L.options.width??1),S>=E&&S<N&&(!k||(L.options.layer??"bottom")===k)&&(yield L)}forEachDecorationAtCell(S,v,k,E){this._decorations.forEachByKey(v,(N=>{x=N.options.x??0,w=x+(N.options.width??1),S>=x&&S<w&&(!k||(N.options.layer??"bottom")===k)&&E(N)}))}}u.DecorationService=C;class b extends f.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(S){super(),this.options=S,this.onRenderEmitter=this.register(new m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=S.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),m=d(8343);class f{constructor(...x){this._entries=new Map;for(const[w,C]of x)this.set(w,C)}set(x,w){const C=this._entries.get(x);return this._entries.set(x,w),C}forEach(x){for(const[w,C]of this._entries.entries())x(w,C)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}u.ServiceCollection=f,u.InstantiationService=class{constructor(){this._services=new f,this._services.set(h.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const w=(0,m.getServiceDependencies)(g).sort(((_,S)=>_.index-S.index)),C=[];for(const _ of w){const S=this._services.get(_.id);if(!S)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${_.id}.`);C.push(S)}const b=w.length>0?w[0].index:x.length;if(x.length!==b)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${b+1} conflicts with ${x.length} static arguments`);return new g(...x,...C)}}},7866:function(c,u,d){var h=this&&this.__decorate||function(b,_,S,v){var k,E=arguments.length,N=E<3?_:v===null?v=Object.getOwnPropertyDescriptor(_,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,_,S,v);else for(var L=b.length-1;L>=0;L--)(k=b[L])&&(N=(E<3?k(N):E>3?k(_,S,N):k(_,S))||N);return E>3&&N&&Object.defineProperty(_,S,N),N},m=this&&this.__param||function(b,_){return function(S,v){_(S,v,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.traceCall=u.setTraceLogger=u.LogService=void 0;const f=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 f.Disposable{get logLevel(){return this._logLevel}constructor(b){super(),this._optionsService=b,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(b){for(let _=0;_<b.length;_++)typeof b[_]=="function"&&(b[_]=b[_]())}_log(b,_,S){this._evalLazyOptionalParams(S),b.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+_,...S)}trace(b,..._){var S;this._logLevel<=g.LogLevelEnum.TRACE&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.trace.bind(this._optionsService.options.logger))??console.log,b,_)}debug(b,..._){var S;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.debug.bind(this._optionsService.options.logger))??console.log,b,_)}info(b,..._){var S;this._logLevel<=g.LogLevelEnum.INFO&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.info.bind(this._optionsService.options.logger))??console.info,b,_)}warn(b,..._){var S;this._logLevel<=g.LogLevelEnum.WARN&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.warn.bind(this._optionsService.options.logger))??console.warn,b,_)}error(b,..._){var S;this._logLevel<=g.LogLevelEnum.ERROR&&this._log(((S=this._optionsService.options.logger)==null?void 0:S.error.bind(this._optionsService.options.logger))??console.error,b,_)}};u.LogService=C=h([m(0,g.IOptionsService)],C),u.setTraceLogger=function(b){w=b},u.traceCall=function(b,_,S){if(typeof S.value!="function")throw new Error("not supported");const v=S.value;S.value=function(...k){if(w.logLevel!==g.LogLevelEnum.TRACE)return v.apply(this,k);w.trace(`GlyphRenderer#${v.name}(${k.map((N=>JSON.stringify(N))).join(", ")})`);const E=v.apply(this,k);return w.trace(`GlyphRenderer#${v.name} return`,E),E}}},7302:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OptionsService=u.DEFAULT_OPTIONS=void 0;const h=d(8460),m=d(844),f=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:f.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends m.Disposable{constructor(C){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const b={...u.DEFAULT_OPTIONS};for(const _ in C)if(_ in b)try{const S=C[_];b[_]=this._sanitizeAndValidateOption(_,S)}catch(S){console.error(S)}this.rawOptions=b,this.options={...b},this._setupOptions(),this.register((0,m.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,b){return this.onOptionChange((_=>{_===C&&b(this.rawOptions[C])}))}onMultipleOptionChange(C,b){return this.onOptionChange((_=>{C.indexOf(_)!==-1&&b()}))}_setupOptions(){const C=_=>{if(!(_ in u.DEFAULT_OPTIONS))throw new Error(`No option with key "${_}"`);return this.rawOptions[_]},b=(_,S)=>{if(!(_ in u.DEFAULT_OPTIONS))throw new Error(`No option with key "${_}"`);S=this._sanitizeAndValidateOption(_,S),this.rawOptions[_]!==S&&(this.rawOptions[_]=S,this._onOptionChange.fire(_))};for(const _ in this.rawOptions){const S={get:C.bind(this,_),set:b.bind(this,_)};Object.defineProperty(this.options,_,S)}}_sanitizeAndValidateOption(C,b){switch(C){case"cursorStyle":if(b||(b=u.DEFAULT_OPTIONS[C]),!(function(_){return _==="block"||_==="underline"||_==="bar"})(b))throw new Error(`"${b}" is not a valid value for ${C}`);break;case"wordSeparator":b||(b=u.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof b=="number"&&1<=b&&b<=1e3)break;b=g.includes(b)?b:u.DEFAULT_OPTIONS[C];break;case"cursorWidth":b=Math.floor(b);case"lineHeight":case"tabStopWidth":if(b<1)throw new Error(`${C} cannot be less than 1, value: ${b}`);break;case"minimumContrastRatio":b=Math.max(1,Math.min(21,Math.round(10*b)/10));break;case"scrollback":if((b=Math.min(b,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${b}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(b<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${b}`);break;case"rows":case"cols":if(!b&&b!==0)throw new Error(`${C} must be numeric, value: ${b}`);break;case"windowsPty":b=b??{}}return b}}u.OptionsService=x},2660:function(c,u,d){var h=this&&this.__decorate||function(x,w,C,b){var _,S=arguments.length,v=S<3?w:b===null?b=Object.getOwnPropertyDescriptor(w,C):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(x,w,C,b);else for(var k=x.length-1;k>=0;k--)(_=x[k])&&(v=(S<3?_(v):S>3?_(w,C,v):_(w,C))||v);return S>3&&v&&Object.defineProperty(w,C,v),v},m=this&&this.__param||function(x,w){return function(C,b){w(C,b,x)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkService=void 0;const f=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),E={data:x,id:this._nextId++,lines:[k]};return k.onDispose((()=>this._removeMarkerFromLink(E,k))),this._dataByLinkId.set(E.id,E),E.id}const C=x,b=this._getEntryIdKey(C),_=this._entriesWithId.get(b);if(_)return this.addLineToLink(_.id,w.ybase+w.y),_.id;const S=w.addMarker(w.ybase+w.y),v={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[S]};return S.onDispose((()=>this._removeMarkerFromLink(v,S))),this._entriesWithId.set(v.key,v),this._dataByLinkId.set(v.id,v),v.id}addLineToLink(x,w){const C=this._dataByLinkId.get(x);if(C&&C.lines.every((b=>b.line!==w))){const b=this._bufferService.buffer.addMarker(w);C.lines.push(b),b.onDispose((()=>this._removeMarkerFromLink(C,b)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))==null?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const C=x.lines.indexOf(w);C!==-1&&(x.lines.splice(C,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};u.OscLinkService=g=h([m(0,f.IBufferService)],g)},8343:(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(m){return m[h]||[]},u.createDecorator=function(m){if(u.serviceRegistry.has(m))return u.serviceRegistry.get(m);const f=function(g,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,b,_){b[d]===b?b[h].push({id:C,index:_}):(b[h]=[{id:C,index:_}],b[d]=b)})(f,g,w)};return f.toString=()=>m,u.serviceRegistry.set(m,f),f}},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 m;u.IBufferService=(0,h.createDecorator)("BufferService"),u.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),u.ICoreService=(0,h.createDecorator)("CoreService"),u.ICharsetService=(0,h.createDecorator)("CharsetService"),u.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(f){f[f.TRACE=0]="TRACE",f[f.DEBUG=1]="DEBUG",f[f.INFO=2]="INFO",f[f.WARN=3]="WARN",f[f.ERROR=4]="ERROR",f[f.OFF=5]="OFF"})(m||(u.LogLevelEnum=m={})),u.ILogService=(0,h.createDecorator)("LogService"),u.IOptionsService=(0,h.createDecorator)("OptionsService"),u.IOscLinkService=(0,h.createDecorator)("OscLinkService"),u.IUnicodeService=(0,h.createDecorator)("UnicodeService"),u.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeService=void 0;const h=d(8460),m=d(225);class f{static extractShouldJoin(x){return(1&x)!=0}static extractWidth(x){return x>>1&3}static extractCharKind(x){return x>>3}static createPropertyValue(x,w,C=!1){return(16777215&x)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new h.EventEmitter,this.onChange=this._onChange.event;const x=new m.UnicodeV6;this.register(x),this._active=x.version,this._activeProvider=x}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(x){if(!this._providers[x])throw new Error(`unknown Unicode version "${x}"`);this._active=x,this._activeProvider=this._providers[x],this._onChange.fire(x)}register(x){this._providers[x.version]=x}wcwidth(x){return this._activeProvider.wcwidth(x)}getStringCellWidth(x){let w=0,C=0;const b=x.length;for(let _=0;_<b;++_){let S=x.charCodeAt(_);if(55296<=S&&S<=56319){if(++_>=b)return w+this.wcwidth(S);const E=x.charCodeAt(_);56320<=E&&E<=57343?S=1024*(S-55296)+E-56320+65536:w+=this.wcwidth(E)}const v=this.charProperties(S,C);let k=f.extractWidth(v);f.extractShouldJoin(v)&&(k-=f.extractWidth(C)),w+=k,C=v}return w}charProperties(x,w){return this._activeProvider.charProperties(x,w)}}u.UnicodeService=f}},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 o={};return(()=>{var c=o;Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const u=a(9042),d=a(3236),h=a(844),m=a(5741),f=a(8285),g=a(7975),x=a(7090),w=["cols","rows"];class C extends h.Disposable{constructor(_){super(),this._core=this.register(new d.Terminal(_)),this._addonManager=this.register(new m.AddonManager),this._publicOptions={...this._core.options};const S=k=>this._core.options[k],v=(k,E)=>{this._checkReadonlyOptions(k),this._core.options[k]=E};for(const k in this._core.options){const E={get:S.bind(this,k),set:v.bind(this,k)};Object.defineProperty(this._publicOptions,k,E)}}_checkReadonlyOptions(_){if(w.includes(_))throw new Error(`Option "${_}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new f.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const _=this._core.coreService.decPrivateModes;let S="none";switch(this._core.coreMouseService.activeProtocol){case"X10":S="x10";break;case"VT200":S="vt200";break;case"DRAG":S="drag";break;case"ANY":S="any"}return{applicationCursorKeysMode:_.applicationCursorKeys,applicationKeypadMode:_.applicationKeypad,bracketedPasteMode:_.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:S,originMode:_.origin,reverseWraparoundMode:_.reverseWraparound,sendFocusMode:_.sendFocus,wraparoundMode:_.wraparound}}get options(){return this._publicOptions}set options(_){for(const S in _)this._publicOptions[S]=_[S]}blur(){this._core.blur()}focus(){this._core.focus()}input(_,S=!0){this._core.input(_,S)}resize(_,S){this._verifyIntegers(_,S),this._core.resize(_,S)}open(_){this._core.open(_)}attachCustomKeyEventHandler(_){this._core.attachCustomKeyEventHandler(_)}attachCustomWheelEventHandler(_){this._core.attachCustomWheelEventHandler(_)}registerLinkProvider(_){return this._core.registerLinkProvider(_)}registerCharacterJoiner(_){return this._checkProposedApi(),this._core.registerCharacterJoiner(_)}deregisterCharacterJoiner(_){this._checkProposedApi(),this._core.deregisterCharacterJoiner(_)}registerMarker(_=0){return this._verifyIntegers(_),this._core.registerMarker(_)}registerDecoration(_){return this._checkProposedApi(),this._verifyPositiveIntegers(_.x??0,_.width??0,_.height??0),this._core.registerDecoration(_)}hasSelection(){return this._core.hasSelection()}select(_,S,v){this._verifyIntegers(_,S,v),this._core.select(_,S,v)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(_,S){this._verifyIntegers(_,S),this._core.selectLines(_,S)}dispose(){super.dispose()}scrollLines(_){this._verifyIntegers(_),this._core.scrollLines(_)}scrollPages(_){this._verifyIntegers(_),this._core.scrollPages(_)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(_){this._verifyIntegers(_),this._core.scrollToLine(_)}clear(){this._core.clear()}write(_,S){this._core.write(_,S)}writeln(_,S){this._core.write(_),this._core.write(`\r
261
+ `,S)}paste(_){this._core.paste(_)}refresh(_,S){this._verifyIntegers(_,S),this._core.refresh(_,S)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(_){this._addonManager.loadAddon(this,_)}static get strings(){return u}_verifyIntegers(..._){for(const S of _)if(S===1/0||isNaN(S)||S%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(..._){for(const S of _)if(S&&(S===1/0||isNaN(S)||S%1!=0||S<0))throw new Error("This API only accepts positive integers")}}c.Terminal=C})(),o})()))})(Lx)),Lx.exports}var tU=eU();/**
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 nU=2,rU=1,sU=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var f;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((f=this._terminal.options.overviewRuler)==null?void 0:f.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},u=c.top+c.bottom,d=c.right+c.left,h=r-u,m=a-d-t;return{cols:Math.max(nU,Math.floor(m/e.css.cell.width)),rows:Math.max(rU,Math.floor(h/e.css.cell.height))}}};function iU({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=j.useRef(null),o=j.useRef(e),c=j.useRef(null),u=j.useRef(null),d=fs(f=>f.writeSession),h=fs(f=>f.resizeSession),m=It(f=>f.settings[Ne.DISPLAY_TERMINAL_FONT]??Mh);return j.useEffect(()=>{o.current=e},[e]),j.useEffect(()=>{It.getState().getSetting(Ne.DISPLAY_TERMINAL_FONT)},[]),j.useEffect(()=>{if(!n)return;const f=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),j.useEffect(()=>{if(!a.current)return;const f=new tU.Terminal({fontFamily:m,fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new sU;f.loadAddon(g),c.current={term:f,fitAddon:g},a.current.addEventListener("keydown",b=>{b.key==="Escape"&&n&&(b.preventDefault(),b.stopPropagation(),n())}),f.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),g.fit(),r&&setTimeout(()=>{f.focus()},150);const w=new ResizeObserver(()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{requestAnimationFrame(()=>{var _;g.fit&&g.fit();const b=(_=c.current)==null?void 0:_.term;b&&b.cols>0&&b.rows>0&&h(o.current,b.cols,b.rows)})},100)});w.observe(a.current),f.onData(b=>{if(b==="\x1B"&&n){n();return}d(o.current,b)}),f.onKey(b=>{b.key==="\x1B"&&n&&(b.domEvent.stopPropagation(),n())});const C=Ht.subscribe(b=>{const _=b.payload;if(b.type==="terminal.output"&&(_==null?void 0:_.sessionId)===o.current){const S=_==null?void 0:_.data;S&&f.write(S)}});return()=>{C(),w.disconnect(),u.current&&clearTimeout(u.current),f.dispose(),c.current=null}},[e,d,h]),j.useEffect(()=>{const f=c.current;if(!f)return;f.term.options.fontFamily=m,f.fitAddon.fit();const{cols:g,rows:x}=f.term;g>0&&x>0&&h(o.current,g,x)},[m,h]),s.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[s.jsx("div",{}),s.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:s.jsx(_b,{})})]}),s.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:f=>{f.key==="Escape"&&n&&(f.preventDefault(),f.stopPropagation(),n())}})]})}const CT="openfox-chat-textarea";function Cu(e){if(!Vt())return;const t=document.getElementById(CT);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function aU(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 oU({isOpen:e,onClose:t}){const n=fs(C=>C.createSession),r=fs(C=>C.killSession),a=fs(C=>C.sessions),o=fs(C=>C.setWorkdir),c=fs(C=>C.fetchSessions),u=zt(C=>C.currentProject),d=De(C=>C.currentSession),[h,m]=j.useState(!0),f=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&&o(C)},[d==null?void 0:d.workspace,u==null?void 0:u.workdir,o]),j.useEffect(()=>{e?(m(!0),c(u==null?void 0:u.id).finally(()=>m(!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;Vt()&&((C=f.current)==null||C.focus()),setTimeout(()=>{g.current=!1},200)},100)):x.current=!1},[e]),j.useEffect(()=>{if(!e)return;const C=b=>{g.current||b.key==="Escape"&&(b.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:w}),s.jsxs("div",{ref:f,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),w())},children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>n(void 0,(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(q3,{})}),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(Ss,{})})]})]}),s.jsx(ft,{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 ${aU(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>s.jsx(iU,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1&&Vt()},C.id))})})]})]}):null}function zl({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",align:a="left",isOpen:o,onOpenChange:c,labelActionClassName:u}){const[d,h]=j.useState(!1),m=o!==void 0,f=m?o:d,g=q=>{if(m){const W=typeof q=="function"?q(d):q;c==null||c(W)}else h(q)},[x,w]=j.useState(null),C=j.useRef(null),b=j.useRef(null),[_,S]=j.useState(0),v=j.useRef(0),k=j.useMemo(()=>[...e,...t],[e,t]),E=j.useRef(k),N=j.useCallback(()=>{if(!C.current)return;const q=C.current.getBoundingClientRect(),W=200,ee=Number.parseInt(r,10)||120,H=window.innerHeight-q.bottom<W;w({top:H?q.top-W-4:q.bottom+4,left:a==="right"?q.right-ee:q.left,alignToTop:H})},[a,r]);j.useEffect(()=>{E.current=k},[k]),j.useEffect(()=>{function q(W){if(b.current){const ee=W.target;b.current.contains(ee)||g(!1)}}return f&&document.addEventListener("mousedown",q),()=>{document.removeEventListener("mousedown",q)}},[f]),j.useEffect(()=>{f&&N()},[f,N]),j.useEffect(()=>{if(!f)return;setTimeout(()=>{var W;(W=b.current)==null||W.focus()},0);function q(W){const ee=E.current,J=ee.filter(P=>!L(P)),H=A(v.current,ee);switch(W.key){case"ArrowDown":if(W.preventDefault(),W.stopPropagation(),H<J.length-1){const P=O(v.current+1,ee);v.current=P,S(P)}break;case"ArrowUp":if(W.preventDefault(),W.stopPropagation(),H>0){const P=I(v.current-1,ee);v.current=P,S(P)}break;case"Enter":W.preventDefault(),W.stopPropagation(),F(v.current,ee);break;case"Escape":W.preventDefault(),W.stopPropagation(),g(!1);break}}return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[f,k]);function L(q){var J;const W=q.label;return W?String(((J=W.props)==null?void 0:J.className)??"").includes("cursor-default"):!1}function A(q,W){let ee=0;for(let J=0;J<q;J++){const H=W[J];H&&!L(H)&&ee++}return ee}function O(q,W){for(let ee=q;ee<W.length;ee++){const J=W[ee];if(J&&!L(J))return ee}return q}function I(q,W){for(let ee=q;ee>=0;ee--){const J=W[ee];if(J&&!L(J))return ee}return q}function F(q,W){var J;const ee=W[q];!ee||L(ee)||((J=ee.onClick)==null||J.call(ee),ee.href&&(window.history.pushState(null,"",ee.href),window.dispatchEvent(new PopStateEvent("popstate"))),g(!1))}j.useEffect(()=>{f&&(S(k.findIndex(q=>!L(q))),v.current=k.findIndex(q=>!L(q)))},[f,k]);const B=q=>{q.stopPropagation(),f||N(),g(!f)};function z(q,W,ee,J){const P=!L(q)&&J===_,D=s.jsxs(s.Fragment,{children:[q.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:q.icon}),s.jsx("span",{className:"min-w-0",children:q.label})]}),$=W!==ee-1?"border-b border-border":"",K=`px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${q.danger?"text-accent-error hover:bg-accent-error/10":P?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,Z=q.href?s.jsx(ir,{href:q.href,onClick:V=>{var M;(M=q.onClick)==null||M.call(q,V),g(!1)},onAuxClick:()=>g(!1),className:`w-full ${K}`,children:D}):s.jsx("button",{onClick:V=>{var M;(M=q.onClick)==null||M.call(q,V),q.closeOnClick!==!1&&g(!1)},className:`w-full ${K}`,children:D});return q.labelAction?s.jsxs("div",{className:`flex items-center gap-1 pr-1 ${$} ${u??""}`,children:[Z,s.jsx("span",{className:"flex-shrink-0",children:q.labelAction})]},J):s.jsx("div",{className:$,children:Z},J)}const Y=x&&s.jsxs("div",{ref:b,"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(ft,{className:"max-h-[60vh]",children:e.map((q,W)=>z(q,W,e.length,W))}),t.length>0&&s.jsx("div",{className:"border-t border-border",children:t.map((q,W)=>z(q,W,t.length,e.length+W))})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative",children:s.jsx("div",{ref:C,onClick:B,children:n})}),f&&wi.createPortal(Y,document.body)]})}function lU(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 kT({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(null);j.useEffect(()=>{e&&m()},[e]);const m=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})}},f=j.useCallback(async v=>{o(!0),u(null);try{const E=await(await xe("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:v})})).json();E.success?(r(),t()):E.sudoAvailable?u("Failed to fix permissions: "+(E.error||"Unknown error")):u(`Passwordless sudo is not available. Please fix permissions manually:
273
+
274
+ `+(v==="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{o(!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)??"",b=g&&!x,_=!g&&x,S=!g&&!x;return s.jsx(jt,{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:b?s.jsxs(s.Fragment,{children:["The group ",s.jsx("strong",{children:C})," doesn't have write access:"]}):_?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:[b&&s.jsxs(s.Fragment,{children:[s.jsx(st,{type:"button",variant:"primary",onClick:()=>f("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),_&&s.jsxs(s.Fragment,{children:[s.jsx(st,{type:"button",variant:"primary",onClick:()=>f("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(st,{type:"button",variant:"primary",onClick:()=>f("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",s.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!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(st,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function jT({isOpen:e,onClose:t}){const[,n]=wn(),r=zt(E=>E.listProjects),[a,o]=j.useState(""),[c,u]=j.useState(null),[d,h]=j.useState(!1),[m,f]=j.useState(""),[g,x]=j.useState(null),w=j.useRef(null);j.useEffect(()=>{e&&(xe("/api/config").then(E=>E.json()).then(E=>{E.workdir&&f(E.workdir)}),o(""),u(null),h(!1),x(null),setTimeout(()=>{var E;Vt()&&((E=w.current)==null||E.focus())},100))},[e]);const C=j.useCallback(async E=>{E.preventDefault();const N=lU(a);if(!N.valid){u(N.error);return}const L=`${m}/${a}`;await S(L)},[a,n,t,m]),b=j.useCallback(()=>{x(null)},[]),_=j.useCallback(async()=>{const E=`${m}/${a}`;await S(E)},[m,a,n,t,x,u,h]);async function S(E){h(!0),u(null),x(null);try{const N=await xe("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:E})});if(!N.ok){const O=await N.json().catch(()=>({}));if(O.code==="EACCES"){x(E),h(!1);return}throw new Error(O.error||"Failed to create project")}const A=(await N.json()).project;t(),await r(),n(`/p/${A.id}`)}catch(N){u(N instanceof Error?N.message:"Failed to create project"),h(!1)}}const v=j.useCallback(()=>{o(""),u(null),t()},[t]),k=a?`${m}/${a}`:"";return s.jsxs(s.Fragment,{children:[s.jsx(jt,{isOpen:e,onClose:v,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(Ms,{ref:w,id:"project-name",value:a,onChange:E=>{o(E.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(st,{type:"button",variant:"secondary",onClick:v,disabled:d,children:"Cancel"}),s.jsx(st,{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(as,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&s.jsx(kT,{isOpen:!!g,onClose:b,path:g,onRetry:_})]})}function ET(){return nn(e=>e.workdir)}function mk({projects:e,currentProject:t}){const[,n]=wn(),r=zt(b=>b.loadProject),a=zt(b=>b.toggleStar),o=zt(b=>b.createProject),c=zt(b=>b.listProjects),[u,d]=j.useState(!1),[h,m]=j.useState(!1),f=ET(),g=j.useCallback(async b=>{const _=Tu(b),S=await o(_,b);return S&&"id"in S?(await c(),m(!1),n(`/p/${S.id}`),!0):!1},[o,c,n]),w=j.useMemo(()=>{const b=e.filter(S=>S.isStarred).sort((S,v)=>S.name.localeCompare(v.name)),_=e.filter(S=>!S.isStarred).sort((S,v)=>S.name.localeCompare(v.name));return[...b,..._]},[e]).map(b=>({label:s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsx("span",{className:"truncate flex-1",children:b.name}),s.jsx("button",{onClick:_=>{_.stopPropagation(),_.preventDefault(),_.nativeEvent.stopImmediatePropagation(),a(b.id,!b.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:b.isStarred?"Unstar project":"Star project",children:b.isStarred?s.jsx(mu,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Vf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:b.id===(t==null?void 0:t.id)?s.jsx(zs,{}):void 0,href:`/p/${b.id}`,closeOnClick:!0,onClick:()=>{r(b.id)}})),C=[{label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ss,{className:"w-4 h-4"}),s.jsx("span",{children:"Open Project"})]}),onClick:()=>m(!0)},{label:s.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[s.jsx(as,{className:"w-4 h-4"}),s.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(zl,{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(yn,{})]}),minWidth:"250px"}),u&&s.jsx(jT,{isOpen:u,onClose:()=>d(!1)}),h&&s.jsx(qf,{initialPath:f??void 0,onSelect:g,onClose:()=>m(!1)})]})}function NT(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),c=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${o}/${c}`}function mm(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function TT(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),c=mm(e);if(o===0)return`today ${c}`;if(o===1)return`yesterday ${c}`;if(o<7)return`${o} 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 AT(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 cU(e){const{year:t,month:n,day:r}=AT(e);return`${t}-${n}-${r}`}function LT(e){const t=new Map;for(const a of e){const o=cU(a.updatedAt);t.has(o)||t.set(o,[]),t.get(o).push(a)}for(const[a,o]of t)o.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,o)=>o.localeCompare(a)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function uU(e){const{year:t,month:n,day:r}=AT(e);return`${t}/${n}/${r} ${mm(e)}`}function mf(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function dU({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var w;const o=De(C=>C.loadSession),c=De(C=>C.toggleFavorite),u=50,d=e.filter(C=>C.projectId===t.id).slice(0,15),h=d.filter(C=>C.isFavorite),m=d.filter(C=>!C.isFavorite),f=j.useMemo(()=>{const C=[];C.push({label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(as,{className:"w-4 h-4 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});const b=(S,v)=>{C.push({label:s.jsxs("div",{className:"min-w-[160px]",children:[s.jsx("div",{className:"truncate text-sm",children:mf(S.title??S.id.slice(0,8),u)}),v&&s.jsx("div",{className:"text-text-muted text-xs",children:mm(S.updatedAt)})]}),icon:S.id===(n==null?void 0:n.id)?s.jsx(zs,{}):void 0,href:`/p/${t.id}/s/${S.id}`,onClick:()=>{o(S.id)},labelAction:s.jsx("button",{onClick:()=>c(S.id,!S.isFavorite),className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:S.isFavorite?"Unfavorite session":"Favorite session",children:S.isFavorite?s.jsx(mu,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Vf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})})},_=S=>{const v=LT(S);for(const[k,E]of v){const N=E[0];if(N){C.push({label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:NT(N.updatedAt)}),onClick:()=>{}});for(const L of E)b(L,!0)}}};if(h.length>0)for(const S of h)b(S,!1);return _(m),C},[t.id,h,m,n==null?void 0:n.id]),g=((w=n==null?void 0:n.metadata)==null?void 0:w.title)??(n?n.id.slice(0,8):null),x=g?mf(g,u):"No session selected";return s.jsx(zl,{items:f,isOpen:r,onOpenChange:a,trigger:s.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:g??"","data-testid":"header-session-dropdown",children:[x,s.jsx(yn,{})]}),minWidth:"280px",labelActionClassName:"pr-3"})}function hU({items:e,trigger:t,isActive:n=!1}){const[r,a]=j.useState(!1),o=j.useRef(null);return j.useEffect(()=>{function c(u){o.current&&!o.current.contains(u.target)&&a(!1)}if(r)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),s.jsxs("div",{className:"relative",ref:o,children:[s.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,s.jsx(yn,{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===ir?c.label:null;if(d){const h=d.props.href||"";return s.jsxs(ir,{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 fU({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),o=[{label:s.jsxs(ir,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[s.jsx(as,{className:"w-3 h-3 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(c=>({label:s.jsx(ir,{href:`/p/${e.id}/s/${c.id}`,className:"flex items-center gap-2 truncate text-sm",children:s.jsx("span",{children:mf(c.title??c.id.slice(0,8),50)})}),icon:c.id===(n==null?void 0:n.id)?s.jsx(zs,{className:"w-3 h-3"}):void 0})),{label:s.jsxs(ir,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[s.jsx(z3,{className:"w-3 h-3"}),s.jsx("span",{className:"text-sm",children:"Projects"})]})}];return s.jsx(hU,{items:o,trigger:s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function RT(){const e=ct(a=>a.defaults),t=ct(a=>a.userItems),n=ct(a=>a.projectItems),r=ct(a=>a.fetchAgents);return{agents:[...e,...t,...n],fetchAgents:r}}function mU({task:e,projectId:t,agents:n,queuePosition:r,onEdit:a,onMove:o,onMoveUp:c,onMoveDown:u,onDuplicate:d,onDelete:h,onDragStart:m,onDropOnCard:f,onOpenSession:g}){const[x,w]=j.useState(!1),C=n.find(E=>E.id===e.agentId),b=e.agentId?oo(n,e.agentId):void 0,_=e.attachments.filter(E=>E.mimeType.startsWith("image/")),S=e.activeSessionId??e.sessionIds[e.sessionIds.length-1],v=[{label:"Edit",icon:s.jsx(pb,{className:"w-3.5 h-3.5"}),onClick:()=>a(e)},{label:"History & evidence",icon:s.jsx(zf,{className:"w-3.5 h-3.5"}),onClick:()=>w(E=>!E)},{label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:"Move to…"}),onClick:()=>{}},{label:"To Do",onClick:()=>o(e,"todo")},{label:"In Progress",onClick:()=>o(e,"in_progress")},{label:"Done",onClick:()=>o(e,"done")},{label:"Move up",icon:s.jsx(mb,{className:"w-3.5 h-3.5"}),onClick:()=>c(e)},{label:"Move down",icon:s.jsx(yn,{className:"w-3.5 h-3.5"}),onClick:()=>u(e)}],k=[{label:"Duplicate",icon:s.jsx(jl,{className:"w-3.5 h-3.5"}),onClick:()=>d(e)},{label:"Delete",icon:s.jsx(Si,{className:"w-3.5 h-3.5"}),danger:!0,onClick:()=>h(e)}];return s.jsxs("div",{draggable:!0,onClick:()=>a(e),onDragStart:E=>{E.dataTransfer.effectAllowed="move",m(e)},onDragOver:E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},onDrop:E=>{E.preventDefault(),f(e)},className:`group relative cursor-pointer bg-bg-tertiary border border-border rounded-lg p-2.5 hover:border-accent-primary/40 transition-colors ${e.status==="in_progress"?"ring-1 ring-inset ring-accent-primary/20":""}`,children:[e.status==="in_progress"&&s.jsxs("span",{className:`mb-1.5 inline-flex items-center gap-1 text-xs font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded ${e.runState==="running"?"bg-emerald-500/15 text-emerald-400":"bg-amber-500/15 text-amber-400"}`,children:[e.runState==="running"?s.jsx(Hf,{className:"w-2.5 h-2.5"}):s.jsx(vE,{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(zl,{items:v,footerItems:k,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(gb,{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]}),_.length>0&&s.jsx("span",{className:"flex -space-x-1",children:_.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:b},children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:b}}),C.name]}),S&&s.jsxs(ir,{href:`/p/${t}/s/${S}`,onClick:E=>{E.stopPropagation(),g==null||g(S)},className:"ml-auto text-xs px-1.5 py-1 rounded bg-accent-primary/10 text-accent-primary hover:bg-accent-primary/20 flex items-center gap-1",children:["Open session ",s.jsx(yb,{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 pU({title:e,accentClass:t,hint:n,tasks:r,projectId:a,agents:o,queuePositionOf:c,headerAction:u,footer:d,onEdit:h,onMove:m,onMoveUp:f,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnColumn:b,onDropOnCard:_,onOpenSession:S}){return s.jsxs("section",{onDragOver:v=>{v.preventDefault(),v.dataTransfer.dropEffect="move"},onDrop:v=>{v.preventDefault(),b()},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(mU,{task:v,projectId:a,agents:o,queuePosition:c(v),onEdit:h,onMove:m,onMoveUp:f,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnCard:_,onOpenSession: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 gU={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},xU="M6 18L18 6M6 6l12 12";function Mu({onClick:e,className:t="",size:n="md",variant:r="default","aria-label":a,title:o="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(Wf,{onClick:e,icon:xU,iconSize:gU[n],className:`${c} ${t}`,title:o,...a!==void 0?{"aria-label":a}:{}})}const yU=["text/"],bU=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function zh(e){return e.startsWith("image/")}function DT(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function dv(e){return bU.includes(e)||yU.some(t=>e.startsWith(t))}function gl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function OT(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const vU={"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 _U(e){var t;return vU[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function SU(e){return zh(e)||dv(e)||e==="application/pdf"}function hv({attachment:e,onRemove:t}){const n=OT(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(Mu,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),DT(e.mimeType)?s.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):s.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-md bg-bg-secondary text-xs font-bold text-text-muted",children:n}),s.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:gl(e.size)})]})}function wU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function CU(e,t){const n=t.toLowerCase(),r=(e.name??"").toLowerCase(),a=e.id.toLowerCase(),o=a.replace(/-/g," ");return r.includes(n)||a.includes(n)||o.includes(n)}function pk(e){return e.models.some(n=>n.selected)?e.models.filter(n=>n.selected):e.models}function IT({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:o,settingDefault:c,highlighted:u,onModelClick:d,onSetDefault:h,onEditModel:m}){var f;return s.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${u?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[s.jsx("button",{type:"button",onClick:()=>d(e,t.id),disabled:a,className:"flex-1 truncate text-left",children:t.name??((f=t.id.split("/").pop())==null?void 0:f.replace(/-/g," "))??t.id}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[s.jsx("span",{className:"text-xs text-text-muted",children:wU(t.contextWindow)}),o&&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(mu,{className:"w-3.5 h-3.5 text-accent-warning"}):s.jsx(Vf,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),m&&s.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),m(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:s.jsx(pb,{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(zs,{className:"w-3.5 h-3.5"})})]})]})}function MT({providers:e,onSelect:t,onEscape:n,extraItemCount:r=0}){const[a,o]=j.useState(""),[c,u]=j.useState(-1),d=j.useRef(null),h=j.useRef(null),m=j.useMemo(()=>a.trim()?e.map(w=>({provider:w,models:pk(w).filter(C=>CU(C,a))})).filter(w=>w.models.length>0):e.map(w=>({provider:w,models:pk(w)})),[e,a]),f=j.useMemo(()=>m.flatMap(w=>w.models.map(C=>({providerId:w.provider.id,modelConfig:C}))),[m]),g=f.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:o,highlightedIndex:c,setHighlightedIndex:u,visibleGroups:m,flatItems:f,totalNavItems:g,handleSearchKeyDown:w=>{switch(w.key){case"Escape":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),g>0&&u(C=>C<g-1?C+1:0);break;case"ArrowUp":w.preventDefault(),g>0&&u(C=>C>0?C-1:g-1);break;case"Home":w.preventDefault(),u(0);break;case"End":w.preventDefault(),u(g-1);break;case"Enter":if(w.preventDefault(),c>=0&&c<f.length){const C=f[c];C&&t(C.providerId,C.modelConfig.id)}break}},highlightedRef:d,inputRef:h}}function fv({providers:e,value:t,onChange:n,defaultLabel:r="Default (global model)"}){var N;const[a,o]=j.useState(!1),c=j.useRef(null),u=j.useRef(null),[d,h]=j.useState({}),m=t==null?void 0:t.split("/").slice(1).join("/"),f=m?((N=m.split("/").pop())==null?void 0:N.replace(/-/g," "))??m:void 0,{searchQuery:g,setSearchQuery:x,highlightedIndex:w,setHighlightedIndex:C,visibleGroups:b,flatItems:_,handleSearchKeyDown:S,highlightedRef:v,inputRef:k}=MT({providers:e,onSelect:(L,A)=>{n(`${L}/${A}`),o(!1)},onEscape:()=>o(!1)}),E=j.useCallback(()=>{if(!a||!u.current)return;const L=u.current.getBoundingClientRect();h({position:"fixed",top:`${L.bottom+4}px`,left:`${L.left}px`,width:`${Math.max(L.width,288)}px`})},[a]);return j.useEffect(()=>(E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}),[E]),j.useEffect(()=>{if(!a)return;function L(O){var I;c.current&&!c.current.contains(O.target)&&!((I=O.target)!=null&&I.closest("[data-model-picker-dropdown]"))&&(o(!1),x(""),C(-1))}const A=setTimeout(()=>{document.addEventListener("mousedown",L)},0);return()=>{clearTimeout(A),document.removeEventListener("mousedown",L)}},[a,x,C]),j.useEffect(()=>{var L;a?(E(),Vt()&&((L=k.current)==null||L.focus())):(x(""),C(-1))},[a,x,C,k,E]),s.jsxs("div",{className:"relative",ref:c,children:[s.jsxs("button",{ref:u,type:"button",onClick:()=>o(!a),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary hover:bg-bg-secondary transition-colors",children:[s.jsx("span",{className:f?"text-text-primary":"text-text-muted",children:f??r}),s.jsx(yn,{className:`w-3 h-3 text-text-muted transition-transform ${a?"rotate-180":""}`})]}),a&&typeof document<"u"&&wi.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(_i,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:k,type:"text",value:g,onInput:L=>{x(L.currentTarget.value),C(-1)},onKeyDown:S,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsxs(ft,{className:"flex-1",children:[s.jsx("button",{type:"button",onClick:()=>{n(void 0),o(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors hover:bg-bg-tertiary ${t?"text-text-muted":"text-accent-primary bg-accent-primary/5"}`,children:r}),b.map(L=>s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-1.5 text-xs font-medium text-text-muted uppercase tracking-wider bg-bg-tertiary/50",children:L.provider.name}),L.models.map(A=>{const I=_.findIndex(B=>B.providerId===L.provider.id&&B.modelConfig.id===A.id)===w,F=t===`${L.provider.id}/${A.id}`;return s.jsx("div",{ref:I?v:void 0,children:s.jsx(IT,{providerId:L.provider.id,modelConfig:A,isActive:F,highlighted:I,onModelClick:(B,z)=>{n(`${B}/${z}`),o(!1)}})},`${L.provider.id}/${A.id}`)})]},L.provider.id)),b.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 kU(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 mv={builtin:"Built-in",user:"Global",project:"Project"};function pf(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 $y(e,t,n){return n!=="auto"?e.find(r=>r.id===t&&r.scope===n)??pf(e,t):pf(e,t)}const PT=j.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:o},c){const u=kU(t,n),[d,h]=j.useState(0),m=j.useRef(null),f=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 _=w.toLowerCase(),S=r.filter(k=>k.id.toLowerCase().includes(_)||k.name.toLowerCase().includes(_)).map(k=>({type:"workflow",id:k.id,name:k.name,scope:k.scope,paramCount:(k.parameters??[]).length})),v=a.filter(k=>k.id.toLowerCase().includes(_)||k.name.toLowerCase().includes(_)).map(k=>({type:"command",id:k.id,name:k.name,paramCount:0}));return[...S,...v]})();j.useEffect(()=>{h(0),g.current=0},[C.length]);const b=j.useCallback(_=>{if(!u||C.length===0)return!1;switch(_.key){case"ArrowDown":return _.preventDefault(),h(S=>{var k;const v=Math.min(S+1,C.length-1);return(k=f.current[v])==null||k.scrollIntoView({block:"nearest"}),v}),!0;case"ArrowUp":return _.preventDefault(),h(S=>{var k;const v=Math.max(S-1,0);return(k=f.current[v])==null||k.scrollIntoView({block:"nearest"}),v}),!0;case"Enter":case"Tab":{const S=C[g.current];return S?(_.preventDefault(),o(S,u.startIndex),!0):!1}case"Escape":return _.preventDefault(),!0}return!1},[u,C,o]);return j.useImperativeHandle(c,()=>({handleKeyDown:b}),[b]),!u||C.length===0?null:s.jsx("div",{ref:m,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:s.jsx(ft,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("div",{children:C.map((_,S)=>s.jsxs("button",{ref:v=>{f.current[S]=v},role:"option","aria-selected":S===d,className:`w-full text-left px-3 py-2 flex items-center gap-2 text-sm ${S===d?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{u&&o(_,u.startIndex)},children:[s.jsxs("span",{className:`font-medium ${_.type==="workflow"?"text-accent-primary":"text-accent-warning"}`,children:["/",_.id]}),s.jsx("span",{className:"truncate flex-1",children:_.name}),_.type==="workflow"&&s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:mv[_.scope]}),_.paramCount>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:[_.paramCount," param",_.paramCount>1?"s":""]})]},`${_.type}-${_.id}-${_.type==="workflow"?_.scope:""}`))})})})});function jU(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 BT=j.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},o){const c=jU(t,n),[u,d]=j.useState([]),[h,m]=j.useState(!1),[f,g]=j.useState(0),x=j.useRef(null),w=j.useRef([]),C=j.useRef(0),b=j.useRef([]);j.useEffect(()=>{C.current=f},[f]),j.useEffect(()=>{b.current=u},[u]),j.useEffect(()=>{if(!c){d([]);return}const v=setTimeout(()=>{_(c.query)},150);return()=>clearTimeout(v)},[c==null?void 0:c.query,r]);const _=async v=>{m(!0);try{const k=new URLSearchParams({q:v});r&&k.set("workdir",r);const N=await(await xe(`/api/files?${k.toString()}`)).json();d(N),g(0),C.current=0}catch(k){console.error("File search failed:",k),d([])}finally{m(!1)}},S=j.useCallback(v=>{if(!c)return!1;switch(v.key){case"ArrowDown":return v.preventDefault(),g(k=>{var N;const E=Math.min(k+1,b.current.length-1);return w.current[E]&&((N=w.current[E])==null||N.scrollIntoView({block:"nearest"})),E}),C.current=Math.min(C.current+1,b.current.length-1),!0;case"ArrowUp":return v.preventDefault(),g(k=>{var N;const E=Math.max(k-1,0);return w.current[E]&&((N=w.current[E])==null||N.scrollIntoView({block:"nearest"})),E}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const k=b.current;return k[C.current]?(v.preventDefault(),a(k[C.current],c.startIndex),!0):!1}case"Escape":return v.preventDefault(),d([]),!0}return!1},[c,a]);return j.useImperativeHandle(o,()=>({handleKeyDown:S}),[S]),j.useEffect(()=>{if(!c)return;const v=k=>{x.current&&!x.current.contains(k.target)&&d([])};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[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(fa,{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(ft,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("ul",{children:u.map((v,k)=>s.jsxs("li",{ref:E=>{w.current[k]=E},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${k===f?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{c&&a(v,c.startIndex)},children:[v.type==="directory"?s.jsx(ss,{className:"w-4 h-4 shrink-0"}):s.jsx("span",{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"truncate",children:v.path})]},v.path))})})}):null}),gk=e=>Symbol.iterator in e,xk=e=>"entries"in e,yk=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[a,o]of n)if(!r.has(a)||!Object.is(o,r.get(a)))return!1;return!0},EU=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let a=n.next(),o=r.next();for(;!a.done&&!o.done;){if(!Object.is(a.value,o.value))return!1;a=n.next(),o=r.next()}return!!a.done&&!!o.done};function NU(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:gk(e)&&gk(t)?xk(e)&&xk(t)?yk(e,t):EU(e,t):yk({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function $T(e){const t=ps.useRef(void 0);return n=>{const r=e(n);return NU(t.current,r)?t.current:t.current=r}}const Ba=e=>e?`?workdir=${encodeURIComponent(e)}`:"",Rx=e=>e?`&scope=${e}`:"",lo=e=>[...e.defaults,...e.userItems,...e.projectItems],pm=()=>Ut($T(lo)),Ut=Jn((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${Ba(n??t().workdir)}`)).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],activeWorkflowId:a.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async(n,r,a)=>{try{const o=await xe(`/api/workflows/${n}${Ba(r??t().workdir)}${Rx(a)}`);return o.ok?await o.json():null}catch{return null}},fetchDefaultContent:async(n,r)=>{try{const a=await xe(`/api/workflows/defaults/${n}${Ba(r??t().workdir)}`);return a.ok?await a.json():null}catch{return null}},createWorkflow:async(n,r,a)=>{const o=a??t().workdir,c=await da("POST",`/api/workflows${Ba(o)}`,{...n,destination:r});return c.success&&await t().fetchWorkflows(o),c},updateWorkflow:async(n,r,a,o)=>{const c=a??t().workdir,u=await da("PUT",`/api/workflows/${n}${Ba(c)}${Rx(o)}`,r);return u.success&&await t().fetchWorkflows(c),u},deleteWorkflow:async(n,r,a)=>{try{const o=await xe(`/api/workflows/${n}${Ba(a??t().workdir)}${Rx(r)}`,{method:"DELETE"}),c=await o.json();return o.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 o=a??t().workdir;return Pf(`/api/workflows/${n}/duplicate${Ba(o)}`,()=>t().fetchWorkflows(o),r)}}));async function TU(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 nl=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,dn=Jn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async n=>{await TU(nl("/api/commands",n),e,!0)},fetchCommand:async(n,r)=>{try{const a=await xe(nl(`/api/commands/${n}`,r));return a.ok?await a.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,a)=>{const o=await da("POST",nl("/api/commands",a),{...n,destination:r});return o.success&&await t().fetchCommands(a),o},updateCommand:async(n,r,a)=>{const o=await da("PUT",nl(`/api/commands/${n}`,a),r);return o.success&&await t().fetchCommands(a),o},deleteCommand:async(n,r)=>{try{const a=await xe(nl(`/api/commands/${n}`,r),{method:"DELETE"}),o=await a.json();return a.ok?(e(c=>({userItems:c.userItems.filter(u=>u.id!==n),projectItems:c.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r,a)=>Pf(nl(`/api/commands/${n}/duplicate`,a),()=>t().fetchCommands(a),r)}));function rr(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function Fy(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),a=new Array(e.length).fill(!1),o=n.indexOf(r);if(o>=0)for(let m=o;m<o+r.length;m++)a[m]=!0;else{let m=0;for(let f=0;f<e.length&&m<r.length;f++)n[f]===r[m]&&(a[f]=!0,m++)}const c=Array.from(e),u=[];let d="",h=a[0]??!1;for(let m=0;m<c.length;m++){const f=c[m]??"";a[m]===h?d+=f:(u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},u.length):d),d=f,h=a[m]??!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 aa(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const o of r){let c=0;for(let u=0;u<o.length&&c<a.length;u++)o[u]===a[c]&&c++;if(c===a.length)return!0}return!1})}function FT(e,t,n,r,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(o=>Math.min(o+1,t));break;case"ArrowUp":e.preventDefault(),n(o=>Math.max(o-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),a();break}}function gf(e,t,n,r){const a=e.slice(0,n),o=e.slice(t);return{newText:`${a}${r}${o}`,newCursorPos:n+r.length}}function xf(e,t){e&&(e.selectionStart=t,e.selectionEnd=t,e.focus())}function zT(e){if(e.type==="workflow"){const r=lo(Ut.getState()).find(a=>a.id===e.id&&a.scope===e.scope);return((r==null?void 0:r.parameters)??[]).map(a=>a.id)}const t=dn.getState(),n=rr(rr(t.defaults,t.userItems),t.projectItems).find(r=>r.id===e.id);return(n==null?void 0:n.paramNames)??[]}const AU={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function LU(e,t={}){const n={...AU,...t};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=n.maxSizeBytes){const a=await e.arrayBuffer(),o=BU(a),c=`data:${e.type};base64,${o}`,u=await HT(c);return{dataUrl:c,mimeType:e.type,size:e.size,width:u.width,height:u.height}}return await RU(e,n)}async function RU(e,t){const n=await OU(e),r=await HT(n),{width:a,height:o}=DU(r.width,r.height,t.maxWidth,t.maxHeight),c=IU();c.width=a,c.height=o;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,o);let d=t.quality,h="";for(let f=0;f<10&&(h=c.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(bk(h)<=t.maxSizeBytes||d<=.3));f++)d-=.1;const m=bk(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:m,width:a,height:o}}function DU(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 OU(e){return new Promise((t,n)=>{const r=PU(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function HT(e){return new Promise((t,n)=>{const r=MU(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function IU(){var t;const e=pv();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function MU(){const e=pv();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function PU(){const e=pv();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function pv(){return globalThis}function BU(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 bk(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const vk=50*1024*1024,_k=1024*1024,$U=["image/png","image/jpeg","image/gif"];function FU(e){return e==="application/pdf"}function zU(e){return $U.includes(e.type)}async function HU(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 zy(e,t,n){try{if(dv(e.type)){if(e.size>_k){n(`Text file too large (${gl(e.size)}). Maximum is ${gl(_k)}.`);return}const r=await e.text(),a={id:Dh(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(zh(e.type)||FU(e.type)){if(e.size>vk){const r=zh(e.type)?"Image":"PDF";n(`${r} file too large (${gl(e.size)}). Maximum is ${gl(vk)}.`);return}if(zh(e.type)&&zU(e)){const r=await LU(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:Dh(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await HU(e),a={id:Dh(),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 UU="openfox:task-draft";function VU({projectId:e,initialTask:t,onClose:n,onSaved:r}){var Xe;const a=!!t,o=Bt(_e=>_e.createTask),c=Bt(_e=>_e.updateTask),u=Bt(_e=>_e.lastError),{agents:d,fetchAgents:h}=RT(),m=d.filter(_e=>!_e.subagent),f=nn(_e=>_e.providers),x=(Xe=zt(_e=>_e.projects).find(_e=>_e.id===e))==null?void 0:Xe.workdir;j.useEffect(()=>{h()},[h]);const w=`${UU}:${e}:${(t==null?void 0:t.id)??"new"}`,[C,b]=j.useState(()=>(t==null?void 0:t.prompt)??""),[_,S]=j.useState(()=>(t==null?void 0:t.attachments)??[]),[v,k]=j.useState(()=>(t==null?void 0:t.agentId)??void 0),[E,N]=j.useState(()=>t==null?void 0:t.providerId),[L,A]=j.useState(()=>t==null?void 0:t.model),[O,I]=j.useState(null),[F,B]=j.useState(!1),[z,Y]=j.useState([]),q=j.useRef(null),W=j.useRef(null),ee=j.useRef(null),J=j.useRef(null),H=j.useRef(0),P=j.useRef([]),[D,U]=j.useState(!1);j.useEffect(()=>{if(x)return;let _e=!1;return xe(`/api/projects/${e}`).then(ye=>ye.ok?ye.json():null).then(ye=>{var fe;!_e&&((fe=ye==null?void 0:ye.project)!=null&&fe.workdir)&&zt.setState({currentProject:ye.project})}).catch(()=>{}),()=>{_e=!0}},[e,x]),j.useEffect(()=>{try{const _e=localStorage.getItem(w);if(_e){const ye=JSON.parse(_e);ye.prompt&&b(ye.prompt)}}catch{}},[]),j.useEffect(()=>{const _e=setTimeout(()=>{try{localStorage.setItem(w,JSON.stringify({prompt:C}))}catch{}},300);return()=>clearTimeout(_e)},[C,w]);const $=j.useCallback(_e=>{for(const ye of Array.from(_e))zy(ye,fe=>S(oe=>[...oe,fe]),fe=>I(fe))},[]),Q=_e=>{_e.clipboardData.files.length>0&&$(_e.clipboardData.files)},K=_e=>{_e.preventDefault()},Z=_e=>{_e.preventDefault(),_e.dataTransfer.files.length>0&&$(_e.dataTransfer.files)},V=_e=>{P.current.push(_e),P.current.length>50&&P.current.shift(),U(!0)},M=_e=>{_e!==C&&(V(C),b(_e))},X=()=>{var ye;const _e=P.current.pop();_e!==void 0&&(b(_e),U(P.current.length>0),(ye=q.current)==null||ye.focus())},ne=j.useCallback((_e,ye)=>{const{newText:fe,newCursorPos:oe}=gf(C,H.current,ye,`/${_e.id} `);V(C),b(fe),H.current=oe,xf(q.current,oe),Y(zT(_e))},[C]),re=j.useCallback((_e,ye)=>{const oe=_e.type==="directory"?"/":" ",{newText:Me,newCursorPos:He}=gf(C,H.current,ye,`@${_e.path}${oe}`);V(C),b(Me),H.current=He,xf(q.current,He)},[C]),ie=async()=>{const _e=C.trim().length>0,ye=_.length>0;if(!_e&&!ye){I("Add a prompt or an attachment");return}B(!0),I(null);const fe={prompt:C,..._.length>0?{attachments:_}:{},...a?{agentId:v??null}:v?{agentId:v}:{},...a&&(t!=null&&t.providerId)&&!E?{providerId:null}:E?{providerId:E}:{},...a&&(t!=null&&t.model)&&!L?{model:null}:L?{model:L}:{}},oe=a?await c(e,t.id,fe):await o(e,fe);if(B(!1),oe){try{localStorage.removeItem(w)}catch{}r(oe)}else I(u??"Could not save the task")},ge=_e=>{var ye,fe;if(!((ye=J.current)!=null&&ye.handleKeyDown(_e))&&!((fe=ee.current)!=null&&fe.handleKeyDown(_e))){if(_e.key==="z"&&(_e.metaKey||_e.ctrlKey)){_e.preventDefault(),X();return}_e.key==="Enter"&&!_e.shiftKey&&!_e.nativeEvent.isComposing&&(_e.preventDefault(),ie())}},ke=lo(Ut.getState()),Oe=(()=>{const _e=dn.getState();return rr(rr(_e.defaults,_e.userItems),_e.projectItems)})(),Fe=(()=>{if(z.length===0)return 0;const _e=C.match(/\/(\w+)\s+(.*)$/),fe=(_e?_e[2].trim().split(/\s+/):[]).filter(Boolean).length;return z[fe]?z.length-fe:0})(),we=E&&L?`${E}/${L}`:void 0,We=a&&t.status==="in_progress"&&t.runState==="running";return s.jsxs(jt,{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:We?"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(st,{onClick:n,children:"Cancel"}),s.jsx(st,{variant:"primary",onClick:()=>void ie(),disabled:F,children:F?"Saving…":a?"Save changes":"Create task"})]})]}),children:[We&&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:K,onDrop:Z,children:[s.jsx("textarea",{ref:q,value:C,onChange:_e=>M(_e.target.value),onSelect:_e=>{H.current=_e.currentTarget.selectionStart},onPaste:Q,onKeyDown:ge,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(BT,{ref:ee,text:C,cursorPos:H.current,workdir:x,onSelect:re}),s.jsx(PT,{ref:J,text:C,cursorPos:H.current,workflows:ke,commands:Oe,onSelect:ne}),z.length>0&&Fe>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:[Fe," required param",Fe>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:X,disabled:!D,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 _e;return(_e=W.current)==null?void 0:_e.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(gE,{})})]}),s.jsx("input",{ref:W,type:"file",multiple:!0,className:"hidden",onChange:_e=>{_e.target.files&&$(_e.target.files),_e.target.value=""}})]})]}),_.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(_e=>s.jsx(hv,{attachment:_e,onRemove:ye=>S(fe=>fe.filter(oe=>oe.id!==ye))},_e.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:v??"",onChange:_e=>k(_e.target.value||void 0),className:"w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"",children:"Default agent"}),m.map(_e=>s.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Model"}),s.jsx(fv,{providers:f,value:we,onChange:_e=>{if(_e){const ye=_e.indexOf("/");N(_e.slice(0,ye)),A(_e.slice(ye+1))}else N(void 0),A(void 0)}})]})]}),O&&s.jsx("div",{className:"text-sm text-accent-error",children:O})]})]})}const WU=()=>`gate_${crypto.randomUUID().slice(0,8)}`;function GU({projectId:e,onClose:t}){const n=Bt(x=>x.gates),r=Bt(x=>x.loadGates),a=Bt(x=>x.setGateConfig),[o,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((b,_)=>_===x?{...b,...w}:b))},m=()=>{c(x=>[...x,{id:WU(),name:"",description:"",required:!0,variant:"done"}])},f=x=>{c(w=>w.filter((C,b)=>b!==x))},g=async()=>{const x=o.filter(w=>w.name.trim().length>0).map((w,C)=>({...w,id:w.id||`gate_${C}`,name:w.name.trim()}));d(!0),await a(e,x),d(!1),t()};return s.jsx(jt,{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(st,{onClick:t,children:"Cancel"}),s.jsx(st,{variant:"primary",onClick:()=>void g(),disabled:u,children:u?"Saving…":"Save gates"})]})]}),children:s.jsxs("div",{className:"space-y-3",children:[o.length===0&&s.jsx("p",{className:"text-sm text-text-muted",children:"No gates configured — any task can move straight to Done. Add a gate like “all green” (every criterion passes with evidence) or “commit” (work committed with a commit reference)."}),o.map((x,w)=>s.jsxs("div",{className:"border border-border rounded-lg p-3 space-y-2 bg-bg-tertiary/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ms,{type:"text",value:x.name,onChange:C=>h(w,{name:C.target.value}),placeholder:"Gate name, e.g. “all green” or “commit”",className:"flex-1 text-sm"}),s.jsx("button",{type:"button",onClick:()=>f(w),className:"p-1.5 rounded hover:bg-accent-error/10 text-text-muted hover:text-accent-error transition-colors",title:"Remove gate",children:s.jsx(Si,{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(st,{onClick:m,children:[s.jsx(as,{className:"w-3.5 h-3.5 mr-1 inline-block"})," Add gate"]})]})})}function gv({isOpen:e,onClose:t,projectId:n}){const[,r]=wn(),a=Bt(V=>V.tasks),o=Bt(V=>V.settings),c=Bt(V=>V.loadBoard),u=Bt(V=>V.loadGates),d=Bt(V=>V.moveTask),h=Bt(V=>V.reorderTask),m=Bt(V=>V.deleteTask),f=Bt(V=>V.duplicateTask),g=Bt(V=>V.setSettings),x=Bt(V=>V.lastError),{agents:w,fetchAgents:C}=RT(),[b,_]=j.useState(null),[S,v]=j.useState(!1),[k,E]=j.useState(""),[N,L]=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 V=k.toLowerCase();return a.filter(M=>M.prompt.toLowerCase().includes(V))},[a,k]),I=j.useMemo(()=>{const V=O.filter(ne=>ne.status==="todo").sort((ne,re)=>ne.position-re.position),M=O.filter(ne=>ne.status==="in_progress").sort((ne,re)=>ne.runState==="running"!=(re.runState==="running")?ne.runState==="running"?-1:1:ne.position-re.position),X=O.filter(ne=>ne.status==="done").sort((ne,re)=>ne.position-re.position);return{todo:V,in_progress:M,done:X}},[O]),F=j.useMemo(()=>{const V=a.filter(X=>X.status==="in_progress"&&X.runState==="queued").sort((X,ne)=>X.position-ne.position),M=new Map;return V.forEach((X,ne)=>M.set(X.id,ne+1)),M},[a]),B=j.useMemo(()=>a.filter(V=>V.status==="in_progress"&&V.runState==="running").length,[a]),z=j.useMemo(()=>a.filter(V=>V.status==="in_progress"&&V.runState==="queued").length,[a]),Y=j.useCallback(V=>{if(V.runState==="queued")return V.queuePosition!==void 0?V.queuePosition:F.get(V.id)},[F]),q=j.useCallback(async(V,M)=>{const X=await d(n,V.id,M);X!=null&&X.sessionId&&r(`/p/${n}/s/${X.sessionId}`)},[d,n,r]),W=j.useCallback(async V=>{const M=A.current;A.current=null,M&&M.task.status!==V&&await q(M.task,V)},[q]),ee=j.useCallback(async V=>{const M=A.current;if(A.current=null,!M||M.task.id===V.task.id)return;const X=I[V.task.status].findIndex(ne=>ne.id===V.task.id);X<0||(M.task.status===V.task.status?await h(n,M.task.id,V.task.status,X):(await q(M.task,V.task.status),await h(n,M.task.id,V.task.status,X)))},[I,h,n,q]),J=j.useCallback(V=>{const M=I[V.status].findIndex(X=>X.id===V.id);M>0&&h(n,V.id,V.status,M-1)},[I,h,n]),H=j.useCallback(V=>{const M=I[V.status].findIndex(X=>X.id===V.id);M>=0&&M<I[V.status].length-1&&h(n,V.id,V.status,M+1)},[I,h,n]),P=j.useCallback(V=>{f(n,V.id)},[f,n]),D=j.useCallback(async()=>{N&&(await m(n,N.id),L(null))},[N,m,n]),U=V=>{const M=Bt.getState().settings.slotLimit,X=Math.max(1,Math.min(10,M+V));X!==M&&g(n,{slotLimit:X})},$=()=>{const V=Bt.getState().settings.queuePaused;g(n,{queuePaused:!V})},Q={projectId:n,agents:w,queuePositionOf:Y,onEdit:V=>_({mode:"edit",task:V}),onMove:(V,M)=>void q(V,M),onMoveUp:J,onMoveDown:H,onDuplicate:P,onDelete:V=>L(V),onDragStart:V=>{A.current={task:V}},onOpenSession:()=>t()},K=V=>{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"}}[V];return s.jsx(pU,{title:M.title,accentClass:M.accentClass,hint:"hint"in M?M.hint:void 0,tasks:I[V],headerAction:V==="todo"?s.jsxs(st,{variant:"primary",onClick:()=>_({mode:"create"}),children:[s.jsx(as,{className:"w-4 h-4 mr-1 inline-block"})," New Task"]}):V==="done"?s.jsx(st,{onClick:()=>v(!0),children:"Gates"}):void 0,footer:V==="in_progress"?Z:void 0,onDropOnColumn:()=>void W(V),onDropOnCard:X=>void ee({task:X}),...Q},V)},Z=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:()=>U(-1),disabled:o.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:o.slotLimit}),s.jsx("button",{type:"button",onClick:()=>U(1),disabled:o.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:B})," / ",o.slotLimit," running"]}),z>0&&s.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"}),s.jsx("strong",{className:"text-text-primary tabular-nums",children:z})," queued"]})]}),s.jsxs(st,{size:"sm",onClick:$,className:`shrink-0 flex items-center gap-1 whitespace-nowrap border ${o.queuePaused?"border-amber-400/40 text-amber-400 hover:bg-amber-400/10":"border-border text-text-muted hover:bg-bg-tertiary"}`,title:o.queuePaused?"Resume auto-launch of queued tasks":"Pause auto-launch of queued tasks",children:[o.queuePaused?s.jsx(Hf,{className:"w-3 h-3"}):s.jsx(vE,{className:"w-3 h-3"}),o.queuePaused?"Resume":"Pause"]})]})})]});return s.jsxs(s.Fragment,{children:[s.jsxs(jt,{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(_i,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-text-muted"}),s.jsx(Ms,{type:"text",value:k,onChange:V=>E(V.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:()=>Bt.setState({lastError:null}),className:"text-sm underline",children:"Dismiss"})]}),s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2 h-full",children:[K("todo"),K("in_progress"),K("done")]})]}),b&&s.jsx(VU,{projectId:n,initialTask:b.mode==="edit"?b.task:null,onClose:()=>_(null),onSaved:()=>_(null)}),S&&s.jsx(GU,{projectId:n,onClose:()=>v(!1)}),N&&s.jsx(El,{isOpen:!0,onClose:()=>L(null),onConfirm:()=>void D(),title:"Delete task?",message:`“${N.prompt.slice(0,60)}” will be removed from the board. Its sessions and history stay untouched.`,confirmLabel:"Delete task",confirmVariant:"danger"})]})}function qU({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=j.useState(!1),[a,o]=j.useState(!1),[c,u]=j.useState(!!document.fullscreenElement),[d,h]=wn(),[m,f]=j.useState(!1),g=Bt(W=>W.counts.running),x=Bt(W=>W.loadCounts),w=Bt(W=>W.activeProjectId),C=Bt(W=>W.lastAutoLaunch),b=Bt(W=>W.clearAutoLaunch);j.useEffect(()=>{const W=()=>u(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const _=d.startsWith("/p/"),S=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),v=cE(),k=De(W=>W.openSessionIds.length),E=De(W=>W.currentSession),N=De(W=>W.sessions),L=zt(W=>W.currentProject),A=zt(W=>W.projects),O=nn(W=>W.startAutoRefresh),I=nn(W=>W.stopAutoRefresh),F=fs(W=>W.setOpen),B=fs(W=>W.isOpen),z=bi(W=>W.status==="available"),Y=bi(W=>W.check);j.useEffect(()=>{bi.getState().status==="idle"&&Y()},[Y]),j.useEffect(()=>{const W=()=>o(!0);return window.addEventListener("open-session-dropdown",W),()=>window.removeEventListener("open-session-dropdown",W)},[]);const q=Eu();return pu(q.terminalToggle,()=>{fs.getState().toggleOpen()},{capture:!0}),j.useEffect(()=>{L!=null&&L.id&&w!==L.id&&x(L.id)},[L==null?void 0:L.id,w,x]),j.useEffect(()=>(O(),()=>I()),[O,I]),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&&S||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?"Toggle split view control panel":"Toggle session list","aria-label":v?"Toggle split view control panel":"Toggle session list",children:s.jsx(sy,{})}):null,s.jsx(ir,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),!v&&L&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(mk,{projects:A,currentProject:L})}),s.jsx("span",{className:"md:hidden",children:s.jsx(fU,{currentProject:L,sessions:N,currentSession:E,projectIdFromUrl:_&&d.split("/")[2]||null},L==null?void 0:L.id)}),s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(dU,{sessions:N,currentProject:L,currentSession:E,isOpen:a,onOpenChange:o})})]}),!v&&!L&&s.jsx("span",{className:"hidden md:inline",children:s.jsx(mk,{projects:A})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!v&&s.jsx("button",{onClick:()=>{const W=E==null?void 0:E.id;S&&W&&De.getState().openPane(W,{focus:!0}),h("/split-view")},className:"p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Open split view","aria-label":"Open split view",children:s.jsx(fu,{className:"w-4 h-4"})}),v&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1 text-xs text-text-muted px-1.5",title:"Split view active","data-testid":"split-indicator",children:[s.jsx(fu,{className:"w-3.5 h-3.5"}),k]}),s.jsx("button",{onClick:()=>{De.getState().exitSplitView(),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Exit split view","aria-label":"Exit split view",children:s.jsx(Ss,{className:"w-4 h-4"})})]}),S&&s.jsx("button",{onClick:()=>{var W,ee,J;document.fullscreenElement?(W=document.exitFullscreen)==null||W.call(document):(J=(ee=document.documentElement).requestFullscreen)==null||J.call(ee)},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(U3,{}):s.jsx(V3,{})}),_&&s.jsxs("button",{onClick:()=>f(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Project tasks","aria-label":"Open project tasks",children:[s.jsx(vb,{className:"w-4 h-4"}),g>0&&s.jsx("span",{className:"absolute top-0.5 right-0.5 min-w-3.5 h-3.5 px-0.5 rounded-full bg-accent-success text-white text-[9px] font-semibold flex items-center justify-center",children:g>99?"99+":g})]}),_&&s.jsx("button",{onClick:()=>F(!B),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${B?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:s.jsx(X3,{})}),_&&L&&s.jsx("button",{onClick:()=>xe(`/api/projects/${L.id}/open-folder`).catch(()=>{}),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Open project folder",children:s.jsx(ss,{className:"w-4 h-4"})}),s.jsxs("button",{onClick:()=>r(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:z?"Settings — update available":"Settings",children:[s.jsx(bE,{}),z&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),s.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:s.jsx(G3,{})}),t&&S&&s.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:q.criteriaSidebar?`Toggle criteria sidebar (${Sb(q.criteriaSidebar)})`:"Toggle criteria sidebar",children:s.jsx(sy,{})})]}),s.jsx(Z7,{isOpen:n,onClose:()=>r(!1)}),s.jsx(oU,{isOpen:B,onClose:()=>F(!1)}),L&&s.jsx(gv,{isOpen:m,onClose:()=>f(!1),projectId:L.id}),C&&s.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg bg-bg-secondary border border-border shadow-xl text-sm text-text-primary",children:[s.jsxs("span",{children:["“",C.taskTitle,"” auto-launched — a slot freed up."]}),s.jsxs("button",{type:"button",onClick:()=>{const W=C.sessionId,ee=C.projectId;b(),h(`/p/${ee}/s/${W}`)},className:"flex items-center gap-1 px-2.5 py-1 rounded bg-accent-primary/25 hover:bg-accent-primary/40 font-medium transition-colors",children:["Open session ",s.jsx(Ff,{className:"w-3 h-3"})]}),s.jsx("button",{type:"button",onClick:b,className:"text-xs text-text-muted underline",children:"Dismiss"})]})]})}function UT({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:o=n?"Saving...":"Save"}){return s.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[s.jsx(st,{variant:"secondary",onClick:e,children:a}),s.jsx(st,{variant:"primary",onClick:t,disabled:r??n,children:o})]})}const xh=Jn()(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})}})),KU=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],YU=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"],VT=/^[a-zA-Z]:$/;function XU(e,t=KU,n=YU){if(!e)return null;const r=e.replace(/[\\/]+$/,"")||"/";if(VT.test(r)||t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function WT(e){const t=e.replace(/[\\/]+$/,"");return t?VT.test(t)?`${t}\\`:t:"/"}function QU(e,t){const n=WT(e);return/[\\/]$/.test(n)?`${n}${t}`:`${n}/${t}`}function JU({isOpen:e,onClose:t,project:n}){const r=zt(ce=>ce.updateProject),a=xh(ce=>ce.config),o=xh(ce=>ce.loading),c=xh(ce=>ce.fetchConfig),u=xh(ce=>ce.saveConfig),d=ct(ce=>ce.defaults),h=ct(ce=>ce.userItems),m=ct(ce=>ce.fetchAgents),f=[...d,...h].filter(ce=>!ce.subagent),g=()=>{try{Ht.send("context.checkDynamic",{})}catch{}t()},[x,w]=j.useState(n.customInstructions??""),[C,b]=j.useState(n.dangerLevel??""),[_,S]=j.useState(n.defaultAgent??""),[v,k]=j.useState(!1),[E,N]=j.useState(!1),[L,A]=j.useState(!1),[O,I]=j.useState(!1),[F,B]=j.useState(null),z=_!==""&&!f.some(ce=>ce.id===_),[Y,q]=j.useState(""),[W,ee]=j.useState(!1),[J,H]=j.useState(""),[P,D]=j.useState(!1),[U,$]=j.useState(""),[Q,K]=j.useState(!1),[Z,V]=j.useState(!1),[M,X]=j.useState([]),[ne,re]=j.useState(""),[ie,ge]=j.useState({}),[ke,Oe]=j.useState(!1),[Fe,we]=j.useState(new Set),We=v||E||L||W||P||ke;j.useEffect(()=>{e&&(w(n.customInstructions??""),b(n.dangerLevel??""),S(n.defaultAgent??""),k(!1),N(!1),A(!1),ee(!1),D(!1),Oe(!1),we(new Set),c(n.workdir),m().catch(()=>{}))},[e,n,c,m]),j.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?q(a.setup.join(" && ")):q(""),H((a==null?void 0:a.rootDir)??""),ge((a==null?void 0:a.mcpOverrides)??{})},[a]);const Xe=du(ce=>ce.servers),_e=ce=>ie[ce]??{},ye=ce=>{var Ve;const ae=_e(ce);if(ae.disabled!==void 0)return ae.disabled;const Re=Xe.find(dt=>dt.name===ce);return!!((Ve=Re==null?void 0:Re.config)!=null&&Ve.disabled)},fe=(ce,ae)=>{var Ve;return((Ve=_e(ce).disabledTools)==null?void 0:Ve.includes(ae))??!1},oe=ce=>{ge(ae=>({...ae,[ce]:{...ae[ce],disabled:!ye(ce)}})),Oe(!0)},Me=(ce,ae)=>{ge(Re=>{const Ve=Re[ce]??{},dt=Ve.disabledTools??[],vt=dt.includes(ae)?dt.filter(wt=>wt!==ae):[...dt,ae];return{...Re,[ce]:{...Ve,disabledTools:vt.length>0?vt:void 0}}}),Oe(!0)},He=ce=>{we(ae=>{if(ae.has(ce)){const Ve=new Set(ae);return Ve.delete(ce),Ve}const Re=new Set(ae);return Re.add(ce),Re})},he=ce=>{w(ce.target.value),k(!0)},Te=ce=>{b(ce),N(!0)},Qe=ce=>{q(ce.target.value),ee(!0)},me=ce=>{H(ce.target.value),D(!0)},ze=j.useCallback(async()=>{const ae={customInstructions:x||null,dangerLevel:C===""?null:C};if(L&&(ae.defaultAgent=_===""?null:_),await r(n.id,ae),W||P||ke){const Re=Y.trim()?Y.split("&&").map(dt=>dt.trim()).filter(Boolean):[],Ve={};W&&(Ve.setup=Re),P&&(Ve.rootDir=J.trim()),Object.keys(ie).length>0&&(Ve.mcpOverrides=ie),await u(n.workdir,Ve)}k(!1),N(!1),A(!1),ee(!1),D(!1),Oe(!1),g()},[n.id,C,x,_,L,Y,J,ie,W,P,ke,r,u,n.workdir,g]),at=async()=>{const ce=J.trim(),ae=(a==null?void 0:a.rootDir)??"";if(ce){const Re=XU(ce);if(Re==="exact"){const Ve=WT(ce);B(`Cannot use "${Ve}" directly as workspace root. Use a subdirectory like "${QU(ce,n.name)}" instead.`);return}if(Re==="virtual_fs"){B(`Cannot use paths under "${ce}" for workspaces.`);return}}if(!P||!ce||ce===ae){I(!0),B(null);try{await ze()}catch(Re){B(Re instanceof Error?Re.message:"Failed to save settings")}finally{I(!1)}return}$(ce),I(!0),B(null);try{const Re=await xe(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:ce,workdir:n.workdir,projectName:n.name})});if(!Re.ok){const dt=await Re.json().catch(()=>({}));B((dt==null?void 0:dt.error)??"Failed to validate workspace root directory");return}const Ve=await Re.json();if(!Ve.exists){re(Ve.resolvedPath),K(!0);return}if(Ve.workspaces&&Ve.workspaces.length>0){X(Ve.workspaces),V(!0);return}B(null),await ze()}catch(Re){B(Re instanceof Error?Re.message:"Failed to validate settings")}finally{I(!1)}},Ze=async()=>{K(!1),I(!0);try{const ce=await xe(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:U,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!ce.ok){const Re=await ce.json().catch(()=>({}));B((Re==null?void 0:Re.error)??"Failed to create directory"),I(!1);return}const ae=await ce.json();if(ae.workspaces&&ae.workspaces.length>0){X(ae.workspaces),V(!0),I(!1);return}await ze()}catch(ce){B(ce instanceof Error?ce.message:"Failed to create directory")}finally{I(!1)}},et=async()=>{V(!1),I(!0),B(null);try{await ze()}catch(ce){B(ce instanceof Error?ce.message:"Failed to save settings")}finally{I(!1)}},ot=()=>{K(!1),V(!1),w(n.customInstructions??""),b(n.dangerLevel??""),S(n.defaultAgent??""),k(!1),N(!1),A(!1),ee(!1),D(!1),g()};return s.jsxs(jt,{isOpen:e,onClose:ot,title:`${n.name} Settings`,size:"lg",footer:s.jsx(UT,{onCancel:ot,onSave:at,saving:O,saveDisabled:!We||O}),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:()=>Te(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${C===""?"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:()=>Te("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${C==="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:()=>Te("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${C==="dangerous"?"bg-red-500/20 text-red-400 border border-red-500/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-default-agent",className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Agent"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Default agent for new sessions in this project. Choose "Use system default" to follow the global default agent. Existing sessions are not affected.'}),s.jsxs("select",{id:"project-default-agent",value:_,onChange:ce=>{S(ce.target.value),A(!0)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",disabled:O,children:[s.jsx("option",{value:"",children:"Use system default"}),z&&s.jsxs("option",{value:_,children:[_," (missing agent)"]}),f.map(ce=>s.jsx("option",{value:ce.id,children:ce.name},ce.id))]}),z&&s.jsxs("p",{className:"text-xs text-red-400 mt-1",children:['The stored default agent "',_,'" no longer exists. Pick another agent to restore a valid default.']}),f.length===0&&s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),s.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files."}),s.jsx("textarea",{value:x,onChange:he,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:O})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),o&&s.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),s.jsx("input",{type:"text",value:Y,onChange:Qe,placeholder:"npm install --prefer-offline",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:o||O})]}),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:J,onChange:me,placeholder:"/absolute/or/relative/path",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:o||O})]}),Xe.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:Xe.map(ce=>{const ae=ye(ce.name);return s.jsx(_T,{server:ce,expanded:Fe.has(ce.name),onToggleExpand:He,serverToggleEnabled:!ae,onServerToggle:()=>oe(ce.name),tools:ce.tools.map(Re=>({...Re,enabled:!fe(ce.name,Re.name)})),onToolToggle:Re=>Me(ce.name,Re),statusDot:uv(ae?"disabled":ce.status),statusColor:cv(ae?"disabled":ce.status)},ce.name)})})]}),F&&s.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:F})]}),Q&&s.jsxs(jt,{isOpen:Q,onClose:()=>K(!1),title:"Directory not found",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>K(!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:Ze,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:ne})," does not exist."]}),s.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),Z&&s.jsxs(jt,{isOpen:Z,onClose:()=>V(!1),title:"Orphaned workspaces",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>V(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:et,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:[M.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),s.jsx("ul",{className:"mt-2 space-y-1",children:M.map(ce=>s.jsx("li",{className:"text-sm font-mono text-text-muted",children:ce.name},ce.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 GT({initialWidth:e,minWidth:t,maxWidth:n,direction:r}){const[a,o]=j.useState(e),[c,u]=j.useState(!1),d=j.useRef({startX:0,startWidth:e}),h=j.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d.current={startX:m.clientX,startWidth:a},u(!0)},[a]);return j.useEffect(()=>{if(!c)return;const m=w=>{const{startX:C,startWidth:b}=d.current,_=w.clientX-C,S=r==="left"?b+_:b-_;o(Math.max(t,Math.min(n,S)))},f=()=>{u(!1)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",f);const g=document.body.style.userSelect,x=document.body.style.cursor;return document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",f),document.body.style.userSelect=g,document.body.style.cursor=x}},[c,r,t,n]),{width:a,isResizing:c,handleMouseDown:h}}function qT({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 KT({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=wn(),[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(null),[m,f]=j.useState(""),[g,x]=j.useState(!1),w=De(ye=>ye.sessions),C=De(ye=>ye.currentSession),b=De(ye=>ye.unreadSessionIds),_=De(ye=>ye.deleteSession),S=De(ye=>ye.deleteAllSessions),v=De(ye=>ye.loadMoreSessions),k=De(ye=>ye.sessionsHasMore),E=De(ye=>ye.sessionsPaginationLoading),N=De(ye=>ye.sessionsWithPendingConfirmations),L=De(ye=>ye.pendingPathConfirmations),A=De(ye=>ye.toggleFavorite),O=zt(ye=>ye.currentProject),[I,F]=j.useState(""),[B,z]=j.useState(-1),Y=j.useRef(null),q=j.useRef(null),{width:W,handleMouseDown:ee}=GT({initialWidth:300,minWidth:200,maxWidth:600,direction:"left"}),J=j.useRef(!1),H=Eu();pu(H.sessionSearch,()=>{var ye;if(t&&document.activeElement===Y.current){n==null||n();return}t||(J.current=!0,n==null||n()),Vt()&&((ye=Y.current)==null||ye.focus())});const P=j.useRef(null),D=j.useCallback(()=>{k&&!E&&O&&v(O.id)},[k,E,O,v]);j.useEffect(()=>{if(!P.current||!k)return;const ye=new IntersectionObserver(fe=>{const oe=fe[0];oe&&oe.isIntersecting&&D()},{threshold:.1});return ye.observe(P.current),()=>ye.disconnect()},[k,D]);const U=w.filter(ye=>ye.projectId===(O==null?void 0:O.id)),[$,Q]=j.useMemo(()=>{const ye=[],fe=[];for(const oe of U)oe.isFavorite?ye.push(oe):fe.push(oe);return[ye,fe]},[U]),K=ye=>I?ye.filter(fe=>{var He;const oe=fe.title??"",Me=(((He=fe.recentUserPrompts)==null?void 0:He.map(he=>he.content))??[]).join(" ");return aa(oe,I)||aa(Me,I)}):ye,Z=j.useMemo(()=>K($),[$,I]),V=j.useMemo(()=>K(Q),[Q,I]),M=[...Z,...V],X=I.length>0,ne=X&&M.length===0;j.useEffect(()=>{z(M.length>0?0:-1)},[M.length]),j.useEffect(()=>{var fe;if(B<0)return;const ye=(fe=q.current)==null?void 0:fe.querySelector(`[data-sidx="${B}"]`);ye==null||ye.scrollIntoView({block:"nearest"})},[B]);const re=(ye,fe)=>{fe==null||fe.stopPropagation(),u(ye)},ie=()=>{c&&(_(c),(C==null?void 0:C.id)===c&&r(`/p/${e}`),u(null))},ge=(ye,fe)=>{fe==null||fe.stopPropagation();const oe=w.find(He=>He.id===ye),Me=(oe==null?void 0:oe.title)??ye.slice(0,6);f(Me),h(ye)},ke=()=>{if(!d||m.trim()==="")return;const ye=De.getState().renameSession;ye(d,m.trim()),h(null),f("")},Oe=()=>{x(!0)},Fe=()=>{S(e),r(`/p/${e}`),x(!1)},we=(ye,fe)=>{A(ye,!fe)},We=ye=>{if(!J.current)return;ye.target.closest('a[href*="/s/"]')&&(J.current=!1,n==null||n())},Xe=()=>{var ye;F(""),Vt()&&((ye=Y.current)==null||ye.focus())},_e=ye=>{var fe;switch(ye.key){case"Escape":F(""),(fe=Y.current)==null||fe.blur();break;case"ArrowDown":ye.preventDefault(),z(oe=>oe<M.length-1?oe+1:oe);break;case"ArrowUp":ye.preventDefault(),z(oe=>oe>0?oe-1:0);break;case"Enter":{ye.preventDefault();const oe=M[B];oe&&(r(`/p/${e}/s/${oe.id}`),J.current&&(J.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 ye=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[s.jsx(ir,{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(zl,{items:[{label:"Edit project settings",onClick:()=>o(!0)},{label:"Delete all sessions",onClick:Oe,danger:!0}],trigger:s.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:s.jsx(gb,{})})}),n&&s.jsx(Mu,{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(_i,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{ref:Y,type:"text",value:I,onChange:fe=>F(fe.target.value),onKeyDown:_e,placeholder:"Search sessions...",className:"w-full bg-bg-tertiary border border-border rounded pl-8 pr-8 py-1.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),I&&s.jsx("button",{type:"button",onClick:Xe,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(Ss,{className:"w-3.5 h-3.5"})})]}),X&&!ne&&s.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[M.length," ",M.length===1?"match":"matches"]})]}),O&&s.jsx(JU,{isOpen:a,onClose:()=>o(!1),project:O}),s.jsx(El,{isOpen:c!==null,onClose:()=>u(null),onConfirm:ie,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),s.jsx(El,{isOpen:g,onClose:()=>x(!1),onConfirm:Fe,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),s.jsx(jt,{isOpen:d!==null,onClose:()=>{h(null),f("")},title:"Rename session",size:"sm",footer:s.jsx(UT,{onCancel:()=>{h(null),f("")},onSave:ke,saving:!1,saveDisabled:m.trim()==="",saveLabel:"Rename"}),children:s.jsx("input",{type:"text",value:m,onChange:fe=>f(fe.target.value),onKeyDown:fe=>{fe.key==="Enter"&&ke()},onFocus:fe=>fe.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:Vt()})}),s.jsx(ft,{className:"flex-1",children:M.length===0?s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:X?"No matching sessions":"No sessions"}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"divide-y divide-border",ref:q,onClick:We,children:ZU(Z,V,C,b,re,ge,we,e,N,L,I,B)}),E&&s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),s.jsx("div",{ref:P,className:"h-px"})]})})]});return s.jsxs("aside",{className:`
277
+ ${t?"md:w-[var(--sidebar-w)] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden md:border-r-0"}
278
+ md:relative md:h-auto md:translate-x-0
279
+
280
+ fixed z-50 h-[calc(100vh-32px)]
281
+ w-[300px] bg-secondary border-r border-border flex flex-col
282
+ transition-transform duration-300 ease-in-out
283
+ ${t?"translate-x-0":"-translate-x-full"}
284
+ `,style:{"--sidebar-w":`${W}px`},children:[ye,t&&s.jsx(qT,{side:"right",onMouseDown:ee,className:"hidden md:block"})]})})()]})}function ZU(e,t,n,r,a,o,c,u,d,h,m,f){let g=0;const x=C=>{const b=g++,_=(n==null?void 0:n.id)===C.id,S=b===f,v=r.includes(C.id),k=C.isRunning,E=C.isFavorite,N=d.includes(C.id)||_&&h.length>0;return s.jsx("div",{"data-sidx":b,className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${_?"bg-bg-tertiary":""} ${S?"bg-accent-primary/10":""}`,children:s.jsxs(ir,{href:`/p/${u}/s/${C.id}`,className:`block ${_?"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 ${_?"text-accent-primary":"text-text-primary"}`,children:m?Fy(C.title??C.id.slice(0,6),m):C.title??C.id.slice(0,6)}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(zl,{items:[{label:E?"Remove from favorites":"Add to favorites",icon:E?s.jsx(mu,{className:"w-3.5 h-3.5 text-amber-400"}):s.jsx(Vf,{className:"w-3.5 h-3.5"}),onClick:()=>c(C.id,E)},{label:"Rename session",onClick:L=>o(C.id,L)},{label:"Delete session",onClick:L=>a(C.id,L),danger:!0}],trigger:s.jsx("button",{onClick:L=>{L.preventDefault()},className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:s.jsx(gb,{})})})})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[N?s.jsx("span",{title:"Awaiting confirmation",children:s.jsx(bb,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):k?s.jsx(K3,{}):v&&!_?s.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,!E&&s.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:mm(C.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)},w=C=>{const b=LT(C);return Array.from(b).map(([_,S])=>{const v=S[0];return v?s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:NT(v.updatedAt)}),S.map(k=>x(k))]},_):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(mu,{className:"w-3 h-3 text-amber-400"}),"Favorites"]}),e.map(C=>x(C))]}),t.length>0&&w(t)]})}const Sk=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function e9(){var c;const e=zt(u=>u.currentProject),t=De(u=>u.currentSession),n=$f(),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)%Sk.length,o()},150),o()):(a.current&&(clearInterval(a.current),a.current=null),o()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t]);const o=()=>{var m;const d=(m=t==null?void 0:t.metadata)==null?void 0:m.title,h=n?`${Sk[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}const t9={idle:"Idle",plan:"Plan",build:"Build",verification:"Verify",blocked:"Blocked",done:"Done"};function n9(){const[,e]=wn(),t=De(d=>d.sessions),n=De(d=>d.sessionsWithPendingConfirmations),r=zt(d=>d.projects),a=j.useMemo(()=>new Map(r.map(d=>[d.id,d])),[r]),o=j.useMemo(()=>t.filter(d=>d.isRunning||n.includes(d.id)||d.phase==="blocked").sort((d,h)=>new Date(h.updatedAt).getTime()-new Date(d.updatedAt).getTime()),[t,n]),c=()=>{const d=o.map(h=>h.id);d.length!==0&&(De.getState().enterSplitView(d,d[0]),e("/split-view"))},u=d=>{De.getState().openPane(d,{focus:!0}),e("/split-view")};return o.length===0?null:s.jsxs("div",{className:"mb-6 md:mb-8",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold uppercase tracking-wide text-text-muted",children:"Currently running"}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-emerald-400 font-medium",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),o.length]})]}),o.length>1&&s.jsxs(st,{variant:"primary",size:"sm",onClick:c,className:"flex items-center gap-1.5",children:[s.jsx(fu,{className:"w-3.5 h-3.5"}),"Open split view"]})]}),s.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:s.jsx("ul",{className:"divide-y divide-border",children:o.map(d=>{const h=a.get(d.projectId),m=n.includes(d.id);return s.jsxs("li",{className:"flex items-center gap-3 px-3 md:px-4 py-2.5",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.isRunning?"bg-emerald-400 animate-pulse":"bg-amber-400"}`,title:m?"Waiting for your input":d.isRunning?"Running":"Needs attention"}),s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[90px] truncate",children:(h==null?void 0:h.name)??d.projectId.slice(0,10)}),s.jsx("button",{type:"button",onClick:()=>e(`/p/${d.projectId}/s/${d.id}`),className:"text-sm text-text-primary truncate flex-1 min-w-0 text-left hover:underline",title:d.title??d.id,children:d.title??d.id.slice(0,8)}),s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-text-muted shrink-0",children:t9[d.phase]??d.phase}),m&&s.jsx("span",{className:"text-[10px] text-amber-400 shrink-0",title:"Pending confirmation",children:"Needs you"}),s.jsx("span",{className:"text-xs text-text-muted shrink-0 hidden sm:inline",children:TT(d.updatedAt)}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx(st,{variant:"secondary",size:"sm",onClick:()=>e(`/p/${d.projectId}/s/${d.id}`),children:"Open"}),s.jsxs(st,{variant:"secondary",size:"sm",onClick:()=>u(d.id),title:"Add to split view",className:"flex items-center gap-1",children:[s.jsx(fu,{className:"w-3.5 h-3.5"}),"Split"]})]})]},d.id)})})})]})}function YT({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return s.jsx(El,{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 r9({isOpen:e,onClose:t}){const[,n]=wn(),[r,a]=j.useState(!1),o=ET(),[c,u]=j.useState(!1),d=zt(A=>A.projects),h=zt(A=>A.createProject),m=zt(A=>A.listProjects),f=zt(A=>A.deleteProject),[g,x]=j.useState(null),[w,C]=j.useState(null);j.useEffect(()=>{e&&m()},[e,m]);const b=A=>{n(`/p/${A}`),t()},_=(A,O)=>{O.stopPropagation(),x(A)},S=()=>{g&&(f(g.id),x(null))},v=async A=>E(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 E(A){const O=Tu(A),I=await h(O,A);return m(),k(I)?(C(I.error.path||A),!1):I&&"id"in I?(n(`/p/${I.id}`),t(),!0):!1}const N=j.useCallback(()=>{C(null)},[]),L=j.useCallback(async()=>{const A=w;C(null),A&&await E(A)},[w]);return e?s.jsxs(jt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:s.jsx("div",{className:"flex justify-end gap-2",children:s.jsx(st,{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(ft,{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:()=>b(A.id),className:"flex-1 flex items-center gap-3 text-left",children:[s.jsx(ss,{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:TE(A.workdir,32)})]})]}),s.jsx("button",{onClick:O=>_(A,O),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:s.jsx(Si,{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(st,{variant:"primary",onClick:()=>u(!0),children:"Select existing project"}),s.jsx(st,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&s.jsx(jT,{isOpen:r,onClose:()=>a(!1)}),g&&s.jsx(YT,{isOpen:!0,onClose:()=>x(null),projectName:g.name,onConfirm:S}),c&&s.jsx(qf,{initialPath:o??void 0,onSelect:A=>{v(A)},onClose:()=>u(!1)}),w&&s.jsx(kT,{isOpen:!0,onClose:N,path:w,onRetry:L})]}):null}const s9=[{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 i9({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:s9.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 a9(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(null),m=j.useRef(null),f=De(D=>D.searchSessions??D.sessions),g=De(D=>D.searchSessions!==null),x=zt(D=>D.projects),w=zt(D=>D.loading),C=zt(D=>D.listProjects),b=De(D=>D.listHomeSessions),_=De(D=>D.ensureFullSessionList),S=zt(D=>D.deleteProject),v=De(D=>D.connectionStatus),k=Bt(D=>D.summaries),E=Bt(D=>D.loadSummaries);j.useEffect(()=>{v==="connected"&&(C(),b())},[v,C,b]);const N=x.map(D=>D.id).sort().join(",");j.useEffect(()=>{N&&E(N.split(","))},[N,E]),j.useEffect(()=>{const D=setTimeout(()=>u(a),150);return()=>clearTimeout(D)},[a]),j.useEffect(()=>{c&&!g&&_()},[c,g,_]);const{matchCount:L,filteredSessionIds:A,relevanceScores:O,matchTypes:I,promptSnippets:F}=j.useMemo(()=>{if(!c)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const D=new Map(x.map(Z=>[Z.id,Z])),U=new Map,$=new Map,Q=new Map,K=f.filter(Z=>{var ke;const V=D.get(Z.projectId),M=(V==null?void 0:V.name)??"",X=Z.title??"",ne=((ke=Z.recentUserPrompts)==null?void 0:ke.map(Oe=>Oe.content))??[],re=ne.join(" ");let ie=0,ge="";if(aa(X,c)&&(ie+=10,ge="title"),aa(re,c)){ie+=3,ge=ge==="title"?"title":"prompts";const Oe=ne.find(Fe=>aa(Fe,c));if(Oe){const Fe=Oe.toLowerCase().indexOf(c.toLowerCase());if(Fe>=0){const we=Math.max(0,Fe-30),We=Math.min(Oe.length,Fe+c.length+30);Q.set(Z.id,(we>0?"…":"")+Oe.slice(we,We)+(We<Oe.length?"…":""))}else Q.set(Z.id,Oe.slice(0,80)+(Oe.length>80?"…":""))}}return aa(M,c)&&(ie+=1,ge=ge||"project"),U.set(Z.id,ie),$.set(Z.id,ge),ie>0});return{matchCount:K.length,filteredSessionIds:new Set(K.map(Z=>Z.id)),relevanceScores:U,matchTypes:$,promptSnippets:Q}},[f,c,x]),B=j.useMemo(()=>{const D=new Map;for(const U of f){const $=new Date(U.updatedAt).getTime(),Q=D.get(U.projectId)??0;$>Q&&D.set(U.projectId,$)}return D},[f]),z=j.useMemo(()=>{const D=new Map;for(const U of f){const $=D.get(U.projectId);$?$.push(U):D.set(U.projectId,[U])}for(const[,U]of D)U.sort(($,Q)=>new Date(Q.updatedAt).getTime()-new Date($.updatedAt).getTime());return D},[f]),Y=j.useMemo(()=>{let D=x;return c&&A&&(D=x.filter(U=>{const $=z.get(U.id);return $==null?void 0:$.some(Q=>A.has(Q.id))})),[...D].sort((U,$)=>{const Q=B.get(U.id)??new Date(U.updatedAt).getTime();return(B.get($.id)??new Date($.updatedAt).getTime())-Q})},[x,z,c,A,B]),q=j.useCallback(D=>{const U=z.get(D);return U?c&&A&&O?U.filter($=>A.has($.id)).sort(($,Q)=>{const K=(O.get(Q.id)??0)-(O.get($.id)??0);return K!==0?K:new Date(Q.updatedAt).getTime()-new Date($.updatedAt).getTime()}):U.slice(0,5):[]},[z,c,A,O]),W=()=>{t(!0)},ee=()=>{var D;o(""),u(""),Vt()&&((D=m.current)==null||D.focus())},J=D=>{var U;D.key==="Escape"&&(ee(),(U=m.current)==null||U.blur())},H=c.length>0,P=H&&L===0;return s.jsxs(ft,{className:"flex-1 flex flex-col bg-primary",children:[s.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),s.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ir,{href:"/split-view",className:"inline-flex items-center gap-1.5 rounded font-medium transition-colors bg-bg-secondary border border-border text-text-primary hover:bg-bg-tertiary px-3 py-1.5 text-sm",children:[s.jsx(fu,{className:"w-4 h-4"}),"Open split view"]}),s.jsx(st,{variant:"primary",onClick:W,children:"Open Project"})]})]}),s.jsx(n9,{}),f.length>0&&s.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(_i,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),s.jsx("input",{ref:m,type:"text",value:a,onChange:D=>o(D.target.value),onKeyDown:J,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:ee,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(Ss,{className:"w-4 h-4"})})]}),H&&!P&&s.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[L," ",L===1?"match":"matches"]})]}),P?s.jsxs("div",{className:"text-center py-16 text-text-muted",children:[s.jsx(_i,{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"})]}):Y.map(D=>{const U=q(D.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(ir,{href:`/p/${D.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[s.jsx(ss,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),s.jsx("span",{className:"text-text-primary font-semibold",children:D.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(st,{variant:"secondary",size:"sm",onClick:()=>h(D.id),title:`Tasks for ${D.name}`,"aria-label":`Tasks for ${D.name}`,className:"flex items-center gap-1.5",children:[s.jsx(vb,{className:"w-4 h-4"}),s.jsx("span",{children:"Tasks"}),s.jsx(i9,{counts:k[D.id]})]}),s.jsx(ir,{href:`/p/${D.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:D.id,name:D.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(Si,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"divide-y divide-border",children:U.length>0?U.map($=>{const Q=x.find(M=>$.projectId===M.id),K=Q?`/p/${Q.id}/s/${$.id}`:"#",Z=$.title??$.id.slice(0,8),V=I==null?void 0:I.get($.id);return s.jsx(ir,{href:K,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-muted truncate",children:H&&V==="title"?Fy(Z,c):Z}),H&&V&&V!=="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:V==="prompts"?"prompts":"project"}),V==="prompts"&&(F==null?void 0:F.get($.id))&&s.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:Fy(F.get($.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:TT($.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs",children:[$.messageCount," msgs"]})]})]})},$.id)}):s.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},D.id)}),!H&&Y.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(fa,{})})]}),e&&s.jsx(r9,{isOpen:e,onClose:()=>t(!1)}),d&&s.jsx(gv,{isOpen:!0,onClose:()=>h(null),projectId:d}),n&&s.jsx(YT,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>S(n.id)})]})}function o9(){const[,e]=Rl("/p/:projectId/new"),[,t]=wn(),n=e==null?void 0:e.projectId,r=De(c=>c.createSession),a=De(c=>c.resetPendingSessionCreate),o=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(()=>{o()},[o]),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(fa,{})})}function l9(){const e=zt(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(ir,{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 XT=j.createContext(null),c9=XT.Provider;function Fr(){const e=j.useContext(XT),t=De(n=>{var r;return n.focusedSessionId??((r=n.currentSession)==null?void 0:r.id)??null});return e||t}function pn(e,t,n,r){return De(a=>{var o,c;if(e){const u=(o=a.panes)==null?void 0:o[e];return u?t(u):((c=a.currentSession)==null?void 0:c.id)===e?n(a):r}return n(a)})}function QT(){const e=Fr(),t=pn(e,r=>r.contextState??null,r=>r.contextState,null),n=pn(e,r=>r.session??null,r=>r.currentSession,null);return{sessionId:e,contextState:t,currentSession:n}}function JT(){const e=Fr(),t=De(n=>n.queueUpdate);return j.useCallback(n=>{n?e&&t(e):Ht.send("context.applyDynamic",{...e?{sessionId:e}:{}})},[e,t])}const Vc=e=>Math.round(e*10)/10;function u9(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function Hy(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function d9(e){return`${e.providerId}::${e.model}`}function h9(e){return`${e.providerName} > ${e.model}`}function wk(e){let t=0,n=0,r=0,a=0,o=0,c=0;const u=[],d=[];let h=0;for(const[g,x]of e.entries()){const w=x.stats,C=Hy(w);t+=w.totalTime,n+=w.toolTime,r+=w.prefillTokens,a+=w.generationTokens;const b=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,_=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;o+=b,c+=_,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 S=w.llmCalls??[];for(const v of S)h+=1,d.push({messageId:x.id,timestamp:v.timestamp??x.timestamp,providerId:v.providerId,providerName:v.providerName,backend:v.backend,model:v.model,mode:w.mode,responseIndex:g+1,sessionCallIndex:h,callIndex:v.callIndex,promptTokens:v.promptTokens,completionTokens:v.completionTokens,ttft:v.ttft,completionTime:v.completionTime,prefillSpeed:v.prefillSpeed,generationSpeed:v.generationSpeed,totalTime:v.totalTime,...v.temperature!==void 0&&{temperature:v.temperature},...v.topP!==void 0&&{topP:v.topP},...v.topK!==void 0&&{topK:v.topK},...v.maxTokens!==void 0&&{maxTokens:v.maxTokens}})}const m=o>0?Vc(r/o):0,f=c>0?Vc(a/c):0;return{totalTime:Vc(t),aiTime:Vc(t-n),toolTime:Vc(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:m,avgGenerationSpeed:f,responseCount:e.length,llmCallCount:d.length,dataPoints:u,callDataPoints:d}}function ZT(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&u9(a.stats)).sort((a,o)=>new Date(a.timestamp).getTime()-new Date(o.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const o=d9(Hy(a.stats)),c=n.get(o)??[];n.set(o,[...c,a])}const r=Array.from(n.entries()).map(([a,o])=>{const c=Hy(o[0].stats),u=wk(o);return{...c,key:a,label:h9(c),...u}});return{...wk(t),modelGroups:r}}function f9(e){return j.useMemo(()=>ZT(e),[e])}function xv(){var a;const e=De(o=>o.gitStatus),t=De(o=>o.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 Tl(e){return e.toLocaleString("en-US").replace(/,/g," ")}function Ck(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Ps(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),o=r%60;return`${n}h ${a}m ${o}s`}const kk=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),jk=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function Sl(e){return Object.hasOwn(kk,e)?kk[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function m9(e){return Object.hasOwn(jk,e)?jk[e]:e.replace(/_/g," ")}const Ek=["▁","▂","▃","▄","▅","▆","▇","█"];function p9(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 g9(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 x9(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,x)=>g.x-x.x),r=n[0].x,a=n[n.length-1].x,o=Math.min(...n.map(g=>g.y)),c=Math.max(...n.map(g=>g.y)),{minY:u,maxY:d}=g9(o,c),h=Math.max(0,u),m=Array.from({length:t},()=>" "),f=new Map;for(const g of n){const x=a===r?0:Math.round((g.x-r)/(a-r)*(t-1)),w=f.get(x)??[];f.set(x,[...w,g.y])}for(const[g,x]of f){const w=Math.max(...x);m[g]=Ek[p9(w,u,d)]??Ek[0]}return{blocks:m.join(""),minX:r,maxX:a,minY:h,maxY:d}}function Nk(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Tk({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:o,showAxes:c=!0,formatY:u=Nk,formatX:d=Nk}){const h=j.useMemo(()=>{const m=x9(e,t),f=Math.max(t*6,240),g=10,x=8,C=[...e].sort((v,k)=>v.x-k.x).map(v=>{const k=m.maxX===m.minX?f/2:g+(v.x-m.minX)/(m.maxX-m.minX)*(f-g*2),E=m.maxY===m.minY?n/2:x+(m.maxY-v.y)/(m.maxY-m.minY)*(n-x*2);return{...v,cx:k,cy:E,leftPercent:k/f*100,topPercent:E/n*100}}),b=C.map((v,k)=>`${k===0?"M":"L"} ${v.cx.toFixed(1)} ${v.cy.toFixed(1)}`).join(" "),S=[m.maxY,(m.maxY+m.minY)/2,m.minY].map(v=>({value:v,y:m.maxY===m.minY?n/2:x+(m.maxY-v)/(m.maxY-m.minY)*(n-x*2)}));return{...m,chartWidth:f,points:C,path:b,gridLines:S}},[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(m=>s.jsx("span",{children:u(m.value)},`${m.value}-${m.y}`))}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"relative h-[78px]",children:[s.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(m=>s.jsx("line",{x1:"0",x2:h.chartWidth,y1:m.y,y2:m.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${m.y}`)),h.points.map(m=>s.jsx("line",{x1:m.cx,x2:m.cx,y1:n-4,y2:m.cy,stroke:"currentColor",className:"text-border/40"},`guide-${m.cx}-${m.cy}`)),h.points.length>1&&s.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(m=>s.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${m.leftPercent}%`,top:`${m.topPercent}%`},title:`${d(m.x)} -> ${u(m.y)}`,children:s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${m.x}-${m.y}`))]})})]}),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)})]})]}),o&&c&&s.jsx("div",{className:"text-text-muted mt-1 text-center",children:o})]})}function y9({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:a=60}){const o=e.map(u=>({x:u.x,y:u.ppSpeed})),c=e.map(u=>({x:u.x,y:u.tgSpeed}));return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Tk,{data:o,width:a,label:t,xLabel:r}),s.jsx(Tk,{data:c,width:a,label:n,xLabel:r})]})}function b9(e){const t=new Map;for(const n of e.callDataPoints){const r=t.get(n.messageId)??[];t.set(n.messageId,[...r,n])}return e.dataPoints.map(n=>{const r=[...t.get(n.messageId)??[]].sort((a,o)=>a.callIndex-o.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function v9(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 _9(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 S9(e){return e.callDataPoints.length>0?_9(e):v9(e)}function so(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Jc(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function w9(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${so(t)} ctx`:`${so(t)}-${so(n)} ctx`}function yf(e){return`${Jc(e)} t/s`}function eA(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function C9(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 k9({isOpen:e,onClose:t,stats:n}){const r=j.useRef(null),[a,o]=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?b9(d):[],[d]),m=j.useMemo(()=>d?S9(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),f=j.useCallback(w=>{o(C=>({...C,[w]:!C[w]}))},[]),g=j.useCallback(()=>{if(!d)return;const w=C9(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 se(async()=>{const{default:_}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:_}},[])).default,C=await w(r.current,{backgroundColor:"#1a1a1a",scale:2}),b=document.createElement("a");b.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,b.href=C.toDataURL("image/png"),b.click()}catch(w){console.error("Failed to export PNG:",w),g()}},[g]);return s.jsx(jt,{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(ci,{label:"AI Time",value:Ps(d.aiTime)}),s.jsx(ci,{label:"Total Time",value:Ps(d.totalTime)}),s.jsx(ci,{label:"Tool Time",value:Ps(d.toolTime)}),s.jsx(ci,{label:"Responses",value:d.responseCount.toString()}),s.jsx(ci,{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(ci,{label:"Prefill Tokens",value:so(d.prefillTokens),subValue:`@ ${Jc(d.avgPrefillSpeed)} tok/s`}),s.jsx(ci,{label:"Gen Tokens",value:so(d.generationTokens),subValue:`@ ${Jc(d.avgGenerationSpeed)} tok/s`}),s.jsx(ci,{label:"Avg PP Speed",value:`${Jc(d.avgPrefillSpeed)}`,subValue:"tok/s"}),s.jsx(ci,{label:"Avg TG Speed",value:`${Jc(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&m.points.length>1&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:g,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),s.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),s.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:s.jsx(y9,{data:m.points,width:50,prefillLabel:m.prefillLabel,generationLabel:m.generationLabel,xLabel:m.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(ft,{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(j9,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>f(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((b,_)=>s.jsx(E9,{dataPoint:b,index:_},`${b.messageId}-${b.callIndex}`))]},w.messageId))})]})})]})]})})}function ci({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 j9({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?w9(e.calls.map(o=>o.promptTokens)):`${so(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:eA(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ps(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:yf(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:yf(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 E9({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:eA(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ps(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:so(e.promptTokens)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:yf(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:yf(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 N9={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"}},tA=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function T9(e){return N9[e]??{icon:"○",color:"text-text-muted"}}function yv(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Hl=j.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=T9(t);return s.jsx("span",{className:`${a} ${n}`,children:r})});function bf({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:tA.map(r=>{const a=n[r];return a?s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(Hl,{status:r}),s.jsx("span",{children:a})]},r):null})})]})}const nA=j.memo(function({entries:t,title:n,onClearAll:r}){const[a,o]=j.useState(!1),c=j.useCallback(()=>{o(!1),r==null||r()},[r]);return t.length===0?null:s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&s.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),s.jsx("div",{className:"bg-primary",children:t.map((u,d)=>s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[s.jsx(Hl,{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,"]"]})," ",yv(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:()=>o(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all",children:[s.jsx(Si,{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:()=>o(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),A9={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},L9=["pending","completed","failed","dismissed"];function R9(e){return A9[e]??L9}function D9(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function rA({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:o}){const[c,u]=j.useState(e),[d,h]=j.useState(null),[m,f]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(""),b=j.useRef(null),_=j.useRef(null),S=j.useCallback(()=>{const B=_.current;B&&(B.style.height="auto",B.style.height=B.scrollHeight+"px")},[]);j.useEffect(()=>{u(e)},[e]),j.useEffect(()=>{var B;d&&(S(),Vt()&&((B=_.current)==null||B.focus()))},[d,S]),j.useEffect(()=>{var B;g&&Vt()&&((B=b.current)==null||B.focus())},[g]);const v=j.useCallback(B=>{u(B),xe(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:B})}).catch(z=>console.error(`Failed to sync ${n}:`,z))},[t,n]),k=j.useCallback(B=>{const z=R9(n),Y=c.map(q=>q.id===B?{...q,status:D9(q.status,z)}:q);v(Y)},[c,n,v]),E=j.useCallback((B,z)=>{h(B),f(z)},[]),N=j.useCallback((B,z,Y)=>{var ee;const q=(z.trim()||((ee=Y.find(J=>J.id===B))==null?void 0:ee.description))??"",W=Y.map(J=>J.id===B?{...J,description:q}:J);v(W)},[v]),L=j.useCallback(()=>{d&&(N(d,m,c),h(null))},[d,m,c,N]),A=j.useCallback(B=>{B.key==="Enter"&&L(),B.key==="Escape"&&(B.stopPropagation(),h(null))},[L]),O=j.useCallback(B=>{v(c.filter(z=>z.id!==B))},[c,v]),I=j.useCallback(()=>{const B=w.trim();if(!B)return;const z=c.map(q=>Number(q.id)).filter(q=>Number.isInteger(q)&&q>=0),Y=String(Math.max(-1,...z)+1);v([...c,{id:Y,description:B,status:"pending"}]),C("")},[w,c,v]),F=j.useCallback(B=>{B.key==="Enter"&&(B.preventDefault(),I()),B.key==="Escape"&&(x(!1),C(""))},[I]);return s.jsxs(jt,{isOpen:a,onClose:o,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[s.jsxs("ul",{className:"space-y-1",children:[c.map((B,z)=>{const Y=d===B.id,q=s.jsxs("button",{onClick:()=>E(B.id,B.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:["[",B.id,"]"]})," ",s.jsx("span",{children:yv(B.description)})]}),W=Y?s.jsx("textarea",{ref:_,value:m,onChange:ee=>{f(ee.target.value),S()},onBlur:L,onKeyDown:A,className:"w-full bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary resize-none",rows:1}):q;return s.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${z>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>k(B.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:s.jsx(Hl,{status:B.status})}),s.jsx("div",{className:"flex-1 min-w-0",children:W}),s.jsx("button",{onClick:()=>O(B.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(Ss,{className:"w-4 h-4"})})})]},B.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:b,value:w,onChange:B=>C(B.target.value),onKeyDown:F,placeholder:"New entry...",className:"flex-1 bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"}),s.jsxs("button",{onClick:I,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(as,{className:"w-4 h-4"}),"Add"]})]})})]})}const O9={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function I9(e,t){await xe(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function yh({id:e,agents:t}){const n=oo(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 M9({id:e}){const t=Ut(c=>c.defaults),n=Ut(c=>c.userItems),a=j.useMemo(()=>[...t,...n],[t,n]).find(c=>c.id===e),o=(a==null?void 0:a.color)??"#3b82f6";return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${o}20`,color:o},children:(a==null?void 0:a.name)??e})}function sA({entries:e,sessionId:t}){const[n,r]=j.useState(e),[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(""),[m,f]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(!1),b=ct(J=>J.defaults),_=ct(J=>J.userItems),S=ct(J=>J.projectItems),v=j.useMemo(()=>[...b,..._,...S],[b,_,S]),k=j.useRef(null),E=j.useRef(null);j.useEffect(()=>{r(e)},[e]),j.useEffect(()=>{var J;a&&Vt()&&((J=k.current)==null||J.focus())},[a]),j.useEffect(()=>{var J;c&&Vt()&&((J=E.current)==null||J.focus())},[c]);const N=j.useCallback(J=>{r(J),I9(t,J)},[t]),L=j.useCallback(J=>{var $;const H=J.map(Q=>Q.trim()).filter(Boolean);if(H.length===0)return;const P=n.map(Q=>Number(Q.id)).filter(Q=>Number.isInteger(Q)&&Q>=0),D=Math.max(-1,...P)+1,U=H.map((Q,K)=>({id:String(D+K),description:Q,status:"pending"}));N([...n,...U]),h(""),Vt()&&(($=k.current)==null||$.focus())},[n,N]),A=j.useCallback(()=>{L([d])},[L,d]),O=j.useCallback(J=>{const H=J.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);H.length<2||(J.preventDefault(),L(H))},[L]),I=j.useCallback(()=>{o(!1),h("")},[]),F=j.useCallback((J,H)=>{u(J),f(H)},[]),B=j.useCallback(()=>{if(!c)return;const J=m.trim(),H=n.map(P=>P.id===c?{...P,description:J||P.description}:P);N(H),u(null)},[c,m,n,N]),z=j.useCallback(J=>{const H=n.map(P=>P.id===J?{...P,status:O9[P.status]??"pending"}:P);N(H)},[n,N]),Y=j.useCallback(J=>{N(n.filter(H=>H.id!==J))},[n,N]),q=j.useCallback(()=>{N([]),x(!1)},[N]),W=j.useCallback(J=>{J.key==="Enter"&&(J.preventDefault(),A()),J.key==="Escape"&&I()},[A,I]),ee=j.useCallback(J=>{J.key==="Enter"&&B(),J.key==="Escape"&&u(null)},[B]);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((J,H)=>{const P=J.status,D=c===J.id;return s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${H>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>z(J.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${J.status} (click to cycle)`,children:s.jsx(Hl,{status:P})}),s.jsx("div",{className:"flex-1 min-w-0",children:D?s.jsx("input",{ref:E,value:m,onChange:U=>f(U.target.value),onBlur:B,onKeyDown:ee,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):s.jsxs("button",{onClick:()=>F(J.id,J.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:["[",J.id,"] ",yv(J.description)]})}),s.jsx("button",{onClick:()=>Y(J.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(Ss,{className:"w-4 h-4"})})]},J.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:J=>h(J.target.value),onKeyDown:W,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(as,{className:"w-3 h-3"}),"Add"]}),s.jsx("button",{onClick:I,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):s.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[s.jsx(as,{className:"w-3 h-3"}),"Add"]}),n.length>0&&(g?s.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),s.jsx("button",{onClick:q,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>x(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]}):s.jsxs("button",{onClick:()=>x(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[s.jsx(Si,{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(zf,{className:"w-3 h-3"})})]}),s.jsx(jt,{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(yh,{id:"planner",agents:v})," 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(M9,{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(yh,{id:"builder",agents:v}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),s.jsxs("li",{children:["Then launch the ",s.jsx(yh,{id:"verifier",agents:v})," 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(yh,{id:"code_reviewer",agents:v})," 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 iA({isOpen:e,onClose:t}){const n=tr(C=>C.config),r=tr(C=>C.saveConfig),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(!1),[m,f]=j.useState(!1),[g,x]=j.useState(!1);j.useEffect(()=>{e&&(o((n==null?void 0:n.command)??""),u((n==null?void 0:n.url)??""),h((n==null?void 0:n.hotReload)??!1),f((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:m}),x(!1),t())};return s.jsx(jt,{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=>o(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:m,onChange:C=>f(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 Ak={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"},P9={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"},Lk={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},B9="text-text-primary";function $9(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",o;try{for(;(o=n.exec(e))!==null;){if(o.index>r){const h=e.slice(r,o.index);h&&t.push({text:h,className:a})}const c=o[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 m=Ak[h];m&&d.push(m)}else if(h>=40&&h<=47){const m=P9[h];m&&d.push(m)}else if(h>=90&&h<=97){const m=Ak[h];m&&d.push(m)}else if(h in Lk){const m=Lk[h];m&&d.push(m)}else h===39?d.push(B9):h===49&&(a=a.split(" ").filter(m=>!m.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:F9(e),className:"text-text-primary"}]}}function F9(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function vf(e){const t=$9(e),n=[];return t.forEach((r,a)=>{const o=r.text.split(`
285
+ `);o.forEach((c,u)=>{n.push(ps.createElement("span",{key:`${a}-${u}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},c)),u<o.length-1&&n.push(ps.createElement("br",{key:`${a}-${u}-br`}))})}),n.length===1?n[0]:n}function aA({logs:e,preRef:t,preClassName:n="text-sm font-mono",scrollAreaRef:r,onScrollbarGesture:a}){return s.jsx(ft,{ref:r,options:{overflow:{x:"scroll",y:"scroll"}},className:n,onScrollbarGesture:a,children:s.jsx("pre",{ref:t,className:"contents",children:e.length===0?s.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((o,c)=>o.type==="marker"?s.jsx(j.Fragment,{children:s.jsx("hr",{className:"border-t border-border my-1"})},c):s.jsx("span",{className:o.stream==="stderr"?"text-accent-warning":"",children:vf(o.content)},c))})})}function bv({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(yn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const z9=100,H9=6,U9=1500,oA=(e,t)=>e==="down"?!1:t!==null&&t<=H9,Pu=(e,t,n)=>{const r=j.useRef(!0),a=j.useRef(null),o=j.useRef(!1),c=j.useRef(0),u=j.useRef(!1),d=j.useRef(0),[h,m]=j.useState(!0),f=j.useCallback(()=>{if(n)return n();const v=e.current;return v instanceof HTMLElement?v:null},[n,e]),g=j.useCallback(v=>{v||(d.current+=1),r.current=v,m(v)},[]),x=j.useCallback(()=>{g(!1)},[g]),w=j.useCallback(()=>{if(!r.current)return;const v=f();v&&(u.current=!0,v.scrollTop=v.scrollHeight,requestAnimationFrame(()=>{requestAnimationFrame(()=>{u.current=!1})}),c.current=Date.now())},[f]),C=j.useCallback((v,k)=>{v==="down"&&(o.current=!0);const E=oA(v,k);g(E),E&&(c.current=Date.now()),v==="up"&&(o.current=!1)},[g]),b=j.useRef(null);j.useEffect(()=>{if(t!=null&&t.id)return b.current!==null&&(cancelAnimationFrame(b.current),b.current=null),g(!0),c.current=Date.now(),b.current=requestAnimationFrame(()=>{requestAnimationFrame(()=>{w(),b.current=null})}),()=>{b.current!==null&&(cancelAnimationFrame(b.current),b.current=null)}},[t==null?void 0:t.id,g,w]),j.useEffect(()=>{const v=f();if(!v)return;const k=()=>{const B=d.current;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(B!==d.current)return;v.scrollHeight-v.scrollTop-v.offsetHeight<z9&&(c.current=Date.now(),g(!0))})})},E=B=>{if(B.deltaY>0){k();return}x()},N=B=>{B.touches[0]&&(a.current=B.touches[0].clientY)},L=B=>{if(a.current===null)return;const z=B.touches[0];if(!z)return;if(z.clientY-a.current>0){x();return}k()},A=()=>{o.current||u.current||Date.now()-c.current<=U9||g(!1)},O=B=>{if(!(B.ctrlKey||B.metaKey||B.altKey)){if(B.key==="ArrowUp"||B.key==="PageUp"||B.key==="Home"){x();return}(B.key==="ArrowDown"||B.key==="PageDown"||B.key==="End")&&k()}},I=new MutationObserver(()=>{r.current&&requestAnimationFrame(w)}),F=setInterval(()=>{r.current&&w()},1e3);return v.addEventListener("wheel",E,{passive:!0}),v.addEventListener("touchstart",N,{passive:!0}),v.addEventListener("touchmove",L,{passive:!0}),v.addEventListener("scroll",A,{passive:!0}),v.addEventListener("keydown",O),v.tabIndex=-1,I.observe(v,{childList:!0,subtree:!0,characterData:!0}),()=>{v.removeEventListener("wheel",E),v.removeEventListener("touchstart",N),v.removeEventListener("touchmove",L),v.removeEventListener("scroll",A),v.removeEventListener("keydown",O),I.disconnect(),clearInterval(F)}},[t==null?void 0:t.id,f,w,g,x]);const _=j.useCallback(()=>{g(!0),w()},[g,w]),S=j.useCallback(v=>{g(v),v&&w()},[g,w]);return{force_scroll_to_bottom:_,isAutoScrollActive:h,setAutoScroll:S,handleScrollbarGesture:C}},Bu=e=>j.useCallback(()=>{var t,n;return((n=(t=e.current)==null?void 0:t.osInstance())==null?void 0:n.elements().viewport)??null},[e]),vv=j.memo(function({title:t,subtitle:n,logs:r,onClose:a,onClear:o,onInsertMarker:c,preClassName:u}){const d=j.useRef(null),h=Bu(d),{isAutoScrollActive:m,setAutoScroll:f,handleScrollbarGesture:g}=Pu(d,null,h);return s.jsxs(jt,{isOpen:!0,onClose:a,title:t,size:"full",scrollable:!1,headerRight:s.jsx(bv,{isActive:m,onToggle:f,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),footer:s.jsxs("div",{className:"flex items-center gap-2",children:[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(as,{className:"w-3.5 h-3.5"}),"Marker"]}),o&&s.jsxs("button",{onClick:o,className:"text-xs text-text-muted hover:text-accent-error flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Clear logs",children:[s.jsx(Si,{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(ft,{ref:d,className:"flex-1 -m-4 p-4",onScrollbarGesture:g,children:s.jsx(aA,{logs:r,preClassName:u})})]})}),V9=j.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:o}){const[c,u]=j.useState(null),d=j.useRef(null),h=j.useRef(o);h.current=o;const m=j.useCallback((g,x)=>{o(oA(g,x))},[o]),f=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=f();if(!g)return;const x=w=>{if(w.deltaY<0){h.current(!1);return}w.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{g.scrollHeight-g.scrollTop-g.offsetHeight<100&&h.current(!0)}))};return g.addEventListener("wheel",x,{passive:!0}),()=>g.removeEventListener("wheel",x)},[f]),j.useEffect(()=>{const g=f();g&&a&&(g.scrollTop=g.scrollHeight)},[t,a,c,f]),s.jsx("div",{className:`relative ${c?"":"hidden"}`,children:s.jsx(ft,{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:m,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:vf(g.content)},x))})})})}),lA=j.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const o=tr(D=>D.setWorkdir),c=tr(D=>D.status),u=tr(D=>D.config),d=tr(D=>D.logs),h=tr(D=>D.start),m=tr(D=>D.stop),f=tr(D=>D.fetchLogs),g=tr(D=>D.clearLogs),x=tr(D=>D.insertMarker),w=()=>{window.confirm("Clear all dev server logs?")&&g()},[C,b]=j.useState(!1),[_,S]=j.useState(!1),[v,k]=j.useState(!1),[E,N]=j.useState(!1),L=j.useRef(null),A=j.useRef(null),O=j.useCallback(()=>{var D,U;return((U=(D=A.current)==null?void 0:D.osInstance())==null?void 0:U.elements().viewport)??null},[]),{isAutoScrollActive:I,setAutoScroll:F,handleScrollbarGesture:B}=Pu(A,null,O),z=j.useRef(null),Y=j.useRef(null),q=j.useRef(null),W=()=>{const D=c==null?void 0:c.inspectProxyPort;if(!D){c!=null&&c.url&&window.open(c.url,"_blank");return}const U=`${window.location.protocol}//${window.location.hostname}:${D}`;window.open(U,"_blank")},ee=(c==null?void 0:c.state)??"off",J=u!==null,H=ee==="running"||ee==="warning";j.useEffect(()=>{o(t??null)},[t,o]),j.useEffect(()=>{H&&f()},[H,f]);const P=()=>{H?m():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 ${ee==="running"?"bg-accent-success":ee==="warning"?"bg-accent-warning":ee==="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():b(!0)},className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:s.jsx(W3,{})})]}),J?s.jsx(s.Fragment,{children:ee==="running"||ee==="warning"?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:P,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(bb,{}),"Stop"]}),(c==null?void 0:c.url)&&s.jsxs("button",{onClick:()=>W(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:c.url,children:[s.jsx(yb,{}),"Open"]})]}):s.jsx("button",{onClick:P,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():b(!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:q,className:`relative ${J&&H?"":"hidden"}`,onMouseEnter:()=>{!J||!H||n||(Y.current&&clearTimeout(Y.current),z.current=setTimeout(()=>{k(!0),N(!1)},500))},onMouseLeave:()=>{z.current&&clearTimeout(z.current),N(!0),Y.current=setTimeout(()=>k(!1),150)},children:[s.jsx(aA,{logs:d,preRef:L,preClassName:"text-sm bg-bg-primary p-2 rounded max-h-[200px] border border-border",scrollAreaRef:A,onScrollbarGesture:B}),J&&H&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[!n&&(v||E)&&s.jsx(bv,{isActive:I,onToggle:F,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),s.jsx("button",{onClick:()=>n?r==null?void 0:r():S(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),!n&&(v||E)&&q.current&&wi.createPortal(s.jsx(V9,{logs:d,anchorRef:q,isHiding:E,isAutoScrollActive:I,onSetAutoScroll:F}),document.body)]})]}),!a&&s.jsx(iA,{isOpen:C,onClose:()=>b(!1)}),_&&s.jsx(vv,{title:"Dev Server Logs",logs:d,onClose:()=>S(!1),onClear:w,onInsertMarker:x})]})}),W9=j.memo(function({sessionId:t}){const n=Zc(x=>x.processes),r=Zc(x=>x.stopProcess),[a,o]=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 m=x=>{switch(x){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},f=x=>{const w=Zc.getState().logs[x]??[];u(w.map(C=>({content:C.content,stream:C.stream}))),o(x)},g=x=>{t&&r(x,t)};return s.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),s.jsx("div",{className:"space-y-2",children: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 ${m(x.status)}`}),s.jsx("span",{className:"text-sm text-text-primary truncate",title:x.name,children:x.name}),s.jsxs("span",{className:"text-xs text-text-muted",children:["[",x.status,"]"]})]}),s.jsxs("div",{className:"flex gap-1 ml-2",children:[s.jsx("button",{onClick:()=>f(x.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),s.jsx("button",{onClick:()=>g(x.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},x.id))}),a&&(()=>{const x=d.find(w=>w.id===a);return s.jsx(vv,{title:(x==null?void 0:x.name)??"",subtitle:x==null?void 0:x.command,logs:c,onClose:()=>{o(null),u([])}})})()]})});function cA(){return nn.getState().platform??null}function uA(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function dA(e,t,n){const r=cA(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,o=uA(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${o}`}:${t??1}`;const c=`vscode://file/${o}`;return t?`${c}:${t}`:c}function G9(e){const t=cA(),n=uA(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function q9({file:e,showEditorLink:t,workdir:n}){const r=TE(e.path,28),a=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",o=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"",c=t&&n?dA(e.path,void 0,n):void 0,u=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),o&&s.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:o})]});return 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 K9(){const{diff:e}=xv(),t=It(a=>a.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",n=De(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(ft,{className:"mt-3 max-h-[150px]",children:s.jsx("div",{className:"pr-1",children:e.files.map((a,o)=>s.jsx(q9,{file:a,showEditorLink:t,workdir:r},o))})})}function hA(e){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[o,c]=j.useState(!1),[u,d]=j.useState(""),h=j.useCallback(()=>{t||e()},[t,e]),m=u.trim().length>0&&!t,f=j.useCallback(()=>{a(null),n(!1),d(""),c(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:o,setLoading:c,newName:u,setNewName:d,handleClose:h,canCreate:m,resetState:f}}function fA({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:o}){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(jt,{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(fa,{})}):o})}function mA({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:o,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=>o(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 pA({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:o}){const c=De(z=>z.loadSession),{busy:u,setBusy:d,error:h,setError:m,loading:f,setLoading:g,newName:x,setNewName:w,handleClose:C,canCreate:b,resetState:_}=hA(t),[S,v]=j.useState([]),[k,E]=j.useState(null),[N,L]=j.useState(null),[A,O]=j.useState(!1);j.useEffect(()=>{e&&(_(),E(null),L(null),O(!1),xe(`/api/projects/${n}/workspaces`).then(z=>z.json()).then(z=>{v(z.workspaces),g(!1)}).catch(()=>{v([]),g(!1)}))},[e,n,_,g]);const I=j.useCallback(async z=>{m(null),d(!0);try{const Y=await xe(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:z})});if(!Y.ok){const q=await Y.json().catch(()=>({error:"Failed to switch workspace"}));m(q.error),d(!1);return}await c(r,!0),t()}catch(Y){m(Y instanceof Error?Y.message:"Failed to switch workspace"),d(!1)}},[r,c,t,m,d]),F=j.useCallback(async(z,Y)=>{m(null),L(null),O((Y==null?void 0:Y.force)===!0),d(!0);try{const q=await xe(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:z,force:(Y==null?void 0:Y.force)===!0})});if(!q.ok){const J=await q.json().catch(()=>({error:"Failed to delete workspace"}));m(J.error),J.conflictingSessionIds&&L(J.conflictingSessionIds),O(!1),d(!1);return}E(null),O(!1),await c(r,!0);const ee=await(await xe(`/api/projects/${n}/workspaces`)).json();v(ee.workspaces),d(!1),g(!1)}catch(q){m(q instanceof Error?q.message:"Failed to delete workspace"),O(!1),d(!1)}},[r,n,c,m,d]),B=j.useCallback(async()=>{m(null),d(!0);try{const z=await xe(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:x.trim()})});if(!z.ok){const Y=await z.json().catch(()=>({error:"Failed to create workspace"}));m(Y.error),d(!1);return}await c(r),t()}catch(z){m(z instanceof Error?z.message:"Failed to create workspace"),d(!1)}},[x,r,c,t,m,d]);return s.jsx(fA,{isOpen:e,onClose:C,title:"Switch Workspace",busy:u,loading:f,children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),s.jsxs(ft,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[s.jsxs("button",{onClick:()=>I("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(ss,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:"original"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:o??"unknown"}),!a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),S.slice().sort((z,Y)=>z.name===a?-1:Y.name===a?1:z.name.localeCompare(Y.name)).map(z=>s.jsx("div",{className:"group relative",children:k===z.name?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[s.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",z.name,"?"]}),s.jsx("button",{onClick:()=>F(z.name),disabled:u,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),s.jsx("button",{onClick:()=>E(null),disabled:u,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>{!u&&z.name!==a&&I(z.name)},disabled:u||z.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${z.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${u?"opacity-70":""}`,children:[s.jsx(ss,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:z.name}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:z.branch??"unknown"}),z.name===a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),z.name!==a&&!u&&s.jsx("button",{onClick:Y=>{Y.stopPropagation(),m(null),L(null),E(z.name)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 text-xs text-text-muted hover:text-accent-error transition-opacity px-1 py-0.5 rounded",title:"Delete workspace",children:"✕"})]})},z.path))]}),s.jsx(mA,{icon:s.jsx(ss,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:x,onChange:w,onCreate:B,canCreate:b,busy:u}),h&&s.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[s.jsx("p",{className:"text-accent-error",children:h}),N&&N.length>0&&s.jsxs("div",{className:"mt-2 space-y-1",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),s.jsx("ul",{className:"space-y-0.5",children:N.map(z=>s.jsx("li",{children:s.jsx(ir,{href:`/p/${n}/s/${z}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:z})},z))}),s.jsx("button",{onClick:()=>F(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 gA({isOpen:e,onClose:t,sessionId:n}){const r=De(L=>L.loadSession),{busy:a,setBusy:o,error:c,setError:u,loading:d,setLoading:h,newName:m,setNewName:f,handleClose:g,canCreate:x,resetState:w}=hA(t),[C,b]=j.useState([]),[_,S]=j.useState(""),[v,k]=j.useState("");j.useEffect(()=>{e&&(w(),S(""),b([]),k(""),xe(`/api/sessions/${n}/branches`).then(L=>L.json()).then(L=>{b(L.branches),k(L.defaultBranch??""),h(!1)}).catch(()=>{b([]),h(!1)}))},[e,n,w,h]);const E=j.useCallback(async L=>{u(null),o(!0);try{const A=await xe(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:L})});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to switch branch"}));u(O.error),o(!1);return}await r(n,!0),t()}catch(A){u(A instanceof Error?A.message:"Failed to switch branch"),o(!1)}},[n,r,t,u,o]),N=j.useCallback(async()=>{u(null),o(!0);try{const L={name:m.trim()};_&&(L.sourceBranch=_);const A=await xe(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to create branch"}));u(O.error),o(!1);return}await r(n),t()}catch(L){u(L instanceof Error?L.message:"Failed to create branch"),o(!1)}},[m,_,n,r,t,u,o]);return s.jsx(fA,{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(ft,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(L=>s.jsxs("button",{onClick:()=>{L.current||E(L.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${L.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[s.jsx(eo,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:L.name}),L.current&&s.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!L.current&&s.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},L.name))})]}),s.jsx(mA,{icon:s.jsx(eo,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:m,onChange:f,onCreate:N,canCreate:x,busy:a}),m.trim()&&s.jsxs("div",{className:"mt-2",children:[s.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",v||"project default",")"]}),s.jsxs("div",{className:"relative",children:[s.jsx(eo,{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:_,onChange:L=>S(L.target.value),placeholder:v||"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 xA({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:o,onEditWorkspace:c,onEditBranch:u}){const[d,h]=j.useState(!1),[m,f]=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:G9(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[s.jsx(ss,{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(ss,{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(eo,{}),s.jsx("span",{className:"truncate text-text-secondary",children:t}),s.jsx("button",{onClick:()=>{u?u():f(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]})]}),s.jsx(K9,{}),!c&&s.jsx(pA,{isOpen:d,onClose:()=>h(!1),projectId:o,sessionId:a,currentWorkspace:e,currentBranch:t}),!u&&s.jsx(gA,{isOpen:m,onClose:()=>f(!1),sessionId:a})]})}function Y9(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function X9(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function _v({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",o=n==="sm"?"h-1":"h-1.5";return s.jsx("div",{className:`${o} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:s.jsx("div",{className:`h-full transition-all duration-300 ${X9(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function Q9({dangerZone:e,size:t="md"}){return e?s.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function J9({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 Al=j.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:o=1}){const{showSyntaxHighlighting:c}=Fs(),[u,d]=j.useState(null),h=gT(),m=j.useRef(t);if(j.useEffect(()=>{c&&(m.current=t,pT(t,n,h).then(g=>{m.current===t&&d(g)}))},[t,n,h,c]),!c||!u)return s.jsx(J9,{code:t,variant:r});if(r==="inline")return s.jsx("span",{dangerouslySetInnerHTML:{__html:u}});const f=a?"":"shiki-plain";return s.jsx("div",{className:f,style:{"--shiki-start":o},dangerouslySetInnerHTML:{__html:u}})});function yA({src:e,alt:t,isOpen:n,onClose:r}){return n?s.jsx(jt,{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 _f=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})})})}),Z9=j.memo(function({oldString:t,newString:n,filePath:r}){const a=j.useMemo(()=>fm(r),[r]),o=t.length>0,c=n.length>0;return!o&&!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:[o&&s.jsx(_f,{type:"removed",children:s.jsx(Al,{code:t,language:a,variant:"block",showLineNumbers:!0})}),c&&s.jsx(_f,{type:"added",children:s.jsx(Al,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),eV=j.memo(function({content:t,filePath:n}){const r=j.useMemo(()=>fm(n),[n]);return s.jsx(hn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(_f,{type:"added",children:s.jsx(Al,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),tV=j.memo(function({regions:t,filePath:n}){const r=j.useMemo(()=>fm(n),[n]);return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsx("div",{className:"space-y-2",children:t.map((a,o)=>s.jsx(rV,{region:a,language:r},o))})});function nV(e){const t=[];function n(r,a,o){const c=t[t.length-1];c&&c.type===r&&c.startLine+c.lines.length===a?c.lines.push(o):t.push({type:r,startLine:a,lines:[o]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const a=r.oldContent.split(`
286
+ `);for(let c=0;c<a.length;c++)n("removed",r.startLine+c,a[c]);const o=r.newContent.split(`
287
+ `);for(let c=0;c<o.length;c++)n("added",r.startLine+c,o[c])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const rV=j.memo(function({region:t,language:n}){const r=nV(t);return s.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,o)=>s.jsx(sV,{section:a,language:n},o))})}),sV=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(Al,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):s.jsx(_f,{type:t.type,children:s.jsx(Al,{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 iV=j.memo(function({result:t,metadata:n,filePath:r}){const[a,o]=j.useState(!1),c=j.useMemo(()=>fm(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:()=>o(!0),children:s.jsx("img",{src:w,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),s.jsx(yA,{src:w,alt:r,isOpen:a,onClose:()=>o(!1)})]})}if(!t)return s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const h=t;if(c==="markdown"){const w=Rk(h);return s.jsx(hn,{className:"rounded border border-border max-h-[45vh] p-2",children:s.jsx(nr,{content:w})})}const m=Rk(h),f=h.split(`
292
+ `)[0],g=f==null?void 0:f.match(/^(\d+)\|/),x=g?parseInt(g[1],10):1;return s.jsx(hn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(Al,{code:m,language:c,variant:"block",showLineNumbers:!0,startLine:x})})});function aV({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 oV({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(aV,{type:r.type,content:r.content},a))})]})}function Sv({isOpen:e,onClose:t,isRunning:n,onApply:r}){const a=Fr(),[o,c]=j.useState(null),[u,d]=j.useState(!1),h=j.useRef(null),m=j.useCallback(()=>{d(!0);const f=Ht.send("context.applyDynamic.preview",{...a?{sessionId:a}:{}});h.current=f;const g=Ht.subscribe(x=>{if(x.id===f&&x.type==="context.preview"){const w=x.payload;c(w.diff??[]),d(!1),h.current=null,g()}});setTimeout(()=>{h.current===f&&(d(!1),h.current=null,g())},5e3)},[]);return j.useEffect(()=>{e&&(c(null),d(!0),m())},[e,m]),s.jsxs(jt,{isOpen:e,onClose:t,title:"Update system prompt",size:"lg",children:[s.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix.",n&&s.jsxs(s.Fragment,{children:[" ","Since the session is currently running, the update will be queued and applied at the start of the next turn."]})]}),u?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):o&&o.length>0?s.jsx(ft,{className:"max-h-[60vh] border border-border rounded-lg",children:s.jsx(oV,{diff:o})}):s.jsx("p",{className:"text-sm text-text-tertiary mb-4",children:"The system prompt hash has changed (e.g., due to tool or skill changes), but the actual prompt text appears identical. Applying the update will still rebuild the cached prompt to ensure consistency."}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:n?"Queue update":"Update"})]})]})}function bA({variant:e="popover",onUpdateSystemPrompt:t}){const{sessionId:n,contextState:r,currentSession:a}=QT(),o=De(A=>A.compactContext),c=JT(),[u,d]=j.useState(!1),[h,m]=j.useState(!1);if(!r||!a)return null;const{currentTokens:f,maxTokens:g,compactionCount:x,dangerZone:w,dynamicContextChanged:C}=r,b=Math.round(f/g*100),_=a.isRunning,S=()=>{c(_),d(!1)},v=e==="sidebar",k=s.jsxs("span",{className:Y9(b,w),children:[Tl(f)," / ",Tl(g)," (",b,"%)"]}),E=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_v,{percent:b,dangerZone:w,className:"flex-1"}),s.jsx(Q9,{dangerZone:w}),x>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),N=s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>m(!h),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:s.jsx(yE,{})}),h&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>m(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1.5 z-50 bg-bg-secondary border border-border rounded-lg shadow-xl py-1 min-w-[160px]",children:[s.jsx("button",{onClick:()=>{!_&&n&&o(n),m(!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:w?"text-accent-error":"",children:"Compact"})}),C&&s.jsx("button",{onClick:()=>{m(!1),t?t():d(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]}),L=t?null:s.jsx(Sv,{isOpen:u,onClose:()=>d(!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:k}),E]}),s.jsx("div",{className:"shrink-0 pt-0.5",children:N})]}),L]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("div",{className:"flex items-center justify-between text-sm",children:k}),E]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("button",{onClick:()=>{!_&&n&&o(n)},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:w?"text-accent-error":"",children:"Compact"})}),C&&s.jsx("button",{onClick:()=>{t?t():d(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors rounded",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]}),L]})}function Dk({messages:e,workdir:t}){var S,v,k;const[n,r]=j.useState(!1),[a,o]=j.useState(!1),[c,u]=j.useState(null),d=f9(e),{branch:h}=xv(),m=nn(E=>E.version),f=De(E=>E.currentSession),g=Tu((f==null?void 0:f.workspace)??"")||null,x=It(E=>E.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",w=bi(E=>E.status),C=bi(E=>E.check),[b,_]=j.useState(!1);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(bA,{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:Ps(d.aiTime)}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:Ck(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:Ck(d.avgGenerationSpeed)}),s.jsx("span",{children:"tg"})]})}),s.jsx(k9,{isOpen:n,onClose:()=>r(!1),stats:d})]}),s.jsx(ft,{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(bf,{entries:((S=f==null?void 0:f.metadataEntries)==null?void 0:S.criteria)??[],title:"Acceptance Criteria"})}),f&&s.jsx(sA,{entries:((v=f==null?void 0:f.metadataEntries)==null?void 0:v.criteria)??[],sessionId:f.id}),f&&(()=>{const E=["review_findings","todos"],N=f.metadataEntries??{},L=E.filter(O=>O in N),A=Object.keys(N).filter(O=>O!=="criteria"&&!E.includes(O)).sort();return[...L,...A].filter(O=>{var I;return(((I=N[O])==null?void 0:I.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(bf,{entries:N[O],title:Sl(O)})}),s.jsx(nA,{entries:N[O],onClearAll:async()=>{try{await xe(`/api/sessions/${f.id}/metadata/${O}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(I){console.error(`Failed to clear ${O}:`,I)}}})]},O))})()]})}),s.jsx(xA,{workspaceName:g??"original",branch:h,workdir:t,showEditorLink:x,sessionId:(f==null?void 0:f.id)??"",projectId:(f==null?void 0:f.projectId)??""}),s.jsx(lA,{workdir:t}),s.jsx(W9,{sessionId:f==null?void 0:f.id}),m&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[s.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",s.jsxs("span",{className:"font-mono",children:["v",m]}),s.jsx("button",{onClick:()=>{_(!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(Uf,{className:`w-3 h-3 ${w==="checking"?"animate-spin":""}`})})]}),w==="available"&&s.jsx("button",{onClick:()=>o(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),b&&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(BE,{isOpen:a,onClose:()=>o(!1),versionInfo:null}),s.jsx(rA,{isOpen:c!==null,onClose:()=>u(null),entries:((k=f==null?void 0:f.metadataEntries)==null?void 0:k[c??""])??[],sessionId:(f==null?void 0:f.id)??"",metadataKey:c??"",title:Sl(c??"")})]})}function lV({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r,sessionId:a}){const o=pn(a,d=>d.session??null,d=>d.currentSession,null),{width:c,handleMouseDown:u}=GT({initialWidth:320,minWidth:240,maxWidth:600,direction:"right"});return s.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&s.jsx("div",{className:"absolute @md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),s.jsxs("div",{className:"flex h-full",children:[s.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?s.jsxs("aside",{className:"hidden @md:block shrink-0 border-l border-border bg-secondary relative",style:{width:c},children:[s.jsx(qT,{side:"left",onMouseDown:u}),s.jsx(ft,{className:"h-full p-4",children:s.jsx(Dk,{messages:r,workdir:(o==null?void 0:o.workspace)??(o==null?void 0:o.workdir)})})]}):s.jsx("aside",{className:"hidden @md:block w-0 shrink-0 overflow-hidden border-l-0"}),s.jsx("aside",{className:`
293
+ @md:hidden
294
+ bg-secondary
295
+ transition-all duration-300 ease-in-out
296
+ absolute right-0 top-0 h-full z-50
297
+ ${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
298
+ `,children:s.jsx("div",{className:"h-full p-4",children:s.jsx(ft,{className:"h-full",children:s.jsx(Dk,{messages:r,workdir:(o==null?void 0:o.workspace)??(o==null?void 0:o.workdir)})})})})]})]})}function cV(){const{sessionId:e,contextState:t,currentSession:n}=QT(),r=De(C=>C.pendingUpdate),a=De(C=>C.triggerPendingUpdate),o=JT(),[c,u]=j.useState(!1),[d,h]=j.useState(!1),m=j.useRef(!1),f=j.useRef(!1);if(j.useEffect(()=>{t!=null&&t.dynamicContextChanged&&!m.current&&u(!1),m.current=(t==null?void 0:t.dynamicContextChanged)??!1},[t==null?void 0:t.dynamicContextChanged]),j.useEffect(()=>{const C=(n==null?void 0:n.isRunning)??!1;f.current&&!C&&r&&r===e&&a(),f.current=C},[n==null?void 0:n.isRunning,r,e,a]),!t||!n)return null;const{dynamicContextChanged:g}=t,x=n.isRunning,w=()=>{o(x),u(!0),h(!1)};return s.jsxs(s.Fragment,{children:[g&&!c&&s.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[s.jsx("span",{children:"System prompt has changed —"}),s.jsx("button",{onClick:()=>h(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),s.jsx("button",{onClick:()=>u(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:s.jsx(Ss,{})})]})}),s.jsx(Sv,{isOpen:d,onClose:()=>h(!1),isRunning:x,onApply:w})]})}function uV({stats:e,onClose:t}){var u;const n=ct(d=>d.defaults),r=ct(d=>d.userItems),o=[...n,...r].find(d=>d.id===e.mode),c=(o==null?void 0:o.name)??e.mode;return s.jsx(jt,{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(bh,{label:"Total Time",value:Ps(e.totalTime)}),s.jsx(bh,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),s.jsx(bh,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),s.jsx(bh,{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(vh,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&s.jsx(vh,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&s.jsx(vh,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&s.jsx(vh,{label:"maxTok",value:String(d.maxTokens)})]})]})]},h))]})]})})}function bh({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 vh({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 dV=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(hn,{horizontal:!0,className:"ml-1.5 mt-0.5",children:s.jsx(nr,{content:t})})]}):s.jsx(hn,{horizontal:!0,className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:s.jsx(nr,{content:t,muted:!0})})});function vA({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 hV={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"}},Ok=j.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(o=>o.severity==="error"),r=t.filter(o=>o.severity==="warning"),a=t.filter(o=>o.severity==="info"||o.severity==="hint");return s.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[s.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[s.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&s.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&s.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&s.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),s.jsx(hn,{className:"max-h-48",children:t.map((o,c)=>{const u=hV[o.severity];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${u.bg} border-b border-border last:border-b-0`,children:[s.jsx("span",{className:`${u.color} text-xs flex-shrink-0 w-4 text-center`,children:u.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",o.range.start.line+1,":",o.range.start.character+1]}),o.code&&s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",o.code,"]"]})]}),s.jsx("div",{className:"text-xs text-text-primary break-words",children:o.message})]})]},c)})})]})}),fV=j.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:o,result:c,error:u,durationMs:d}){const h=j.useRef(null),[m,f]=j.useState(0),g=Bu(h),{setAutoScroll:x,force_scroll_to_bottom:w,handleScrollbarGesture:C}=Pu(h,null,g);j.useEffect(()=>{o==="pending"?x(!0):(w(),x(!1))},[o,x,w]),j.useEffect(()=>{if(o!=="pending"||!r)return;const v=setInterval(()=>{f(Date.now()-r)},100);return()=>clearInterval(v)},[o,r]);const b=n/1e3,_=o==="pending"?m/1e3:(d??0)/1e3,S=o==="pending"?(a==null?void 0:a.map(v=>v.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:[o==="pending"&&s.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),o==="interrupted"&&s.jsx("span",{className:"text-red-400",children:"interrupted"}),s.jsxs("span",{className:o==="pending"?"text-text-secondary":"text-text-muted",children:[_.toFixed(1),"s / ",b,"s"]})]})]}),o==="pending"&&s.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,m/n*100)}%`}})}),(S||o==="pending")&&s.jsx(ft,{ref:h,onScrollbarGesture:C,className:`text-xs bg-bg-primary p-2 rounded max-h-64 ${o==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:o==="pending"&&a?a.map((v,k)=>s.jsx("span",{className:v.stream==="stderr"?"text-accent-warning":"",children:vf(v.content)},k)):vf(S)}),o==="error"&&u&&s.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})}),Wc=j.memo(function({className:t=""}){return s.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})});function _A(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(ft,{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 mV=j.memo(function({result:t,action:n}){const r=_A(t,"DevServerView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?pV(a):gV(a)});function pV(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(hn,{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 gV(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 xV=j.memo(function({result:t,action:n}){const r=_A(t,"BackgroundProcessView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?yV(a):n==="list"?bV(a):n==="status"?vV(a):n==="start"||n==="stop"?_V(a):s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),s.jsx(hn,{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 yV(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(hn,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((a,o)=>s.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},o))}),n&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function bV(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(SA,{process:a},a.id)),n!=null&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function vV(e){const t=e.process,n=e.uptime;return t?s.jsxs("div",{className:"space-y-2",children:[s.jsx(SA,{process:t}),n!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",SV(n)]})]}):s.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function _V(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,o=a==="running"?"text-accent-success":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[n&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Name:"}),s.jsx("span",{className:"font-medium",children:n})]}),t&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"ID:"}),s.jsx("span",{className:"font-mono",children:t})]}),r!=null&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"PID:"}),s.jsx("span",{className:"font-mono",children:r})]}),a&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Status:"}),s.jsx("span",{className:`font-medium ${o}`,children:a})]})]})}function SA({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 SV(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 wV=j.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(hn,{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 CV(r);case"switch":case"delete":return kV(r);default:return s.jsx(hn,{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 CV(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 Dx({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 kV(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(Dx,{label:"Name",value:e.workspace,mono:!0}),e.path&&s.jsx(Dx,{label:"Path",value:e.path,mono:!0}),e.branch&&s.jsx(Dx,{label:"Branch",value:e.branch,mono:!0})]})}const jV={todo:{label:"To Do",className:"bg-accent-warning/10 text-accent-warning border-accent-warning/30"},in_progress:{label:"In Progress",className:"bg-accent-primary/10 text-accent-primary border-accent-primary/30"},done:{label:"Done",className:"bg-accent-success/10 text-accent-success border-accent-success/30"}},EV=new Set(["get","create","edit","move","set_gate_value","duplicate","reorder"]),NV=j.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(Ox,{result:t})}if(n==="list")return s.jsx(hn,{className:"max-h-[60vh]",children:s.jsx(TV,{data:r})});if(n==="set_gates"){const a=r.gates;return s.jsx(hn,{className:"max-h-[60vh]",children:s.jsx(AV,{gates:Array.isArray(a)?a:[]})})}if(n==="delete"){const a=r.message;return typeof a=="string"&&a.trim()!==""?s.jsx("div",{className:"text-xs text-text-primary",children:a}):s.jsx(Ox,{result:t})}return EV.has(n)?s.jsx(hn,{className:"max-h-[60vh]",children:s.jsx(wA,{task:kA(r)})}):s.jsx(Ox,{result:t})});function Ox({result:e}){return s.jsx(hn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}function TV({data:e}){const t=(e.tasks??[]).map(kA),n=e.gates??[],r=t.filter(u=>u.status==="todo"),a=t.filter(u=>u.status==="in_progress"),o=t.filter(u=>u.status==="done"),c=t.filter(u=>u.status!=="todo"&&u.status!=="in_progress"&&u.status!=="done");return s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-text-muted",children:["Task board · ",t.length," task",t.length===1?"":"s",n.length>0&&s.jsxs("span",{children:[" — Gates: ",n.map(u=>`${u.name} (${u.required?"required":"optional"})`).join(", ")]})]}),t.length===0?s.jsx("div",{className:"text-text-muted italic",children:"No tasks on the board"}):s.jsxs(s.Fragment,{children:[s.jsx(_h,{title:"To Do",tasks:r}),s.jsx(_h,{title:"In Progress",tasks:a}),s.jsx(_h,{title:"Done",tasks:o}),s.jsx(_h,{title:"Other",tasks:c})]})]})}function _h({title:e,tasks:t}){return t.length===0?null:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"text-text-muted",children:[e," · ",t.length]}),t.map(n=>s.jsx(wA,{task:n},n.id))]})}function wA({task:e}){const t=jV[e.status]??{label:e.status,className:"bg-bg-tertiary text-text-secondary border-border"};return s.jsxs("div",{className:"rounded-md border border-border bg-bg-tertiary px-2.5 py-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:`inline-flex items-center rounded border px-1.5 py-0.5 text-[10px] font-medium ${t.className}`,children:t.label}),e.runState==="running"&&s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-success",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success animate-pulse"}),"Running"]}),e.runState==="queued"&&s.jsxs("span",{className:"inline-flex items-center rounded border border-accent-warning/40 bg-accent-warning/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-warning",children:["Queued · #",e.queuePosition??1]})]}),s.jsx("p",{className:"mt-1 text-sm text-text-primary leading-snug break-words whitespace-pre-wrap line-clamp-3",children:e.prompt}),s.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-text-muted",children:[e.boundSession&&s.jsxs("span",{children:["Bound: ",e.boundSession]}),e.model&&s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-secondary border border-border",children:e.model}),e.attachments!==void 0&&e.attachments>0&&s.jsxs("span",{children:[e.attachments," attachment",e.attachments===1?"":"s"]}),e.gates.map(n=>s.jsxs("span",{className:"font-mono px-1.5 py-0.5 rounded border border-border bg-bg-secondary",children:[n.gateId,": ",n.value]},n.gateId))]})]})}function AV({gates:e}){return s.jsxs("div",{className:"space-y-1 text-xs",children:[s.jsx("div",{className:"text-text-muted mb-1",children:"Gate configuration"}),e.length===0?s.jsx("div",{className:"text-text-muted italic",children:"No gates configured"}):e.map(t=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"font-mono text-accent-primary shrink-0",children:t.id}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"text-text-primary",children:[t.name," ",s.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-tertiary text-[10px]",children:t.required?"required":"optional"}),t.variant&&s.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-tertiary text-[10px]",children:t.variant})]}),t.description&&s.jsx("div",{className:"text-text-muted",children:t.description})]})]},t.id))]})}function CA(e){return typeof e=="object"&&e!==null?e:null}function Xi(e){return typeof e=="string"?e:""}function Ik(e){return typeof e=="number"?e:void 0}function LV(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=CA(n);if(!r)continue;const a=Object.keys(r).find(c=>c!=="actor"&&c!=="timestamp");if(!a)continue;const o=r[a];typeof o=="string"&&t.push({gateId:a,value:o})}return t}function kA(e){const t=CA(e)??{},n=Xi(t.runState),r=Ik(t.queuePosition),a=Ik(t.attachments);return{id:Xi(t.id),prompt:Xi(t.prompt),status:Xi(t.status),...n?{runState:n}:{},...r!==void 0?{queuePosition:r}:{},...Xi(t.boundSession)?{boundSession:Xi(t.boundSession)}:{},...Xi(t.model)?{model:Xi(t.model)}:{},...a!==void 0?{attachments:a}:{},gates:LV(t.gateValues)}}function RV(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 DV({confirmation:e}){const t=Fr(),n=De(f=>f.confirmPath),r=De(f=>f.switchDangerLevel),{title:a,description:o}=RV(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",m=()=>{t&&(r(t,"dangerous"),n(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(iy,{}),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:o})]})]}),s.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[s.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),s.jsx(ft,{className:"bg-bg-primary rounded p-2 mb-3 max-h-24",children:s.jsx("ul",{className:"space-y-0.5",children:e.paths.map((f,g)=>s.jsx("li",{className:`text-xs font-mono ${c?"text-red-300":"text-amber-300"} break-all`,children:f},g))})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>t&&n(t,e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),s.jsx("button",{onClick:()=>t&&n(t,e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),s.jsx("button",{onClick:m,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${h?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function OV(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,o=t.limit,c=[];return a!==void 0&&a!==1&&c.push(`offset=${a}`),o!==void 0&&c.push(`limit=${o}`),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??"");if(e==="project_tasks"){const r=String(t.action??""),a=t.taskId?String(t.taskId):"";let o=a?`${r}: ${a}`:r;return r==="move"&&t.to&&(o+=` → ${String(t.to)}`),r==="set_gate_value"&&t.gateId&&(o+=` (${String(t.gateId)})`),o}const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function Mk(e,t,n){var a;const r=OV(e,t);if(e==="read_file"&&n){const o=n.format,c=n.pageCount;if(o==="pdf"&&c!=null)return`${r} (PDF, ${c}p)`;if(o==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const o=n.contentType;if(o){const c=((a=o.split(";")[0])==null?void 0:a.trim())??"";if(c&&c!=="text/html")return`${r} (${c})`}}return r}function IV(e){return JSON.stringify(e,null,2)}const Pk={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},MV=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),PV=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]),BV=new Set(["-p","-f","-d","-P"]);function Bk(e){return e.split(/[\\/]/).pop()??e}function $V(e){const t=[];let n=null,r=!1;for(let a=0;a<e.length;a+=1){const o=e[a];if(r){r=!1;continue}if(o==="\\"&&n!=="'"){r=!0;continue}if(o==="'"||o==='"'){n=n===o?null:n===null?o:n;continue}if(n)continue;if(o==="#"&&(a===0||/\s|[;&|(){}]/.test(e[a-1])))break;if(o!=="<"||e[a-1]==="<"||e[a+1]!=="<"||e[a+2]==="<")continue;let c=a+2;const u=e[c]==="-";for(u&&(c+=1);/\s/.test(e[c]??"");)c+=1;let d="",h=null,m=!1,f=!0;for(;c<e.length;){const g=e[c];if(!h&&/\s|[;&|(){}<>]/.test(g))break;if(g==="'"||g==='"'){f=!1,h===g?(h=null,m=!1):h===null&&(h=g),c+=1;continue}if(!h&&g==="$"&&e[c+1]==="'"){f=!1,m=!0,h="'",c+=2;continue}if(g==="\\"&&c+1<e.length){if(f=!1,m){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:f}),a=c}return t}function FV(e){const t=e.split(`
302
+ `),n=[],r=[],a=[];for(const o of t){if(a.length>0){const c=a[0],u=c.stripTabs?o.replace(/^\t+/,""):o;u===c.delimiter?a.shift():c.expandable&&r.push(u);continue}n.push(o),a.push(...$V(o))}return{command:n.join(`
303
+ `),expandableBodies:r}}function $k(e,t=!0){const n=[];let r=null,a=!1,o=!1,c=!1;for(let u=0;u<e.length;u+=1){const d=e[u];if(o){(d===`
304
+ `||d==="\r")&&(o=!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){o=!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,m=null,f=!1;for(let g=u+2;g<e.length;g+=1){const x=e[g];if(f){f=!1;continue}if(x==="\\"&&m!=="'"){f=!0;continue}if(x==="'"||x==='"'){m=m===x?null:m===null?x:m;continue}if(!m&&(x==="("&&(h+=1),x===")"&&(h-=1),h===0)){n.push(e.slice(u+2,g)),u=g;break}}}}}return n}function zV(e){const t=[];let n="",r=!1,a=null,o=!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(o){r=!0,n+=h,o=!1;continue}if(h==="\\"&&a!=="'"){o=!0;continue}if(a){h===a?a=null:n+=h;continue}if(h==="'"||h==='"'){r=!0,a=h;continue}if(h==="$"&&e.slice(d,d+3)==="$(("){let m=1;const f=d;for(let g=d+3;g<e.length-1;g+=1)if(e.slice(g,g+2)==="(("&&(m+=1),e.slice(g,g+2)==="))"&&(m-=1),m===0){r=!0,n+=e.slice(f,g+2),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 o&&(n+="\\"),u(),t}function rl(e,t,n){for(;t<e.length;){const r=e[t];if(r==="--")return t+1;if(!r.startsWith("-")||r==="-")return t;t+=1,!r.includes("=")&&n.has(r)&&(t+=1)}return t}function Zr(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=Bk(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?Ka(h,t+1):null}const d=u.match(/^--split-string=(.*)$/s);if(d)return Ka(d[1],t+1)}for(n=rl(e,n+1,PV);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return Zr(e.slice(n),t+1)}if(r==="sudo")return n=rl(e,n+1,MV),Zr(e.slice(n),t+1);if(r==="sshpass")return n=rl(e,n+1,BV),Zr(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 Ka(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],m=h.indexOf("#");if(m!==-1){const f=Bk(h.slice(m+1).split("@")[0]),g=Pk[f.toLowerCase()];if(g)return g}}return null}return null}return null}const a=r,o=Pk[a];if(o)return o;if(a==="command"){if(e.slice(n+1).some(u=>u==="-v"||u==="-V"))return null;const c=rl(e,n+1,new Set);return Zr(e.slice(c),t+1)}if(a==="setsid"||a==="nohup"){const c=rl(e,n+1,new Set);return Zr(e.slice(c),t+1)}if(a==="timeout"){const c=rl(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return Zr(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?Ka(h,t+1):null}if(!u.startsWith("-"))break}}return null}function Ka(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=FV(e),a=[...$k(n),...r.flatMap(f=>$k(f,!1))];for(const f of a){const g=Ka(f,t+1);if(g)return g}const o=zV(n);let c=[];const u=new Set([";","|","&","(",")","{","}"]),d=new Set(["then","do","else","elif","if","while","until"]);let h=!1,m=!1;for(const f of o){if(f==="for"||f==="select"){const g=Zr(c,t);if(g)return g;c=[],h=!0;continue}if(f==="case"){const g=Zr(c,t);if(g)return g;c=[],m=!0;continue}if(h){f==="do"&&(h=!1);continue}if(m&&f===")"){c=[];continue}if(u.has(f)){const g=Zr(c,t);if(g)return g;c=[]}else if(d.has(f)){const g=Zr(c,t);if(g)return g;c=[]}else if(f==="fi"||f==="done"||f==="esac"){const g=Zr(c,t);if(g)return g;c=[],f==="esac"&&(m=!1)}else c.push(f)}return Zr(c,t)}function HV(e,t){return e!=="run_command"||typeof t.command!="string"?null:Ka(t.command)}const UV=600;function VV(e,t,n){let r=(e==null?void 0:e.length)??0;if(t)for(const o of t)r+=o.content.length;const a=n.content;return typeof a=="string"&&(r+=a.length),r}const WV={dev_server:mV,workspace:wV,project_tasks:NV,background_process:xV},GV={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}},qV=j.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:o,result:c,error:u,durationMs:d,diagnostics:h,editContext:m,startedAt:f,streamingOutput:g,metadata:x,truncated:w,callId:C}){var I;const{collapseLargeToolCalls:b}=Fs(),_=!o&&(!b||r==="pending"||VV(c,g,n)<UV),[S,v]=j.useState(_),k=GV[r],E=HV(t,n),N=It(F=>F.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",L=t==="edit_file"?(I=m==null?void 0:m.regions[0])==null?void 0:I.startLine:t==="read_file"?(()=>{const F=c==null?void 0:c.split(`
307
+ `)[0],B=F==null?void 0:F.match(/^(\d+): /);return B?parseInt(B[1],10):void 0})():void 0,A=De(F=>F.pendingPathConfirmations),O=C?A.find(F=>F.callId===C||F.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 ${E?"border-text-thinking/60 bg-text-thinking/10":"border-transparent bg-secondary"}`,children:[s.jsx(vA,{tool:t}),s.jsx("span",{className:"text-accent-primary font-medium",children:t}),s.jsx("span",{className:"text-text-muted truncate flex-1",children:Mk(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 ${E?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:[s.jsxs("button",{className:`w-full flex items-center gap-1.5 p-2 text-left ${E?"bg-text-thinking/10 hover:bg-text-thinking/15":"bg-secondary hover:bg-secondary/80"}`,onClick:()=>v(!S),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:Mk(t,n,x)}),s.jsx("span",{className:"text-text-muted text-xs",children:S?"▼":"▶"})]}),S&&s.jsxs("div",{className:`p-2 border-t space-y-2 min-w-0 ${E?"border-text-thinking/40 bg-text-thinking/5":"border-border bg-primary"}`,children:[t==="run_command"&&s.jsx(fV,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:f,streamingOutput:g,status:r,result:c,error:u,durationMs:d}),t==="edit_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[m&&m.regions.length>0?s.jsx(tV,{regions:m.regions,filePath:String(n.path??"")}):s.jsx(Z9,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(Ok,{diagnostics:h})]}),t==="write_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[s.jsx(eV,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(Ok,{diagnostics:h})]}),t==="read_file"&&r==="success"&&s.jsx(iV,{result:c,metadata:x,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const F=(g==null?void 0:g.map(z=>z.content).join(""))??"",B=r==="pending"&&F?F: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(nr,{content:B})})]})})(),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(hn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(nr,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&s.jsxs("div",{children:[s.jsx(hn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(nr,{content:c??""})}),w&&s.jsx(Wc,{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(hn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(nr,{content:c??""})}),w&&s.jsx(Wc,{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(hn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(nr,{content:c??""})}),w&&s.jsx(Wc,{})]}),(()=>{const F=WV[t];return!F||r!=="success"||!c?null:s.jsx(F,{result:c,action:String(n.action??"")})})(),t==="mcp_config"&&r==="success"&&s.jsxs("div",{children:[s.jsx(hn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(nr,{content:c??""})}),w&&s.jsx(Wc,{className:"mt-1"})]}),t==="step_done"&&null,t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&t!=="call_sub_agent"&&t!=="web_search"&&t!=="load_skill"&&t!=="web_fetch"&&t!=="dev_server"&&t!=="workspace"&&t!=="project_tasks"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&s.jsxs(s.Fragment,{children:[Object.keys(n).length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),s.jsx(hn,{horizontal:!0,children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:IV(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(hn,{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(Wc,{className:"mt-1"})]})]}),(E||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"}),N&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((x==null?void 0:x.path)??n.path??"")&&s.jsx("a",{href:dA(String((x==null?void 0:x.path)??n.path),L),className:"text-accent-primary hover:underline",children:"Open in VSCode"}),E&&s.jsxs("span",{className:"shrink-0 rounded border border-text-thinking/50 bg-text-thinking/15 px-1.5 py-0.5 font-semibold tracking-wide text-text-thinking",children:["REMOTE · ",E]})]}),r==="error"&&u&&t!=="run_command"&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:u})]}),O&&s.jsx(DV,{confirmation:O})]})]})}),KV={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 YV(e,t){const n=KV[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const o=m9(a);return`${n} ${o}`}}catch{}return n}function XV(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 QV=j.memo(function({name:t,arguments:n}){let a=YV(t,n)+"...",o=null;if(t==="run_command"&&n){const c=XV(n);c&&(a=c,o=Ka(c))}return s.jsx("div",{className:`border rounded overflow-hidden my-1 min-w-0 animate-pulse ${o?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:s.jsxs("div",{className:`flex items-center gap-1.5 p-2 ${o?"bg-text-thinking/10":"bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),s.jsx(vA,{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})]})})}),JV={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},ZV=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=JV[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 eW(e){if(e==null)return;if(typeof e=="string"){const n=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?n.map(r=>({value:r,label:r})):void 0}if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n=="string"){const r=n.trim();r.length>0&&t.push({value:r,label:r});continue}if(n!=null&&typeof n=="object"){const r=n,a=r.label,o=r.value;if(typeof a=="string"&&a.trim().length>0){const c=a.trim(),u=typeof o=="string"&&o.length>0?o: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 tW({toolCall:e}){var N;const t=Fr(),n=L3(t),r=De(L=>L.answerQuestion),[a,o]=j.useState(""),c=j.useRef(null),u=j.useRef(null),d=n.find(L=>L.callId===e.id),h=e.arguments.question??(d==null?void 0:d.question)??"",m=e.arguments.type??(d==null?void 0:d.type)??"text",f=e.arguments.options??(d==null?void 0:d.options)??void 0,g=eW(f),x=e.result!==void 0,w=d!==void 0&&!x,C=((N=e.result)==null?void 0:N.output)??"",b=C==="[user skipped]";j.useEffect(()=>{w&&Vt()&&c.current&&c.current.focus()},[w]),j.useEffect(()=>{w&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[w]);const _=j.useCallback(()=>{!d||!t||r(t,d.callId,a)},[d,a,r,t]),S=j.useCallback(()=>{!d||!t||r(t,d.callId,"",!0)},[d,r,t]),v=j.useCallback(L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),_()),L.key==="Escape"&&!L.shiftKey&&(L.preventDefault(),S())},[_,S]),k=j.useCallback(L=>{!d||!t||r(t,d.callId,L)},[d,r,t]),E="px-3 py-1.5 text-xs font-medium rounded transition-colors";return s.jsxs("div",{ref:u,className:"my-1",children:[s.jsx("div",{className:"text-sm text-text-primary",children:h}),w&&s.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:s.jsx("div",{className:"p-3 bg-primary space-y-2",children:m==="confirm"?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>k("yes"),className:`${E} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),s.jsx("button",{onClick:()=>k("no"),className:`${E} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),s.jsx("button",{onClick:S,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):m==="choice"&&g!==void 0&&g.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-col gap-1.5",children:g.map((L,A)=>s.jsxs("button",{onClick:()=>k(L.value),className:`${E} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:[s.jsx("span",{className:"block font-medium",children:L.label}),L.description!==void 0&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:L.description})]},A))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("textarea",{ref:c,value:a,onChange:L=>o(L.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:!a.trim(),className:`${E} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),s.jsx("button",{onClick:S,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:c,value:a,onChange:L=>o(L.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:Vt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:S,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),s.jsx("button",{onClick:_,disabled:!a.trim(),className:`${E} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),x&&s.jsx("div",{className:"mt-1 flex items-center gap-2",children:s.jsx("span",{className:`text-xs ${b?"text-amber-400":"text-accent-success"}`,children:b?"Skipped":`Answered: ${C}`})})]})}const Fk={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"}},nW=new Set(["get","list","schema"]),rW=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.some(u=>u.name==="session_metadata"),o=t.flatMap(u=>nW.has(String(u.arguments.action))?iW(u):[sW(u,r)]),c=(()=>{if(!a)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?Sl(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:o.map((u,d)=>s.jsx("div",{className:`flex items-start gap-2 px-2 py-1.5 ${d>0?"border-t border-border":""}`,children:u.node},u.key))})]})});function sW(e,t){return{key:e.id,node:s.jsx(aW,{tc:e,criteriaMap:t})}}function iW(e){var n,r;const t=(n=e.result)==null?void 0:n.output;if(e.result&&!e.result.success)return[{key:`${e.id}-error`,node:s.jsx("span",{className:"text-text-muted text-sm",children:e.result.error??"Read failed."})}];if(!((r=e.result)!=null&&r.success)||!t)return[{key:`${e.id}-empty`,node:s.jsx("span",{className:"text-text-muted text-sm",children:"No output."})}];if(e.arguments.action==="get")try{const a=JSON.parse(t);if(Array.isArray(a))return a.map((o,c)=>({key:`${e.id}-${c}`,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(nr,{content:`[${o.id}] ${o.description}`})})]})}))}catch{}if(e.arguments.action==="schema"){const a=e.arguments.key;return[{key:e.id,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-accent-success text-sm leading-tight flex-shrink-0",children:"✓"}),s.jsx("div",{className:"flex-1 min-w-0 text-sm",children:a?`Schema loaded for '${a}' metadata`:"Schema loaded."})]})}]}return[{key:e.id,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(nr,{content:t})})]})}]}function aW({tc:e,criteriaMap:t}){const n=e.arguments.action,r=e.arguments,a=e.name==="session_metadata",o=n==="remove",c=r.id,u=r.description,d=c?t.get(c):void 0,m=a?`${(n&&{add:"Added",update:"Updated",remove:"Removed",complete:"Completed",pass:"Passed",fail:"Failed"}[n])??"Managed"} item`:"Criterion updated",f=u??(d==null?void 0:d.description)??(o&&c?`[${c}]`:m),g=r.reason,x=n==="fail";return s.jsxs(s.Fragment,{children:[a?s.jsx(Hl,{status:r.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const w=n&&Fk[n]?Fk[n]:{icon:"○",color:"text-text-muted"};return s.jsx("span",{className:`${w.color} text-sm leading-tight flex-shrink-0`,children:w.icon})})(),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:o?"line-through text-text-muted":"",children:s.jsx(nr,{content:f})}),g&&s.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[s.jsx("span",{className:"text-text-muted",children:"└ "}),'"',g,'"']})]})]})}function oW(e){return e==="criterion"||e==="session_metadata"}const lW="[interrupted by user]";function cW(e){if(!e)return"pending";const t=e.output??"";return!e.success&&t.trimEnd().endsWith(lW)?"interrupted":e.success?"success":"error"}async function jA(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 uW({items:e,position:t,onClose:n}){const r=j.useRef(null),[a,o]=j.useState(-1);if(j.useEffect(()=>{t&&o(-1)},[t]),j.useEffect(()=>{var m;if(!t)return;function d(f){r.current&&!r.current.contains(f.target)&&n()}function h(f){var g;switch(f.key){case"Escape":f.preventDefault(),n();break;case"ArrowDown":f.preventDefault(),o(x=>x<e.length-1?x+1:0);break;case"ArrowUp":f.preventDefault(),o(x=>x>0?x-1:e.length-1);break;case"Enter":f.preventDefault(),(g=e[a])==null||g.onClick(),n();break}}return document.addEventListener("mousedown",d),window.addEventListener("keydown",h,!0),window.addEventListener("blur",n),(m=r.current)==null||m.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),wi.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(ft,{className:"max-h-[60vh]",onMouseLeave:()=>o(-1),children:e.map((d,h)=>s.jsxs("button",{onClick:()=>{d.onClick(),n()},onMouseEnter:()=>o(h),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${h<e.length-1?"border-b border-border":""} ${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 EA(){const[e,t]=j.useState(null);return{onContextMenu:j.useCallback((a,o)=>{var u;if(!o||(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(uW,{position:e,onClose:()=>t(null),items:a})}}function dW(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"&&oW(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function hW(e,t){if(e.segments&&e.segments.length>0)return fW(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 fW(e,t,n,r,a){const o=[],c=new Map(t.map(u=>[u.id,u]));for(const u of e)switch(u.type){case"text":o.push({type:"text",content:u.content});break;case"thinking":u.content&&u.content.trim().length>0&&o.push({type:"thinking",content:u.content});break;case"tool_call":{const d=c.get(u.toolCallId);d&&o.push({type:"tool_call",toolCall:d});break}}for(const u of n)o.push({type:"preparing_tool_call",preparing:u});return a&&r&&o.push({type:"stats",stats:r}),o}const wv=j.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:o}){const c=De(N=>{var L,A;return(A=(L=N.currentSession)==null?void 0:L.metadataEntries)==null?void 0:A.criteria}),u=ct(N=>N.defaults),d=ct(N=>N.userItems),h=[...u,...d],m=hW(t,n),f=r?m:m.filter(N=>N.type!=="thinking"),g=dW(f),[x,w]=j.useState(!1),[C,b]=j.useState(null),[,_]=wn(),{onContextMenu:S,contextMenu:v}=EA();if(g.length===0)return null;const k=()=>{jA(t.content)},E=async()=>{if(!o||x)return;w(!0),b(null);const N=await sE(o,t.id);w(!1),N!=null&&N.session?_(`/p/${N.session.projectId}/s/${N.session.id}`):b("Failed to fork session")};return s.jsxs("div",{className:"feed-item",onContextMenu:N=>S(N,!!o),children:[s.jsxs("div",{className:"min-w-0",children:[C&&s.jsx("p",{className:"text-xs text-accent-error mb-1 ml-0.5",children:C}),g.map((N,L)=>{switch(N.type){case"thinking":return s.jsx(dV,{content:N.content},L);case"text":return s.jsx("div",{className:"prose prose-sm prose-invert max-w-none feed-item",children:s.jsx(nr,{content:N.content,isStreaming:t.isStreaming})},L);case"preparing_tool_call":return s.jsx(QV,{name:N.preparing.name,arguments:N.preparing.arguments},`preparing-${N.preparing.index}`);case"tool_call":{const A=N.toolCall,O=A.result;if(A.name==="ask_user")return s.jsx(tW,{toolCall:A},L);if(A.name==="todo_write"){const F=A.arguments.todos,B=Array.isArray(F)?F:[];return s.jsx(ZV,{todos:B},L)}const I=cW(O);return s.jsx(qV,{tool:A.name,args:A.arguments,status:I,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},L)}case"criteria_group":return s.jsx(rW,{toolCalls:N.toolCalls,criteria:c},L);case"stats":{const A=N.stats;if(!A||"error"in A)return null;const O=A.model.split("/").pop()??A.model,I=oo(h,A.mode),F=h.find(q=>q.id===A.mode),B=(F==null?void 0:F.name)??A.mode,z=q=>q>=1e3?`${(q/1e3).toFixed(1)}k`:q.toString(),Y=q=>q>=1e3?`${(q/1e3).toFixed(1)}k`:q.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:I},children:B}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{children:Ps(A.totalTime)}),A.toolTime>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[Ps(A.toolTime)," tools"]})]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[z(A.prefillTokens)," @ ",Y(A.prefillSpeed)," pp"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[z(A.generationTokens)," @ ",Y(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 q=new CustomEvent("open-turn-stats",{detail:{stats:A}});window.dispatchEvent(q)},children:s.jsx(zf,{className:"w-3 h-3"})}),s.jsx("span",{className:"flex-1 h-px bg-border"})]},L)}}}),t.partial&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[s.jsx(iy,{}),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(iy,{}),s.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),v([{label:"Copy",icon:s.jsx(jl,{className:"w-4 h-4"}),onClick:()=>k()},{label:"Fork session from here",icon:s.jsx(eo,{className:"w-4 h-4"}),onClick:()=>void E()}])]})});function Sf(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 mW(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const pW=j.memo(function({data:t}){var a;const n=pm(),r=(t.workflowId?(a=pf(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:Sf(r,.3),backgroundColor:Sf(r,.08)},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Y3,{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(Gc,{label:"Iterations",value:String(t.iterations)}),s.jsx(Gc,{label:"Total time",value:Ps(t.totalTimeSeconds)}),s.jsx(Gc,{label:"Tool calls",value:String(t.totalToolCalls)}),s.jsx(Gc,{label:"Tokens",value:mW(t.totalTokensGenerated)}),s.jsx(Gc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function Gc({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 gW=j.memo(function({data:t}){var a;const n=pm(),r=((a=pf(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:Sf(r,.3),backgroundColor:Sf(r,.08)},children:[s.jsx(Hf,{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 xW({attachments:e,messageId:t}){const[n,r]=j.useState(null),a=De(m=>m.visionFallbackByMessage),o=De(m=>m.messages),c=j.useMemo(()=>{const m=o.findIndex(f=>f.id===t);if(m===-1)return null;for(let f=m+1;f<o.length;f++){const g=o[f];if(g&&g.role==="assistant")return g.id}return null},[o,t]),u=m=>{r(m)},d=()=>{r(null)},h=m=>{const f=`${t}-${m}`;if(a[f])return a[f];if(c){const g=`${c}-${m}`;return a[g]}return null};return e.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(m=>{const f=h(m.id);return DT(m.mimeType)?s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>u(m.data),className:"group relative inline-block",title:(f==null?void 0:f.type)==="done"&&f.description||m.description||m.filename,disabled:(f==null?void 0:f.type)==="start",children:[s.jsx("img",{src:m.data,alt:(f==null?void 0:f.type)==="done"&&f.description||m.description||m.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(f==null?void 0:f.type)==="start"&&s.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:s.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(f==null?void 0:f.type)==="done"&&f.description&&s.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[f.description.slice(0,200),f.description.length>200?"...":""]})]},m.id):s.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[s.jsx("div",{className:"w-10 h-10 flex items-center justify-center rounded-md bg-bg-secondary text-sm font-bold text-text-muted shrink-0",children:OT(m.filename)}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:m.filename,children:m.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:gl(m.size)}),dv(m.mimeType)&&m.data&&s.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[m.data.slice(0,200),m.data.length>200?"...":""]})]})]},m.id)})}),n&&s.jsx(yA,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function yW({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",o=(r==null?void 0:r.type)??"agent",c=o==="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"}[o]??"injected",h=o==="workflow"||o==="subagent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!h&&n(!0)}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!h&&n(!0),children: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(ft,{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(jt,{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:["(",o,")"]})]}),s.jsx("div",{className:"h-full min-h-96",children:s.jsx(ft,{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 Uy="openfox:feed-reveal",wf="openfox:autoscroll-rearm";function bW({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",o=e.isSystemGenerated,c=De(D=>D.loadSession),[,u]=wn(),[d,h]=j.useState(!1),[m,f]=j.useState(!1),[g,x]=j.useState(!1),[w,C]=j.useState(e.content),[b,_]=j.useState(e.attachments??[]),[S,v]=j.useState(!1),[k,E]=j.useState(!1),[N,L]=j.useState(null),[A,O]=j.useState(null),I=j.useRef(null),{onContextMenu:F,contextMenu:B}=EA(),z=j.useCallback(()=>{const D=I.current;D&&(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},[]),Y=async()=>{try{await jA(e.content),f(!0),window.setTimeout(()=>f(!1),1500)}catch{}},q=async()=>{if(!n||!t||k)return;E(!0),L(null);const D=await sE(n,t);if(E(!1),D!=null&&D.session){const U=D.session.projectId;u(`/p/${U}/s/${D.session.id}`)}else L("Failed to fork session")},W=async()=>{if(!n||!t||S)return;v(!0),O(null);const D=await n1(n,t);v(!1),D?(window.dispatchEvent(new CustomEvent(wf)),c(n,!0)):O("Failed to replay")},ee=async()=>{if(!n||!t||!w.trim()||S)return;v(!0),O(null);const D=await n1(n,t,w,b);v(!1),D?(window.dispatchEvent(new CustomEvent(wf)),c(n,!0),x(!1)):O("Failed to send")},J=()=>{C(e.content),_(e.attachments??[]),x(!1),O(null)},P=`flex items-center gap-0.5 self-end transition-[visibility,opacity] focus-within:visible focus-within:opacity-100 ${d&&!g&&!S?"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:D=>F(D,!!n&&!!t),children:[!o&&s.jsxs("div",{className:P,children:[s.jsx("button",{onClick:()=>{Y()},title:"Copy",disabled:S,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:m?s.jsx(zs,{className:"w-3.5 h-3.5 text-accent-success"}):s.jsx(jl,{className:"w-3.5 h-3.5"})}),n&&t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{O(null),C(e.content),_(e.attachments??[]),x(!0)},title:"Edit & resend",disabled:S,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(pb,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>{W()},title:"Replay",disabled:S,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(Uf,{className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:`max-w-[75%] ${g?"w-full":""} rounded p-2 ${o?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[o&&s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),g?s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("textarea",{ref:D=>{I.current=D,D&&(D.style.height="auto",D.style.height=`${D.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:D=>{C(D.target.value),z()},onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ee()),D.key==="Escape"&&J()},disabled:S,autoFocus:Vt()}),b.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(D=>s.jsx(hv,{attachment:D,onRemove:U=>_($=>$.filter(Q=>Q.id!==U))},D.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:J,disabled:S,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:()=>{ee()},disabled:S||!w.trim(),className:"px-4 py-1.5 rounded text-sm bg-accent-primary/20 text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"Send"})]})]}):s.jsxs(s.Fragment,{children:[(A||N)&&s.jsx("p",{className:"text-xs text-accent-error mb-1",children:A??N}),s.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${o?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&s.jsx(xW,{attachments:e.attachments,messageId:e.id})]})]}),B([{label:"Copy",icon:s.jsx(jl,{className:"w-4 h-4"}),onClick:()=>void Y()},{label:"Fork session from here",icon:s.jsx(eo,{className:"w-4 h-4"}),onClick:()=>void q()}])]})}const NA=j.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const o=t.role==="user",c=t.role==="assistant",u=t.role==="system",d=t.role==="tool";if(c)return s.jsx(wv,{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(hn,{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(gW,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return s.jsx(pW,{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(yW,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?s.jsx("div",{className:"flex justify-end feed-item",children:s.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),s.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):o?s.jsx(bW,{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(nr,{content:t.content})})})}),vW={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function _W(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function zk(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function SW({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,o=Math.round(t/n*100);return s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[s.jsxs("span",{className:zk(o,a),children:[Tl(t),"/",Tl(n)]}),s.jsxs("span",{className:zk(o,a),children:["(",o,"%)"]}),s.jsx(_v,{percent:o,dangerZone:a,size:"sm"}),a&&s.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&s.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const wW=j.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const o=j.useRef(null),c=j.useRef(null),[u,d]=j.useState(!1),h=ct(O=>O.defaults),m=ct(O=>O.userItems),f=[...h,...m],g=De(O=>O.subAgentContextStates[r]),{showThinking:x,showVerboseToolOutput:w}=Fs(),C=Bu(c),{isAutoScrollActive:b,setAutoScroll:_,handleScrollbarGesture:S}=Pu(c,null,C),v=j.useCallback(()=>{const O=!u;d(O),O&&setTimeout(()=>{var I;(I=o.current)==null||I.scrollIntoView({block:"start",behavior:"smooth"})},220)},[u]),k=f.find(O=>O.id===n),E=(k==null?void 0:k.name)??vW[n]??n,N=oo(f,n),L=_W(N),A=t.filter(O=>O.role!=="tool");return s.jsxs("div",{ref:o,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[s.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:L,children:[s.jsx("span",{className:"text-xs font-medium",children:E}),s.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:g&&s.jsx(SW,{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:()=>_(!b),children:[s.jsx("span",{className:`w-1 h-1 rounded-full ${b?"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:v,children:[u?"▼":"▶"," Expand"]})]})]}),s.jsx(ft,{ref:c,className:`${u?"max-h-[calc(100vh-10rem)]":"max-h-80"} p-2 transition-[max-height] duration-200`,onScrollbarGesture:S,children:A.map(O=>O.role==="assistant"?s.jsx(wv,{message:O,showStats:!0,showThinking:x,showVerboseToolOutput:w},O.id):s.jsx(NA,{message:O,isLastAssistantMessage:!1},O.id))})]})}),CW={contentVisibility:"auto",containIntrinsicSize:"auto 200px"},kW={contentVisibility:"auto",containIntrinsicSize:"160px",minHeight:"160px"},Sh=30,Ix=20,jW=10,EW=5;function wh(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 TA=j.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,scrollContainerRef:a,showThinking:o=!0,showVerboseToolOutput:c=!0,showStats:u=!0,showAgentDefinitions:d=!0,showWorkflowBars:h=!0}){const m=t.length,{feedVirtualization:f}=Fs(),[g,x]=j.useState(()=>Math.max(0,m-Sh)),w=j.useRef(null),C=j.useRef(t.length),b=j.useRef(!1),_=f?g:0,S=f?CW:void 0;j.useEffect(()=>{f&&(x(Math.max(0,t.length-Sh)),b.current=!1)},[r]),j.useEffect(()=>{const E=C.current;C.current=t.length,f&&t.length-E>=EW&&!b.current&&x(Math.max(0,t.length-Sh))},[t.length,f]),j.useEffect(()=>{f&&g>0&&g>=t.length&&x(Math.max(0,t.length-Sh))},[t.length,g,f]),j.useEffect(()=>{if(!f||g<=0||typeof IntersectionObserver>"u")return;const E=w.current;if(!E)return;const N=new IntersectionObserver(L=>{L.some(A=>A.isIntersecting)&&x(A=>Math.max(0,A-Ix))},{rootMargin:"0px 0px 300px 0px"});return N.observe(E),()=>N.disconnect()},[g,f]);const v=j.useRef(g);v.current=g,j.useEffect(()=>{var A,O;if(!f)return;const E=a==null?void 0:a.current;if(!E)return;const N=(O=(A=E.osInstance)==null?void 0:A.call(E))==null?void 0:O.elements().viewport;if(!N)return;const L=()=>{if(N.scrollTop>4){b.current=!0;return}v.current>0&&x(I=>Math.max(0,I-Ix))};return N.addEventListener("scroll",L,{passive:!0}),()=>N.removeEventListener("scroll",L)},[a,f]),j.useEffect(()=>{var L,A;if(!f||g<=0||!b.current)return;const E=a==null?void 0:a.current,N=(A=(L=E==null?void 0:E.osInstance)==null?void 0:L.call(E))==null?void 0:A.elements().viewport;N&&N.scrollTop<=4&&x(O=>Math.max(0,O-Ix))},[g,a,f]),j.useEffect(()=>{if(!f)return;const E=N=>{var A;const L=(A=N.detail)==null?void 0:A.index;typeof L=="number"&&x(O=>Math.min(O,Math.max(0,L-jW)))};return window.addEventListener(Uy,E),()=>window.removeEventListener(Uy,E)},[f]);const k=t.slice(_);return s.jsxs(s.Fragment,{children:[_>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 ",_," older item",_!==1?"s":""]}),Array.from({length:_},(E,N)=>s.jsx("div",{"data-item-index":N,"data-placeholder":!0,style:kW},`ph-${N}`)),s.jsx("div",{ref:w,"data-testid":"feed-sentinel",style:{height:1}})]}),k.map((E,N)=>{const L=_+N;if(E.type==="context-divider")return s.jsxs("div",{"data-item-index":L,className:"flex items-center gap-2 feed-item px-2 @md:px-4",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),s.jsx("div",{className:"flex-1 border-t border-border"})]},wh(E));if(E.type==="subagent"){const F=E.messages.some(B=>B.isStreaming);return s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:S,children:s.jsx(wW,{messages:E.messages,subAgentType:E.subAgentType,subAgentId:E.subAgentId,isStreaming:F})},wh(E))}const A=E.message;if(A.role==="assistant")return s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:S,children:s.jsx(wv,{message:A,showStats:u,showThinking:o,showVerboseToolOutput:c,sessionId:r??void 0})},wh(E));const O=!d&&A.messageKind==="auto-prompt",I=!h&&(A.messageKind==="workflow-started"||A.messageKind==="task-completed");return O||I?null:s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:S,children:s.jsx("div",{"data-message-id":A.id,className:n===A.id?"rounded animate-highlight-fade":void 0,children:s.jsx(NA,{message:A,messageId:A.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},wh(E))})]})});function gm(e,t,n=!0){j.useEffect(()=>{if(!n)return;const r=a=>{var o;(o=e.current)!=null&&o.contains(a.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const Mx=[];function NW({retry:e}){const[t]=j.useState(Date.now()),[n,r]=j.useState(Date.now());j.useEffect(()=>{const c=setInterval(()=>r(Date.now()),250);return()=>clearInterval(c)},[]);const a=Math.max(0,Math.ceil((e.retryInMs-(n-t))/1e3)),o=a>0?` — next try in ${a}s…`:"…";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-bg-tertiary/60 border border-border text-xs text-text-secondary",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-primary animate-pulse"}),s.jsxs("span",{children:["LLM call failed — retrying “",e.stepName,"” (attempt ",e.attempt,")",o]})]})}const TW=j.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:o,hiddenCount:c=0,onScrollbarGesture:u,emptyState:d}){const h=Fr(),m=pn(h,X=>{var ne,re;return((re=(ne=X.session)==null?void 0:ne.metadataEntries)==null?void 0:re.criteria)??Mx},X=>{var ne,re;return((re=(ne=X.currentSession)==null?void 0:ne.metadataEntries)==null?void 0:re.criteria)??Mx},Mx),f=pn(h,X=>{var ne;return((ne=X.session)==null?void 0:ne.id)??null},X=>{var ne;return((ne=X.currentSession)==null?void 0:ne.id)??null},null),g=pn(h,X=>{var ne;return((ne=X.session)==null?void 0:ne.phase)??null},X=>{var ne;return((ne=X.currentSession)==null?void 0:ne.phase)??null},null),x=pn(h,X=>X.error??null,X=>X.error,null),w=De(X=>X.clearError),C=$f(h),b=pn(h,X=>X.activeWorkflowExecution??null,X=>X.activeWorkflowExecution,null),_=De(X=>X.continueWorkflow),S=De(X=>X.retryWorkflowStep),v=De(X=>X.workflowRetry),{showThinking:k,showVerboseToolOutput:E,showStats:N,showAgentDefinitions:L,showWorkflowBars:A}=Fs(),O=pm(),I=m.some(X=>X.status==="pending"),F=g==="done",B=t.some(X=>X.type==="message"&&X.message.role==="assistant"),z=(b==null?void 0:b.status)==="running"||(b==null?void 0:b.status)==="waiting",Y=I&&!C&&B&&!F&&!z,q=(b==null?void 0:b.status)==="waiting"&&!C,W=pn(h,X=>{var ne;return((ne=X.session)==null?void 0:ne.projectId)??void 0},X=>{var ne;return(ne=X.currentSession)==null?void 0:ne.projectId},void 0),[ee,J]=j.useState(!1),[H,P]=j.useState(!1),[D,U]=j.useState(!1),$=Bu(n);j.useLayoutEffect(()=>{const X=$();X&&P(X.scrollHeight>X.clientHeight+1)},[$,t]),j.useEffect(()=>{const X=$();if(!X)return;const ne=()=>U(X.scrollTop>4);return ne(),X.addEventListener("scroll",ne,{passive:!0}),()=>X.removeEventListener("scroll",ne)},[$]);const Q=()=>{if(!W||!f)return;J(!1),window.open(`/p/${W}/s/${f}/readonly`,"_blank")||J(!0)},[K,Z]=j.useState(!1),V=j.useCallback(X=>{K||!h||(Z(!0),_(h,X),setTimeout(()=>Z(!1),5e3))},[K,_,h]),M=j.useCallback(()=>{var X;o==null||o(),(X=$())==null||X.scrollTo({top:0,behavior:"smooth"})},[$,o]);return s.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[s.jsx(ft,{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:Q,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"]}),ee&&s.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",s.jsx("a",{href:W&&f?`/p/${W}/s/${f}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),s.jsx(TA,{displayItems:t,highlightedMessageId:r,sessionId:f,scrollContainerRef:n,showThinking:k,showVerboseToolOutput:E,showStats:N,showAgentDefinitions:L,showWorkflowBars:A})]}),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:[v&&C&&s.jsx("div",{className:"flex justify-center feed-item","data-testid":"workflow-retry-indicator",children:s.jsx(NW,{retry:v},v.attempt)}),x&&s.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:x.code}),s.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:x.message})]}),s.jsx(Mu,{onClick:w,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),(b==null?void 0:b.status)==="blocked"&&b.currentStepId&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:s.jsx("button",{onClick:()=>f&&S(f),disabled:C,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/15 text-accent-primary border border-accent-primary/25 hover:bg-accent-primary/25 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:C?"⏳ Resuming...":"↻ Retry step"})}),q&&b&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:(b.pendingChoices&&b.pendingChoices.length>0?b.pendingChoices:[{id:void 0,label:`▶ Continue ${b.workflowName} (${b.currentStepName??"..."})`,goto:"",nextStepName:void 0}]).map(X=>s.jsx("button",{onClick:()=>V(X.id),disabled:K,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:K?"⏳ Continuing...":X.id==="continue"?`▶ Continue ${b.workflowName} (${X.nextStepName??b.currentStepName??"..."})`:X.label},X.id??"continue"))}),Y&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:O.map(X=>{const ne=X.color??"#3b82f6",re=parseInt(ne.slice(1,3),16),ie=parseInt(ne.slice(3,5),16),ge=parseInt(ne.slice(5,7),16),ke=`rgba(${re},${ie},${ge},0.12)`,Oe=`rgba(${re},${ie},${ge},0.22)`,Fe=`rgba(${re},${ie},${ge},0.25)`;return s.jsx(AW,{workflowName:X.name,scope:X.scope,color:ne,bg:ke,bgHover:Oe,border:Fe,subGroups:X.subGroups,onLaunch:we=>a(X.id,we,void 0,X.scope)},`${X.id}-${X.scope}`)})})]})]})}),H&&D&&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:M,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(mb,{className:"w-3 h-3"}),"scroll to top"]})})]})});function AW({workflowName:e,scope:t,color:n,bg:r,bgHover:a,border:o,subGroups:c,onLaunch:u}){const[d,h]=j.useState(!1),m=j.useRef(null);gm(m,()=>h(!1),d);const f=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 ${f?"rounded-l":"rounded"}`,style:{backgroundColor:r,color:n,border:`1px solid ${o}`,...f?{borderRight:"none"}:{}},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:["▶ ",e," ",s.jsx("span",{className:"text-[10px] font-normal opacity-70 whitespace-nowrap",children:mv[t]})]}),f&&s.jsxs("div",{ref:m,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 ${o}`},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 LW(){const e=De(r=>r.connectionStatus),t=De(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(Q3,{}),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 RW(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function DW({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(xb,{})})}function AA({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=dn(fe=>fe.defaults),o=dn(fe=>fe.userItems),c=dn(fe=>fe.projectItems),u=dn(fe=>fe.loading),d=dn(fe=>fe.fetchCommands),h=dn(fe=>fe.fetchCommand),m=dn(fe=>fe.fetchDefaultContent),f=dn(fe=>fe.createCommand),g=dn(fe=>fe.updateCommand),x=dn(fe=>fe.deleteCommand),[w,C]=j.useState(null),[b,_]=j.useState(null),{view:S,editingId:v,formError:k,saving:E,formData:N,setView:L,setEditingId:A,setFormError:O,setFormData:I,setSaving:F}=NE(),{requestDelete:B,clearConfirm:z,isConfirming:Y}=Nu(),q=j.useRef(!1),W=ct(fe=>fe.defaults),ee=ct(fe=>fe.userItems),J=ct(fe=>fe.fetchAgents),P=[...W,...ee].filter(fe=>!fe.subagent),D=j.useRef(d),U=j.useRef(J),$=j.useRef(h),Q=j.useRef(m),K=j.useRef(r),Z=j.useRef(n),V=j.useRef(L),M=j.useRef(A),X=j.useRef(O),ne=j.useRef(z);j.useEffect(()=>{D.current=d,U.current=J,$.current=h,Q.current=m,K.current=r,Z.current=n,V.current=L,M.current=A,X.current=O,ne.current=z}),j.useEffect(()=>{if(e)if(D.current(K.current),U.current(K.current),q.current||(ne.current(),q.current=!0),Z.current){const fe=a.some(oe=>oe.id===Z.current);V.current("edit"),M.current(Z.current),X.current(""),fe?Q.current(Z.current).then(oe=>{oe&&I({name:oe.metadata.name+" (copy)",id:`${Z.current}-copy-${Date.now()}`,prompt:oe.prompt,agentMode:oe.metadata.agentMode??"",isDefault:!0,destination:"user"})}):$.current(Z.current,K.current).then(oe=>{oe&&I({name:oe.metadata.name,id:oe.metadata.id,prompt:oe.prompt,agentMode:oe.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else V.current("list"),M.current(null);else q.current=!1},[e]);const re=async fe=>{C(fe);const oe=await m(fe);_((oe==null?void 0:oe.prompt)??null)},ie=async fe=>{if(a.some(Me=>Me.id===fe)){const Me=await m(fe);Me&&(A(null),I({name:`${Me.metadata.name} (copy)`,id:`${fe}-copy-${Date.now()}`,prompt:Me.prompt,agentMode:Me.metadata.agentMode??"",isDefault:!0,destination:"user"}),O(""),L("edit"))}else{const Me=await h(fe,r);Me&&(A(null),I({name:`${Me.metadata.name} (copy)`,id:`${fe}-copy-${Date.now()}`,prompt:Me.prompt,agentMode:Me.metadata.agentMode??"",isDefault:!1,destination:"user"}),O(""),L("edit"))}},ge=()=>{I({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),A(null),L("edit")},ke=async fe=>{const oe=await h(fe,r);oe&&(A(fe),I({name:oe.metadata.name,id:oe.metadata.id,prompt:oe.prompt,agentMode:oe.metadata.agentMode??"",isDefault:!1,destination:"user"}),O(""),L("edit"))},Oe=async fe=>{await x(fe,r),z()},Fe=async()=>{const fe=v??N.id;if(!fe||!N.name||!N.prompt){O("Name and message are required.");return}F(!0),O("");const oe={metadata:{id:fe,name:N.name,...N.agentMode?{agentMode:N.agentMode}:{}},prompt:N.prompt},Me=v?await g(v,oe,r):await f(oe,N.destination,r);if(F(!1),!Me.success){O(Me.error??"Failed to save command.");return}n?t():L("list")},we=()=>{n?t():(L("list"),C(null),_(null))},We=fe=>{I(oe=>({...oe,name:fe})),(!v||N.isDefault)&&I(oe=>({...oe,id:RW(fe)}))},Xe=()=>{C(null),_(null),L("list")},_e=()=>{w&&(C(null),L("edit"),A(w),m(w).then(fe=>{fe&&I({name:`${fe.metadata.name} (copy)`,id:`${w}-copy-${Date.now()}`,prompt:fe.prompt,agentMode:fe.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(w){const fe=a.find(oe=>oe.id===w);return s.jsx(jt,{isOpen:e,onClose:Xe,title:`Default: ${(fe==null?void 0:fe.name)??w}`,size:"xl",children:s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),s.jsx("span",{className:"font-mono",children:w})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:fe==null?void 0:fe.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:(fe==null?void 0:fe.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:b??"",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(st,{variant:"secondary",onClick:Xe,children:"Close"}),s.jsx(st,{variant:"primary",onClick:_e,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return s.jsx(jt,{isOpen:e,onClose:we,title:v?"Edit Command":"New Command",size:"xl",footer:s.jsx(wE,{onCancel:we,onSave:Fe,saving:E,saveDisabled:!N.name||!N.prompt}),children:s.jsxs("div",{className:"flex flex-col h-full",children:[k&&s.jsx(vl,{message:k}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(EE,{name:N.name,id:N.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!v&&!N.isDefault,onNameChange:We,onIdChange:fe=>I(oe=>({...oe,id:fe}))}),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:fe=>I(oe=>({...oe,agentMode:fe.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)"}),P.map(fe=>s.jsx("option",{value:fe.id,children:fe.name},fe.id))]})]}),!v&&s.jsx(Gf,{value:N.destination,onChange:fe=>I(oe=>({...oe,destination:fe}))})]}),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:fe=>I(oe=>({...oe,prompt:fe.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 ye=fe=>fe.map(oe=>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:oe.name})})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(vi,{onClick:()=>ke(oe.id)}),s.jsx(gu,{onClick:()=>ie(oe.id)}),Y(oe.id,"delete")?s.jsx(Yh,{onConfirm:()=>Oe(oe.id),onCancel:z}):s.jsx(Xh,{onClick:()=>B(oe.id)})]})]},oe.id));return s.jsxs(jt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[s.jsx(jE,{description:"Commands are pre-defined messages you can send with a single click.",onNew:ge}),s.jsxs(Cb,{loading:u,hasItems:a.length>0||o.length>0||c.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[a.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:a.map(fe=>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:fe.name})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(DW,{onClick:()=>re(fe.id)}),s.jsx(gu,{onClick:()=>ie(fe.id)})]})]},fe.id))})]}),o.length>0&&s.jsx(kE,{children:ye(o)}),c.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:ye(c)})]})]})]})}function OW({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(yn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),e]}),s.jsx("div",{className:"mt-2 space-y-2",children:n})]})}const $a=150,ui=54,Ch=80,ds=30,sl=70,Hk=100,Fa=50,kh=50,Uk=4,LA={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},RA=[{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)"}],IW=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"},{value:"user",label:"User (pause)"}];function Cv(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 MW(e,t,n,r){const a=kh+Fa+$a+Hk+$a+Fa+kh,o=a/2,c=kh+Fa+$a/2,u=kh+Fa+$a+Hk+$a/2,d=[],h=[],m=new Map,f=e.filter(q=>q.type==="agent"||q.type==="shell"||q.type==="user"),g=e.filter(q=>q.type==="sub_agent"),x=g.length>0,w=x?c:o,C=f.length>0?u:o,b=Fa+ds/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:b,w:Ch,h:ds}),m.set("$start",{cx:w,cy:b,w:Ch,h:ds});const _=q=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:q,w:Ch,h:ds}),m.set("$done",{cx:w,cy:q,w:Ch,h:ds})};if(e.length===0){const q=b+ds/2+sl*2+ds/2;return _(q),{nodes:d,edges:h,width:a,height:q+ds/2+Fa,posMap:m}}const S=b+ds/2+sl,v=(q,W)=>{q.forEach((ee,J)=>{const H=S+J*(ui+sl)+ui/2,{name:P,color:D}=Cv(ee,r);d.push({id:ee.id,type:"step",label:P,color:D,cx:W,cy:H,w:$a,h:ui}),m.set(ee.id,{cx:W,cy:H,w:$a,h:ui})})};v(f,w),v(g,C);const k=f.length>0?S+(f.length-1)*(ui+sl)+ui/2:b,E=x?S+(g.length-1)*(ui+sl)+ui/2:b,N=Math.max(k,E)+ui/2+sl+ds/2;_(N);const L=[];t&&m.has(t)&&L.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let A=0;for(const q of e)q.transitions.forEach((W,ee)=>{var $;if(!W.goto||!m.has(W.goto))return;const J=m.get(q.id),H=m.get(W.goto),P=W.when.type==="step_result"?`${W.when.result}`:W.when.type==="metadata_all_match"?`${W.when.key??"?"}=${W.when.value??"?"}`:W.when.type==="metadata_all_in"?`${W.when.key??"?"} in [${(($=W.when.values)==null?void 0:$.join(","))??"?"}]`:LA[W.when.type]??W.when.type,D=q.id===W.goto;let U;D?U="back":H.cy>J.cy+1?U="down":H.cy<J.cy-1?U="back":U="same",L.push({from:q.id,to:W.goto,label:P,edgeKey:`${q.id}:${ee}`,direction:U,backEdgeIndex:U==="back"?A++:0})});const O=new Map,I=new Map,F=new Map,B=new Map;for(const q of L)q.direction==="down"&&(O.set(q.from,(O.get(q.from)??0)+1),I.set(q.to,(I.get(q.to)??0)+1));const z=new Map,Y=new Map;for(const q of L){if(q.direction!=="same")continue;const W=[q.from,q.to].sort().join("|");z.set(W,(z.get(W)??0)+1)}for(const q of L){if(q.direction==="back"||q.direction==="same"){let U=0;if(q.direction==="same"){const $=[q.from,q.to].sort().join("|");U=Y.get($)??0,Y.set($,U+1)}h.push({...q,fromPort:0,toPort:0,sameEdgeIndex:U});continue}const W=O.get(q.from)??1,ee=I.get(q.to)??1,J=F.get(q.from)??0,H=B.get(q.to)??0;F.set(q.from,J+1),B.set(q.to,H+1);const P=W===1?0:-.6+1.2*J/(W-1),D=ee===1?0:-.6+1.2*H/(ee-1);h.push({...q,fromPort:P,toPort:D,sameEdgeIndex:0})}return{nodes:d,edges:h,width:a,height:N+ds/2+Fa,posMap:m}}function PW({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:o,isReadOnly:c,onSelectNode:u,onSelectEdge:d,onRemoveStep:h,onCreateTransition:m,onReconnectTo:f,onReconnectFrom:g,onDeleteTransition:x}){const w=j.useRef(null),C=j.useRef(!1),[b,_]=j.useState(null),[S,v]=j.useState(null),[k,E]=j.useState(null),{nodes:N,edges:L,width:A,height:O,posMap:I}=j.useMemo(()=>MW(e,t,a,o),[e,t,a,o]),F=j.useCallback(K=>{var ne;const Z=w.current;if(!Z)return{x:0,y:0};const V=Z.createSVGPoint();V.x=K.clientX,V.y=K.clientY;const M=(ne=Z.getScreenCTM())==null?void 0:ne.inverse();if(!M)return{x:0,y:0};const X=V.matrixTransform(M);return{x:X.x,y:X.y}},[]),B=j.useCallback(K=>!K||!S||K==="$start"?!1:S.type==="reconnect-from"?K!=="$done":!0,[S]),z=j.useCallback((K,Z)=>{if(c)return;K.stopPropagation(),K.preventDefault();const V=F(K);v({type:"new",fromNodeId:Z,mouseX:V.x,mouseY:V.y})},[F,c]),Y=j.useCallback((K,Z)=>{if(c)return;K.stopPropagation(),K.preventDefault();const V=F(K);v({type:"reconnect-to",fromNodeId:Z.from,edgeKey:Z.edgeKey,mouseX:V.x,mouseY:V.y})},[F,c]),q=j.useCallback((K,Z)=>{if(c)return;K.stopPropagation(),K.preventDefault();const V=F(K);v({type:"reconnect-from",fromNodeId:Z.from,fixedTargetId:Z.to,edgeKey:Z.edgeKey,mouseX:V.x,mouseY:V.y})},[F,c]),W=j.useCallback(K=>{if(!S)return;const Z=F(K);v(V=>V?{...V,mouseX:Z.x,mouseY:Z.y}:null)},[S,F]),ee=j.useCallback(()=>{S&&(C.current=!0,k&&B(k)&&(S.type==="new"?m(S.fromNodeId,k):S.type==="reconnect-to"?f(S.edgeKey,k):S.type==="reconnect-from"&&g(S.edgeKey,k)),v(null),E(null))},[S,k,B,m,f,g]),J=j.useCallback(()=>{if(C.current){C.current=!1;return}u(null),d(null)},[u,d]);j.useEffect(()=>{if(c)return;const K=Z=>{Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement||(Z.key==="Delete"||Z.key==="Backspace")&&r&&r!=="start"&&(Z.preventDefault(),x(r),d(null))};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[c,r,x,d]);const H=K=>{const Z=I.get(K.from),V=I.get(K.to);if(!Z||!V)return null;let M,X,ne,re="middle",ie,ge;if(K.direction==="down"){const ke=Z.cx+K.fromPort*(Z.w/2-10),Oe=Z.cy+Z.h/2,Fe=V.cx+K.toPort*(V.w/2-10),we=V.cy-V.h/2,We=we-Oe,Xe=Fe-ke;M=`M ${ke} ${Oe} C ${ke} ${Oe+We*.4}, ${Fe-Xe*.2} ${we-We*.1}, ${Fe} ${we}`,X=ke+(Fe-ke)*.5,ne=Oe+We*.6,ie={x:ke,y:Oe},ge={x:Fe,y:we}}else if(K.direction==="back"){const ke=K.from===K.to,Oe=Z.cx>=A/2,Fe=K.backEdgeIndex*16,we=Oe?A-20-Fe:20+Fe;if(ke){const We=Z.cx>=A/2,Xe=30+K.backEdgeIndex*14,_e=Z.cy-Z.h/2,ye=We?Z.cx+Z.w/2:Z.cx-Z.w/2,fe=We?ye+Xe:ye-Xe,oe=Z.cx+(We?Z.w/4:-Z.w/4),Me=_e-20-K.backEdgeIndex*10;M=`M ${ye} ${Z.cy} C ${fe} ${Z.cy}, ${fe} ${Me}, ${oe} ${_e}`,X=fe+10,ne=Me+4,re="middle",ie={x:ye,y:Z.cy},ge={x:oe,y:_e}}else{const We=Oe?Z.cx+Z.w/2:Z.cx-Z.w/2,Xe=V.cx+(Oe?V.w/4:-V.w/4),_e=Math.min(Z.cy,V.cy)-V.h/2-18-K.backEdgeIndex*14;M=`M ${We} ${Z.cy} L ${we} ${Z.cy} L ${we} ${_e} L ${Xe} ${_e} L ${Xe} ${V.cy-V.h/2}`,X=we,ne=(Z.cy+_e)/2,re=Oe?"start":"end",ie={x:We,y:Z.cy},ge={x:Xe,y:V.cy-V.h/2}}}else{const ke=V.cx>Z.cx,Oe=K.sameEdgeIndex===0?-12:12,Fe=ke?Z.cx+Z.w/2:Z.cx-Z.w/2,we=ke?V.cx-V.w/2:V.cx+V.w/2,We=Z.cy+Oe,Xe=V.cy+Oe,_e=(Fe+we)/2;M=`M ${Fe} ${We} C ${_e} ${We}, ${_e} ${Xe}, ${we} ${Xe}`,X=_e,ne=(We+Xe)/2-6,ie={x:Fe,y:We},ge={x:we,y:Xe}}return{path:M,labelX:X,labelY:ne,labelAnchor:re,fromPt:ie,toPt:ge}},P=(K,Z)=>{const V=H(K);if(!V)return null;const{path:M,labelX:X,labelY:ne,labelAnchor:re}=V,ie=r===K.edgeKey,ge=K.label&&K.label!=="otherwise";return s.jsxs("g",{children:[s.jsx("path",{d:M,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:ke=>{ke.stopPropagation(),c||d(ie?null:K.edgeKey)}}),s.jsx("path",{d:M,fill:"none",stroke:ie?"#58a6ff":"#484f58",strokeWidth:ie?2.2:1.2,markerEnd:ie?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),ge&&s.jsx("text",{x:X+(re==="start"?5:re==="end"?-5:0),y:ne+3,textAnchor:re,className:"text-[8px]",fill:ie?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:K.label})]},Z)},D=()=>{if(!r||S)return null;const K=L.find(ne=>ne.edgeKey===r);if(!K)return null;const Z=H(K);if(!Z)return null;const{fromPt:V,toPt:M}=Z,X=6;return s.jsxs(s.Fragment,{children:[K.edgeKey!=="start"&&s.jsx("circle",{cx:V.x,cy:V.y,r:X,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ne=>q(ne,K)}),s.jsx("circle",{cx:M.x,cy:M.y,r:X,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ne=>Y(ne,K)})]})},U=()=>{if(!S)return null;let K,Z,V,M;if(S.type==="reconnect-from"){const re=I.get(S.fixedTargetId);if(!re)return null;K=S.mouseX,Z=S.mouseY,V=re.cx,M=re.cy-re.h/2}else{const re=I.get(S.fromNodeId);if(!re)return null;K=re.cx,Z=re.cy+re.h/2,V=S.mouseX,M=S.mouseY}const X=M-Z,ne=Math.abs(X)>10?`M ${K} ${Z} C ${K} ${Z+X*.4}, ${V} ${M-X*.4}, ${V} ${M}`:`M ${K} ${Z} L ${V} ${M}`;return s.jsx("path",{d:ne,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},$=K=>{const Z=K.cy+K.h/2,V=(S==null?void 0:S.fromNodeId)===K.id;return s.jsx("circle",{cx:K.cx,cy:Z,r:Uk,fill:V?"#58a6ff":"#1c2128",stroke:V?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:V?1:.5,className:"cursor-crosshair",onMouseDown:M=>z(M,K.id)})},Q=K=>{const Z=K.cy-K.h/2,V=S&&k===K.id&&B(K.id);return s.jsx("circle",{cx:K.cx,cy:Z,r:Uk,fill:V?"#3fb950":"#1c2128",stroke:V?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:V?1:.5})};return s.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${O}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:W,onMouseUp:ee,onClick:J,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),s.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),L.map((K,Z)=>P(K,Z)),N.map(K=>{const Z=n===K.id,V=K.cx-K.w/2,M=K.cy-K.h/2,X=b===K.id,ne=S&&k===K.id&&B(K.id);if(K.type==="terminal"){const ie=K.id==="$start",ge=ie?"#58a6ff":"#3fb950",ke=ie,Oe=!ie;return s.jsxs("g",{onClick:Fe=>{Fe.stopPropagation(),ie&&!c&&d("start")},className:ie&&!c?"cursor-pointer":void 0,children:[ne&&s.jsx("rect",{x:V-3,y:M-3,width:K.w+6,height:K.h+6,rx:K.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ie&&r==="start"&&s.jsx("rect",{x:V-3,y:M-3,width:K.w+6,height:K.h+6,rx:K.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:V,y:M,width:K.w,height:K.h,rx:K.h/2,fill:ge,fillOpacity:.08,stroke:ge,strokeOpacity:.4,strokeWidth:1.5}),s.jsx("text",{x:K.cx,y:K.cy+4,textAnchor:"middle",fill:ge,className:"text-[10px] font-medium",pointerEvents:"none",children:K.label}),ke&&$(K),Oe&&Q(K)]},K.id)}const re=K.color??"#6b7280";return s.jsxs("g",{onClick:ie=>{ie.stopPropagation(),c||u(Z?null:K.id)},onMouseEnter:()=>_(K.id),onMouseLeave:()=>_(null),className:c?void 0:"cursor-pointer",children:[ne&&s.jsx("rect",{x:V-3,y:M-3,width:K.w+6,height:K.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),Z&&s.jsx("rect",{x:V-3,y:M-3,width:K.w+6,height:K.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:V,y:M,width:K.w,height:K.h,rx:10,fill:re,fillOpacity:.08,stroke:re,strokeOpacity:.6,strokeWidth:Z?2:1.5}),s.jsx("text",{x:K.cx,y:K.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:K.label}),!c&&$(K),!c&&Q(K),X&&!S&&!c&&s.jsxs("g",{onClick:ie=>{ie.stopPropagation(),h(K.id)},className:"cursor-pointer",children:[s.jsx("circle",{cx:V+K.w-2,cy:M+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),s.jsx("line",{x1:V+K.w-5,y1:M-1,x2:V+K.w+1,y2:M+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),s.jsx("line",{x1:V+K.w+1,y1:M-1,x2:V+K.w-5,y2:M+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},K.id)}),S&&N.map(K=>B(K.id)?s.jsx("rect",{x:K.cx-K.w/2-8,y:K.cy-K.h/2-8,width:K.w+16,height:K.h+16,fill:"transparent",rx:12,onMouseEnter:()=>E(K.id),onMouseLeave:()=>E(null),onMouseUp:Z=>{Z.stopPropagation(),ee()}},`drop-${K.id}`):null),U(),D()]})}const jh="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",qc="block text-[11px] text-text-secondary mb-0.5";function BW({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:o,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:qc,children:"Name"}),s.jsx("input",{value:e,onChange:m=>c(m.target.value),placeholder:"Workflow name",className:`${jh} ${o?"opacity-50":""}`,readOnly:o})]}),s.jsxs("div",{className:"min-w-[100px]",children:[s.jsx("label",{className:qc,children:"ID"}),s.jsx("input",{value:t,readOnly:!0,className:`${jh} font-mono opacity-50`})]}),s.jsxs("div",{className:"flex-1 min-w-[140px]",children:[s.jsx("label",{className:qc,children:"Description"}),s.jsx("input",{value:n,onChange:m=>!o&&u(m.target.value),readOnly:o,placeholder:"What does this workflow do?",className:`${jh} ${o?"opacity-50":""}`})]}),s.jsxs("div",{className:"w-20",children:[s.jsx("label",{className:qc,children:"Max Iter."}),s.jsx("input",{type:"number",value:r,onChange:m=>!o&&d(Number(m.target.value)),readOnly:o,className:`${jh} font-mono ${o?"opacity-50":""}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:qc,children:"Color"}),s.jsx("input",{type:"color",value:a,onChange:m=>!o&&h(m.target.value),disabled:o,className:`w-8 h-8 rounded border border-border bg-transparent ${o?"opacity-50":"cursor-pointer"}`})]})]})}function $W({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:o}){return s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:o})]})}function Px({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($W,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const za="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",Bx="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",Ns="block text-[11px] text-text-secondary mb-0.5";function $x({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 FW({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:o,onRemove:c,onSetEntry:u}){const{color:d,name:h}=Cv(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:Ns,children:"Name"}),s.jsx("input",{value:e.name,onChange:m=>o({...e,name:m.target.value}),placeholder:"Step name",className:za})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Type"}),s.jsx("select",{value:e.type,onChange:m=>{const f=m.target.value,g=f==="sub_agent"?"verification":"build";if(f==="agent"){const x=n.find(w=>!w.subagent);o({...e,type:f,phase:g,agentId:(x==null?void 0:x.id)??"builder",name:(x==null?void 0:x.name)??"Agent"})}else if(f==="sub_agent"){const x=n.find(w=>w.subagent);o({...e,type:f,phase:g,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else o(f==="user"?{...e,type:f,phase:g,name:"User"}:{...e,type:f,phase:g,name:"Shell"})},className:Bx,children:IW.map(m=>s.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.type==="agent"&&s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Agent Type"}),s.jsx("select",{value:e.agentId??"builder",onChange:m=>{const f=n.find(g=>g.id===m.target.value);o({...e,agentId:m.target.value,name:(f==null?void 0:f.name)??m.target.value})},className:Bx,children:n.filter(m=>!m.subagent).map(m=>s.jsx("option",{value:m.id,children:m.name},m.id))})]}),e.type==="sub_agent"&&s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Sub-Agent Type"}),s.jsxs("select",{value:e.subAgentType??"",onChange:m=>{const f=n.find(g=>g.id===m.target.value);o({...e,subAgentType:m.target.value,name:(f==null?void 0:f.name)??m.target.value})},className:Bx,children:[s.jsx("option",{value:"",children:"— select —"}),n.filter(m=>m.subagent).map(m=>s.jsx("option",{value:m.id,children:m.name},m.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Prompt"}),s.jsx("textarea",{value:e.prompt??"",onChange:m=>o({...e,prompt:m.target.value||void 0}),rows:6,className:`${za} resize-y text-xs`,placeholder:"Injected on first entry..."}),s.jsx($x,{variables:a,onInsert:m=>o({...e,prompt:(e.prompt??"")+`{{${m}}}`})})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Nudge Prompt"}),s.jsx("textarea",{value:e.nudgePrompt??"",onChange:m=>o({...e,nudgePrompt:m.target.value||void 0}),rows:6,className:`${za} resize-y text-xs`,placeholder:"Injected on re-entry..."}),s.jsx($x,{variables:a,onInsert:m=>o({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${m}}}`})})]})]}),e.type==="shell"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Command"}),s.jsx("textarea",{value:e.command??"",onChange:m=>o({...e,command:m.target.value}),rows:3,className:`${za} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),s.jsx($x,{variables:a,onInsert:m=>o({...e,command:(e.command??"")+`{{${m}}}`})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Timeout (ms)"}),s.jsx("input",{type:"number",value:e.timeout??6e4,onChange:m=>o({...e,timeout:Number(m.target.value)}),className:`${za} font-mono text-xs`})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Success Codes"}),s.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:m=>o({...e,successExitCodes:m.target.value.split(",").map(f=>Number(f.trim())).filter(f=>!isNaN(f))}),className:`${za} font-mono text-xs`})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Sub-group"}),s.jsx("input",{value:e.subGroup??"",onChange:m=>o({...e,subGroup:m.target.value||void 0}),placeholder:"e.g. build, verify, review",className:za})]}),s.jsx("div",{className:"pt-1 border-t border-border/50",children:s.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const il="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Vk="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Ha="block text-[11px] text-text-secondary mb-0.5";function zW({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:o,transitionIndex:c,totalTransitions:u,onUpdateCondition:d,onUpdateSubGroup:h,onDelete:m,onMoveUp:f,onMoveDown:g}){var C;const x=a&&(a.type==="sub_agent"||a.type==="agent")?o.find(b=>b.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:f,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(yn,{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(yn,{className:"w-3 h-3"})})]})]}),s.jsx("button",{onClick:m,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:e}),s.jsx(Ff,{}),s.jsx("span",{className:"font-medium text-text-primary",children:t})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ha,children:"Condition"}),s.jsx("select",{value:n.type,onChange:b=>{d(b.target.value==="step_result"?{type:"step_result",result:"success"}:{type:b.target.value})},className:Vk,children:RA.map(b=>s.jsx("option",{value:b.value,children:b.label},b.value))})]}),n.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:Ha,children:"Result"}),w?s.jsx("select",{value:n.result??x.results[0],onChange:b=>{d({type:"step_result",result:b.target.value})},className:Vk,children:x.results.map(b=>s.jsx("option",{value:b,children:b},b))}):s.jsx("input",{type:"text",value:n.result??"success",onChange:b=>d({type:"step_result",result:b.target.value}),placeholder:"e.g. success, passed, failed",className:il})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Ha,children:"Metadata Key"}),s.jsx("input",{type:"text",value:n.key??"",onChange:b=>d({...n,key:b.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:il})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ha,children:"Field"}),s.jsx("input",{type:"text",value:n.field??"",onChange:b=>d({...n,field:b.target.value}),placeholder:"e.g. status",className:il})]}),n.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:Ha,children:"Value"}),s.jsx("input",{type:"text",value:n.value??"",onChange:b=>d({...n,value:b.target.value}),placeholder:"e.g. passed, resolved",className:il})]}):s.jsxs("div",{children:[s.jsx("label",{className:Ha,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:b=>d({...n,values:b.target.value.split(",").map(_=>_.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:il})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ha,children:"Sub-group"}),s.jsx("input",{type:"text",value:r??"",onChange:b=>h(b.target.value||void 0),placeholder:"e.g. build, verify",className:il})]}),(a==null?void 0:a.type)==="user"&&s.jsxs("div",{className:"pt-1 border-t border-border/50 space-y-1",children:[s.jsx("p",{className:"text-text-muted text-[10px]",children:'On a user step, each "Step result is..." transition becomes a choice button; "Always" becomes a Continue button.'}),n.type==="step_result"&&a.transitions.filter(b=>b.when.type==="step_result"&&b.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((b,_)=>_>c&&b.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(b=>b.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 HW(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function UW(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Kc="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",Wk="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",al="block text-[11px] text-text-secondary mb-0.5",Gk=[];function DA({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){var mt,Dt;const a=Ut(Ee=>Ee.defaults),o=Ut(Ee=>Ee.userItems),c=Ut(Ee=>Ee.projectItems),u=Ut(Ee=>Ee.loading),d=Ut(Ee=>Ee.templateVariables),h=Ut(Ee=>Ee.fetchWorkflows),m=Ut(Ee=>Ee.fetchWorkflow),f=Ut(Ee=>Ee.fetchDefaultContent),g=Ut(Ee=>Ee.fetchTemplateVariables),x=Ut(Ee=>Ee.createWorkflow),w=Ut(Ee=>Ee.updateWorkflow),C=Ut(Ee=>Ee.deleteWorkflow),{requestDelete:b,clearConfirm:_,isConfirming:S}=Nu(),[v,k]=j.useState("list"),[E,N]=j.useState(null),[L,A]=j.useState(void 0),[O,I]=j.useState(!1),[F,B]=j.useState(null),[z,Y]=j.useState(null),[q,W]=j.useState(""),[ee,J]=j.useState(""),[H,P]=j.useState(""),[D,U]=j.useState("1.0.0"),[$,Q]=j.useState("#3b82f6"),[K,Z]=j.useState(""),[V,M]=j.useState(50),[X,ne]=j.useState(Gk),[re,ie]=j.useState({type:"always"}),[ge,ke]=j.useState([]),[Oe,Fe]=j.useState("user"),[we,We]=j.useState(""),[Xe,_e]=j.useState(!1),ye=ct(Ee=>Ee.defaults),fe=ct(Ee=>Ee.userItems),oe=ct(Ee=>Ee.projectItems),Me=j.useMemo(()=>[...ye,...fe,...oe],[ye,fe,oe]),He=ct(Ee=>Ee.fetchAgents),[he]=j.useState(null);j.useEffect(()=>{e&&(h(r),g(),He(),B(null),Y(null),n?a.some(Ae=>Ae.id===n)?f(n,r).then(Ae=>{Ae&&Te({...Ae,metadata:{...Ae.metadata,name:Ae.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):m(n,r).then(Ae=>{Ae&&Te(Ae,{editingId:n,isReadOnly:!1})}):(k("list"),N(null),I(!1)))},[e,h,m,f,g,n,r]);const Te=(Ee,Ae)=>{W(Ee.metadata.name),J(Ee.metadata.id),P(Ee.metadata.description),U(Ee.metadata.version),Q(Ee.metadata.color??"#3b82f6"),Z(Ee.entryStep),M(Ee.settings.maxIterations),ne(Ee.steps),ie(Ee.startCondition??{type:"always"}),ke(Ee.metadata.parameters??[]),We(""),(Ae==null?void 0:Ae.editingId)!==void 0&&N(Ae.editingId),(Ae==null?void 0:Ae.isReadOnly)!==void 0&&I(Ae.isReadOnly),(Ae==null?void 0:Ae.selectedNodeKey)!==void 0&&B(null),(Ae==null?void 0:Ae.selectedEdgeKey)!==void 0&&Y(null),k("edit")},Qe=async(Ee,Ae)=>{A(Ae);const Be=await m(Ee,r,Ae);Be&&Te(Be,{editingId:Ee,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},me=async()=>{var gt;const Ee=E??ee;if(!Ee||!q)return We("Name is required."),!1;if(X.length===0)return We("Add at least one step."),!1;const Ae=ge.find(kt=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(kt.id));if(Ae)return We(`Invalid parameter ID "${Ae.id}". Use letters, digits, and underscores only.`),!1;let Be=K;if(!Be||!X.some(kt=>kt.id===Be)){if(Be=((gt=X.find(kt=>kt.id))==null?void 0:gt.id)??"",!Be)return We("All steps need an ID."),!1;Z(Be)}_e(!0),We("");const Je={metadata:{id:Ee,name:q,description:H,version:D||"1.0.0",color:$,...ge.length>0?{parameters:ge}:{}},entryStep:Be,settings:{maxIterations:V},steps:X,startCondition:re},nt=E?await w(E,Je,r,L):await x(Je,Oe,r);return _e(!1),nt.success?(E||N(Ee),!0):(We(nt.error??"Failed to save."),!1)},ze=async()=>{await me()},at=async()=>{await me()&&(n?t():k("list"))},Ze=()=>{n?t():k("list")},et=Ee=>{W(Ee),E||J(HW(Ee))},ot=async(Ee,Ae)=>a.some(Je=>Je.id===Ee)?await f(Ee,r):await m(Ee,r,Ae),ce=async(Ee,Ae)=>{const Be=await ot(Ee,Ae);Be&&Te({...Be,metadata:{...Be.metadata,name:Be.metadata.name+" (copy)",id:`${Ee}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},ae=()=>{N(null),A(void 0),W(""),J(""),P(""),U("1.0.0"),Q("#3b82f6"),Z(""),M(50),ne(structuredClone(Gk)),ie({type:"always"}),ke([]),Fe("user"),We(""),B(null),Y(null),I(!1),k("edit")},Re=async(Ee,Ae)=>{await C(Ee,Ae,r),_()},Ve=j.useCallback(Ee=>{B(Ee),Y(null)},[]),dt=j.useCallback(Ee=>{Y(Ee),B(null)},[]),vt=F!==null?Number(F):-1,wt=vt>=0?X[vt]??null:null,an=j.useCallback(Ee=>{ne(Ae=>Ae.map((Be,Je)=>Je===vt?Ee:Be))},[vt]),on=re.type==="step_result"?`${re.result}`:re.type==="metadata_all_match"?`${re.key??"?"}=${re.value??"?"}`:re.type==="metadata_all_in"?`${re.key??"?"} in [${((mt=re.values)==null?void 0:mt.join(","))??"?"}]`:LA[re.type]??re.type,fn=()=>{const Ee=X.length,Ae=UW(X),Be=Me.find(Je=>!Je.subagent);ne([...X,{id:Ae,name:(Be==null?void 0:Be.name)??"Agent",type:"agent",phase:"build",agentId:(Be==null?void 0:Be.id)??"builder",transitions:[]}]),K||Z(Ae),Ve(String(Ee))},zn=j.useCallback((Ee,Ae)=>{Ee==="$start"?(Z(Ae),dt("start")):ne(Be=>{const Je=Be.find(gt=>gt.id===Ee),nt=Je?Je.transitions.length:0;return dt(`${Ee}:${nt}`),Be.map(gt=>gt.id===Ee?{...gt,transitions:[...gt.transitions,{when:{type:"always"},goto:Ae}]}:gt)})},[dt]),bn=Ee=>{if(Ee==="start")return null;const Ae=Ee.lastIndexOf(":"),Be=Ee.slice(0,Ae),Je=parseInt(Ee.slice(Ae+1));return{stepId:Be,transIdx:Je}},gn=j.useCallback((Ee,Ae)=>{const Be=bn(Ee);Be&&ne(Je=>Je.map(nt=>nt.id===Be.stepId?{...nt,transitions:nt.transitions.map((gt,kt)=>kt===Be.transIdx?Ae(gt):gt)}:nt))},[]),hr=j.useCallback((Ee,Ae)=>{if(Ee==="start"){Z(Ae);return}gn(Ee,Be=>({...Be,goto:Ae}))},[gn]),Se=j.useCallback((Ee,Ae)=>{const Be=bn(Ee);Be&&(ne(Je=>{const nt=Je.find(kt=>kt.id===Be.stepId);if(!nt)return Je;const gt=nt.transitions[Be.transIdx];return gt?Je.map(kt=>kt.id===Be.stepId?{...kt,transitions:kt.transitions.filter((Mn,Cn)=>Cn!==Be.transIdx)}:kt.id===Ae?{...kt,transitions:[...kt.transitions,gt]}:kt):Je}),Y(null))},[]),tt=j.useCallback(Ee=>{if(Ee==="start"){Z(""),Y(null);return}const Ae=bn(Ee);Ae&&(ne(Be=>Be.map(Je=>Je.id===Ae.stepId?{...Je,transitions:Je.transitions.filter((nt,gt)=>gt!==Ae.transIdx)}:Je)),Y(null))},[]),Ye=j.useCallback((Ee,Ae)=>{if(Ee==="start"){ie(Ae);return}gn(Ee,Be=>({...Be,when:Ae}))},[gn]),Ue=j.useCallback((Ee,Ae)=>{Ee!=="start"&&gn(Ee,Be=>({...Be,subGroup:Ae||void 0}))},[gn]),ue=Ee=>Cv(Ee,Me).name,Ke=()=>{if(!z)return null;if(z==="start"){const Mn=X.find(Cn=>Cn.id===K);return{type:"start",fromLabel:"Start",toLabel:Mn?ue(Mn):"(none)",condition:re}}const Ee=z.lastIndexOf(":"),Ae=z.slice(0,Ee),Be=parseInt(z.slice(Ee+1)),Je=X.find(Mn=>Mn.id===Ae);if(!Je)return null;const nt=Je.transitions[Be];if(!nt)return null;const gt=X.find(Mn=>Mn.id===nt.goto),kt=nt.goto==="$done"?"Done":gt?ue(gt):nt.goto;return{type:"step",fromLabel:ue(Je),toLabel:kt,condition:nt.when,subGroup:nt.subGroup}};if(v==="edit"){const Ee=Ke();return s.jsxs(jt,{isOpen:e,onClose:Ze,title:O?q:E?"Edit Workflow":"New Workflow",size:"full",children:[we&&s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:we}),s.jsx(BW,{formName:q,formId:ee,formDescription:H,formMaxIterations:V,formColor:$,isReadOnly:O,onNameChange:et,onDescriptionChange:P,onMaxIterationsChange:M,onColorChange:Q}),!O&&s.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:s.jsxs(OW,{title:`Parameters (${ge.length})`,children:[ge.map((Ae,Be)=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{value:Ae.id,onChange:Je=>{const nt=[...ge];nt[Be]={...Ae,id:Je.target.value},ke(nt)},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:Ae.label,onChange:Je=>{const nt=[...ge];nt[Be]={...Ae,label:Je.target.value},ke(nt)},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:Ae.description??"",onChange:Je=>{const nt=[...ge];nt[Be]={...Ae,description:Je.target.value||void 0},ke(nt)},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:Ae.required??!1,onChange:Je=>{const nt=[...ge];nt[Be]={...Ae,required:Je.target.checked||void 0},ke(nt)},className:"rounded border-border"}),"Req."]}),s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>{Be!==0&&ke(ge.map((Je,nt)=>nt===Be?{...ge[Be-1],position:nt}:nt===Be-1?{...ge[Be],position:nt}:{...Je,position:nt}))},disabled:Be===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${Ae.label||Ae.id} up`,children:"▲"}),s.jsx("button",{onClick:()=>{Be!==ge.length-1&&ke(ge.map((Je,nt)=>nt===Be?{...ge[Be+1],position:nt}:nt===Be+1?{...ge[Be],position:nt}:{...Je,position:nt}))},disabled:Be===ge.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${Ae.label||Ae.id} down`,children:"▼"})]}),s.jsx("button",{onClick:()=>ke(ge.filter((Je,nt)=>nt!==Be)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},Ae.id)),s.jsx("button",{onClick:()=>{const Ae=`param_${ge.length+1}`;ke([...ge,{id:Ae,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!E&&!O&&s.jsx(Gf,{value:Oe,onChange:Fe}),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:fn,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),s.jsxs(ft,{className:"flex-1 min-h-0 p-2",children:[s.jsx(PW,{steps:X,entryStep:K,selectedNodeId:(wt==null?void 0:wt.id)??null,selectedEdgeKey:z,startConditionLabel:on,agentTypes:Me,isReadOnly:O,onSelectNode:Ae=>{if(Ae===null){Ve(null);return}const Be=X.findIndex(Je=>Je.id===Ae);Ve(Be>=0?String(Be):null)},onSelectEdge:dt,onRemoveStep:Ae=>{var Je;const Be=X.findIndex(nt=>nt.id===Ae);if(ne(nt=>nt.filter(gt=>gt.id!==Ae)),vt===Be&&Ve(null),K===Ae){const nt=X.filter(gt=>gt.id!==Ae);Z(((Je=nt[0])==null?void 0:Je.id)??"")}},onCreateTransition:zn,onReconnectTo:hr,onReconnectFrom:Se,onDeleteTransition:tt}),X.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:fn,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),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(ft,{className:"p-3 flex-1 min-h-0",children:O&&(Ee||wt)?s.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):Ee?Ee.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"})}),K&&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(Ff,{}),s.jsx("span",{className:"text-text-primary font-medium",children:Ee.toLabel})]}),s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Activation Condition"}),s.jsx("select",{value:re.type,onChange:Ae=>ie(Ae.target.value==="step_result"?{type:"step_result",result:"success"}:Ae.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Ae.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Ae.target.value}),className:Wk,children:RA.map(Ae=>s.jsx("option",{value:Ae.value,children:Ae.label},Ae.value))})]}),re.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Result"}),K&&(()=>{const Ae=X.find(gt=>gt.id===K),Be=Ae&&(Ae.type==="sub_agent"||Ae.type==="agent")?Me.find(gt=>gt.id===(Ae.type==="sub_agent"?Ae.subAgentType:Ae.agentId)):void 0,Je=(Be==null?void 0:Be.results)&&Be.results.length>0,nt=(Be==null?void 0:Be.results)??[];return Je?s.jsx("select",{value:re.result??nt[0],onChange:gt=>ie({type:"step_result",result:gt.target.value}),className:Wk,children:nt.map(gt=>s.jsx("option",{value:gt,children:gt},gt))}):s.jsx("input",{type:"text",value:re.result??"success",onChange:gt=>ie({type:"step_result",result:gt.target.value}),placeholder:"e.g. success, passed, failed",className:Kc})})()]}),(re.type==="metadata_all_match"||re.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Metadata Key"}),s.jsx("input",{type:"text",value:re.key??"",onChange:Ae=>ie({...re,key:Ae.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Kc})]}),s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Field"}),s.jsx("input",{type:"text",value:re.field??"",onChange:Ae=>ie({...re,field:Ae.target.value}),placeholder:"e.g. status",className:Kc})]}),re.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Value"}),s.jsx("input",{type:"text",value:re.value??"",onChange:Ae=>ie({...re,value:Ae.target.value}),placeholder:"e.g. passed, resolved",className:Kc})]}):s.jsxs("div",{children:[s.jsx("label",{className:al,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((Dt=re.values)==null?void 0:Dt.join(", "))??"",onChange:Ae=>ie({...re,values:Ae.target.value.split(",").map(Be=>Be.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Kc})]})]}),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 Ae=bn(z),Be=Ae==null?void 0:Ae.stepId,Je=(Ae==null?void 0:Ae.transIdx)??0,nt=Be?X.find(kt=>kt.id===Be):void 0,gt=(nt==null?void 0:nt.transitions.length)??0;return s.jsx(zW,{fromLabel:Ee.fromLabel,toLabel:Ee.toLabel,condition:Ee.condition,subGroup:"subGroup"in Ee?Ee.subGroup:void 0,fromStep:Ee.type==="step"?X.find(kt=>kt.id===Ee.fromLabel):void 0,agentTypes:Me,transitionIndex:Je,totalTransitions:gt,onUpdateCondition:kt=>Ye(z,kt),onUpdateSubGroup:kt=>Ue(z,kt),onDelete:()=>tt(z),onMoveUp:()=>{ne(kt=>{const Mn=kt.find(Nn=>Nn.id===Be);if(!Mn||Je===0)return kt;const Cn=[...Mn.transitions];return[Cn[Je-1],Cn[Je]]=[Cn[Je],Cn[Je-1]],kt.map(Nn=>Nn.id===Be?{...Nn,transitions:Cn}:Nn)}),Y(`${Be}:${Je-1}`)},onMoveDown:()=>{ne(kt=>{const Mn=kt.find(Nn=>Nn.id===Be);if(!Mn||Je===Mn.transitions.length-1)return kt;const Cn=[...Mn.transitions];return[Cn[Je],Cn[Je+1]]=[Cn[Je+1],Cn[Je]],kt.map(Nn=>Nn.id===Be?{...Nn,transitions:Cn}:Nn)}),Y(`${Be}:${Je+1}`)}})})():wt?s.jsx(FW,{step:wt,isEntry:wt.id===K,agentTypes:Me,transitionCount:wt.transitions.length,templateVariables:d,onUpdate:an,onRemove:()=>{var Ae;if(wt&&(ne(X.filter((Be,Je)=>Je!==vt)),Ve(null),K===wt.id)){const Be=X.filter((Je,nt)=>nt!==vt);Z(((Ae=Be[0])==null?void 0:Ae.id)??"")}},onSetEntry:()=>Z(wt.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(st,{variant:"secondary",onClick:Ze,children:"Close"}),O?s.jsx(st,{variant:"primary",onClick:()=>{W(q+" (copy)"),J(`${E}-copy-${Date.now()}`),N(null),I(!1)},children:"Duplicate & Customize"}):s.jsxs(s.Fragment,{children:[s.jsx(st,{variant:"primary",onClick:ze,children:"Save"}),s.jsx(st,{variant:"primary",onClick:at,children:"Save & Close"})]})]})]})}return s.jsx(jt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:s.jsx(CE,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:ae,loading:u,hasItems:a.length>0||o.length>0||c.length>0,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(Px,{title:"Built-in",items:a,renderActions:Ee=>s.jsx(s.Fragment,{children:s.jsx(vi,{onClick:()=>ce(Ee.id),children:s.jsx(xb,{})})})}),s.jsx(Px,{title:"Custom",items:o,renderActions:Ee=>s.jsxs(s.Fragment,{children:[s.jsx(vi,{onClick:()=>Qe(Ee.id,"user"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(gu,{onClick:()=>ce(Ee.id,"user")}),S(`user:${Ee.id}`,"delete")?s.jsx(Yh,{onConfirm:()=>Re(Ee.id,"user"),onCancel:_}):s.jsx(Xh,{onClick:()=>b(`user:${Ee.id}`)})]})}),c.length>0&&s.jsx(Px,{title:"Project",items:c,renderActions:Ee=>s.jsxs(s.Fragment,{children:[s.jsx(vi,{onClick:()=>Qe(Ee.id,"project"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(gu,{onClick:()=>ce(Ee.id,"project")}),S(`project:${Ee.id}`,"delete")?s.jsx(Yh,{onConfirm:()=>Re(Ee.id,"project"),onCancel:_}):s.jsx(Xh,{onClick:()=>b(`project:${Ee.id}`)})]})})]})})})}function VW(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function WW({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:o,textareaContent:c,onSearchMessages:u,onToggleAutoScroll:d,isAutoScrollActive:h}){const[,m]=wn(),f=dn(K=>K.fetchCommands),g=Ut(K=>K.fetchWorkflows),x=ct(K=>K.fetchAgents),w=dn(K=>K.defaults),C=dn(K=>K.userItems),b=dn(K=>K.projectItems),_=Ut(K=>K.defaults),S=Ut(K=>K.userItems),v=Ut(K=>K.projectItems),k=ct(K=>K.defaults),E=ct(K=>K.userItems),N=ct(K=>K.projectItems),L=Fr(),A=pn(L,K=>{var Z;return((Z=K.session)==null?void 0:Z.mode)??null},K=>{var Z;return((Z=K.currentSession)==null?void 0:Z.mode)??null},null),O=pn(L,K=>{var Z;return((Z=K.session)==null?void 0:Z.dangerLevel)??"normal"},K=>{var Z;return((Z=K.currentSession)==null?void 0:Z.dangerLevel)??"normal"},"normal"),I=De(K=>K.switchMode),F=De(K=>K.switchDangerLevel),B=pn(L,K=>{var Z;return((Z=K.session)==null?void 0:Z.projectId)??null},K=>{var Z;return((Z=K.currentSession)==null?void 0:Z.projectId)??null},null),z=pn(L,K=>{var Z;return((Z=K.session)==null?void 0:Z.workdir)??void 0},K=>{var Z;return(Z=K.currentSession)==null?void 0:Z.workdir},void 0),Y=j.useRef(void 0),[q,W]=j.useState(""),[ee,J]=j.useState(0),H=j.useRef(null),P=j.useRef(!1);j.useEffect(()=>{e&&(P.current=!0)},[e]),j.useEffect(()=>{if(e){f(z),g(z),x(z),W(""),J(0);const K=setTimeout(()=>{var Z;Vt()&&((Z=H.current)==null||Z.focus())},50);return()=>clearTimeout(K)}},[e,f,g,x,z]),j.useEffect(()=>{var K;!e&&P.current&&(n==null||n(),(K=Y.current)==null||K.call(Y),Y.current=void 0)},[e,n]);const U=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const K=B??VW(window.location.pathname);K&&m(`/p/${K}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{Y.current=o,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),u==null||u()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!h)}},...rr(rr(k,E),N).filter(K=>!K.subagent&&K.id!==A).map(K=>({id:K.id,name:K.name,prefix:"Agent > Switch to",action:()=>L&&I(L,K.id)})),...rr(rr(w,C),b).map(K=>({id:K.id,name:K.name,prefix:"Command > Launch",action:()=>r(K.id,c)})),...rr(rr(_,S),v).map(K=>({id:K.id,name:K.name,prefix:"Workflow > Run",action:()=>a(K.id,K.scope)})),...["normal","dangerous"].filter(K=>K!==O).map(K=>({id:K,name:K.charAt(0).toUpperCase()+K.slice(1),prefix:"Mode > Switch to",action:()=>L&&F(L,K)}))].filter(K=>aa(`${K.prefix} ${K.name}`,q)),$=U.length-1,Q=K=>{FT(K,$,J,()=>{var Z;(Z=U[ee])==null||Z.action(),t()},t)};return e?wi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx("input",{ref:H,type:"text",value:q,onChange:K=>{W(K.target.value),J(0)},onKeyDown:Q,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx(wb,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),s.jsx(ft,{className:"max-h-[60vh] p-2",children:U.length===0?s.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+_.length+S.length>0?"No matches":"No agents, commands, or workflows yet"}):U.map((K,Z)=>s.jsxs("button",{type:"button",onClick:()=>{K.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${Z===ee?"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:[K.prefix," "]}),s.jsx("span",{children:K.name})]},K.id))})]})]}),document.body):null}const OA="openfox-message-search-filters",GW=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function qW(){try{const e=localStorage.getItem(OA);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function KW(e){localStorage.setItem(OA,JSON.stringify([...e]))}function YW(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 XW(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),c=String(t.getDate()).padStart(2,"0"),u=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${a}/${o}/${c} ${u}:${d}`}function QW(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 JW(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 ZW(e){var n,r;if(e.type!=="message")return s.jsx(b1,{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(Z3,{className:"w-3.5 h-3.5"}):s.jsx(b1,{className:"w-3.5 h-3.5"}):s.jsx(J3,{className:"w-3.5 h-3.5"})}function qk(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",a=r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(n.messageKind==="workflow-started")try{return`Workflow: ${JSON.parse(r).workflowName}`}catch{return"Workflow started"}if(n.messageKind==="task-completed")return"Task completed";if(n.messageKind==="auto-prompt")return"Auto-prompt";if(n.messageKind==="correction")return"Correction";if(n.messageKind==="context-reset")return"Context reset";if(n.messageKind==="command")return"Command executed";if(n.role==="assistant")return a?a.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const o=a.slice(0,200);return o.length<a.length?`${o}...`:o}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function eG({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,o]=j.useState(""),[c,u]=j.useState(0),[d,h]=j.useState(qW),m=j.useRef(null),f=j.useRef(null),g=j.useRef(null),x=E=>{h(N=>{const L=new Set(N);return L.has(E)?L.delete(E):L.add(E),KW(L),L})},w=j.useMemo(()=>n.filter(E=>{var N,L;return!(E.type==="context-divider"||E.type==="message"&&(E.message.messageKind==="auto-prompt"||E.message.role==="assistant"&&!((N=E.message.content)!=null&&N.trim())&&!((L=E.message.thinkingContent)!=null&&L.trim())))}),[n]),C=j.useMemo(()=>w.filter(E=>{const N=YW(E);return!(N&&!d.has(N))}),[w,d]),b=j.useMemo(()=>a?w.filter(E=>{const N=qk(E);return aa(N,a)}):C,[C,a]),_=b.length-1;j.useEffect(()=>{if(e){o(""),u(0);const E=setTimeout(()=>{var N;Vt()&&((N=m.current)==null||N.focus())},50);return()=>clearTimeout(E)}},[e]),j.useEffect(()=>{var E;if(e&&f.current){const N=(E=f.current.osInstance())==null?void 0:E.elements().viewport;N&&(N.scrollTop=N.scrollHeight)}},[e]),j.useEffect(()=>{g.current&&g.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[c]);const S=E=>{FT(E,_,u,()=>{const N=b[c];if(N){const L=n.indexOf(N);L>=0&&r(L),t()}},t)},v=E=>{const N=n.indexOf(E);N>=0&&r(N),t()},k=E=>n.indexOf(E);return e?wi.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(_i,{}),s.jsx("input",{ref:m,type:"text",value:a,onChange:E=>{o(E.target.value),u(0)},onKeyDown:S,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(Ss,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:GW.map(E=>{const N=d.has(E.key);return s.jsx("button",{type:"button",onClick:()=>x(E.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${N?"bg-accent-primary/20 text-accent-primary border border-accent-primary/40":"bg-bg-tertiary text-text-muted border border-border hover:text-text-secondary"}`,children:E.label},E.key)})}),s.jsx(ft,{ref:f,className:"max-h-[60vh] p-2",children:b.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"}):b.map((E,N)=>{const L=k(E),A=ZW(E),O=qk(E),I=JW(E),F=QW(E),B=E.type==="message"&&E.message.role==="user";return s.jsx("button",{ref:N===c?g:null,type:"button",onClick:()=>v(E),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${N===c?"bg-accent-primary/20 text-text-primary":B?"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 ${I}`,children:O})]}),F&&s.jsx("span",{className:"text-text-muted text-xs shrink-0",children:XW(F)})]})},`${L}-${E.type}`)})})]})]}),document.body):null}function IA(e){const t=new Set,n=[],r=/\{\{(\w+)\}\}/g;let a;for(;(a=r.exec(e))!==null;){const o=a[1];t.has(o)||(t.add(o),n.push(o))}return n}function tG(e,t,n){const r=e.trim();if(!r.startsWith("/"))return null;const a=r.slice(1).split(/\s+/),o=a[0];if(!o)return null;const c=a.slice(1),u={},d=t.find(h=>h.id===o);return d?(d.parameters&&d.parameters.length>0?[...d.parameters].sort((m,f)=>(m.position??0)-(f.position??0)).forEach((m,f)=>{c[f]!==void 0&&(u[m.id]=c[f])}):c.forEach((h,m)=>{u[String(m)]=h}),{workflowId:o,params:u}):n&&n.find(m=>m.id===o)?(c.forEach((m,f)=>{u[String(f)]=m}),{commandId:o,params:u}):null}function nG({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const o=j.useRef(null),c=j.useRef(null);j.useEffect(()=>{var h;c.current&&((h=o.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(ft,{ref:o,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg max-h-64",onKeyDown:u,children:e.map((h,m)=>s.jsxs("div",{ref:m===t?c:null,role:"listitem",onClick:()=>d(h.content),className:`
317
+ p-2 rounded cursor-pointer transition-colors
318
+ ${m===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
319
+ `,children:[s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&s.jsxs(s.Fragment,{children:[" | ",s.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),s.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function rG(){const e=A3(),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 sG(){const e=Fr(),t=pn(e,u=>u.activeWorkflowExecution??null,u=>u.activeWorkflowExecution,null),n=De(u=>u.exitWorkflow),[r,a]=j.useState(!1);j.useEffect(()=>{a(!1)},[t==null?void 0:t.id]);const o=j.useCallback(()=>{r||!e||(a(!0),n(e))},[r,n,e]);if(!t||t.status!=="running"&&t.status!=="waiting")return null;const c=t.workflowColor&&/^#[0-9a-fA-F]{6}$/.test(t.workflowColor)?t.workflowColor:"#3b82f6";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border",children:[s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:c}}),s.jsx("span",{className:"font-medium text-text-primary truncate",children:t.workflowName}),t.currentStepName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{className:"text-text-muted truncate",children:t.currentStepName})]}),s.jsx("div",{className:"ml-auto shrink-0",children:s.jsx("button",{onClick:o,disabled:r,className:"text-xs px-2 py-0.5 rounded text-text-tool-error hover:bg-text-tool-error/10 transition-colors disabled:opacity-50",children:r?"Exiting...":"✕ Exit"})})]})}function MA(e,t){const n=De(c=>c.sendMessage),r=De(c=>c.launchWorkflow),a=j.useCallback((c,u,d)=>{e(!0),t&&n(t,c,u,d)},[e,n,t]),o=j.useCallback((c,u,d,h,m,f="auto")=>{e(!0),t&&r(t,c,u,d,h,m,f)},[e,r,t]);return{sendMessage:a,launchWorkflow:o}}function iG({children:e}){return wi.createPortal(e,document.body)}function aG(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 oG({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:o,textareaContent:c,attachments:u}){const[d,h]=j.useState(!1),[m,f]=j.useState("commands"),[g,x]=j.useState(""),[w,C]=j.useState(0),[b,_]=j.useState(null),[S,v]=j.useState(null),k=j.useRef(null),E=j.useRef(null),N=dn(U=>U.defaults),L=dn(U=>U.userItems),A=dn(U=>U.projectItems),O=dn(U=>U.fetchCommands),I=Ut(U=>U.fetchWorkflows),F=De(U=>{var $;return($=U.currentSession)==null?void 0:$.workdir}),B=rr(rr(N,L),A),z=pm();j.useEffect(()=>{d&&(m==="commands"?O(F):m==="workflows"&&I(F))},[d,m,O,I,F]),j.useEffect(()=>{d&&(x(""),C(0),requestAnimationFrame(()=>{var U;Vt()&&((U=k.current)==null||U.focus())}))},[d,m]),j.useEffect(()=>{if(!d)return;const U=$=>{var Q;(Q=E.current)!=null&&Q.contains($.target)||h(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[d]);const Y=U=>{switch(U.key){case"ArrowDown":U.preventDefault(),C($=>{const K=(m==="commands"?B:z).filter(Z=>{const V=g.toLowerCase();return!V||Z.name.toLowerCase().includes(V)});return Math.min($+1,K.length-1)});break;case"ArrowUp":U.preventDefault(),C($=>Math.max($-1,0));break;case"Enter":U.preventDefault();break;case"Escape":U.preventDefault(),h(!1);break}},q=U=>{x(U),C(0)},W=B.filter(U=>!g||U.name.toLowerCase().includes(g.toLowerCase())),ee=z.filter(U=>!g||U.name.toLowerCase().includes(g.toLowerCase())),J=async U=>{const $=await dn.getState().fetchCommand(U,F);$&&e($.prompt,$.metadata.agentMode,c,u),h(!1)},H=(U,$)=>{t(U,$),h(!1)},P=(U,$)=>{$.stopPropagation(),h(!1),_(U)},D=(U,$)=>{$.stopPropagation(),h(!1),v(U)};return s.jsxs("div",{ref:E,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(yE,{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:()=>{f("commands"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),s.jsx("button",{type:"button",onClick:()=>{f("workflows"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),s.jsx("button",{type:"button",onClick:()=>f("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),m!=="attach"&&s.jsx("div",{className:"p-2 border-b border-border",children:s.jsx("input",{ref:k,value:g,onChange:U=>q(U.target.value),onKeyDown:Y,placeholder:m==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),s.jsx(ft,{className:"max-h-64 p-1",children:m==="commands"?W.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:B.length===0?"No commands yet":"No matches"}):W.map((U,$)=>s.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${$===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsx("button",{type:"button",onClick:()=>J(U.id),className:"flex-1 text-left",children:s.jsx("div",{className:"text-sm text-text-primary font-medium",children:U.name})}),s.jsx(vi,{className:"opacity-0 group-hover:opacity-100",onClick:Q=>P(U.id,Q)})]},U.id)):m==="workflows"?ee.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:z.length===0?"No workflows yet":"No matches"}):ee.map((U,$)=>{const Q=aG(U),K=U.color??"#3b82f6";return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${$===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsxs("button",{type:"button",onClick:()=>H(U.id,U.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:K}}),s.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:U.name}),s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:mv[U.scope]}),Q!==null&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Q?"#22c55e":"#6b7280"},title:Q?"Entry condition met":"Entry condition not met"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[U.subGroups&&U.subGroups.length>0&&s.jsx(lG,{subGroups:U.subGroups,onSelect:Z=>{h(!1),n(U.id,Z,U.scope)}}),s.jsx(vi,{className:"opacity-0 group-hover:opacity-100",onClick:Z=>D(U.id,Z)})]})]},`${U.id}-${U.scope}`)}):s.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{o(),h(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[s.jsx(gE,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),s.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),m!=="attach"&&s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{h(!1),m==="commands"?r():a()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:m==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),s.jsx(AA,{isOpen:!!b,onClose:()=>_(null),initialEditId:b,projectDir:F}),s.jsx(DA,{isOpen:!!S,onClose:()=>v(null),initialEditId:S})]})}function lG({subGroups:e,onSelect:t}){const[n,r]=j.useState(!1),[a,o]=j.useState({top:0,right:0}),c=j.useRef(null),u=j.useRef(null);gm(u,()=>r(!1),n);const d=h=>{if(h.stopPropagation(),!n&&c.current){const m=c.current.getBoundingClientRect();o({top:m.bottom+4,right:window.innerWidth-m.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(iG,{children:s.jsx("div",{ref:u,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(h=>s.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),t(h)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:h},h))})})]})}function cG({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(Mu,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function uG({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,model:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h}){var g;const m=e.allowedTools.filter(x=>!(r!=null&&r.has(x))),f=a?(g=a.split("/").pop())==null?void 0:g.replace(/-/g," "):void 0;return s.jsxs(RE,{isBuiltIn:t,isConfirmingDelete:n,onView:o,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"}),f&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent-primary/10 text-accent-primary",children:f})]}),e.description&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[m.slice(0,5).map(x=>s.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:x},x)),m.length>5&&s.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",m.length-5," more"]})]})]})}function Kk({title:e,agentTitle:t="Agents",subagentTitle:n="Sub-agents",agents:r,subagents:a,isBuiltIn:o,alwaysAllowedNames:c,modelOverrides:u,onView:d,onDuplicate:h,onEdit:m,onDelete:f,onCancelDelete:g,isConfirmingDelete:x}){if(r.length===0&&a.length===0)return null;const w=C=>s.jsx(uG,{agent:C,model:u==null?void 0:u[C.id],isBuiltIn:o,isConfirmingDelete:(x==null?void 0:x(C.id))??!1,alwaysAllowedNames:c,onView:()=>d(C.id),onEdit:m?()=>m(C.id):void 0,onDuplicate:()=>h(C.id),onDelete:o?void 0:()=>f==null?void 0:f(C.id),onCancelDelete:o?void 0:()=>g==null?void 0:g(C.id)},C.id);return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),r.length>0&&s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:t}),s.jsxs("div",{className:"space-y-2",children:[r.map(w),a.length>0&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:n}),s.jsx("div",{className:"space-y-2",children:a.map(w)})]})]})]})}function dG(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const a=n.slice(0,r),c=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(c))}}return t}function Eh(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function hG({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:o,formModel:c,formPrompt:u,formError:d,isReadOnly:h,availableTools:m,providers:f,onNameChange:g,onIdChange:x,onDescriptionChange:w,onSubagentChange:C,onToolsChange:b,onColorChange:_,onModelChange:S,onPromptChange:v}){const k=dG(a),E=m.filter(I=>!(r&&I.topLevelOnly)&&!I.isMcp),N=m.filter(I=>I.isMcp&&!(r&&I.topLevelOnly)),L=new Map;for(const I of N){const F=I.mcpServer??I.name,B=L.get(F)??[];B.push(I),L.set(F,B)}const A=(I,F)=>{const B=new Map(k),z=B.get(I)||new Set,Y=new Set(z);Y.has(F)?Y.delete(F):Y.add(F),Y.size===0?B.set(I,new Set):B.set(I,Y),b(Eh(B))},O=I=>{const F=new Map(k);F.has(I)?F.delete(I):F.set(I,new Set),b(Eh(F))};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3",children:[d&&s.jsx(vl,{message:d}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(ns,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),s.jsx(ns,{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(ns,{label:"Description",value:n,onChange:w,placeholder:"What this agent does",readOnly:h}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),s.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[s.jsx("button",{onClick:()=>!h&&C(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${h?"pointer-events-none opacity-60":""}`,children:"Agent"}),s.jsx("button",{onClick:()=>!h&&C(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),s.jsx("input",{type:"color",value:o,onChange:I=>!h&&_(I.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(fv,{providers:f,value:c,onChange:S,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(ft,{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32",children:E.map(I=>{const F=k.has(I.name),B=I.actions.length>0,z=k.get(I.name)||new Set;return B?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:I.name}),s.jsx("span",{className:"text-[10px]",children:"*"})]},I.name):s.jsx(zl,{trigger:s.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${F?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} cursor-pointer`,children:[s.jsx("span",{children:I.name}),z.size>0&&s.jsx("span",{className:"text-[10px]",children:"*"})]}),minWidth:"160px",items:[...I.actions.map(Y=>({label:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${I.name}-${Y}`,children:[s.jsx("input",{type:"checkbox",id:`${I.name}-${Y}`,checked:z.has(Y),onChange:()=>A(I.name,Y),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),s.jsx("span",{children:Y})]}),closeOnClick:!1})),{label:F?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(F)O(I.name);else{const Y=new Map(k);Y.set(I.name,new Set(I.actions)),b(Eh(Y))}}}]},I.name):s.jsx("button",{onClick:()=>!h&&O(I.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${F?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:s.jsx("span",{children:I.name})},I.name)})})]}),L.size>0&&(()=>{const I=new Set(N.map(q=>q.name)),F=k.has("__mcp_none__"),B=[...k.keys()].some(q=>I.has(q)),z=F?"none":B?"partial":"all",Y=q=>{const W=new Map(k);for(const ee of W.keys())(ee==="__mcp_none__"||I.has(ee))&&W.delete(ee);if(q==="none"&&W.set("__mcp_none__",new Set),q==="partial")for(const ee of I)W.set(ee,new Set);b(Eh(W))};return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["MCP Tools ",s.jsx("span",{className:"text-text-muted font-normal",children:"— from connected MCP servers"})]}),s.jsxs("div",{className:"bg-bg-tertiary border border-border rounded overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-4 px-3 py-1.5",children:["all","none","partial"].map(q=>s.jsxs("label",{className:`flex items-center gap-1.5 text-xs cursor-pointer ${h?"pointer-events-none opacity-60":""}`,children:[s.jsx("input",{type:"radio",name:"mcp-mode",checked:z===q,onChange:()=>Y(q),disabled:h,className:"w-3 h-3 accent-accent-primary"}),s.jsxs("span",{className:z===q?"text-text-primary font-medium":"text-text-muted",children:[q.charAt(0).toUpperCase()+q.slice(1),q==="partial"&&I.size>0&&s.jsxs("span",{className:"ml-1 text-text-muted font-normal",children:["(",[...k.keys()].filter(W=>I.has(W)).length,"/",I.size,")"]})]})]},q))}),z==="partial"&&(()=>{const[q,W]=j.useState(""),[ee,J]=j.useState(0),H=j.useRef(null),P=$=>{var K;const Q=(K=H.current)==null?void 0:K.querySelector(`[data-idx="${$}"]`);Q==null||Q.scrollIntoView({block:"nearest"})};j.useEffect(()=>{P(ee)},[ee]);const D=q?N.filter($=>$.name.toLowerCase().includes(q.toLowerCase())):N,U=$=>{$.key==="ArrowDown"?($.preventDefault(),J(Q=>Math.min(Q+1,D.length-1))):$.key==="ArrowUp"?($.preventDefault(),J(Q=>Math.max(Q-1,0))):$.key==="Enter"&&D[ee]&&($.preventDefault(),O(D[ee].name))};return s.jsxs("div",{children:[s.jsx("div",{className:"px-3 py-2 border-b border-border",children:s.jsx("input",{type:"text",value:q,onChange:$=>{W($.target.value),J(0)},onKeyDown:U,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(ft,{className:"max-h-60",children:s.jsxs("div",{ref:H,children:[D.map(($,Q)=>{const K=k.has($.name),Z=Q===ee;return s.jsxs("div",{"data-idx":Q,className:`flex items-center justify-between px-3 py-1.5 transition-colors ${Z?"bg-bg-primary":"hover:bg-bg-primary/30"}`,onMouseEnter:()=>J(Q),children:[s.jsx("span",{className:`text-xs font-mono ${K?"text-text-primary":"text-text-muted"}`,children:$.name}),s.jsx(xs,{enabled:K,onClick:()=>O($.name),label:$.name})]},$.name)}),D.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:I=>!h&&v(I.target.value),readOnly:h,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"opacity-60":""}`})]})]})}function fG(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function mG({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=ct(ae=>ae.defaults),o=ct(ae=>ae.userItems),c=ct(ae=>ae.projectItems),u=ct(ae=>ae.loading),d=ct(ae=>ae.fetchAgents),h=ct(ae=>ae.fetchAgent),m=ct(ae=>ae.fetchDefaultContent),f=ct(ae=>ae.createAgent),g=ct(ae=>ae.updateAgent),x=ct(ae=>ae.deleteAgent),[w,C]=j.useState("list"),[b,_]=j.useState(null),[S,v]=j.useState(!1),[k,E]=j.useState(""),[N,L]=j.useState(""),[A,O]=j.useState(""),[I,F]=j.useState(!1),[B,z]=j.useState([]),[Y,q]=j.useState("#6b7280"),[W,ee]=j.useState(void 0),[J,H]=j.useState(""),[P,D]=j.useState("user"),[U,$]=j.useState(""),[Q,K]=j.useState(!1),[Z,V]=j.useState(!1),[M,X]=j.useState(null),[ne,re]=j.useState([]),[ie,ge]=j.useState(new Set),{requestDelete:ke,clearConfirm:Oe,isConfirming:Fe}=Nu(),we=ae=>{E(ae.metadata.name),L(ae.metadata.id),O(ae.metadata.description),F(ae.metadata.subagent),z(ae.metadata.allowedTools),q(ae.metadata.color??"#6b7280"),H(ae.prompt),$(""),V(!0),xe(`/api/agents/${ae.metadata.id}/model`).then(Re=>Re.json()).then(Re=>{Re.providerId&&Re.model?ee(`${Re.providerId}/${Re.model}`):ee(void 0)}).catch(()=>ee(void 0)).finally(()=>V(!1))},We=(ae,Re,Ve)=>{E(ae.metadata.name+" (copy)"),L(`${Re}-copy-${Date.now()}`),O(ae.metadata.description),F(ae.metadata.subagent),z(ae.metadata.allowedTools),q(ae.metadata.color??"#6b7280"),H(ae.prompt),$(""),_(null),v(!1),C("edit")},Xe=(ae,Re)=>{we(ae),_(Re),v(!0),C("edit")};j.useEffect(()=>{e&&(d(r),xe("/api/tools").then(ae=>ae.json()).then(ae=>{const Re=ae.tools||[];ge(new Set(Re.filter(Ve=>Ve.alwaysAllowed).map(Ve=>Ve.name))),re(Re.filter(Ve=>!Ve.alwaysAllowed))}).catch(()=>{re([]),ge(new Set)}),n?a.some(Re=>Re.id===n)?m(n).then(Re=>{Re&&We(Re,n)}):h(n,r).then(Re=>{Re&&(we(Re),_(n),v(!1),C("edit"))}):(C("list"),_(null),v(!1)))},[e,d,h,m,n,r]);const _e=async ae=>{if(a.some(Ve=>Ve.id===ae)){const Ve=await m(ae);if(!Ve)return;Xe(Ve,ae)}else{const Ve=await h(ae,r);if(!Ve)return;Xe(Ve,ae)}},ye=async ae=>{let Re=await m(ae);Re||(Re=await h(ae,r)),Re&&We(Re,ae)},fe=()=>{_(null),E(""),L(""),O(""),F(!1),z(["read_file"]),q("#6b7280"),H(""),D("user"),$(""),v(!1),C("edit")},oe=async ae=>{const Re=await h(ae,r);Re&&(we(Re),_(ae),v(!1),C("edit"))},Me=ae=>{X(ae)},He=async ae=>{await x(ae,r)},he=async()=>{var an;const ae=b??N;if(!ae||!k||!J){$("Name and prompt are required.");return}K(!0),$("");const Re={metadata:{id:ae,name:k,description:A,subagent:I,allowedTools:B.filter(on=>!ie.has(on)),color:Y},prompt:J},Ve=b?await g(b,Re,r):await f(Re,P,r);if(!Ve.success){K(!1),$(Ve.error??"Failed to save agent.");return}await PA(b??N,W),await d(r);const dt=b??N,vt=Fr(),wt=vt?((an=De.getState().panes[vt])==null?void 0:an.session)??null:De.getState().currentSession;if((wt==null?void 0:wt.mode)===dt&&W&&vt){const{providerId:on,model:fn}=kv(W);De.getState().setSessionProvider(vt,on,fn)}K(!1),n?t():C("list")},Te=()=>{n?t():(C("list"),v(!1))},Qe=ae=>{E(ae),b||L(fG(ae))},me=ct(ae=>ae.modelOverrides),ze=a.filter(ae=>ae.subagent),at=a.filter(ae=>!ae.subagent),Ze=o.filter(ae=>ae.subagent),et=o.filter(ae=>!ae.subagent),ot=c.filter(ae=>ae.subagent),ce=c.filter(ae=>!ae.subagent);return w==="edit"?s.jsxs(s.Fragment,{children:[s.jsxs(jt,{isOpen:e,onClose:Te,title:S?`${k}`:b?"Edit Agent":"New Agent",size:"xl",footer:S?s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{onClick:()=>{E(k+" (copy)"),L(`${b}-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(wE,{onCancel:Te,onSave:he,saving:Q,saveDisabled:!k||!J||Z}),children:[!b&&!S&&s.jsx(Gf,{value:P,onChange:D}),s.jsx(hG,{formName:k,formId:N,formDescription:A,formSubagent:I,formTools:B,formColor:Y,formModel:W,formPrompt:J,formError:U,isReadOnly:S,availableTools:ne,providers:nn.getState().providers,onNameChange:Qe,onIdChange:L,onDescriptionChange:O,onSubagentChange:ae=>{F(ae),ae&&z(Re=>Re.filter(Ve=>{var dt;return!((dt=ne.find(vt=>vt.name===Ve))!=null&&dt.topLevelOnly)}))},onToolsChange:z,onColorChange:q,onModelChange:ee,onPromptChange:H})]}),s.jsx(Yk,{agentId:M,onClose:()=>X(null),onSaved:()=>d(r)})]}):s.jsxs(s.Fragment,{children:[s.jsx(jt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:s.jsx(CE,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:fe,loading:u,hasItems:a.length>0||o.length>0||c.length>0,children:s.jsxs("div",{className:"space-y-4",children:[a.length>0&&s.jsx(Kk,{title:"Built-in",agents:at,subagents:ze,isBuiltIn:!0,alwaysAllowedNames:ie,modelOverrides:me,onView:_e,onEdit:Me,onDuplicate:ye}),(et.length>0||Ze.length>0||ce.length>0||ot.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:et,subagents:Ze},{title:"Project",agents:ce,subagents:ot}].map(ae=>(ae.agents.length>0||ae.subagents.length>0)&&s.jsx(Kk,{title:ae.title,agents:ae.agents,subagents:ae.subagents,isBuiltIn:!1,alwaysAllowedNames:ie,modelOverrides:me,isConfirmingDelete:Re=>Fe(Re,"delete"),onView:_e,onDuplicate:ye,onEdit:oe,onDelete:Re=>{Fe(Re,"delete")?(He(Re),Oe()):ke(Re)},onCancelDelete:Oe},ae.title))})]})]})})}),s.jsx(Yk,{agentId:M,onClose:()=>X(null),onSaved:()=>d(r)})]})}function kv(e){const t=e.indexOf("/");return t>0?{providerId:e.substring(0,t),model:e.substring(t+1)}:{providerId:e,model:e}}async function PA(e,t){if(t){const{providerId:n,model:r}=kv(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 Yk({agentId:e,onClose:t,onSaved:n}){const[r,a]=j.useState(void 0),[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,m]=j.useState(null),f=ct(S=>S.defaults),g=ct(S=>S.userItems),x=ct(S=>S.projectItems),w=[...f,...g,...x],C=e?w.find(S=>S.id===e):void 0,b=nn(S=>S.providers);j.useEffect(()=>{e&&(c(!0),xe(`/api/agents/${e}/model`).then(S=>S.json()).then(S=>{a(S.providerId&&S.model?`${S.providerId}/${S.model}`:void 0)}).catch(()=>a(void 0)).finally(()=>c(!1)))},[e]);const _=async()=>{var S;if(e){d(!0),m(null);try{await PA(e,r);const v=Fr(),k=v?((S=De.getState().panes[v])==null?void 0:S.session)??null:De.getState().currentSession;if((k==null?void 0:k.mode)===e&&r&&v){const{providerId:E,model:N}=kv(r);De.getState().setSessionProvider(v,E,N)}n(),t()}catch{m("Failed to save. Please try again.")}d(!1)}};return s.jsx(jt,{isOpen:!!e,onClose:t,title:`Model — ${(C==null?void 0:C.name)??e??""}`,size:"md",children:s.jsxs("div",{className:"space-y-4 p-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Choose which model to use when this agent is active. This overrides the session/global model."}),o?s.jsx("div",{className:"text-sm text-text-muted py-2",children:"Loading..."}):s.jsx(fv,{providers:b,value:r,onChange:a,defaultLabel:"Default (global model)"}),h&&s.jsx("p",{className:"text-xs text-red-500",children:h}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{onClick:t,className:"px-4 py-1.5 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),s.jsx("button",{onClick:_,disabled:u,className:"px-4 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-50 transition-colors",children:u?"Saving...":"Save"})]})]})})}function pG(){const e=Fr(),t=pn(e,E=>{var N;return((N=E.session)==null?void 0:N.mode)??null},E=>{var N;return((N=E.currentSession)==null?void 0:N.mode)??null},null),n=pn(e,E=>{var N;return((N=E.session)==null?void 0:N.workdir)??void 0},E=>{var N;return(N=E.currentSession)==null?void 0:N.workdir},void 0),r=De(E=>E.switchMode),a=ct(E=>E.defaults),o=ct(E=>E.userItems),c=ct(E=>E.projectItems),u=ct(E=>E.fetchAgents),d=[...a,...o,...c],[h,m]=j.useState(!1),[f,g]=j.useState(!1),[x,w]=j.useState(null),C=j.useRef(null);j.useEffect(()=>{u(n)},[u,n]),gm(C,()=>m(!1));const b=Eu();if(!t)return null;const _=d.filter(E=>!E.subagent),S=_.find(E=>E.id===t),v=(S==null?void 0:S.name)??t,k=oo(d,t);return s.jsxs("div",{className:"relative",ref:C,children:[s.jsxs("button",{type:"button",onClick:()=>m(!h),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[s.jsx("span",{className:"text-sm font-medium",style:{color:k},children:v}),s.jsx(yn,{className:`w-3 h-3 text-text-muted transition-transform ${h?"rotate-180":""}`})]}),h&&_.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:[_.map((E,N)=>{const L=E.id===t,A=oo(d,E.id),O=b.agentSwitching[N],I=O?Sb(O):null;return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${L?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{!L&&e&&r(e,E.id),m(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",style:{color:A},children:E.name}),L&&s.jsx(zs,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),I&&s.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:I})]},E.id)}),s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{m(!1),g(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),s.jsx(mG,{isOpen:f,onClose:()=>{g(!1),w(null)},initialEditId:x,projectDir:n})]})}function gG(){const e=Fr(),t=pn(e,r=>{var a;return((a=r.session)==null?void 0:a.dangerLevel)??"normal"},r=>{var a;return((a=r.currentSession)==null?void 0:a.dangerLevel)??"normal"},"normal"),n=De(r=>r.switchDangerLevel);return e?s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[s.jsx("button",{type:"button",onClick:()=>n(e,"normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${t==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),s.jsx("button",{type:"button",onClick:()=>n(e,"dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${t==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]}):null}function Xk({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 xG=[8080,11434,8e3,1234];function Vy(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function BA(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 yG({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:o,onTestParams:c,onShowRaw:u}){var d,h,m,f,g,x,w,C,b,_,S,v,k,E,N,L,A,O,I,F,B,z,Y,q,W,ee,J,H,P,D,U,$,Q,K,Z,V,M,X,ne,re,ie,ge,ke,Oe,Fe;return s.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>o(e.id),disabled:n.progress[e.id]==="probing",className:"px-4 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:n.progress[e.id]==="probing"?"Probing...":"Auto-config"}),n.progress[e.id]==="done"&&s.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&s.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),s.jsxs("div",{className:"flex gap-3 items-end",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),s.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:we=>a(e.id,{contextWindow:parseInt(we.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:we=>a(e.id,{supportsVision:we.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:(m=r[e.id+"-thinking"])==null?void 0:m.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:(f=r[e.id+"-thinking"])!=null&&f.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:(b=r[e.id+"-non-thinking"])==null?void 0:b.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(_=r[e.id+"-non-thinking"])!=null&&_.loading?"Testing...":"Test non-thinking"}),((S=r[e.id+"-non-thinking"])==null?void 0:S.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((v=r[e.id+"-non-thinking"])==null?void 0:v.error)&&s.jsx("span",{className:"text-xs text-red-500",title:(k=r[e.id+"-non-thinking"])==null?void 0:k.error,children:"Fail"}),((E=r[e.id+"-non-thinking"])==null?void 0:E.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(yn,{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:((N=t[e.id])==null?void 0:N.thinkingEnabled)??!1,onChange:we=>a(e.id,{thinkingEnabled:we.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"})]}),((L=t[e.id])==null?void 0:L.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:we=>a(e.id,{thinkingLevel:we.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(we=>s.jsx("option",{value:we,children:we},we))}):s.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((I=t[e.id])==null?void 0:I.thinkingLevel)??"",onChange:we=>a(e.id,{thinkingLevel:we.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsx(Xk,{value:(F=t[e.id])==null?void 0:F.thinkingQueryParams,onChange:we=>a(e.id,{thinkingQueryParams:we})})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((B=t[e.id])==null?void 0:B.nonThinkingEnabled)??!1,onChange:we=>a(e.id,{nonThinkingEnabled:we.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"})]}),((z=t[e.id])==null?void 0:z.nonThinkingEnabled)&&s.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:s.jsx(Xk,{value:(Y=t[e.id])==null?void 0:Y.nonThinkingQueryParams,onChange:we=>a(e.id,{nonThinkingQueryParams:we})})})]}),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:((q=t[e.id])==null?void 0:q.temperature)??"",onChange:we=>a(e.id,{temperature:we.target.value?parseFloat(we.target.value):void 0}),placeholder:((ee=(W=t[e.id])==null?void 0:W.defaultTemperature)==null?void 0:ee.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((J=t[e.id])==null?void 0:J.defaultTemperature)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(H=t[e.id])==null?void 0:H.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:((P=t[e.id])==null?void 0:P.topP)??"",onChange:we=>a(e.id,{topP:we.target.value?parseFloat(we.target.value):void 0}),placeholder:((U=(D=t[e.id])==null?void 0:D.defaultTopP)==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"}),(($=t[e.id])==null?void 0:$.defaultTopP)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Q=t[e.id])==null?void 0:Q.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:((K=t[e.id])==null?void 0:K.topK)??"",onChange:we=>a(e.id,{topK:we.target.value?parseInt(we.target.value):void 0}),placeholder:((V=(Z=t[e.id])==null?void 0:Z.defaultTopK)==null?void 0:V.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: ",(X=t[e.id])==null?void 0:X.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:((ne=t[e.id])==null?void 0:ne.maxTokens)??"",onChange:we=>a(e.id,{maxTokens:we.target.value?parseInt(we.target.value):void 0}),placeholder:((ie=(re=t[e.id])==null?void 0:re.defaultMaxTokens)==null?void 0:ie.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ge=t[e.id])==null?void 0:ge.defaultMaxTokens)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(ke=t[e.id])==null?void 0:ke.defaultMaxTokens]})]})]})]}),s.jsx("div",{className:"pt-3 border-t border-border",children:s.jsx(bG,{value:(Oe=t[e.id])==null?void 0:Oe.compactionThreshold,maxTokens:((Fe=t[e.id])==null?void 0:Fe.contextWindow)??e.contextWindow,onChange:we=>a(e.id,{compactionThreshold:we})})})]})]})}function bG({value:e,maxTokens:t,onChange:n}){const o=Math.min(95,Math.floor((t-5e3)/t*100)),c=Math.min(o,Math.ceil(15e3/t*100)),u=Math.min(e??.85,o/100),[d,h]=j.useState(Math.round(u*100));j.useEffect(()=>{const f=Math.min(e??.85,o/100);h(Math.round(f*100))},[e,o]);const m=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,"% · ",Tl(m)]}),s.jsx("button",{type:"button",onClick:()=>{n(void 0),h(Math.round(.85*100))},disabled:e===void 0,className:"text-xs text-accent-primary hover:underline disabled:text-text-muted disabled:no-underline",children:"Default"})]})]}),s.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:c,max:o,step:"1",value:d,onChange:f=>h(Number(f.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 ",Tl(15e3)," tokens · maximum ",o,"% · default 85%"]})]})}function $A({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:o}){const[c,u]=j.useState(r),[d,h]=j.useState(""),[m,f]=j.useState(""),[g,x]=j.useState("unknown"),[w,C]=j.useState(""),[b,_]=j.useState(!1),[S,v]=j.useState(),[k,E]=j.useState(),[N,L]=j.useState(!1),[A,O]=j.useState(null),[I,F]=j.useState([]),[B,z]=j.useState(null),[Y,q]=j.useState(!1),[W,ee]=j.useState(""),[J,H]=j.useState(!0),[P,D]=j.useState({}),[U,$]=j.useState({loading:!1,progress:{}}),[Q,K]=j.useState({}),[Z,V]=j.useState(null),[M,X]=j.useState(new Set),[ne,re]=j.useState(""),[ie,ge]=j.useState(null),[ke,Oe]=j.useState("disconnected"),[Fe,we]=j.useState(!1),[We,Xe]=j.useState(null),[_e,ye]=j.useState([]),[fe,oe]=j.useState(!1),[Me,He]=j.useState(!1),[he,Te]=j.useState(""),[Qe,me]=j.useState(null),ze=j.useRef(null),at=j.useRef(!1),Ze=j.useRef(null),et=j.useRef(null);j.useEffect(()=>{c===1&&e&&requestAnimationFrame(()=>{var Se;Vt()&&((Se=Ze.current)==null||Se.focus())})},[c,e]),j.useEffect(()=>()=>{ze.current!==null&&window.clearTimeout(ze.current)},[]),j.useEffect(()=>{e&&xe("/api/provider-presets").then(async Se=>Se.ok?await Se.json():{presets:[]}).then(Se=>ye(Se.presets)).catch(()=>ye([]))},[e]);function ot(Se,tt){D(Ye=>({...Ye,[Se]:{...Ye[Se],...tt}}))}function ce(Se){X(tt=>new Set(tt).add(Se.id)),D(tt=>({...tt,[Se.id]:{contextWindow:Se.contextWindow,...tt[Se.id]}}))}function ae(Se){if(!Se.trim())return I;const tt=Se.toLowerCase().split(/\s+/).filter(Boolean);return I.filter(Ye=>tt.every(Ue=>Ye.id.toLowerCase().includes(Ue)))}function Re(){const Se=he.trim();if(!Se){me("Enter a model name");return}const tt=Ke=>Ke.toLowerCase().replace(/[-_\s:.]+/g,""),Ye=tt(Se),Ue=I.find(Ke=>tt(Ke.id)===Ye);if(Ue){ce(Ue),me(`"${Ue.id}" is already in the list`),Te(""),!S&&U.progress[Ue.id]!=="probing"&&fn(Ue.id);return}const ue={id:Se,contextWindow:2e5};F(Ke=>[...Ke,ue]),X(Ke=>new Set(Ke).add(ue.id)),D(Ke=>({...Ke,[ue.id]:{contextWindow:ue.contextWindow,thinkingEnabled:!0}})),z(ue.id),Te(""),me(null),O(null)}j.useEffect(()=>{var Se,tt;if(e)if(u(r),h((a==null?void 0:a.name)??""),f((a==null?void 0:a.url)??""),x((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),_((a==null?void 0:a.isLocal)??!1),v(a==null?void 0:a.authAdapter),E(a==null?void 0:a.transportAdapter),O(null),ee((a==null?void 0:a.thinkingField)??""),H((a==null?void 0:a.sendReasoningInMessages)??!0),K({}),V(null),ge(null),Oe("disconnected"),Xe(null),oe(!1),He(!1),Te(""),me(null),(Se=a==null?void 0:a.models)!=null&&Se.length){const Ye={},Ue=new Set;for(const ue of a.models)Ye[ue.id]={contextWindow:ue.contextWindow,supportsVision:ue.supportsVision,thinkingEnabled:ue.thinkingEnabled,thinkingLevel:ue.thinkingLevel??Vy(ue.reasoningEfforts),nonThinkingEnabled:ue.nonThinkingEnabled,thinkingQueryParams:ue.thinkingQueryParams,nonThinkingQueryParams:ue.nonThinkingQueryParams,defaultTemperature:ue.defaultTemperature,defaultTopP:ue.defaultTopP,defaultTopK:ue.defaultTopK,defaultMaxTokens:ue.defaultMaxTokens,temperature:ue.temperature,topP:ue.topP,topK:ue.topK,maxTokens:ue.maxTokens,compactionThreshold:ue.compactionThreshold},ue.selected&&Ue.add(ue.id);if(Ue.size===0)for(const ue of a.models)Ue.add(ue.id);X(Ue),D(Ye),F(a.models),z(o??((tt=a.models[0])==null?void 0:tt.id)??null)}else F([]),D({}),z(null),X(new Set)},[e,r,a==null?void 0:a.id,o]),j.useEffect(()=>{const Se=!!S;c===2&&m&&I.length===0&&!N&&!A&&(!Se||ke==="connected")&&on(m)},[c,ke]),j.useEffect(()=>{!e||!S||!(a!=null&&a.id)||dt(a.id)},[e,k,a==null?void 0:a.id]),j.useEffect(()=>{if(!We)return;const Se=(a==null?void 0:a.id)??ie;if(!Se)return;let tt=!1;const Ye=async()=>{const ue=await dt(Se);tt||ue!=="connected"||(Xe(null),oe(!1),He(!1),await on(m))};Ye();const Ue=window.setInterval(()=>void Ye(),2e3);return()=>{tt=!0,window.clearInterval(Ue)}},[We,ie,a==null?void 0:a.id]);async function Ve(){if(a!=null&&a.id)return a.id;if(ie)return ie;const Se=await xe("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:m,backend:g,authAdapter:S,transportAdapter:k,isLocal:!1,models:[]})});if(!Se.ok)throw new Error("Unable to create provider");const tt=await Se.json();return ge(tt.provider.id),tt.provider.id}async function dt(Se){const tt=await xe(`/api/provider-auth/${Se}/status`);if(!tt.ok)return"error";const Ye=await tt.json(),Ue=Ye.state==="connected"?"connected":Ye.state==="pending"?"pending":Ye.state==="error"?"error":"disconnected";return Oe(Ue),Ue}async function vt(){we(!0),Oe("pending");try{const Se=await Ve(),tt=await xe(`/api/provider-auth/${Se}/login`,{method:"POST"});if(!tt.ok)throw new Error("Unable to start provider sign-in");const Ye=await tt.json();Xe(Ye)}catch{Oe("error")}finally{we(!1)}}async function wt(){var Se;We!=null&&We.userCode&&(await((Se=navigator.clipboard)==null?void 0:Se.writeText(We.userCode)),ze.current!==null&&window.clearTimeout(ze.current),He(!1),requestAnimationFrame(()=>He(!0)),ze.current=window.setTimeout(()=>{He(!1),ze.current=null},1500))}function an(){We&&(window.open(We.directUrl??We.verificationUrl,"_blank","noopener,noreferrer"),oe(!0))}async function on(Se){var tt,Ye;L(!0),O(null),F([]);try{const Ue=new URLSearchParams({url:Se});w&&Ue.set("apiKey",w),g&&Ue.set("backend",g);const ue=k?await xe(`/api/providers/${await Ve()}/models`):await xe(`/api/providers/models?${Ue.toString()}`);if(ue.ok){const Ke=await ue.json();if((tt=Ke.models)!=null&&tt.length){F(Ke.models),z(((Ye=Ke.models[0])==null?void 0:Ye.id)??null);const mt={};for(const Dt of Ke.models)mt[Dt.id]={contextWindow:Dt.contextWindow,thinkingEnabled:!0,thinkingLevel:Vy(Dt.reasoningEfforts),defaultTemperature:Dt.defaultTemperature,defaultTopP:Dt.defaultTopP,defaultTopK:Dt.defaultTopK,defaultMaxTokens:Dt.defaultMaxTokens};D(mt),Ke.models.length===1&&(X(new Set([Ke.models[0].id])),z(Ke.models[0].id),fn(Ke.models[0].id))}}else{const Ke=await ue.json();O(Ke.error??`Failed to fetch models from ${Se}`)}}catch(Ue){O(`Failed to fetch models from ${Se}: ${Ue instanceof Error?Ue.message:"Unknown error"}`)}L(!1)}async function fn(Se){$(tt=>({loading:!0,progress:{...tt.progress,[Se]:"probing"}}));try{const tt=await xe("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:m,apiKey:w||void 0,backend:g||"unknown",models:[{id:Se}]})});if(!tt.ok){const Ue=await tt.json();throw new Error(Ue.error??"Auto-config failed")}const Ye=await tt.json();for(const Ue of Ye.models){const ue={};Ue.contextSource!=="default"&&(ue.contextWindow=Ue.contextWindow,ue.supportsVision=Ue.supportsVision),Ue.thinkingConfig&&(ue.thinkingEnabled=!0,ue.thinkingQueryParams=JSON.stringify(Ue.thinkingConfig)),Ue.nonThinkingConfig&&(ue.nonThinkingEnabled=!0,ue.nonThinkingQueryParams=JSON.stringify(Ue.nonThinkingConfig)),ot(Ue.id,ue),$(Ke=>({...Ke,progress:{...Ke.progress,[Ue.id]:"done"}}))}}catch(tt){console.error("Auto-config error:",tt),$(Ye=>({...Ye,progress:{...Ye.progress,[Se]:"error"}}))}finally{$(tt=>({...tt,loading:!1}))}}async function zn(Se,tt){const Ye=Se+"-"+tt;K(Ue=>({...Ue,[Ye]:{loading:!0}}));try{const Ue=P[Se],ue=await xe("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:m,providerId:(a==null?void 0:a.id)??ie??void 0,transportAdapter:k,model:Se,apiKey:w||void 0,backend:g||"unknown",thinkingField:W||void 0,mode:tt,modelConfig:{temperature:Ue==null?void 0:Ue.temperature,topP:Ue==null?void 0:Ue.topP,topK:Ue==null?void 0:Ue.topK,maxTokens:Ue==null?void 0:Ue.maxTokens,supportsVision:Ue==null?void 0:Ue.supportsVision,thinkingEnabled:Ue==null?void 0:Ue.thinkingEnabled,thinkingLevel:Ue==null?void 0:Ue.thinkingLevel,nonThinkingEnabled:Ue==null?void 0:Ue.nonThinkingEnabled,thinkingQueryParams:Ue==null?void 0:Ue.thinkingQueryParams,nonThinkingQueryParams:Ue==null?void 0:Ue.nonThinkingQueryParams}})}),Ke=await ue.json();ue.ok?K(mt=>({...mt,[Ye]:{loading:!1,result:JSON.stringify(Ke,null,2),message:Ke.message}})):K(mt=>({...mt,[Ye]:{loading:!1,error:Ke.error??"Test failed"}}))}catch(Ue){K(ue=>({...ue,[Ye]:{loading:!1,error:Ue instanceof Error?Ue.message:"Request failed"}}))}}function bn(){F([]),D({}),$({loading:!1,progress:{}}),K({}),V(null),X(new Set),re(""),Te(""),me(null)}function gn(){ie&&!at.current&&xe(`/api/providers/${ie}`,{method:"DELETE"}).catch(Se=>{console.warn("Failed to clean up draft provider",Se)}),t()}function hr(){const Se=d||"Provider",tt=(a==null?void 0:a.id)??ie??`temp-${Date.now()}`;n({id:tt,name:Se,url:m,backend:g||"unknown",apiKey:w||void 0,isLocal:b,thinkingField:W||void 0,sendReasoningInMessages:J,authAdapter:S,transportAdapter:k,models:I.map(Ye=>{var Ue,ue,Ke,mt,Dt,Ee,Ae,Be,Je,nt,gt,kt,Mn,Cn,Nn,ho;return{id:Ye.id,name:Ye.name,apiModelId:Ye.apiModelId,requestBody:Ye.requestBody,reasoningEfforts:Ye.reasoningEfforts,contextWindow:((Ue=P[Ye.id])==null?void 0:Ue.contextWindow)??Ye.contextWindow,selected:M.has(Ye.id)||void 0,supportsVision:(ue=P[Ye.id])==null?void 0:ue.supportsVision,thinkingEnabled:(Ke=P[Ye.id])==null?void 0:Ke.thinkingEnabled,thinkingLevel:(mt=P[Ye.id])==null?void 0:mt.thinkingLevel,nonThinkingEnabled:(Dt=P[Ye.id])==null?void 0:Dt.nonThinkingEnabled,thinkingQueryParams:(Ee=P[Ye.id])==null?void 0:Ee.thinkingQueryParams,nonThinkingQueryParams:(Ae=P[Ye.id])==null?void 0:Ae.nonThinkingQueryParams,temperature:(Be=P[Ye.id])==null?void 0:Be.temperature,topP:(Je=P[Ye.id])==null?void 0:Je.topP,topK:(nt=P[Ye.id])==null?void 0:nt.topK,maxTokens:(gt=P[Ye.id])==null?void 0:gt.maxTokens,defaultMaxTokens:(kt=P[Ye.id])==null?void 0:kt.defaultMaxTokens,defaultTemperature:(Mn=P[Ye.id])==null?void 0:Mn.defaultTemperature,defaultTopP:(Cn=P[Ye.id])==null?void 0:Cn.defaultTopP,defaultTopK:(Nn=P[Ye.id])==null?void 0:Nn.defaultTopK,compactionThreshold:(ho=P[Ye.id])==null?void 0:ho.compactionThreshold}})}),at.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(ft,{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:gn,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(Se=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Se<c?"bg-accent-success":Se===c?"bg-accent-primary":"bg-border"}`},Se))}),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:[_e.map(Se=>s.jsx("button",{type:"button",onClick:()=>{h(Se.defaults.name??Se.name),f(Se.defaults.url),x(Se.defaults.backend),_(!1),C(""),v(Se.authAdapter),E(Se.transportAdapter),O(null),bn()},className:`p-2 rounded border text-center text-sm transition-colors ${k&&k===Se.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Se.name},Se.id)),s.jsx("button",{type:"button",onClick:()=>{x("unknown"),_(!1),v(void 0),E(void 0),O(null),bn()},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"),xG.map(Se=>{const tt={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(Ue=>Ue||(Ye[Se]??"")),f(Ue=>Ue||`http://localhost:${Se}`),x(tt[Se]??""),_(!0),v(void 0),E(void 0),O(null),bn()},className:`p-2 rounded border text-center text-sm transition-colors ${g===tt[Se]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Ye[Se]??`localhost:${Se}`},Se)})]})]}),!S&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),s.jsx("input",{ref:Ze,type:"text",value:m,"data-testid":"provider-modal-url",onChange:Se=>{f(Se.target.value),O(null),F([]),D({})},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:Se=>h(Se.target.value),placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!S&&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:Se=>C(Se.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!S&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:b,onChange:Se=>_(Se.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:()=>q(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:s.jsx(bE,{className:"w-4 h-4"})})]}),!!S&&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."})]}),ke==="connected"?s.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):s.jsx("button",{type:"button",onClick:()=>void vt(),disabled:Fe||ke==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:Fe||ke==="pending"?"Connecting...":ke==="error"?"Retry":"Connect"})]}),We&&s.jsx("div",{className:"mt-4 border-t border-border pt-4",children:We.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 wt(),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:We.userCode??"Continue"}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>void wt(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:Me?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:an,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:fe?"Reopen authorization":"Open authorization"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted mb-3",children:We.instructions}),s.jsx("button",{type:"button",onClick:an,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:fe?"Reopen authorization":"Open authorization"})]})})]}),N&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),A&&s.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[s.jsx("p",{children:A}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",m]}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>on(m),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),s.jsx("button",{onClick:()=>{bn(),u(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"}),!S&&s.jsx("button",{onClick:()=>{var Se;return(Se=et.current)==null?void 0:Se.focus()},className:"text-xs text-accent-primary hover:underline",children:"Add model manually"})]})]}),g&&(!S||ke==="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:et,type:"text",value:he,onChange:Se=>{Te(Se.target.value),Qe&&me(null)},onKeyDown:Se=>{Se.key==="Enter"&&(Se.preventDefault(),Re())},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:Re,"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"})]}),Qe&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:Qe})]}),I.length>0&&g&&(!S||ke==="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:I.filter(Se=>M.has(Se.id)).map(Se=>{var tt;return s.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{onClick:()=>z(B===Se.id?null:Se.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:Se.name??Se.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((tt=P[Se.id])==null?void 0:tt.contextWindow)??Se.contextWindow).toLocaleString()," ctx"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[U.progress[Se.id]==="probing"?s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):U.progress[Se.id]==="done"?s.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):U.progress[Se.id]==="error"?s.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):S?null:s.jsx("button",{onClick:Ye=>{Ye.stopPropagation(),fn(Se.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),I.length>1&&s.jsx("button",{onClick:Ye=>{Ye.stopPropagation();const Ue=new Set(M);Ue.delete(Se.id),X(Ue),B===Se.id&&z(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),s.jsx(yn,{className:`w-4 h-4 text-text-muted transition-transform ${B===Se.id?"rotate-180":""}`})]})]}),B===Se.id&&s.jsx(yG,{model:Se,modelConfigs:P,autoConfigState:U,testResults:Q,onUpdateConfig:ot,onRunAutoConfig:fn,onTestParams:zn,onShowRaw:V})]},Se.id)})})]}),I.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:ne,onChange:Se=>re(Se.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),ne&&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 ",ae(ne).length," of ",I.length," models"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{const Se=new Set(M),tt=ae(ne);for(const Ye of tt)Se.add(Ye.id);if(X(Se),D(Ye=>{const Ue={...Ye};for(const ue of tt)Ue[ue.id]={contextWindow:ue.contextWindow,...Ue[ue.id]};return Ue}),!S)for(const Ye of tt)U.progress[Ye.id]!=="probing"&&U.progress[Ye.id]!=="done"&&fn(Ye.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),s.jsx("button",{onClick:()=>{const Se=new Set(M),tt=ae(ne);for(const Ye of tt)Se.delete(Ye.id);X(Se)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),s.jsxs(ft,{className:"space-y-1 max-h-48 border border-border rounded-lg bg-bg-primary",children:[ae(ne).map(Se=>{var Ye;const tt=M.has(Se.id);return s.jsxs("div",{role:"checkbox","aria-checked":tt,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${tt?"bg-accent-primary/5":""}`,onClick:()=>{if(tt){const Ue=new Set(M);Ue.delete(Se.id),X(Ue)}else ce(Se),S||fn(Se.id)},onKeyDown:Ue=>{(Ue.key==="Enter"||Ue.key===" ")&&(Ue.preventDefault(),Ue.currentTarget.click())},children:[s.jsx("input",{type:"checkbox",checked:tt,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:Se.name??Se.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Ye=P[Se.id])==null?void 0:Ye.contextWindow)??Se.contextWindow).toLocaleString()," ctx"]}),U.progress[Se.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"}),U.progress[Se.id]==="done"&&s.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),U.progress[Se.id]==="error"&&s.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},Se.id)}),ae(ne).length===0&&s.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",ne,"”"]})]})]})]})]}),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&&bn(),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:gn,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:!m,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):s.jsx("button",{onClick:hr,disabled:U.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:U.loading?"Configuring...":"Save Provider"})]})]})]}),Y&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:Se=>{Se.target===Se.currentTarget&&q(!1)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),s.jsx("button",{onClick:()=>q(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'reasoning_effort: "low"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",s.jsx("span",{className:"text-text-muted",children:"(override)"})]}),s.jsx("input",{type:"text",value:W,onChange:Se=>ee(Se.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),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:J,onChange:Se=>H(Se.target.checked),className:"rounded border-border bg-bg-primary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"Send reasoning in messages"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:"When disabled, strips reasoning/thinking content from assistant messages sent to this provider"})]})]}),s.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:s.jsx("button",{onClick:()=>q(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),Z&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:Se=>{Se.target===Se.currentTarget&&V(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:()=>V(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx(ft,{horizontal:!0,children:s.jsx("pre",{className:"px-6 py-4 text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:Z})})]})})]}):null}function Qk({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 vG(){var Ue;const[,e]=wn(),t=Fr(),n=pn(t,ue=>ue.session??null,ue=>ue.currentSession,null),r=De(ue=>ue.setSessionProvider),[a,o]=j.useState(!1),[c,u]=j.useState([]),[d,h]=j.useState(null),m=j.useRef(null),[f,g]=j.useState(null),[x,w]=j.useState(!1),[C,b]=j.useState({}),[_,S]=j.useState(null),[v,k]=j.useState(null),[E,N]=j.useState(!1),L=j.useRef(null),[A,O]=j.useState(!1),I=j.useRef(new Set),F=nn(ue=>ue.providers),B=nn(ue=>ue.activeProviderId),z=nn(ue=>ue.defaultModelSelection),Y=nn(ue=>ue.activating),q=nn(ue=>ue.activateProvider),W=nn(ue=>ue.refreshModel),ee=nn(ue=>ue.refreshProviderModels),J=nn(ue=>ue.setDefaultModel),H=nn(ue=>ue.fetchConfig),P=Eu();pu(P.modelSelector,()=>o(ue=>!ue));const D=(n==null?void 0:n.providerId)??null,U=(n==null?void 0:n.providerModel)??null,$=(z==null?void 0:z.split("/")[0])??null,Q=(z==null?void 0:z.split("/").slice(1).join("/"))??null,K=ct(ue=>ue.defaults),Z=ct(ue=>ue.userItems),V=ct(ue=>ue.modelOverrides),M=n==null?void 0:n.mode,X=M?K.find(ue=>ue.id===M)??Z.find(ue=>ue.id===M):void 0,ne=M?V[M]??void 0:void 0,re=ne?ne.split("/")[0]??null:null,ie=ne?ne.split("/").slice(1).join("/")??null:null,ge=M?oo([...K,...Z],M):void 0,ke=!!ne,Oe=re??D??$,Fe=ie??U??Q,we=Fe?((Ue=Fe.split("/").pop())==null?void 0:Ue.replace(/-/g," "))??Fe:"No model",[We,Xe]=j.useState(!1);j.useEffect(()=>{function ue(Ke){m.current&&!m.current.contains(Ke.target)&&(o(!1),u([]),I.current=new Set)}return document.addEventListener("mousedown",ue),()=>document.removeEventListener("mousedown",ue)},[]),j.useEffect(()=>()=>{L.current!==null&&window.clearTimeout(L.current)},[]),j.useEffect(()=>{a||(an(""),fn(-1))},[a]),j.useEffect(()=>{var ue;a&&Vt()&&((ue=Se.current)==null||ue.focus())},[a]),j.useEffect(()=>{if(a){const ue=F.map(Ke=>Ke.id);u(ue),F.filter(Ke=>!!Ke.authAdapter).forEach(Ke=>void me(Ke.id)),ue.forEach(Ke=>{I.current.has(Ke)||(I.current.add(Ke),Me(Ke))})}},[a,F]),j.useEffect(()=>{if(!v)return;let ue=!1;const Ke=async()=>{const Dt=await me(v.providerId);ue||Dt==="connected"&&(k(null),N(!1),O(!1),await H(),I.current.delete(v.providerId),await Me(v.providerId))};Ke();const mt=window.setInterval(()=>void Ke(),2e3);return()=>{ue=!0,window.clearInterval(mt)}},[v]);const _e=F.find(ue=>ue.id===Oe),ye=(_e==null?void 0:_e.status)==="disconnected",fe=(ue,Ke)=>n?n.providerId===ue&&n.providerModel===Ke:!1,oe=(ue,Ke)=>z?z===`${ue}/${Ke}`:!1,Me=async ue=>{h(ue);try{await ee(ue)}catch{}finally{h(null)}},He=ue=>{c.includes(ue.id)?u(c.filter(Ke=>Ke!==ue.id)):(u([...c,ue.id]),Me(ue.id))},he=async ue=>{if(ue.id===B){He(ue);return}n&&t?(r(t,ue.id,void 0),o(!1),u([])):await q(ue.id)&&(o(!1),u([]))},Te=ue=>{He(ue)},Qe=async(ue,Ke)=>{ue.stopPropagation(),I.current.delete(Ke),await Me(Ke)},me=async ue=>{const Ke=await xe(`/api/provider-auth/${ue}/status`);if(!Ke.ok)return"error";const mt=await Ke.json();return b(Dt=>({...Dt,[ue]:mt.state})),mt.state},ze=async(ue,Ke)=>{ue.stopPropagation(),S(Ke),b(mt=>({...mt,[Ke]:"pending"})),N(!1),O(!1);try{const mt=await xe(`/api/provider-auth/${Ke}/login`,{method:"POST"});if(!mt.ok)throw new Error("Unable to start provider sign-in");const Dt=await mt.json();k({providerId:Ke,...Dt})}catch{b(mt=>({...mt,[Ke]:"error"}))}finally{S(null)}},at=async()=>{var ue;v!=null&&v.userCode&&(await((ue=navigator.clipboard)==null?void 0:ue.writeText(v.userCode)),L.current!==null&&window.clearTimeout(L.current),N(!1),requestAnimationFrame(()=>N(!0)),L.current=window.setTimeout(()=>{N(!1),L.current=null},1500))},Ze=()=>{v&&(window.open(v.directUrl??v.verificationUrl,"_blank","noopener,noreferrer"),O(!0))},et=()=>{k(null),N(!1),O(!1)},ot=async(ue,Ke)=>{ue.stopPropagation(),S(Ke);try{if(!(await xe(`/api/provider-auth/${Ke}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");b(Dt=>({...Dt,[Ke]:"disconnected"})),await H()}finally{S(null)}},ce=(ue,Ke)=>{g({providerId:ue,model:Ke}),w(!0)},ae=f?F.find(ue=>ue.id===f.providerId):void 0,Re=()=>{g(null),w(!1)},Ve=async ue=>{try{if(!(await xe(`/api/providers/${ue.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(BA(ue))})).ok)throw new Error("Failed to update provider");await nn.getState().fetchConfig()}catch{}g(null),w(!1)},dt=async(ue,Ke)=>{if(M&&ne&&ne!==`${ue}/${Ke}`&&(xe(`/api/agents/${M}/model`,{method:"DELETE"}).catch(()=>{}),ct.setState(Dt=>{const Ee={...Dt.modelOverrides};return delete Ee[M],{modelOverrides:Ee}})),n&&t){De.setState(Dt=>({...Dt,currentSession:Dt.currentSession?{...Dt.currentSession,providerId:ue,providerModel:Ke}:null})),r(t,ue,Ke),u([]),o(!1),Cu();return}await q(ue)&&(u([]),o(!1),Cu())},vt=async(ue,Ke,mt)=>{ue.stopPropagation(),Xe(!0);try{await J(Ke,mt)}catch{}finally{Xe(!1)}},{searchQuery:wt,setSearchQuery:an,highlightedIndex:on,setHighlightedIndex:fn,visibleGroups:zn,flatItems:bn,handleSearchKeyDown:gn,highlightedRef:hr,inputRef:Se}=MT({providers:F,onSelect:dt,onEscape:()=>o(!1),extraItemCount:1}),tt=on===bn.length,Ye=ue=>{if(ue.key==="Enter"&&on===bn.length){ue.preventDefault(),e("/onboarding"),o(!1);return}gn(ue)};return F.length===0?s.jsxs("button",{type:"button",onClick:()=>W(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:ye?"LLM server is offline. Click to retry.":we??"Click to refresh model",children:[ye?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):s.jsx(Qk,{activeProvider:_e,shortModelName:we,agentOverrideActive:ke,agentColor:ge,agentName:X==null?void 0:X.name}),s.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):s.jsxs("div",{className:"relative",ref:m,children:[s.jsxs("button",{type:"button",onClick:()=>o(!a),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[ye?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):s.jsx(Qk,{activeProvider:_e,shortModelName:we,agentOverrideActive:ke,agentColor:ge,agentName:X==null?void 0:X.name}),s.jsx(yn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(_i,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:Se,type:"text",value:wt,onInput:ue=>{an(ue.currentTarget.value),fn(-1)},onKeyDown:Ye,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsx(ft,{className:"flex-1 min-h-0",children:s.jsxs("div",{children:[zn.map(ue=>{const Ke=wt.trim().length>0||c.includes(ue.provider.id);return s.jsxs("div",{children:[s.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${ue.provider.id===Oe?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${Y?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[s.jsxs("div",{onClick:()=>!Y&&he(ue.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[s.jsx("span",{className:`text-sm font-medium truncate ${ue.provider.id===Oe?"text-accent-primary":"text-text-primary"}`,children:ue.provider.name}),s.jsx("span",{className:"text-xs text-text-muted truncate",children:ue.provider.backend!=="unknown"&&iE(ue.provider.backend)})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!ue.provider.authAdapter&&(C[ue.provider.id]==="connected"||ue.provider.credentialRef?s.jsx("button",{type:"button",onClick:mt=>ot(mt,ue.provider.id),disabled:_===ue.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:mt=>ze(mt,ue.provider.id),disabled:_===ue.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:_===ue.provider.id?"Starting…":C[ue.provider.id]==="error"||C[ue.provider.id]==="expired"?"Retry":"Connect"})),ue.provider.id===Oe?s.jsx("span",{className:"text-accent-success",title:"Active provider",children:s.jsx(zs,{className:"w-4 h-4"})}):s.jsx("span",{className:"w-4"}),s.jsx("button",{type:"button",onClick:mt=>{mt.stopPropagation(),Qe(mt,ue.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:s.jsx(Uf,{className:`w-4 h-4 ${d===ue.provider.id?"animate-spin":""} ${ue.provider.id===B?"text-accent-primary":"text-text-muted"}`})}),s.jsx("button",{type:"button",onClick:mt=>{mt.stopPropagation(),Te(ue.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:s.jsx(yn,{className:`w-4 h-4 transition-transform ${Ke?"rotate-180":""} ${ue.provider.id===B?"text-accent-primary":"text-text-muted"}`})})]})]}),Ke&&s.jsx(ft,{className:"bg-bg-primary border-t border-border max-h-40",children:d===ue.provider.id?s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):ue.models.length>0?ue.models.map(mt=>{const Ee=bn.findIndex(Ae=>Ae.providerId===ue.provider.id&&Ae.modelConfig.id===mt.id)===on;return s.jsx("div",{ref:Ee?hr:void 0,children:s.jsx(IT,{providerId:ue.provider.id,modelConfig:mt,isActive:fe(ue.provider.id,mt.id),isDefault:oe(ue.provider.id,mt.id),disabled:d==="activating",hasSession:!!n,settingDefault:We,highlighted:Ee,onModelClick:dt,onSetDefault:vt,onEditModel:ce})},`${ue.provider.id}/${mt.id}`)}):s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},ue.provider.id)}),zn.length===0&&wt.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 ${tt?"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:ue=>{ue.target===ue.currentTarget&&et()},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:et,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:at,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:E?"Copied to clipboard":"Click the code to copy it"}),s.jsxs("div",{className:"mt-6 flex gap-3",children:[s.jsx("button",{type:"button",onClick:at,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:E?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:Ze,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:A?"Reopen authorization":"Open authorization"})]}),s.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:A?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:v.instructions}),s.jsx("div",{className:"mt-6 flex gap-3",children:s.jsx("button",{type:"button",onClick:Ze,className:"w-full rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:A?"Reopen authorization":"Open authorization"})})]})]})}),f&&x&&s.jsx($A,{isOpen:!0,onClose:Re,onSave:Ve,initialStep:2,editProvider:{id:f.providerId,name:(ae==null?void 0:ae.name)??"",url:(ae==null?void 0:ae.url)??"",backend:(ae==null?void 0:ae.backend)??"unknown",apiKey:ae==null?void 0:ae.apiKey,isLocal:ae==null?void 0:ae.isLocal,thinkingField:ae==null?void 0:ae.thinkingField,sendReasoningInMessages:ae==null?void 0:ae.sendReasoningInMessages,authAdapter:ae==null?void 0:ae.authAdapter,transportAdapter:ae==null?void 0:ae.transportAdapter,models:ae==null?void 0:ae.models},editModelId:f.model.id})]})}function _G(){const e=du(k=>k.servers),t=du(k=>k.fetchServers),n=De(k=>k.currentSession),r=n==null?void 0:n.id,[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(new Set),[m,f]=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 E=await k.json();f(new Set(E.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]),gm(g,()=>o(!1));const C=k=>m.has(k.name),b=e.filter(k=>k.status==="connected"&&!C(k)),_=b.length,S=b.reduce((k,E)=>k+E.estimatedTokens,0),v=async(k,E)=>{if(r){u(null),h(N=>new Set(N).add(k));try{const N=new Set(m);E?N.add(k):N.delete(k);const L=await xe(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(N)})});if(!L.ok){const A=await L.json().catch(()=>({}));throw new Error(A.error??"Toggle failed")}f(N),await t()}catch(N){u(N instanceof Error?N.message:String(N))}finally{h(N=>{const L=new Set(N);return L.delete(k),L})}}};return s.jsxs("div",{className:"relative",ref:g,children:[s.jsxs("button",{type:"button",onClick:()=>o(!a),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:_>0?`${_} MCP server(s) active`:"No MCP server active",children:[s.jsx("span",{className:"text-sm text-accent-primary whitespace-nowrap",children:_>0?`● ${_} MCP (${ff(S)})`:"MCP"}),s.jsx(yn,{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(ft,{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 E=C(k),N=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 ${cv(E?"disabled":k.status)}`,children:uv(E?"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:[ff(k.estimatedTokens)," tokens"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[N&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"..."}),s.jsx(xs,{enabled:!E,onClick:()=>v(k.name,!E)})]})]})},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 SG({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:o,errorMessage:c,setErrorMessage:u,scrollToBottom:d,sessionId:h,showHistory:m,history:f,selectedIndex:g,openHistory:x,closeHistory:w,navigateUp:C,navigateDown:b,selectCurrent:_,isAutoScrollActive:S,setAutoScroll:v,onOpenMessageSearch:k,onOpenCommandsModal:E,onOpenWorkflowsModal:N,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:A,onSendCommand:O,clearInput:I}){const F=j.useRef(null),B=j.useRef(null),z=j.useRef(0),Y=j.useRef(0),q=j.useRef(null),W=j.useRef(null),ee=$f(h),J=De(me=>me.stopGeneration),H=De(me=>me.cancelQueued),P=T3(h),D=pn(h,me=>me.restoredInput??null,me=>me.restoredInput,null),U=De(me=>me.clearRestoredInput),$=pn(h,me=>{var ze;return((ze=me.session)==null?void 0:ze.workdir)??void 0},me=>{var ze;return(ze=me.currentSession)==null?void 0:ze.workdir},void 0),Q=pn(h,me=>me.session??null,me=>me.currentSession,null),K=j.useRef(!1),Z=j.useRef(void 0),V=j.useRef(!1),[M,X]=j.useState([]),ne=j.useRef(null),{sendMessage:re,launchWorkflow:ie}=MA(v,h);j.useEffect(()=>{Z.current!==$&&(Z.current=$,Ut.getState().fetchWorkflows($),dn.getState().fetchCommands($))},[$]),j.useEffect(()=>{e||X([])},[e]),j.useEffect(()=>{var me;D!==null&&(t(D),U(h),Vt()&&((me=F.current)==null||me.focus()))},[D,t,U]);const ge=j.useCallback(()=>{const me=F.current;if(!me)return;const ze=e.length>=z.current;z.current=e.length,ze||(me.style.height="auto"),me.style.height=`${Math.min(200,me.scrollHeight)}px`},[e]);j.useEffect(()=>{if(!h)return;const me=`openfox:draft:${h}`,ze=localStorage.getItem(me);ze!==null&&t(ze)},[h,t]),j.useEffect(()=>{var me;Vt()&&((me=F.current)==null||me.focus()),ge()},[h,ge]),j.useEffect(()=>{if(!h)return;const me=`openfox:draft:${h}`,ze=setTimeout(()=>{e?localStorage.setItem(me,e):localStorage.removeItem(me)},500);return()=>clearTimeout(ze)},[h,e]),j.useEffect(()=>{ge()},[e,ge]),j.useEffect(()=>{const me=F.current;if(!me)return;const ze=async at=>{var ot;if(document.activeElement!==me)return;const Ze=(ot=at.clipboardData)==null?void 0:ot.items;if(!Ze)return;const et=[];for(const ce of Array.from(Ze)){let ae=ce.getAsFile();if(ae&&SU(ae.type)){if(at.preventDefault(),!ae.name){const Re=_U(ae.type);ae=new File([ae],`pasted-file.${Re}`,{type:ae.type})}await zy(ae,Re=>et.push(Re),u)}}et.length>0&&r(ce=>[...ce,...et])};return me.addEventListener("paste",ze),()=>me.removeEventListener("paste",ze)},[r,u]);const ke=me=>{me.preventDefault(),!(!e.trim()&&n.length===0)&&oe()},Oe=me=>{var ze,at;if(!((ze=W.current)!=null&&ze.handleKeyDown(me))&&!((at=q.current)!=null&&at.handleKeyDown(me))){if(m)switch(me.key){case"Enter":{me.preventDefault();const Ze=_();Ze&&(t(Ze),w());return}case"Escape":me.preventDefault(),w(),ee&&h&&J(h);return;case"ArrowUp":me.preventDefault(),C();return;case"ArrowDown":me.preventDefault(),b();return}if(me.key==="ArrowUp"&&e.trim()===""&&!m){me.preventDefault(),x();return}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),ke(me))}};async function Fe(me,ze,at){const Ze=[];for(const et of Array.from(me))await zy(et,ot=>Ze.push(ot),at);Ze.length>0&&ze(et=>[...et,...Ze])}const we=j.useCallback(async me=>{const ze=me.target.files;!ze||ze.length===0||(u(null),await Fe(ze,r,u),B.current&&(B.current.value=""))},[r,u]),We=j.useCallback(me=>{var ze;(ze=me.dataTransfer.types)!=null&&ze.includes("Files")&&(me.preventDefault(),me.stopPropagation(),o(!0))},[o]),Xe=j.useCallback(me=>{me.preventDefault(),me.stopPropagation(),o(!1)},[o]),_e=j.useCallback(async me=>{me.preventDefault(),me.stopPropagation(),o(!1),u(null);const ze=me.dataTransfer.files;!ze||ze.length===0||await Fe(ze,r,u)},[r,o,u]),ye=j.useCallback(me=>{r(n.filter(ze=>ze.id!==me))},[n,r]),fe=j.useCallback(()=>{var me;(me=B.current)==null||me.click()},[]),oe=()=>{if(V.current||!e.trim()&&n.length===0)return;if(V.current=!0,d==null||d(),e.trim().startsWith("/")){const ze=lo(Ut.getState()),at=dn.getState(),Ze=rr(rr(at.defaults,at.userItems),at.projectItems),et=tG(e,ze,Ze);if(et!=null&&et.workflowId){const ot=ne.current,ce=ot&&ot.id===et.workflowId?ot.scope:"auto";ne.current=null;const ae=$y(ze,et.workflowId,ce),Re=((ae==null?void 0:ae.parameters)??[]).filter(Ve=>Ve.required&&!(Ve.id in et.params));if(Re.length>0){const Ve=Re.map(dt=>dt.label||dt.id).join(", ");u(`Missing required parameter${Re.length>1?"s":""}: ${Ve}`),V.current=!1;return}ie(void 0,void 0,et.workflowId,void 0,et.params,ce),I(),V.current=!1;return}if(et!=null&&et.commandId){at.fetchCommand(et.commandId,$).then(ot=>{if(ot){const ce=IA(ot.prompt),ae={};for(const[Ve,dt]of Object.entries(et.params)){const vt=parseInt(Ve,10),wt=ce[vt];wt&&(ae[wt]=dt)}let Re=ot.prompt;for(const[Ve,dt]of Object.entries(ae))Re=Re.replaceAll(`{{${Ve}}}`,dt);O(Re,ot.metadata.agentMode),I()}V.current=!1});return}}re(e,n),I(),V.current=!1},Me=j.useCallback((me,ze)=>{const Ze=me.type==="directory"?"/":" ",{newText:et,newCursorPos:ot}=gf(e,Y.current,ze,`@${me.path}${Ze}`);t(et),Y.current=ot,xf(F.current,ot)},[e,t]),He=j.useCallback((me,ze)=>{const{newText:at,newCursorPos:Ze}=gf(e,Y.current,ze,`/${me.id} `);t(at),Y.current=Ze,xf(F.current,Ze),me.type==="workflow"&&(ne.current={id:me.id,scope:me.scope}),X(zT(me))},[e,t]),he=j.useCallback(me=>{const ze=me.target.value;t(ze),m&&w(),Y.current=me.target.selectionStart;const at=ne.current;if(at){const Ze=ze.match(/^\/(\S+)/),et=Ze?Ze[1]:void 0;(!et||et!==at.id)&&(ne.current=null)}M.length>0&&(!ze.startsWith("/")||!ze.includes(" "))&&X([]),!K.current&&h&&ze&&Q&&(Q.messageCount??0)===0&&(K.current=!0,xe(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,m,w,h,Q,M]),Te=j.useCallback(me=>{Y.current=me.target.selectionStart},[]),Qe=j.useCallback(me=>{Y.current=me.currentTarget.selectionStart},[]);return s.jsxs("div",{className:"relative",children:[ee&&s.jsx("div",{className:"absolute -top-8 left-2 @md:left-4 z-10",children:s.jsx(rG,{})}),s.jsxs("div",{className:`absolute -top-8 right-2 @md:right-4 z-10 flex items-center gap-2 border${S?" border-transparent":" rounded backdrop-blur-xl saturate-150 border-border"}`,children:[s.jsx(bv,{isActive:S,onToggle:v,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(_i,{}),"Browse history"]})]}),s.jsx(sG,{}),s.jsxs("form",{onSubmit:ke,className:"p-2 @md:p-4 bg-secondary rounded-lg",children:[s.jsx("input",{ref:B,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:we,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(me=>s.jsx(hv,{attachment:me,onRemove:ye},me.id))}),m&&s.jsx(nG,{history:f,selectedIndex:g,onSelect:me=>{t(me),w()},onEscape:w,onNavigate:me=>{me==="up"?C():b()}}),s.jsx(cG,{messages:P,onCancel:me=>h&&H(h,me)}),s.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:We,onDragLeave:Xe,onDrop:_e,children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx("textarea",{id:CT,ref:F,value:e,onChange:he,onKeyDown:Oe,onSelect:Te,onKeyUp:Qe,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(BT,{ref:q,text:e,cursorPos:Y.current,workdir:$,onSelect:Me}),s.jsx(PT,{ref:W,text:e,cursorPos:Y.current,workflows:lo(Ut.getState()),commands:(()=>{const me=dn.getState();return rr(rr(me.defaults,me.userItems),me.projectItems)})(),onSelect:He}),M.length>0&&(()=>{const me=e.match(/\/(\w+)\s+(.*)$/),at=(me?me[2].trim().split(/\s+/):[]).filter(Boolean).length,Ze=M[at];return Ze?s.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[Ze,"=?"]}):null})()]}),s.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[ee&&s.jsxs("button",{type:"button",onClick:()=>h&&J(h),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[s.jsx(bb,{}),"Abort"]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button",onClick:oe,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(oG,{onSendCommand:O,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:A,onOpenCommandsManager:E,onOpenWorkflowsManager:N,onAttach:fe,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pG,{}),s.jsx(gG,{})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[It(me=>me.settings)[Ne.FEATURES_PER_SESSION_MCP]==="true"&&s.jsx(_G,{}),s.jsx(vG,{})]})]})]})]})}const wG=4;function CG({projectId:e}){const[,t]=wn(),n=Bt(w=>w.tasks),r=Bt(w=>w.activeProjectId),a=Bt(w=>w.loadBoard),o=Bt(w=>w.moveTask),c=Bt(w=>w.lastError),[u,d]=j.useState(!1),[h,m]=j.useState(null);j.useEffect(()=>{r!==e&&a(e)},[r,e,a]);const f=j.useMemo(()=>n.filter(w=>w.status==="todo"&&w.sessionIds.length===0).sort((w,C)=>w.position-C.position).slice(0,wG),[n]),g=j.useMemo(()=>n.filter(w=>w.status==="in_progress"&&w.runState==="running").length,[n]);if(f.length===0)return null;const x=async w=>{var b;m(null);const C=await o(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"&&m({label:((b=w.prompt.split(`
320
+ `)[0])==null?void 0:b.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(vb,{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(st,{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:()=>m(null),title:"Dismiss",className:"shrink-0 text-xs text-text-muted underline hover:text-text-primary transition-colors",children:"Dismiss"})]})}),s.jsx("ul",{className:"mt-3 space-y-2",children:f.map((w,C)=>s.jsxs("li",{className:"flex items-start justify-between gap-3 rounded-md border border-border bg-bg-secondary px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-text-primary font-medium leading-snug line-clamp-2 break-words whitespace-pre-wrap",children:w.prompt}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-text-muted",children:[w.attachments.length>0&&s.jsxs("span",{children:["📎 ",w.attachments.length]}),w.model&&s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary border border-border",children:w.model})]})]}),s.jsxs(st,{variant:C===0?"primary":"secondary",size:"sm",onClick:()=>void x(w),className:"shrink-0 flex items-center gap-1",children:["Start ",s.jsx(Ff,{className:"w-3 h-3"})]})]},w.id))}),c&&s.jsx("div",{className:"mt-3 text-sm text-accent-error",children:c})]}),s.jsx(gv,{isOpen:u,onClose:()=>d(!1),projectId:e})]})}function Jk({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[o,c]=j.useState({}),u=[...t].sort((m,f)=>(m.position??0)-(f.position??0)),d=()=>{var f;const m={};for(const g of u){const x=(f=o[g.id])==null?void 0:f.trim();x&&(m[g.id]=x)}n(m)},h=u.every(m=>{var f;return!m.required||(((f=o[m.id])==null?void 0:f.trim())??"")!==""});return s.jsxs(jt,{isOpen:!0,onClose:r,title:`Run: ${e}`,size:"sm",closeOnEscape:!0,closeOnBackdropClick:!0,children:[s.jsx("div",{className:"space-y-3 py-2",children:u.map(m=>s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[m.label||m.id,m.required&&s.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),m.description&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:m.description}),s.jsx("input",{value:o[m.id]??"",onChange:f=>c(g=>({...g,[m.id]:f.target.value})),placeholder:m.label||m.id,className:"mt-1 w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:(m.position===0||m===u[0])&&Vt()})]},m.id))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border",children:[s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm text-text-muted hover:text-text-primary transition-colors",children:"Cancel"}),s.jsx("button",{onClick: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 Zk=9999,Nh=j.forwardRef(function({trigger:t,children:n},r){const[a,o]=j.useState(!1),c=j.useRef(null),u=j.useRef(null),d=j.useRef(null),h=j.useCallback(()=>{o(!1)},[]);j.useImperativeHandle(r,()=>({close:h}),[h]);const m=j.useCallback(f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a?h():(d.current=document.activeElement,o(!0))),f.key==="Escape"&&a&&h()},[a,h]);return j.useEffect(()=>{var w;if(!a){Vt()&&((w=d.current)==null||w.focus()),d.current=null;return}const f=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",f),document.addEventListener("keydown",g),window.addEventListener("blur",x),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",g),window.removeEventListener("blur",x)}},[a,h]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref: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),o(f=>!f)},onKeyDown:m,children:t}),a&&wi.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:Zk,top:0,left:0};const f=c.current.getBoundingClientRect(),g=320,x=8;let w=f.left;return w+g>window.innerWidth-x&&(w=f.right-g),w=Math.max(x,Math.min(w,window.innerWidth-g-x)),{zIndex:Zk,top:f.bottom+4,left:w}})(),children:s.jsx(ft,{className:"max-h-full",children:n})}),document.body)]})});function kG({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=tA.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(Hl,{status:r}),s.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function jG({visible:e}){const t=De(M=>M.currentSession),n=tr(M=>M.status),r=tr(M=>M.config),a=tr(M=>M.start),o=De(M=>M.contextState),c=De(M=>M.queueUpdate),u=tr(M=>M.logs),{branch:d,diff:h}=xv(),[m,f]=j.useState(!1),[g,x]=j.useState(!1),[w,C]=j.useState(!1),[b,_]=j.useState(null),[S,v]=j.useState(!1),[k,E]=j.useState(!1),N=j.useRef(null),L=j.useRef(null),A=j.useRef(null),O=j.useRef(null),I=It(M=>M.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!t)return null;const F=Tu(t.workspace??"")||"original",B=t.workspace??t.workdir,z=t.metadataEntries??{},Y=z.criteria??[],q=["review_findings","todos"],W=q.filter(M=>{var X;return M in z&&(((X=z[M])==null?void 0:X.length)??0)>0}),ee=Object.keys(z).filter(M=>M!=="criteria"&&!q.includes(M)).filter(M=>{var X;return(((X=z[M])==null?void 0:X.length)??0)>0}),J=[...W,...ee].reduce((M,X)=>{var ne;return M+(((ne=z[X])==null?void 0:ne.length)??0)},0),H=[...W,...ee].map(Sl),P=h.files,D=P.reduce((M,X)=>M+X.additions,0),U=P.reduce((M,X)=>M+X.deletions,0),$=(n==null?void 0:n.state)??"off",Q=$==="running"||$==="warning",K=r!==null,Z=M=>{M.stopPropagation(),a()},V=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(ss,{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:F}),s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx(eo,{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??"-"}),P.length>0?s.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",D," -",U]}):s.jsx("span",{className:"shrink-0"}),s.jsx(Nh,{ref:O,trigger:s.jsx(yn,{className:"w-3 h-3"}),children:s.jsx(xA,{workspaceName:F,branch:d,workdir:B,showEditorLink:I,sessionId:t.id,projectId:t.projectId,onEditWorkspace:()=>{var M;(M=O.current)==null||M.close(),v(!0)},onEditBranch:()=>{var M;(M=O.current)==null||M.close(),E(!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(kG,{entries:Y}),J>0&&s.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:H.join(", "),children:["+",J]}),s.jsx(Nh,{ref:A,trigger:s.jsx(yn,{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(),_("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(bf,{entries:Y,title:"Acceptance Criteria"})}),s.jsx(sA,{entries:Y,sessionId:t.id})]}),[...W,...ee].map(M=>{const X=z[M];return s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var ne;(ne=A.current)==null||ne.close(),_(M)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(bf,{entries:X,title:Sl(M)})}),s.jsx(nA,{entries:X})]},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:o&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:o.currentTokens>=1e3?`${Math.round(o.currentTokens/1e3)}K`:o.currentTokens}),s.jsx(_v,{percent:Math.round(o.currentTokens/o.maxTokens*100),dangerZone:o.dangerZone,size:"sm"}),s.jsx(Nh,{ref:L,trigger:s.jsx(yn,{className:"w-3 h-3"}),children:s.jsx(bA,{onUpdateSystemPrompt:()=>{var M;(M=L.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 ${$==="running"?"bg-accent-success":$==="warning"?"bg-accent-warning":$==="error"?"bg-accent-error":"bg-text-muted"}`}),K?Q?s.jsx("button",{onClick:V,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(yb,{className:"w-3.5 h-3.5"})}):s.jsx("button",{onClick:Z,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(Hf,{className:"w-3.5 h-3.5"})}):s.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),s.jsx(Nh,{ref:N,trigger:s.jsx(yn,{className:"w-3 h-3"}),children:s.jsx(lA,{workdir:B,compact:!0,onExpand:()=>f(!0),onConfigure:()=>{var M;(M=N.current)==null||M.close(),x(!0)}})})]})]}),m&&s.jsx(vv,{title:"Dev Server Logs",logs:u,onClose:()=>f(!1)}),g&&s.jsx(iA,{isOpen:!0,onClose:()=>x(!1)}),b&&t&&s.jsx(rA,{isOpen:!0,onClose:()=>_(null),entries:z[b]??[],sessionId:t.id,metadataKey:b,title:Sl(b)}),S&&s.jsx(pA,{isOpen:!0,onClose:()=>v(!1),projectId:t.projectId,sessionId:t.id,currentWorkspace:F,currentBranch:d}),k&&s.jsx(gA,{isOpen:!0,onClose:()=>E(!1),sessionId:t.id}),w&&o&&s.jsx(Sv,{isOpen:!0,onClose:()=>C(!1),isRunning:t.isRunning,onApply:()=>{t.isRunning?c(t.id):Ht.send("context.applyDynamic",{sessionId:t.id}),C(!1)}})]})}function EG(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function FA(e,t=[]){const n=new Map,r=new Map;for(const h of t)h.type==="message"?n.set(h.message.id,h):h.type==="subagent"&&r.set(h.subAgentId,h);const a=[];let o,c=1,u=null;const d=()=>{if(!u||u.size===0)return;const h=new Map;let m=0;for(const g of e)g.role!=="tool"&&g.contextWindowId===o&&(g.subAgentId&&!h.has(g.subAgentId)&&h.set(g.subAgentId,m),m++);const f=[...u.entries()].sort((g,x)=>(h.get(g[0])??0)-(h.get(x[0])??0));for(const[g,x]of f){const w=r.get(g);(w==null?void 0:w.type)==="subagent"&&w.messages.length===x.messages.length&&w.messages.every((b,_)=>b===x.messages[_])?a.push(w):a.push({type:"subagent",subAgentId:g,subAgentType:x.subAgentType,messages:x.messages})}u=null};for(let h=0;h<e.length;h++){const m=e[h];if(m.role!=="tool")if(m.contextWindowId&&o&&m.contextWindowId!==o&&(d(),c++,a.push({type:"context-divider",windowSequence:c})),o=m.contextWindowId,m.subAgentId&&m.subAgentType){u||(u=new Map);let f=u.get(m.subAgentId);f||(f={subAgentType:m.subAgentType,messages:[]},u.set(m.subAgentId,f)),f.messages.push(m)}else{d();const f=n.get(m.id);(f==null?void 0:f.type)==="message"&&f.message===m?a.push(f):a.push({type:"message",message:m})}}return d(),a}const NG=10,TG=150;function AG(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 LG(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,NG).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:uU(r.timestamp),trimmedContent:mf(r.content,TG),sessionId:r.sessionId,sessionName:r.sessionName}))}function RG(e,t,n){const r=[],a=e.filter(o=>o.role==="user"&&!o.isSystemGenerated&&o.messageKind!=="auto-prompt");for(const o of a)r.push({id:o.id,content:o.content,timestamp:o.timestamp,sessionId:n??"",sessionName:"This session"});for(const o of t)n&&o.id===n||r.push(...AG(o));return LG(r)}function DG(e,t=[],n=null){const[r,a]=j.useState(0),[o,c]=j.useState(!1),u=j.useMemo(()=>RG(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)},[]),m=j.useCallback(()=>{a(x=>u.length===0?x:x===0?u.length-1:x-1)},[u.length]),f=j.useCallback(()=>{a(x=>u.length===0?x:x===u.length-1?0:x+1)},[u.length]),g=j.useCallback(()=>{if(u.length===0||!o)return null;const x=u[r];return(x==null?void 0:x.content)??null},[u,r,o]);return{history:u,selectedIndex:r,showHistory:o,openHistory:d,closeHistory:h,navigateUp:m,navigateDown:f,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(nr,{content:t.description})})]})]})});function zA({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r,sessionId:a}={}){const o=e??!0,[c,u]=j.useState(""),[d,h]=j.useState([]),[m,f]=j.useState(!1),[g,x]=j.useState(null),[w,C]=j.useState(!1),[b,_]=j.useState(!1),[S,v]=j.useState(!1),[k,E]=j.useState(!1),[N,L]=j.useState(null),A=j.useRef(null),O=Bu(A),I=De(ce=>{var ae;return ce.focusedSessionId??((ae=ce.currentSession)==null?void 0:ae.id)??null}),F=a??I,B=a!=null,z=!B||I===a,Y=pn(B?a:null,ce=>ce.session??null,ce=>ce.currentSession,null),q=pn(B?a:null,ce=>ce.messages,ce=>ce.messages,[]),W=pn(B?a:null,ce=>ce.hiddenCount??0,ce=>ce.hiddenCount,0),ee=De(ce=>ce.sessions),J=$f(B?a:null),H=De(ce=>ce.stopGeneration),P=n??q,{maxVisibleItems:D}=Fs(),U=ct(ce=>ce.defaults),$=ct(ce=>ce.userItems),Q=[...U,...$].filter(ce=>!ce.subagent),{history:K,selectedIndex:Z,showHistory:V,openHistory:M,closeHistory:X,navigateUp:ne,navigateDown:re,selectCurrent:ie}=DG(P,ee,Y==null?void 0:Y.id);j.useEffect(()=>{if(!z)return;const ce=ae=>{L(ae.detail.stats)};return window.addEventListener("open-turn-stats",ce),()=>window.removeEventListener("open-turn-stats",ce)},[z]);const ge=Y==null?void 0:Y.workdir;j.useEffect(()=>{Ut.getState().setWorkdir(ge),ge&&Ut.getState().fetchWorkflows()},[ge]),j.useEffect(()=>{Ut.getState().fetchWorkflows()},[]),j.useEffect(()=>{if(!z)return;const ce=ae=>{EG(ae)&&(ae.preventDefault(),E(!0))};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[z]);const ke=j.useRef([]),{displayItems:Oe,hiddenCount:Fe}=j.useMemo(()=>{const ce=FA(P,ke.current);return ke.current=ce,D>0&&ce.length>D?{displayItems:ce.slice(-D),hiddenCount:ce.length-D}:{displayItems:ce,hiddenCount:0}},[P,D]),we=r??W??Fe,{isAutoScrollActive:We,setAutoScroll:Xe,handleScrollbarGesture:_e}=Pu(A,Y,O),{sendMessage:ye,launchWorkflow:fe}=MA(Xe,F);j.useEffect(()=>{const ce=()=>Xe(!0);return window.addEventListener(wf,ce),()=>window.removeEventListener(wf,ce)},[Xe]);const[oe,Me]=j.useState(null),[He,he]=j.useState(null),Te=j.useCallback((ce,ae,Re,Ve="auto")=>{const dt=lo(Ut.getState()),vt=$y(dt,ce,Ve);((vt==null?void 0:vt.parameters)??[]).filter(an=>an.position!==void 0||an.required).length>0?Me({id:ce,name:(vt==null?void 0:vt.name)??ce,subGroup:ae,scope:Ve}):fe(void 0,void 0,ce,ae,Re,Ve)},[fe]),Qe=j.useCallback((ce,ae,Re,Ve)=>{Te(ce,ae,Re,Ve)},[Te]),me=j.useCallback(ce=>{Xe(!1);const ae=document.querySelector(`[data-item-index="${ce}"]`);ae&&(ae.hasAttribute("data-placeholder")?(window.dispatchEvent(new CustomEvent(Uy,{detail:{index:ce}})),requestAnimationFrame(()=>requestAnimationFrame(()=>{var Re;(Re=document.querySelector(`[data-item-index="${ce}"]`))==null||Re.scrollIntoView({behavior:"smooth",block:"center"})}))):ae.scrollIntoView({behavior:"smooth",block:"center"}))},[Xe]);j.useEffect(()=>{if(!z)return;const ce=ae=>{const Re=S||w||b||k||N;ae.key==="Escape"&&J&&!Re&&F&&H(F),ae.key==="ScrollLock"&&Xe(!We)};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[z,J,H,We,S,w,b,k,N]);const ze=Eu();pu(z?ze.quickAction:null,()=>{v(!0)}),pu(z?ze.criteriaSidebar:null,()=>{t==null||t()}),sO(z?ze.agentSwitching:[],z?Q:[],ce=>{F&&De.getState().switchMode(F,ce)});const at=(ce,ae)=>{Te(ce,void 0,void 0,ae),et()},Ze=(ce,ae,Re)=>{Te(ce,ae,void 0,Re),et()},et=()=>{u(""),h([]),Y!=null&&Y.id&&localStorage.removeItem(`openfox:draft:${Y.id}`)},ot=j.useCallback(async(ce,ae,Re,Ve)=>{const dt=IA(ce);if(dt.length>0)he({prompt:ce,paramKeys:dt,agentMode:ae,textareaContent:Re,attachments:Ve});else{ae&&F&&(Y==null?void 0:Y.mode)!==ae&&await De.getState().switchMode(F,ae);const vt=Re&&Re.trim()?`${Re.trim()}
321
+
322
+ ${ce}`:ce;ye(vt,Ve!=null&&Ve.length?Ve:void 0,{messageKind:"command",isSystemGenerated:!0}),et()}},[ye,et,Y]);return s.jsxs(c9,{value:F,children:[s.jsxs(lV,{criteriaSidebarOpen:o,onCriteriaSidebarToggle:t,messages:P,sessionId:F,children:[s.jsx(jG,{visible:!o}),s.jsx(cV,{}),N&&s.jsx(uV,{stats:N,onClose:()=>L(null)}),s.jsx(LW,{}),s.jsx(TW,{displayItems:Oe,scrollContainerRef:A,highlightedMessageId:null,onLaunchWorkflow:Qe,onScrollToTop:()=>Xe(!1),hiddenCount:we,onScrollbarGesture:_e,emptyState:P.length===0&&(Y!=null&&Y.projectId)?s.jsx(CG,{projectId:Y.projectId}):void 0}),s.jsx(SG,{input:c,setInput:u,attachments:d,setAttachments:h,dragOver:m,setDragOver:f,errorMessage:g,setErrorMessage:x,scrollToBottom:()=>{var ce,ae;return(ae=O())==null?void 0:ae.scrollTo({top:((ce=O())==null?void 0:ce.scrollHeight)??0,behavior:"smooth"})},sessionId:F,showHistory:V,history:K,selectedIndex:Z,openHistory:M,closeHistory:X,navigateUp:ne,navigateDown:re,selectCurrent:ie,isAutoScrollActive:We,setAutoScroll:Xe,onOpenMessageSearch:()=>E(!0),onOpenCommandsModal:()=>C(!0),onOpenWorkflowsModal:()=>_(!0),onSelectWorkflow:at,onSelectWorkflowWithSubGroup:Ze,onSendCommand:ot,clearInput:et}),s.jsx(AA,{isOpen:w,onClose:()=>C(!1),projectDir:Y==null?void 0:Y.workdir}),s.jsx(DA,{isOpen:b,onClose:()=>_(!1),projectDir:Y==null?void 0:Y.workdir}),s.jsx(WW,{isOpen:S,onClose:()=>v(!1),onSearchMessages:()=>E(!0),isAutoScrollActive:We,onToggleAutoScroll:Xe,textareaContent:c,onCloseComplete:Cu,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(ce,ae)=>{const Re=await dn.getState().fetchCommand(ce,Y==null?void 0:Y.workdir);Re&&ot(Re.prompt,Re.metadata.agentMode,ae)},onSelectWorkflow:(ce,ae)=>{Te(ce,void 0,void 0,ae),et()}}),oe&&s.jsx(Jk,{workflowName:oe.name,parameters:(()=>{var ae;const ce=lo(Ut.getState());return((ae=$y(ce,oe.id,oe.scope))==null?void 0:ae.parameters)??[]})(),onConfirm:ce=>{fe(void 0,void 0,oe.id,oe.subGroup,ce,oe.scope),Me(null)},onCancel:()=>Me(null)}),He&&s.jsx(Jk,{workflowName:"Command",confirmLabel:"Launch command",parameters:He.paramKeys.map((ce,ae)=>({id:ce,label:ce,position:ae})),onConfirm:ce=>{let ae=He.prompt;for(const[wt,an]of Object.entries(ce))ae=ae.replaceAll(`{{${wt}}}`,an);const{agentMode:Re,textareaContent:Ve,attachments:dt}=He;Re&&F&&(Y==null?void 0:Y.mode)!==Re&&De.getState().switchMode(F,Re);const vt=Ve&&Ve.trim()?`${Ve.trim()}
323
+
324
+ ${ae}`:ae;ye(vt,dt!=null&&dt.length?dt:void 0,{messageKind:"command",isSystemGenerated:!0}),et(),he(null)},onCancel:()=>he(null)})]}),k&&s.jsx(eG,{isOpen:k,onClose:()=>{E(!1),Cu(!0)},displayItems:Oe,onNavigate:me})]})}function OG(){var v;const[,e]=Rl("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=j.useState(null),[a,o]=j.useState([]),[c,u]=j.useState(0),[d,h]=j.useState(!0),[m,f]=j.useState(null),g=async()=>{if(t){h(!0),f(null);try{const k=await xe(`/api/sessions/${t}?full=true`);if(!k.ok){f(`Failed to load session (${k.status})`),h(!1);return}const E=await k.json();r(E.session??null),o(E.messages??[]),u(E.hiddenCount??0)}catch(k){f(k instanceof Error?k.message:"Unknown error")}finally{h(!1)}}};j.useEffect(()=>{It.getState().getSettings([...hb])},[]),j.useEffect(()=>{g()},[t]);const{showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:b,showWorkflowBars:_}=Fs(),S=j.useMemo(()=>FA(a),[a]);return d?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsx(fa,{})}):m?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx("div",{className:"text-red-400 text-sm",children:m}),s.jsx("button",{onClick:g,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):s.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((v=n==null?void 0:n.metadata)==null?void 0:v.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(ft,{className:"flex-1 print:overflow-visible",children:[s.jsx("div",{className:"pt-4",children:s.jsx(TA,{displayItems:S,showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:b,showWorkflowBars:_})}),s.jsx("div",{className:"h-8"})]})]})}const IG=788;function ej({sessionId:e,focused:t,onFocus:n,onClose:r,className:a}){var S,v,k,E;const o=j.useRef(null),[c,u]=j.useState(!1),d=j.useRef(!1),h=j.useRef(null);j.useEffect(()=>{const N=o.current;if(!N||typeof ResizeObserver>"u")return;const L=new ResizeObserver(()=>{const A=N.clientWidth>=IG;h.current!==null&&h.current!==A&&(d.current=!1),h.current=A,d.current||u(A)});return L.observe(N),()=>L.disconnect()},[]);const m=De(N=>N.panes[e]),f=(S=m==null?void 0:m.session)==null?void 0:S.projectId,g=zt(N=>f?N.projects.find(L=>L.id===f):void 0),x=((k=(v=m==null?void 0:m.session)==null?void 0:v.metadata)==null?void 0:k.title)??e.slice(0,8),w=((E=m==null?void 0:m.session)==null?void 0:E.isRunning)??!1,C=(m==null?void 0:m.pendingPathConfirmations.length)??0,b=(m==null?void 0:m.pendingQuestions.length)??0,_=j.useMemo(()=>{const N=[];return b>0&&N.push(`${b} question${b>1?"s":""}`),C>0&&N.push(`${C} confirmation${C>1?"s":""}`),N},[b,C]);return s.jsxs("div",{ref:o,"data-split-pane":e,"data-focused":t?"true":"false",className:`${a??""} @container relative flex flex-col min-w-0 min-h-0 overflow-hidden ${t?"ring-1 ring-inset ring-accent-primary/50":""}`,onClick:n,children:[s.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 border-b border-border bg-secondary shrink-0",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${w?"bg-emerald-400 animate-pulse":"bg-text-muted/40"}`,title:w?"Running":"Not running"}),s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[80px] truncate",children:(g==null?void 0:g.name)??(f?f.slice(0,10):"…")}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",title:x,children:x}),_.length>0&&s.jsx("span",{className:"flex items-center gap-1 text-[10px] text-amber-400 shrink-0",title:_.join(" · "),children:_.join(" · ")}),s.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),d.current=!0,u(L=>!L)},className:`p-1 rounded hover:bg-bg-tertiary transition-colors shrink-0 ${c?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:c?"Hide criteria sidebar":"Show criteria sidebar","aria-label":c?"Hide criteria sidebar":"Show criteria sidebar",children:s.jsx(sy,{className:"w-3.5 h-3.5"})}),s.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),r()},className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors shrink-0",title:"Close pane","aria-label":"Close pane",children:s.jsx(Ss,{className:"w-3.5 h-3.5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 bg-primary relative",children:s.jsx(zA,{sessionId:e,criteriaSidebarOpen:c,onCriteriaSidebarToggle:()=>{d.current=!0,u(N=>!N)}})})]})}function MG(e,t,n={}){const r=n.windowMinutes??30,a=n.bucketMinutes??3,o=r*6e4,c=a*6e4,u=Math.max(1,Math.floor(o/c)),d=t-o,h=new Array(u).fill(0);for(const m of e){const f=ZT(m);if(!f)continue;const g=new Map;for(const x of f.dataPoints){const w=new Date(x.timestamp).getTime();if(Number.isNaN(w)||w<d||w>t)continue;const C=Math.min(u-1,Math.max(0,Math.floor((w-d)/c))),b=g.get(C)??[];g.set(C,[...b,x.generationSpeed])}for(const[x,w]of g){const C=w.reduce((b,_)=>b+_,0)/w.length;h[x]=(h[x]??0)+C}}return h.map((m,f)=>({x:d+f*c,y:m}))}const Wy=280,Zi=44,Cf=4;function PG(e,t){const n=e.map((a,o)=>{const c=o/Math.max(1,e.length-1)*Wy,u=Zi-Cf-a.y/t*(Zi-Cf*2);return{x:c,y:u}});if(n.length===0)return"";if(n.length===1)return`M ${n[0].x.toFixed(1)} ${n[0].y.toFixed(1)}`;let r=`M ${n[0].x.toFixed(1)} ${n[0].y.toFixed(1)}`;for(let a=0;a<n.length-1;a++){const o=n[Math.max(0,a-1)],c=n[a],u=n[a+1],d=n[Math.min(n.length-1,a+2)],h=c.x+(u.x-o.x)/6,m=c.y+(u.y-o.y)/6,f=u.x-(d.x-c.x)/6,g=u.y-(d.y-c.y)/6;r+=` C ${h.toFixed(1)} ${m.toFixed(1)}, ${f.toFixed(1)} ${g.toFixed(1)}, ${u.x.toFixed(1)} ${u.y.toFixed(1)}`}return r}function BG(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function $G(e,t,n){if(n<=0||t<=0)return Math.min(100,Math.max(0,e));const r=Math.min(t/2/n*100,50);return Math.min(Math.max(e,r),100-r)}function FG(){const e=De(v=>v.openSessionIds),t=De($T(v=>Object.fromEntries(e.map(k=>{var E;return[k,(E=v.panes[k])==null?void 0:E.messages]})))),[n,r]=j.useState(()=>Date.now()),[a,o]=j.useState(null),[c,u]=j.useState(null),d=j.useRef(null),h=j.useRef(null);j.useEffect(()=>{const v=setInterval(()=>r(Date.now()),6e4);return()=>clearInterval(v)},[]),j.useEffect(()=>{const v=d.current,k=h.current;!v||!k||u({width:k.offsetWidth,container:v.clientWidth})},[a]);const m=j.useMemo(()=>Object.values(t).filter(v=>!!v),[t]),f=j.useMemo(()=>MG(m,n),[m,n]),g=j.useMemo(()=>f.reduce((v,k)=>Math.max(v,k.y),0),[f]),x=j.useMemo(()=>g>0?PG(f,g):"",[f,g]),w=f.length-1,C=v=>v/Math.max(1,w)*100,b=v=>(Zi-Cf-v/g*(Zi-Cf*2))/Zi*100,_=a!==null?$G(C(a),(c==null?void 0:c.width)??0,(c==null?void 0:c.container)??0):0,S=v=>{const k=v.currentTarget.getBoundingClientRect();if(k.width<=0)return;const E=(v.clientX-k.left)/k.width;o(Math.min(w,Math.max(0,Math.round(E*w))))};return s.jsxs("div",{"data-testid":"aggregate-stats",title:"Combined generation speed across open panes, last 30 min (3-min buckets)",children:[s.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:"Generation"}),g>0&&s.jsxs("span",{className:"text-[10px] text-text-muted",title:"Peak combined generation speed in the window",children:[Math.round(g)," tok/s"]})]}),g>0?s.jsxs("div",{"data-testid":"aggregate-chart",ref:d,className:"relative",onMouseMove:S,onMouseLeave:()=>o(null),children:[s.jsxs("svg",{viewBox:`0 0 ${Wy} ${Zi}`,className:"w-full h-9",preserveAspectRatio:"none","aria-label":"Generation speed over the last 30 minutes",role:"img",children:[s.jsx("path",{d:`${x} L ${Wy} ${Zi} L 0 ${Zi} Z`,fill:"currentColor",className:"text-accent-primary/15"}),s.jsx("path",{d:x,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",className:"text-accent-primary"})]}),a!==null&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pointer-events-none absolute w-1.5 h-1.5 rounded-full bg-accent-primary -translate-x-1/2 -translate-y-1/2",style:{left:`${C(a)}%`,top:`${b(f[a].y)}%`}}),s.jsxs("div",{ref:h,"data-testid":"aggregate-tooltip",className:"pointer-events-none absolute z-10 -translate-x-1/2 -translate-y-full whitespace-nowrap rounded bg-bg-tertiary px-1.5 py-0.5 text-[10px] text-text-secondary shadow",style:{left:`${_}%`,top:`${b(f[a].y)}%`},children:[BG(f[a].x)," · ",Math.round(f[a].y)," tok/s"]})]})]}):s.jsx("p",{className:"text-xs text-text-muted",children:"No generation in the last 30 min"})]})}function tj(e,t){return t??e.slice(0,8)}function zG({collapsed:e=!1,layout:t,onLayoutChange:n}){const r=De(b=>b.openSessionIds),a=De(b=>{var _;return b.focusedSessionId??((_=b.currentSession)==null?void 0:_.id)}),o=De(b=>b.panes),c=De(b=>b.sessions),u=De(b=>b.focusPane),d=De(b=>b.closePane),h=De(b=>b.reorderPane),m=De(b=>b.openPane),f=De(b=>b.isPaneOpen),g=zt(b=>b.projects),x=j.useMemo(()=>new Map(g.map(b=>[b.id,b])),[g]),w=j.useMemo(()=>[...c].sort((b,_)=>b.isRunning!==_.isRunning?b.isRunning?-1:1:new Date(_.updatedAt).getTime()-new Date(b.updatedAt).getTime()),[c]),C=b=>{f(b.id)?u(b.id):m(b.id,{focus:!0})};return s.jsxs("aside",{"data-testid":"split-control-panel",className:`shrink-0 border-r border-border bg-secondary flex flex-col min-h-0 transition-[width] duration-200 ${e?"w-0 overflow-hidden border-r-0":"w-56"}`,"aria-hidden":e,children:[s.jsxs("div",{className:"flex items-center gap-1 px-2 h-9 border-b border-border shrink-0",children:[s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted whitespace-nowrap",children:"Split view"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:r.length}),s.jsxs("div",{className:"flex items-center rounded bg-bg-tertiary p-0.5 ml-1",role:"group","aria-label":"Pane layout",children:[s.jsx("button",{type:"button",onClick:()=>n("columns"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${t==="columns"?"bg-accent-primary/25 text-text-primary":"text-text-muted hover:text-text-primary"}`,title:"Stack panes as columns","aria-label":"Columns layout","aria-pressed":t==="columns",children:"Columns"}),s.jsx("button",{type:"button",onClick:()=>n("grid"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${t==="grid"?"bg-accent-primary/25 text-text-primary":"text-text-muted hover:text-text-primary"}`,title:"Arrange panes in a grid","aria-label":"Grid layout","aria-pressed":t==="grid",children:"Grid"})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[s.jsxs("div",{className:"px-3 pt-3 pb-2",children:[s.jsx("h2",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted mb-1",children:"Open panes"}),r.length===0?s.jsx("p",{className:"text-xs text-text-muted",children:"No panes open — pick a session below."}):s.jsx("ul",{className:"space-y-0.5",children:r.map((b,_)=>{var k,E,N;const S=b===a,v=tj(b,(N=(E=(k=o[b])==null?void 0:k.session)==null?void 0:E.metadata)==null?void 0:N.title);return s.jsxs("li",{className:`group flex items-center gap-1 rounded px-1.5 py-1 cursor-pointer ${S?"bg-bg-tertiary":"hover:bg-bg-tertiary/50"}`,onClick:()=>u(b),"data-open-pane":b,children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${S?"bg-accent-primary":"bg-text-muted/40"}`}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",title:v,children:v}),s.jsxs("div",{className:"flex items-center gap-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),h(b,-1)},disabled:_===0,className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary disabled:opacity-30 disabled:cursor-default",title:"Move pane left","aria-label":"Move pane left",children:s.jsx(mb,{className:"w-3 h-3"})}),s.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),h(b,1)},disabled:_===r.length-1,className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary disabled:opacity-30 disabled:cursor-default",title:"Move pane right","aria-label":"Move pane right",children:s.jsx(yn,{className:"w-3 h-3"})}),s.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),d(b)},className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary",title:"Close pane","aria-label":"Close pane",children:s.jsx(Ss,{className:"w-3 h-3"})})]})]},b)})})]}),s.jsx("div",{className:"px-3 pt-3 pb-4 border-t border-border",children:s.jsx(FG,{})}),s.jsxs("div",{className:"px-3 pt-3 pb-4 border-t border-border",children:[s.jsx("h2",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted mb-1",children:"Sessions"}),w.length===0?s.jsx("p",{className:"text-xs text-text-muted",children:"No sessions yet."}):s.jsx("ul",{className:"space-y-0.5",children:w.map(b=>{var S;const _=f(b.id);return s.jsxs("li",{className:"flex items-center gap-1.5 rounded px-1.5 py-1 cursor-pointer hover:bg-bg-tertiary/50",onClick:()=>C(b),"data-session-item":b.id,title:_?"Focus pane":"Open in split view",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${b.isRunning?"bg-emerald-400 animate-pulse":"bg-text-muted/40"}`}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",children:tj(b.id,b.title)}),s.jsx("span",{className:"text-[9px] text-accent-primary truncate max-w-[60px] shrink-0",children:((S=x.get(b.projectId))==null?void 0:S.name)??b.projectId.slice(0,8)})]},b.id)})})]})]})]})}function HG({controlOpen:e=!0}){const[,t]=wn(),n=De(m=>m.openSessionIds),r=De(m=>{var f;return m.focusedSessionId??((f=m.currentSession)==null?void 0:f.id)}),a=De(m=>m.focusPane),o=De(m=>m.closePane),[c,u]=j.useState(i3);j.useEffect(()=>{a3(c)},[c]);const d=j.useRef(n.length);j.useEffect(()=>{const m=d.current;d.current=n.length,m>0&&n.length===0&&t("/")},[n.length,t]);const h=n.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("p",{className:"text-sm text-text-muted px-4 text-center",children:"No panes open — pick a session on the left to open it in split view."})}):c==="columns"?s.jsx("div",{className:"flex gap-px bg-border flex-1 min-w-0 min-h-0",children:n.map(m=>{const f=m===r;return s.jsx(ej,{className:"flex-1",sessionId:m,focused:f,onFocus:()=>a(m),onClose:()=>o(m)},m)})}):s.jsx("div",{className:`grid gap-px bg-border flex-1 min-w-0 min-h-0 ${n.length<=1?"grid-cols-1":"grid-cols-2"}`,children:n.map(m=>{const f=m===r;return s.jsx(ej,{sessionId:m,focused:f,onFocus:()=>a(m),onClose:()=>o(m)},m)})});return s.jsxs("div",{className:"flex-1 min-w-0 flex h-full min-h-0 bg-primary",children:[s.jsx(zG,{collapsed:!e,layout:c,onLayoutChange:u}),h]})}function nj({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,o]=j.useState(""),c=j.useRef(null);j.useEffect(()=>{e&&(o(""),setTimeout(()=>{var d;Vt()&&((d=c.current)==null||d.focus())},100))},[e]);const u=d=>{d.preventDefault(),a.trim()&&n(a)};return s.jsx(jt,{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(Ms,{ref:c,type:"password",value:a,onChange:d=>o(d.target.value),placeholder:"Enter password",autoFocus:Vt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(st,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(st,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function UG({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return s.jsx("div",{className:"flex justify-center py-6",children:s.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,o)=>{const c=o+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[o]}),o<t-1&&s.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${u?"bg-accent-primary":"bg-border"}`})]},o)})})})}function VG({onNext:e}){const[t,n]=j.useState([]),[r,a]=j.useState([]),[o,c]=j.useState(!1),[u,d]=j.useState(null),[h,m]=j.useState(null),[f,g]=j.useState(null);j.useEffect(()=>{x()},[]);async function x(){try{const E=await xe("/api/providers");if(E.ok){const L=(await E.json()).providers.map(A=>({id:A.id,name:A.name,url:A.url,backend:A.backend,model:null,apiKey:A.apiKey,isLocal:A.isLocal,thinkingField:A.thinkingField,sendReasoningInMessages:A.sendReasoningInMessages,models:A.models}));n(L),a(L)}}catch{}}async function w(E){const N=E.id.startsWith("temp-"),L=r.some(I=>I.id===E.id),A=r.length===0&&u===null,O=BA(E);try{let I;if(N){const B=await xe("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!B.ok)throw new Error("Failed to create provider");const z=await B.json();I={...E,id:z.provider.id,model:null}}else{if(!(await xe(`/api/providers/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).ok)throw new Error("Failed to update provider");I={...E,model:null}}const F=B=>B.some(z=>z.id===I.id)?B.map(z=>z.id===I.id?I:z):[...B,I];a(F),n(F),A&&!L&&e({providers:[I]})}catch{if(N){const I={...E,model:null};a(F=>[...F,I])}}}function C(){d(null),c(!0)}function b(E){d(E),c(!0)}function _(){c(!1),d(null)}function S(E){m(E),t.some(L=>L.id===E)?xe(`/api/providers/${E}`,{method:"DELETE"}).then(()=>{a(r.filter(L=>L.id!==E)),n(t.filter(L=>L.id!==E)),m(null)}).catch(()=>m(null)):(a(r.filter(L=>L.id!==E)),m(null))}function v(){const E=r.filter(N=>!N.id.startsWith("temp-"));e({providers:E})}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(E=>s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:iE(E.backend)}),s.jsx("span",{className:"text-text-primary font-medium",children:E.name}),s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${E.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:E.isLocal?"local":"api"})]}),s.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:E.url}),E.model&&s.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",E.model]})]}),s.jsx("div",{className:"flex items-center gap-1",children:f===E.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>S(E.id),disabled:h===E.id,className:"px-2 py-1 text-xs text-red-500 hover:text-red-400 bg-red-500/10 rounded transition-colors disabled:opacity-50",children:h===E.id?"Deleting...":"Confirm"}),s.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>b(E),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),s.jsx("button",{onClick:()=>g(E.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:s.jsx(Si,{})})]})})]},E.id))}):s.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:s.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),s.jsxs("button",{onClick:C,"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[s.jsx(as,{className:"w-4 h-4"}),"Add Provider"]}),s.jsx("button",{onClick:v,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($A,{isOpen:o,onClose:_,onSave:w,initialStep:1,editProvider:u??void 0})]})}function WG({onNext:e}){const[t,n]=j.useState(""),[r,a]=j.useState(!1);return j.useEffect(()=>{xe("/api/config").then(o=>o.json()).then(o=>{o.workdir?n(o.workdir):fetch(vs("/api/directories?path=")+encodeURIComponent("/home")).then(c=>c.json()).then(c=>{c.current&&n(c.current)}).catch(()=>{})}).catch(()=>{fetch(vs("/api/directories?path=")+encodeURIComponent("/home")).then(o=>o.json()).then(o=>{o.current&&n(o.current)}).catch(()=>{})})},[]),s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),s.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&s.jsx(qf,{initialPath:t||void 0,onSelect:o=>{n(o),a(!1)},onClose:()=>a(!1)}),s.jsx("button",{onClick:()=>e({workdir:t}),disabled:!t,"data-testid":"onboarding-workdir-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function GG(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function qG(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??GG(r.id)});return t},[e])}function KG({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 YG({backend:e,url:t,model:n,apiKey:r,onBackendChange:a,onUrlChange:o,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=>o(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 XG(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 QG(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function JG({enabled:e,hasOptions:t,selectedRef:n,visionModelOptions:r,onProviderModelSelect:a,noOptionsMessage:o,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(KG,{value:n,options:r,onChange:a})]}):s.jsx("p",{className:"text-sm text-text-muted italic",children:o}),s.jsx(YG,{...u}),c]}):null}function ZG({onNext:e}){const[t,n]=j.useState(!1),[r,a]=j.useState("http://localhost:11434"),[o,c]=j.useState("qwen3.5:0.8b"),[u,d]=j.useState(""),[h,m]=j.useState("ollama"),[f,g]=j.useState([]),[x,w]=j.useState(""),{copied:C,copy:b}=xT();j.useEffect(()=>{xe("/api/config").then(L=>L.json()).then(L=>{L.visionFallback&&(n(L.visionFallback.enabled),L.visionFallback.providerModelRef?w(L.visionFallback.providerModelRef):(a(L.visionFallback.url??"http://localhost:11434"),c(L.visionFallback.model??"qwen3.5:0.8b"),d(L.visionFallback.apiKey??""),L.visionFallback.backend&&m(L.visionFallback.backend))),L.providers&&g(L.providers)}).catch(()=>{})},[]);const _=qG(f),S=QG(w,a,c),v=XG(m,w,a,c);function k(L){if(L){e({});return}e(t&&x?{visionFallback:{enabled:t,providerModelRef:x,timeout:120}}:{visionFallback:{enabled:t,url:r,model:o,timeout:120,backend:h,providerModelRef:"",apiKey:h==="openai"?u:""}})}const E=_.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:()=>b("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:C?s.jsx(zs,{className:"w-4 h-4 text-accent-primary"}):s.jsx(H3,{className:"w-4 h-4"})})]}),s.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",s.jsx("strong",{children:"OpenAI"})," backend type."]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:L=>n(L.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),s.jsx(JG,{enabled:t,hasOptions:E,selectedRef:x,visionModelOptions:_,onProviderModelSelect:S,backend:h,url:r,model:o,apiKey:u,onBackendChange:v,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 eq({onComplete:e}){const[t,n]=j.useState(1),[r,a]=j.useState(!1),[o,c]=j.useState({});async function u(f){c(g=>({...g,providers:f.providers})),n(2)}async function d(f){c(g=>({...g,...f})),n(3)}async function h(f){a(!0);try{if(!(await xe("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:o.workdir,visionFallback:f.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(g){console.error("Failed to save onboarding data:",g),a(!1)}}const m=f=>{n(f)};return s.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[s.jsx(Mu,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),s.jsx(UG,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:m}),s.jsx("div",{className:"max-w-xl mx-auto",children:r?s.jsxs("div",{className:"text-center",children:[s.jsx(as,{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(VG,{onNext:u}),t===2&&s.jsx(WG,{onNext:d}),t===3&&s.jsx(ZG,{onNext:h})]})})]})}function tq({projectId:e}){var m;const[,t]=wn(),n=De(f=>f.sessionsWithPendingConfirmations),r=De(f=>{var g;return(g=f.currentSession)==null?void 0:g.id}),a=De(f=>f.crossSessionConfirmations),o=De(f=>f.sessions),c=n.find(f=>f!==r);if(!c)return null;const u=o.find(f=>f.id===c),d=(u==null?void 0:u.title)??c.slice(0,6),h=((m=a[c])==null?void 0:m.length)??0;return s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 cursor-pointer hover:bg-amber-500/20 transition-colors",onClick:()=>t(e?`/p/${e}/s/${c}`:`/s/${c}`),role:"button",tabIndex:0,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&t(e?`/p/${e}/s/${c}`:`/s/${c}`)},children:[s.jsx(zf,{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 Fx="openfox_updated_to",zx="update_pending";function nq(){const[e,t]=j.useState(!1),n=localStorage.getItem(Fx),r=localStorage.getItem(zx);j.useEffect(()=>{if(!n||!r)return;const o=setTimeout(()=>{localStorage.removeItem(Fx),localStorage.removeItem(zx),t(!0)},8e3);return()=>clearTimeout(o)},[n,r]);const a=()=>{localStorage.removeItem(Fx),localStorage.removeItem(zx),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(zs,{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(_b,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Xt.getState().loadUserPresets(),Xt.getState().applySavedTheme());function jv(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function Ev(){return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(fa,{})})}function rq({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Rl("/p/:projectId"),r=n==null?void 0:n.projectId,a=De(d=>d.connectionStatus),o=zt(d=>d.currentProject),c=jv();return B3({canLoad:a==="connected"||c,projectId:r,currentProjectId:o==null?void 0:o.id}),!o||o.id!==r?s.jsx(Ev,{}):s.jsxs(s.Fragment,{children:[s.jsx(KT,{projectId:r,isOpen:e,onClose:t}),s.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:s.jsx(l9,{})})]})}function sq({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=Rl("/p/:projectId/s/:sessionId"),o=a==null?void 0:a.projectId,c=a==null?void 0:a.sessionId,[,u]=wn(),d=De(C=>C.connectionStatus),h=De(C=>C.currentSession),m=De(C=>C.error),f=De(C=>C.clearError),g=zt(C=>C.currentProject),x=jv();return $3({canLoad:d==="connected"||x,projectId:o,sessionId:c,currentProjectId:g==null?void 0:g.id,currentSessionId:h==null?void 0:h.id}),j.useEffect(()=>{(m==null?void 0:m.code)==="NOT_FOUND"&&o&&(f(),u(`/p/${o}`))},[m,o,f,u]),!g||g.id!==o?s.jsx(Ev,{}):s.jsxs(s.Fragment,{children:[s.jsx(KT,{projectId:o,isOpen:e,onClose:t}),s.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[s.jsx(tq,{projectId:o}),s.jsx(zA,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function iq(){const e=nn(r=>r.fetchConfig),[,t]=wn();async function n(){await e(),t("/")}return s.jsx(ft,{className:"flex-1",children:s.jsx(eq,{onComplete:n})})}function aq(){const{connectionStatus:e}=R3(),t=nn(Q=>Q.fetchConfig),n=nn(Q=>Q.refreshProviderModels),r=nn(Q=>Q.providers),a=nn(Q=>Q.activeProviderId),[,o]=wn(),c=jv(),[u,d]=j.useState(!1);j.useEffect(()=>{(e==="connected"||c)&&t().then(()=>{d(!0),It.getState().getSettings([...hb,Ne.DISPLAY_THEME,Ne.DISPLAY_USER_PRESETS,Ne.DISPLAY_CUSTOM_CSS,Ne.KEYBINDINGS,Ne.FEATURES_PER_SESSION_MCP]),du.getState().fetchServers()})},[e,c,t]),j.useEffect(()=>{u&&a&&n(a).then(()=>{const Q=nn.getState().defaultModelSelection;(Q?Q.split("/")[0]:null)!==a&&t()})},[u,a,n,t]);const h=It(Q=>Q.settings);j.useEffect(()=>{u&&r.length===0&&o("/onboarding")},[u,r.length]),j.useEffect(()=>{const{applyPreset:Q,applyTokens:K,setFollowSystemTheme:Z,initSystemThemeListener:V}=Xt.getState(),M=h[Ne.DISPLAY_THEME],X=h[Ne.DISPLAY_USER_PRESETS],ne=h[Ne.DISPLAY_FOLLOW_SYSTEM_THEME];if(X&&localStorage.setItem("openfox:userPresets",X),M){localStorage.setItem("openfox:theme",M);try{const ie=JSON.parse(M);ie.preset&&ie.tokens?(Q(ie.preset),Xt.setState({basePreset:ie.preset}),K(ie.tokens)):ie.preset?Q(ie.preset):ie.tokens&&K(ie.tokens)}catch{Q("dark")}}else Q("system");ne!==void 0&&Xt.getState().followSystemTheme!==(ne==="true")&&Z(ne==="true");const re=V();return()=>re()},[h[Ne.DISPLAY_THEME],h[Ne.DISPLAY_USER_PRESETS]]),j.useEffect(()=>{const Q=h[Ne.DISPLAY_CUSTOM_CSS]??"";let K=document.getElementById("custom-css");K||(K=document.createElement("style"),K.id="custom-css",document.head.appendChild(K)),K.textContent=Q},[h[Ne.DISPLAY_CUSTOM_CSS]]);const[m,f]=j.useState(!1);j.useEffect(()=>{const Q=It.getState().settings[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(Q===void 0||Q==="false")return;let K=!1;if(localStorage.getItem("update_pending")==="true"&&(K=!0,localStorage.removeItem("update_pending")),u){const V=nn.getState().version,M=jb();HO(V,M)&&(K=!0),zO(V)}K&&f(!0)},[h[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],u]);const g=()=>{const Q=localStorage.getItem("openfox:leftSidebar");return Q!==null?Q==="true":!0},x=()=>{const Q=localStorage.getItem("openfox:rightSidebar");return Q!==null?Q==="true":!0},[w,C]=j.useState(g),[b,_]=j.useState(x),[S,v]=j.useState(!1),[k,E]=j.useState(!1),[N,L]=j.useState(!1),A=Y5();j.useEffect(()=>{const Q=()=>{L(window.innerWidth<768)};return Q(),window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]);const[O]=wn(),I=/^\/p\/[^/]+$/.test(O),F=cE(),[B,z]=j.useState(!1),Y=j.useRef(!1);j.useEffect(()=>{Y.current&&!F&&De.getState().exitSplitView(),Y.current=F},[F]),j.useEffect(()=>{if(!F){z(!1);return}let Q=!1;const K=o3();return(K&&K.openSessionIds.length>0?De.getState().enterSplitView(K.openSessionIds,K.focusedSessionId??void 0):Promise.resolve()).then(()=>{Q||z(!0)}),()=>{Q=!0}},[F]);const q=N?S:I?!0:w,W=N?k:b,ee=()=>{N?v(!S):C(!w)},J=()=>{N?E(!k):_(!b)};j.useEffect(()=>{N||localStorage.setItem("openfox:leftSidebar",String(w))},[w,N]),j.useEffect(()=>{N||localStorage.setItem("openfox:rightSidebar",String(b))},[b,N]),j.useEffect(()=>{(e==="connected"||c)&&t()},[e,t,c]);const H=De(Q=>Q.showPasswordModal),P=De(Q=>Q.passwordModalRetry),D=De(Q=>Q.submitPassword),U=De(Q=>Q.cancelPassword),[$]=Rl("/p/:projectId/s/:sessionId/readonly");return!$&&e!=="connected"&&!H&&!c?s.jsxs(s.Fragment,{children:[s.jsx(nj,{isOpen:!0,isRetry:P,onSubmit:D,onCancel:U}),s.jsx("div",{className:"h-screen flex items-center justify-center",children:s.jsx(dO,{text:"Connecting to server..."})})]}):$?s.jsx(OG,{}):s.jsxs(s.Fragment,{children:[s.jsx(nj,{isOpen:H,isRetry:P,onSubmit:D,onCancel:U}),s.jsxs("div",{className:"flex flex-col",style:{height:N?`calc(${A.offsetTop}px + ${A.height}px)`:"100vh"},children:[s.jsx(e9,{}),s.jsx(qU,{onMenuClick:ee,onCriteriaToggle:J}),s.jsx("div",{className:"@container flex-1 flex overflow-hidden",children:s.jsxs(DD,{children:[s.jsx(Xo,{path:"/onboarding",children:s.jsx(iq,{})}),s.jsx(Xo,{path:"/split-view",children:B?s.jsx(HG,{controlOpen:q}):s.jsx(Ev,{})}),s.jsx(Xo,{path:"/p/:projectId/s/:sessionId",children:s.jsx(sq,{sidebarOpen:q,onSidebarToggle:ee,rightSidebarOpen:W,onRightSidebarToggle:J})}),s.jsx(Xo,{path:"/p/:projectId/new",children:s.jsx(o9,{})}),s.jsx(Xo,{path:"/p/:projectId",children:s.jsx(rq,{sidebarOpen:q,onSidebarToggle:ee})}),s.jsx(Xo,{path:"/",children:s.jsx(a9,{})})]})})]}),s.jsx(nq,{}),s.jsx(vT,{isOpen:m,onClose:()=>f(!1),since:FO()??void 0})]})}const Th=window.location.pathname.match(/\/p\/[^/]+\/s\/([0-9a-fA-F-]+)/);Th!=null&&Th[1]&&Q5(Th[1]);hD.createRoot(document.getElementById("root")).render(s.jsx(ps.StrictMode,{children:s.jsx(dj,{base:rE,children:s.jsx(aq,{})})}));